line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Braintree::CreditCardGateway; |
2
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
5628
|
use Carp qw(confess); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
109
|
|
4
|
1
|
|
|
1
|
|
7
|
use Net::Braintree::Validations qw(verify_params credit_card_signature); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
5
|
1
|
|
|
1
|
|
5
|
use Net::Braintree::Util qw(validate_id); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
6
|
1
|
|
|
1
|
|
4
|
use Net::Braintree::Result; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
7
|
1
|
|
|
1
|
|
4
|
use Try::Tiny; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
432
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'gateway' => (is => 'ro'); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub create { |
12
|
0
|
|
|
0
|
0
|
|
my ($self, $params) = @_; |
13
|
0
|
0
|
|
|
|
|
confess "ArgumentError" unless verify_params($params, credit_card_signature); |
14
|
0
|
|
|
|
|
|
$self->_make_request("/payment_methods/", "post", {credit_card => $params}); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub delete { |
18
|
0
|
|
|
0
|
0
|
|
my ($self, $token) = @_; |
19
|
0
|
|
|
|
|
|
$self->_make_request("/payment_methods/credit_card/$token", "delete", undef); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub update { |
23
|
0
|
|
|
0
|
0
|
|
my ($self, $token, $params) = @_; |
24
|
0
|
0
|
|
|
|
|
confess "ArgumentError" unless verify_params($params, credit_card_signature); |
25
|
0
|
|
|
|
|
|
$self->_make_request("/payment_methods/credit_card/$token", "put", {credit_card => $params}); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub find { |
29
|
0
|
|
|
0
|
0
|
|
my ($self, $token) = @_; |
30
|
0
|
0
|
|
|
|
|
confess "NotFoundError" unless validate_id($token); |
31
|
0
|
|
|
|
|
|
$self->_make_request("/payment_methods/credit_card/$token", "get", undef)->credit_card; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub from_nonce { |
35
|
0
|
|
|
0
|
0
|
|
my ($self, $nonce) = @_; |
36
|
0
|
0
|
|
|
|
|
confess "NotFoundError" unless validate_id($nonce); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
try { |
39
|
0
|
|
|
0
|
|
|
return $self->_make_request("/payment_methods/from_nonce/$nonce", "get", undef)->credit_card; |
40
|
|
|
|
|
|
|
} catch { |
41
|
0
|
|
|
0
|
|
|
confess "Payment method with nonce $nonce locked, consumed or not found"; |
42
|
|
|
|
|
|
|
} |
43
|
0
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _make_request { |
46
|
0
|
|
|
0
|
|
|
my($self, $path, $verb, $params) = @_; |
47
|
0
|
|
|
|
|
|
my $response = $self->gateway->http->$verb($path, $params); |
48
|
0
|
|
|
|
|
|
my $result = Net::Braintree::Result->new(response => $response); |
49
|
0
|
|
|
|
|
|
return $result; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |