| 1 | # vim: sw=4 ts=4 ft=perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package # hide from pause | ||||||||||||||||||||||||||||||||||||||||||
| 4 | WebService::Braintree::CreditCardGateway; | ||||||||||||||||||||||||||||||||||||||||||
| 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 | extends 'WebService::Braintree::PaymentMethodGatewayBase'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 22 | with 'WebService::Braintree::Role::CollectionBuilder'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 22 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 22 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 22 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 22 | ▶ | use WebService::Braintree::Util qw(validate_id); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 22 | ▶ | use WebService::Braintree::Validations qw(verify_params credit_card_signature); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 22 | ▶ | use WebService::Braintree::_::CreditCard; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my ($self, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | confess "ArgumentError" unless verify_params($params, credit_card_signature); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | return $self->_create( | |||||||||||||||||||||||||||||||||||||||||
| 26 | "/payment_methods", 'post', {credit_card => $params}, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my ($self, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | confess "NotFoundError" unless validate_id($token); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $self->_make_request("/payment_methods/credit_card/$token", "delete", undef); | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my ($self, $token, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | confess "ArgumentError" unless verify_params($params, credit_card_signature); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | return $self->_update( | |||||||||||||||||||||||||||||||||||||||||
| 40 | "/payment_methods/credit_card/$token", "put", {credit_card => $params}, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | ▶ | sub find { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | my ($self, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | ▶ | confess "NotFoundError" unless validate_id($token); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | return $self->_find(credit_card => ( | |||||||||||||||||||||||||||||||||||||||||
| 48 | "/payment_methods/credit_card/${token}", 'get', undef, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub from_nonce { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_nonce: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my ($self, $nonce) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | confess "NotFoundError" unless validate_id($nonce); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | return $self->_make_request("/payment_methods/from_nonce/$nonce", "get", undef)->credit_card; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | confess "Payment method with nonce $nonce locked, consumed or not found"; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub expired { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expired: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | return $self->resource_collection({ | |||||||||||||||||||||||||||||||||||||||||
| 67 | ids_url => "/payment_methods/all/expired_ids", | ||||||||||||||||||||||||||||||||||||||||||
| 68 | obj_url => "/payment_methods/all/expired", | ||||||||||||||||||||||||||||||||||||||||||
| 69 | inflate => [qw/payment_methods credit_card _::CreditCard/], | ||||||||||||||||||||||||||||||||||||||||||
| 70 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub expiring_between { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expiring_between: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my ($self, $start, $end) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | confess "ArgumentError" unless $start && blessed($start) && $start->isa('DateTime'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$start and builtin::blessed($start) and $start->isa("DateTime")
$start and builtin::blessed($start)
MC/DC0%0/3
$start and builtin::blessed($start) and $start->isa("DateTime")
$start
builtin::blessed($start)
$start->isa("DateTime")
Truth table0%0/4
A and B and C
A= $startB= builtin::blessed($start)C= $start->isa("DateTime")
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | confess "ArgumentError" unless $end && blessed($end) && $end->isa('DateTime'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$end and builtin::blessed($end) and $end->isa("DateTime")
$end and builtin::blessed($end)
MC/DC0%0/3
$end and builtin::blessed($end) and $end->isa("DateTime")
$end
builtin::blessed($end)
$end->isa("DateTime")
Truth table0%0/4
A and B and C
A= $endB= builtin::blessed($end)C= $end->isa("DateTime")
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $start = $start->strftime('%m%Y'); | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $end = $end->strftime('%m%Y'); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $params = "start=${start}&end=${end}"; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | return $self->resource_collection({ | |||||||||||||||||||||||||||||||||||||||||
| 83 | ids_url => "/payment_methods/all/expiring_ids?${params}", | ||||||||||||||||||||||||||||||||||||||||||
| 84 | obj_url => "/payment_methods/all/expiring?${params}", | ||||||||||||||||||||||||||||||||||||||||||
| 85 | inflate => [qw/payment_methods credit_card _::CreditCard/], | ||||||||||||||||||||||||||||||||||||||||||
| 86 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 22 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 22 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 92 | __END__ | ||||||||||||||||||||||||||||||||||||||||||