File Coverage

blib/lib/Net/API/Stripe/Billing/CreditNote.pm
Criterion Covered Total %
statement 7 30 23.3
branch n/a
condition n/a
subroutine 3 26 11.5
pod 23 23 100.0
total 33 79 41.7


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Billing/CreditNote.pm
3             ## Version v0.200.0
4             ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/05/15
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/credit_notes
11             package Net::API::Stripe::Billing::CreditNote;
12             BEGIN
13             {
14 1     1   853 use strict;
  1         2  
  1         28  
15 1     1   4 use parent qw( Net::API::Stripe::Generic );
  1         2  
  1         4  
16 1     1   399 our( $VERSION ) = 'v0.200.0';
17             };
18              
19 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
20              
21 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
22              
23 0     0 1   sub amount { return( shift->_set_get_number( 'amount', @_ ) ); }
24              
25 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
26              
27 0     0 1   sub currency { return( shift->_set_get_scalar( 'currency', @_ ) ); }
28              
29 0     0 1   sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); }
30              
31 0     0 1   sub customer_balance_transaction { return( shift->_set_get_scalar_or_object( 'customer_balance_transaction', 'Net::API::Stripe::Balance::Transaction', @_ ) ); }
32              
33 0     0 1   sub invoice { return( shift->_set_get_scalar_or_object( 'invoice', 'Net::API::Stripe::Billing::Invoice', @_ ) ); }
34              
35 0     0 1   sub lines { return( shift->_set_get_object_array( 'lines', 'Net::API::Stripe::List', @_ ) ); }
36              
37 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
38              
39 0     0 1   sub memo { return( shift->_set_get_scalar( 'memo', @_ ) ); }
40              
41 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
42              
43 0     0 1   sub number { return( shift->_set_get_number( 'number', @_ ) ); }
44              
45 0     0 1   sub out_of_band_amount { return( shift->_set_get_number( 'out_of_band_amount', @_ ) ); }
46              
47 0     0 1   sub pdf { return( shift->_set_get_scalar( 'pdf', @_ ) ); }
48              
49 0     0 1   sub reason { return( shift->_set_get_scalar( 'reason', @_ ) ); }
50              
51 0     0 1   sub refund { return( shift->_set_get_scalar_or_object( 'refund', 'Net::API::Stripe::Refund', @_ ) ); }
52              
53 0     0 1   sub status { return( shift->_set_get_scalar( 'status', @_ ) ); }
54              
55 0     0 1   sub subtotal { return( shift->_set_get_number( 'subtotal', @_ ) ); }
56              
57             sub tax_amounts
58             {
59 0     0 1   return( shift->_set_get_class( 'tax_amounts',
60             {
61             amount => { type => 'number' },
62             inclusive => { type => 'boolean' },
63             tax_rate => { type => 'scalar_or_object', class => 'Net::API::Stripe::Tax::Rate' },
64             }, @_ ) );
65             }
66              
67 0     0 1   sub total { return( shift->_set_get_number( 'total', @_ ) ); }
68              
69 0     0 1   sub type { return( shift->_set_get_scalar( 'type', @_ ) ); }
70              
71 0     0 1   sub voided_at { return( shift->_set_get_datetime( 'voided_at', @_ ) ); }
72              
73             1;
74              
75             __END__
76              
77             =encoding utf8
78              
79             =head1 NAME
80              
81             Net::API::Stripe::Billing::CreditNote - A Stripe Credit Note Object
82              
83             =head1 SYNOPSIS
84              
85             my $note = $stripe->credite_note({
86             amount => 2000,
87             memo => 'Credit note for your purchase on 2020-03-17',
88             currency => 'eur',
89             # Required
90             invoice => $invoice_object,
91             number => 'CR2020031701',
92             metadata => { transac_id => 1212, client_id => 789, ts => 1584403200 }
93             total => 2000
94             });
95              
96             =head1 VERSION
97              
98             v0.200.0
99              
100             =head1 DESCRIPTION
101              
102             Issue a credit note to adjust an invoice's amount after the invoice is finalized.
103              
104             =head2 CREATING A CREDIT NOTE
105              
106             Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result in any combination of the following:
107              
108             =over 4
109              
110             =item * Refund: create a new refund (using refund_amount) or link an existing refund (using refund).
111              
112             =item * Customer balance credit: credit the customer’s balance (using credit_amount) which will be automatically applied to their next invoice when it’s finalized.
113              
114             =item * Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount).
115              
116             =back
117              
118             For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.
119              
120             You may issue multiple credit notes for an invoice. Each credit note will increment the invoice’s pre_payment_credit_notes_amount or post_payment_credit_notes_amount depending on its status at the time of credit note creation.
121              
122             =head1 CONSTRUCTOR
123              
124             =over 4
125              
126             =item B<new>( %ARG )
127              
128             Creates a new L<Net::API::Stripe::Billing::CreditNote> object.
129             It may also take an hash like arguments, that also are method of the same name.
130              
131             =back
132              
133             =head1 METHODS
134              
135             =over 4
136              
137             =item B<id> string
138              
139             Unique identifier for the object.
140              
141             =item B<object> string, value is "credit_note"
142              
143             String representing the object’s type. Objects of the same type share the same value.
144              
145             =item B<amount> integer
146              
147             The integer amount in JPY representing the total amount of the credit note, including tax.
148              
149             =item B<created> timestamp
150              
151             Time at which the object was created. Measured in seconds since the Unix epoch.
152              
153             =item B<currency> currency
154              
155             Three-letter ISO currency code, in lowercase. Must be a supported currency.
156              
157             =item B<customer> string (expandable)
158              
159             ID of the customer. When expanded, this is a L<Net::API::Stripe::Customer> object.
160              
161             =item B<customer_balance_transaction> string (expandable)
162              
163             Customer balance transaction related to this credit note. When expanded, this is a L<Net::API::Stripe::Balance::Transaction> object.
164              
165             =item B<invoice> string (expandable)
166              
167             ID of the invoice. When expanded, this is a L<Net::API::Stripe::Billing::Invoice> object.
168              
169             =item B<lines>() list
170              
171             Line items that make up the credit note.
172              
173             This is a L<Net::API::Stripe::List> object with a list of L<Net::API::Stripe::Billing::CreditNote::LineItem>
174              
175             =item B<livemode> boolean
176              
177             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
178              
179             =item B<memo> string
180              
181             Customer-facing text that appears on the credit note PDF.
182              
183             =item B<metadata> hash
184              
185             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.
186              
187             =item B<number> string
188              
189             A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.
190              
191             =item B<out_of_band_amount>() integer
192              
193             Amount that was credited outside of Stripe.
194              
195             =item B<pdf> string
196              
197             The link to download the PDF of the credit note.
198              
199             =item B<reason> string
200              
201             Reason for issuing this credit note, one of duplicate, fraudulent, order_change, or product_unsatisfactory
202              
203             =item B<refund> string (expandable)
204              
205             Refund related to this credit note. When expanded, this is a L<Net::API::Stripe::Refund> object.
206              
207             =item B<status> string
208              
209             Status of this credit note, one of issued or void. Learn more about voiding credit notes.
210              
211             =item B<subtotal>() integer
212              
213             The integer amount in JPY representing the amount of the credit note, excluding tax and discount.
214              
215             =item B<total>() integer
216              
217             The integer amount in JPY representing the total amount of the credit note, including tax and discount.
218              
219             =item B<tax_amounts>() array of objects
220              
221             The amount of tax calculated per tax rate for this line item.
222              
223             This is a dynamic class with the following properties:
224              
225             =over 8
226              
227             =item I<amount> integer
228              
229             The amount, in JPY, of the tax.
230              
231             =item I<inclusive> boolean
232              
233             Whether this tax amount is inclusive or exclusive.
234              
235             =item I<tax_rate> string expandable
236              
237             The tax rate that was applied to get this tax amount.
238              
239             When expanded, this is a L<Net::API::Stripe::Tax::Rate> object.
240              
241             =back
242              
243             =item B<type> string
244              
245             Type of this credit note, one of post_payment or pre_payment. A pre_payment credit note means it was issued when the invoice was open. A post_payment credit note means it was issued when the invoice was paid.
246              
247             =item B<voided_at> timestamp
248              
249             The time that the credit note was voided. This is a C<DateTime> object.
250              
251             =back
252              
253             =head1 API SAMPLE
254              
255             {
256             "id": "cn_fake124567890",
257             "object": "credit_note",
258             "amount": 1690,
259             "created": 1571397911,
260             "currency": "jpy",
261             "customer": "cus_fake124567890",
262             "customer_balance_transaction": null,
263             "invoice": "in_fake124567890",
264             "livemode": false,
265             "memo": null,
266             "metadata": {},
267             "number": "ABCD-1234-CN-01",
268             "pdf": "https://pay.stripe.com/credit_notes/acct_19eGgRCeyNCl6fY2/cnst_123456789/pdf",
269             "reason": null,
270             "refund": null,
271             "status": "issued",
272             "type": "pre_payment",
273             "voided_at": null
274             }
275              
276             =head1 HISTORY
277              
278             =head2 v0.1
279              
280             Initial version
281              
282             =head1 AUTHOR
283              
284             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
285              
286             =head1 SEE ALSO
287              
288             Stripe API documentation:
289              
290             L<https://stripe.com/docs/api/credit_notes>, L<https://stripe.com/docs/billing/invoices/credit-notes>
291              
292             =head1 COPYRIGHT & LICENSE
293              
294             Copyright (c) 2020-2020 DEGUEST Pte. Ltd.
295              
296             You can use, copy, modify and redistribute this package and associated
297             files under the same terms as Perl itself.
298              
299             =cut