Braintree/CreditCardGateway.pm

filter: Statementstmt 50.0% 20 / 40 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 6 / 14 Podpod 0.0% 0 / 5 totaltotal 38.8% 26 / 67 CC 5 SCAR 12.4
CC
5
Cov
42%
create
6.0
update
6.0
find
6.0
CRAP 3.4
« Braintree/MerchantAccount/IndividualDetails.pm ↑ Summary Braintree/TransactionGateway.pm »
1 package Net::Braintree::CreditCardGateway;
2 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Net::Braintree::Validations qw(verify_params credit_card_signature);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Net::Braintree::Util qw(validate_id);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Net::Braintree::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 has 'gateway' => (is => 'ro');
10  
11 sub create {
12 0 ▶ my ($self, $params) = @_;
Subroutine create: not called CC=2 SCAR=17.9
Pod undocumented
13 0 ▶ confess "ArgumentError" unless verify_params($params, credit_card_signature);
Branch: 1 branch
BranchTrueFalseTotal
unless verify_params($params, credit_card_signature()) 0 0 0
14 0 $self->_make_request("/payment_methods/", "post", {credit_card => $params});
15 }
16  
17 sub delete {
18 0 ▶ my ($self, $token) = @_;
Subroutine delete: not called CC=1 SCAR=6.9
Pod undocumented
19 0 $self->_make_request("/payment_methods/credit_card/$token", "delete", undef);
20 }
21  
22 sub update {
23 0 ▶ my ($self, $token, $params) = @_;
Subroutine update: not called CC=2 SCAR=17.9
Pod undocumented
24 0 ▶ confess "ArgumentError" unless verify_params($params, credit_card_signature);
Branch: 1 branch
BranchTrueFalseTotal
unless verify_params($params, credit_card_signature()) 0 0 0
25 0 $self->_make_request("/payment_methods/credit_card/$token", "put", {credit_card => $params});
26 }
27  
28 sub find {
29 0 ▶ my ($self, $token) = @_;
Subroutine find: not called CC=2 SCAR=17.9
Pod undocumented
30 0 ▶ confess "NotFoundError" unless validate_id($token);
Branch: 1 branch
BranchTrueFalseTotal
unless validate_id($token) 0 0 0
31 0 $self->_make_request("/payment_methods/credit_card/$token", "get", undef)->credit_card;
32 }
33  
34 sub from_nonce {
35 0 ▶ my ($self, $nonce) = @_;
Subroutine from_nonce: not called CC=2 SCAR=17.9
Pod undocumented
36 0 ▶ confess "NotFoundError" unless validate_id($nonce);
Branch: 1 branch
BranchTrueFalseTotal
unless validate_id($nonce) 0 0 0
37  
38 try {
39 0 ▶ return $self->_make_request("/payment_methods/from_nonce/$nonce", "get", undef)->credit_card;
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 } catch {
41 0 ▶ confess "Payment method with nonce $nonce locked, consumed or not found";
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 }
43 0 }
44  
45 sub _make_request {
46 0 ▶ my($self, $path, $verb, $params) = @_;
Subroutine _make_request: not called CC=1 SCAR=6.9
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 1;
« Braintree/MerchantAccount/IndividualDetails.pm ↑ Summary Braintree/TransactionGateway.pm »