/**
  * 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;
 }
Пример #2
0
 /**
  * send this message and get response
  * save all warnings - errors are only saved if no payment-url is send from pnag
  *
  * @return SofortLib_TransactionData $this
  */
 public function sendRequest()
 {
     $requestData[$this->_xmlRootTag] = $this->_parameters;
     $requestData = $this->_prepareRootTag($requestData);
     $xmlRequest = ArrayToXml::render($requestData);
     $this->_log($xmlRequest, ' XmlRequest -> ');
     $xmlResponse = $this->_sendMessage($xmlRequest);
     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->_log($xmlResponse, ' XmlResponse <- ');
     $this->_handleErrors();
     $this->_parseXml();
     return $this;
 }
 /**
  * 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;
     }
 }
 public function testRender()
 {
     $XmlToArray = new XmlToArray($this->_xml, $this->_maxDepth);
     $billcodeArray = array('billcode_request' => array('billcode' => array('@data' => 'test', '@attributes' => array()), '@data' => '', '@attributes' => array()));
     $this->assertEquals($XmlToArray->render($this->_xml), $billcodeArray);
 }