Esempio n. 1
0
 function result()
 {
     $this->load->helper('url');
     $configPath = APPPATH . "lgdacom";
     //LG유플러스에서 제공한 환경파일
     $CST_PLATFORM = $this->input->post('CST_PLATFORM');
     $CST_MID = $this->input->post('CST_MID');
     $LGD_MID = ("test" == $CST_PLATFORM ? "t" : "") . $CST_MID;
     $LGD_PAYKEY = $this->input->post("LGD_PAYKEY");
     require_once APPPATH . "lgdacom/XPayClient.php";
     $xpay = new XPayClient($configPath, $CST_PLATFORM);
     $xpay->Init_TX($LGD_MID);
     $xpay->Set("LGD_TXNAME", "PaymentByKey");
     $xpay->Set("LGD_PAYKEY", $LGD_PAYKEY);
     $this->load->helper('url');
     if ($xpay->TX()) {
         $LGD_RESPCODE = $xpay->Response("LGD_RESPCODE", 0);
         $LGD_TID = $xpay->Response("LGD_TID", 0);
         $LGD_PAYTYPE = $xpay->Response("LGD_PAYTYPE", 0);
         $LGD_PAYDATE = $xpay->Response("LGD_PAYDATE", 0);
         if ("0000" == $xpay->Response_Code()) {
             //PUT customer/order/:ordernumber?purchase=true
             $ch = curl_init();
             $url = "http://52.68.221.38/index.php/customer/quote/id/" . $this->input->post('ordernumber') . "/token/" . $this->input->post('token') . '/format/json';
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
             $result = curl_exec($ch);
             // $result is always false when on the same server for some reason
             curl_close($ch);
             if ($result != true && $result != 'true') {
                 $xpay->Rollback("상점 DB처리 실패로 인하여 Rollback 처리[TID:" . $xpay->Response("LGD_TID", 0) . ",MID:" . $xpay->Response("LGD_MID", 0) . ",OID:" . $xpay->Response("LGD_OID", 0) . "]");
                 //echo "TX Rollback Response_code = " . $xpay->Response_Code() . "<br/>";
                 //echo "TX Rollback Response_msg = " . $xpay->Response_Msg() . " ";
                 if ("0000" == $xpay->Response_Code()) {
                     $this->load->view('failTemplate');
                 } else {
                     $this->load->view('failTemplate');
                 }
             } else {
                 $this->load->view('successTemplate', $this->input->post());
             }
         } else {
             $this->load->view('failTemplate');
         }
     } else {
         $this->load->view('failTemplate');
     }
 }
Esempio n. 2
0
 function purchase_post()
 {
     $configPath = APPPATH . "lgdacom";
     $CST_PLATFORM = $this->post('CST_PLATFORM');
     $CST_MID = $this->post('CST_MID');
     $LGD_MID = ("test" == $CST_PLATFORM ? "t" : "") . $CST_MID;
     $LGD_PAYKEY = $this->post("LGD_PAYKEY");
     require_once APPPATH . "lgdacom/XPayClient.php";
     $xpay = new XPayClient($configPath, $CST_PLATFORM);
     $xpay->Init_TX($LGD_MID);
     $xpay->Set("LGD_TXNAME", "PaymentByKey");
     $xpay->Set("LGD_PAYKEY", $LGD_PAYKEY);
     if ($xpay->TX()) {
         //1)결제결과 화면처리 (성공, 실패 결과 처리를 하시기 바랍니다.)
         $LGD_RESPCODE = $xpay->Response("LGD_RESPCODE", 0);
         $LGD_TID = $xpay->Response("LGD_TID", 0);
         $LGD_PAYTYPE = $xpay->Response("LGD_PAYTYPE", 0);
         $LGD_PAYDATE = $xpay->Response("LGD_PAYDATE", 0);
         if ("0000" == $xpay->Response_Code()) {
             //완료되면 주문을 결제로 처리
             //업데이트 하기
             /*
             if($output != true && $output != 'true'){                        
                 $result = false;
             }else{
                 $result = true;
             }
             */
             $result = true;
             if ($result != true) {
                 $xpay->Rollback("상점 DB처리 실패로 인하여 Rollback 처리[TID:" . $xpay->Response("LGD_TID", 0) . ",MID:" . $xpay->Response("LGD_MID", 0) . ",OID:" . $xpay->Response("LGD_OID", 0) . "]");
                 //echo "TX Rollback Response_code = " . $xpay->Response_Code() . "<br/>";
                 //echo "TX Rollback Response_msg = " . $xpay->Response_Msg() . " ";
                 if ("0000" == $xpay->Response_Code()) {
                     echo 'rollback';
                     //redirect('process/rollback');
                 } else {
                     $result_array['success'] = false;
                     $result_array['message'] = 'rollback 실패';
                     return false;
                 }
             } else {
                 return true;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }