Пример #1
0
 /**
  * Preparing data and parsing result received
  * @param  array $data
  * @return void
  */
 public function handle($data)
 {
     $this->_request = ArrayToXml::render($data);
     $this->_rawRequest = $this->_request;
     $xmlResponse = self::sendMessage($this->_request);
     if (!in_array($this->getConnection()->getHttpStatusCode(), array('200', '301', '302'))) {
         $this->_response = array('errors' => array('error' => array('code' => array('@data' => $this->getConnection()->getHttpStatusCode()), 'message' => array('@data' => $this->getConnection()->error))));
     } else {
         try {
             $this->_response = XmlToArray::render($xmlResponse);
         } catch (\Exception $e) {
             $this->_response = array('errors' => array('error' => array('code' => array('@data' => '0999'), 'message' => array('@data' => $e->getMessage()))));
         }
     }
     $this->_rawResponse = $xmlResponse;
 }
 /**
  * Reads the input and tries to read the transaction id
  *
  * @param  string         $content XML-File Content
  * @return boolean|string (transaction ID, when true)
  */
 public function getNotification($content)
 {
     try {
         $response = XmlToArray::render($content);
     } catch (\Exception $e) {
         $this->errors['error']['message'] = 'could not parse message';
         return false;
     }
     if (!isset($response['status_notification'])) {
         return false;
     }
     if (isset($response['status_notification']['transaction']['@data'])) {
         $this->_transactionId = $response['status_notification']['transaction']['@data'];
         if ($response['status_notification']['time']['@data']) {
             $this->_time = $response['status_notification']['time']['@data'];
         }
         return $this->_transactionId;
     } else {
         return false;
     }
 }