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 <@sitael.tokyo.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
|
|
|
|
|
|
|
package Net::API::Stripe::Billing::Plan; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
1
|
|
|
1
|
|
827
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
18
|
1
|
|
|
1
|
|
4
|
use parent qw( Net::API::Stripe::Generic ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
19
|
1
|
|
|
1
|
|
398
|
our( $VERSION ) = 'v0.100.0'; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
1
|
|
sub id { shift->_set_get_scalar( 'id', @_ ); } |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
1
|
|
sub object { shift->_set_get_scalar( 'object', @_ ); } |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
1
|
|
sub active { shift->_set_get_boolean( 'active', @_ ); } |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
0
|
1
|
|
sub aggregate_usage { shift->_set_get_scalar( 'aggregate_usage', @_ ); } |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
1
|
|
sub amount { shift->_set_get_number( 'amount', @_ ); } |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
0
|
1
|
|
sub amount_decimal { return( shift->_set_get_number( 'amount_decimal', @_ ) ); } |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
0
|
1
|
|
sub billing_scheme { shift->_set_get_scalar( 'billing_scheme', @_ ); } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
## Not part of the official api documentation, but found in sub object data like in here |
37
|
|
|
|
|
|
|
## https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments |
38
|
0
|
|
|
0
|
1
|
|
sub count { return( shift->_set_get_number( 'count', @_ ) ); } |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
0
|
1
|
|
sub created { shift->_set_get_datetime( 'created', @_ ); } |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
1
|
|
sub currency { shift->_set_get_scalar( 'currency', @_ ); } |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
1
|
|
sub deleted { return( shift->_set_get_boolean( 'deleted', @_ ) ); } |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
0
|
1
|
|
sub interval { shift->_set_get_scalar( 'interval', @_ ); } |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
0
|
1
|
|
sub interval_count { shift->_set_get_scalar( 'interval_count', @_ ); } |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
1
|
|
sub livemode { shift->_set_get_boolean( 'livemode', @_ ); } |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
1
|
|
sub metadata { shift->_set_get_hash( 'metadata', @_ ); } |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
1
|
|
sub name { return( shift->_set_get_scalar( 'name', @_ ) ); } |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
1
|
|
sub nickname { shift->_set_get_scalar( 'nickname', @_ ); } |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
0
|
1
|
|
sub product { shift->_set_get_scalar_or_object( 'product', 'Net::API::Stripe::Product', @_ ); } |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
1
|
|
sub statement_description { return( shift->_set_get_scalar( 'statement_description', @_ ) ); } |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
0
|
1
|
|
sub statement_descriptor { return( shift->_set_get_scalar( 'statement_descriptor', @_ ) ); } |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
1
|
|
sub tiers { shift->_set_get_object( 'tiers', 'Net::API::Stripe::Billing::Plan::Tiers', @_ ); } |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
0
|
1
|
|
sub tiers_mode { shift->_set_get_scalar( 'tiers_mode', @_ ); } |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
1
|
|
sub transform_usage { shift->_set_get_object( 'transform_usage', 'Net::API::Stripe::Billing::Plan::TransformUsage', @_ ); } |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
0
|
1
|
|
sub trial_period_days { shift->_set_get_number( 'trial_period_days', @_ ); } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
## Not part of the official api documentation, but found in sub object data like in here |
73
|
|
|
|
|
|
|
## https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments |
74
|
0
|
|
|
0
|
1
|
|
sub type { return( shift->_set_get_scalar( 'type', @_ ) ); } |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
1
|
|
sub usage_type { shift->_set_get_scalar( 'usage_type', @_ ); } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=encoding utf8 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Net::API::Stripe::Billing::Plan - A Stripe Plan Object |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SYNOPSIS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $plan = $stripe->plan({ |
91
|
|
|
|
|
|
|
# Or you can just use 1. $stripe->true returns a Module::Generic::Boolean object |
92
|
|
|
|
|
|
|
active => $stripe->true, |
93
|
|
|
|
|
|
|
amount => 2000, |
94
|
|
|
|
|
|
|
billing_scheme => 'per_unit', |
95
|
|
|
|
|
|
|
count => 12, |
96
|
|
|
|
|
|
|
currency => 'jpy', |
97
|
|
|
|
|
|
|
interval => 'month', |
98
|
|
|
|
|
|
|
interval_count => 1, |
99
|
|
|
|
|
|
|
metadata => { transaction_id => 1212, customer_id => 123 }, |
100
|
|
|
|
|
|
|
name => 'Professional services subscription gold plan', |
101
|
|
|
|
|
|
|
statement_description => 'Provider, Inc Pro Services', |
102
|
|
|
|
|
|
|
}); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 VERSION |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
v0.100.0 |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DESCRIPTION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
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. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=over 4 |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item B<new>( %ARG ) |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Creates a new L<Net::API::Stripe::Billing::Plan> object. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 METHODS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over 4 |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item B<id> string |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Unique identifier for the object. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item B<object> string, value is "plan" |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
String representing the objectâs type. Objects of the same type share the same value. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item B<active> boolean |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Whether the plan is currently available for new subscriptions. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item B<aggregate_usage> string |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
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>. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item B<amount> positive integer or zero |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
The amount in JPY to be charged on the interval specified. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item B<amount_decimal> decimal string |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Same as I<amount>, but contains a decimal value with at most 12 decimal places. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item B<billing_scheme> string |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
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. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item B<count> integer |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
For fixed_count installment plans, this is the number of installment payments your customer will make to their credit card. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Not part of the official api documentation, but found in sub object data like in here |
159
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item B<created> timestamp |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Time at which the object was created. Measured in seconds since the Unix epoch. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item B<currency> currency |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Three-letter ISO currency code, in lowercase. Must be a supported currency. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item B<deleted> boolean |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Appears only when the plan has been deleted. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item B<interval> string |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
One of I<day>, I<week>, I<month> or I<year>. The frequency with which a subscription should be billed. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item B<interval_count> positive integer |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
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. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item B<livemode> boolean |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Has the value I<true> if the object exists in live mode or the value I<false> if the object exists in test mode. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item B<metadata> hash |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
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. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item B<name> string |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This is an undocumented property, which appears in data returned by Stripe. This contains the name of the plan. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item B<nickname> string |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
A brief description of the plan, hidden from customers. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item B<product> string (expandable) |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
The product whose pricing this plan determines. When expanded, this is a L<Net::API::Stripe::Product> object. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item B<statement_description> string |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This is an undocumented property, which appears in data returned by Stripe. This contains a description of the plan. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item B<statement_descriptor> string |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
This is an undocumented property, which appears in data returned by Stripe. This contains a description of the plan. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item B<tiers> array of hashes |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
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>. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This is an array of L<Net::API::Stripe::Billing::Plan::Tiers> objects. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item B<tiers_mode> string |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
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. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item B<transform_usage> hash |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with tiers. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
This is a L<Net::API::Stripe::Billing::Plan::TransformUsage> object. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item B<trial_period_days> positive integer |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Default number of trial days when subscribing a customer to this plan using I<trial_from_plan=true>. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item B<type> string |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Type of installment plan, one of fixed_count. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Not part of the official api documentation, but found in sub object data like in here |
234
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments> |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item B<usage_type> string |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
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>. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=back |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 API SAMPLE |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
{ |
245
|
|
|
|
|
|
|
"id": "expert-monthly-jpy", |
246
|
|
|
|
|
|
|
"object": "plan", |
247
|
|
|
|
|
|
|
"active": true, |
248
|
|
|
|
|
|
|
"aggregate_usage": null, |
249
|
|
|
|
|
|
|
"amount": 8000, |
250
|
|
|
|
|
|
|
"amount_decimal": "8000", |
251
|
|
|
|
|
|
|
"billing_scheme": "per_unit", |
252
|
|
|
|
|
|
|
"created": 1507273129, |
253
|
|
|
|
|
|
|
"currency": "jpy", |
254
|
|
|
|
|
|
|
"interval": "month", |
255
|
|
|
|
|
|
|
"interval_count": 1, |
256
|
|
|
|
|
|
|
"livemode": false, |
257
|
|
|
|
|
|
|
"metadata": {}, |
258
|
|
|
|
|
|
|
"nickname": null, |
259
|
|
|
|
|
|
|
"product": "prod_fake123456789", |
260
|
|
|
|
|
|
|
"tiers": null, |
261
|
|
|
|
|
|
|
"tiers_mode": null, |
262
|
|
|
|
|
|
|
"transform_usage": null, |
263
|
|
|
|
|
|
|
"trial_period_days": null, |
264
|
|
|
|
|
|
|
"usage_type": "licensed" |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head1 ACTUAL API DATA RETURNED |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
As you can see, there are extra properties: I<name>, I<statement_description> and I<statement_descriptior> |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
{ |
272
|
|
|
|
|
|
|
"id": "professional-monthly-jpy", |
273
|
|
|
|
|
|
|
"object": "plan", |
274
|
|
|
|
|
|
|
"active": true, |
275
|
|
|
|
|
|
|
"aggregate_usage": null, |
276
|
|
|
|
|
|
|
"amount": 8000, |
277
|
|
|
|
|
|
|
"amount_decimal": "8000", |
278
|
|
|
|
|
|
|
"billing_scheme": "per_unit", |
279
|
|
|
|
|
|
|
"created": 1541833564, |
280
|
|
|
|
|
|
|
"currency": "jpy", |
281
|
|
|
|
|
|
|
"interval": "month", |
282
|
|
|
|
|
|
|
"interval_count": 1, |
283
|
|
|
|
|
|
|
"livemode": false, |
284
|
|
|
|
|
|
|
"metadata": {}, |
285
|
|
|
|
|
|
|
"name": "MyShop, Inc monthly membership", |
286
|
|
|
|
|
|
|
"nickname": null, |
287
|
|
|
|
|
|
|
"product": "prod_fake123456789", |
288
|
|
|
|
|
|
|
"statement_description": null, |
289
|
|
|
|
|
|
|
"statement_descriptor": null, |
290
|
|
|
|
|
|
|
"tiers": null, |
291
|
|
|
|
|
|
|
"tiers_mode": null, |
292
|
|
|
|
|
|
|
"transform_usage": null, |
293
|
|
|
|
|
|
|
"trial_period_days": null, |
294
|
|
|
|
|
|
|
"usage_type": "licensed" |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head1 HISTORY |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=head2 v0.1 |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
Initial version |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head1 STRIPE HISTORY |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head2 2018-02-05 |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
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. |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=head1 AUTHOR |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=head1 SEE ALSO |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
Stripe API documentation: |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/plans>, L<https://stripe.com/docs/billing/subscriptions/products-and-plans> |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
Copyright (c) 2019-2020 DEGUEST Pte. Ltd. |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
324
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=cut |