예제 #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');
     }
 }
예제 #2
0
 function readHash($token, $input)
 {
     require_once APPPATH . "lgdacom/XPayClient.php";
     $data = $input;
     //$data['token']                      = $token;
     $data['deadline_number'] = $input['deadline_number'];
     $data['CST_PLATFORM'] = 'service';
     //LG유플러스 결제 서비스 선택(test:테스트, service:서비스)
     $data['CST_MID'] = 'paperbetter';
     //상점아이디(LG유플러스로부터 발급받으신 상점 아이디를 입력하세요)
     $data['LGD_MID'] = ("test" == $data['CST_PLATFORM'] ? "t" : "") . $data['CST_MID'];
     //상점아이디(자동생성)
     $data['LGD_OID'] = $input['ordernumber'];
     $data['LGD_PRODUCTINFO'] = '페이퍼베러 결제 (' . $data['cash_paid'] . '원)';
     //상품명
     $data['price'] = $input['price'];
     $data['points_used'] = $input['points_used'];
     $data['cash_paid'] = $input['cash_paid'];
     $data['LGD_AMOUNT'] = $input['cash_paid'];
     $data['LGD_BUYEREMAIL'] = $input['useremail'];
     $data['LGD_BUYERID'] = $input['useremail'];
     $data['LGD_BUYER'] = $input['username'];
     $data['LGD_TIMESTAMP'] = date('YmdHms');
     //타임스탬프
     $data['LGD_CUSTOM_SKIN'] = "blue";
     $data['LGD_MERTKEY'] = "b00296f6b40cfd26f1363f6a50d20241";
     //상점MertKey(mertkey는 상점관리자 -> 계약정보 -> 상점정보관리에서 확인하실 수 있습니다)
     $data['configPath'] = APPPATH . "lgdacom";
     ///LG유플러스에서 제공한 환경파일("/conf/lgdacom.conf") 위치 지정.
     $data['LGD_BUYERIP'] = $_SERVER['REMOTE_ADDR'];
     //구매자IP
     //$LGD_CASNOTEURL = "https://상점URL/cas_noteurl.php";
     $xpay = new XPayClient($data['configPath'], $data['CST_PLATFORM']);
     $xpay->Init_TX($data['LGD_MID']);
     $data['LGD_HASHDATA'] = md5($data['LGD_MID'] . $data['LGD_OID'] . $data['LGD_AMOUNT'] . $data['LGD_TIMESTAMP'] . $xpay->config[$data['LGD_MID']]);
     $data['LGD_CUSTOM_PROCESSTYPE'] = "TWOTR";
     $result = $data;
     return $result;
 }
