File Coverage

lib/Net/API/Stripe/Billing/Subscription/Schedule.pm
Criterion Covered Total %
statement 19 47 40.4
branch n/a
condition n/a
subroutine 7 35 20.0
pod 28 28 100.0
total 54 110 49.0


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Billing/Subscription/Schedule.pm
3             ## Version v0.101.0
4             ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/12/25
7             ## Modified 2022/10/29
8             ## All rights reserved
9             ##
10             ## This program is free software; you can redistribute it and/or modify it
11             ## under the same terms as Perl itself.
12             ##----------------------------------------------------------------------------
13             package Net::API::Stripe::Billing::Subscription::Schedule;
14             BEGIN
15             {
16 2     2   21077927 use strict;
  2         18  
  2         61  
17 2     2   11 use warnings;
  2         5  
  2         61  
18 2     2   12 use parent qw( Net::API::Stripe::Generic );
  2         8  
  2         11  
19 2     2   150 use vars qw( $VERSION );
  2         7  
  2         148  
20 2     2   42 our( $VERSION ) = 'v0.101.0';
21             };
22              
23 2     2   12 use strict;
  2         3  
  2         44  
24 2     2   15 use warnings;
  2         7  
  2         1164  
25              
26 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
27              
28 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
29              
30 0     0 1   sub application { return( shift->_set_get_scalar_or_object( 'application', 'Net::API::Stripe::Connect::Account', @_ ) ); }
31              
32 0     0 1   sub canceled_at { return( shift->_set_get_datetime( 'canceled_at', @_ ) ); }
33              
34 0     0 1   sub completed_at { return( shift->_set_get_datetime( 'completed_at', @_ ) ); }
35              
36 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
37              
38             sub current_phase
39             {
40 0     0 1   return( shift->_set_get_class( 'current_phase',
41             {
42             end_date => { type => 'datetime' },
43             start_date => { type => 'datetime' },
44             }, @_ )
45             );
46             }
47              
48 0     0 1   sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); }
49              
50 0     0 1   sub default_settings { return( shift->_set_get_object( 'default_settings', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
51              
52 0     0 1   sub end_behavior { return( shift->_set_get_scalar( 'end_behavior', @_ ) ); }
53              
54 0     0 1   sub from_subscription { return( shift->_set_get_scalar_or_object( 'from_subscription', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
55              
56 0     0 1   sub invoice_now { return( shift->_set_get_boolean( 'invoice_now', @_ ) ); }
57              
58 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
59              
60 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
61              
62 0     0 1   sub phases { return( shift->_set_get_object_array( 'phases', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
63              
64 0     0 1   sub preserve_cancel_date { return( shift->_set_get_boolean( 'preserve_cancel_date', @_ ) ); }
65              
66 0     0 1   sub prorate { return( shift->_set_get_boolean( 'prorate', @_ ) ); }
67              
68 0     0 1   sub proration_behavior { return( shift->_set_get_scalar( 'proration_behavior', @_ ) ); }
69              
70 0     0 1   sub released_at { return( shift->_set_get_datetime( 'released_at', @_ ) ); }
71              
72 0     0 1   sub released_subscription { return( shift->_set_get_scalar( 'released_subscription', @_ ) ); }
73              
74 0     0 1   sub renewal_interval { return( shift->_set_get_scalar( 'renewal_interval', @_ ) ); }
75              
76 0     0 1   sub start_date { return( shift->_set_get_datetime( 'start_date', @_ ) ); }
77              
78 0     0 1   sub status { return( shift->_set_get_scalar( 'status', @_ ) ); }
79              
80 0     0 1   sub subscription { return( shift->_set_get_scalar_or_object( 'subscription', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
81              
82             ## Undocumented but appears in data returned
83              
84 0     0 1   sub tax_percent { return( shift->_set_get_number( 'tax_percent', @_ ) ); }
85              
86             ## Undocumented but appears in data returned
87              
88 0     0 1   sub test_clock { return( shift->_set_get_scalar_or_object( 'test_clock', 'Net::API::Stripe::Billing::TestHelpersTestClock', @_ ) ); }
89              
90             sub transfer_data
91             {
92 0     0 1   return( shift->_set_get_class( 'transfer_data',
93             {
94             amount_percent => { type => 'number' },
95             destination => { type => 'object', class => 'Net::API::Stripe::Connect::Account' },
96             }, @_ ) );
97             }
98              
99             ## Undocumented but appears in data returned
100              
101 0     0 1   sub trial_end { return( shift->_set_get_datetime( 'trial_end', @_ ) ); }
102              
103             1;
104              
105             __END__
106              
107             =encoding utf8
108              
109             =head1 NAME
110              
111             Net::API::Stripe::Billing::Subscription::Schedule - A Stripe Subscription Schedule Object
112              
113             =head1 SYNOPSIS
114              
115             my $sched = $stripe->schedule({
116             customer => $customer_object,
117             invoice_now => 1,
118             end_behavior => 'release',
119             });
120              
121             =head1 VERSION
122              
123             v0.101.0
124              
125             =head1 DESCRIPTION
126              
127             A subscription schedule allows you to create and manage the lifecycle of a subscription by predefining expected changes.
128              
129             =head1 CONSTRUCTOR
130              
131             =head2 new( %ARG )
132              
133             Creates a new L<Net::API::Stripe::Billing::Subscription::Schedule> object.
134             It may also take an hash like arguments, that also are method of the same name.
135              
136             =head1 METHODS
137              
138             =head2 id string
139              
140             Unique identifier for the object.
141              
142             =head2 object string, value is C<subscription_schedule>
143              
144             String representing the object’s type. Objects of the same type share the same value.
145              
146             =head2 application expandable
147              
148             ID of the Connect Application that created the schedule.
149              
150             When expanded this is an L<Net::API::Stripe::Connect::Account> object.
151              
152             =head2 canceled_at timestamp
153              
154             Time at which the subscription schedule was canceled. Measured in seconds since the Unix epoch.
155              
156             =head2 completed_at timestamp
157              
158             Time at which the subscription schedule was completed. Measured in seconds since the Unix epoch.
159              
160             =head2 created timestamp
161              
162             Time at which the object was created. Measured in seconds since the Unix epoch.
163              
164             =head2 current_phase hash
165              
166             Object representing the start and end dates for the current phase of the subscription schedule, if it is active.
167              
168             =over 4
169              
170             =item I<end_date> timestamp
171              
172             =item I<start_date> timestamp
173              
174             =back
175              
176             =head2 customer string expandable
177              
178             ID of the customer who owns the subscription schedule. When expanded, this is a L<Net::API::Stripe::Customer> object.
179              
180             =head2 default_settings object
181              
182             Object representing the subscription schedule's default settings.
183              
184             This is a L<Net::API::Stripe::Billing::Subscription> object.
185              
186             =head2 end_behavior string
187              
188             Configures how the subscription schedule behaves when it ends. Possible values are I<release> or I<cancel> with the default being release. release will end the subscription schedule and keep the underlying subscription running.cancel will end the subscription schedule and cancel the underlying subscription.
189              
190             =head2 from_subscription string
191              
192             Migrate an existing subscription to be managed by a subscription schedule. If this parameter is set, a subscription schedule will be created using the subscription’s plan(s), set to auto-renew using the subscription’s interval. When using this parameter, other parameters (such as phase values) cannot be set. To create a subscription schedule with other modifications, Stripe recommends making two separate API calls.
193              
194             This is used only when creating a subscription schedule.
195              
196             =head2 invoice_now boolean
197              
198             If the subscription schedule is active, indicates whether or not to generate a final invoice that contains any un-invoiced metered usage and new/pending proration invoice items. Defaults to true.
199              
200             This is used only when cancelling a subscription schedule.
201              
202             =head2 livemode boolean
203              
204             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
205              
206             =head2 metadata hash
207              
208             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.
209              
210             =head2 phases array of objects
211              
212             Configuration for the subscription schedule's phases.
213              
214             This is a L<Net::API::Stripe::Billing::Subscription> object.
215              
216             =head2 preserve_cancel_date boolean
217              
218             Keep any cancellation on the subscription that the schedule has set.
219              
220             This is used only when making a Stripe api call to release a subscription schedule.
221              
222             =head2 prorate boolean
223              
224             This is only used when making B<update> or B<cancel>.
225              
226             When doing an update and if the update changes the current phase, indicates if the changes should be prorated. Defaults to true.
227              
228             When cancelling the subscription schedule, if the subscription schedule is active, this indicates if the cancellation should be prorated. Defaults to true.
229              
230             =head2 proration_behavior string
231              
232             Determines how to handle prorations resulting from the billing_cycle_anchor. Valid values are I<create_prorations> or I<none>.
233              
234             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.
235              
236             This property is not documented on Stripe api documentation, but appears in data returned as of 2020-12-02.
237              
238             =head2 released_at timestamp
239              
240             Time at which the subscription schedule was released. Measured in seconds since the Unix epoch.
241              
242             =head2 released_subscription string
243              
244             ID of the subscription once managed by the subscription schedule (if it is released).
245              
246             =head2 renewal_interval
247              
248             This property was found in the data returned from Stripe, but is not documented yet as of 2020-12-03.
249              
250             =head2 start_date unix timestamp
251              
252             When the subscription schedule starts. Stripe recommends using now so that it starts the subscription immediately. You can also use a Unix timestamp to backdate the subscription so that it starts on a past date, or set a future date for the subscription to start on. When you backdate, the billing_cycle_anchor of the subscription is equivalent to the start_date.
253              
254             This is used only when creating a subscription schedule.
255              
256             =head2 status string
257              
258             The present status of the subscription schedule. Possible values are not_started, active, completed, released, and canceled. You can read more about the different states in Stripe behavior guide.
259              
260             =head2 subscription string expandable
261              
262             ID of the subscription managed by the subscription schedule. When expanded, this is a L<Net::API::Stripe::Billing::Subscription> object.
263              
264             =head2 tax_percent decimal (deprecated)
265              
266             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.
267              
268             This is an undocumented property for Subscription Schedule that usually belonging to L<Subscription|Net::API::Stripe::Billing::Subscription>, but that appears in data returned by Stripe.
269              
270             =head2 test_clock expandable
271              
272             ID of the test clock this subscription schedule belongs to.
273              
274             When expanded this is an L<Net::API::Stripe::Billing::TestHelpersTestClock> object.
275              
276             =head2 transfer_data hash
277              
278             This is for Connect only.
279              
280             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.
281              
282             This is an undocumented property for Subscription Schedule that usually belonging to L<Subscription|Net::API::Stripe::Billing::Subscription>, but that appears in data returned by Stripe.
283              
284             =over 4
285              
286             =item I<amount_percent> decimal
287              
288             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.
289              
290             =item I<destination> string expandable
291              
292             The account where funds from the payment will be transferred to upon payment success.
293              
294             =back
295              
296             =head2 trial_end timestamp
297              
298             If the subscription has a trial, the end of that trial.
299              
300             This is an undocumented property for Subscription Schedule that usually belonging to L<Subscription|Net::API::Stripe::Billing::Subscription>, but that appears in data returned by Stripe.
301              
302             =head1 API SAMPLE
303              
304             {
305             "id": "sub_sched_fake123456789",
306             "object": "subscription_schedule",
307             "canceled_at": null,
308             "completed_at": null,
309             "created": 1577193148,
310             "current_phase": null,
311             "customer": "cus_fake123456789",
312             "default_settings": {
313             "billing_thresholds": null,
314             "collection_method": "charge_automatically",
315             "default_payment_method": null,
316             "invoice_settings": null
317             },
318             "end_behavior": "cancel",
319             "livemode": false,
320             "metadata": {},
321             "phases": [
322             {
323             "application_fee_percent": null,
324             "billing_thresholds": null,
325             "collection_method": null,
326             "coupon": null,
327             "default_payment_method": null,
328             "default_tax_rates": [],
329             "end_date": 1572481590,
330             "invoice_settings": null,
331             "plans": [
332             {
333             "billing_thresholds": null,
334             "plan": "gold",
335             "quantity": 1,
336             "tax_rates": []
337             }
338             ],
339             "start_date": 1541031990,
340             "tax_percent": null,
341             "trial_end": null
342             }
343             ],
344             "released_at": null,
345             "released_subscription": null,
346             "status": "not_started",
347             "subscription": null
348             }
349              
350             =head1 HISTORY
351              
352             =head2 v0.1
353              
354             Initial version
355              
356             =head1 AUTHOR
357              
358             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
359              
360             =head1 SEE ALSO
361              
362             Stripe API documentation:
363              
364             L<https://stripe.com/docs/api>, L<https://stripe.com/docs/api/subscription_schedules/object>, L<https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing>
365              
366             See also L<use cases|https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases>
367              
368             =head1 COPYRIGHT & LICENSE
369              
370             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
371              
372             You can use, copy, modify and redistribute this package and associated
373             files under the same terms as Perl itself.
374              
375             =cut