Exemplo n.º 1
0
 /**
  * method to create xml from the request
  * 
  * @return SimpleXml xml object
  */
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $xml->{$msgType}->portingDateTime = Application_Model_General::getDateTimeIso($this->getBodyField('PORT_TIME'));
     return $xml;
 }
Exemplo n.º 2
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);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * sendMessage method defined by NP wsdl
  * called by external providers to send transaction messages to internal
  * the call to internal will be forward by forking
  * 
  * @param		Array $params
  * @return		array "NP_ACK" or string
  */
 public function sendMessage($params)
 {
     Application_Model_General::virtualSleep();
     $reqModel = new Application_Model_Request($params);
     //prepares data for sending internal the message
     $ack = $reqModel->Execute();
     // log all received calls if request log enabled
     if (Application_Model_General::getSettings('EnableRequestLog')) {
         Application_Model_General::logRequestResponse($params, $ack, $reqModel->getRequest()->getHeaderField('REQUEST_ID'), '[Input] ');
     }
     if ($ack === FALSE || strpos(strtolower($ack), "ack") === FALSE) {
         $ack = "Ack00";
     }
     return array('NP_ACK' => array('ACK_CODE' => $ack, 'ACK_DATE' => Application_Model_General::getDateTimeIso()));
 }
Exemplo n.º 4
0
 /**
  * send publish to specific provider
  * 
  * @param array $request 
  * @return void
  */
 public function executePublish($request)
 {
     $params = Application_Model_General::getParamsArray($request);
     // let's check if it's port (means we have execute response before)
     $execute_exists = Application_Model_General::getTransactions($request['request_id'], 'Execute_response', 'null');
     if (empty($execute_exists) || !is_array($execute_exists) || !count($execute_exists)) {
         $publish_type = "Rtrn";
     } else {
         $publish_type = "Port";
     }
     $params['PROCESS_TYPE'] = "PORT";
     $params['MSG_TYPE'] = "Publish";
     $params['FROM'] = Application_Model_General::getSettings('InternalProvider');
     $params['DONOR'] = $params['FROM_PROVIDER'];
     //$row['DONOR'] = $provider;
     $params['PUBLISH_TYPE'] = $publish_type;
     $params["RETRY_DATE"] = Application_Model_General::getDateTimeIso();
     $params["RETRY_NO"] = $this->get_retry_no($params);
     $params["VERSION_NO"] = Application_Model_General::getSettings("VersionNo");
     $reqModel = new Application_Model_Request($params);
     // make sure the request is ok.
     // can use $reqModel->RequestValidate() but maybe there is no need becuse i'm building it
     // TODO.oc666: why we execute from internal?
     $reqModel->ExecuteFromInternal();
     //what with the ack in the DB - status 1 for each?
 }
Exemplo n.º 5
0
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $networkType = Application_Model_General::getSettings("NetworkType");
     $xml->{$msgType}->donor = $this->getBodyField('DONOR');
     $xml->{$msgType}->connectDateTime = Application_Model_General::getDateTimeIso($this->getBodyField('CONNECT_TIME'));
     $xml->{$msgType}->publishType = $this->getBodyField('PUBLISH_TYPE');
     $xml->{$msgType}->disconnectDateTime = Application_Model_General::getDateTimeIso($this->getBodyField('DISCONNECT_TIME'));
     if ($networkType === "M") {
         $xml->{$msgType}->mobile;
         $xml->{$msgType}->mobile->numberType = "I";
         $xml->{$msgType}->mobile->number = $this->getBodyField("NUMBER");
     } else {
         $xml->{$msgType}->fixed->fixedNumberSingle;
     }
     return $xml;
 }
Exemplo n.º 6
0
 /**
  * Adds Hardcoded Values to Missing Fields for SOAP Request 
  * 
  * @param array $params 
  * 
  */
 private function AddParamsToInternalReq(&$params)
 {
     //		$params['FORK'] = 1;
     $params['FROM_PROVIDER'] = Application_Model_General::getSettings('InternalProvider');
     //requests from internal - Transfer to internal
     if (isset($params['MSG_TYPE'])) {
         $params['PROCESS_TYPE'] = Application_Model_General::getProcessType($params['MSG_TYPE']);
     }
     if (isset($params['msg_type'])) {
         $params['PROCESS_TYPE'] = Application_Model_General::getProcessType($params['msg_type']);
     }
     $params['VERSION_NO'] = Application_Model_General::getSettings("VersionNo");
     $params['RETRY_NO'] = 1;
     $params['RETRY_DATE'] = Application_Model_General::getDateTimeIso();
     $params['NETWORK_TYPE'] = Application_Model_General::getSettings("NetworkType");
     if (isset($params['more'])) {
         foreach ($params['more'] as $key => $value) {
             $params[strtoupper($key)] = $value;
         }
     }
     // backward compatibility
     if (!isset($params['NUMBER_TYPE'])) {
         $params['NUMBER_TYPE'] = Application_Model_General::getSettings("NumberType");
     }
     if (isset($params['number_type'])) {
         $params['NUMBER_TYPE'] = $params['number_type'];
     }
 }
