lib/WebService/Braintree/Transaction.pm

filter: Statementstmt 57.8% 33 / 57 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 50.0% 11 / 22 Podpod 100% 14 / 14 totaltotal 55.7% 58 / 104 CC 5 SCAR 10.3
CC
5
Cov
51%
submit_for_settlement
6.0
refund
6.0
update_details
6.0
CRAP 2.8
« lib/WebService/Braintree/UsBankAccount.pm ↑ Summary lib/WebService/Braintree/Customer.pm »
1 # vim: sw=4 ts=4 ft=perl
2  
3 package WebService::Braintree::Transaction;
4 22 $WebService::Braintree::Transaction::VERSION = '1.7';
5 22 ▶use 5.010_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 22 ▶use strictures 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 WebService::Braintree::Transaction
11  
12 =head1 PURPOSE
13  
14 This class generates and manages transactions.
15  
16 =cut
17  
18 22 ▶use WebService::Braintree::Transaction::CreatedUsing;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 22 ▶use WebService::Braintree::Transaction::EscrowStatus;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 22 ▶use WebService::Braintree::Transaction::Source;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 22 ▶use WebService::Braintree::Transaction::Status;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 22 ▶use WebService::Braintree::Transaction::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 22 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 22 with 'WebService::Braintree::Role::Interface';
27  
28 =head1 CLASS METHODS
29  
30 =head2 sale()
31  
32 This takes a hashref of parameters and returns the transaction created.
33  
34 =cut
35  
36 1 ▶sub sale {
Subroutine sale: called CC=1 SCAR=0.0
Pod documented
37 1 my ($class, $params) = @_;
38 1 $class->gateway->transaction->sale($params);
39 }
40  
41 =head2 credit()
42  
43 This takes a hashref of parameters and returns the transaction created.
44  
45 =cut
46  
47 0 ▶sub credit {
Subroutine credit: not called CC=1 SCAR=6.9
Pod documented
48 0 my ($class, $params) = @_;
49 0 $class->gateway->transaction->credit($params);
50 }
51  
52 =head2 find()
53  
54 This takes an id and returns the transaction (if it exists).
55  
56 =cut
57  
58 2 ▶sub find {
Subroutine find: called CC=1 SCAR=0.0
Pod documented
59 2 my ($class, $id) = @_;
60 2 $class->gateway->transaction->find($id);
61 }
62  
63 =head2 clone_transaction()
64  
65 This takes an id and a hashref of parameters and clones the transaction (if it
66 exists) with the parameters as overrides.
67  
68 =cut
69  
70 1 ▶sub clone_transaction {
Subroutine clone_transaction: called CC=1 SCAR=0.0
Pod documented
71 1 my ($class, $id, $params) = @_;
72 1 $class->gateway->transaction->clone_transaction($id, $params);
73 }
74  
75 =head2 void()
76  
77 This takes an id and voids the transaction (if it exists).
78  
79 =cut
80  
81 0 ▶sub void {
Subroutine void: not called CC=1 SCAR=6.9
Pod documented
82 0 my ($class, $id) = @_;
83 0 $class->gateway->transaction->void($id);
84 }
85  
86 =head2 submit_for_settlement()
87  
88 This takes an id, an optional amount, amount, and optional parameters and submits the transaction
89 for settlement.
90  
91 =cut
92  
93 0 ▶sub submit_for_settlement {
Subroutine submit_for_settlement: not called CC=2 SCAR=17.9
Pod documented
94 0 my ($class, $id, $amount, $params) = @_;
95 0 ▶ $class->gateway->transaction->submit_for_settlement($id, $amount, ($params // {}));
Condition0%0/2
$params // {}
l!l
00
MC/DC0%0/1
$params // {}
$params
Truth table0%0/2
A
A= $params
Aresult
11
00
96 }
97  
98 =head2 refund()
99  
100 This takes an id and an optional amount and refunds the transaction (if it
101 exists).
102  
103 =cut
104  
105 0 ▶sub refund {
Subroutine refund: not called CC=2 SCAR=17.9
Pod documented
106 0 my ($class, $id, $amount) = @_;
107 0 my $params = {};
108 0 ▶ $params->{'amount'} = $amount if $amount;
Branch: 1 branch
BranchTrueFalseTotal
if $amount 0 0 0
109 0 $class->gateway->transaction->refund($id, $params);
110 }
111  
112 =head2 hold_in_escrow()
113  
114 This takes an id and holds the transaction (if it exists) in escrow.
115  
116 =cut
117  
118 0 ▶sub hold_in_escrow {
Subroutine hold_in_escrow: not called CC=1 SCAR=6.9
Pod documented
119 0 my ($class, $id) = @_;
120 0 $class->gateway->transaction->hold_in_escrow($id);
121 }
122  
123 =head2 release_from_escrow()
124  
125 This takes an id and releases the transaction (if it exists) from escrow.
126  
127 =cut
128  
129 0 ▶sub release_from_escrow {
Subroutine release_from_escrow: not called CC=1 SCAR=6.9
Pod documented
130 0 my ($class, $id) = @_;
131 0 $class->gateway->transaction->release_from_escrow($id);
132 }
133  
134 =head2 cancel_release()
135  
136 This takes an id and cancels the release of the transaction (if it exists).
137  
138 =cut
139  
140 0 ▶sub cancel_release {
Subroutine cancel_release: not called CC=1 SCAR=6.9
Pod documented
141 0 my ($class, $id) = @_;
142 0 $class->gateway->transaction->cancel_release($id);
143 }
144  
145 =head2 update_details()
146  
147 This takes an id and updates the transaction details with the provided
148 parameters. This requires the transaction to be in submitted_for_settlement
149 status.
150  
151 =cut
152  
153 0 ▶sub update_details {
Subroutine update_details: not called CC=2 SCAR=17.9
Pod documented
154 0 my ($class, $id, $params) = @_;
155 0 ▶ $class->gateway->transaction->update_details($id, ($params // {}));
Condition0%0/2
$params // {}
l!l
00
MC/DC0%0/1
$params // {}
$params
Truth table0%0/2
A
A= $params
Aresult
11
00
156 }
157  
158 =head2 submit_for_partial_settlement()
159  
160 This takes an id, amount, and optional parameters and submits the transaction
161 for partial settlement.
162  
163 =cut
164  
165 0 ▶sub submit_for_partial_settlement {
Subroutine submit_for_partial_settlement: not called CC=2 SCAR=17.9
Pod documented
166 0 my ($class, $id, $amount, $params) = @_;
167 0 ▶ $class->gateway->transaction->submit_for_partial_settlement($id, $amount, ($params // {}));
Condition0%0/2
$params // {}
l!l
00
MC/DC0%0/1
$params // {}
$params
Truth table0%0/2
A
A= $params
Aresult
11
00
168 }
169  
170 =head2 search()
171  
172 This takes a subref which is used to set the search parameters and returns a
173 transaction object.
174  
175 Please see L<Searching|WebService::Braintree/SEARCHING> for more information on
176 the subref and how it works.
177  
178 =cut
179  
180 0 ▶sub search {
Subroutine search: not called CC=1 SCAR=6.9
Pod documented
181 0 my ($class, $block) = @_;
182 0 $class->gateway->transaction->search($block);
183 }
184  
185 =head2 all()
186  
187 This returns all the transactions.
188  
189 =cut
190  
191 0 ▶sub all {
Subroutine all: not called CC=1 SCAR=6.9
Pod documented
192 0 my $class = shift;
193 0 $class->gateway->transaction->all;
194 }
195  
196 22 __PACKAGE__->meta->make_immutable;
197  
198 22 1;
199 __END__
« lib/WebService/Braintree/UsBankAccount.pm ↑ Summary lib/WebService/Braintree/Customer.pm »