You are here

private static function Braintree_Address::_verifyGatewayResponse in Commerce Braintree 7

generic method for validating incoming gateway responses

creates a new Braintree_Address 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_Address::_verifyGatewayResponse()
Braintree_Address::update in braintree_php/lib/Braintree/Address.php
updates the address record
Braintree_Address::_doCreate in braintree_php/lib/Braintree/Address.php
sends the create request to the gateway @ignore

File

braintree_php/lib/Braintree/Address.php, line 322

Class

Braintree_Address
Creates and manages Braintree Addresses

Code

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

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