You are here

private static function Braintree_Transaction::_verifyGatewayResponse in Commerce Braintree 7

generic method for validating incoming gateway responses

creates a new Braintree_Transaction 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

4 calls to Braintree_Transaction::_verifyGatewayResponse()
Braintree_Transaction::refund in braintree_php/lib/Braintree/Transaction.php
Braintree_Transaction::submitForSettlement in braintree_php/lib/Braintree/Transaction.php
Braintree_Transaction::void in braintree_php/lib/Braintree/Transaction.php
void a transaction by id
Braintree_Transaction::_doCreate in braintree_php/lib/Braintree/Transaction.php
sends the create request to the gateway

File

braintree_php/lib/Braintree/Transaction.php, line 633

Class

Braintree_Transaction
Creates and manages transactions

Code

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

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