| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Business::BalancedPayments; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.0600'; # VERSION |
|
4
|
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
752364
|
use Business::BalancedPayments::V10; |
|
|
12
|
|
|
|
|
67
|
|
|
|
12
|
|
|
|
|
484
|
|
|
6
|
12
|
|
|
12
|
|
6309
|
use Business::BalancedPayments::V11; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Carp qw(croak); |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub client { |
|
10
|
|
|
|
|
|
|
my ($class, %args) = @_; |
|
11
|
|
|
|
|
|
|
$args{version} ||= 1.1; |
|
12
|
|
|
|
|
|
|
croak "only versions 1.0 and 1.1 are supported" |
|
13
|
|
|
|
|
|
|
unless $args{version} == 1 or $args{version} == 1.1; |
|
14
|
|
|
|
|
|
|
return $args{version} == 1 |
|
15
|
|
|
|
|
|
|
? Business::BalancedPayments::V10->new(%args) |
|
16
|
|
|
|
|
|
|
: Business::BalancedPayments::V11->new(%args); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# ABSTRACT: Balanced Payments API bindings |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__END__ |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=pod |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=encoding UTF-8 |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Business::BalancedPayments - Balanced Payments API bindings |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 VERSION |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
version 1.0600 |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
use Business::BalancedPayments; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $bp = Business::BalancedPayments->client(secret => 'abc123'); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $customer = $bp->create_customer; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $card = $bp->create_card({ |
|
47
|
|
|
|
|
|
|
card_number => '5105105105105100', |
|
48
|
|
|
|
|
|
|
expiration_month => 12, |
|
49
|
|
|
|
|
|
|
expiration_year => 2020, |
|
50
|
|
|
|
|
|
|
security_code => 123, |
|
51
|
|
|
|
|
|
|
}); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$bp->add_card($card, customer => $customer); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This module provides bindings for the |
|
58
|
|
|
|
|
|
|
L<Balanced|https://www.balancedpayments.com> API. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The client methods documented here are for v1.1 of the Balanced API |
|
63
|
|
|
|
|
|
|
L<https://docs.balancedpayments.com/1.1/api>. |
|
64
|
|
|
|
|
|
|
See L<Business::BalancedPayments::V10> for the v1.0 methods. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
For the C<get_*> methods, the C<$id> param can be the id of the resource or |
|
67
|
|
|
|
|
|
|
a uri. For example, the following two lines are equivalent: |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$bp->get_card('CC6J123'); |
|
70
|
|
|
|
|
|
|
$bp->get_card('/cards/CC6J123'); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 client |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $bp = Business::BalancedPayments->client( |
|
75
|
|
|
|
|
|
|
secret => $secret, |
|
76
|
|
|
|
|
|
|
version => 1.1, # optional, defaults to 1.1 |
|
77
|
|
|
|
|
|
|
logger => $logger, # optional |
|
78
|
|
|
|
|
|
|
retries => 3, # optional |
|
79
|
|
|
|
|
|
|
); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns a new Balanced client object. |
|
82
|
|
|
|
|
|
|
Parameters: |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over 4 |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item secret |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Required. The Balanced Payments secret key for your account. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item version |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Optional. Defaults to C<'1.1'>. |
|
93
|
|
|
|
|
|
|
The only supported versions currently are C<'1.0'> and C<'1.1'>. |
|
94
|
|
|
|
|
|
|
Note that version C<'1.0'> was officially deprecated March 2014. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
See L<WebService::Client> for other supported parameters such as C<logger>, |
|
99
|
|
|
|
|
|
|
C<retries>, and C<timeout>. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 get_card |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
get_card($id) |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns the card for the given id. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Example response: |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
{ |
|
110
|
|
|
|
|
|
|
'id' => 'CC6J', |
|
111
|
|
|
|
|
|
|
'href' => '/cards/CC6J', |
|
112
|
|
|
|
|
|
|
'address' => { |
|
113
|
|
|
|
|
|
|
'city' => undef, |
|
114
|
|
|
|
|
|
|
'country_code' => undef, |
|
115
|
|
|
|
|
|
|
'line1' => undef, |
|
116
|
|
|
|
|
|
|
'line2' => undef, |
|
117
|
|
|
|
|
|
|
'postal_code' => undef, |
|
118
|
|
|
|
|
|
|
'state' => undef |
|
119
|
|
|
|
|
|
|
}, |
|
120
|
|
|
|
|
|
|
'avs_postal_match' => undef, |
|
121
|
|
|
|
|
|
|
'avs_result' => undef, |
|
122
|
|
|
|
|
|
|
'avs_street_match' => undef, |
|
123
|
|
|
|
|
|
|
'bank_name' => 'BANK OF HAWAII', |
|
124
|
|
|
|
|
|
|
'brand' => 'MasterCard', |
|
125
|
|
|
|
|
|
|
'can_credit' => 0, |
|
126
|
|
|
|
|
|
|
'can_debit' => 1, |
|
127
|
|
|
|
|
|
|
'category' => 'other', |
|
128
|
|
|
|
|
|
|
'created_at' => '2014-09-21T05:55:17.564617Z', |
|
129
|
|
|
|
|
|
|
'cvv' => undef, |
|
130
|
|
|
|
|
|
|
'cvv_match' => undef, |
|
131
|
|
|
|
|
|
|
'cvv_result' => undef, |
|
132
|
|
|
|
|
|
|
'expiration_month' => 12, |
|
133
|
|
|
|
|
|
|
'expiration_year' => 2020, |
|
134
|
|
|
|
|
|
|
'fingerprint' => 'fc4c', |
|
135
|
|
|
|
|
|
|
'is_verified' => $VAR1->{'cards'}[0]{'can_debit'}, |
|
136
|
|
|
|
|
|
|
'links' => { 'customer' => undef }, |
|
137
|
|
|
|
|
|
|
'meta' => {}, |
|
138
|
|
|
|
|
|
|
'name' => undef, |
|
139
|
|
|
|
|
|
|
'number' => 'xxxxxxxxxxxx5100', |
|
140
|
|
|
|
|
|
|
'type' => 'credit', |
|
141
|
|
|
|
|
|
|
'updated_at' => '2014-09-21T05:55:17.564619Z' |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 create_card |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
create_card($card) |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Creates a card. |
|
149
|
|
|
|
|
|
|
Returns the card card that was created. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Example: |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my $card = $bp->create_card({ |
|
154
|
|
|
|
|
|
|
number => '5105105105105100', |
|
155
|
|
|
|
|
|
|
expiration_month => 12, |
|
156
|
|
|
|
|
|
|
expiration_year => 2020, |
|
157
|
|
|
|
|
|
|
}); |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 add_card |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
add_card($card, customer => $customer); |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Associates a card with a customer. |
|
164
|
|
|
|
|
|
|
It expects a card hashref, such as one returned by L</get_card>, |
|
165
|
|
|
|
|
|
|
and a customer hashref, such as one returned by L</get_customer>. |
|
166
|
|
|
|
|
|
|
Returns the card. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Example: |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
my $customer = $bp->create_customer; |
|
171
|
|
|
|
|
|
|
my $card = $bp->get_card($card_id); |
|
172
|
|
|
|
|
|
|
$bp->add_card($card, customer => $customer); |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 get_customer |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
get_customer($id) |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Returns the customer for the given id. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Example response: |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
{ |
|
183
|
|
|
|
|
|
|
'address' => { |
|
184
|
|
|
|
|
|
|
'city' => undef, |
|
185
|
|
|
|
|
|
|
'country_code' => undef, |
|
186
|
|
|
|
|
|
|
'line1' => undef, |
|
187
|
|
|
|
|
|
|
'line2' => undef, |
|
188
|
|
|
|
|
|
|
'postal_code' => undef, |
|
189
|
|
|
|
|
|
|
'state' => undef |
|
190
|
|
|
|
|
|
|
}, |
|
191
|
|
|
|
|
|
|
'business_name' => undef, |
|
192
|
|
|
|
|
|
|
'created_at' => '2014-10-02T07:59:26.311760Z', |
|
193
|
|
|
|
|
|
|
'dob_month' => undef, |
|
194
|
|
|
|
|
|
|
'dob_year' => undef, |
|
195
|
|
|
|
|
|
|
'ein' => undef, |
|
196
|
|
|
|
|
|
|
'email' => 'foo@bar.com', |
|
197
|
|
|
|
|
|
|
'href' => '/customers/CUe3pf7nX93sMvrd9qcC29W', |
|
198
|
|
|
|
|
|
|
'id' => 'CUe3pf7nX93sMvrd9qcC29W', |
|
199
|
|
|
|
|
|
|
'links' => { |
|
200
|
|
|
|
|
|
|
'destination' => undef, |
|
201
|
|
|
|
|
|
|
'source' => undef |
|
202
|
|
|
|
|
|
|
}, |
|
203
|
|
|
|
|
|
|
'merchant_status' => 'no-match', |
|
204
|
|
|
|
|
|
|
'meta' => {}, |
|
205
|
|
|
|
|
|
|
'name' => undef, |
|
206
|
|
|
|
|
|
|
'phone' => undef, |
|
207
|
|
|
|
|
|
|
'ssn_last4' => undef, |
|
208
|
|
|
|
|
|
|
'updated_at' => '2014-10-02T07:59:26.405946Z' |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head2 create_customer |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
create_customer($customer) |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Creates a customer. |
|
216
|
|
|
|
|
|
|
A customer hashref is optional. |
|
217
|
|
|
|
|
|
|
Returns the customer. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Example: |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
$bp->create_customer({ name => 'Bob', email => 'bob@foo.com' }); |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 update_customer |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
update_customer($customer) |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Updates a customer. |
|
228
|
|
|
|
|
|
|
Returns the updated customer. |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Example: |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
my $customer = $bp->get_customer($customer_id); |
|
233
|
|
|
|
|
|
|
$customer->{email} = 'sue@foo.com'; |
|
234
|
|
|
|
|
|
|
$bp->update_customer($customer); |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 get_hold |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
get_hold($id) |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Returns the card hold for the given id. |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Example response: |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
{ |
|
245
|
|
|
|
|
|
|
'amount' => 123, |
|
246
|
|
|
|
|
|
|
'created_at' => '2014-10-03T03:39:46.933465Z', |
|
247
|
|
|
|
|
|
|
'currency' => 'USD', |
|
248
|
|
|
|
|
|
|
'description' => undef, |
|
249
|
|
|
|
|
|
|
'expires_at' => '2014-10-10T03:39:47.051257Z', |
|
250
|
|
|
|
|
|
|
'failure_reason' => undef, |
|
251
|
|
|
|
|
|
|
'failure_reason_code' => undef, |
|
252
|
|
|
|
|
|
|
'href' => '/card_holds/HL7b0bw2Ooe6G3yad7dR1rRr', |
|
253
|
|
|
|
|
|
|
'id' => 'HL7b0bw2Ooe6G3yad7dR1rRr', |
|
254
|
|
|
|
|
|
|
'links' => { |
|
255
|
|
|
|
|
|
|
'card' => 'CC7af3NesZk2bYR5GxqLLmfe', |
|
256
|
|
|
|
|
|
|
'debit' => undef, |
|
257
|
|
|
|
|
|
|
'order' => undef |
|
258
|
|
|
|
|
|
|
}, |
|
259
|
|
|
|
|
|
|
'meta' => {}, |
|
260
|
|
|
|
|
|
|
'status' => 'succeeded', |
|
261
|
|
|
|
|
|
|
'transaction_number' => 'HL7JT-EWF-5CQ6', |
|
262
|
|
|
|
|
|
|
'updated_at' => '2014-10-03T03:39:47.094448Z', |
|
263
|
|
|
|
|
|
|
'voided_at' => undef |
|
264
|
|
|
|
|
|
|
} |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head2 create_hold |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
create_hold($hold_data, card => $card) |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Creates a card hold. |
|
271
|
|
|
|
|
|
|
The C<$hold_data> hashref must contain an amount. |
|
272
|
|
|
|
|
|
|
The card param is a hashref such as one returned from L</get_card>. |
|
273
|
|
|
|
|
|
|
Returns the created hold. |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head2 capture_hold |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
capture_hold($hold, debit => $debit) |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
Captures a previously created card hold. |
|
280
|
|
|
|
|
|
|
This creates a debit. |
|
281
|
|
|
|
|
|
|
The C<$debit> hashref is optional and can contain an amount. |
|
282
|
|
|
|
|
|
|
Any amount up to the amount of the hold may be captured. |
|
283
|
|
|
|
|
|
|
Returns the created debit. |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
Example: |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
my $hold = $bp->get_hold($hold_id); |
|
288
|
|
|
|
|
|
|
my $debit = $bp->capture_hold( |
|
289
|
|
|
|
|
|
|
$hold, |
|
290
|
|
|
|
|
|
|
debit => { |
|
291
|
|
|
|
|
|
|
amount => 1000, |
|
292
|
|
|
|
|
|
|
description => 'money for stuffs', |
|
293
|
|
|
|
|
|
|
appears_on_statement_as => 'ACME 123', |
|
294
|
|
|
|
|
|
|
} |
|
295
|
|
|
|
|
|
|
); |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head2 void_hold |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
void_hold($hold) |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
Cancels the hold. |
|
302
|
|
|
|
|
|
|
Once voided, the hold can no longer be captured. |
|
303
|
|
|
|
|
|
|
Returns the voided hold. |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
Example: |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
my $hold = $bp->get_hold($hold_id); |
|
308
|
|
|
|
|
|
|
my $voided_hold = $bp->void_hold($hold); |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head2 get_debit |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
get_debit($id) |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
Returns the debit for the given id. |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Example response: |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
{ |
|
319
|
|
|
|
|
|
|
'amount' => 123, |
|
320
|
|
|
|
|
|
|
'appears_on_statement_as' => 'BAL*Tilt.com', |
|
321
|
|
|
|
|
|
|
'created_at' => '2014-10-06T05:01:39.045336Z', |
|
322
|
|
|
|
|
|
|
'currency' => 'USD', |
|
323
|
|
|
|
|
|
|
'description' => undef, |
|
324
|
|
|
|
|
|
|
'failure_reason' => undef, |
|
325
|
|
|
|
|
|
|
'failure_reason_code' => undef, |
|
326
|
|
|
|
|
|
|
'href' => '/debits/WD6F5x4VpYx4hfB02tGIqNU1', |
|
327
|
|
|
|
|
|
|
'id' => 'WD6F5x4VpYx4hfB02tGIqNU1', |
|
328
|
|
|
|
|
|
|
'links' => { |
|
329
|
|
|
|
|
|
|
'card_hold' => 'HL6F4q5kJGxt1ftH8vgZZJkh', |
|
330
|
|
|
|
|
|
|
'customer' => undef, |
|
331
|
|
|
|
|
|
|
'dispute' => undef, |
|
332
|
|
|
|
|
|
|
'order' => undef, |
|
333
|
|
|
|
|
|
|
'source' => 'CC6DFWepK7eeL03cZ06Sb9Xf' |
|
334
|
|
|
|
|
|
|
}, |
|
335
|
|
|
|
|
|
|
'meta' => {}, |
|
336
|
|
|
|
|
|
|
'status' => 'succeeded', |
|
337
|
|
|
|
|
|
|
'transaction_number' => 'WAVD-B0K-R7TX', |
|
338
|
|
|
|
|
|
|
'updated_at' => '2014-10-06T05:01:39.542306Z' |
|
339
|
|
|
|
|
|
|
} |
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=head2 create_debit |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
create_debit($debit, card => $card) |
|
344
|
|
|
|
|
|
|
create_debit($debit, bank => $bank) |
|
345
|
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
Debits a card or a bank. |
|
347
|
|
|
|
|
|
|
The C<$debit> hashref must contain an amount. |
|
348
|
|
|
|
|
|
|
The card param is a hashref such as one returned from L</get_card>. |
|
349
|
|
|
|
|
|
|
The bank param is a hashref such as one returned from L</get_bank_account>. |
|
350
|
|
|
|
|
|
|
Returns the created debit. |
|
351
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
Example: |
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
my $card = $bp->get_card($card_id); |
|
355
|
|
|
|
|
|
|
my $debit = $bp->create_debit({ amount => 123 }, card => $card); |
|
356
|
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
=head2 refund_debit |
|
358
|
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
refund_debit($debit) |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
Refunds a debit. |
|
362
|
|
|
|
|
|
|
Returnds the refund. |
|
363
|
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
Example: |
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
my $debit = $bp->get_debit($debit_id); |
|
367
|
|
|
|
|
|
|
my $refund = $bp->refund_debit($debit); |
|
368
|
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
Example response: |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
{ |
|
372
|
|
|
|
|
|
|
'amount' => 123, |
|
373
|
|
|
|
|
|
|
'created_at' => '2014-10-06T04:57:44.959806Z', |
|
374
|
|
|
|
|
|
|
'currency' => 'USD', |
|
375
|
|
|
|
|
|
|
'description' => undef, |
|
376
|
|
|
|
|
|
|
'href' => '/refunds/RF2pO6Fz8breGs2TAIpfE2nr', |
|
377
|
|
|
|
|
|
|
'id' => 'RF2pO6Fz8breGs2TAIpfE2nr', |
|
378
|
|
|
|
|
|
|
'links' => { |
|
379
|
|
|
|
|
|
|
'debit' => 'WD2hQV9COFX0aPMSIzyeAuAg', |
|
380
|
|
|
|
|
|
|
'dispute' => undef, |
|
381
|
|
|
|
|
|
|
'order' => undef |
|
382
|
|
|
|
|
|
|
}, |
|
383
|
|
|
|
|
|
|
'meta' => {}, |
|
384
|
|
|
|
|
|
|
'status' => 'succeeded', |
|
385
|
|
|
|
|
|
|
'transaction_number' => 'RFRGL-EU1-A39B', |
|
386
|
|
|
|
|
|
|
'updated_at' => '2014-10-06T04:57:48.161218Z' |
|
387
|
|
|
|
|
|
|
} |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
=head2 get_bank_account |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
get_bank_account($id) |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
Returns the bank account for the given id. |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
Example response: |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
{ |
|
398
|
|
|
|
|
|
|
'account_number' => 'xxxxxxxx6789', |
|
399
|
|
|
|
|
|
|
'account_type' => 'checking', |
|
400
|
|
|
|
|
|
|
'address' => { |
|
401
|
|
|
|
|
|
|
'city' => undef, |
|
402
|
|
|
|
|
|
|
'country_code' => 'USA', |
|
403
|
|
|
|
|
|
|
'line1' => '123 Abc St', |
|
404
|
|
|
|
|
|
|
'line2' => undef, |
|
405
|
|
|
|
|
|
|
'postal_code' => '94103', |
|
406
|
|
|
|
|
|
|
'state' => undef |
|
407
|
|
|
|
|
|
|
}, |
|
408
|
|
|
|
|
|
|
'bank_name' => '', |
|
409
|
|
|
|
|
|
|
'can_credit' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ), |
|
410
|
|
|
|
|
|
|
'can_debit' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ), |
|
411
|
|
|
|
|
|
|
'created_at' => '2014-10-06T06:40:14.649386Z', |
|
412
|
|
|
|
|
|
|
'fingerprint' => 'cc552495fc90556293db500b985bacc918d9fb4d37b42052adf64', |
|
413
|
|
|
|
|
|
|
'href' => '/bank_accounts/BA4TAWvO3d3J14i6BdjJUZsp', |
|
414
|
|
|
|
|
|
|
'id' => 'BA4TAWvO3d3J14i6BdjJUZsp', |
|
415
|
|
|
|
|
|
|
'links' => { |
|
416
|
|
|
|
|
|
|
'bank_account_verification' => undef, |
|
417
|
|
|
|
|
|
|
'customer' => undef |
|
418
|
|
|
|
|
|
|
}, |
|
419
|
|
|
|
|
|
|
'meta' => {}, |
|
420
|
|
|
|
|
|
|
'name' => 'Bob Smith', |
|
421
|
|
|
|
|
|
|
'routing_number' => '110000000', |
|
422
|
|
|
|
|
|
|
'updated_at' => '2014-10-06T06:40:14.649388Z' |
|
423
|
|
|
|
|
|
|
} |
|
424
|
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=head2 create_bank_account |
|
426
|
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
create_bank_account($bank) |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
Creates a bank account. |
|
430
|
|
|
|
|
|
|
Returns the bank account that was created. |
|
431
|
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
Example: |
|
433
|
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
my $bank = $bp->create_bank_account({ |
|
435
|
|
|
|
|
|
|
account_number => '000123456789', |
|
436
|
|
|
|
|
|
|
acount_type => 'checking', |
|
437
|
|
|
|
|
|
|
name => 'Bob Smith', |
|
438
|
|
|
|
|
|
|
routing_number => '110000000', |
|
439
|
|
|
|
|
|
|
address => { |
|
440
|
|
|
|
|
|
|
line1 => '123 Abc St', |
|
441
|
|
|
|
|
|
|
postal_code => '94103', |
|
442
|
|
|
|
|
|
|
}, |
|
443
|
|
|
|
|
|
|
}); |
|
444
|
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
=head2 add_bank_account |
|
446
|
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
add_bank_account($bank, customer => $customer) |
|
448
|
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
Associates a bank account to the given customer. |
|
450
|
|
|
|
|
|
|
Returns the bank account. |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
Example: |
|
453
|
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
my $bank = $bp->add_bank_account($bank_id); |
|
455
|
|
|
|
|
|
|
my $customer = $bp->get_customer($customer_id); |
|
456
|
|
|
|
|
|
|
$bank = $bp->add_bank_account($bank, customer => $customer); |
|
457
|
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
=head2 get_credit |
|
459
|
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
get_credit($id) |
|
461
|
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
Returns the credit for the given id. |
|
463
|
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
Example response: |
|
465
|
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
{ |
|
467
|
|
|
|
|
|
|
'amount' => 123, |
|
468
|
|
|
|
|
|
|
'appears_on_statement_as' => 'Tilt.com', |
|
469
|
|
|
|
|
|
|
'created_at' => '2014-10-06T06:52:00.522212Z', |
|
470
|
|
|
|
|
|
|
'currency' => 'USD', |
|
471
|
|
|
|
|
|
|
'description' => undef, |
|
472
|
|
|
|
|
|
|
'failure_reason' => undef, |
|
473
|
|
|
|
|
|
|
'failure_reason_code' => undef, |
|
474
|
|
|
|
|
|
|
'href' => '/credits/CR27ns5sg1FFgHsGy5VEhowd', |
|
475
|
|
|
|
|
|
|
'id' => 'CR27ns5sg1FFgHsGy5VEhowd', |
|
476
|
|
|
|
|
|
|
'links' => { |
|
477
|
|
|
|
|
|
|
'customer' => undef, |
|
478
|
|
|
|
|
|
|
'destination' => 'BA26JfFfg1vqrCoXPzSSxtKg', |
|
479
|
|
|
|
|
|
|
'order' => undef |
|
480
|
|
|
|
|
|
|
}, |
|
481
|
|
|
|
|
|
|
'meta' => {}, |
|
482
|
|
|
|
|
|
|
'status' => 'succeeded', |
|
483
|
|
|
|
|
|
|
'transaction_number' => 'CR4F7-4XQ-JLDG', |
|
484
|
|
|
|
|
|
|
'updated_at' => '2014-10-06T06:52:03.558485Z' |
|
485
|
|
|
|
|
|
|
} |
|
486
|
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
=head2 create_credit |
|
488
|
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
create_credit($credit, bank_account => $bank) |
|
490
|
|
|
|
|
|
|
create_credit($credit, card => $card) |
|
491
|
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
Sends money to a bank account or a credit card. |
|
493
|
|
|
|
|
|
|
The C<$credit> hashref must contain an amount. |
|
494
|
|
|
|
|
|
|
A bank_account or card param is required. |
|
495
|
|
|
|
|
|
|
Returns the created credit. |
|
496
|
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
Example: |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
my $bank = $bp->get_bank_account($bank_account_id); |
|
500
|
|
|
|
|
|
|
my $credit = $bp->create_credit({ amount => 123 }, bank_account => $bank); |
|
501
|
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
=head2 get_bank_verification |
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
get_bank_verification($id) |
|
505
|
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
Gets a bank account verification. |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
Example response: |
|
509
|
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
{ |
|
511
|
|
|
|
|
|
|
'attempts' => 0, |
|
512
|
|
|
|
|
|
|
'attempts_remaining' => 3, |
|
513
|
|
|
|
|
|
|
'created_at' => '2014-10-06T08:01:59.972034Z', |
|
514
|
|
|
|
|
|
|
'deposit_status' => 'succeeded', |
|
515
|
|
|
|
|
|
|
'href' => '/verifications/BZnWun9Itq7FVtj1nludGjC', |
|
516
|
|
|
|
|
|
|
'id' => 'BZnWun9Itq7FVtj1nludGjC', |
|
517
|
|
|
|
|
|
|
'links' => { |
|
518
|
|
|
|
|
|
|
'bank_account' => 'BAdFCPv3GkIlXEWQrdTyIW9' |
|
519
|
|
|
|
|
|
|
}, |
|
520
|
|
|
|
|
|
|
'meta' => {}, |
|
521
|
|
|
|
|
|
|
'updated_at' => '2014-10-06T08:02:00.268756Z', |
|
522
|
|
|
|
|
|
|
'verification_status' => 'pending' |
|
523
|
|
|
|
|
|
|
} |
|
524
|
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
=head2 create_bank_verification |
|
526
|
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
create_bank_verification(bank_account => $bank) |
|
528
|
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
Create a new bank account verification. |
|
530
|
|
|
|
|
|
|
This initiates the process of sending micro deposits to the bank account which |
|
531
|
|
|
|
|
|
|
will be used to verify bank account ownership. |
|
532
|
|
|
|
|
|
|
A bank_account param is required. |
|
533
|
|
|
|
|
|
|
Returns the created bank account verification. |
|
534
|
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
Example: |
|
536
|
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
my $bank = $bp->get_bank_account($bank_account_id); |
|
538
|
|
|
|
|
|
|
my $verification = $bp->create_bank_verification(bank_account => $bank); |
|
539
|
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
=head2 confirm_bank_verification |
|
541
|
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
confirm_bank_verification($verification, |
|
543
|
|
|
|
|
|
|
amount_1 => $amount_1, amount_2 => $amount_2); |
|
544
|
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
Confirm the trial deposit amounts that were sent to the bank account. |
|
546
|
|
|
|
|
|
|
Returns the bank account verification. |
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
Example: |
|
549
|
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
my $ver = $bp->get_bank_account($bank_account_id); |
|
551
|
|
|
|
|
|
|
$verification = |
|
552
|
|
|
|
|
|
|
$bp->confirm_bank_verification($ver, amount_1 => 1, amount_2 => 2); |
|
553
|
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
=head2 get_disputes |
|
555
|
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
get_disputes({ |
|
557
|
|
|
|
|
|
|
$start_date => '2014-01-01T12:00:00', |
|
558
|
|
|
|
|
|
|
$end_date => DateTime->now, |
|
559
|
|
|
|
|
|
|
$limit => 10, |
|
560
|
|
|
|
|
|
|
$offset => 0, |
|
561
|
|
|
|
|
|
|
}) |
|
562
|
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
Lists all disputes (chargebacks). |
|
564
|
|
|
|
|
|
|
All of the parameters are optional and must be passed inside of a HashRef. |
|
565
|
|
|
|
|
|
|
The C<$start_date> and C<$end_date> parameters can either be DateTime objects, or |
|
566
|
|
|
|
|
|
|
ISO8601 formatted strings. |
|
567
|
|
|
|
|
|
|
The C<$limit> and C<$offset> parameters must be valid integers. |
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
Example response: |
|
570
|
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
{ |
|
572
|
|
|
|
|
|
|
disputes => [ |
|
573
|
|
|
|
|
|
|
{ |
|
574
|
|
|
|
|
|
|
amount => 6150, |
|
575
|
|
|
|
|
|
|
created_at => '2013-12-06T02:05:13.656744Z', |
|
576
|
|
|
|
|
|
|
currency => 'USD', |
|
577
|
|
|
|
|
|
|
href => '/disputes/DT1234567890', |
|
578
|
|
|
|
|
|
|
id => 'DT1234567890', |
|
579
|
|
|
|
|
|
|
initiated_at => '2013-09-11T00:00:00Z', |
|
580
|
|
|
|
|
|
|
links => { |
|
581
|
|
|
|
|
|
|
transaction => 'WD1234567890' |
|
582
|
|
|
|
|
|
|
}, |
|
583
|
|
|
|
|
|
|
meta => {}, |
|
584
|
|
|
|
|
|
|
reason => 'clerical', |
|
585
|
|
|
|
|
|
|
respond_by => '2013-10-15T00:00:00Z', |
|
586
|
|
|
|
|
|
|
status => 'lost', |
|
587
|
|
|
|
|
|
|
updated_at => '2013-12-06T20:59:33.884181Z' |
|
588
|
|
|
|
|
|
|
}, |
|
589
|
|
|
|
|
|
|
{ |
|
590
|
|
|
|
|
|
|
amount => 10250, |
|
591
|
|
|
|
|
|
|
created_at => '2013-12-06T01:55:28.882064Z', |
|
592
|
|
|
|
|
|
|
currency => 'USD', |
|
593
|
|
|
|
|
|
|
href => '/disputes/DT0987654321', |
|
594
|
|
|
|
|
|
|
id => 'DT0987654321', |
|
595
|
|
|
|
|
|
|
initiated_at => '2013-08-28T00:00:00Z', |
|
596
|
|
|
|
|
|
|
links => { |
|
597
|
|
|
|
|
|
|
transaction => 'WD0987654321' |
|
598
|
|
|
|
|
|
|
}, |
|
599
|
|
|
|
|
|
|
meta => {}, |
|
600
|
|
|
|
|
|
|
reason => 'clerical', |
|
601
|
|
|
|
|
|
|
respond_by => '2013-10-02T00:00:00Z', |
|
602
|
|
|
|
|
|
|
status => 'lost', |
|
603
|
|
|
|
|
|
|
updated_at => '2013-12-06T21:04:11.158050Z' |
|
604
|
|
|
|
|
|
|
} |
|
605
|
|
|
|
|
|
|
], |
|
606
|
|
|
|
|
|
|
links => { |
|
607
|
|
|
|
|
|
|
disputes.events => '/disputes/{disputes.id}/events', |
|
608
|
|
|
|
|
|
|
disputes.transaction => '/resources/{disputes.transaction}', |
|
609
|
|
|
|
|
|
|
}, |
|
610
|
|
|
|
|
|
|
meta { |
|
611
|
|
|
|
|
|
|
first => '/disputes?limit=10&offset=0', |
|
612
|
|
|
|
|
|
|
href => '/disputes?limit=10&offset=0', |
|
613
|
|
|
|
|
|
|
last => '/disputes?limit=10&offset=300', |
|
614
|
|
|
|
|
|
|
limit => 10, |
|
615
|
|
|
|
|
|
|
next => '/disputes?limit=10&offset=10', |
|
616
|
|
|
|
|
|
|
offset => 0, |
|
617
|
|
|
|
|
|
|
previous => undef, |
|
618
|
|
|
|
|
|
|
total => 100 |
|
619
|
|
|
|
|
|
|
} |
|
620
|
|
|
|
|
|
|
} |
|
621
|
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
=head2 get_dispute |
|
623
|
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
get_dispute('DT1234567890') |
|
625
|
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
Fetches a dispute (chargeback). |
|
627
|
|
|
|
|
|
|
The C<$id> of the dispute is a required parameter. |
|
628
|
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
Example response: |
|
630
|
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
{ |
|
632
|
|
|
|
|
|
|
amount => 6150, |
|
633
|
|
|
|
|
|
|
created_at => '2013-12-06T02:05:13.656744Z', |
|
634
|
|
|
|
|
|
|
currency => 'USD', |
|
635
|
|
|
|
|
|
|
href => '/disputes/DT1234567890', |
|
636
|
|
|
|
|
|
|
id => 'DT1234567890', |
|
637
|
|
|
|
|
|
|
initiated_at => '2013-09-11T00:00:00Z', |
|
638
|
|
|
|
|
|
|
links => { |
|
639
|
|
|
|
|
|
|
transaction => 'WD1234567890' |
|
640
|
|
|
|
|
|
|
}, |
|
641
|
|
|
|
|
|
|
meta => {}, |
|
642
|
|
|
|
|
|
|
reason => 'clerical', |
|
643
|
|
|
|
|
|
|
respond_by => '2013-10-15T00:00:00Z', |
|
644
|
|
|
|
|
|
|
status => 'lost', |
|
645
|
|
|
|
|
|
|
updated_at => '2013-12-06T20:59:33.884181Z' |
|
646
|
|
|
|
|
|
|
} |
|
647
|
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
=head1 AUTHORS |
|
649
|
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
=over 4 |
|
651
|
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
=item * |
|
653
|
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
Ali Anari <ali@tilt.com> |
|
655
|
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
=item * |
|
657
|
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
Khaled Hussein <khaled@tilt.com> |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
=item * |
|
661
|
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
Naveed Massjouni <naveed@tilt.com> |
|
663
|
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=item * |
|
665
|
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
Al Newkirk <al@tilt.com> |
|
667
|
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=item * |
|
669
|
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
Will Wolf <will@tilt.com> |
|
671
|
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
=back |
|
673
|
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
675
|
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Crowdtilt, Inc.. |
|
677
|
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
679
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
680
|
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
=cut |