Braintree\PaymentMethodGateway::_verifyGatewayResponse PHP Метод

_verifyGatewayResponse() приватный Метод

creates a new CreditCard or PayPalAccount object and encapsulates it inside a Result\Successful object, or encapsulates a Errors object inside a Result\Error alternatively, throws an Unexpected exception if the response is invalid.
private _verifyGatewayResponse ( array $response ) : Braintree\Result\Successful | Error
$response array gateway response values
Результат Braintree\Result\Successful | Braintree\Result\Error
    private function _verifyGatewayResponse($response)
    {
        if (isset($response['creditCard'])) {
            return new Result\Successful(CreditCard::factory($response['creditCard']), 'paymentMethod');
        } else {
            if (isset($response['paypalAccount'])) {
                return new Result\Successful(PayPalAccount::factory($response['paypalAccount']), "paymentMethod");
            } else {
                if (isset($response['coinbaseAccount'])) {
                    return new Result\Successful(CoinbaseAccount::factory($response['coinbaseAccount']), "paymentMethod");
                } else {
                    if (isset($response['applePayCard'])) {
                        return new Result\Successful(ApplePayCard::factory($response['applePayCard']), "paymentMethod");
                    } else {
                        if (isset($response['androidPayCard'])) {
                            return new Result\Successful(AndroidPayCard::factory($response['androidPayCard']), "paymentMethod");
                        } else {
                            if (isset($response['amexExpressCheckoutCard'])) {
                                return new Result\Successful(AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']), "paymentMethod");
                            } else {
                                if (isset($response['europeBankAccount'])) {
                                    return new Result\Successful(EuropeBankAccount::factory($response['europeBankAccount']), "paymentMethod");
                                } else {
                                    if (isset($response['usBankAccount'])) {
                                        return new Result\Successful(UsBankAccount::factory($response['usBankAccount']), "paymentMethod");
                                    } else {
                                        if (isset($response['venmoAccount'])) {
                                            return new Result\Successful(VenmoAccount::factory($response['venmoAccount']), "paymentMethod");
                                        } else {
                                            if (isset($response['paymentMethodNonce'])) {
                                                return new Result\Successful(PaymentMethodNonce::factory($response['paymentMethodNonce']), "paymentMethodNonce");
                                            } else {
                                                if (isset($response['apiErrorResponse'])) {
                                                    return new Result\Error($response['apiErrorResponse']);
                                                } else {
                                                    if (is_array($response)) {
                                                        return new Result\Successful(UnknownPaymentMethod::factory($response), "paymentMethod");
                                                    } else {
                                                        throw new Exception\Unexpected('Expected payment method or apiErrorResponse');
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }