/** * Get a service response from the given Omnipay response * @param AbstractResponse $omnipayResponse * @param bool $isNotification whether or not this response is a response to a notification * @return ServiceResponse */ protected function wrapOmnipayResponse(AbstractResponse $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); }