Пример #1
0
 /**
  * @see Paranoia\Payment\Adapter\AdapterAbstract::parseResponse()
  */
 protected function parseResponse($rawResponse)
 {
     $response = new PaymentResponse();
     try {
         /**
          * @var object $xml
          */
         $xml = new \SimpleXmlElement($rawResponse);
     } catch (\Exception $e) {
         throw new UnexpectedResponse('Provider returned unexpected response: ' . $rawResponse);
     }
     $response->setIsSuccess((string) $xml->Transaction->Response->Code == '00');
     $response->setResponseCode((string) $xml->Transaction->ReasonCode);
     if (!$response->isSuccess()) {
         $errorMessages = array();
         if (property_exists($xml->Transaction->Response, 'ErrorMsg')) {
             $errorMessages[] = sprintf('Error Message: %s', (string) $xml->Transaction->Response->ErrorMsg);
         }
         if (property_exists($xml->Transaction->Response, 'SysErrMsg')) {
             $errorMessages[] = sprintf('System Error Message: %s', (string) $xml->Transaction->Response->SysErrMsg);
         }
         $errorMessage = implode(' ', $errorMessages);
         $response->setResponseMessage($errorMessage);
     } else {
         $response->setResponseMessage('Success');
         $response->setOrderId((string) $xml->Order->OrderID);
         $response->setTransactionId((string) $xml->Transaction->RetrefNum);
     }
     $response->setRawData($rawResponse);
     return $response;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  * @see Paranoia\Payment\Adapter\AdapterAbstract::parseResponse()
  */
 protected function parseResponse($rawResponse, $transactionType)
 {
     $response = new PaymentResponse();
     try {
         /**
          * @var object $xml
          */
         $xml = new \SimpleXmlElement($rawResponse);
     } catch (\Exception $e) {
         $exception = new UnexpectedResponse('Provider returned unexpected response: ' . $rawResponse);
         $eventArg = new PaymentEventArg(null, null, $transactionType, $exception);
         $this->getDispatcher()->dispatch(self::EVENT_ON_EXCEPTION, $eventArg);
         throw $exception;
     }
     $response->setIsSuccess((int) $xml->approved > 0);
     if (!$response->isSuccess()) {
         $response->setResponseCode((string) $xml->respCode);
         $errorMessages = array();
         if (property_exists($xml, 'respCode')) {
             $errorMessages[] = sprintf('Error: %s', (string) $xml->respCode);
         }
         if (property_exists($xml, 'respText')) {
             $errorMessages[] = sprintf('Error Message: %s ', (string) $xml->respText);
         }
         $errorMessage = implode(' ', $errorMessages);
         $response->setResponseMessage($errorMessage);
     } else {
         $response->setResponseCode("0000");
         $response->setResponseMessage('Success');
         if (property_exists($xml, 'orderId')) {
             $response->setOrderId((string) $xml->orderId);
         }
         $response->setTransactionId((string) $xml->hostlogkey);
         if (property_exists($xml, 'authCode')) {
             $response->setOrderId((string) $xml->authCode);
         }
     }
     $event = $response->isSuccess() ? self::EVENT_ON_TRANSACTION_SUCCESSFUL : self::EVENT_ON_TRANSACTION_FAILED;
     $this->getDispatcher()->dispatch($event, new PaymentEventArg(null, $response, $transactionType));
     return $response;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  * @see Paranoia\Payment\Adapter\AdapterAbstract::parseResponse()
  */
 protected function parseResponse($rawResponse, $transactionType)
 {
     $response = new PaymentResponse();
     try {
         /**
          * @var object $xml
          */
         $xml = new \SimpleXmlElement($rawResponse);
     } catch (\Exception $e) {
         $exception = new UnexpectedResponse('Provider returned unexpected response: ' . $rawResponse);
         $eventArg = new PaymentEventArg(null, null, $transactionType, $exception);
         $this->getDispatcher()->dispatch(self::EVENT_ON_EXCEPTION, $eventArg);
         throw $exception;
     }
     $response->setIsSuccess('00' == (string) $xml->Transaction->Response->Code);
     $response->setResponseCode((string) $xml->Transaction->ReasonCode);
     if (!$response->isSuccess()) {
         $errorMessages = array();
         if (property_exists($xml->Transaction->Response, 'ErrorMsg')) {
             $errorMessages[] = sprintf('Error Message: %s', (string) $xml->Transaction->Response->ErrorMsg);
         }
         if (property_exists($xml->Transaction->Response, 'SysErrMsg')) {
             $errorMessages[] = sprintf('System Error Message: %s', (string) $xml->Transaction->Response->SysErrMsg);
         }
         $errorMessage = implode(' ', $errorMessages);
         $response->setResponseMessage($errorMessage);
     } else {
         $response->setResponseMessage('Success');
         $response->setOrderId((string) $xml->Order->OrderID);
         $response->setTransactionId((string) $xml->Transaction->RetrefNum);
     }
     $event = $response->isSuccess() ? self::EVENT_ON_TRANSACTION_SUCCESSFUL : self::EVENT_ON_TRANSACTION_FAILED;
     $this->getDispatcher()->dispatch($event, new PaymentEventArg(null, $response, $transactionType));
     return $response;
 }
Пример #4
0
 /**
  * @see Paranoia\Payment\Adapter\AdapterAbstract::parseResponse()
  */
 protected function parseResponse($rawResponse)
 {
     $response = new PaymentResponse();
     try {
         /**
          * @var object $xml
          */
         $xml = new \SimpleXmlElement($rawResponse);
     } catch (\Exception $e) {
         $exception = new UnexpectedResponse('Provider returned unexpected response: ' . $rawResponse);
         $this->triggerEvent(self::EVENT_ON_EXCEPTION, array_merge($this->collectTransactionInformation(), array('exception' => $exception)));
         throw $exception;
     }
     $response->setIsSuccess((string) $xml->Response == 'Approved');
     $response->setResponseCode((string) $xml->ProcReturnCode);
     if (!$response->isSuccess()) {
         $errorMessages = array();
         if (property_exists($xml, 'Error')) {
             $errorMessages[] = sprintf('Error: %s', (string) $xml->Error);
         }
         if (property_exists($xml, 'ErrMsg')) {
             $errorMessages[] = sprintf('Error Message: %s ', (string) $xml->ErrMsg);
         }
         if (property_exists($xml, 'Extra') && property_exists($xml->Extra, 'HOSTMSG')) {
             $errorMessages[] = sprintf('Host Message: %s', (string) $xml->Extra->HOSTMSG);
         }
         $errorMessage = implode(' ', $errorMessages);
         $response->setResponseMessage($errorMessage);
     } else {
         $response->setResponseMessage('Success');
         $response->setOrderId((string) $xml->OrderId);
         $response->setTransactionId((string) $xml->TransId);
     }
     $response->setRawData($rawResponse);
     $eventData = $this->collectTransactionInformation();
     $eventName = $response->isSuccess() ? self::EVENT_ON_TRANSACTION_SUCCESSFUL : self::EVENT_ON_TRANSACTION_FAILED;
     $this->triggerEvent($eventName, $eventData);
     return $response;
 }
Пример #5
0
 /**
  * @see Paranoia\Payment\Adapter\AdapterAbstract::parseResponse()
  */
 protected function parseResponse($rawResponse)
 {
     $response = new PaymentResponse();
     try {
         /**
          * @var object $xml
          */
         $xml = new \SimpleXmlElement($rawResponse);
     } catch (\Exception $e) {
         $exception = new UnexpectedResponse('Provider returned unexpected response: ' . $rawResponse);
         $this->triggerEvent(self::EVENT_ON_EXCEPTION, array_merge($this->collectTransactionInformation(), array('exception' => $exception)));
         throw $exception;
     }
     $response->setIsSuccess((int) $xml->approved > 0);
     if (!$response->isSuccess()) {
         $response->setResponseCode((string) $xml->respCode);
         $errorMessages = array();
         if (property_exists($xml, 'respCode')) {
             $errorMessages[] = sprintf('Error: %s', (string) $xml->respCode);
         }
         if (property_exists($xml, 'respText')) {
             $errorMessages[] = sprintf('Error Message: %s ', (string) $xml->respText);
         }
         $errorMessage = implode(' ', $errorMessages);
         $response->setResponseMessage($errorMessage);
     } else {
         $response->setResponseCode("0000");
         $response->setResponseMessage('Success');
         if (property_exists($xml, 'orderId')) {
             $response->setOrderId((string) $xml->orderId);
         }
         $response->setTransactionId((string) $xml->hostlogkey);
         if (property_exists($xml, 'authCode')) {
             $response->setOrderId((string) $xml->authCode);
         }
     }
     $response->setRawData($rawResponse);
     $eventData = $this->collectTransactionInformation();
     $eventName = $response->isSuccess() ? self::EVENT_ON_TRANSACTION_SUCCESSFUL : self::EVENT_ON_TRANSACTION_FAILED;
     $this->triggerEvent($eventName, $eventData);
     return $response;
 }