Stripe/Billing/Subscription.pm

filter: Statementstmt 14.5% 8 / 55 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 6.0% 3 / 50 Podpod 100% 47 / 47 totaltotal 38.1% 58 / 152 CC 1 SCAR 6.6
CC
1
Cov
15%
id
2.0
object
2.0
application_fee_percent
2.0
CRAP 1.9
« Stripe/Payment/Intent.pm ↑ Summary Stripe/Charge.pm »
1 ##----------------------------------------------------------------------------
2 ## Stripe API - ~/lib/Net/API/Stripe/Billing/Subscription.pm
3 ## Version v0.300.0
4 ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
6 ## Created 2019/11/02
7 ## Modified 2020/05/15
8 ##
9 ##----------------------------------------------------------------------------
10 ## https://stripe.com/docs/api/subscriptions
11 package Net::API::Stripe::Billing::Subscription;
12 BEGIN
13 {
14 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶ use parent qw( Net::API::Stripe::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶ our( $VERSION ) = 'v0.300.0';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 };
18  
19 0 ▶sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
20  
21 0 ▶sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
Subroutine object: not called CC=1 SCAR=6.9
Pod documented
22  
23 0 ▶sub application_fee_percent { return( shift->_set_get_number( 'application_fee_percent', @_ ) ); }
Subroutine application_fee_percent: not called CC=1 SCAR=6.9
Pod documented
24  
25 0 ▶sub backdate_start_date { return( shift->_set_get_datetime( 'backdate_start_date', @_ ) ); }
Subroutine backdate_start_date: not called CC=1 SCAR=6.9
Pod documented
26  
27 0 ▶sub billing { return( shift->_set_get_scalar( 'billing', @_ ) ); }
Subroutine billing: not called CC=1 SCAR=6.9
Pod documented
28  
29 0 ▶sub billing_cycle_anchor { return( shift->_set_get_datetime( 'billing_cycle_anchor', @_ ) ); }
Subroutine billing_cycle_anchor: not called CC=1 SCAR=6.9
Pod documented
30  
31 0 ▶sub billing_thresholds { return( shift->_set_get_object( 'billing_thresholds', 'Net::API::Stripe::Billing::Thresholds', @_ ) ); }
Subroutine billing_thresholds: not called CC=1 SCAR=6.9
Pod documented
32  
33 0 ▶sub cancel_at { return( shift->_set_get_datetime( 'cancel_at', @_ ) ); }
Subroutine cancel_at: not called CC=1 SCAR=6.9
Pod documented
34  
35 0 ▶sub cancel_at_period_end { return( shift->_set_get_boolean( 'cancel_at_period_end', @_ ) ); }
Subroutine cancel_at_period_end: not called CC=1 SCAR=6.9
Pod documented
36  
37 0 ▶sub canceled_at { return( shift->_set_get_datetime( 'canceled_at', @_ ) ); }
Subroutine canceled_at: not called CC=1 SCAR=6.9
Pod documented
38  
39 0 ▶sub collection_method { return( shift->_set_get_scalar( 'collection_method', @_ ) ); }
Subroutine collection_method: not called CC=1 SCAR=6.9
Pod documented
40  
41 0 ▶sub coupon { return( shift->_set_get_scalar( 'coupon', @_ ) ); }
Subroutine coupon: not called CC=1 SCAR=6.9
Pod documented
42  
43 0 ▶sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
Subroutine created: not called CC=1 SCAR=6.9
Pod documented
44  
45 0 ▶sub current_period_end { return( shift->_set_get_datetime( 'current_period_end', @_ ) ); }
Subroutine current_period_end: not called CC=1 SCAR=6.9
Pod documented
46  
47 0 ▶sub current_period_start { return( shift->_set_get_datetime( 'current_period_start', @_ ) ); }
Subroutine current_period_start: not called CC=1 SCAR=6.9
Pod documented
48  
49 0 ▶sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); }
Subroutine customer: not called CC=1 SCAR=6.9
Pod documented
50  
51 0 ▶sub days_until_due { return( shift->_set_get_number( 'days_until_due', @_ ) ); }
Subroutine days_until_due: not called CC=1 SCAR=6.9
Pod documented
52  
53 0 ▶sub default_payment_method { return( shift->_set_get_scalar_or_object( 'default_payment_method', 'Net::API::Stripe::Payment::Method', @_ ) ); }
Subroutine default_payment_method: not called CC=1 SCAR=6.9
Pod documented
54  
55 0 ▶sub default_source { return( shift->_set_get_scalar_or_object( 'default_source', 'Net::API::Stripe::Payment::Source', @_ ) ); }
Subroutine default_source: not called CC=1 SCAR=6.9
Pod documented
56  
57 0 ▶sub default_tax_rates { return( shift->_set_get_object_array( 'default_tax_rates', 'Net::API::Stripe::Tax::Rate', @_ ) ); }
Subroutine default_tax_rates: not called CC=1 SCAR=6.9
Pod documented
58  
59 0 ▶sub discount { return( shift->_set_get_object( 'discount', 'Net::API::Stripe::Billing::Discount', @_ ) ); }
Subroutine discount: not called CC=1 SCAR=6.9
Pod documented
60  
61 0 ▶sub ended_at { return( shift->_set_get_datetime( 'ended_at', @_ ) ); }
Subroutine ended_at: not called CC=1 SCAR=6.9
Pod documented
62  
63 0 ▶sub invoice_customer_balance_settings { return( shift->_set_get_hash_as_object( 'invoice_customer_balance_settings', 'Net::API::Stripe::Billing::Invoice::BalanceSettings', @_ ) ); }
Subroutine invoice_customer_balance_settings: not called CC=1 SCAR=6.9
Pod documented
64  
65 0 ▶sub items { return( shift->_set_get_object( 'items', 'Net::API::Stripe::Billing::Subscription::Items', @_ ) ); }
Subroutine items: not called CC=1 SCAR=6.9
Pod documented
66  
67 0 ▶sub latest_invoice { return( shift->_set_get_scalar_or_object( 'latest_invoice', 'Net::API::Stripe::Billing::Invoice', @_ ) ); }
Subroutine latest_invoice: not called CC=1 SCAR=6.9
Pod documented
68  
69 0 ▶sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
Subroutine livemode: not called CC=1 SCAR=6.9
Pod documented
70  
71 0 ▶sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
Subroutine metadata: not called CC=1 SCAR=6.9
Pod documented
72  
73 0 ▶sub next_pending_invoice_item_invoice { return( shift->_set_get_hash_as_object( 'next_pending_invoice_item_invoice', 'Net::API::Billing::Subscription::Item::Invoice', @_ ) ); }
Subroutine next_pending_invoice_item_invoice: not called CC=1 SCAR=6.9
Pod documented
74  
75 0 ▶sub off_session { return( shift->_set_get_boolean( 'off_session', @_ ) ); }
Subroutine off_session: not called CC=1 SCAR=6.9
Pod documented
76  
77 sub pause_collection
78 {
79 0 ▶ return( shift->_set_get_class( 'pause_collection',
Subroutine pause_collection: not called CC=1 SCAR=6.9
Pod documented
80 {
81 behavior => { type => 'scalar' },
82 resumes_at => { type => 'datetime' },
83 }, @_ ) );
84 }
85  
86 0 ▶sub payment_behavior { return( shift->_set_get_scalar( 'payment_behavior', @_ ) ); }
Subroutine payment_behavior: not called CC=1 SCAR=6.9
Pod documented
87  
88 0 ▶sub pending_invoice_item_interval { return( shift->_set_get_object( 'pending_invoice_item_interval', 'Net::API::Stripe::Billing::Plan', @_ ) ); }
Subroutine pending_invoice_item_interval: not called CC=1 SCAR=6.9
Pod documented
89  
90 0 ▶sub pending_setup_intent { return( shift->_set_get_scalar_or_object( 'pending_setup_intent', 'Net::API::Stripe::Payment::Intent::Setup', @_ ) ); }
Subroutine pending_setup_intent: not called CC=1 SCAR=6.9
Pod documented
91  
92 sub pending_update
93 {
94 0 ▶ return( shift->_set_get_class( 'pending_update',
Subroutine pending_update: not called CC=1 SCAR=6.9
Pod documented
95 {
96 billing_cycle_anchor => { type => 'datetime' },
97 expires_at => { type => 'datetime' },
98 subscription_items => { type => 'object_array_object', class => 'Net::API::Stripe::Billing::Subscription::Item' },
99 trial_end => { type => 'datetime' },
100 trial_from_plan => { type => 'boolean' },
101 }, @_ ) );
102 }
103  
104 0 ▶sub plan { return( shift->_set_get_object( 'plan', 'Net::API::Stripe::Billing::Plan', @_ ) ); }
Subroutine plan: not called CC=1 SCAR=6.9
Pod documented
105  
106 0 ▶sub prorate { return( shift->_set_get_boolean( 'prorate', @_ ) ); }
Subroutine prorate: not called CC=1 SCAR=6.9
Pod documented
107  
108 0 ▶sub proration_behavior { return( shift->_set_get_scalar( 'proration_behavior', @_ ) ); }
Subroutine proration_behavior: not called CC=1 SCAR=6.9
Pod documented
109  
110 0 ▶sub quantity { return( shift->_set_get_number( 'quantity', @_ ) ); }
Subroutine quantity: not called CC=1 SCAR=6.9
Pod documented
111  
112 0 ▶sub schedule { return( shift->_set_get_scalar_or_object( 'schedule', 'Net::API::Stripe::Billing::Subscription::Schedule', @_ ) ); }
Subroutine schedule: not called CC=1 SCAR=6.9
Pod documented
113  
114 0 ▶sub start { return( shift->_set_get_datetime( 'start', @_ ) ); }
Subroutine start: not called CC=1 SCAR=6.9
Pod documented
115  
116 0 ▶sub start_date { return( shift->_set_get_datetime( 'start_date', @_ ) ); }
Subroutine start_date: not called CC=1 SCAR=6.9
Pod documented
117  
118 0 ▶sub status { return( shift->_set_get_scalar( 'status', @_ ) ); }
Subroutine status: not called CC=1 SCAR=6.9
Pod documented
119  
120 0 ▶sub tax_percent { return( shift->_set_get_number( 'tax_percent', @_ ) ); }
Subroutine tax_percent: not called CC=1 SCAR=6.9
Pod documented
121  
122 0 ▶sub trial_end { return( shift->_set_get_datetime( 'trial_end', @_ ) ); }
Subroutine trial_end: not called CC=1 SCAR=6.9
Pod documented
123  
124 0 ▶sub trial_from_plan { return( shift->_set_get_boolean( 'trial_from_plan', @_ ) ); }
Subroutine trial_from_plan: not called CC=1 SCAR=6.9
Pod documented
125  
126 0 ▶sub trial_period_days { return( shift->_set_get_number( 'trial_period_days', @_ ) ); }
Subroutine trial_period_days: not called CC=1 SCAR=6.9
Pod documented
127  
128 0 ▶sub trial_start { return( shift->_set_get_datetime( 'trial_start', @_ ) ); }
Subroutine trial_start: not called CC=1 SCAR=6.9
Pod documented
129  
130 1 1;
131  
132 __END__
133  
134 =encoding utf8
135  
136 =head1 NAME
137  
138 Net::API::Stripe::Billing::Subscription - A Stripe Subscription Object
139  
140 =head1 SYNOPSIS
141  
142 my $sub = $stripe->subscription({
143 application_fee_percent => 2,
144 # Could also be a unix timestamp
145 backdate_start_date => '2020-01-01',
146 billing_cycle_anchor => '2020-04-01',
147 coupon => 'SUMMER10POFF',
148 current_period_end => '2020-06-30',
149 customer => $cust_object,
150 days_until_due => 7,
151 default_payment_method => 'pm_fake123456789',
152 metadata => { transaction_id => 1212, customer_id => 123 },
153 off_session => $stripe->true,
154 payment_behavior => 'error_if_incomplete',
155 plan => $plan_object,
156 quantity => 1,
157 });
158  
159 =head1 VERSION
160  
161 v0.300.0
162  
163 =head1 DESCRIPTION
164  
165 Subscriptions allow you to charge a customer on a recurring basis.
166  
167 =head1 CONSTRUCTOR
168  
169 =over 4
170  
171 =item B<new>( %ARG )
172  
173 Creates a new L<Net::API::Stripe::Billing::Subscription> object.
174 It may also take an hash like arguments, that also are method of the same name.
175  
176 =back
177  
178 =head1 METHODS
179  
180 =over 4
181  
182 =item B<id> string
183  
184 Unique identifier for the object.
185  
186 =item B<object> string, value is "subscription"
187  
188 String representing the object’s type. Objects of the same type share the same value.
189  
190 =item B<application_fee_percent> decimal
191  
192 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.
193  
194 =item B<backdate_start_date>
195  
196 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.
197  
198 =item B<billing>()
199  
200 =item B<billing_cycle_anchor> timestamp
201  
202 Determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices.
203  
204 =item B<billing_thresholds> hash
205  
206 Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period
207  
208 This is a L<Net::API::Stripe::Billing::Thresholds> object.
209  
210 =over 8
211  
212 =item B<amount_gte> integer
213  
214 Monetary threshold that triggers the subscription to create an invoice
215  
216 =item B<reset_billing_cycle_anchor> boolean
217  
218 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.
219  
220 =back
221  
222 =item B<cancel_at> timestamp
223  
224 This is an undocumented property returned by Stripe, and I assume this is a duplicate to the B<canceled_at> one.
225  
226 This is added here, so returned data does not yield a warning, but obviously this should not be used otherwise.
227  
228 According to Stripe support as of 2019-11-07, this is:
229  
230 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.
231  
232 =item B<cancel_at_period_end> boolean
233  
234 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.
235  
236 =item B<canceled_at> timestamp
237  
238 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.
239  
240 =item B<collection_method> string
241  
242 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.
243  
244 =item B<coupon> string
245  
246 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.
247  
248 =item B<created> timestamp
249  
250 Time at which the object was created. Measured in seconds since the Unix epoch.
251  
252 =item B<current_period_end> timestamp
253  
254 End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created.
255  
256 =item B<current_period_start> timestamp
257  
258 Start of the current period that the subscription has been invoiced for.
259  
260 =item B<customer> string (expandable)
261  
262 ID of the customer who owns the subscription. When expanded, this is a L<Net::API::Stripe::Customer> object.
263  
264 =item B<days_until_due> integer
265  
266 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.
267  
268 =item B<default_payment_method> string (expandable)
269  
270 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.
271  
272 When expanded, this is a L<Net::API::Stripe::Payment::Method> object.
273  
274 =item B<default_source> string (expandable)
275  
276 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.
277  
278 When expanded, this is a L<Net::API::Stripe::Payment::Source> object.
279  
280 =item B<default_tax_rates> array of hashes
281  
282 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.
283  
284 This is an array of L<Net::API::Stripe::Tax::Rate> objects.
285  
286 =item B<discount> hash, discount object
287  
288 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.
289  
290 This is a L<Net::API::Stripe::Billing::Discount> object.
291  
292 =item B<ended_at> timestamp
293  
294 If the subscription has ended, the date the subscription ended.
295  
296 =item B<invoice_customer_balance_settings>()
297  
298 =item B<items> list
299  
300 List of subscription items, each with an attached plan.
301  
302 This is a L<Net::API::Stripe::Billing::Subscription::Items> object.
303  
304 =item B<latest_invoice> string (expandable)
305  
306 The most recent invoice this subscription has generated.
307  
308 When expanded, this is a L<Net::API::Stripe::Billing::Invoice> object.
309  
310 =item B<livemode> boolean
311  
312 Has the value true if the object exists in live mode or the value false if the object exists in test mode.
313  
314 =item B<metadata> hash
315  
316 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.
317  
318 =item B<next_pending_invoice_item_invoice>
319  
320 This is an undocumented property on Stripe, but found in its sample data.
321  
322 This is managed with a virtual module L<Net::API::Billing::Subscription::Item::Invoice>
323  
324 =item B<pause_collection> hash
325  
326 If specified, payment collection for this subscription will be paused.
327  
328 =over 8
329  
330 =item I<pause_collection.behavior> string
331  
332 The payment collection behavior for this subscription while paused. One of keep_as_draft, mark_uncollectible, or void.
333  
334 =item I<resumes_at> timestamp
335  
336 The time after which the subscription will resume collecting payments.
337  
338 =back
339  
340 =item B<off_session> boolean
341  
342 Indicates if a customer is on or off-session while an invoice payment is attempted.
343  
344 =item B<payment_behavior> string
345  
346 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.
347  
348 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.
349  
350 I<pending_if_incomplete> is only used with updates and cannot be passed when creating a subscription.
351 Possible enum values
352  
353 =over 8
354  
355 =item I<allow_incomplete>
356  
357 =item I<error_if_incomplete>
358  
359 =item I<pending_if_incomplete>
360  
361 =back
362  
363 =item B<pending_invoice_item_interval>()
364  
365 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.
366  
367 =over 8
368  
369 =item I<interval> required
370  
371 Specifies invoicing frequency. Either day, week, month or year.
372  
373 =item I<interval_count> optional
374  
375 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).
376  
377 =back
378  
379 =item B<pending_setup_intent> string (expandable)
380  
381 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.
382  
383 When expanded, this is a L<Net::API::Stripe::Payment::Intent::Setup> object.
384  
385 =item B<pending_update>() hash
386  
387 If specified, pending updates that will be applied to the subscription once the latest_invoice has been paid.
388  
389 =over 8
390  
391 =item I<billing_cycle_anchor> timestamp
392  
393 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.
394  
395 =item I<expires_at> timestamp
396  
397 The point after which the changes reflected by this update will be discarded and no longer applied.
398  
399 =item I<subscription_items> array of hashes
400  
401 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.
402  
403 =item I<trial_end> timestamp
404  
405 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.
406  
407 =item I<trial_from_plan> boolean
408  
409 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.
410  
411 =back
412  
413 =item B<plan> hash, plan object
414  
415 Hash describing the plan the customer is subscribed to. Only set if the subscription contains a single plan.
416  
417 This is a L<Net::API::Stripe::Billing::Plan> object.
418  
419 =item B<prorate> boolean (deprecated)
420  
421 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.
422  
423 =item B<proration_behavior> string
424  
425 Determines how to handle prorations resulting from the billing_cycle_anchor. Valid values are I<create_prorations> or I<none>.
426  
427 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.
428  
429 =item B<quantity> integer
430  
431 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.
432  
433 =item B<schedule> string expandable
434  
435 The schedule attached to the subscription. When expanded, this is a L<Net::API::Stripe::Billing::Subscription::Schedule> object.
436  
437 =item B<start> timestamp
438  
439 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.
440  
441 =item B<start_date> timestamp
442  
443 Date when the subscription was first created. The date might differ from the created date due to backdating.
444  
445 =item B<status> string
446  
447 Possible values are incomplete, incomplete_expired, trialing, active, past_due, canceled, or unpaid.
448  
449 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.
450  
451 A subscription that is currently in a trial period is trialing and moves to active when the trial period is over.
452  
453 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.
454  
455 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.
456  
457 =item B<tax_percent> decimal (deprecated)
458  
459 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.
460  
461 =item B<trial_end> timestamp
462  
463 If the subscription has a trial, the end of that trial.
464  
465 =item B<trial_from_plan> boolean
466  
467 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.
468  
469 =item B<trial_period_days> integer
470  
471 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.
472  
473 =item B<trial_start> timestamp
474  
475 If the subscription has a trial, the beginning of that trial.
476  
477 =back
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
« Stripe/Payment/Intent.pm ↑ Summary Stripe/Charge.pm »