/**
  * @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);
 }
Exemple #2
0
 protected function logRequest(Message\Request $request, Message\Response $response = NULL, \Exception $exception = NULL)
 {
     if (!$this->logger) {
         return;
     }
     $context = ['request' => $request->toArray(), 'response' => $response ? $response->toArray() : NULL];
     $responseMsg = $response ? $response->getResultMessage() : NULL;
     unset($context['request']['signature']);
     unset($context['response']['signature']);
     if ($exception === NULL) {
         $this->logger->info($request->getEndpointName() . ($responseMsg ? ': ' . $responseMsg : NULL), $context);
     } else {
         $context['exception'] = ['type' => get_class($exception), 'code' => $exception->getCode(), 'message' => $exception->getMessage()];
         $this->logger->error($request->getEndpointName() . ($responseMsg ? ': ' . $responseMsg : NULL), $context);
     }
 }