line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Braintree::Transaction; |
2
|
|
|
|
|
|
|
$WebService::Braintree::Transaction::VERSION = '0.94'; |
3
|
20
|
|
|
20
|
|
459
|
use 5.010_001; |
|
20
|
|
|
|
|
71
|
|
4
|
20
|
|
|
20
|
|
111
|
use strictures 1; |
|
20
|
|
|
|
|
153
|
|
|
20
|
|
|
|
|
819
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
WebService::Braintree::Transaction |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 PURPOSE |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
This class generates and manages transactions. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
20
|
|
|
20
|
|
6900
|
use WebService::Braintree::Transaction::CreatedUsing; |
|
20
|
|
|
|
|
47
|
|
|
20
|
|
|
|
|
499
|
|
17
|
20
|
|
|
20
|
|
4652
|
use WebService::Braintree::Transaction::EscrowStatus; |
|
20
|
|
|
|
|
46
|
|
|
20
|
|
|
|
|
503
|
|
18
|
20
|
|
|
20
|
|
4567
|
use WebService::Braintree::Transaction::Source; |
|
20
|
|
|
|
|
46
|
|
|
20
|
|
|
|
|
498
|
|
19
|
20
|
|
|
20
|
|
4635
|
use WebService::Braintree::Transaction::Status; |
|
20
|
|
|
|
|
46
|
|
|
20
|
|
|
|
|
529
|
|
20
|
20
|
|
|
20
|
|
4783
|
use WebService::Braintree::Transaction::Type; |
|
20
|
|
|
|
|
52
|
|
|
20
|
|
|
|
|
493
|
|
21
|
|
|
|
|
|
|
|
22
|
20
|
|
|
20
|
|
105
|
use Moose; |
|
20
|
|
|
|
|
36
|
|
|
20
|
|
|
|
|
139
|
|
23
|
|
|
|
|
|
|
extends "WebService::Braintree::ResultObject"; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 CLASS METHODS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 sale() |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This takes a hashref of parameters and returns the transaction created. This is |
30
|
|
|
|
|
|
|
a wrapper around L</create()> with the type set to 'sale'. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub sale { |
35
|
0
|
|
|
0
|
1
|
|
my ($class, $params) = @_; |
36
|
0
|
|
|
|
|
|
$class->create($params, 'sale'); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 credit() |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
This takes a hashref of parameters and returns the transaction created. This is |
42
|
|
|
|
|
|
|
a wrapper around L</create()> with the type set to 'credit'. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub credit { |
47
|
0
|
|
|
0
|
1
|
|
my ($class, $params) = @_; |
48
|
0
|
|
|
|
|
|
$class->create($params, 'credit'); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 credit() |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This takes a hashref of parameters and a type and returns the transaction |
54
|
|
|
|
|
|
|
created. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
In general, you will not call this method. Instead, call one of the wrappers |
57
|
|
|
|
|
|
|
of this method, such as L</sale()> and L</credit()>. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub create { |
62
|
0
|
|
|
0
|
0
|
|
my ($class, $params, $type) = @_; |
63
|
0
|
|
|
|
|
|
$params->{'type'} = $type; |
64
|
0
|
|
|
|
|
|
$class->gateway->transaction->create($params); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 find() |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This takes an id and returns the transaction (if it exists). |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub find { |
74
|
0
|
|
|
0
|
1
|
|
my ($class, $id) = @_; |
75
|
0
|
|
|
|
|
|
$class->gateway->transaction->find($id); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 clone_transaction() |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This takes an id and a hashref of parameters and clones the transaction (if it |
81
|
|
|
|
|
|
|
exists) with the parameters as overrides. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub clone_transaction { |
86
|
0
|
|
|
0
|
1
|
|
my ($class, $id, $params) = @_; |
87
|
0
|
|
|
|
|
|
$class->gateway->transaction->clone_transaction($id, $params); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 void() |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This takes an id and voids the transaction (if it exists). |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub void { |
97
|
0
|
|
|
0
|
1
|
|
my ($class, $id) = @_; |
98
|
0
|
|
|
|
|
|
$class->gateway->transaction->void($id); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 submit_for_settlement() |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This takes an id and an optional amount and submits the transaction (if it |
104
|
|
|
|
|
|
|
exists) for settlement. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub submit_for_settlement { |
109
|
0
|
|
|
0
|
1
|
|
my ($class, $id, $amount) = @_; |
110
|
0
|
|
|
|
|
|
my $params = {}; |
111
|
0
|
0
|
|
|
|
|
$params->{'amount'} = $amount if $amount; |
112
|
0
|
|
|
|
|
|
$class->gateway->transaction->submit_for_settlement($id, $params); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 refund() |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This takes an id and an optional amount and refunds the transaction (if it |
118
|
|
|
|
|
|
|
exists). |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub refund { |
123
|
0
|
|
|
0
|
1
|
|
my ($class, $id, $amount) = @_; |
124
|
0
|
|
|
|
|
|
my $params = {}; |
125
|
0
|
0
|
|
|
|
|
$params->{'amount'} = $amount if $amount; |
126
|
0
|
|
|
|
|
|
$class->gateway->transaction->refund($id, $params); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 hold_in_escrow() |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This takes an id and holds the transaction (if it exists) in escrow. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub hold_in_escrow { |
136
|
0
|
|
|
0
|
1
|
|
my ($class, $id) = @_; |
137
|
0
|
|
|
|
|
|
$class->gateway->transaction->hold_in_escrow($id); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 release_from_escrow() |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This takes an id and releases the transaction (if it exists) from escrow. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub release_from_escrow { |
147
|
0
|
|
|
0
|
1
|
|
my ($class, $id) = @_; |
148
|
0
|
|
|
|
|
|
$class->gateway->transaction->release_from_escrow($id); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 cancel_release() |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This takes an id and cancels the release of the transaction (if it exists). |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub cancel_release { |
158
|
0
|
|
|
0
|
1
|
|
my ($class, $id) = @_; |
159
|
0
|
|
|
|
|
|
$class->gateway->transaction->cancel_release($id); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 search() |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This takes a subref which is used to set the search parameters and returns a |
165
|
|
|
|
|
|
|
transaction object. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Please see L<Searching|WebService::Braintree/SEARCHING> for more information on |
168
|
|
|
|
|
|
|
the subref and how it works. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub search { |
173
|
0
|
|
|
0
|
1
|
|
my ($class, $block) = @_; |
174
|
0
|
|
|
|
|
|
$class->gateway->transaction->search($block); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 all() |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This returns all the transactions. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub all { |
184
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
185
|
0
|
|
|
|
|
|
$class->gateway->transaction->all; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub gateway { |
189
|
0
|
|
|
0
|
0
|
|
WebService::Braintree->configuration->gateway; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
In addition to the methods provided by the keys returned from Braintree, this |
195
|
|
|
|
|
|
|
class provides the following methods: |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 disbursement_details() |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This returns the disbursement details of this transaction (if they exist). It |
200
|
|
|
|
|
|
|
will be a L<WebService::Braintree::DisbursementDetails> object. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
has disbursement_details => (is => 'rw'); |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 paypal_details() |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
This returns the PayPal details of this transaction (if they exist). It |
209
|
|
|
|
|
|
|
will be a L<WebService::Braintree::PayPalDetails> object. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
has paypal_details => (is => 'rw'); |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head2 subscription() |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This returns the related subscription of this transaction (if they exist). It |
218
|
|
|
|
|
|
|
will be a L<WebService::Braintree::Subscription> object. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=cut |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
has subscription => (is => 'rw'); |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub BUILD { |
225
|
0
|
|
|
0
|
0
|
|
my ($self, $attrs) = @_; |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
$self->build_sub_object($attrs, |
228
|
|
|
|
|
|
|
method => 'subscription', |
229
|
|
|
|
|
|
|
class => 'Subscription', |
230
|
|
|
|
|
|
|
key => 'subscription', |
231
|
|
|
|
|
|
|
); |
232
|
0
|
|
|
|
|
|
$self->build_sub_object($attrs, |
233
|
|
|
|
|
|
|
method => 'disbursement_details', |
234
|
|
|
|
|
|
|
class => 'DisbursementDetails', |
235
|
|
|
|
|
|
|
key => 'disbursement_details', |
236
|
|
|
|
|
|
|
); |
237
|
0
|
|
|
|
|
|
$self->build_sub_object($attrs, |
238
|
|
|
|
|
|
|
method => 'paypal_details', |
239
|
|
|
|
|
|
|
class => 'PayPalDetails', |
240
|
|
|
|
|
|
|
key => 'paypal', |
241
|
|
|
|
|
|
|
); |
242
|
|
|
|
|
|
|
|
243
|
0
|
|
|
|
|
|
$self->setup_sub_objects($self, $attrs, { |
244
|
|
|
|
|
|
|
disputes => 'WebService::Braintree::Dispute', |
245
|
|
|
|
|
|
|
}); |
246
|
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
|
$self->set_attributes_from_hash($self, $attrs); |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head2 is_disbursed() |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
This returns whether or not the disbursement details of this transaction are |
253
|
|
|
|
|
|
|
valid. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub is_disbursed { |
258
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
259
|
0
|
0
|
|
|
|
|
$self->disbursement_details && $self->disbursement_details->is_valid(); |
260
|
|
|
|
|
|
|
}; |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
1; |
265
|
|
|
|
|
|
|
__END__ |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head1 TODO |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=over 4 |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=item Need to document the keys and values that are returned |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=item Need to document the required and optional input parameters |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=item Need to document the possible errors/exceptions |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=back |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=cut |