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 0 ▶sub create {
Subroutine create: not called CC=2 SCAR=17.9
Pod undocumented
11 0 my ($self, $params) = @_;
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 0 ▶sub find {
Subroutine find: not called CC=2 SCAR=17.9
Pod undocumented
17 0 my ($self, $id) = @_;
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 0 ▶sub retry_subscription_charge {
Subroutine retry_subscription_charge: not called CC=1 SCAR=6.9
Pod undocumented
23 0 my ($self, $subscription_id, $amount) = @_;
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 0 ▶sub submit_for_settlement {
Subroutine submit_for_settlement: not called CC=1 SCAR=6.9
Pod undocumented
34 0 my ($self, $id, $params) = @_;
35 0 $self->_make_request("/transactions/$id/submit_for_settlement", "put", {transaction => $params});
36 }
37  
38 0 ▶sub void {
Subroutine void: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my ($self, $id) = @_;
40 0 $self->_make_request("/transactions/$id/void", "put", undef);
41 }
42  
43 0 ▶sub refund {
Subroutine refund: not called CC=1 SCAR=6.9
Pod undocumented
44 0 my ($self, $id, $params) = @_;
45 0 $self->_make_request("/transactions/$id/refund", "post", {transaction => $params});
46 }
47  
48 0 ▶sub clone_transaction {
Subroutine clone_transaction: not called CC=2 SCAR=17.9
Pod undocumented
49 0 my ($self, $id, $params) = @_;
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 0 ▶sub search {
Subroutine search: not called CC=2 SCAR=17.9
Pod undocumented
55 0 my ($self, $block) = @_;
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 0 ▶ return Net::Braintree::ResourceCollection->new()->init($response, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 $self->fetch_transactions($search, shift);
62 0 });
63 }
64  
65 0 ▶sub hold_in_escrow {
Subroutine hold_in_escrow: not called CC=1 SCAR=6.9
Pod undocumented
66 0 my ($self, $id) = @_;
67 0 $self->_make_request("/transactions/$id/hold_in_escrow", "put", undef);
68 }
69  
70 0 ▶sub release_from_escrow {
Subroutine release_from_escrow: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my ($self, $id) = @_;
72 0 $self->_make_request("/transactions/$id/release_from_escrow", "put", undef);
73 }
74  
75 0 ▶sub cancel_release {
Subroutine cancel_release: not called CC=1 SCAR=6.9
Pod undocumented
76 0 my ($self, $id) = @_;
77 0 $self->_make_request("/transactions/$id/cancel_release", "put", undef);
78 }
79  
80 0 ▶sub all {
Subroutine all: not called CC=1 SCAR=6.9
Pod undocumented
81 0 my $self = shift;
82 0 my $response = $self->gateway->http->post("/transactions/advanced_search_ids");
83 0 ▶ return Net::Braintree::ResourceCollection->new()->init($response, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
84 0 $self->fetch_transactions(Net::Braintree::TransactionSearch->new, shift);
85 0 });
86 }
87  
88 0 ▶sub _make_request {
Subroutine _make_request: not called CC=1 SCAR=6.9
89 0 my($self, $path, $verb, $params) = @_;
90 0 my $response = $self->gateway->http->$verb($path, $params);
91 0 return Net::Braintree::Result->new(response => $response);
92 }
93  
94 0 ▶sub fetch_transactions {
Subroutine fetch_transactions: not called CC=2 SCAR=17.9
Pod undocumented
95 0 my ($self, $search, $ids) = @_;
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 »