예제 #3
0
 function processPayment($args)
 {
     $configPath = _XE_PATH_ . "modules/epay/plugins/xpay/libs";
     $xpay_home = sprintf(_XE_PATH_ . "files/epay/%s", $args->plugin_srl);
     $CST_PLATFORM = Context::get('cst_platform');
     $CST_MID = Context::get('cst_mid');
     $LGD_MID = Context::get('lgd_mid');
     $LGD_PAYKEY = Context::get('lgd_paykey');
     $config = $this->getConfig();
     require_once _XE_PATH_ . "modules/epay/plugins/xpay/libs/XPayClient.php";
     $xpay = new XPayClient($configPath, $config, $CST_PLATFORM);
     $xpay->config[$this->plugin_info->mert_id] = $this->plugin_info->mert_key;
     $xpay->Init_TX($LGD_MID);
     $xpay->Set("LGD_TXNAME", "PaymentByKey");
     $xpay->Set("LGD_PAYKEY", $LGD_PAYKEY);
     $vars = Context::getRequestVars();
     /*
      * 2. 최종결제 요청 결과처리
      *
      * 최종 결제요청 결과 리턴 파라미터는 연동메뉴얼을 참고하시기 바랍니다.
      */
     $utf8VACTName = '';
     $utf8VACTInputName = '';
     if ($xpay->TX()) {
         $utf8ResultMsg = $xpay->Response_Msg();
         $utf8VACTName = $xpay->Response('LGD_SAOWNER');
         $utf8VACTInputName = $xpay->Response('LGD_PAYER');
         // error check
         if ($xpay->Response_Code() != '0000') {
             $output = new Object(-1, $utf8ResultMsg);
             $output->add('state', '3');
             // failure
         } else {
             $output = new Object(0, $utf8ResultMsg);
             if ($this->getPaymethod($xpay->Response('LGD_PAYTYPE', 0)) == 'VA') {
                 $output->add('state', '1');
                 // not completed
             } else {
                 $output->add('state', '2');
                 // completed (success)
             }
         }
         /*
         				//1)결제결과 화면처리(성공,실패 결과 처리를 하시기 바랍니다.)
         				echo "결제요청이 완료되었습니다.  <br>";
         				echo "TX Response_code = " . $xpay->Response_Code() . "<br>";
         				echo "TX Response_msg = " . iconv('EUC-KR','UTF-8',$xpay->Response_Msg()) . "<p>";
         					
         				echo "거래번호 : " . $xpay->Response("LGD_TID",0) . "<br>";
         				echo "상점아이디 : " . $xpay->Response("LGD_MID",0) . "<br>";
         				echo "상점주문번호 : " . $xpay->Response("LGD_OID",0) . "<br>";
         				echo "결제금액 : " . $xpay->Response("LGD_AMOUNT",0) . "<br>";
         				echo "결과코드 : " . $xpay->Response("LGD_RESPCODE",0) . "<br>";
         				echo "결과메세지 : " . $xpay->Response("LGD_RESPMSG",0) . "<p>";
         					
         				$keys = $xpay->Response_Names();
         				foreach($keys as $name) {
         					echo $name . " = " . $xpay->Response($name, 0) . "<br>";
         				}
          
         				echo "<p>";
         */
         /*
         				if( "0000" == $xpay->Response_Code() ) {
         					//최종결제요청 결과 성공 DB처리
         					echo "최종결제요청 결과 성공 DB처리하시기 바랍니다.<br>";
         
         					//최종결제요청 결과 성공 DB처리 실패시 Rollback 처리
         					$isDBOK = true; //DB처리 실패시 false로 변경해 주세요.
         					if( !$isDBOK ) {
         						echo "<p>";
         						$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 = " . iconv('EUC-KR','UTF-8',$xpay->Response_Msg()) . "<p>";
         							
         						if( "0000" == $xpay->Response_Code() ) {
         							echo "자동취소가 정상적으로 완료 되었습니다.<br>";
         						}else{
         							echo "자동취소가 정상적으로 처리되지 않았습니다.<br>";
         						}
         					}            	
         				}else{
         					//최종결제요청 결과 실패 DB처리
         					echo "최종결제요청 결과 실패 DB처리하시기 바랍니다.<br>";            	            
         				}
         */
     } else {
         /*
         				//2)API 요청실패 화면처리
         				echo "결제요청이 실패하였습니다.  <br>";
         				echo "TX Response_code = " . $xpay->Response_Code() . "<br>";
         				echo "TX Response_msg = " . iconv('EUC-KR','UTF-8',$xpay->Response_Msg()) . "<p>";
         					
         				//최종결제요청 결과 실패 DB처리
         				echo "최종결제요청 결과 실패 DB처리하시기 바랍니다.<br>";            	                        
         */
         $utf8ResultMsg = "결제요청이 실패하였습니다.";
         $output = new Object(-1, $utf8ResultMsg);
         $output->add('state', '3');
         // failure
     }
     $output->add('payment_method', $this->getPaymethod($xpay->Response('LGD_PAYTYPE', 0)));
     $output->add('payment_amount', $xpay->Response('LGD_AMOUNT', 0));
     $output->add('result_code', $xpay->Response_Code());
     $output->add('result_message', $utf8ResultMsg);
     $output->add('vact_num', $xpay->Response('LGD_ACCOUNTNUM', 0));
     // 계좌번호
     $output->add('vact_bankname', $xpay->Response('LGD_FINANCENAME', 0));
     //은행코드
     $output->add('vact_bankcode', $xpay->Response('LGD_FINANCECODE', 0));
     //은행코드
     $output->add('vact_name', $utf8VACTName);
     // 예금주
     $output->add('vact_inputname', $utf8VACTInputName);
     // 송금자
     $output->add('vact_regnum', '');
     //송금자 주번
     $output->add('vact_date', '');
     // 송금일자
     $output->add('vact_time', '');
     // 송금시간
     $output->add('pg_tid', $xpay->Response('LGD_TID', 0));
     $original = array();
     $keys = $xpay->Response_Names();
     foreach ($keys as $name) {
         $original[] = $name . " = " . $xpay->Response($name, 0) . "\n";
     }
     $output->add('ORIGINAL', $original);
     return $output;
 }
예제 #4
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;
     }
 }