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