File Coverage

lib/Net/API/Stripe/Billing/CreditNote.pm
Criterion Covered Total %
statement 19 46 41.3
branch n/a
condition n/a
subroutine 7 34 20.5
pod 27 27 100.0
total 53 107 49.5


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