Braintree\TransactionGateway::_verifyGatewayResponse PHP Method

_verifyGatewayResponse() private method

creates a new Transaction 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.
private _verifyGatewayResponse ( array $response ) : Braintree\Result\Successful | Error
$response array gateway response values
return Braintree\Result\Successful | Braintree\Result\Error
    private function _verifyGatewayResponse($response)
    {
        if (isset($response['transaction'])) {
            // return a populated instance of Transaction
            return new Result\Successful(Transaction::factory($response['transaction']));
        } else {
            if (isset($response['apiErrorResponse'])) {
                return new Result\Error($response['apiErrorResponse']);
            } else {
                throw new Exception\Unexpected("Expected transaction or apiErrorResponse");
            }
        }
    }