« lib/WebService/Braintree/Role/CollectionBuilder.pm
↑ Summary
lib/WebService/Braintree/TransactionGateway.pm »
| 1 | # vim: sw=4 ts=4 ft=perl | ||||||||||
| 2 | |||||||||||
| 3 | package WebService::Braintree::PaymentMethodResult; | ||||||||||
| 4 | 22 | $WebService::Braintree::PaymentMethodResult::VERSION = '1.7'; | |||||||||
| 5 | 22 | ▶ | use 5.010_001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 22 | ▶ | use strictures 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | WebService::Braintree::PaymentMethodResult | ||||||||||
| 11 | |||||||||||
| 12 | =head1 PURPOSE | ||||||||||
| 13 | |||||||||||
| 14 | This class represents a result from the Braintree API with no validation errors. | ||||||||||
| 15 | It is specifically used for results from PaymentMethod interfaces. | ||||||||||
| 16 | |||||||||||
| 17 | This class is a sibling class to L<WebService::Braintree::Result>. | ||||||||||
| 18 | |||||||||||
| 19 | =cut | ||||||||||
| 20 | |||||||||||
| 21 | 22 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | 22 | ▶ | use WebService::Braintree::Types qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | AmexExpressCheckoutCard | ||||||||||
| 25 | AndroidPayCard | ||||||||||
| 26 | ApplePayCard | ||||||||||
| 27 | CoinbaseAccount | ||||||||||
| 28 | CreditCard | ||||||||||
| 29 | EuropeBankAccount | ||||||||||
| 30 | MasterpassCard | ||||||||||
| 31 | PaymentMethodNonce | ||||||||||
| 32 | PayPalAccount | ||||||||||
| 33 | UsBankAccount | ||||||||||
| 34 | VenmoAccount | ||||||||||
| 35 | VisaCheckoutCard | ||||||||||
| 36 | UnknownPaymentMethod | ||||||||||
| 37 | 22 | ); | |||||||||
| 38 | |||||||||||
| 39 | =head1 METHODS | ||||||||||
| 40 | |||||||||||
| 41 | =cut | ||||||||||
| 42 | |||||||||||
| 43 | =head2 Possible objects | ||||||||||
| 44 | |||||||||||
| 45 | These are the possible objects that are returnable by this object. If this | ||||||||||
| 46 | result does not have anything for that method, it will return undef. | ||||||||||
| 47 | |||||||||||
| 48 | =over 4 | ||||||||||
| 49 | |||||||||||
| 50 | =item L<amex_express_checkout_card|WebService::Braintree::_::AmexExpressCheckoutCard> | ||||||||||
| 51 | |||||||||||
| 52 | =item L<android_pay_card|WebService::Braintree::_::AndroidPayCard> | ||||||||||
| 53 | |||||||||||
| 54 | =item L<apple_pay_card|WebService::Braintree::_::ApplePayCard> | ||||||||||
| 55 | |||||||||||
| 56 | =item L<coinbase_account|WebService::Braintree::_::CoinbaseAccount> | ||||||||||
| 57 | |||||||||||
| 58 | =item L<credit_card|WebService::Braintree::_::CreditCard> | ||||||||||
| 59 | |||||||||||
| 60 | =item L<europe_bank_account|WebService::Braintree::_::EuropeBankAccount> | ||||||||||
| 61 | |||||||||||
| 62 | =item L<masterpass_card|WebService::Braintree::_::MasterpassCard> | ||||||||||
| 63 | |||||||||||
| 64 | =item L<payment_method_nonce|WebService::Braintree::_::PaymentMethodNonce> | ||||||||||
| 65 | |||||||||||
| 66 | =item L<paypal_account|WebService::Braintree::_::PayPalAccount> | ||||||||||
| 67 | |||||||||||
| 68 | =item L<us_bank_account|WebService::Braintree::_::UsBankAccount> | ||||||||||
| 69 | |||||||||||
| 70 | =item L<venmo_account|WebService::Braintree::_::VenmoAccount> | ||||||||||
| 71 | |||||||||||
| 72 | =item L<visa_checkout_card|WebService::Braintree::_::VisaCheckoutCard> | ||||||||||
| 73 | |||||||||||
| 74 | =item L<unknown|WebService::Braintree::_::UnknownPaymentMethod> | ||||||||||
| 75 | |||||||||||
| 76 | If the response cannot match any of the other possible types, then the result | ||||||||||
| 77 | will be in the C<< unknown() >>. | ||||||||||
| 78 | |||||||||||
| 79 | =back | ||||||||||
| 80 | |||||||||||
| 81 | =cut | ||||||||||
| 82 | |||||||||||
| 83 | 22 | my %payment_methods = ( | |||||||||
| 84 | amex_express_checkout_card => AmexExpressCheckoutCard, | ||||||||||
| 85 | android_pay_card => AndroidPayCard, | ||||||||||
| 86 | apple_pay_card => ApplePayCard, | ||||||||||
| 87 | coinbase_account => CoinbaseAccount, | ||||||||||
| 88 | credit_card => CreditCard, | ||||||||||
| 89 | europe_bank_account => EuropeBankAccount, | ||||||||||
| 90 | masterpass_card => MasterpassCard, | ||||||||||
| 91 | payment_method_nonce => PaymentMethodNonce, | ||||||||||
| 92 | paypal_account => PayPalAccount, | ||||||||||
| 93 | us_bank_account => UsBankAccount, | ||||||||||
| 94 | venmo_account => VenmoAccount, | ||||||||||
| 95 | visa_checkout_card => VisaCheckoutCard, | ||||||||||
| 96 | unknown => UnknownPaymentMethod, | ||||||||||
| 97 | ); | ||||||||||
| 98 | |||||||||||
| 99 | 22 | ▶ | while (my ($method, $type) = each %payment_methods) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 100 | 286 | has $method => ( | |||||||||
| 101 | is => 'ro', | ||||||||||
| 102 | isa => $type, | ||||||||||
| 103 | coerce => 1, | ||||||||||
| 104 | ); | ||||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | 0 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 108 | 0 | my ($self, $attrs) = @_; | |||||||||
| 109 | |||||||||||
| 110 | 0 | my $have_item = 0; | |||||||||
| 111 | 0 | foreach my $attr (keys %payment_methods) { | |||||||||
| 112 | 0 | ▶ | if ($self->$attr) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 113 | 0 | $have_item = 1; | |||||||||
| 114 | 0 | last; | |||||||||
| 115 | } | ||||||||||
| 116 | } | ||||||||||
| 117 | |||||||||||
| 118 | 0 | ▶ | $self->unknown((values %$attrs)[0]) unless $have_item; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 119 | } | ||||||||||
| 120 | |||||||||||
| 121 | =head2 payment_method() | ||||||||||
| 122 | |||||||||||
| 123 | This will return the value encapsulated in this PaymentMethodResult. | ||||||||||
| 124 | |||||||||||
| 125 | =cut | ||||||||||
| 126 | |||||||||||
| 127 | 0 | ▶ | sub payment_method { | ||||||||
|
Subroutine
payment_method: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 128 | 0 | my $self = shift; | |||||||||
| 129 | |||||||||||
| 130 | 0 | foreach my $attr (keys %payment_methods) { | |||||||||
| 131 | 0 | ▶ | return $self->$attr if $self->$attr; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 132 | } | ||||||||||
| 133 | |||||||||||
| 134 | 0 | return; | |||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | =head2 is_success | ||||||||||
| 138 | |||||||||||
| 139 | This always returns true. | ||||||||||
| 140 | |||||||||||
| 141 | =cut | ||||||||||
| 142 | |||||||||||
| 143 | 0 | ▶ | sub is_success { 1 } | ||||||||
|
Subroutine
is_success: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 144 | |||||||||||
| 145 | 22 | __PACKAGE__->meta->make_immutable; | |||||||||
| 146 | |||||||||||
| 147 | 22 | 1; | |||||||||
| 148 | __END__ | ||||||||||