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