File Coverage

blib/lib/Net/API/Stripe/Customer/BalanceTransaction.pm
Criterion Covered Total %
statement 7 20 35.0
branch n/a
condition n/a
subroutine 3 16 18.7
pod 13 13 100.0
total 23 49 46.9


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Customer/BalanceTransaction.pm
3             ## Version v0.100.0
4             ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/05/15
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/customer_balance_transactions
11             package Net::API::Stripe::Customer::BalanceTransaction;
12             BEGIN
13             {
14 1     1   872 use strict;
  1         2  
  1         32  
15 1     1   5 use parent qw( Net::API::Stripe::Generic );
  1         2  
  1         5  
16 1     1   257 our( $VERSION ) = 'v0.100.0';
17             };
18              
19 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
20              
21 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
22              
23 0     0 1   sub amount { return( shift->_set_get_number( 'amount', @_ ) ); }
24              
25 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
26              
27 0     0 1   sub credit_note { return( shift->_set_get_scalar_or_object( 'credit_note', 'Net::API::Stripe::Billing::CreditNote', @_ ) ); }
28              
29 0     0 1   sub currency { return( shift->_set_get_scalar( 'currency', @_ ) ); }
30              
31 0     0 1   sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); }
32              
33 0     0 1   sub description { return( shift->_set_get_scalar( 'description', @_ ) ); }
34              
35 0     0 1   sub ending_balance { return( shift->_set_get_number( 'ending_balance', @_ ) ); }
36              
37 0     0 1   sub invoice { return( shift->_set_get_scalar_or_object( 'invoice', 'Net::API::Stripe::Billing::Invoice', @_ ) ); }
38              
39 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
40              
41 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
42              
43 0     0 1   sub type { return( shift->_set_get_scalar( 'type', @_ ) ); }
44              
45             1;
46              
47             __END__
48              
49             =encoding utf8
50              
51             =head1 NAME
52              
53             Net::API::Stripe::Customer::BalanceTransaction - A Stripe Customer Balance Tranaction Object
54              
55             =head1 SYNOPSIS
56              
57             my $bt = $stripe->balance_transaction({
58             amount => 2000,
59             currency => 'jpy',
60             customer => $customer_object,
61             description => 'Payment for professional service',
62             invoice => $invoice_object,
63             metadata => { transaction_id => 123 },
64             type => 'initial',
65             });
66              
67             Crediting the customer:
68              
69             my $bt = $stripe->balance_transaction({
70             amount => -2000,
71             credit_note => $credit_note_object,
72             currency => 'jpy',
73             customer => $customer_object,
74             description => 'Credit note for cancelled invoice',
75             invoice => $invoice_object,
76             metadata => { transaction_id => 123 },
77             type => 'credit_note',
78             });
79              
80             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
81              
82             =head1 VERSION
83              
84             v0.100.0
85              
86             =head1 DESCRIPTION
87              
88             Each customer has a I<balance> value, which denotes a debit or credit that's automatically applied to their next invoice upon finalization. You may modify the value directly by using the update customer API (L<https://stripe.com/docs/api/customers/update>), or by creating a Customer Balance Transaction, which increments or decrements the customer's I<balance> by the specified I<amount>.
89              
90             =head1 CONSTRUCTOR
91              
92             =over 4
93              
94             =item B<new>( %ARG )
95              
96             Creates a new L<Net::API::Stripe::Customer::BalanceTransaction> object.
97             It may also take an hash like arguments, that also are method of the same name.
98              
99             =back
100              
101             =head1 METHODS
102              
103             =over 4
104              
105             =item B<id> string
106              
107             Unique identifier for the object.
108              
109             =item B<object> string, value is "customer_balance_transaction"
110              
111             String representing the object’s type. Objects of the same type share the same value.
112              
113             =item B<amount> integer
114              
115             The amount of the transaction. A negative value is a credit for the customer’s balance, and a positive value is a debit to the customer’s balance.
116              
117             =item B<created> timestamp
118              
119             Time at which the object was created. Measured in seconds since the Unix epoch.
120              
121             =item B<credit_note> string (expandable)
122              
123             The ID of the credit note (if any) related to the transaction. When expanded this is a L<Net::API::Stripe::Billing::CreditNote> object.
124              
125             =item B<currency> currency
126              
127             Three-letter ISO currency code, in lowercase. Must be a supported currency.
128              
129             =item B<customer> string (expandable)
130              
131             The ID of the customer the transaction belongs to. When expanded, this is a L<Net::API::Stripe::Customer> object.
132              
133             =item B<description> string
134              
135             An arbitrary string attached to the object. Often useful for displaying to users.
136              
137             =item B<ending_balance> integer
138              
139             The customer’s balance after the transaction was applied. A negative value decreases the amount due on the customer’s next invoice. A positive value increases the amount due on the customer’s next invoice.
140              
141             =item B<invoice> string (expandable)
142              
143             The ID of the invoice (if any) related to the transaction. When expanded, this is a L<Net::API::Stripe::Billing::Invoice> object.
144              
145             =item B<livemode> boolean
146              
147             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
148              
149             =item B<metadata> hash
150              
151             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.
152              
153             =item B<type> string
154              
155             Transaction type: adjustment, applied_to_invoice, credit_note, initial, invoice_too_large, invoice_too_small, unapplied_from_invoice, or unspent_receiver_credit. See the Customer Balance page to learn more about transaction types.
156              
157             =back
158              
159             =head1 API SAMPLE
160              
161             {
162             "object": "balance",
163             "available": [
164             {
165             "amount": 0,
166             "currency": "jpy",
167             "source_types": {
168             "card": 0
169             }
170             }
171             ],
172             "connect_reserved": [
173             {
174             "amount": 0,
175             "currency": "jpy"
176             }
177             ],
178             "livemode": false,
179             "pending": [
180             {
181             "amount": 7712,
182             "currency": "jpy",
183             "source_types": {
184             "card": 7712
185             }
186             }
187             ]
188             }
189              
190             =head1 HISTORY
191              
192             =head2 v0.1
193              
194             Initial version
195              
196             =head1 AUTHOR
197              
198             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
199              
200             =head1 SEE ALSO
201              
202             Stripe API documentation:
203              
204             L<https://stripe.com/docs/api/customer_balance_transactions>, L<https://stripe.com/docs/billing/customer/balance>
205              
206             =head1 COPYRIGHT & LICENSE
207              
208             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
209              
210             You can use, copy, modify and redistribute this package and associated
211             files under the same terms as Perl itself.
212              
213             =cut