示例#1
0
 protected function _loadFromXml(DOMElement $elem)
 {
     parent::_parseFromXml($elem);
     //card request specific data
     $elems = $elem->getElementsByTagName('invoice');
     if ($elems->length != 1) {
         throw new Exception('Mobilpay_Payment_Request_Card::loadFromXml failed; invoice element is missing', self::ERROR_LOAD_FROM_XML_ORDER_INVOICE_ELEM_MISSING);
     }
     $this->invoice = new Invoice($elems->item(0));
     $elems = $elem->getElementsByTagName('recurrence');
     if ($elems->length > 0) {
         $this->recurrence = new Recurrence($elems->item(0));
     }
     return $this;
 }
示例#2
0
 protected function _loadFromXml(DOMElement $elem)
 {
     parent::_parseFromXml($elem);
     //SMS request specific data
     $elems = $elem->getElementsByTagName('service');
     if ($elems->length != 1) {
         throw new Exception('Mobilpay_Payment_Request_Sms::loadFromXml failed: service is missing', self::ERROR_LOAD_FROM_XML_SERVICE_ELEM_MISSING);
     }
     $xmlElem = $elems->item(0);
     $this->service = $xmlElem->nodeValue;
     $elems = $elem->getElementsByTagName('msisdn');
     if ($elems->length == 1) {
         $this->msisdn = $elems->item(0)->nodeValue;
     }
     $elem = $elem;
     return $this;
 }
 /**
  * Process IPN request data
  *
  * @return array
  */
 public function getData()
 {
     if (!$this->getPrivateKey()) {
         throw new MissingKeyException("Missing private key path parameter");
     }
     $data = [];
     $this->responseError = new stdClass();
     $this->responseError->code = 0;
     $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_NONE;
     $this->responseError->message = '';
     if ($this->getIpnEnvKey() && $this->getIpnData()) {
         try {
             $data = AbstractRequest::factoryFromEncrypted($this->getIpnEnvKey(), $this->getIpnData(), $this->getPrivateKey());
             $this->responseError->message = $data->objPmNotify->getCrc();
             $data = json_decode(json_encode($data), true);
             // extract the transaction status from the IPN message
             if (isset($data['objPmNotify']['action'])) {
                 $this->action = $data['objPmNotify']['action'];
             }
             if (!in_array($this->action, ['confirmed_pending', 'paid_pending', 'paid', 'confirmed', 'canceled', 'credit'])) {
                 $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_PERMANENT;
                 $this->responseError->code = AbstractRequest::ERROR_CONFIRM_INVALID_ACTION;
                 $this->responseError->message = 'mobilpay_refference_action paramaters is invalid';
             }
         } catch (Exception $e) {
             $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_TEMPORARY;
             $this->responseError->code = $e->getCode();
             $this->responseError->message = $e->getMessage();
         }
     } else {
         $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_PERMANENT;
         $this->responseError->code = AbstractRequest::ERROR_CONFIRM_INVALID_POST_PARAMETERS;
         $this->responseError->message = 'mobilpay.ro posted invalid parameters';
     }
     return $data;
 }