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