protected function wrapOmnipayResponse(ResponseInterface $omnipayResponse, $isNotification = false)
    {
        if ($isNotification) {
            $flags = ServiceResponse::SERVICE_NOTIFICATION;
            if (!$omnipayResponse->isSuccessful()) {
                $flags |= ServiceResponse::SERVICE_ERROR;
            }
            return $this->generateServiceResponse($flags, $omnipayResponse);
        }

        $isAsync = GatewayInfo::shouldUseAsyncNotifications($this->payment->Gateway);
        $flags = $isAsync ? ServiceResponse::SERVICE_PENDING : 0;

        if (!$omnipayResponse->isSuccessful() && !$omnipayResponse->isRedirect() && !$isAsync) {
            $flags |= ServiceResponse::SERVICE_ERROR;
        }

        return $this->generateServiceResponse($flags, $omnipayResponse);
    }