« lib/WebService/Braintree/_/VisaCheckoutCard.pm
↑ Summary
lib/WebService/Braintree/_/CreditCard.pm »
| 1 | # vim: sw=4 ts=4 ft=perl | ||||||||||
| 2 | |||||||||||
| 3 | package # hide from pause | ||||||||||
| 4 | WebService::Braintree::ClientTokenGateway; | ||||||||||
| 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 | |||||||||||
| 12 | 22 | ▶ | use Carp qw(confess); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 22 | ▶ | use WebService::Braintree::Validations qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | verify_params | ||||||||||
| 16 | client_token_signature_with_customer_id | ||||||||||
| 17 | client_token_signature_without_customer_id | ||||||||||
| 18 | 22 | ); | |||||||||
| 19 | |||||||||||
| 20 | 4 | ▶ | sub generate { | ||||||||
|
Subroutine
generate: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||
| 21 | 4 | my ($self, $params) = @_; | |||||||||
| 22 | 4 | ▶ | if ($params) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 4 | ▶ | confess "ArgumentError" unless $self->_conditionally_verify_params($params); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | $params = {client_token => $params}; | |||||||||
| 25 | } | ||||||||||
| 26 | 0 | my $result = $self->_make_raw_request("/client_token", 'post', $params); | |||||||||
| 27 | 0 | return $result->{client_token}{value}; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | |||||||||||
| 31 | 4 | ▶ | sub _conditionally_verify_params { | ||||||||
|
Subroutine
_conditionally_verify_params: called CC=2 SCAR=7.6
| |||||||||||
| 32 | 4 | my ($self, $params) = @_; | |||||||||
| 33 | |||||||||||
| 34 | 4 | ▶ | if (exists $params->{"customer_id"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | verify_params($params, client_token_signature_with_customer_id); | |||||||||
| 36 | } else { | ||||||||||
| 37 | 4 | verify_params($params, client_token_signature_without_customer_id); | |||||||||
| 38 | } | ||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 22 | __PACKAGE__->meta->make_immutable; | |||||||||
| 42 | |||||||||||
| 43 | 22 | 1; | |||||||||
| 44 | __END__ | ||||||||||