File Coverage

lib/Net/API/Stripe/Billing/Quote.pm
Criterion Covered Total %
statement 19 54 35.1
branch n/a
condition n/a
subroutine 7 42 16.6
pod 33 35 94.2
total 59 131 45.0


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Billing/Quote
3             ## Version v0.2.0
4             ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2022/01/24
7             ## Modified 2022/10/29
8             ##
9             ##----------------------------------------------------------------------------
10             package Net::API::Stripe::Billing::Quote;
11             BEGIN
12             {
13 2     2   21350514 use strict;
  2         17  
  2         66  
14 2     2   14 use warnings;
  2         4  
  2         62  
15 2     2   12 use parent qw( Net::API::Stripe::Generic );
  2         3  
  2         12  
16 2     2   136 use vars qw( $VERSION );
  2         5  
  2         132  
17 2     2   38 our( $VERSION ) = 'v0.2.0';
18             };
19              
20 2     2   16 use strict;
  2         3  
  2         38  
21 2     2   10 use warnings;
  2         4  
  2         1578  
22              
23 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
24              
25 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
26              
27 0     0 1   sub amount_subtotal { return( shift->_set_get_number( 'amount_subtotal', @_ ) ); }
28              
29 0     0 1   sub amount_total { return( shift->_set_get_number( 'amount_total', @_ ) ); }
30              
31 0     0 0   sub application { return( shift->_set_get_scalar_or_object( 'application', 'Net::API::Stripe::Connect::Account', @_ ) ); }
32              
33 0     0 1   sub application_fee_amount { return( shift->_set_get_number( 'application_fee_amount', @_ ) ); }
34              
35 0     0 1   sub application_fee_percent { return( shift->_set_get_number( 'application_fee_percent', @_ ) ); }
36              
37 0     0 1   sub automatic_tax { return( shift->_set_get_class( 'automatic_tax',
38             {
39             enabled => { type => "boolean" },
40             status => { type => "scalar" },
41             }, @_ ) ); }
42              
43 0     0 1   sub collection_method { return( shift->_set_get_scalar( 'collection_method', @_ ) ); }
44              
45 0     0 1   sub computed { return( shift->_set_get_class( 'computed',
46             {
47             recurring => { package => "Net::API::Stripe::Checkout::Session", type => "object" },
48             upfront => { package => "Net::API::Stripe::Checkout::Session", type => "object" },
49             }, @_ ) ); }
50              
51 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
52              
53 0     0 1   sub currency { return( shift->_set_get_scalar( 'currency', @_ ) ); }
54              
55 0     0 1   sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); }
56              
57 0     0 1   sub default_tax_rates { return( shift->_set_get_scalar_or_object( 'default_tax_rates', 'Net::API::Stripe::Tax::Rate', @_ ) ); }
58              
59 0     0 1   sub description { return( shift->_set_get_scalar( 'description', @_ ) ); }
60              
61 0     0 1   sub discounts { return( shift->_set_get_scalar_or_object( 'discounts', 'Net::API::Stripe::Billing::Discount', @_ ) ); }
62              
63 0     0 1   sub expires_at { return( shift->_set_get_datetime( 'expires_at', @_ ) ); }
64              
65 0     0 1   sub footer { return( shift->_set_get_scalar( 'footer', @_ ) ); }
66              
67 0     0 1   sub from_quote { return( shift->_set_get_class( 'from_quote',
68             {
69             is_revision => { type => "boolean" },
70             quote => {
71             package => "Net::API::Stripe::Billing::Quote",
72             type => "scalar_or_object",
73             },
74             }, @_ ) ); }
75              
76 0     0 1   sub header { return( shift->_set_get_scalar( 'header', @_ ) ); }
77              
78 0     0 1   sub invoice { return( shift->_set_get_scalar_or_object( 'invoice', 'Net::API::Stripe::Billing::Invoice', @_ ) ); }
79              
80 0     0 1   sub invoice_settings { return( shift->_set_get_object( 'invoice_settings', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
81              
82 0     0 1   sub line_items { return( shift->_set_get_object( 'line_items', 'Net::API::Stripe::List', @_ ) ); }
83              
84 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
85              
86 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
87              
88 0     0 1   sub number { return( shift->_set_get_scalar( 'number', @_ ) ); }
89              
90 0     0 1   sub on_behalf_of { return( shift->_set_get_scalar_or_object( 'on_behalf_of', 'Net::API::Stripe::Connect::Account', @_ ) ); }
91              
92 0     0 1   sub status { return( shift->_set_get_scalar( 'status', @_ ) ); }
93              
94 0     0 1   sub status_transitions { return( shift->_set_get_class( 'status_transitions',
95             {
96             accepted_at => { type => "datetime" },
97             canceled_at => { type => "datetime" },
98             finalized_at => { type => "datetime" },
99             }, @_ ) ); }
100              
101 0     0 1   sub subscription { return( shift->_set_get_scalar_or_object( 'subscription', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
102              
103 0     0 1   sub subscription_data { return( shift->_set_get_object( 'subscription_data', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
104              
105 0     0 1   sub subscription_schedule { return( shift->_set_get_scalar_or_object( 'subscription_schedule', 'Net::API::Stripe::Billing::Subscription::Schedule', @_ ) ); }
106              
107 0     0 0   sub test_clock { return( shift->_set_get_scalar_or_object( 'test_clock', 'Net::API::Stripe::Billing::TestClock', @_ ) ); }
108              
109 0     0 1   sub total_details { return( shift->_set_get_class( 'total_details',
110             {
111             amount_discount => { type => "number" },
112             amount_shipping => { type => "number" },
113             amount_tax => { type => "number" },
114             breakdown => {
115             definition => {
116             discounts => {
117             definition =>
118             {
119             amount => { type => "number" },
120             discount => { package => "Net::API::Stripe::Billing::Discount", type => "object" }
121             },
122             type => "class_array",
123             },
124             taxes => {
125             definition => {
126             amount => { type => "number" },
127             rate => { package => "Net::API::Stripe::Tax::Rate", type => "object" },
128             },
129             type => "class_array",
130             },
131             },
132             type => "class",
133             },
134             }, @_ ) ); }
135              
136 0     0 1   sub transfer_data { return( shift->_set_get_object( 'transfer_data', 'Net::API::Stripe::Charge', @_ ) ); }
137              
138             1;
139              
140             __END__
141              
142             =encoding utf8
143              
144             =head1 NAME
145              
146             Net::API::Stripe::Billing::Quote - The quote object
147              
148             =head1 SYNOPSIS
149              
150             =head1 VERSION
151              
152             v0.2.0
153              
154             =head1 DESCRIPTION
155              
156             A Quote is a way to model prices that you'd like to provide to a customer.
157             Once accepted, it will automatically create an invoice, subscription or subscription schedule.
158              
159             =head1 METHODS
160              
161             =head2 id string
162              
163             Unique identifier for the object.
164              
165             =head2 object string
166              
167             String representing the object's type. Objects of the same type share the same value.
168              
169             =head2 amount_subtotal integer
170              
171             Total before any discounts or taxes are applied.
172              
173             =head2 amount_total integer
174              
175             Total after discounts and taxes are applied.
176              
177             =head2 application_fee_amount integer
178              
179             The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. Only applicable if there are no line items with recurring prices on the quote.
180              
181             =head2 application_fee_percent decimal
182              
183             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. Only applicable if there are line items with recurring prices on the quote.
184              
185             =head2 automatic_tax hash
186              
187             Settings for automatic tax lookup for this quote and resulting invoices and subscriptions.
188              
189             It has the following properties:
190              
191             =over 4
192              
193             =item I<enabled> boolean
194              
195             Automatically calculate taxes
196              
197             =item I<status> string
198              
199             The status of the most recent automated tax calculation for this quote.
200              
201              
202             =back
203              
204             =head2 collection_method string
205              
206             Either C<charge_automatically>, or C<send_invoice>. When charging automatically, Stripe will attempt to pay invoices at the end of the subscription cycle or on finalization using the default payment method attached to the subscription or customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions. Defaults to C<charge_automatically>.
207              
208             =head2 computed hash
209              
210             The definitive totals and line items for the quote, computed based on your inputted line items as well as other configuration such as trials. Used for rendering the quote to your customer.
211              
212             It has the following properties:
213              
214             =over 4
215              
216             =item I<recurring> hash
217              
218             The definitive totals and line items the customer will be charged on a recurring basis. Takes into account the line items with recurring prices and discounts with C<duration=forever> coupons only. Defaults to C<null> if no inputted line items with recurring prices.
219              
220             When expanded, this is a L<Net::API::Stripe::Checkout::Session> object.
221              
222             =item I<upfront> hash
223              
224             The definitive upfront totals and line items the customer will be charged on the first invoice.
225              
226             When expanded, this is a L<Net::API::Stripe::Checkout::Session> object.
227              
228              
229             =back
230              
231             =head2 created timestamp
232              
233             Time at which the object was created. Measured in seconds since the Unix epoch.
234              
235             =head2 currency string
236              
237             Three-letter L<ISO currency code|ISO currency code>, in lowercase. Must be a L<supported currency|supported currency>.
238              
239             =head2 customer expandable
240              
241             The customer which this quote belongs to. A customer is required before finalizing the quote. Once specified, it cannot be changed.
242              
243             When expanded this is an L<Net::API::Stripe::Customer> object.
244              
245             =head2 default_tax_rates expandable
246              
247             The tax rates applied to this quote.
248              
249             When expanded this is an L<Net::API::Stripe::Tax::Rate> object.
250              
251             =head2 description string
252              
253             A description that will be displayed on the quote PDF.
254              
255             =head2 discounts expandable
256              
257             The discounts applied to this quote.
258              
259             When expanded this is an L<Net::API::Stripe::Billing::Discount> object.
260              
261             =head2 expires_at timestamp
262              
263             The date on which the quote will be canceled if in C<open> or C<draft> status. Measured in seconds since the Unix epoch.
264              
265             =head2 footer string
266              
267             A footer that will be displayed on the quote PDF.
268              
269             =head2 from_quote hash
270              
271             Details of the quote that was cloned. See the L<cloning documentation|cloning documentation> for more details.
272              
273             It has the following properties:
274              
275             =over 4
276              
277             =item I<is_revision> boolean
278              
279             Whether this quote is a revision of a different quote.
280              
281             =item I<quote> string expandable
282              
283             The quote that was cloned.
284              
285             When expanded this is an L<Net::API::Stripe::Billing::Quote> object.
286              
287              
288             =back
289              
290             =head2 header string
291              
292             A header that will be displayed on the quote PDF.
293              
294             =head2 invoice expandable
295              
296             The invoice that was created from this quote.
297              
298             When expanded this is an L<Net::API::Stripe::Billing::Invoice> object.
299              
300             =head2 invoice_settings object
301              
302             All invoices will be billed using the specified settings.
303              
304             This is a L<Net::API::Stripe::Billing::Subscription> object.
305              
306             =head2 line_items object
307              
308             A list of items the customer is being quoted for.
309              
310             This is a L<Net::API::Stripe::List> object.
311              
312             =head2 livemode boolean
313              
314             Has the value C<true> if the object exists in live mode or the value C<false> if the object exists in test mode.
315              
316             =head2 metadata hash
317              
318             Set of L<key-value pairs|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.
319              
320             =head2 number string
321              
322             A unique number that identifies this particular quote. This number is assigned once the quote is L<finalized|finalized>.
323              
324             =head2 on_behalf_of expandable
325              
326             The account on behalf of which to charge. See the L<Connect documentation|Connect documentation> for details.
327              
328             When expanded this is an L<Net::API::Stripe::Connect::Account> object.
329              
330             =head2 status string
331              
332             The status of the quote.
333              
334             =head2 status_transitions hash
335              
336             The timestamps of which the quote transitioned to a new status.
337              
338             It has the following properties:
339              
340             =over 4
341              
342             =item I<accepted_at> timestamp
343              
344             The time that the quote was accepted. Measured in seconds since Unix epoch.
345              
346             =item I<canceled_at> timestamp
347              
348             The time that the quote was canceled. Measured in seconds since Unix epoch.
349              
350             =item I<finalized_at> timestamp
351              
352             The time that the quote was finalized. Measured in seconds since Unix epoch.
353              
354              
355             =back
356              
357             =head2 subscription expandable
358              
359             The subscription that was created or updated from this quote.
360              
361             When expanded this is an L<Net::API::Stripe::Billing::Subscription> object.
362              
363             =head2 subscription_data object
364              
365             When creating a subscription or subscription schedule, the specified configuration data will be used. There must be at least one line item with a recurring price for a subscription or subscription schedule to be created.
366              
367             This is a L<Net::API::Stripe::Billing::Subscription> object.
368              
369             =head2 subscription_schedule expandable
370              
371             The subscription schedule that was created or updated from this quote.
372              
373             When expanded this is an L<Net::API::Stripe::Billing::Subscription::Schedule> object.
374              
375             =head2 total_details hash
376              
377             Tax and discount details for the computed total amount.
378              
379             It has the following properties:
380              
381             =over 4
382              
383             =item I<amount_discount> integer
384              
385             This is the sum of all the line item discounts.
386              
387             =item I<amount_shipping> integer
388              
389             This is the sum of all the line item shipping amounts.
390              
391             =item I<amount_tax> integer
392              
393             This is the sum of all the line item tax amounts.
394              
395             =item I<breakdown> hash
396              
397             Breakdown of individual tax and discount amounts that add up to the totals.
398              
399             =over 8
400              
401             =item I<discounts> array
402              
403             The aggregated line item discounts.
404              
405             =over 12
406              
407             =item I<amount> integer
408              
409             The amount discounted.
410              
411             =item I<discount> hash
412              
413             The discount applied.
414              
415             =back
416              
417             =item I<taxes> array
418              
419             The aggregated line item tax amounts by rate.
420              
421             =over 12
422              
423             =item I<amount> integer
424              
425             Amount of tax applied for this rate.
426              
427             =item I<rate> hash
428              
429             The tax rate applied.
430              
431             When expanded, this is a L<Net::API::Stripe::Billing::Quote> object.
432              
433             =back
434              
435             =back
436              
437              
438             =back
439              
440             =head2 transfer_data object
441              
442             The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the invoices.
443              
444             This is a L<Net::API::Stripe::Charge> object.
445              
446             =head1 API SAMPLE
447              
448             {
449             "id": "qt_1KJGon2eZvKYlo2CYE6HxURp",
450             "object": "quote",
451             "amount_subtotal": 0,
452             "amount_total": 0,
453             "application_fee_amount": null,
454             "application_fee_percent": null,
455             "automatic_tax": {
456             "enabled": false,
457             "status": null
458             },
459             "collection_method": "charge_automatically",
460             "computed": {
461             "recurring": null,
462             "upfront": {
463             "amount_subtotal": 0,
464             "amount_total": 0,
465             "total_details": {
466             "amount_discount": 0,
467             "amount_shipping": 0,
468             "amount_tax": 0
469             }
470             }
471             },
472             "created": 1642508985,
473             "currency": "usd",
474             "customer": "cus_AJ6yY15pe9xOZe",
475             "default_tax_rates": [
476            
477             ],
478             "description": null,
479             "discounts": [
480            
481             ],
482             "expires_at": 1645100985,
483             "footer": null,
484             "from_quote": null,
485             "header": null,
486             "invoice": null,
487             "invoice_settings": {
488             "days_until_due": null
489             },
490             "livemode": false,
491             "metadata": {
492             },
493             "number": null,
494             "on_behalf_of": null,
495             "status": "draft",
496             "status_transitions": {
497             "accepted_at": null,
498             "canceled_at": null,
499             "finalized_at": null
500             },
501             "subscription": null,
502             "subscription_data": {
503             "effective_date": null,
504             "trial_period_days": null
505             },
506             "subscription_schedule": null,
507             "total_details": {
508             "amount_discount": 0,
509             "amount_shipping": 0,
510             "amount_tax": 0
511             },
512             "transfer_data": null
513             }
514              
515             =head1 HISTORY
516              
517             =head2 v0.1.0
518              
519             Initial version
520              
521             =head1 AUTHOR
522              
523             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
524              
525             =head1 SEE ALSO
526              
527             L<Stripe API documentation|https://stripe.com/docs/api#quote_object>
528              
529             =head1 COPYRIGHT & LICENSE
530              
531             Copyright (c) 2019-2022 DEGUEST Pte. Ltd.
532              
533             You can use, copy, modify and redistribute this package and associated
534             files under the same terms as Perl itself.
535              
536             =cut