Braintree/TransactionGateway.pm

filter: Statementstmt 27.4% 17 / 62 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 23.8% 5 / 21 Podpod 0.0% 0 / 13 totaltotal 20.7% 22 / 106 CC 6 SCAR 12.1
CC
6
Cov
24%
create
6.0
find
6.0
clone_transaction
6.0
CRAP 3.3
« Braintree/CreditCardGateway.pm ↑ Summary Braintree/CustomerGateway.pm »
1 package Net::Braintree::TransactionGateway;
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::Util qw(validate_id);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Net::Braintree::Validations qw(verify_params transaction_signature clone_transaction_signature transaction_search_results_signature);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Net::Braintree::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 has 'gateway' => (is => 'ro');
9  
10 sub create {
11 0 ▶ my ($self, $params) = @_;
Subroutine create: not called CC=2 SCAR=17.9
Pod undocumented
12 0 ▶ confess "ArgumentError" unless verify_params($params, transaction_signature);
Branch: 1 branch
BranchTrueFalseTotal
unless verify_params($params, transaction_signature()) 0 0 0
13 0 $self->_make_request("/transactions/", "post", {transaction => $params});
14 }
15  
16 sub find {
17 0 ▶ my ($self, $id) = @_;
Subroutine find: not called CC=2 SCAR=17.9
Pod undocumented
18 0 ▶ confess "NotFoundError" unless validate_id($id);
Branch: 1 branch
BranchTrueFalseTotal
unless validate_id($id) 0 0 0
19 0 $self->_make_request("/transactions/$id", "get", undef);
20 }
21  
22 sub retry_subscription_charge {
23 0 ▶ my ($self, $subscription_id, $amount) = @_;
Subroutine retry_subscription_charge: not called CC=1 SCAR=6.9
Pod undocumented
24 0 my $params = {
25 subscription_id => $subscription_id,
26 amount => $amount,
27 type => "sale"
28 };
29  
30 0 $self->create($params);
31 }
32  
33 sub submit_for_settlement {
34 0 ▶ my ($self, $id, $params) = @_;
Subroutine submit_for_settlement: not called CC=1 SCAR=6.9
Pod undocumented
35 0 $self->_make_request("/transactions/$id/submit_for_settlement", "put", {transaction => $params});
36 }
37  
38 sub void {
39 0 ▶ my ($self, $id) = @_;
Subroutine void: not called CC=1 SCAR=6.9
Pod undocumented
40 0 $self->_make_request("/transactions/$id/void", "put", undef);
41 }
42  
43 sub refund {
44 0 ▶ my ($self, $id, $params) = @_;
Subroutine refund: not called CC=1 SCAR=6.9
Pod undocumented
45 0 $self->_make_request("/transactions/$id/refund", "post", {transaction => $params});
46 }
47  
48 sub clone_transaction {
49 0 ▶ my ($self, $id, $params) = @_;
Subroutine clone_transaction: not called CC=2 SCAR=17.9
Pod undocumented
50 0 ▶ confess "ArgumentError" unless verify_params($params, clone_transaction_signature);
Branch: 1 branch
BranchTrueFalseTotal
unless verify_params($params, clone_transaction_signature()) 0 0 0
51 0 $self->_make_request("/transactions/$id/clone", "post", {transaction_clone => $params});
52 }
53  
54 sub search {
55 0 ▶ my ($self, $block) = @_;
Subroutine search: not called CC=2 SCAR=17.9
Pod undocumented
56 0 my $search = Net::Braintree::TransactionSearch->new;
57 0 my $params = $block->($search)->to_hash;
58 0 my $response = $self->gateway->http->post("/transactions/advanced_search_ids", {search => $params});
59 0 ▶ confess "DownForMaintenanceError" unless (verify_params($response, transaction_search_results_signature));
Branch: 1 branch
BranchTrueFalseTotal
unless verify_params($response, transaction_search_results_signature()) 0 0 0
60 return Net::Braintree::ResourceCollection->new()->init($response, sub {
61 0 ▶ $self->fetch_transactions($search, shift);
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 0 });
63 }
64  
65 sub hold_in_escrow {
66 0 ▶ my ($self, $id) = @_;
Subroutine hold_in_escrow: not called CC=1 SCAR=6.9
Pod undocumented
67 0 $self->_make_request("/transactions/$id/hold_in_escrow", "put", undef);
68 }
69  
70 sub release_from_escrow {
71 0 ▶ my ($self, $id) = @_;
Subroutine release_from_escrow: not called CC=1 SCAR=6.9
Pod undocumented
72 0 $self->_make_request("/transactions/$id/release_from_escrow", "put", undef);
73 }
74  
75 sub cancel_release {
76 0 ▶ my ($self, $id) = @_;
Subroutine cancel_release: not called CC=1 SCAR=6.9
Pod undocumented
77 0 $self->_make_request("/transactions/$id/cancel_release", "put", undef);
78 }
79  
80 sub all {
81 0 ▶ my $self = shift;
Subroutine all: not called CC=1 SCAR=6.9
Pod undocumented
82 0 my $response = $self->gateway->http->post("/transactions/advanced_search_ids");
83 return Net::Braintree::ResourceCollection->new()->init($response, sub {
84 0 ▶ $self->fetch_transactions(Net::Braintree::TransactionSearch->new, shift);
Subroutine __ANON__: not called CC=1 SCAR=6.9
85 0 });
86 }
87  
88 sub _make_request {
89 0 ▶ my($self, $path, $verb, $params) = @_;
Subroutine _make_request: not called CC=1 SCAR=6.9
90 0 my $response = $self->gateway->http->$verb($path, $params);
91 0 return Net::Braintree::Result->new(response => $response);
92 }
93  
94 sub fetch_transactions {
95 0 ▶ my ($self, $search, $ids) = @_;
Subroutine fetch_transactions: not called CC=2 SCAR=17.9
Pod undocumented
96 0 $search->ids->in($ids);
97 0 ▶ return [] if scalar @{$ids} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$ids;} == 0 0 0 0
98 0 my $response = $self->gateway->http->post("/transactions/advanced_search/", {search => $search->to_hash});
99 0 my $attrs = $response->{'credit_card_transactions'}->{'transaction'};
100 0 return to_instance_array($attrs, "Net::Braintree::Transaction");
101 }
102  
103 1 1;
« Braintree/CreditCardGateway.pm ↑ Summary Braintree/CustomerGateway.pm »