| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Braintree::MerchantAccountGateway; |
|
2
|
|
|
|
|
|
|
$WebService::Braintree::MerchantAccountGateway::VERSION = '0.94'; |
|
3
|
20
|
|
|
20
|
|
402
|
use 5.010_001; |
|
|
20
|
|
|
|
|
68
|
|
|
4
|
20
|
|
|
20
|
|
102
|
use strictures 1; |
|
|
20
|
|
|
|
|
140
|
|
|
|
20
|
|
|
|
|
760
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
20
|
|
|
20
|
|
1995
|
use Moose; |
|
|
20
|
|
|
|
|
44
|
|
|
|
20
|
|
|
|
|
119
|
|
|
7
|
|
|
|
|
|
|
with 'WebService::Braintree::Role::MakeRequest'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
20
|
|
|
20
|
|
122278
|
use Carp qw(confess); |
|
|
20
|
|
|
|
|
69
|
|
|
|
20
|
|
|
|
|
1210
|
|
|
10
|
20
|
|
|
20
|
|
124
|
use WebService::Braintree::Validations qw(verify_params); |
|
|
20
|
|
|
|
|
45
|
|
|
|
20
|
|
|
|
|
871
|
|
|
11
|
20
|
|
|
20
|
|
142
|
use WebService::Braintree::Util qw(validate_id is_hashref to_instance_array); |
|
|
20
|
|
|
|
|
41
|
|
|
|
20
|
|
|
|
|
1066
|
|
|
12
|
20
|
|
|
20
|
|
121
|
use WebService::Braintree::Result; |
|
|
20
|
|
|
|
|
51
|
|
|
|
20
|
|
|
|
|
12228
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'gateway' => (is => 'ro'); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub create { |
|
17
|
0
|
|
|
0
|
0
|
|
my ($self, $params) = @_; |
|
18
|
0
|
0
|
|
|
|
|
confess "ArgumentError" unless verify_params($params, _detect_signature($params)); |
|
19
|
0
|
|
|
|
|
|
$self->_make_request("/merchant_accounts/create_via_api", "post", {merchant_account => $params}); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub update { |
|
23
|
0
|
|
|
0
|
0
|
|
my ($self, $merchant_account_id, $params) = @_; |
|
24
|
0
|
0
|
|
|
|
|
confess "ArgumentError" unless verify_params($params, _update_signature()); |
|
25
|
0
|
|
|
|
|
|
$self->_make_request("/merchant_accounts/${merchant_account_id}/update_via_api", "put", {merchant_account => $params}); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub find { |
|
29
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
|
30
|
0
|
0
|
|
|
|
|
confess "NotFoundError" unless validate_id($id); |
|
31
|
0
|
|
|
|
|
|
my $result = $self->_make_request("/merchant_accounts/$id", "get", undef)->merchant_account; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub all { |
|
35
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
36
|
0
|
|
|
|
|
|
my $response = $self->gateway->http->get("/merchant_accounts"); |
|
37
|
0
|
|
|
|
|
|
return to_instance_array($response->{merchant_accounts}{merchant_account}, 'WebService::Braintree::MerchantAccount'); |
|
38
|
|
|
|
|
|
|
#return WebService::Braintree::ResourceCollection->new->init($response, sub { |
|
39
|
|
|
|
|
|
|
# $self->fetch_merchant_accounts( |
|
40
|
|
|
|
|
|
|
# WebService::Braintree::MerchantAccountSearch->new, shift, |
|
41
|
|
|
|
|
|
|
# ); |
|
42
|
|
|
|
|
|
|
#}); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub fetch_merchant_accounts { |
|
46
|
0
|
|
|
0
|
0
|
|
my ($self, $search, $ids) = @_; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
return [] if scalar @{$ids} == 0; |
|
|
0
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$search->ids->in($ids); |
|
51
|
0
|
|
|
|
|
|
my $response = $self->gateway->http->post("/merchant_accounts/advanced_search/", {search => $search->to_hash}); |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $attrs = $response->{'merchant_accounts'}->{'merchant_account'}; |
|
54
|
0
|
|
|
|
|
|
return to_instance_array($attrs, "WebService::Braintree::MerchantAccount"); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _detect_signature { |
|
58
|
0
|
|
|
0
|
|
|
my ($params) = @_; |
|
59
|
0
|
0
|
|
|
|
|
if (is_hashref($params->{applicant_details})) { |
|
60
|
0
|
|
|
|
|
|
warnings::warnif("deprecated", "[DEPRECATED] Passing applicant_details to create is deprecated. Please use individual, business, and funding."); |
|
61
|
0
|
|
|
|
|
|
return _deprecated_create_signature(); |
|
62
|
|
|
|
|
|
|
} else { |
|
63
|
0
|
|
|
|
|
|
return _create_signature(); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _deprecated_create_signature{ |
|
68
|
|
|
|
|
|
|
return { |
|
69
|
0
|
|
|
0
|
|
|
applicant_details => { |
|
70
|
|
|
|
|
|
|
company_name => ".", |
|
71
|
|
|
|
|
|
|
first_name => ".", |
|
72
|
|
|
|
|
|
|
last_name => ".", |
|
73
|
|
|
|
|
|
|
email => ".", |
|
74
|
|
|
|
|
|
|
phone => ".", |
|
75
|
|
|
|
|
|
|
date_of_birth => ".", |
|
76
|
|
|
|
|
|
|
ssn => ".", |
|
77
|
|
|
|
|
|
|
tax_id => ".", |
|
78
|
|
|
|
|
|
|
routing_number => ".", |
|
79
|
|
|
|
|
|
|
account_number => ".", |
|
80
|
|
|
|
|
|
|
address => { |
|
81
|
|
|
|
|
|
|
street_address => ".", |
|
82
|
|
|
|
|
|
|
postal_code => ".", |
|
83
|
|
|
|
|
|
|
locality => ".", |
|
84
|
|
|
|
|
|
|
region => ".", |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
}, |
|
87
|
|
|
|
|
|
|
tos_accepted => ".", |
|
88
|
|
|
|
|
|
|
master_merchant_account_id => ".", |
|
89
|
|
|
|
|
|
|
id => "." |
|
90
|
|
|
|
|
|
|
}; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _create_signature{ |
|
94
|
|
|
|
|
|
|
return { |
|
95
|
0
|
|
|
0
|
|
|
individual => { |
|
96
|
|
|
|
|
|
|
first_name => ".", |
|
97
|
|
|
|
|
|
|
last_name => ".", |
|
98
|
|
|
|
|
|
|
email => ".", |
|
99
|
|
|
|
|
|
|
phone => ".", |
|
100
|
|
|
|
|
|
|
date_of_birth => ".", |
|
101
|
|
|
|
|
|
|
ssn => ".", |
|
102
|
|
|
|
|
|
|
address => { |
|
103
|
|
|
|
|
|
|
street_address => ".", |
|
104
|
|
|
|
|
|
|
postal_code => ".", |
|
105
|
|
|
|
|
|
|
locality => ".", |
|
106
|
|
|
|
|
|
|
region => ".", |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
}, |
|
109
|
|
|
|
|
|
|
business => { |
|
110
|
|
|
|
|
|
|
legal_name => ".", |
|
111
|
|
|
|
|
|
|
dba_name => ".", |
|
112
|
|
|
|
|
|
|
tax_id => ".", |
|
113
|
|
|
|
|
|
|
address => { |
|
114
|
|
|
|
|
|
|
street_address => ".", |
|
115
|
|
|
|
|
|
|
postal_code => ".", |
|
116
|
|
|
|
|
|
|
locality => ".", |
|
117
|
|
|
|
|
|
|
region => ".", |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
}, |
|
120
|
|
|
|
|
|
|
funding => { |
|
121
|
|
|
|
|
|
|
destination => ".", |
|
122
|
|
|
|
|
|
|
email => ".", |
|
123
|
|
|
|
|
|
|
mobile_phone => ".", |
|
124
|
|
|
|
|
|
|
routing_number => ".", |
|
125
|
|
|
|
|
|
|
account_number => ".", |
|
126
|
|
|
|
|
|
|
descriptor => ".", |
|
127
|
|
|
|
|
|
|
}, |
|
128
|
|
|
|
|
|
|
tos_accepted => ".", |
|
129
|
|
|
|
|
|
|
master_merchant_account_id => ".", |
|
130
|
|
|
|
|
|
|
id => "." |
|
131
|
|
|
|
|
|
|
}; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub _update_signature{ |
|
135
|
|
|
|
|
|
|
return { |
|
136
|
0
|
|
|
0
|
|
|
individual => { |
|
137
|
|
|
|
|
|
|
first_name => ".", |
|
138
|
|
|
|
|
|
|
last_name => ".", |
|
139
|
|
|
|
|
|
|
email => ".", |
|
140
|
|
|
|
|
|
|
phone => ".", |
|
141
|
|
|
|
|
|
|
date_of_birth => ".", |
|
142
|
|
|
|
|
|
|
ssn => ".", |
|
143
|
|
|
|
|
|
|
address => { |
|
144
|
|
|
|
|
|
|
street_address => ".", |
|
145
|
|
|
|
|
|
|
postal_code => ".", |
|
146
|
|
|
|
|
|
|
locality => ".", |
|
147
|
|
|
|
|
|
|
region => ".", |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
}, |
|
150
|
|
|
|
|
|
|
business => { |
|
151
|
|
|
|
|
|
|
legal_name => ".", |
|
152
|
|
|
|
|
|
|
dba_name => ".", |
|
153
|
|
|
|
|
|
|
tax_id => ".", |
|
154
|
|
|
|
|
|
|
address => { |
|
155
|
|
|
|
|
|
|
street_address => ".", |
|
156
|
|
|
|
|
|
|
postal_code => ".", |
|
157
|
|
|
|
|
|
|
locality => ".", |
|
158
|
|
|
|
|
|
|
region => ".", |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
}, |
|
161
|
|
|
|
|
|
|
funding => { |
|
162
|
|
|
|
|
|
|
destination => ".", |
|
163
|
|
|
|
|
|
|
email => ".", |
|
164
|
|
|
|
|
|
|
mobile_phone => ".", |
|
165
|
|
|
|
|
|
|
routing_number => ".", |
|
166
|
|
|
|
|
|
|
account_number => ".", |
|
167
|
|
|
|
|
|
|
descriptor => ".", |
|
168
|
|
|
|
|
|
|
}, |
|
169
|
|
|
|
|
|
|
master_merchant_account_id => ".", |
|
170
|
|
|
|
|
|
|
id => "." |
|
171
|
|
|
|
|
|
|
}; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |
|
177
|
|
|
|
|
|
|
__END__ |