Example #1
0
 public function url_notification()
 {
     // notification page
     $log_array = array('type' => 'Ukash URL_Notification', 'value' => $_POST);
     log_message('gash', json_encode($log_array) . "</br>");
     $UTID = $_POST['UTID'];
     $order_info = $this->pay_model->get_order_by_tradeseq($UTID);
     if (!empty($order_info)) {
         //query trasation detail
         $res = $this->pay_model->get_merchant_data_by_pay_type($order_info->pay_type_id, $order_info->method_id);
         $source = array('SecurityToken' => $res['merchant_name'], 'BrandID' => $res['merchant_key2'], 'UTID' => $UTID);
         // $soap = new SoapClient($this->staging_url.'?wsdl');
         $soap = new SoapClient($this->live_url . '?wsdl');
         $response = $soap->GetTransactionStatus($source);
         //get the transaction detail
         $xml_obj = simplexml_load_string($response->GetTransactionStatusResult);
         $log_array = array('type' => 'Ukash GetTransactionStatusResult', 'value' => $xml_obj);
         log_message('gash', json_encode($log_array) . "</br>");
         //  $msg = $this->recharge_lang['ask_to_contact'];
         if ($xml_obj->errCode == 0 && $xml_obj->TransactionCode == 0) {
             //update database and offer gold
             if ($xml_obj->SecurityToken == $res['merchant_key'] && $order_info->order_sn == $xml_obj->MerchantTransactionID && $xml_obj->MerchantCurrency == $res['merchant_key3'] && $xml_obj->SettleAmount == $order_info->pay_amount) {
                 $update_order = array('order_sn' => $order_info->order_sn, 'auth_code' => "{$xml_obj->UkashTransactionID}");
                 //  tranform auth_code to a string, otherwish error will occure in mysql
                 $this->CI->payorder->update_order_to_get_payment($update_order);
                 $offer_data_res = $this->offer_service($order_info->order_sn, $order_info->game_id);
                 if (empty($offer_data_res) || !$offer_data_res['status']) {
                     log_message('gash', 'Ukash offer ' . $condition['recharge_id'] . ' YUANBAO wrong . reason: ' . $offer_data_res['message'] . "</br>");
                     $msg = $this->recharge_lang['ask_to_contact'];
                     exit;
                 }
                 $offer_order['order_sn'] = $order_info->order_sn;
                 $this->CI->payorder->update_order_to_offer_service($offer_order);
                 //$msg = $this->recharge_lang['recharge_success'];
             }
         }
         //$this->CI->payorder->over($msg);
         exit;
     }
 }