public function testFind_nonExistantNonce() { $this->setExpectedException('Braintree\\Exception\\NotFound'); Braintree\PaymentMethodNonce::find('not_a_nonce'); }
/** * @param string $token * @return \Braintree\Result\Successful|\Braintree\Result\Error */ public function createNonce($token) { return PaymentMethodNonce::create($token); }
public function grant($sharedPaymentMethodToken, $allowVaulting) { $fullPath = $this->_config->merchantPath() . '/payment_methods/grant'; $response = $this->_http->post($fullPath, ['payment_method' => ['shared_payment_method_token' => $sharedPaymentMethodToken, 'allow_vaulting' => $allowVaulting]]); return PaymentMethodNonce::factory($response['paymentMethodNonce']); }
/** * generic method for validating incoming gateway responses * * 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. * * @ignore * @param array $response gateway response values * @return Result\Successful|Result\Error * @throws Exception\Unexpected */ 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['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'); } } } } } } } } } } } }