line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## Stripe API - ~/lib/Net/API/Stripe/Billing/Subscription.pm |
3
|
|
|
|
|
|
|
## Version v0.301.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2020 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2019/11/02 |
7
|
|
|
|
|
|
|
## Modified 2022/10/29 |
8
|
|
|
|
|
|
|
## |
9
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
## https://stripe.com/docs/api/subscriptions |
11
|
|
|
|
|
|
|
BEGIN |
12
|
|
|
|
|
|
|
{ |
13
|
|
|
|
|
|
|
use strict; |
14
|
2
|
|
|
2
|
|
24121569
|
use warnings; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
62
|
|
15
|
2
|
|
|
2
|
|
10
|
use parent qw( Net::API::Stripe::Generic ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
16
|
2
|
|
|
2
|
|
10
|
use vars qw( $VERSION ); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
10
|
|
17
|
2
|
|
|
2
|
|
148
|
our( $VERSION ) = 'v0.301.0'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
114
|
|
18
|
2
|
|
|
2
|
|
39
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use strict; |
21
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
39
|
|
22
|
2
|
|
|
2
|
|
23
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2054
|
|
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
1
|
|
|
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
1
|
|
|
27
|
|
|
|
|
|
|
{ |
28
|
0
|
|
|
0
|
0
|
|
enabled => { type => 'boolean' }, |
29
|
|
|
|
|
|
|
}, @_ ) ); } |
30
|
0
|
|
|
0
|
1
|
|
|
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
0
|
0
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
|
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
1
|
|
|
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
1
|
|
|
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
|
|
|
|
|
|
|
## To cancel subscriptions |
53
|
0
|
|
|
0
|
1
|
|
|
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
|
|
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
|
|
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
1
|
|
|
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
0
|
1
|
|
|
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
0
|
1
|
|
return( shift->_set_get_class( 'pause_collection', |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
0
|
1
|
|
behavior => { type => 'scalar' }, |
66
|
|
|
|
|
|
|
resumes_at => { type => 'datetime' }, |
67
|
0
|
|
|
0
|
1
|
|
}, @_ ) ); |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
0
|
1
|
|
|
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
0
|
1
|
|
|
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
0
|
|
|
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
0
|
1
|
|
return( shift->_set_get_class( 'pending_update', |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
0
|
1
|
|
billing_cycle_anchor => { type => 'datetime' }, |
78
|
|
|
|
|
|
|
expires_at => { type => 'datetime' }, |
79
|
|
|
|
|
|
|
subscription_items => { type => 'object_array_object', class => 'Net::API::Stripe::Billing::Subscription::Item' }, |
80
|
|
|
|
|
|
|
trial_end => { type => 'datetime' }, |
81
|
0
|
|
|
0
|
1
|
|
trial_from_plan => { type => 'boolean' }, |
82
|
|
|
|
|
|
|
}, @_ ) ); |
83
|
0
|
|
|
0
|
1
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
0
|
1
|
|
|
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
0
|
1
|
|
|
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
0
|
1
|
|
|
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
1
|
|
|
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
0
|
1
|
|
|
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
0
|
1
|
|
{ |
96
|
|
|
|
|
|
|
return( shift->_set_get_class( 'transfer_data', |
97
|
|
|
|
|
|
|
{ |
98
|
|
|
|
|
|
|
amount_percent => { type => 'number' }, |
99
|
0
|
|
|
0
|
1
|
|
destination => { type => 'object', class => 'Net::API::Stripe::Connect::Account' }, |
100
|
|
|
|
|
|
|
}, @_ ) ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
0
|
1
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
0
|
|
|
0
|
0
|
|
|
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
0
|
1
|
|
=encoding utf8 |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
0
|
1
|
|
=head1 NAME |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Net::API::Stripe::Billing::Subscription - A Stripe Subscription Object |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
0
|
1
|
|
=head1 SYNOPSIS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $sub = $stripe->subscription({ |
119
|
|
|
|
|
|
|
application_fee_percent => 2, |
120
|
|
|
|
|
|
|
# Could also be a unix timestamp |
121
|
|
|
|
|
|
|
backdate_start_date => '2020-01-01', |
122
|
|
|
|
|
|
|
billing_cycle_anchor => '2020-04-01', |
123
|
|
|
|
|
|
|
coupon => 'SUMMER10POFF', |
124
|
|
|
|
|
|
|
current_period_end => '2020-06-30', |
125
|
|
|
|
|
|
|
customer => $cust_object, |
126
|
0
|
|
|
0
|
1
|
|
days_until_due => 7, |
127
|
|
|
|
|
|
|
default_payment_method => 'pm_fake123456789', |
128
|
0
|
|
|
0
|
1
|
|
metadata => { transaction_id => 1212, customer_id => 123 }, |
129
|
|
|
|
|
|
|
off_session => $stripe->true, |
130
|
0
|
|
|
0
|
1
|
|
payment_behavior => 'error_if_incomplete', |
131
|
|
|
|
|
|
|
plan => $plan_object, |
132
|
0
|
|
|
0
|
1
|
|
quantity => 1, |
133
|
|
|
|
|
|
|
}); |
134
|
0
|
|
|
0
|
1
|
|
|
135
|
|
|
|
|
|
|
=head1 VERSION |
136
|
0
|
|
|
0
|
1
|
|
|
137
|
|
|
|
|
|
|
v0.301.0 |
138
|
0
|
|
|
0
|
1
|
|
|
139
|
|
|
|
|
|
|
=head1 DESCRIPTION |
140
|
0
|
|
|
0
|
1
|
|
|
141
|
|
|
|
|
|
|
Subscriptions allow you to charge a customer on a recurring basis. |
142
|
0
|
|
|
0
|
1
|
|
|
143
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
144
|
0
|
|
|
0
|
0
|
|
|
145
|
|
|
|
|
|
|
=head2 new( %ARG ) |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Creates a new L<Net::API::Stripe::Billing::Subscription> object. |
148
|
0
|
|
|
0
|
1
|
|
It may also take an hash like arguments, that also are method of the same name. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 METHODS |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 id string |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Unique identifier for the object. |
155
|
0
|
|
|
0
|
1
|
|
|
156
|
|
|
|
|
|
|
=head2 object string, value is "subscription" |
157
|
0
|
|
|
0
|
1
|
|
|
158
|
|
|
|
|
|
|
String representing the object’s type. Objects of the same type share the same value. |
159
|
0
|
|
|
0
|
1
|
|
|
160
|
|
|
|
|
|
|
=head2 application_fee_percent decimal |
161
|
0
|
|
|
0
|
1
|
|
|
162
|
|
|
|
|
|
|
A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner’s Stripe account. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 backdate_start_date |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
For new subscriptions, a past timestamp to backdate the subscription’s start date to. If set, the first invoice will contain a proration for the timespan between the start date and the current time. Can be combined with trials and the billing cycle anchor. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 billing |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
String like C<charge_automatically>, but not documented. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 billing_cycle_anchor timestamp |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 billing_thresholds hash |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This is a L<Net::API::Stripe::Billing::Thresholds> object. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=over 4 |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item I<amount_gte> integer |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Monetary threshold that triggers the subscription to create an invoice |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item I<reset_billing_cycle_anchor> boolean |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Indicates if the billing_cycle_anchor should be reset when a threshold is reached. If true, billing_cycle_anchor will be updated to the date/time the threshold was last reached; otherwise, the value will remain unchanged. This value may not be true if the subscription contains items with plans that have aggregate_usage=last_ever. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=back |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 cancel_at timestamp |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
This is an undocumented property returned by Stripe, and I assume this is a duplicate to the B<canceled_at> one. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This is added here, so returned data does not yield a warning, but obviously this should not be used otherwise. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
According to Stripe support as of 2019-11-07, this is: |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
If the associated subscription has been set up to be canceled at a future date, the ‘cancel_at’ property is used to specify the future timestamp of when it will be canceled. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head2 cancel_at_period_end boolean |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
If the subscription has been canceled with the at_period_end flag set to true, cancel_at_period_end on the subscription will be true. You can use this attribute to determine whether a subscription that has a status of active is scheduled to be canceled at the end of the current period. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 canceled_at timestamp |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with cancel_at_period_end, canceled_at will still reflect the date of the initial cancellation request, not the end of the subscription period when the subscription is automatically moved to a canceled state. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 collection_method string |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head2 coupon string |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
The code of the coupon to apply to this subscription. A coupon applied to a subscription will only affect invoices created for that particular subscription. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head2 created timestamp |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Time at which the object was created. Measured in seconds since the Unix epoch. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head2 currency currency |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Three-letter L<ISO currency code|https://www.iso.org/iso-4217-currency-codes.html>, in lowercase. Must be a L<supported currency|https://stripe.com/docs/currencies>. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head2 current_period_end timestamp |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head2 current_period_start timestamp |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Start of the current period that the subscription has been invoiced for. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 customer string (expandable) |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
ID of the customer who owns the subscription. When expanded, this is a L<Net::API::Stripe::Customer> object. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 days_until_due integer |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Number of days a customer has to pay invoices generated by this subscription. This value will be null for subscriptions where collection_method=charge_automatically. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head2 default_payment_method string (expandable) |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. If not set, invoices will use the default payment method in the customer’s invoice settings. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
When expanded, this is a L<Net::API::Stripe::Payment::Method> object. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head2 default_source string (expandable) |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If not set, defaults to the customer’s default source. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
When expanded, this is a L<Net::API::Stripe::Payment::Source> object. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head2 default_tax_rates array of hashes |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
The tax rates that will apply to any subscription item that does not have tax_rates set. Invoices created will have their default_tax_rates populated from the subscription. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
This is an array of L<Net::API::Stripe::Tax::Rate> objects. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head2 discount hash, discount object |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
This is a L<Net::API::Stripe::Billing::Discount> object. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head2 ended_at timestamp |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
If the subscription has ended, the date the subscription ended. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head2 invoice_customer_balance_settings |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
This is a L<Net::API::Stripe::Billing::Invoice::BalanceSettings> object. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head2 invoice_now boolean |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
This is used to cancel a subscription. See here: L<https://stripe.com/docs/api/subscriptions/cancel> |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head2 items list |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
List of subscription items, each with an attached plan. |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
This is a L<Net::API::Stripe::Billing::Subscription::Items> object. |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=head2 latest_invoice string (expandable) |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
The most recent invoice this subscription has generated. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
When expanded, this is a L<Net::API::Stripe::Billing::Invoice> object. |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head2 livemode boolean |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
Has the value true if the object exists in live mode or the value false if the object exists in test mode. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=head2 metadata hash |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
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. |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=head2 next_pending_invoice_item_invoice |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
This is an undocumented property on Stripe, but found in its sample data. |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
This is managed with a virtual module L<Net::API::Billing::Subscription::Item::Invoice> |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=head2 off_session boolean |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
Indicates if a customer is on or off-session while an invoice payment is attempted. |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=head2 pause_collection hash |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
If specified, payment collection for this subscription will be paused. |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=over 4 |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=item I<pause_collection.behavior> string |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
The payment collection behavior for this subscription while paused. One of keep_as_draft, mark_uncollectible, or void. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=item I<resumes_at> timestamp |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
The time after which the subscription will resume collecting payments. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=back |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=head2 payment_behavior string |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
Use I<allow_incomplete> to create subscriptions with status=incomplete if the first invoice cannot be paid. Creating subscriptions with this status allows you to manage scenarios where additional user actions are needed to pay a subscription’s invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the SCA Migration Guide for Billing to learn more. This is the default behavior. |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
Use I<error_if_incomplete> if you want Stripe to return an HTTP 402 status code if a subscription’s first invoice cannot be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further user action is needed, this parameter does not create a subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the changelog to learn more. |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
I<pending_if_incomplete> is only used with updates and cannot be passed when creating a subscription. |
335
|
|
|
|
|
|
|
Possible enum values |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=over 4 |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=item I<allow_incomplete> |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=item I<error_if_incomplete> |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
=item I<pending_if_incomplete> |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
=back |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
=head2 pending_invoice_item_interval |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling Create an invoice for the given subscription at the specified interval. |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=over 4 |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=item I<interval> required |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
Specifies invoicing frequency. Either day, week, month or year. |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
=item I<interval_count> optional |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
The number of intervals between invoices. For example, interval=month and interval_count=3 bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
=back |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
=head2 pending_setup_intent string (expandable) |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
You can use this SetupIntent to collect user authentication when creating a subscription without immediate payment or updating a subscription’s payment method, allowing you to optimize for off-session payments. Learn more in the SCA Migration Guide. |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
When expanded, this is a L<Net::API::Stripe::Payment::Intent::Setup> object. |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
=head2 pending_update hash |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
If specified, pending updates that will be applied to the subscription once the latest_invoice has been paid. |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
=over 4 |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=item I<billing_cycle_anchor> timestamp |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
If the update is applied, determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices. |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
=item I<expires_at> timestamp |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
The point after which the changes reflected by this update will be discarded and no longer applied. |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
=item I<subscription_items> array of hashes |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
List of subscription items (L<Net::APi::Stripe::Billing::Subscription::Item>), each with an attached plan, that will be set if the update is applied. |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
=item I<trial_end> timestamp |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
Unix timestamp representing the end of the trial period the customer will get before being charged for the first time, if the update is applied. |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=item I<trial_from_plan> boolean |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
Indicates if a plan’s trial_period_days should be applied to the subscription. Setting trial_end per subscription is preferred, and this defaults to false. Setting this flag to true together with trial_end is not allowed. |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
=back |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
=head2 plan hash, plan object |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
Hash describing the plan the customer is subscribed to. Only set if the subscription contains a single plan. |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
This is a L<Net::API::Stripe::Billing::Plan> object. |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
=head2 prorate boolean (deprecated) |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
Boolean (defaults to true) telling us whether to credit for unused time when the billing cycle changes (e.g. when switching plans, resetting billing_cycle_anchor=now, or starting a trial), or if an item’s quantity changes. If false, the anchor period will be free (similar to a trial) and no proration adjustments will be created. This field has been deprecated and will be removed in a future API version. Use proration_behavior=create_prorations as a replacement for prorate=true and proration_behavior=none for prorate=false. |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
=head2 proration_behavior string |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
Determines how to handle prorations resulting from the billing_cycle_anchor. Valid values are I<create_prorations> or I<none>. |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
Passing I<create_prorations> will cause proration invoice items to be created when applicable. Prorations can be disabled by passing I<none>. If no value is passed, the default is create_prorations. |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
=head2 quantity integer |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
The quantity of the plan to which the customer is subscribed. For example, if your plan is $10/user/month, and your customer has 5 users, you could pass 5 as the quantity to have the customer charged $50 (5 x $10) monthly. Only set if the subscription contains a single plan. |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=head2 schedule string expandable |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
The schedule attached to the subscription. When expanded, this is a L<Net::API::Stripe::Billing::Subscription::Schedule> object. |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=head2 start timestamp |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
Date of the last substantial change to this subscription. For example, a change to the items array, or a change of status, will reset this timestamp. |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=head2 start_date timestamp |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
Date when the subscription was first created. The date might differ from the created date due to backdating. |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
=head2 status string |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
Possible values are incomplete, incomplete_expired, trialing, active, past_due, canceled, or unpaid. |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
For collection_method=charge_automatically a subscription moves into incomplete if the initial payment attempt fails. A subscription in this state can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an active state. If the first invoice is not paid within 23 hours, the subscription transitions to incomplete_expired. This is a terminal state, the open invoice will be voided and no further invoices will be generated. |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
A subscription that is currently in a trial period is trialing and moves to active when the trial period is over. |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
If subscription collection_method=charge_automatically it becomes past_due when payment to renew it fails and canceled or unpaid (depending on your subscriptions settings) when Stripe has exhausted all payment retry attempts. |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
If subscription collection_method=send_invoice it becomes past_due when its invoice is not paid by the due date, and canceled or unpaid if it is still not paid by an additional deadline after that. Note that when a subscription has a status of unpaid, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices. |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=head2 tax_percent decimal (deprecated) |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
A non-negative decimal (with at most four decimal places) between 0 and 100. This represents the percentage of the subscription invoice subtotal that will be calculated and added as tax to the final amount in each billing period. For example, a plan which charges $10/month with a tax_percent of 20.0 will charge $12 per invoice. To unset a previously-set value, pass an empty string. This field has been deprecated and will be removed in a future API version, for further information view the migration docs for tax_rates. |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
=head2 transfer_data hash |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
This is for Connect only. |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
The account (if any) the subscription’s payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription’s invoices. |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=over 4 |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=item I<amount_percent> decimal |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the destination account. By default, the entire amount is transferred to the destination. |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=item I<destination> string expandable |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
The account where funds from the payment will be transferred to upon payment success. |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
=back |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=head2 trial_end timestamp |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
If the subscription has a trial, the end of that trial. |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
=head2 trial_from_plan boolean |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
Indicates if a plan’s trial_period_days should be applied to the subscription. Setting trial_end per subscription is preferred, and this defaults to false. Setting this flag to true together with trial_end is not allowed. |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=head2 trial_period_days integer |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
Integer representing the number of trial period days before the customer is charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=head2 trial_start timestamp |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
If the subscription has a trial, the beginning of that trial. |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=head1 API SAMPLE |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
{ |
482
|
|
|
|
|
|
|
"id": "sub_fake123456789", |
483
|
|
|
|
|
|
|
"object": "subscription", |
484
|
|
|
|
|
|
|
"application_fee_percent": null, |
485
|
|
|
|
|
|
|
"billing": "charge_automatically", |
486
|
|
|
|
|
|
|
"billing_cycle_anchor": 1551492959, |
487
|
|
|
|
|
|
|
"billing_thresholds": null, |
488
|
|
|
|
|
|
|
"cancel_at_period_end": false, |
489
|
|
|
|
|
|
|
"canceled_at": 1555726796, |
490
|
|
|
|
|
|
|
"collection_method": "charge_automatically", |
491
|
|
|
|
|
|
|
"created": 1551492959, |
492
|
|
|
|
|
|
|
"current_period_end": 1556763359, |
493
|
|
|
|
|
|
|
"current_period_start": 1554171359, |
494
|
|
|
|
|
|
|
"customer": "cus_fake123456789", |
495
|
|
|
|
|
|
|
"days_until_due": null, |
496
|
|
|
|
|
|
|
"default_payment_method": null, |
497
|
|
|
|
|
|
|
"default_source": null, |
498
|
|
|
|
|
|
|
"default_tax_rates": [], |
499
|
|
|
|
|
|
|
"discount": null, |
500
|
|
|
|
|
|
|
"ended_at": 1555726796, |
501
|
|
|
|
|
|
|
"items": { |
502
|
|
|
|
|
|
|
"object": "list", |
503
|
|
|
|
|
|
|
"data": [ |
504
|
|
|
|
|
|
|
{ |
505
|
|
|
|
|
|
|
"id": "si_fake123456789", |
506
|
|
|
|
|
|
|
"object": "subscription_item", |
507
|
|
|
|
|
|
|
"billing_thresholds": null, |
508
|
|
|
|
|
|
|
"created": 1551492959, |
509
|
|
|
|
|
|
|
"metadata": {}, |
510
|
|
|
|
|
|
|
"plan": { |
511
|
|
|
|
|
|
|
"id": "professional-monthly-jpy", |
512
|
|
|
|
|
|
|
"object": "plan", |
513
|
|
|
|
|
|
|
"active": true, |
514
|
|
|
|
|
|
|
"aggregate_usage": null, |
515
|
|
|
|
|
|
|
"amount": 8000, |
516
|
|
|
|
|
|
|
"amount_decimal": "8000", |
517
|
|
|
|
|
|
|
"billing_scheme": "per_unit", |
518
|
|
|
|
|
|
|
"created": 1541833564, |
519
|
|
|
|
|
|
|
"currency": "jpy", |
520
|
|
|
|
|
|
|
"interval": "month", |
521
|
|
|
|
|
|
|
"interval_count": 1, |
522
|
|
|
|
|
|
|
"livemode": false, |
523
|
|
|
|
|
|
|
"metadata": {}, |
524
|
|
|
|
|
|
|
"nickname": null, |
525
|
|
|
|
|
|
|
"product": "prod_fake123456789", |
526
|
|
|
|
|
|
|
"tiers": null, |
527
|
|
|
|
|
|
|
"tiers_mode": null, |
528
|
|
|
|
|
|
|
"transform_usage": null, |
529
|
|
|
|
|
|
|
"trial_period_days": null, |
530
|
|
|
|
|
|
|
"usage_type": "licensed" |
531
|
|
|
|
|
|
|
}, |
532
|
|
|
|
|
|
|
"quantity": 1, |
533
|
|
|
|
|
|
|
"subscription": "sub_fake123456789", |
534
|
|
|
|
|
|
|
"tax_rates": [] |
535
|
|
|
|
|
|
|
} |
536
|
|
|
|
|
|
|
], |
537
|
|
|
|
|
|
|
"has_more": false, |
538
|
|
|
|
|
|
|
"url": "/v1/subscription_items?subscription=sub_fake123456789" |
539
|
|
|
|
|
|
|
}, |
540
|
|
|
|
|
|
|
"latest_invoice": "in_fake123456789", |
541
|
|
|
|
|
|
|
"livemode": false, |
542
|
|
|
|
|
|
|
"metadata": {}, |
543
|
|
|
|
|
|
|
"pending_setup_intent": null, |
544
|
|
|
|
|
|
|
"plan": { |
545
|
|
|
|
|
|
|
"id": "professional-monthly-jpy", |
546
|
|
|
|
|
|
|
"object": "plan", |
547
|
|
|
|
|
|
|
"active": true, |
548
|
|
|
|
|
|
|
"aggregate_usage": null, |
549
|
|
|
|
|
|
|
"amount": 8000, |
550
|
|
|
|
|
|
|
"amount_decimal": "8000", |
551
|
|
|
|
|
|
|
"billing_scheme": "per_unit", |
552
|
|
|
|
|
|
|
"created": 1541833564, |
553
|
|
|
|
|
|
|
"currency": "jpy", |
554
|
|
|
|
|
|
|
"interval": "month", |
555
|
|
|
|
|
|
|
"interval_count": 1, |
556
|
|
|
|
|
|
|
"livemode": false, |
557
|
|
|
|
|
|
|
"metadata": {}, |
558
|
|
|
|
|
|
|
"nickname": null, |
559
|
|
|
|
|
|
|
"product": "prod_fake123456789", |
560
|
|
|
|
|
|
|
"tiers": null, |
561
|
|
|
|
|
|
|
"tiers_mode": null, |
562
|
|
|
|
|
|
|
"transform_usage": null, |
563
|
|
|
|
|
|
|
"trial_period_days": null, |
564
|
|
|
|
|
|
|
"usage_type": "licensed" |
565
|
|
|
|
|
|
|
}, |
566
|
|
|
|
|
|
|
"quantity": 1, |
567
|
|
|
|
|
|
|
"start": 1554430777, |
568
|
|
|
|
|
|
|
"start_date": 1551492959, |
569
|
|
|
|
|
|
|
"status": "canceled", |
570
|
|
|
|
|
|
|
"tax_percent": null, |
571
|
|
|
|
|
|
|
"trial_end": null, |
572
|
|
|
|
|
|
|
"trial_start": null |
573
|
|
|
|
|
|
|
} |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
=head1 HISTORY |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
=head2 v0.1 |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
Initial version |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
=head1 AUTHOR |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
=head1 SEE ALSO |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
Stripe API documentation: |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/subscriptions>, L<https://stripe.com/docs/billing/subscriptions/creating> |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
Copyright (c) 2020 DEGUEST Pte. Ltd. |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
596
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
=cut |