| 1 | package Net::Braintree::CreditCardGateway; | ||||||||||
| 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::Validations qw(verify_params credit_card_signature); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Net::Braintree::Util qw(validate_id); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Net::Braintree::Result; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | has 'gateway' => (is => 'ro'); | |||||||||
| 10 | |||||||||||
| 11 | 0 | ▶ | sub create { | ||||||||
|
Subroutine
create: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 12 | 0 | my ($self, $params) = @_; | |||||||||
| 13 | 0 | ▶ | confess "ArgumentError" unless verify_params($params, credit_card_signature); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 0 | $self->_make_request("/payment_methods/", "post", {credit_card => $params}); | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 0 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 18 | 0 | my ($self, $token) = @_; | |||||||||
| 19 | 0 | $self->_make_request("/payment_methods/credit_card/$token", "delete", undef); | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | sub update { | ||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 23 | 0 | my ($self, $token, $params) = @_; | |||||||||
| 24 | 0 | ▶ | confess "ArgumentError" unless verify_params($params, credit_card_signature); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | $self->_make_request("/payment_methods/credit_card/$token", "put", {credit_card => $params}); | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub find { | ||||||||
|
Subroutine
find: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 29 | 0 | my ($self, $token) = @_; | |||||||||
| 30 | 0 | ▶ | confess "NotFoundError" unless validate_id($token); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | $self->_make_request("/payment_methods/credit_card/$token", "get", undef)->credit_card; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | sub from_nonce { | ||||||||
|
Subroutine
from_nonce: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 35 | 0 | my ($self, $nonce) = @_; | |||||||||
| 36 | 0 | ▶ | confess "NotFoundError" unless validate_id($nonce); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 39 | 0 | return $self->_make_request("/payment_methods/from_nonce/$nonce", "get", undef)->credit_card; | |||||||||
| 40 | 0 | ▶ | } catch { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 41 | 0 | confess "Payment method with nonce $nonce locked, consumed or not found"; | |||||||||
| 42 | } | ||||||||||
| 43 | 0 | } | |||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | sub _make_request { | ||||||||
|
Subroutine
_make_request: not called CC=1 SCAR=6.9
| |||||||||||
| 46 | 0 | my($self, $path, $verb, $params) = @_; | |||||||||
| 47 | 0 | my $response = $self->gateway->http->$verb($path, $params); | |||||||||
| 48 | 0 | my $result = Net::Braintree::Result->new(response => $response); | |||||||||
| 49 | 0 | return $result; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 1 | 1; | |||||||||