line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## Stripe API - ~/lib/Net/API/Stripe/Billing/Plan.pm |
3
|
|
|
|
|
|
|
## Version v0.100.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2019 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2019/11/02 |
7
|
|
|
|
|
|
|
## Modified 2020/05/15 |
8
|
|
|
|
|
|
|
## |
9
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
## The product in Billing is the same as the core Product class. |
11
|
|
|
|
|
|
|
## https://stripe.com/docs/api/service_products/object |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
## For product objects, see Net::API::Stripe::Product |
14
|
|
|
|
|
|
|
BEGIN |
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
use strict; |
17
|
2
|
|
|
2
|
|
24401701
|
use warnings; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
63
|
|
18
|
2
|
|
|
2
|
|
9
|
use parent qw( Net::API::Stripe::Generic ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
60
|
|
19
|
2
|
|
|
2
|
|
9
|
use vars qw( $VERSION ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
10
|
|
20
|
2
|
|
|
2
|
|
138
|
our( $VERSION ) = 'v0.100.0'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
109
|
|
21
|
2
|
|
|
2
|
|
40
|
}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use strict; |
24
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
37
|
|
25
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
968
|
|
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
1
|
|
|
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
1
|
|
|
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
1
|
|
|
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
|
## Not part of the official api documentation, but found in sub object data like in here |
34
|
|
|
|
|
|
|
## https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments |
35
|
0
|
|
|
0
|
1
|
|
|
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
|
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
1
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
1
|
|
|
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
1
|
|
|
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
1
|
|
|
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
0
|
1
|
|
|
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
0
|
1
|
|
|
52
|
|
|
|
|
|
|
## Not part of the official api documentation, but found in sub object data like in here |
53
|
0
|
|
|
0
|
1
|
|
## https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
0
|
|
|
0
|
1
|
|
|
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
1
|
|
=encoding utf8 |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
0
|
1
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
0
|
1
|
|
Net::API::Stripe::Billing::Plan - A Stripe Plan Object |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
1
|
|
=head1 SYNOPSIS |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
|
my $plan = $stripe->plan({ |
68
|
|
|
|
|
|
|
# Or you can just use 1. $stripe->true returns a Module::Generic::Boolean object |
69
|
0
|
|
|
0
|
1
|
|
active => $stripe->true, |
70
|
|
|
|
|
|
|
amount => 2000, |
71
|
0
|
|
|
0
|
1
|
|
billing_scheme => 'per_unit', |
72
|
|
|
|
|
|
|
count => 12, |
73
|
0
|
|
|
0
|
1
|
|
currency => 'jpy', |
74
|
|
|
|
|
|
|
interval => 'month', |
75
|
0
|
|
|
0
|
1
|
|
interval_count => 1, |
76
|
|
|
|
|
|
|
metadata => { transaction_id => 1212, customer_id => 123 }, |
77
|
|
|
|
|
|
|
name => 'Professional services subscription gold plan', |
78
|
|
|
|
|
|
|
statement_description => 'Provider, Inc Pro Services', |
79
|
0
|
|
|
0
|
1
|
|
}); |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
0
|
1
|
|
=head1 VERSION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
v0.100.0 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DESCRIPTION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Plans define the base price, currency, and billing cycle for subscriptions. For example, you might have a ¥5/month plan that provides limited access to your products, and a ¥15/month plan that allows full access. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 new( %ARG ) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Creates a new L<Net::API::Stripe::Billing::Plan> object. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 METHODS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 id string |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Unique identifier for the object. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 object string, value is "plan" |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
String representing the object’s type. Objects of the same type share the same value. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 active boolean |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Whether the plan is currently available for new subscriptions. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 aggregate_usage string |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Specifies a usage aggregation strategy for plans of I<usage_type=metered>. Allowed values are I<sum> for summing up all usage during a period, I<last_during_period> for picking the last usage record reported within a period, I<last_ever> for picking the last usage record ever (across period bounds) or I<max> which picks the usage record with the maximum reported usage during a period. Defaults to I<sum>. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 amount positive integer or zero |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The amount in JPY to be charged on the interval specified. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 amount_decimal decimal string |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Same as I<amount>, but contains a decimal value with at most 12 decimal places. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 billing_scheme string |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Describes how to compute the price per period. Either I<per_unit> or I<tiered>. I<per_unit> indicates that the fixed amount (specified in I<amount>) will be charged per unit in I<quantity> (for plans with I<usage_type=licensed>), or per unit of total usage (for plans with I<usage_type=metered>). I<tiered> indicates that the unit pricing will be computed using a tiering strategy as defined using the I<tiers> and I<tiers_mode> attributes. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 count integer |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
For fixed_count installment plans, this is the number of installment payments your customer will make to their credit card. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Not part of the official api documentation, but found in sub object data like in here |
130
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 created timestamp |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Time at which the object was created. Measured in seconds since the Unix epoch. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 currency currency |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Three-letter ISO currency code, in lowercase. Must be a supported currency. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 deleted boolean |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Appears only when the plan has been deleted. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 interval string |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
One of I<day>, I<week>, I<month> or I<year>. The frequency with which a subscription should be billed. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 interval_count positive integer |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
The number of intervals (specified in the I<interval> property) between subscription billings. For example, I<interval=month> and I<interval_count=3> bills every 3 months. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 livemode boolean |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Has the value I<true> if the object exists in live mode or the value I<false> if the object exists in test mode. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 metadata hash |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 name string |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This is an undocumented property, which appears in data returned by Stripe. This contains the name of the plan. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 nickname string |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
A brief description of the plan, hidden from customers. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 product string (expandable) |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
The product whose pricing this plan determines. When expanded, this is a L<Net::API::Stripe::Product> object. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 statement_description string |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This is an undocumented property, which appears in data returned by Stripe. This contains a description of the plan. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 statement_descriptor string |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This is an undocumented property, which appears in data returned by Stripe. This contains a description of the plan. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 tiers array of hashes |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Each element represents a pricing tier. This parameter requires I<billing_scheme> to be set to I<tiered>. See also the documentation for I<billing_scheme>. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This is an array of L<Net::API::Stripe::Billing::Plan::Tiers> objects. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 tiers_mode string |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Defines if the tiering price should be graduated or volume based. In volume-based tiering, the maximum quantity within a period determines the per unit price, in graduated tiering pricing can successively change as the quantity grows. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head2 transform_usage hash |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with tiers. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
This is a L<Net::API::Stripe::Billing::Plan::TransformUsage> object. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 trial_period_days positive integer |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Default number of trial days when subscribing a customer to this plan using I<trial_from_plan=true>. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 type string |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Type of installment plan, one of fixed_count. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Not part of the official api documentation, but found in sub object data like in here |
205
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments> |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head2 usage_type string |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Configures how the quantity per period should be determined, can be either I<metered> or I<licensed>. I<licensed> will automatically bill the I<quantity> set for a plan when adding it to a subscription, I<metered> will aggregate the total usage based on usage records. Defaults to I<licensed>. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 API SAMPLE |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
{ |
214
|
|
|
|
|
|
|
"id": "expert-monthly-jpy", |
215
|
|
|
|
|
|
|
"object": "plan", |
216
|
|
|
|
|
|
|
"active": true, |
217
|
|
|
|
|
|
|
"aggregate_usage": null, |
218
|
|
|
|
|
|
|
"amount": 8000, |
219
|
|
|
|
|
|
|
"amount_decimal": "8000", |
220
|
|
|
|
|
|
|
"billing_scheme": "per_unit", |
221
|
|
|
|
|
|
|
"created": 1507273129, |
222
|
|
|
|
|
|
|
"currency": "jpy", |
223
|
|
|
|
|
|
|
"interval": "month", |
224
|
|
|
|
|
|
|
"interval_count": 1, |
225
|
|
|
|
|
|
|
"livemode": false, |
226
|
|
|
|
|
|
|
"metadata": {}, |
227
|
|
|
|
|
|
|
"nickname": null, |
228
|
|
|
|
|
|
|
"product": "prod_fake123456789", |
229
|
|
|
|
|
|
|
"tiers": null, |
230
|
|
|
|
|
|
|
"tiers_mode": null, |
231
|
|
|
|
|
|
|
"transform_usage": null, |
232
|
|
|
|
|
|
|
"trial_period_days": null, |
233
|
|
|
|
|
|
|
"usage_type": "licensed" |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 ACTUAL API DATA RETURNED |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
As you can see, there are extra properties: I<name>, I<statement_description> and I<statement_descriptior> |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
{ |
241
|
|
|
|
|
|
|
"id": "professional-monthly-jpy", |
242
|
|
|
|
|
|
|
"object": "plan", |
243
|
|
|
|
|
|
|
"active": true, |
244
|
|
|
|
|
|
|
"aggregate_usage": null, |
245
|
|
|
|
|
|
|
"amount": 8000, |
246
|
|
|
|
|
|
|
"amount_decimal": "8000", |
247
|
|
|
|
|
|
|
"billing_scheme": "per_unit", |
248
|
|
|
|
|
|
|
"created": 1541833564, |
249
|
|
|
|
|
|
|
"currency": "jpy", |
250
|
|
|
|
|
|
|
"interval": "month", |
251
|
|
|
|
|
|
|
"interval_count": 1, |
252
|
|
|
|
|
|
|
"livemode": false, |
253
|
|
|
|
|
|
|
"metadata": {}, |
254
|
|
|
|
|
|
|
"name": "MyShop, Inc monthly membership", |
255
|
|
|
|
|
|
|
"nickname": null, |
256
|
|
|
|
|
|
|
"product": "prod_fake123456789", |
257
|
|
|
|
|
|
|
"statement_description": null, |
258
|
|
|
|
|
|
|
"statement_descriptor": null, |
259
|
|
|
|
|
|
|
"tiers": null, |
260
|
|
|
|
|
|
|
"tiers_mode": null, |
261
|
|
|
|
|
|
|
"transform_usage": null, |
262
|
|
|
|
|
|
|
"trial_period_days": null, |
263
|
|
|
|
|
|
|
"usage_type": "licensed" |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head1 HISTORY |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head2 v0.1 |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Initial version |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 STRIPE HISTORY |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head2 2018-02-05 |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
Each plan object is now linked to a product object with I<type=service>. The plan object fields I<statement_descriptor> and I<name> attributes have been moved to product objects. Creating a plan now requires passing a I<product> attribute to I<POST /v1/plans>. This may be either an existing product ID or a dictionary of product fields, so that you may continue to create plans without separately creating products. |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 AUTHOR |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head1 SEE ALSO |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Stripe API documentation: |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/plans>, L<https://stripe.com/docs/billing/subscriptions/products-and-plans> |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
Copyright (c) 2019-2020 DEGUEST Pte. Ltd. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
293
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=cut |