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