File Coverage

lib/Net/API/Stripe/Billing/Invoice/Item.pm
Criterion Covered Total %
statement 19 44 43.1
branch n/a
condition n/a
subroutine 7 32 21.8
pod 23 25 92.0
total 49 101 48.5


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Billing/Invoice/Item.pm
3             ## Version v0.100.1
4             ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/10/22
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/invoiceitems
14             package Net::API::Stripe::Billing::Invoice::Item;
15             BEGIN
16             {
17 2     2   21655925 use strict;
  2         16  
  2         65  
18 2     2   10 use warnings;
  2         4  
  2         66  
19 2     2   11 use parent qw( Net::API::Stripe::Generic );
  2         4  
  2         11  
20 2     2   204 use vars qw( $VERSION );
  2         6  
  2         141  
21 2     2   45 our( $VERSION ) = 'v0.100.1';
22             };
23              
24 2     2   12 use strict;
  2         3  
  2         40  
25 2     2   9 use warnings;
  2         5  
  2         1078  
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 currency { return( shift->_set_get_scalar( 'currency', @_ ) ); }
34              
35 0     0 1   sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); }
36              
37 0     0 1   sub date { return( shift->_set_get_datetime( 'date', @_ ) ); }
38              
39 0     0 0   sub deleted { return( shift->_set_get_boolean( 'deleted', @_ ) ); }
40              
41 0     0 1   sub description { return( shift->_set_get_scalar( 'description', @_ ) ); }
42              
43 0     0 1   sub discountable { return( shift->_set_get_boolean( 'discountable', @_ ) ); }
44              
45 0     0 1   sub discounts { return( shift->_set_get_object_array( 'discounts', 'Net::API::Stripe::Billing::Discount', @_ ) ); }
46              
47 0     0 1   sub invoice { return( shift->_set_get_scalar_or_object( 'invoice', 'Net::API::Stripe::Billing::Invoice', @_ ) ); }
48              
49 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
50              
51 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
52              
53 0     0 1   sub period { return( shift->_set_get_object( 'period', 'Net::API::Stripe::Billing::Invoice::Period', @_ ) ); }
54              
55 0     0 1   sub plan { return( shift->_set_get_object( 'plan', 'Net::API::Stripe::Billing::Plan', @_ ) ); }
56              
57 0     0 1   sub price { return( shift->_set_get_object( 'price', 'Net::API::Stripe::Price', @_ ) ); }
58              
59 0     0 1   sub proration { return( shift->_set_get_boolean( 'proration', @_ ) ); }
60              
61 0     0 1   sub quantity { return( shift->_set_get_number( 'quantity', @_ ) ); }
62              
63 0     0 1   sub subscription { return( shift->_set_get_scalar_or_object( 'subscription', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
64              
65 0     0 1   sub subscription_item { return( shift->_set_get_scalar( 'subscription_item', @_ ) ); }
66              
67 0     0 1   sub tax_rates { return( shift->_set_get_object_array( 'tax_rates', 'Net::API::Stripe::Tax::Rate', @_ ) ); }
68              
69 0     0 0   sub test_clock { return( shift->_set_get_scalar_or_object( 'test_clock', 'Net::API::Stripe::Billing::TestClock', @_ ) ); }
70              
71 0     0 1   sub unified_proration { return( shift->_set_get_scalar( 'unified_proration', @_ ) ); }
72              
73 0     0 1   sub unit_amount { return( shift->_set_get_number( 'unit_amount', @_ ) ); }
74              
75 0     0 1   sub unit_amount_decimal { return( shift->_set_get_number( 'unit_amount_decimal', @_ ) ); }
76              
77             1;
78              
79             __END__
80              
81             =encoding utf8
82              
83             =head1 NAME
84              
85             Net::API::Stripe::Billing::Invoice::Item - A Stripe Invoice Item Object
86              
87             =head1 SYNOPSIS
88              
89             my $invoice_item = $stripe->invoice_item({
90             amount => 2000,
91             currency => 'jpy',
92             customer => $customer_object,
93             date => '2020-03-17',
94             description => 'Support services',
95             invoice => $invoice_object,
96             metadata => { transaction_id => 1212, customer_id => 987 },
97             plan => $plan_object,
98             proration => 1,
99             quantity => 7,
100             subscription => $subscription_object,
101             });
102              
103             =head1 VERSION
104              
105             v0.100.1
106              
107             =head1 DESCRIPTION
108              
109             Sometimes you want to add a charge or credit to a customer, but actually charge or credit the customer's card only at the end of a regular billing cycle. This is useful for combining several charges (to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals.
110              
111             =head1 CONSTRUCTOR
112              
113             =head2 new( %ARG )
114              
115             Creates a new L<Net::API::Stripe::Billing::Invoice::Item> object.
116              
117             =head1 METHODS
118              
119             =head2 id string
120              
121             Unique identifier for the object.
122              
123             =head2 object string, value is "invoiceitem"
124              
125             String representing the object’s type. Objects of the same type share the same value.
126              
127             =head2 amount integer
128              
129             Amount (in the I<currency> specified) of the invoice item. This should always be equal to I<unit_amount * quantity>.
130              
131             =head2 currency currency
132              
133             Three-letter ISO currency code, in lowercase. Must be a supported currency (L<https://stripe.com/docs/currencies>).
134              
135             =head2 customer string (expandable)
136              
137             The ID of the customer who will be billed when this invoice item is billed. When expanded, this is a L<Net::API::Stripe::Customer> object.
138              
139             =head2 date timestamp
140              
141             Time at which the object was created. Measured in seconds since the Unix epoch.
142              
143             =head2 description string
144              
145             An arbitrary string attached to the object. Often useful for displaying to users.
146              
147             =head2 discountable boolean
148              
149             If true, discounts will apply to this invoice item. Always false for prorations.
150              
151             =head2 discounts
152              
153             array containing strings. expandable
154              
155             The discounts which apply to the invoice item. Item discounts are applied before invoice discounts. Use expand[]=discounts to expand each discount.
156              
157             =head2 invoice string (expandable)
158              
159             The ID of the invoice this invoice item belongs to. When expanded, this is a L<Net::API::Stripe::Billing::Invoice> object.
160              
161             =head2 livemode boolean
162              
163             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
164              
165             =head2 metadata hash
166              
167             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.
168              
169             =head2 period hash
170              
171             The period associated with with this invoice item.
172              
173             This is a L<Net::API::Stripe::Billing::Invoice::Period> object.
174              
175             =head2 plan hash, plan object
176              
177             If the invoice item is a proration, the plan of the subscription that the proration was computed for.
178              
179             This is a L<Net::API::Stripe::Billing::Plan> object.
180              
181             =head2 price hash, price object
182              
183             The price of the invoice item.
184              
185             This is a L<Net::API::Stripe::Price> object.
186              
187             =head2 proration boolean
188              
189             Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.
190              
191             =head2 quantity integer
192              
193             Quantity of units for the invoice item. If the invoice item is a proration, the quantity of the subscription that the proration was computed for.
194              
195             =head2 subscription string (expandable)
196              
197             The subscription that this invoice item has been created for, if any. When expanded, this is a L<Net::API::Stripe::Billing::Subscription> object.
198              
199             =head2 subscription_item string
200              
201             The subscription item that this invoice item has been created for, if any.
202              
203             =head2 tax_rates array of hashes
204              
205             The tax rates which apply to the invoice item. When set, the default_tax_rates on the invoice do not apply to this invoice item.
206              
207             This is an array of L<Net::API::Stripe::Tax::Rate> objects.
208              
209             =head2 unified_proration boolean
210              
211             For prorations this indicates whether Stripe automatically grouped multiple related debit and credit line items into a single combined line item.
212              
213             =head2 unit_amount integer
214              
215             Unit Amount (in the currency specified) of the invoice item.
216              
217             =head2 unit_amount_decimal decimal string
218              
219             Same as unit_amount, but contains a decimal value with at most 12 decimal places.
220              
221             =head1 API SAMPLE
222              
223             {
224             "id": "ii_fake123456789",
225             "object": "invoiceitem",
226             "amount": 8000,
227             "currency": "jpy",
228             "customer": "cus_fake123456789",
229             "date": 1551493020,
230             "description": "Unused time on Provider, Inc entrepreneur monthly membership after 02 Mar 2019",
231             "discountable": false,
232             "invoice": "in_fake123456789",
233             "livemode": false,
234             "metadata": {},
235             "period": {
236             "end": 1554171359,
237             "start": 1551493020
238             },
239             "plan": {
240             "id": "entrepreneur-monthly-jpy",
241             "object": "plan",
242             "active": true,
243             "aggregate_usage": null,
244             "amount": 2000,
245             "amount_decimal": "2000",
246             "billing_scheme": "per_unit",
247             "created": 1541833424,
248             "currency": "jpy",
249             "interval": "month",
250             "interval_count": 1,
251             "livemode": false,
252             "metadata": {},
253             "nickname": null,
254             "product": "prod_fake123456789",
255             "tiers": null,
256             "tiers_mode": null,
257             "transform_usage": null,
258             "trial_period_days": null,
259             "usage_type": "licensed"
260             },
261             "proration": true,
262             "quantity": 1,
263             "subscription": "sub_fake123456789",
264             "subscription_item": "si_fake123456789",
265             "tax_rates": [],
266             "unit_amount": 8000,
267             "unit_amount_decimal": "8000"
268             }
269              
270             =head1 HISTORY
271              
272             =head2 v0.1
273              
274             Initial version
275              
276             =head1 AUTHOR
277              
278             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
279              
280             =head1 SEE ALSO
281              
282             Stripe API documentation:
283              
284             L<https://stripe.com/docs/api/invoiceitems>, L<https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items>
285              
286             =head1 COPYRIGHT & LICENSE
287              
288             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
289              
290             You can use, copy, modify and redistribute this package and associated
291             files under the same terms as Perl itself.
292              
293             =cut