Stripe/Billing/Subscription/Schedule.pm

filter: Statementstmt 27.5% 8 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 12.5% 3 / 24 Podpod 100% 21 / 21 totaltotal 43.2% 32 / 74 CC 1 SCAR 6.3
CC
1
Cov
28%
id
2.0
object
2.0
canceled_at
2.0
CRAP 1.9
« Stripe/Billing/Invoice/Item.pm ↑ Summary Stripe/Product.pm »
1 ##----------------------------------------------------------------------------
2 ## Stripe API - ~/lib/Net/API/Stripe/Billing/Subscription/Schedule.pm
3 ## Version v0.100.0
4 ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
6 ## Created 2019/12/25
7 ## Modified 2020/05/15
8 ##
9 ##----------------------------------------------------------------------------
10 package Net::API::Stripe::Billing::Subscription::Schedule;
11 BEGIN
12 {
13 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶ use parent qw( Net::API::Stripe::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶ our( $VERSION ) = 'v0.100.0';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 };
17  
18 0 ▶sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
19  
20 0 ▶sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
Subroutine object: not called CC=1 SCAR=6.9
Pod documented
21  
22 0 ▶sub canceled_at { return( shift->_set_get_datetime( 'canceled_at', @_ ) ); }
Subroutine canceled_at: not called CC=1 SCAR=6.9
Pod documented
23  
24 0 ▶sub completed_at { return( shift->_set_get_datetime( 'completed_at', @_ ) ); }
Subroutine completed_at: not called CC=1 SCAR=6.9
Pod documented
25  
26 0 ▶sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
Subroutine created: not called CC=1 SCAR=6.9
Pod documented
27  
28 sub current_phase
29 {
30 0 ▶ return( shift->_set_get_class( 'current_phase',
Subroutine current_phase: not called CC=1 SCAR=6.9
Pod documented
31 {
32 end_date => { type => 'datetime' },
33 start_date => { type => 'datetime' },
34 }, @_ )
35 );
36 }
37  
38 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
39  
40 sub default_settings
41 {
42 0 ▶ return( shift->_set_get_class( 'default_settings',
Subroutine default_settings: not called CC=1 SCAR=6.9
Pod documented
43 {
44 billing_thresholds => { type => 'object', class => 'Net::API::Stripe::Billing::Thresholds' },
45 collection_method => { type => 'scalar' },
46 default_payment_method => { type => 'scalar_or_object', class => 'Net::API::Stripe::Payment::Method' },
47 invoice_settings => { type => 'class', definition =>
48 {
49 days_until_due => { type => 'scalar' }
50 }}
51 }, @_ )
52 );
53 }
54  
55 0 ▶sub end_behavior { return( shift->_set_get_scalar( 'end_behavior', @_ ) ); }
Subroutine end_behavior: not called CC=1 SCAR=6.9
Pod documented
56  
57 0 ▶sub from_subscription { return( shift->_set_get_scalar_or_object( 'from_subscription', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
Subroutine from_subscription: not called CC=1 SCAR=6.9
Pod documented
58  
59 0 ▶sub invoice_now { return( shift->_set_get_boolean( 'invoice_now', @_ ) ); }
Subroutine invoice_now: not called CC=1 SCAR=6.9
Pod documented
60  
61 0 ▶sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
Subroutine livemode: not called CC=1 SCAR=6.9
Pod documented
62  
63 0 ▶sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
Subroutine metadata: not called CC=1 SCAR=6.9
Pod documented
64  
65 sub phases
66 {
67 0 ▶ return( shift->_set_get_class_array( 'phases',
Subroutine phases: not called CC=1 SCAR=6.9
Pod documented
68 {
69 application_fee_percent => { type => 'number' },
70 billing_thresholds => { type => 'object', class => 'Net::API::Stripe::Billing::Thresholds' },
71 collection_method => { type => 'scalar' },
72 coupon => { type => 'scalar_or_object', class => 'Net::API::Stripe::Billing::Coupon' },
73 default_payment_method => { type => 'scalar_or_object', class => 'Net::API::Stripe::Payment::Method' },
74 default_tax_rates => { type => 'object_array', class => 'Net::API::Stripe::Tax::Rate' },
75 end_date => { type => 'datetime' },
76 invoice_settings => { type => 'class', definition =>
77 {
78 days_until_due => { type => 'number' }
79 }},
80 iterations => { type => 'number' },
81 plans => { type => 'class_array', definition =>
82 {
83 billing_thresholds => { type => 'object', class => 'Net::API::Stripe::Billing::Thresholds' },
84 plan => { type => 'scalar_or_object', class => 'Net::API::Stripe::Billing::Plan' },
85 quantity => { type => 'number' },
86 tax_rates => { type => 'object_array', class => 'Net::APi::Stripe::Tax::Rate' },
87 }},
88 start_date => { type => 'datetime' },
89 trial_end => { type => 'datetime' },
90 }, @_ )
91 );
92 }
93  
94 0 ▶sub preserve_cancel_date { return( shift->_set_get_boolean( 'preserve_cancel_date', @_ ) ); }
Subroutine preserve_cancel_date: not called CC=1 SCAR=6.9
Pod documented
95  
96 0 ▶sub prorate { return( shift->_set_get_boolean( 'prorate', @_ ) ); }
Subroutine prorate: not called CC=1 SCAR=6.9
Pod documented
97  
98 0 ▶sub released_at { return( shift->_set_get_datetime( 'released_at', @_ ) ); }
Subroutine released_at: not called CC=1 SCAR=6.9
Pod documented
99  
100 0 ▶sub released_subscription { return( shift->_set_get_scalar( 'released_subscription', @_ ) ); }
Subroutine released_subscription: not called CC=1 SCAR=6.9
Pod documented
101  
102 0 ▶sub start_date { return( shift->_set_get_datetime( 'start_date', @_ ) ); }
Subroutine start_date: not called CC=1 SCAR=6.9
Pod documented
103  
104 0 ▶sub status { return( shift->_set_get_scalar( 'status', @_ ) ); }
Subroutine status: not called CC=1 SCAR=6.9
Pod documented
105  
106 0 ▶sub subscription { return( shift->_set_get_scalar_or_object( 'subscription', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
Subroutine subscription: not called CC=1 SCAR=6.9
Pod documented
107  
108 1 1;
109  
110 __END__
111  
112 =encoding utf8
113  
114 =head1 NAME
115  
116 Net::API::Stripe::Billing::Subscription::Schedule - A Stripe Subscription Schedule Object
117  
118 =head1 SYNOPSIS
119  
120 my $sched = $stripe->schedule({
121 customer => $customer_object,
122 invoice_now => 1,
123 end_behavior => 'release',
124 });
125  
126 =head1 VERSION
127  
128 v0.100.0
129  
130 =head1 DESCRIPTION
131  
132 A subscription schedule allows you to create and manage the lifecycle of a subscription by predefining expected changes.
133  
134 =head1 CONSTRUCTOR
135  
136 =over 4
137  
138 =item B<new>( %ARG )
139  
140 Creates a new L<Net::API::Stripe::Billing::Subscription::Schedule> object.
141 It may also take an hash like arguments, that also are method of the same name.
142  
143 =back
144  
145 =head1 METHODS
146  
147 =over 4
148  
149 =item B<id> string
150  
151 Unique identifier for the object.
152  
153 =item B<object> string, value is C<subscription_schedule>
154  
155 String representing the object’s type. Objects of the same type share the same value.
156  
157 =item B<canceled_at> timestamp
158  
159 Time at which the subscription schedule was canceled. Measured in seconds since the Unix epoch.
160  
161 =item B<completed_at> timestamp
162  
163 Time at which the subscription schedule was completed. Measured in seconds since the Unix epoch.
164  
165 =item B<created> timestamp
166  
167 Time at which the object was created. Measured in seconds since the Unix epoch.
168  
169 =item B<current_phase> hash
170  
171 Object representing the start and end dates for the current phase of the subscription schedule, if it is active.
172  
173 =over 8
174  
175 =item I<end_date> timestamp
176  
177 =item I<start_date> timestamp
178  
179 =back
180  
181 =item B<customer> string expandable
182  
183 ID of the customer who owns the subscription schedule. When expanded, this is a L<Net::API::Stripe::Customer> object.
184  
185 =item B<default_settings> hash
186  
187 Object representing the subscription schedule’s default settings.
188  
189 =over 12
190  
191 =item I<billing_thresholds> hash
192  
193 Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period
194  
195 This is a L<Net::API::Stripe::Billing::Thresholds> object.
196  
197 =over 16
198  
199 =item I<amount_gte> integer
200  
201 Monetary threshold that triggers the subscription to create an invoice
202  
203 =item I<reset_billing_cycle_anchor> boolean
204  
205 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.
206  
207 =back
208  
209 =item I<collection_method> string
210  
211 Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay the underlying subscription at the end of each billing cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions.
212  
213 =item I<default_payment_method> string expandable
214  
215 ID of the default payment method for the subscription schedule. If not set, invoices will use the default payment method in the customer’s invoice settings. When expanded, this is a L<Net::API::Stripe::Payment::Method> object.
216  
217 =item I<invoice_settings> hash
218  
219 The subscription schedule’s default invoice settings.
220  
221 =over 16
222  
223 =item I<days_until_due> integer
224  
225 Number of days within which a customer must pay invoices generated by this subscription schedule. This value will be null for subscription schedules where billing=charge_automatically.
226  
227 =back
228  
229 =back
230  
231 =item B<end_behavior> string
232  
233 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.
234  
235 =item B<from_subscription> string
236  
237 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.
238  
239 This is used only when creating a subscription schedule.
240  
241 =item B<invoice_now> boolean
242  
243 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.
244  
245 This is used only when cancelling a subscription schedule.
246  
247 =item B<livemode> boolean
248  
249 Has the value true if the object exists in live mode or the value false if the object exists in test mode.
250  
251 =item B<metadata> hash
252  
253 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.
254  
255 =item B<phases> array of hashes
256  
257 Configuration for the subscription schedule’s phases.
258  
259 =over 12
260  
261 =item I<application_fee_percent> decimal
262  
263 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 during this phase of the schedule.
264  
265 =item I<billing_thresholds> hash
266  
267 Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period.
268  
269 This is a L<Net::API::Stripe::Billing::Thresholds> object.
270  
271 =over 16
272  
273 =item I<amount_gte> integer
274  
275 Monetary threshold that triggers the subscription to create an invoice
276  
277 =item I<reset_billing_cycle_anchor> boolean
278  
279 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.
280  
281 =back
282  
283 =item I<collection_method> string
284  
285 Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay the underlying subscription at the end of each billing cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions.
286  
287 =item I<coupon> string expandable
288  
289 ID of the coupon to use during this phase of the subscription schedule. When expanded, this is a L<Net::API::Stripe::Billing::Coupon> object.
290  
291 =item I<default_payment_method> string expandable
292  
293 ID of the default payment method for the subscription schedule. It must belong to the customer associated with the subscription schedule. If not set, invoices will use the default payment method in the customer’s invoice settings.
294  
295 When expanded, this is a L<Net::API::Stripe::Payment::Method> object.
296  
297 =item I<default_tax_rates> array of L<Net::API::Stripe::Tax::Rate> objects.
298  
299 =item I<end_date> timestamp
300  
301 The end of this phase of the subscription schedule.
302  
303 =item I<invoice_settings> hash
304  
305 The subscription schedule’s default invoice settings.
306  
307 =over 16
308  
309 =item I<days_until_due> integer
310  
311 Number of days within which a customer must pay invoices generated by this subscription schedule. This value will be null for subscription schedules where billing=charge_automatically.
312  
313 =back
314  
315 =item I<iterations> integer
316  
317 Integer representing the multiplier applied to the plan interval. For example, iterations=2 applied to a plan with interval=month and interval_count=3 results in a phase of duration 2 * 3 months = 6 months. If set, end_date must not be set.
318  
319 This option is only used in making calls to create or update a subscription schedule.
320  
321 =item I<plans> array of hashes
322  
323 Plans to subscribe during this phase of the subscription schedule.
324  
325 =over 16
326  
327 =item I<billing_thresholds> hash
328  
329 Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period
330  
331 =over 20
332  
333 =item I<usage_gte> integer
334  
335 Usage threshold that triggers the subscription to create an invoice
336  
337 =back
338  
339 =item I<plan> string expandable
340  
341 ID of the plan to which the customer should be subscribed. When expanded, this is a L<Net::API::Stripe::Billing::Plan> object.
342  
343 =item I<quantity> positive integer or zero
344  
345 Quantity of the plan to which the customer should be subscribed.
346  
347 =item I<tax_rates> array of L<Net::APi::Stripe::Tax::Rate> objects.
348  
349 The tax rates which apply to this phase_item. When set, the default_tax_rates on the phase do not apply to this phase_item.
350  
351 =back
352  
353 =item I<start_date> timestamp
354  
355 The start of this phase of the subscription schedule.
356  
357 =item I<trial_end> timestamp
358  
359 When the trial ends within the phase.
360  
361 =back
362  
363 =item B<preserve_cancel_date> boolean
364  
365 Keep any cancellation on the subscription that the schedule has set.
366  
367 This is used only when cancelling subscription schedule.
368  
369 =item B<preserve_cancel_date> boolean
370  
371 Keep any cancellation on the subscription that the schedule has set.
372  
373 This is used only when making a Stripe api call to release a subscription schedule.
374  
375 =item B<prorate> boolean
376  
377 This is only used when making B<update> or B<cancel>.
378  
379 When doing an update and if the update changes the current phase, indicates if the changes should be prorated. Defaults to true.
380  
381 When cancelling the subscription schedule, if the subscription schedule is active, this indicates if the cancellation should be prorated. Defaults to true.
382  
383 =item B<released_at> timestamp
384  
385 Time at which the subscription schedule was released. Measured in seconds since the Unix epoch.
386  
387 =item B<released_subscription> string
388  
389 ID of the subscription once managed by the subscription schedule (if it is released).
390  
391 =item B<start_date> unix timestamp
392  
393 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.
394  
395 This is used only when creating a subscription schedule.
396  
397 =item B<status> string
398  
399 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.
400  
401 =item B<subscription> string expandable
402  
403 ID of the subscription managed by the subscription schedule. When expanded, this is a L<Net::API::Stripe::Billing::Subscription> object.
404  
405 =back
406  
407 =head1 API SAMPLE
408  
409 {
410 "id": "sub_sched_fake123456789",
411 "object": "subscription_schedule",
412 "canceled_at": null,
413 "completed_at": null,
414 "created": 1577193148,
415 "current_phase": null,
416 "customer": "cus_fake123456789",
417 "default_settings": {
418 "billing_thresholds": null,
419 "collection_method": "charge_automatically",
420 "default_payment_method": null,
421 "invoice_settings": null
422 },
423 "end_behavior": "cancel",
424 "livemode": false,
425 "metadata": {},
426 "phases": [
427 {
428 "application_fee_percent": null,
429 "billing_thresholds": null,
430 "collection_method": null,
431 "coupon": null,
432 "default_payment_method": null,
433 "default_tax_rates": [],
434 "end_date": 1572481590,
435 "invoice_settings": null,
436 "plans": [
437 {
438 "billing_thresholds": null,
439 "plan": "gold",
440 "quantity": 1,
441 "tax_rates": []
442 }
443 ],
444 "start_date": 1541031990,
445 "tax_percent": null,
446 "trial_end": null
447 }
448 ],
449 "released_at": null,
450 "released_subscription": null,
451 "status": "not_started",
452 "subscription": null
453 }
454  
455 =head1 HISTORY
456  
457 =head2 v0.1
458  
459 Initial version
460  
461 =head1 AUTHOR
462  
463 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
464  
465 =head1 SEE ALSO
466  
467 Stripe API documentation:
468  
469 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>
470  
471 =head1 COPYRIGHT & LICENSE
472  
473 Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
474  
475 You can use, copy, modify and redistribute this package and associated
476 files under the same terms as Perl itself.
477  
478 =cut
479  
« Stripe/Billing/Invoice/Item.pm ↑ Summary Stripe/Product.pm »