File Coverage

lib/Net/API/Stripe/Billing/Invoice/LineItem.pm
Criterion Covered Total %
statement 19 37 51.3
branch n/a
condition n/a
subroutine 7 25 28.0
pod 18 18 100.0
total 44 80 55.0


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Billing/Invoice/LineItem.pm
3             ## Version v0.100.0
4             ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/05/15
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/invoices/line_item
11             package Net::API::Stripe::Billing::Invoice::LineItem;
12             BEGIN
13             {
14 2     2   21234005 use strict;
  2         16  
  2         70  
15 2     2   10 use warnings;
  2         4  
  2         59  
16 2     2   12 use parent qw( Net::API::Stripe::List::Item );
  2         9  
  2         11  
17 2     2   128 use vars qw( $VERSION );
  2         12  
  2         99  
18 2     2   38 our( $VERSION ) = 'v0.100.0';
19             };
20              
21 2     2   11 use strict;
  2         6  
  2         38  
22 2     2   10 use warnings;
  2         4  
  2         867  
23              
24             # NOTE: method id is inherited
25              
26             # NOTE: method object is inherited
27              
28             # NOTE: method amount is inherited
29              
30 0     0 1   sub amount_excluding_tax { return( shift->_set_get_number( 'amount_excluding_tax', @_ ) ); }
31              
32             # NOTE: method currency is inherited
33              
34             # NOTE: method description is inherited
35              
36             sub discount_amounts
37             {
38 0     0 1   return( shift->_set_get_class_array( 'discount_amounts',
39             {
40             amount => { type => 'number' },
41             discount => { type => 'object', class => 'Net::API::Stripe::Billing::Discount' },
42             }, @_ ) );
43             }
44              
45 0     0 1   sub discountable { return( shift->_set_get_boolean( 'discountable', @_ ) ); }
46              
47 0     0 1   sub discounts { return( shift->_set_get_scalar_or_object_array( 'discounts', 'Net::API::Stripe::Billing::Discount', @_ ) ); }
48              
49 0     0 1   sub invoice_item { return( shift->_set_get_scalar( 'invoice_item', @_ ) ); }
50              
51 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
52              
53 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
54              
55 0     0 1   sub period { return( shift->_set_get_object( 'period', 'Net::API::Stripe::Billing::Invoice::Period', @_ ) ); }
56              
57 0     0 1   sub plan { return( shift->_set_get_object( 'plan', 'Net::API::Stripe::Billing::Plan', @_ ) ); }
58              
59             # NOTE: method price is inherited
60              
61 0     0 1   sub proration { return( shift->_set_get_boolean( 'proration', @_ ) ); }
62              
63 0     0 1   sub proration_details { return( shift->_set_get_class( 'proration_details',
64             {
65             credited_items => { type => 'class', definition =>
66             {
67             invoice => { type => 'string' },
68             invoice_line_items => { type => 'array' },
69             }},
70             }, @_ ) ); }
71              
72             # NOTE: method quantity is inherited
73              
74 0     0 1   sub subscription { return( shift->_set_get_scalar( 'subscription', @_ ) ); }
75              
76 0     0 1   sub subscription_item { return( shift->_set_get_scalar( 'subscription_item', @_ ) ); }
77              
78 0     0 1   sub tax_amounts { return( shift->_set_get_object_array( 'tax_amounts', 'Net::API::Stripe::Billing::Invoice::TaxAmount', @_ ) ); }
79              
80 0     0 1   sub tax_rates { return( shift->_set_get_object_array( 'tax_rates', 'Net::API::Stripe::Tax::Rate', @_ ) ); }
81              
82             # The source type: invoiceitem or subscription
83             # NOTE: method type is inherited
84              
85 0     0 1   sub unified_proration { return( shift->_set_get_scalar( 'unified_proration', @_ ) ); }
86              
87 0     0 1   sub unique_id { return( shift->_set_get_scalar( 'unique_id', @_ ) ); }
88              
89 0     0 1   sub unit_amount_excluding_tax { return( shift->_set_get_number( 'unit_amount_excluding_tax', @_ ) ); }
90              
91             1;
92              
93             __END__
94              
95             =encoding utf8
96              
97             =head1 NAME
98              
99             Net::API::Stripe::Billing::Invoice::LineItem - A Stripe Invoice Line Item Object
100              
101             =head1 SYNOPSIS
102              
103             my $line_item = $stripe->invoice_line_item({
104             amount => 2000,
105             currency => 'jpy',
106             description 'Professional service work',
107             discountable => 0,
108             metadata => { transaction_id => 1212, customer_id => 987 },
109             plan => $plan_object,
110             proration => 0,
111             quantity => 7,
112             subscription => 'sub_fake123456789',
113             type => 'subscription',
114             });
115              
116             =head1 VERSION
117              
118             v0.100.0
119              
120             =head1 DESCRIPTION
121              
122             This is a Stripe L<Net::API::Stripe::Billing::Invoice::LineItem> object as documented here: L<https://stripe.com/docs/api/invoices/line_item>
123              
124             =head1 CONSTRUCTOR
125              
126             =head2 new
127              
128             Creates a new L<Net::API::Stripe::Billing::Invoice::LineItem> object.
129              
130             =head1 METHODS
131              
132             =head2 id string
133              
134             Unique identifier for the object.
135              
136             =head2 object string, value is "line_item"
137              
138             String representing the object’s type. Objects of the same type share the same value.
139              
140             =head2 amount integer
141              
142             The amount, in its smallest representation, such as cents. For example, $9 would be 900, and ¥1000 (Japanese Yen) would be 1000.
143              
144             =head2 amount_excluding_tax
145              
146             The integer amount representing the amount for this line item, excluding all tax and discounts.
147              
148             =head2 currency currency
149              
150             Three-letter ISO currency code, in lowercase. Must be a supported currency.
151              
152             =head2 description string
153              
154             An arbitrary string attached to the object. Often useful for displaying to users.
155              
156             =head2 discount_amounts array of hashes
157              
158             The amount of discount calculated per discount for this line item.
159              
160             Properties are:
161              
162             =over 4
163              
164             =item I<amount> integer
165              
166             The amount of the discount.
167              
168             =item I<discount> string expandable
169              
170             The discount that was applied to get this discount amount.
171              
172             When expanded, this is a L<Net::API::Stripe::Billing::Discount> object.
173              
174             =back
175              
176             =head2 discountable boolean
177              
178             If true, discounts will apply to this line item. Always false for prorations.
179              
180             =head2 discounts expandable
181              
182             The discounts applied to the invoice line item. Line item discounts are applied before invoice discounts. Use C<expand[]=discounts> to expand each discount.
183              
184             When expanded this is an L<Net::API::Stripe::Billing::Discount> object.
185              
186             =head2 invoice_item string
187              
188             The ID of the invoice item associated with this line item if any.
189              
190             =head2 livemode boolean
191              
192             Whether this is a test line item.
193              
194             =head2 metadata hash
195              
196             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. Note that for line items with type=subscription this will reflect the metadata of the subscription that caused the line item to be created.
197              
198             =head2 period hash
199              
200             The timespan covered by this invoice item.
201              
202             This is a L<Net::API::Stripe::Billing::Invoice::Period> object.
203              
204             =head2 plan hash, plan object
205              
206             The plan of the subscription, if the line item is a subscription or a proration.
207              
208             This is a L<Net::API::Stripe::Billing::Plan> object.
209              
210             =head2 price object
211              
212             The price of the line item.
213              
214             This is a L<Net::API::Stripe::Price> object.
215              
216             =head2 proration boolean
217              
218             Whether this is a proration.
219              
220             =head2 proration_details
221              
222             Additional details for proration line items
223              
224             =over 4
225              
226             credited_items hash
227              
228             For a credit proration line_item, the original debit line_items to which the credit proration applies.
229              
230             =over 8
231              
232             =item * C<invoice> string
233              
234             Invoice containing the credited invoice line items
235              
236             =item * C<invoice_line_items> array containing strings
237              
238             Credited invoice line items
239              
240             =back
241              
242             =back
243              
244             =head2 quantity integer
245              
246             The quantity of the subscription, if the line item is a subscription or a proration.
247              
248             =head2 subscription string
249              
250             The subscription that the invoice item pertains to, if any.
251              
252             =head2 subscription_item string
253              
254             The subscription item that generated this invoice item. Left empty if the line item is not an explicit result of a subscription.
255              
256             =head2 tax_amounts array of hashes
257              
258             The amount of tax calculated per tax rate for this line item
259              
260             This is an array of L<Net::API::Stripe::Billing::Invoice::TaxAmount> objects.
261              
262             =head2 tax_rates array of hashes
263              
264             The tax rates which apply to the line item.
265              
266             This is an array of L<Net::API::Stripe::Tax::Rate> objects.
267              
268             =head2 type string
269              
270             A string identifying the type of the source of this line item, either an invoiceitem or a subscription.
271              
272             =head2 unified_proration boolean
273              
274             For prorations this indicates whether Stripe automatically grouped multiple related debit and credit line items into a single combined line item.
275              
276             =head2 unit_amount_excluding_tax
277              
278             The amount in the currency smallest representation, such as cents representing the unit amount for this line item, excluding all tax and discounts. Example 900 for C<$9> or 1000 for ¥1000 (Japanese Yen).
279              
280             =head1 API SAMPLE
281              
282             {
283             "id": "ii_fake123456789",
284             "object": "line_item",
285             "amount": -2000,
286             "currency": "jpy",
287             "description": "Unused time on Provider, Inc entrepreneur monthly membership after 02 Mar 2019",
288             "discountable": false,
289             "invoice_item": "ii_fake123456789",
290             "livemode": false,
291             "metadata": {},
292             "period": {
293             "end": 1554171359,
294             "start": 1551493020
295             },
296             "plan": {
297             "id": "entrepreneur-monthly-jpy",
298             "object": "plan",
299             "active": true,
300             "aggregate_usage": null,
301             "amount": 2000,
302             "amount_decimal": "2000",
303             "billing_scheme": "per_unit",
304             "created": 1541833424,
305             "currency": "jpy",
306             "interval": "month",
307             "interval_count": 1,
308             "livemode": false,
309             "metadata": {},
310             "nickname": null,
311             "product": "prod_fake123456789",
312             "tiers": null,
313             "tiers_mode": null,
314             "transform_usage": null,
315             "trial_period_days": null,
316             "usage_type": "licensed"
317             },
318             "proration": true,
319             "quantity": 1,
320             "subscription": "sub_fake123456789",
321             "subscription_item": "si_fake123456789",
322             "tax_amounts": [],
323             "tax_rates": [],
324             "type": "invoiceitem"
325             }
326              
327             =head1 HISTORY
328              
329             =head2 v0.1
330              
331             Initial version
332              
333             =head1 STRIPE HISTORY
334              
335             =head2 2019-12-03
336              
337             The id field of all invoice line items have changed and are now prefixed with il_. The new id has consistent prefixes across all line items, is globally unique, and can be used for pagination.
338              
339             =over 4
340              
341             =item You can no longer use the prefix of the id to determine the source of the line item. Instead use the type field for this purpose.
342              
343             =item For lines with type=invoiceitem, use the invoice_item field to reference or update the originating Invoice Item object.
344              
345             =item The Invoice Line Item object on earlier API versions also have a unique_id field to be used for migrating internal references before upgrading to this version.
346              
347             =item When setting a tax rate to individual line items, use the new id. Users on earlier API versions can pass in either a line item id or unique_id.
348              
349             =back
350              
351             =head2 2022-07-12
352              
353             The following methods have been aded by Stripe:
354              
355             =over 4
356              
357             =item * L</amount_excluding_tax>
358              
359             =item * L</proration_details>
360              
361             =item * L</unit_amount_excluding_tax>
362              
363             =back
364              
365             =head1 AUTHOR
366              
367             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
368              
369             =head1 SEE ALSO
370              
371             Stripe API documentation:
372              
373             L<https://stripe.com/docs/api/invoices/line_item>
374              
375             =head1 COPYRIGHT & LICENSE
376              
377             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
378              
379             You can use, copy, modify and redistribute this package and associated
380             files under the same terms as Perl itself.
381              
382             =cut