« lib/WebService/Braintree/PaymentMethodResult.pm
↑ Summary
lib/WebService/Braintree/TransactionLineItemGateway.pm »
| 1 | # vim: sw=4 ts=4 ft=perl | ||||||||||||
| 2 | |||||||||||||
| 3 | package # hide from pause | ||||||||||||
| 4 | WebService::Braintree::TransactionGateway; | ||||||||||||
| 5 | |||||||||||||
| 6 | 22 | ▶ | use 5.010_001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 22 | ▶ | use strictures 1; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 22 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 22 | with 'WebService::Braintree::Role::MakeRequest'; | |||||||||||
| 11 | 22 | with 'WebService::Braintree::Role::CollectionBuilder'; | |||||||||||
| 12 | |||||||||||||
| 13 | 22 | ▶ | use Carp qw(confess); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | 22 | ▶ | use WebService::Braintree::Util qw(validate_id); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | 22 | ▶ | use WebService::Braintree::Validations qw( | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | verify_params transaction_signature clone_transaction_signature | ||||||||||||
| 18 | transaction_search_results_signature | ||||||||||||
| 19 | 22 | ); | |||||||||||
| 20 | |||||||||||||
| 21 | 22 | ▶ | use WebService::Braintree::_::Transaction; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 22 | ▶ | use WebService::Braintree::TransactionSearch; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | |||||||||||||
| 24 | 1 | ▶ | sub create { | ||||||||||
|
Subroutine
create: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||
| 25 | 1 | my ($self, $params) = @_; | |||||||||||
| 26 | 1 | ▶ | confess "ArgumentError" unless verify_params($params, transaction_signature); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 27 | 0 | $self->_make_request("/transactions/", "post", {transaction => $params}); | |||||||||||
| 28 | } | ||||||||||||
| 29 | |||||||||||||
| 30 | 1 | ▶ | sub sale { | ||||||||||
|
Subroutine
sale: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 31 | 1 | my ($self, $params) = @_; | |||||||||||
| 32 | 1 | ▶ | $params //= {}; | ||||||||||
|
Condition50%1/2
$params //= {}
MC/DC0%0/1
$params //= {}
$params
Truth table50%1/2
A
A= $params
| |||||||||||||
| 33 | 1 | $params->{type} = 'sale'; | |||||||||||
| 34 | 1 | $self->create($params); | |||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | 0 | ▶ | sub credit { | ||||||||||
|
Subroutine
credit: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 38 | 0 | my ($self, $params) = @_; | |||||||||||
| 39 | 0 | ▶ | $params //= {}; | ||||||||||
|
Condition0%0/2
$params //= {}
MC/DC0%0/1
$params //= {}
$params
Truth table0%0/2
A
A= $params
| |||||||||||||
| 40 | 0 | $params->{type} = 'credit'; | |||||||||||
| 41 | 0 | $self->create($params); | |||||||||||
| 42 | } | ||||||||||||
| 43 | |||||||||||||
| 44 | 2 | ▶ | sub find { | ||||||||||
|
Subroutine
find: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||
| 45 | 2 | my ($self, $id) = @_; | |||||||||||
| 46 | 2 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 47 | 0 | $self->_make_request("/transactions/$id", "get", undef); | |||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | 0 | ▶ | sub retry_subscription_charge { | ||||||||||
|
Subroutine
retry_subscription_charge: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 51 | 0 | my ($self, $id, $amount) = @_; | |||||||||||
| 52 | 0 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 53 | 0 | $self->create({ | |||||||||||
| 54 | subscription_id => $id, | ||||||||||||
| 55 | amount => $amount, | ||||||||||||
| 56 | type => "sale" | ||||||||||||
| 57 | }); | ||||||||||||
| 58 | } | ||||||||||||
| 59 | |||||||||||||
| 60 | 0 | ▶ | sub submit_for_settlement { | ||||||||||
|
Subroutine
submit_for_settlement: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||
| 61 | 0 | my ($self, $id, $amount, $params) = @_; | |||||||||||
| 62 | 0 | ▶ | $params //= {}; | ||||||||||
|
Condition0%0/2
$params //= {}
MC/DC0%0/1
$params //= {}
$params
Truth table0%0/2
A
A= $params
| |||||||||||||
| 63 | |||||||||||||
| 64 | 0 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 65 | 0 | ▶ | confess "ArgumentError" unless verify_params($params, { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 66 | order_id => 1, | ||||||||||||
| 67 | descriptor => { | ||||||||||||
| 68 | name => 1, | ||||||||||||
| 69 | phone => 1, | ||||||||||||
| 70 | url => 1, | ||||||||||||
| 71 | }, | ||||||||||||
| 72 | }); | ||||||||||||
| 73 | |||||||||||||
| 74 | 0 | $self->_make_request("/transactions/$id/submit_for_settlement", "put", { transaction => {%$params, amount => $amount}}); | |||||||||||
| 75 | } | ||||||||||||
| 76 | |||||||||||||
| 77 | 0 | ▶ | sub void { | ||||||||||
|
Subroutine
void: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 78 | 0 | my ($self, $id) = @_; | |||||||||||
| 79 | 0 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 80 | 0 | $self->_make_request("/transactions/$id/void", "put", undef); | |||||||||||
| 81 | } | ||||||||||||
| 82 | |||||||||||||
| 83 | 0 | ▶ | sub refund { | ||||||||||
|
Subroutine
refund: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||
| 84 | 0 | my ($self, $id, $params) = @_; | |||||||||||
| 85 | |||||||||||||
| 86 | 0 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 87 | 0 | ▶ | confess "ArgumentError" unless verify_params($params, { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 88 | amount => 1, | ||||||||||||
| 89 | order_id => 1, | ||||||||||||
| 90 | }); | ||||||||||||
| 91 | |||||||||||||
| 92 | 0 | $self->_make_request("/transactions/$id/refund", "post", {transaction => $params}); | |||||||||||
| 93 | } | ||||||||||||
| 94 | |||||||||||||
| 95 | 1 | ▶ | sub clone_transaction { | ||||||||||
|
Subroutine
clone_transaction: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||||
| 96 | 1 | my ($self, $id, $params) = @_; | |||||||||||
| 97 | 1 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 98 | 1 | ▶ | confess "ArgumentError" unless verify_params($params, clone_transaction_signature); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 99 | 0 | $self->_make_request("/transactions/$id/clone", "post", {transaction_clone => $params}); | |||||||||||
| 100 | } | ||||||||||||
| 101 | |||||||||||||
| 102 | 0 | ▶ | sub search { | ||||||||||
|
Subroutine
search: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 103 | 0 | my ($self, $block) = @_; | |||||||||||
| 104 | |||||||||||||
| 105 | return $self->resource_collection({ | ||||||||||||
| 106 | ids_url => "/transactions/advanced_search_ids", | ||||||||||||
| 107 | 0 | ▶ | post_ids => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||
| 108 | 0 | my $response = shift; | |||||||||||
| 109 | 0 | ▶ | confess "DownForMaintenanceError" unless | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 110 | verify_params($response, transaction_search_results_signature); | ||||||||||||
| 111 | }, | ||||||||||||
| 112 | 0 | obj_url => "/transactions/advanced_search", | |||||||||||
| 113 | inflate => [qw/credit_card_transactions transaction _::Transaction/], | ||||||||||||
| 114 | search => $block->(WebService::Braintree::TransactionSearch->new), | ||||||||||||
| 115 | }); | ||||||||||||
| 116 | } | ||||||||||||
| 117 | |||||||||||||
| 118 | 0 | ▶ | sub hold_in_escrow { | ||||||||||
|
Subroutine
hold_in_escrow: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 119 | 0 | my ($self, $id) = @_; | |||||||||||
| 120 | 0 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 121 | 0 | $self->_make_request("/transactions/$id/hold_in_escrow", "put", undef); | |||||||||||
| 122 | } | ||||||||||||
| 123 | |||||||||||||
| 124 | 0 | ▶ | sub release_from_escrow { | ||||||||||
|
Subroutine
release_from_escrow: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 125 | 0 | my ($self, $id) = @_; | |||||||||||
| 126 | 0 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 127 | 0 | $self->_make_request("/transactions/$id/release_from_escrow", "put", undef); | |||||||||||
| 128 | } | ||||||||||||
| 129 | |||||||||||||
| 130 | 0 | ▶ | sub cancel_release { | ||||||||||
|
Subroutine
cancel_release: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 131 | 0 | my ($self, $id) = @_; | |||||||||||
| 132 | 0 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 133 | 0 | $self->_make_request("/transactions/$id/cancel_release", "put", undef); | |||||||||||
| 134 | } | ||||||||||||
| 135 | |||||||||||||
| 136 | 0 | ▶ | sub update_details { | ||||||||||
|
Subroutine
update_details: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||
| 137 | 0 | my ($self, $id, $params) = @_; | |||||||||||
| 138 | 0 | ▶ | $params //= {}; | ||||||||||
|
Condition0%0/2
$params //= {}
MC/DC0%0/1
$params //= {}
$params
Truth table0%0/2
A
A= $params
| |||||||||||||
| 139 | |||||||||||||
| 140 | 0 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 141 | 0 | ▶ | confess "ArgumentError" unless verify_params($params, { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 142 | amount => 1, | ||||||||||||
| 143 | order_id => 1, | ||||||||||||
| 144 | descriptor => { | ||||||||||||
| 145 | name => 1, | ||||||||||||
| 146 | phone => 1, | ||||||||||||
| 147 | url => 1, | ||||||||||||
| 148 | }, | ||||||||||||
| 149 | }); | ||||||||||||
| 150 | |||||||||||||
| 151 | 0 | $self->_make_request("/transactions/$id/update_details", "put", { transaction => $params }); | |||||||||||
| 152 | } | ||||||||||||
| 153 | |||||||||||||
| 154 | 0 | ▶ | sub submit_for_partial_settlement { | ||||||||||
|
Subroutine
submit_for_partial_settlement: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||
| 155 | 0 | my ($self, $id, $amount, $params) = @_; | |||||||||||
| 156 | 0 | ▶ | $params //= {}; | ||||||||||
|
Condition0%0/2
$params //= {}
MC/DC0%0/1
$params //= {}
$params
Truth table0%0/2
A
A= $params
| |||||||||||||
| 157 | |||||||||||||
| 158 | 0 | ▶ | confess "NotFoundError" unless validate_id($id); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 159 | 0 | ▶ | confess "ArgumentError" unless verify_params($params, { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 160 | order_id => 1, | ||||||||||||
| 161 | descriptor => { | ||||||||||||
| 162 | name => 1, | ||||||||||||
| 163 | phone => 1, | ||||||||||||
| 164 | url => 1, | ||||||||||||
| 165 | }, | ||||||||||||
| 166 | }); | ||||||||||||
| 167 | |||||||||||||
| 168 | 0 | $self->_make_request("/transactions/$id/submit_for_partial_settlement", "post", { transaction => {%$params, amount => $amount}}); | |||||||||||
| 169 | } | ||||||||||||
| 170 | |||||||||||||
| 171 | 0 | ▶ | sub all { | ||||||||||
|
Subroutine
all: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 172 | 0 | my $self = shift; | |||||||||||
| 173 | |||||||||||||
| 174 | 0 | return $self->resource_collection({ | |||||||||||
| 175 | ids_url => "/transactions/advanced_search_ids", | ||||||||||||
| 176 | obj_url => "/transactions/advanced_search", | ||||||||||||
| 177 | inflate => [qw/credit_card_transactions transaction _::Transaction/], | ||||||||||||
| 178 | }); | ||||||||||||
| 179 | } | ||||||||||||
| 180 | |||||||||||||
| 181 | 22 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 182 | |||||||||||||
| 183 | 22 | 1; | |||||||||||
| 184 | __END__ | ||||||||||||