/** * @param Response $httpResponse * @return array * @throws \RuntimeException */ protected function extractDataFromResponse($httpResponse, GiropayResponse $giropayResponse) { $response = new PaymentResponseDTO(PaymentType::$BANK_ACCOUNT, GiropayPaymentGatewayType::$GIROPAY); $response->rawResponse($httpResponse->getBody(true)); try { $data = $httpResponse->json(); if (!array_key_exists("rc", $data) || !is_numeric($data["rc"])) { throw new \RuntimeException("Missing required response parameter rc"); } if (!array_key_exists($data["rc"], GiropayResultType::$TYPES)) { throw new \RuntimeException("Unknown Result Code: " . $data["rc"]); } $result = GiropayResultType::$TYPES[$data["rc"]]; $giropayResponse->setResult($result); if (GiropayResultType::$OK->equals($result) && !$this->verifyHttpResponseHash($httpResponse)) { throw new \RuntimeException("The validation hash was invalid"); } } catch (Guzzle\Common\Exception\RuntimeException $e) { throw new \RuntimeException("Json payload could not be parsed", 0, $e); } return $data; }
/** * @param PaymentRequestDTO $transactionToBeRolledBack * @throws PaymentException * @return PaymentResponseDTO */ public function rollbackAuthorizeAndCapture(PaymentRequestDTO $transactionToBeRolledBack) { $responseDto = new PaymentResponseDTO(PaymentType::$CREDIT_CARD, NullPaymentGatewayType::$NULL_GATEWAY); $responseDto->rawResponse("rollback authorize and capture - successful")->successful(true)->paymentTransactionType(PaymentTransactionType::$VOID)->amount(new Money($transactionToBeRolledBack->getTransactionTotal())); return $responseDto; }
/** * @param Request $request * @throws PaymentException * @return PaymentResponseDTO */ public function translateWebResponse(Request $request) { $responseDTO = new PaymentResponseDTO(PaymentType::$THIRD_PARTY_ACCOUNT, GiropayPaymentGatewayType::$GIROPAY); $responseDTO->rawResponse($this->webResponsePrintService->printRequest($request)); // TODO: Implement requestHostedEndpoint() method. }