/** * @param array $data * @return Message\Response */ public function receiveResponse(array $data) { if (empty($data)) { throw new InvalidArgumentException('Expected at least partial response from gateway, nothing was given.'); } $data += array_fill_keys(['payId', 'dttm', 'resultCode', 'resultMessage', 'paymentStatus', 'authCode', 'merchantData', 'signature'], NULL); return Message\Response::createFromArray($data)->verify($this->signature); }
/** * @param array $data * @return Message\Response */ public function receiveResponse(array $data) { if (empty($data)) { throw new InvalidArgumentException('Expected at least partial response from gateway, nothing was given.'); } $data += array_fill_keys(['payId', 'dttm', 'resultCode', 'resultMessage', 'paymentStatus', 'authCode', 'merchantData', 'signature'], NULL); $response = Message\Response::createFromArray($data); // todo: call onResponse? if ($this->logger) { $logParams = $data; unset($logParams['signature']); $this->logger->info('payment/process', ['response' => $logParams]); } if ((int) $data['resultCode'] === PaymentException::INTERNAL_ERROR) { throw InternalErrorException::fromResponse($data, $response); } if (empty($data['signature'])) { throw new ApiException(sprintf('The "signature" key is missing or empty in response %s', json_encode($data))); } $response->verify($this->signature); if ((int) $data['resultCode'] === PaymentException::SESSION_EXPIRED) { throw SessionExpiredException::fromResponse($data, $response); } $this->handleInvalidPaymentStatus($response); return $response; }