File Coverage

lib/Net/API/Stripe/Billing/Subscription.pm
Criterion Covered Total %
statement 19 74 25.6
branch n/a
condition n/a
subroutine 7 62 11.2
pod 50 55 90.9
total 76 191 39.7


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             package Net::API::Stripe::Billing::Subscription;
12             BEGIN
13             {
14 2     2   21258424 use strict;
  2         15  
  2         62  
15 2     2   11 use warnings;
  2         2  
  2         56  
16 2     2   11 use parent qw( Net::API::Stripe::Generic );
  2         11  
  2         19  
17 2     2   146 use vars qw( $VERSION );
  2         7  
  2         129  
18 2     2   38 our( $VERSION ) = 'v0.301.0';
19             };
20              
21 2     2   10 use strict;
  2         5  
  2         38  
22 2     2   13 use warnings;
  2         4  
  2         2171  
23              
24 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
25              
26 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
27              
28 0     0 0   sub application { return( shift->_set_get_scalar_or_object( 'application', 'Net::API::Stripe::Connect::Account', @_ ) ); }
29              
30 0     0 1   sub application_fee_percent { return( shift->_set_get_number( 'application_fee_percent', @_ ) ); }
31              
32 0     0 0   sub automatic_tax { return( shift->_set_get_class( 'automatic_tax',
33             {
34             enabled => { type => 'boolean' },
35             }, @_ ) ); }
36              
37 0     0 1   sub backdate_start_date { return( shift->_set_get_datetime( 'backdate_start_date', @_ ) ); }
38              
39 0     0 1   sub billing { return( shift->_set_get_scalar( 'billing', @_ ) ); }
40              
41 0     0 1   sub billing_cycle_anchor { return( shift->_set_get_datetime( 'billing_cycle_anchor', @_ ) ); }
42              
43 0     0 1   sub billing_thresholds { return( shift->_set_get_object( 'billing_thresholds', 'Net::API::Stripe::Billing::Thresholds', @_ ) ); }
44              
45 0     0 1   sub cancel_at { return( shift->_set_get_datetime( 'cancel_at', @_ ) ); }
46              
47 0     0 1   sub cancel_at_period_end { return( shift->_set_get_boolean( 'cancel_at_period_end', @_ ) ); }
48              
49 0     0 1   sub canceled_at { return( shift->_set_get_datetime( 'canceled_at', @_ ) ); }
50              
51 0     0 1   sub collection_method { return( shift->_set_get_scalar( 'collection_method', @_ ) ); }
52              
53 0     0 1   sub coupon { return( shift->_set_get_scalar( 'coupon', @_ ) ); }
54              
55 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
56              
57 0     0 1   sub currency { return( shift->_set_get_number( 'currency', @_ ) ); }
58              
59 0     0 1   sub current_period_end { return( shift->_set_get_datetime( 'current_period_end', @_ ) ); }
60              
61 0     0 1   sub current_period_start { return( shift->_set_get_datetime( 'current_period_start', @_ ) ); }
62              
63 0     0 1   sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); }
64              
65 0     0 1   sub days_until_due { return( shift->_set_get_number( 'days_until_due', @_ ) ); }
66              
67 0     0 1   sub default_payment_method { return( shift->_set_get_scalar_or_object( 'default_payment_method', 'Net::API::Stripe::Payment::Method', @_ ) ); }
68              
69 0     0 1   sub default_source { return( shift->_set_get_scalar_or_object( 'default_source', 'Net::API::Stripe::Payment::Source', @_ ) ); }
70              
71 0     0 1   sub default_tax_rates { return( shift->_set_get_object_array( 'default_tax_rates', 'Net::API::Stripe::Tax::Rate', @_ ) ); }
72              
73 0     0 0   sub description { return( shift->_set_get_scalar( 'description', @_ ) ); }
74              
75 0     0 1   sub discount { return( shift->_set_get_object( 'discount', 'Net::API::Stripe::Billing::Discount', @_ ) ); }
76              
77 0     0 1   sub ended_at { return( shift->_set_get_datetime( 'ended_at', @_ ) ); }
78              
79             ## To cancel subscriptions
80              
81 0     0 1   sub invoice_customer_balance_settings { return( shift->_set_get_hash_as_object( 'invoice_customer_balance_settings', 'Net::API::Stripe::Billing::Invoice::BalanceSettings', @_ ) ); }
82              
83 0     0 1   sub invoice_now { return( shift->_set_get_boolean( 'invoice_now', @_ ) ); }
84              
85 0     0 1   sub items { return( shift->_set_get_object( 'items', 'Net::API::Stripe::Billing::Subscription::Items', @_ ) ); }
86              
87 0     0 1   sub latest_invoice { return( shift->_set_get_scalar_or_object( 'latest_invoice', 'Net::API::Stripe::Billing::Invoice', @_ ) ); }
88              
89 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
90              
91 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
92              
93 0     0 1   sub next_pending_invoice_item_invoice { return( shift->_set_get_hash_as_object( 'next_pending_invoice_item_invoice', 'Net::API::Billing::Subscription::Item::Invoice', @_ ) ); }
94              
95 0     0 1   sub off_session { return( shift->_set_get_boolean( 'off_session', @_ ) ); }
96              
97             sub pause_collection
98             {
99 0     0 1   return( shift->_set_get_class( 'pause_collection',
100             {
101             behavior => { type => 'scalar' },
102             resumes_at => { type => 'datetime' },
103             }, @_ ) );
104             }
105              
106 0     0 1   sub payment_behavior { return( shift->_set_get_scalar( 'payment_behavior', @_ ) ); }
107              
108 0     0 0   sub payment_settings { return( shift->_set_get_object( 'payment_settings', 'Net::API::Stripe::Payment::Settings', @_ ) ); }
109              
110 0     0 1   sub pending_invoice_item_interval { return( shift->_set_get_object( 'pending_invoice_item_interval', 'Net::API::Stripe::Billing::Plan', @_ ) ); }
111              
112 0     0 1   sub pending_setup_intent { return( shift->_set_get_scalar_or_object( 'pending_setup_intent', 'Net::API::Stripe::Payment::Intent::Setup', @_ ) ); }
113              
114             sub pending_update
115             {
116 0     0 1   return( shift->_set_get_class( 'pending_update',
117             {
118             billing_cycle_anchor => { type => 'datetime' },
119             expires_at => { type => 'datetime' },
120             subscription_items => { type => 'object_array_object', class => 'Net::API::Stripe::Billing::Subscription::Item' },
121             trial_end => { type => 'datetime' },
122             trial_from_plan => { type => 'boolean' },
123             }, @_ ) );
124             }
125              
126 0     0 1   sub plan { return( shift->_set_get_object( 'plan', 'Net::API::Stripe::Billing::Plan', @_ ) ); }
127              
128 0     0 1   sub prorate { return( shift->_set_get_boolean( 'prorate', @_ ) ); }
129              
130 0     0 1   sub proration_behavior { return( shift->_set_get_scalar( 'proration_behavior', @_ ) ); }
131              
132 0     0 1   sub quantity { return( shift->_set_get_number( 'quantity', @_ ) ); }
133              
134 0     0 1   sub schedule { return( shift->_set_get_scalar_or_object( 'schedule', 'Net::API::Stripe::Billing::Subscription::Schedule', @_ ) ); }
135              
136 0     0 1   sub start { return( shift->_set_get_datetime( 'start', @_ ) ); }
137              
138 0     0 1   sub start_date { return( shift->_set_get_datetime( 'start_date', @_ ) ); }
139              
140 0     0 1   sub status { return( shift->_set_get_scalar( 'status', @_ ) ); }
141              
142 0     0 1   sub tax_percent { return( shift->_set_get_number( 'tax_percent', @_ ) ); }
143              
144 0     0 0   sub test_clock { return( shift->_set_get_scalar_or_object( 'test_clock', 'Net::API::Stripe::Billing::TestClock', @_ ) ); }
145              
146             sub transfer_data
147             {
148 0     0 1   return( shift->_set_get_class( 'transfer_data',
149             {
150             amount_percent => { type => 'number' },
151             destination => { type => 'object', class => 'Net::API::Stripe::Connect::Account' },
152             }, @_ ) );
153             }
154              
155 0     0 1   sub trial_end { return( shift->_set_get_datetime( 'trial_end', @_ ) ); }
156              
157 0     0 1   sub trial_from_plan { return( shift->_set_get_boolean( 'trial_from_plan', @_ ) ); }
158              
159 0     0 1   sub trial_period_days { return( shift->_set_get_number( 'trial_period_days', @_ ) ); }
160              
161 0     0 1   sub trial_start { return( shift->_set_get_datetime( 'trial_start', @_ ) ); }
162              
163             1;
164              
165             __END__
166              
167             =encoding utf8
168              
169             =head1 NAME
170              
171             Net::API::Stripe::Billing::Subscription - A Stripe Subscription Object
172              
173             =head1 SYNOPSIS
174              
175             my $sub = $stripe->subscription({
176             application_fee_percent => 2,
177             # Could also be a unix timestamp
178             backdate_start_date => '2020-01-01',
179             billing_cycle_anchor => '2020-04-01',
180             coupon => 'SUMMER10POFF',
181             current_period_end => '2020-06-30',
182             customer => $cust_object,
183             days_until_due => 7,
184             default_payment_method => 'pm_fake123456789',
185             metadata => { transaction_id => 1212, customer_id => 123 },
186             off_session => $stripe->true,
187             payment_behavior => 'error_if_incomplete',
188             plan => $plan_object,
189             quantity => 1,
190             });
191              
192             =head1 VERSION
193              
194             v0.301.0
195              
196             =head1 DESCRIPTION
197              
198             Subscriptions allow you to charge a customer on a recurring basis.
199              
200             =head1 CONSTRUCTOR
201              
202             =head2 new( %ARG )
203              
204             Creates a new L<Net::API::Stripe::Billing::Subscription> object.
205             It may also take an hash like arguments, that also are method of the same name.
206              
207             =head1 METHODS
208              
209             =head2 id string
210              
211             Unique identifier for the object.
212              
213             =head2 object string, value is "subscription"
214              
215             String representing the object’s type. Objects of the same type share the same value.
216              
217             =head2 application_fee_percent decimal
218              
219             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.
220              
221             =head2 backdate_start_date
222              
223             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.
224              
225             =head2 billing
226              
227             String like C<charge_automatically>, but not documented.
228              
229             =head2 billing_cycle_anchor timestamp
230              
231             Determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices.
232              
233             =head2 billing_thresholds hash
234              
235             Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period
236              
237             This is a L<Net::API::Stripe::Billing::Thresholds> object.
238              
239             =over 4
240              
241             =item I<amount_gte> integer
242              
243             Monetary threshold that triggers the subscription to create an invoice
244              
245             =item I<reset_billing_cycle_anchor> boolean
246              
247             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.
248              
249             =back
250              
251             =head2 cancel_at timestamp
252              
253             This is an undocumented property returned by Stripe, and I assume this is a duplicate to the B<canceled_at> one.
254              
255             This is added here, so returned data does not yield a warning, but obviously this should not be used otherwise.
256              
257             According to Stripe support as of 2019-11-07, this is:
258              
259             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.
260              
261             =head2 cancel_at_period_end boolean
262              
263             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.
264              
265             =head2 canceled_at timestamp
266              
267             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.
268              
269             =head2 collection_method string
270              
271             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.
272              
273             =head2 coupon string
274              
275             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.
276              
277             =head2 created timestamp
278              
279             Time at which the object was created. Measured in seconds since the Unix epoch.
280              
281             =head2 currency currency
282              
283             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>.
284              
285             =head2 current_period_end timestamp
286              
287             End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created.
288              
289             =head2 current_period_start timestamp
290              
291             Start of the current period that the subscription has been invoiced for.
292              
293             =head2 customer string (expandable)
294              
295             ID of the customer who owns the subscription. When expanded, this is a L<Net::API::Stripe::Customer> object.
296              
297             =head2 days_until_due integer
298              
299             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.
300              
301             =head2 default_payment_method string (expandable)
302              
303             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.
304              
305             When expanded, this is a L<Net::API::Stripe::Payment::Method> object.
306              
307             =head2 default_source string (expandable)
308              
309             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.
310              
311             When expanded, this is a L<Net::API::Stripe::Payment::Source> object.
312              
313             =head2 default_tax_rates array of hashes
314              
315             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.
316              
317             This is an array of L<Net::API::Stripe::Tax::Rate> objects.
318              
319             =head2 discount hash, discount object
320              
321             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.
322              
323             This is a L<Net::API::Stripe::Billing::Discount> object.
324              
325             =head2 ended_at timestamp
326              
327             If the subscription has ended, the date the subscription ended.
328              
329             =head2 invoice_customer_balance_settings
330              
331             This is a L<Net::API::Stripe::Billing::Invoice::BalanceSettings> object.
332              
333             =head2 invoice_now boolean
334              
335             Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items.
336              
337             This is used to cancel a subscription. See here: L<https://stripe.com/docs/api/subscriptions/cancel>
338              
339             =head2 items list
340              
341             List of subscription items, each with an attached plan.
342              
343             This is a L<Net::API::Stripe::Billing::Subscription::Items> object.
344              
345             =head2 latest_invoice string (expandable)
346              
347             The most recent invoice this subscription has generated.
348              
349             When expanded, this is a L<Net::API::Stripe::Billing::Invoice> object.
350              
351             =head2 livemode boolean
352              
353             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
354              
355             =head2 metadata hash
356              
357             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.
358              
359             =head2 next_pending_invoice_item_invoice
360              
361             This is an undocumented property on Stripe, but found in its sample data.
362              
363             This is managed with a virtual module L<Net::API::Billing::Subscription::Item::Invoice>
364              
365             =head2 off_session boolean
366              
367             Indicates if a customer is on or off-session while an invoice payment is attempted.
368              
369             =head2 pause_collection hash
370              
371             If specified, payment collection for this subscription will be paused.
372              
373             =over 4
374              
375             =item I<pause_collection.behavior> string
376              
377             The payment collection behavior for this subscription while paused. One of keep_as_draft, mark_uncollectible, or void.
378              
379             =item I<resumes_at> timestamp
380              
381             The time after which the subscription will resume collecting payments.
382              
383             =back
384              
385             =head2 payment_behavior string
386              
387             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.
388              
389             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.
390              
391             I<pending_if_incomplete> is only used with updates and cannot be passed when creating a subscription.
392             Possible enum values
393              
394             =over 4
395              
396             =item I<allow_incomplete>
397              
398             =item I<error_if_incomplete>
399              
400             =item I<pending_if_incomplete>
401              
402             =back
403              
404             =head2 pending_invoice_item_interval
405              
406             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.
407              
408             =over 4
409              
410             =item I<interval> required
411              
412             Specifies invoicing frequency. Either day, week, month or year.
413              
414             =item I<interval_count> optional
415              
416             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).
417              
418             =back
419              
420             =head2 pending_setup_intent string (expandable)
421              
422             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.
423              
424             When expanded, this is a L<Net::API::Stripe::Payment::Intent::Setup> object.
425              
426             =head2 pending_update hash
427              
428             If specified, pending updates that will be applied to the subscription once the latest_invoice has been paid.
429              
430             =over 4
431              
432             =item I<billing_cycle_anchor> timestamp
433              
434             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.
435              
436             =item I<expires_at> timestamp
437              
438             The point after which the changes reflected by this update will be discarded and no longer applied.
439              
440             =item I<subscription_items> array of hashes
441              
442             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.
443              
444             =item I<trial_end> timestamp
445              
446             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.
447              
448             =item I<trial_from_plan> boolean
449              
450             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.
451              
452             =back
453              
454             =head2 plan hash, plan object
455              
456             Hash describing the plan the customer is subscribed to. Only set if the subscription contains a single plan.
457              
458             This is a L<Net::API::Stripe::Billing::Plan> object.
459              
460             =head2 prorate boolean (deprecated)
461              
462             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.
463              
464             =head2 proration_behavior string
465              
466             Determines how to handle prorations resulting from the billing_cycle_anchor. Valid values are I<create_prorations> or I<none>.
467              
468             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.
469              
470             =head2 quantity integer
471              
472             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.
473              
474             =head2 schedule string expandable
475              
476             The schedule attached to the subscription. When expanded, this is a L<Net::API::Stripe::Billing::Subscription::Schedule> object.
477              
478             =head2 start timestamp
479              
480             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.
481              
482             =head2 start_date timestamp
483              
484             Date when the subscription was first created. The date might differ from the created date due to backdating.
485              
486             =head2 status string
487              
488             Possible values are incomplete, incomplete_expired, trialing, active, past_due, canceled, or unpaid.
489              
490             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.
491              
492             A subscription that is currently in a trial period is trialing and moves to active when the trial period is over.
493              
494             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.
495              
496             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.
497              
498             =head2 tax_percent decimal (deprecated)
499              
500             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.
501              
502             =head2 transfer_data hash
503              
504             This is for Connect only.
505              
506             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.
507              
508             =over 4
509              
510             =item I<amount_percent> decimal
511              
512             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.
513              
514             =item I<destination> string expandable
515              
516             The account where funds from the payment will be transferred to upon payment success.
517              
518             =back
519              
520             =head2 trial_end timestamp
521              
522             If the subscription has a trial, the end of that trial.
523              
524             =head2 trial_from_plan boolean
525              
526             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.
527              
528             =head2 trial_period_days integer
529              
530             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.
531              
532             =head2 trial_start timestamp
533              
534             If the subscription has a trial, the beginning of that trial.
535              
536             =head1 API SAMPLE
537              
538             {
539             "id": "sub_fake123456789",
540             "object": "subscription",
541             "application_fee_percent": null,
542             "billing": "charge_automatically",
543             "billing_cycle_anchor": 1551492959,
544             "billing_thresholds": null,
545             "cancel_at_period_end": false,
546             "canceled_at": 1555726796,
547             "collection_method": "charge_automatically",
548             "created": 1551492959,
549             "current_period_end": 1556763359,
550             "current_period_start": 1554171359,
551             "customer": "cus_fake123456789",
552             "days_until_due": null,
553             "default_payment_method": null,
554             "default_source": null,
555             "default_tax_rates": [],
556             "discount": null,
557             "ended_at": 1555726796,
558             "items": {
559             "object": "list",
560             "data": [
561             {
562             "id": "si_fake123456789",
563             "object": "subscription_item",
564             "billing_thresholds": null,
565             "created": 1551492959,
566             "metadata": {},
567             "plan": {
568             "id": "professional-monthly-jpy",
569             "object": "plan",
570             "active": true,
571             "aggregate_usage": null,
572             "amount": 8000,
573             "amount_decimal": "8000",
574             "billing_scheme": "per_unit",
575             "created": 1541833564,
576             "currency": "jpy",
577             "interval": "month",
578             "interval_count": 1,
579             "livemode": false,
580             "metadata": {},
581             "nickname": null,
582             "product": "prod_fake123456789",
583             "tiers": null,
584             "tiers_mode": null,
585             "transform_usage": null,
586             "trial_period_days": null,
587             "usage_type": "licensed"
588             },
589             "quantity": 1,
590             "subscription": "sub_fake123456789",
591             "tax_rates": []
592             }
593             ],
594             "has_more": false,
595             "url": "/v1/subscription_items?subscription=sub_fake123456789"
596             },
597             "latest_invoice": "in_fake123456789",
598             "livemode": false,
599             "metadata": {},
600             "pending_setup_intent": null,
601             "plan": {
602             "id": "professional-monthly-jpy",
603             "object": "plan",
604             "active": true,
605             "aggregate_usage": null,
606             "amount": 8000,
607             "amount_decimal": "8000",
608             "billing_scheme": "per_unit",
609             "created": 1541833564,
610             "currency": "jpy",
611             "interval": "month",
612             "interval_count": 1,
613             "livemode": false,
614             "metadata": {},
615             "nickname": null,
616             "product": "prod_fake123456789",
617             "tiers": null,
618             "tiers_mode": null,
619             "transform_usage": null,
620             "trial_period_days": null,
621             "usage_type": "licensed"
622             },
623             "quantity": 1,
624             "start": 1554430777,
625             "start_date": 1551492959,
626             "status": "canceled",
627             "tax_percent": null,
628             "trial_end": null,
629             "trial_start": null
630             }
631              
632             =head1 HISTORY
633              
634             =head2 v0.1
635              
636             Initial version
637              
638             =head1 AUTHOR
639              
640             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
641              
642             =head1 SEE ALSO
643              
644             Stripe API documentation:
645              
646             L<https://stripe.com/docs/api/subscriptions>, L<https://stripe.com/docs/billing/subscriptions/creating>
647              
648             =head1 COPYRIGHT & LICENSE
649              
650             Copyright (c) 2020 DEGUEST Pte. Ltd.
651              
652             You can use, copy, modify and redistribute this package and associated
653             files under the same terms as Perl itself.
654              
655             =cut