Braintree\PaymentMethodGateway::find PHP Method

find() public method

find a PaymentMethod by token
public find ( string $token ) : CreditCard | braintree\PayPalAccount
$token string payment method unique id
return CreditCard | braintree\PayPalAccount
    public function find($token)
    {
        $this->_validateId($token);
        try {
            $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token;
            $response = $this->_http->get($path);
            if (isset($response['creditCard'])) {
                return CreditCard::factory($response['creditCard']);
            } else {
                if (isset($response['paypalAccount'])) {
                    return PayPalAccount::factory($response['paypalAccount']);
                } else {
                    if (isset($response['coinbaseAccount'])) {
                        return CoinbaseAccount::factory($response['coinbaseAccount']);
                    } else {
                        if (isset($response['applePayCard'])) {
                            return ApplePayCard::factory($response['applePayCard']);
                        } else {
                            if (isset($response['androidPayCard'])) {
                                return AndroidPayCard::factory($response['androidPayCard']);
                            } else {
                                if (isset($response['amexExpressCheckoutCard'])) {
                                    return AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']);
                                } else {
                                    if (isset($response['europeBankAccount'])) {
                                        return EuropeBankAccount::factory($response['europeBankAccount']);
                                    } else {
                                        if (isset($response['usBankAccount'])) {
                                            return UsBankAccount::factory($response['usBankAccount']);
                                        } else {
                                            if (isset($response['venmoAccount'])) {
                                                return VenmoAccount::factory($response['venmoAccount']);
                                            } else {
                                                if (is_array($response)) {
                                                    return UnknownPaymentMethod::factory($response);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception\NotFound $e) {
            throw new Exception\NotFound('payment method with token ' . $token . ' not found');
        }
    }