File Coverage

lib/Net/API/Stripe/Customer/BalanceTransaction.pm
Criterion Covered Total %
statement 19 32 59.3
branch n/a
condition n/a
subroutine 7 20 35.0
pod 13 13 100.0
total 39 65 60.0


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