Пример #1
0
 /**
  * Constructor
  * 
  * Checks if message is soap or not 
  * 
  * @param array $params
  * @return void 
  */
 public function __construct($params)
 {
     //check if this is a soap request
     if (is_object($params) && isset($params->NP_MESSAGE)) {
         $this->request = Np_Method::getInstance($params);
         $this->data = $params;
         if (!isset($this->data['PHONE_NUMBER'])) {
             $this->data['PHONE_NUMBER'] = Application_Model_General::getFieldFromRequests("phone_number", $params['REQUEST_ID']);
         }
     } else {
         if (is_array($params)) {
             // this is internal and not external (soap)
             if (isset($params['MANUAL']) && $params['MANUAL']) {
                 $fields = array('last_transaction', 'from_provider', 'to_provider');
                 $values = Application_Model_General::getFieldFromRequests($fields, $params['REQUEST_ID'], 'request_id');
                 if ($values['last_transaction'] != $params['MSG_TYPE'] && $values['last_transaction'] != $params['MSG_TYPE'] . '_response') {
                     $response = array('success' => 0, 'error' => 1, 'manual' => 1, 'desc' => 'The request is not at the right stage');
                     die(json_encode($response));
                 }
                 if (!isset($params['FROM']) || !isset($params['TO'])) {
                     $params['FROM'] = $values['to_provider'];
                     $params['TO'] = $values['from_provider'];
                 }
                 if (!isset($params['TRX_NO'])) {
                     $transaction = Application_Model_General::getTransactions($params['REQUEST_ID'], $params['MSG_TYPE']);
                     $params['TRX_NO'] = $transaction[0]['trx_no'];
                     $params['RETRY_DATE'] = Application_Model_General::getDateTimeIso($transaction[0]['last_transaction_time']);
                 }
                 $this->data = $params;
             } else {
                 if (is_array($params)) {
                     // we are receiving data => need to send to provider
                     if (!isset($params['REQUEST_ID']) && $params['MSG_TYPE'] != "Check" && isset($params['PHONE_NUMBER'])) {
                         //CALL FROM INTERNAL WITH NO REQUEST ID
                         //if the type is check the request id will be added later- on insert to DB
                         $params['REQUEST_ID'] = Application_Model_General::getFieldFromRequests("request_id", $params['PHONE_NUMBER']);
                     }
                     $this->data = $params;
                 } else {
                     //no parameters
                     $this->data = NULL;
                     $this->request = NULL;
                     return;
                 }
             }
             $this->request = Np_Method::getInstance($this->data);
         }
     }
 }
Пример #2
0
 /**
  * @TODO: implement send error to internal
  */
 public function SendErrorToInternal($errorData)
 {
     $request = Np_Method::getInstance($errorData);
     if (isset($errorData['STATUS'])) {
         $request->setRejectReasonCode($errorData['STATUS']);
         $request->setAck($errorData['STATUS']);
     } else {
         $request->setRejectReasonCode(false);
         $request->setAck(false);
     }
     $this->SendRequestToInternal($request);
     return TRUE;
 }