/** * @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; }
public function equals(GiropayResponse $o) { return $this->getRawResponse() == $o->getRawResponse(); }