« lib/WebService/Braintree/TransactionLineItemGateway.pm
↑ Summary
lib/WebService/Braintree/DisputeGateway.pm »
| 1 | # vim: sw=4 ts=4 ft=perl | ||||||||||||||
| 2 | |||||||||||||||
| 3 | package # hide from pause | ||||||||||||||
| 4 | WebService::Braintree::PaymentMethodGateway; | ||||||||||||||
| 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 | |||||||||||||||
| 12 | 22 | ▶ | use Carp qw(confess); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | |||||||||||||||
| 14 | 22 | ▶ | use WebService::Braintree::Util qw( | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | hash_to_query_string | ||||||||||||||
| 16 | validate_id | ||||||||||||||
| 17 | 22 | ); | |||||||||||||
| 18 | 22 | ▶ | use WebService::Braintree::Validations qw(verify_params address_signature); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | |||||||||||||||
| 20 | 22 | ▶ | use WebService::Braintree::PaymentMethodResult; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 21 | |||||||||||||||
| 22 | 0 | ▶ | sub create { | ||||||||||||
|
Subroutine
create: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 23 | 0 | my ($self, $params) = @_; | |||||||||||||
| 24 | 0 | ▶ | confess "ArgumentError" unless verify_params($params, _signature_for('create')); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 25 | 0 | return $self->_create( | |||||||||||||
| 26 | "/payment_methods", 'post', {payment_method => $params}, | ||||||||||||||
| 27 | ); | ||||||||||||||
| 28 | } | ||||||||||||||
| 29 | |||||||||||||||
| 30 | 0 | ▶ | sub update { | ||||||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 31 | 0 | my ($self, $token, $params) = @_; | |||||||||||||
| 32 | 0 | ▶ | confess "ArgumentError" unless verify_params($params, _signature_for('update')); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 33 | 0 | return $self->_update( | |||||||||||||
| 34 | "/payment_methods/any/" . $token, "put", {payment_method => $params}, | ||||||||||||||
| 35 | ); | ||||||||||||||
| 36 | } | ||||||||||||||
| 37 | |||||||||||||||
| 38 | 0 | ▶ | sub find { | ||||||||||||
|
Subroutine
find: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 39 | 0 | my ($self, $token) = @_; | |||||||||||||
| 40 | 0 | ▶ | confess "NotFoundError" unless validate_id($token); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 41 | 0 | return $self->_find(payment_method => ( | |||||||||||||
| 42 | "/payment_methods/any/${token}", 'get', undef, | ||||||||||||||
| 43 | )); | ||||||||||||||
| 44 | } | ||||||||||||||
| 45 | |||||||||||||||
| 46 | 0 | ▶ | sub delete { | ||||||||||||
|
Subroutine
delete: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 47 | 0 | my ($self, $token, $params) = @_; | |||||||||||||
| 48 | 0 | ▶ | confess "NotFoundError" unless validate_id($token); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 49 | 0 | my $query = ''; | |||||||||||||
| 50 | 0 | ▶ | if ($params) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 51 | 0 | ▶ | confess "ArgumentError" unless verify_params($params, { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 52 | revoke_all_grants => 1, | ||||||||||||||
| 53 | }); | ||||||||||||||
| 54 | 0 | $query = '?' . hash_to_query_string($params); | |||||||||||||
| 55 | } | ||||||||||||||
| 56 | 0 | $self->_make_request("/payment_methods/any/${token}${query}", 'delete'); | |||||||||||||
| 57 | } | ||||||||||||||
| 58 | |||||||||||||||
| 59 | 0 | ▶ | sub grant { | ||||||||||||
|
Subroutine
grant: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 60 | 0 | my ($self, $token, $params) = @_; | |||||||||||||
| 61 | |||||||||||||||
| 62 | 0 | ▶ | confess "NotFoundError" unless validate_id($token); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 63 | #confess "ArgumentError" unless verify_params($params, { | ||||||||||||||
| 64 | # revoke_all_grants => 1, | ||||||||||||||
| 65 | #}); | ||||||||||||||
| 66 | |||||||||||||||
| 67 | 0 | $self->_make_request("/payment_methods/grant", 'post', {payment_method => { %$params, shared_payment_method_token => $token}}); | |||||||||||||
| 68 | } | ||||||||||||||
| 69 | |||||||||||||||
| 70 | 0 | ▶ | sub revoke { | ||||||||||||
|
Subroutine
revoke: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 71 | 0 | my ($self, $token) = @_; | |||||||||||||
| 72 | 0 | ▶ | confess "NotFoundError" unless validate_id($token); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 73 | 0 | $self->_make_request("/payment_methods/revoke", 'post', {payment_method => { shared_payment_method_token => $token}}); | |||||||||||||
| 74 | } | ||||||||||||||
| 75 | |||||||||||||||
| 76 | 0 | ▶ | sub _signature_for { | ||||||||||||
|
Subroutine
_signature_for: not called CC=3 SCAR=24.8
| |||||||||||||||
| 77 | 0 | my ($type) = @_; | |||||||||||||
| 78 | |||||||||||||||
| 79 | 0 | my $signature = { | |||||||||||||
| 80 | billing_address => address_signature(), | ||||||||||||||
| 81 | billing_address_id => 1, | ||||||||||||||
| 82 | cardholder_name => 1, | ||||||||||||||
| 83 | cvv => 1, | ||||||||||||||
| 84 | device_session_id => 1, | ||||||||||||||
| 85 | expiration_date => 1, | ||||||||||||||
| 86 | expiration_month => 1, | ||||||||||||||
| 87 | expiration_year => 1, | ||||||||||||||
| 88 | number => 1, | ||||||||||||||
| 89 | token => 1, | ||||||||||||||
| 90 | venmo_sdk_payment_method_code => 1, | ||||||||||||||
| 91 | device_data => 1, | ||||||||||||||
| 92 | fraud_merchant_id => 1, | ||||||||||||||
| 93 | payment_method_nonce => 1, | ||||||||||||||
| 94 | options => { | ||||||||||||||
| 95 | make_default => 1, | ||||||||||||||
| 96 | verification_merchant_account_id => 1, | ||||||||||||||
| 97 | verify_card => 1, | ||||||||||||||
| 98 | venmo_sdk_session => 1, | ||||||||||||||
| 99 | verification_amount => 1, | ||||||||||||||
| 100 | paypal => { | ||||||||||||||
| 101 | payee_email => 1, | ||||||||||||||
| 102 | order_id => 1, | ||||||||||||||
| 103 | custom_field => 1, | ||||||||||||||
| 104 | description => 1, | ||||||||||||||
| 105 | amount => 1, | ||||||||||||||
| 106 | shipping => address_signature(), | ||||||||||||||
| 107 | }, | ||||||||||||||
| 108 | }, | ||||||||||||||
| 109 | }; | ||||||||||||||
| 110 | |||||||||||||||
| 111 | 0 | ▶ | if ($type eq 'create') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 112 | $signature = { | ||||||||||||||
| 113 | 0 | %{$signature}, | |||||||||||||
| 114 | customer_id => 1, | ||||||||||||||
| 115 | paypal_refresh_token => 1, | ||||||||||||||
| 116 | paypal_vault_without_upgrade => 1, | ||||||||||||||
| 117 | }; | ||||||||||||||
| 118 | 0 | $signature->{options}{fail_on_duplicate_payment_method} = 1; | |||||||||||||
| 119 | } | ||||||||||||||
| 120 | elsif ($type eq 'update') { | ||||||||||||||
| 121 | 0 | $signature->{billing_address}{update_existing} = 1; | |||||||||||||
| 122 | } | ||||||||||||||
| 123 | |||||||||||||||
| 124 | 0 | return $signature; | |||||||||||||
| 125 | } | ||||||||||||||
| 126 | |||||||||||||||
| 127 | 22 | __PACKAGE__->meta->make_immutable; | |||||||||||||
| 128 | |||||||||||||||
| 129 | 22 | 1; | |||||||||||||
| 130 | __END__ | ||||||||||||||