public function createOrReverse(
        Model\InStore\Refund $refund,
        Model\InStore\Reversal $refundReversal = null,
        HandlerStack $stack = null
    ) {
        try {
            return $this->create($refund, $stack);
        } catch (ApiException $refundException) {
            // http://docs.afterpay.com.au/instore-api-v1.html#create-refund
            // Should a success or error response (with exception to 409 conflict) not be received,
            // the POS should queue the request ID for reversal
            if ($refundException->getErrorResponse()->getErrorCode() == self::ERROR_CONFLICT) {
                throw $refundException;
            }
            $errorResponse = $refundException->getErrorResponse();
        } catch (RequestException $refundException) {
            // a timeout or other exception has occurred. attempt a reversal
            $errorResponse = new Model\ErrorResponse();
            $errorResponse->setHttpStatusCode(
                $refundException->getResponse() ? $refundException->getResponse()->getStatusCode() : self::ERROR_INTERNAL_ERROR
            );
            $errorResponse->setMessage($refundException->getMessage());
        }

        $now = new \DateTime();
        if ($refundReversal === null) {
            $refundReversal = new Model\InStore\Reversal();
            $refundReversal->setReversingRequestId($refund->getRequestId());
            $refundReversal->setRequestedAt($now);
        }

        try {
            $reversal = $this->reverse($refundReversal, $stack);
            $reversal->setErrorReason($errorResponse);

            return $reversal;
        } catch (ApiException $reversalException) {
            $reversalErrorResponse = $reversalException->getErrorResponse();
            if ($reversalErrorResponse->getErrorCode() === self::ERROR_MSG_PRECONDITION_FAILED) {
                // there was trouble reversing probably because the refund failed
                throw $refundException;
            }

            throw $reversalException;
        }
    }