Exemplo n.º 7
0
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $networkType = Application_Model_General::getSettings("NetworkType");
     $numberType = $this->getBodyField('NUMBER_TYPE');
     $requestId = $this->getHeaderField('REQUEST_ID');
     $requestRecord = Application_Model_General::getFieldFromRequests(array('flags', 'transfer_time'), $requestId, 'request_id');
     $flags = json_decode($requestRecord['flags'], true);
     if (empty($numberType)) {
         $numberType = isset($flags['number_type']) ? $flags['number_type'] : Application_Model_General::getSettings("NumberType");
     }
     $number = $this->getBodyField('NUMBER');
     $portTime = Application_Model_General::getDateTimeIso($requestRecord['transfer_time']);
     $process_type = $this->getHeaderField('PROCESS_TYPE');
     if ($process_type == "PORT") {
         $path =& $xml->{$msgType}->updateRequestType;
         $path->updateType = "REQUEST";
         $path->portingDateTime = $portTime;
     } else {
         if ($process_type == "CANCEL") {
             $path =& $xml->{$msgType}->updateCancelTypeType;
             $path->updateType = "CANCEL";
             $path->portingDateTime = $portTime;
         } else {
             if ($process_type == "UPDATE") {
                 $path =& $xml->{$msgType}->updateUpdateTypeType;
                 $path->updateType = "UPDATE";
                 $path->portingDateTime = $portTime;
             }
         }
     }
     if ($networkType === "M") {
         $networkType = "mobile";
     } else {
         $networkType = "fixed";
     }
     $path->{$networkType};
     $path->{$networkType}->networkType = "M";
     if ($numberType === "I") {
         $path->{$networkType}->mobileNumberIdentified;
         $path->{$networkType}->mobileNumberIdentified->numberType = $numberType;
         $path->{$networkType}->mobileNumberIdentified->identificationValue = isset($flags['identification_value']) ? $flags['identification_value'] : 'default';
         $path->{$networkType}->mobileNumberIdentified->identificationValue2nd = 'default';
         $path->{$networkType}->mobileNumberIdentified->identificationValue3rd = 'default';
         $path->{$networkType}->mobileNumberIdentified->number = $number;
     } else {
         $path->{$networkType}->mobileNumberUnidentified;
         $path->{$networkType}->mobileNumberUnidentified->numberType = $numberType;
         $path->{$networkType}->mobileNumberUnidentified->number = $number;
     }
     return $xml;
 }
Exemplo n.º 8
0
 /**
  * sends automatic response to transaction messages sent to internal.
  * 
  * @param bool $status
  * 
  * @todo refactoring to bridge classes
  */
 public function CreateMethodResponse($status)
 {
     //update DB ack!
     //SEND RESPONSE TO PROVIDER
     $response = array('REQUEST_ID' => $this->params['REQUEST_ID'], 'PROCESS_TYPE' => $this->params['PROCESS_TYPE'], 'MSG_TYPE' => $this->params['MSG_TYPE'] . "_response", 'REQUEST_TRX_NO' => $this->params['TRX_NO'], 'FROM' => $this->params['TO'], 'TO' => $this->params['FROM'], 'REQUEST_RETRY_DATE' => $this->params['RETRY_DATE'], 'RETRY_DATE' => Application_Model_General::getDateTimeIso(), 'RETRY_NO' => isset($this->params['RETRY_NO']) ? $this->params['RETRY_NO'] : 1, 'VERSION_NO' => Application_Model_General::getSettings("VersionNo"), 'NETWORK_TYPE' => Application_Model_General::getSettings('NetworkType'), 'NUMBER_TYPE' => isset($this->params['NUMBER_TYPE']) ? $this->params['NUMBER_TYPE'] : Application_Model_General::getSettings("NumberType"));
     $phone_number = array("PHONE_NUMBER" => $this->params['PHONE_NUMBER']);
     Application_Model_General::writeToLog(array_merge($response, $phone_number));
     //check $status
     if (($status->status == "Ack00" || $status->status == "true") && !isset($status->resultCode) || $status->status == NULL && $status->resultCode == "Ack00") {
         $response['APPROVAL_IND'] = "Y";
     } elseif ($status->status == "Gen07") {
         $response['APPROVAL_IND'] = "N";
         $response['REJECT_REASON_CODE'] = "Gen07";
     } else {
         $response['APPROVAL_IND'] = "N";
         $response['REJECT_REASON_CODE'] = $status->status;
     }
     if ($this->params['MSG_TYPE'] == "Execute") {
         $time = isset($status->DISCONNECT_TIME) ? $status->DISCONNECT_TIME : null;
         $response['DISCONNECT_TIME'] = Application_Model_General::getDateTimeIso($time);
     }
     if ($response['MSG_TYPE'] == "Inquire_number_response") {
         $response['CURRENT_OPERATOR'] = isset($status->current_operator) ? $status->current_operator : $status->more->current_operator;
     }
     if (isset($status->resultCode) && !empty($status->resultCode)) {
         $response['REJECT_REASON_CODE'] = $status->resultCode;
     }
     $reqModel = new Application_Model_Request($response);
     $reqModel->ExecuteFromInternal(FALSE);
     // ExecuteResponse();
 }