line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Braintree::TransactionGateway; |
2
|
|
|
|
|
|
|
$WebService::Braintree::TransactionGateway::VERSION = '0.93'; |
3
|
1
|
|
|
1
|
|
12
|
use Moose; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
13
|
|
4
|
|
|
|
|
|
|
with 'WebService::Braintree::Role::MakeRequest'; |
5
|
1
|
|
|
1
|
|
13155
|
use Carp qw(confess); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
118
|
|
6
|
1
|
|
|
1
|
|
11
|
use WebService::Braintree::Util qw(validate_id); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
77
|
|
7
|
1
|
|
|
1
|
|
11
|
use WebService::Braintree::Validations qw(verify_params transaction_signature clone_transaction_signature transaction_search_results_signature); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
105
|
|
8
|
1
|
|
|
1
|
|
9
|
use WebService::Braintree::Util; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1649
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'gateway' => (is => 'ro'); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub create { |
13
|
0
|
|
|
0
|
0
|
|
my ($self, $params) = @_; |
14
|
0
|
0
|
|
|
|
|
confess "ArgumentError" unless verify_params($params, transaction_signature); |
15
|
0
|
|
|
|
|
|
$self->_make_request("/transactions/", "post", {transaction => $params}); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub find { |
19
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
20
|
0
|
0
|
|
|
|
|
confess "NotFoundError" unless validate_id($id); |
21
|
0
|
|
|
|
|
|
$self->_make_request("/transactions/$id", "get", undef); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub retry_subscription_charge { |
25
|
0
|
|
|
0
|
0
|
|
my ($self, $subscription_id, $amount) = @_; |
26
|
0
|
|
|
|
|
|
my $params = { |
27
|
|
|
|
|
|
|
subscription_id => $subscription_id, |
28
|
|
|
|
|
|
|
amount => $amount, |
29
|
|
|
|
|
|
|
type => "sale" |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$self->create($params); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub submit_for_settlement { |
36
|
0
|
|
|
0
|
0
|
|
my ($self, $id, $params) = @_; |
37
|
0
|
|
|
|
|
|
$self->_make_request("/transactions/$id/submit_for_settlement", "put", {transaction => $params}); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub void { |
41
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
42
|
0
|
|
|
|
|
|
$self->_make_request("/transactions/$id/void", "put", undef); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub refund { |
46
|
0
|
|
|
0
|
0
|
|
my ($self, $id, $params) = @_; |
47
|
0
|
|
|
|
|
|
$self->_make_request("/transactions/$id/refund", "post", {transaction => $params}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub clone_transaction { |
51
|
0
|
|
|
0
|
0
|
|
my ($self, $id, $params) = @_; |
52
|
0
|
0
|
|
|
|
|
confess "ArgumentError" unless verify_params($params, clone_transaction_signature); |
53
|
0
|
|
|
|
|
|
$self->_make_request("/transactions/$id/clone", "post", {transaction_clone => $params}); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub search { |
57
|
0
|
|
|
0
|
0
|
|
my ($self, $block) = @_; |
58
|
0
|
|
|
|
|
|
my $search = WebService::Braintree::TransactionSearch->new; |
59
|
0
|
|
|
|
|
|
my $params = $block->($search)->to_hash; |
60
|
0
|
|
|
|
|
|
my $response = $self->gateway->http->post("/transactions/advanced_search_ids", {search => $params}); |
61
|
0
|
0
|
|
|
|
|
confess "DownForMaintenanceError" unless (verify_params($response, transaction_search_results_signature)); |
62
|
|
|
|
|
|
|
return WebService::Braintree::ResourceCollection->new()->init($response, sub { |
63
|
0
|
|
|
0
|
|
|
$self->fetch_transactions($search, shift); |
64
|
0
|
|
|
|
|
|
}); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub hold_in_escrow { |
68
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
69
|
0
|
|
|
|
|
|
$self->_make_request("/transactions/$id/hold_in_escrow", "put", undef); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub release_from_escrow { |
73
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
74
|
0
|
|
|
|
|
|
$self->_make_request("/transactions/$id/release_from_escrow", "put", undef); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub cancel_release { |
78
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
79
|
0
|
|
|
|
|
|
$self->_make_request("/transactions/$id/cancel_release", "put", undef); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub all { |
83
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
84
|
0
|
|
|
|
|
|
my $response = $self->gateway->http->post("/transactions/advanced_search_ids"); |
85
|
|
|
|
|
|
|
return WebService::Braintree::ResourceCollection->new()->init($response, sub { |
86
|
0
|
|
|
0
|
|
|
$self->fetch_transactions(WebService::Braintree::TransactionSearch->new, shift); |
87
|
0
|
|
|
|
|
|
}); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub fetch_transactions { |
91
|
0
|
|
|
0
|
0
|
|
my ($self, $search, $ids) = @_; |
92
|
0
|
|
|
|
|
|
$search->ids->in($ids); |
93
|
0
|
0
|
|
|
|
|
return [] if scalar @{$ids} == 0; |
|
0
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $response = $self->gateway->http->post("/transactions/advanced_search/", {search => $search->to_hash}); |
95
|
0
|
|
|
|
|
|
my $attrs = $response->{'credit_card_transactions'}->{'transaction'}; |
96
|
0
|
|
|
|
|
|
return to_instance_array($attrs, "WebService::Braintree::Transaction"); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|