You are here

private static function Braintree_CreditCard::_verifyGatewayResponse in Commerce Braintree 7

generic method for validating incoming gateway responses

creates a new Braintree_CreditCard object and encapsulates it inside a Braintree_Result_Successful object, or encapsulates a Braintree_Errors object inside a Result_Error alternatively, throws an Unexpected exception if the response is invalid.

@ignore

Parameters

array $response gateway response values:

Return value

object Result_Successful or Result_Error

Throws

Braintree_Exception_Unexpected

2 calls to Braintree_CreditCard::_verifyGatewayResponse()
Braintree_CreditCard::_doCreate in braintree_php/lib/Braintree/CreditCard.php
sends the create request to the gateway
Braintree_CreditCard::_doUpdate in braintree_php/lib/Braintree/CreditCard.php
sends the update request to the gateway

File

braintree_php/lib/Braintree/CreditCard.php, line 552

Class

Braintree_CreditCard
Creates and manages Braintree CreditCards

Code

private static function _verifyGatewayResponse($response) {
  if (isset($response['creditCard'])) {

    // return a populated instance of Braintree_Address
    return new Braintree_Result_Successful(self::factory($response['creditCard']));
  }
  else {
    if (isset($response['apiErrorResponse'])) {
      return new Braintree_Result_Error($response['apiErrorResponse']);
    }
    else {
      throw new Braintree_Exception_Unexpected("Expected address or apiErrorResponse");
    }
  }
}