== More information ==
Inheritance: extends braintree\Base
 /**
  * generic method for validating incoming gateway responses
  *
  * creates a new UsBankAccount 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['usBankAccount'])) {
         // return a populated instance of UsBankAccount
         return new Result\Successful(UsBankAccount::factory($response['usBankAccount']));
     } else {
         if (isset($response['apiErrorResponse'])) {
             return new Result\Error($response['apiErrorResponse']);
         } else {
             throw new Exception\Unexpected('Expected US bank account or apiErrorResponse');
         }
     }
 }
 public function testSale_createsASaleUsingGivenToken()
 {
     $customer = Braintree\Customer::createNoValidate();
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = Test\Helper::generateValidUsBankAccountNonce();
     $result = Braintree\PaymentMethod::create(['customerId' => $customer->id, 'paymentMethodNonce' => $nonce]);
     $result = Braintree\UsBankAccount::sale($result->paymentMethod->token, ['merchantAccountId' => 'us_bank_merchant_account', 'amount' => '100.00']);
     $this->assertTrue($result->success);
     $transaction = $result->transaction;
     $this->assertEquals(Braintree\Transaction::SETTLEMENT_PENDING, $transaction->status);
     $this->assertEquals(Braintree\Transaction::SALE, $transaction->type);
     $this->assertEquals('100.00', $transaction->amount);
     $this->assertEquals('021000021', $transaction->usBankAccount->routingNumber);
     $this->assertEquals('1234', $transaction->usBankAccount->last4);
     $this->assertEquals('checking', $transaction->usBankAccount->accountType);
     $this->assertEquals('PayPal Checking - 1234', $transaction->usBankAccount->accountDescription);
     $this->assertEquals('Dan Schulman', $transaction->usBankAccount->accountHolderName);
     $this->assertRegExp('/CHASE/', $transaction->usBankAccount->bankName);
 }
 /**
  * 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['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');
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }