diff --git a/shop/inicis/INIStdPayResult.php b/shop/inicis/INIStdPayResult.php deleted file mode 100644 index 794109c32..000000000 --- a/shop/inicis/INIStdPayResult.php +++ /dev/null @@ -1,28 +0,0 @@ -'.PHP_EOL; - -echo make_order_field($data, $exclude); - -echo ''.PHP_EOL; -?> - -
- - 주문완료 중입니다. 잠시만 기다려 주십시오. -
- - \ No newline at end of file diff --git a/shop/inicis/inipay_result.php b/shop/inicis/inipay_result.php deleted file mode 100644 index ae465b8ed..000000000 --- a/shop/inicis/inipay_result.php +++ /dev/null @@ -1,39 +0,0 @@ - \ No newline at end of file diff --git a/shop/inicis/INIStdPayReturn.php b/shop/inicis/inistdpay_result.php similarity index 82% rename from shop/inicis/INIStdPayReturn.php rename to shop/inicis/inistdpay_result.php index a80686f9f..38c5a72dd 100644 --- a/shop/inicis/INIStdPayReturn.php +++ b/shop/inicis/inistdpay_result.php @@ -1,181 +1,210 @@ -makeHash(signKey, "sha256"); // 가맹점 확인을 위한 signKey를 해시값으로 변경 (SHA-256방식 사용) - $mKey = hash("sha256", $signKey); - - //##################### - // 2.signature 생성 - //##################### - $signParam['authToken'] = $authToken; // 필수 - $signParam['timestamp'] = $timestamp; // 필수 - // signature 데이터 생성 (모듈에서 자동으로 signParam을 알파벳 순으로 정렬후 NVP 방식으로 나열해 hash) - $signature = $util->makeSignature($signParam); - - - //##################### - // 3.API 요청 전문 생성 - //##################### - $authMap['mid'] = $mid; // 필수 - $authMap['authToken'] = $authToken; // 필수 - $authMap['signature'] = $signature; // 필수 - $authMap['timestamp'] = $timestamp; // 필수 - $authMap['charset'] = $charset; // default=UTF-8 - $authMap['format'] = $format; // default=XML - //if(null != notiUrl && notiUrl.length() > 0){ - // authMap.put("notiUrl" ,notiUrl); - //} - - - try { - - $httpUtil = new HttpClient(); - - //##################### - // 4.API 통신 시작 - //##################### - - $authResultString = ""; - if ($httpUtil->processHTTP($authUrl, $authMap)) { - $authResultString = $httpUtil->body; - } else { - echo "Http Connect Error\n"; - echo $httpUtil->errormsg; - - throw new Exception("Http Connect Error"); - } - - //############################################################ - //5.API 통신결과 처리(***가맹점 개발수정***) - //############################################################ - - $resultMap = json_decode($authResultString, true); - - $tid = $resultMap['tid']; - $oid = $resultMap['MOID']; - - /************************* 결제보안 추가 2016-05-18 START ****************************/ - $secureMap['mid'] = $mid; //mid - $secureMap['tstamp'] = $timestamp; //timestemp - $secureMap['MOID'] = $resultMap['MOID']; //MOID - $secureMap['TotPrice'] = $resultMap['TotPrice']; //TotPrice - - // signature 데이터 생성 - $secureSignature = $util->makeSignatureAuth($secureMap); - /************************* 결제보안 추가 2016-05-18 END ****************************/ - - $sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$oid' "; - $row = sql_fetch($sql); - - $data = unserialize(base64_decode($row['dt_data'])); - - if(isset($data['pp_id']) && $data['pp_id']) { - $order_action_url = G5_HTTPS_SHOP_URL.'/personalpayformupdate.php'; - $page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.$data['pp_id']; - } else { - $order_action_url = G5_HTTPS_SHOP_URL.'/orderformupdate.php'; - $page_return_url = G5_SHOP_URL.'/orderform.php'; - if($_SESSION['ss_direct']) - $page_return_url .= '?sw_direct=1'; - } - - if ((strcmp('0000', $resultMap['resultCode']) == 0) && (strcmp($secureSignature, $resultMap['authSignature']) == 0) ) { //결제보안 추가 2016-05-18 - /* * *************************************************************************** - * 여기에 가맹점 내부 DB에 결제 결과를 반영하는 관련 프로그램 코드를 구현한다. - - [중요!] 승인내용에 이상이 없음을 확인한 뒤 가맹점 DB에 해당건이 정상처리 되었음을 반영함 - 처리중 에러 발생시 망취소를 한다. - * **************************************************************************** */ - - // 결제결과 session에 저장 - set_session('resultMap', $resultMap); - - require G5_SHOP_PATH.'/inicis/INIStdPayResult.php'; - exit; - } else { - $s = '(오류코드:'.$resultMap['resultCode'].') '.$resultMap['resultMsg']; - alert($s, $page_return_url); - } - - // 수신결과를 파싱후 resultCode가 "0000"이면 승인성공 이외 실패 - // 가맹점에서 스스로 파싱후 내부 DB 처리 후 화면에 결과 표시 - // payViewType을 popup으로 해서 결제를 하셨을 경우 - // 내부처리후 스크립트를 이용해 opener의 화면 전환처리를 하세요 - //throw new Exception("강제 Exception"); - } catch (Exception $e) { - // $s = $e->getMessage() . ' (오류코드:' . $e->getCode() . ')'; - //#################################### - // 실패시 처리(***가맹점 개발수정***) - //#################################### - //---- db 저장 실패시 등 예외처리----// - $s = $e->getMessage() . ' (오류코드:' . $e->getCode() . ')'; - echo $s; - - //##################### - // 망취소 API - //##################### - - $netcancelResultString = ""; // 망취소 요청 API url(고정, 임의 세팅 금지) - if ($httpUtil->processHTTP($netCancel, $authMap)) { - $netcancelResultString = $httpUtil->body; - } else { - echo "Http Connect Error\n"; - echo $httpUtil->errormsg; - - throw new Exception("Http Connect Error"); - } - - echo "## 망취소 API 결과 ##"; - - $netcancelResultString = str_replace("<", "<", $$netcancelResultString); - $netcancelResultString = str_replace(">", ">", $$netcancelResultString); - - echo "
", $netcancelResultString . "
"; - // 취소 결과 확인 - } - } else { - - //############# - // 인증 실패시 - //############# - echo "
"; - echo "####인증실패####"; - - echo "
" . var_dump($_REQUEST) . "
"; - } -} catch (Exception $e) { - $s = $e->getMessage() . ' (오류코드:' . $e->getCode() . ')'; - echo $s; -} +makeHash(signKey, "sha256"); // 가맹점 확인을 위한 signKey를 해시값으로 변경 (SHA-256방식 사용) + $mKey = hash("sha256", $signKey); + + //##################### + // 2.signature 생성 + //##################### + $signParam['authToken'] = $authToken; // 필수 + $signParam['timestamp'] = $timestamp; // 필수 + // signature 데이터 생성 (모듈에서 자동으로 signParam을 알파벳 순으로 정렬후 NVP 방식으로 나열해 hash) + $signature = $util->makeSignature($signParam); + + + //##################### + // 3.API 요청 전문 생성 + //##################### + $authMap['mid'] = $mid; // 필수 + $authMap['authToken'] = $authToken; // 필수 + $authMap['signature'] = $signature; // 필수 + $authMap['timestamp'] = $timestamp; // 필수 + $authMap['charset'] = $charset; // default=UTF-8 + $authMap['format'] = $format; // default=XML + //if(null != notiUrl && notiUrl.length() > 0){ + // authMap.put("notiUrl" ,notiUrl); + //} + + + try { + + $httpUtil = new HttpClient(); + + //##################### + // 4.API 통신 시작 + //##################### + + $authResultString = ""; + if ($httpUtil->processHTTP($authUrl, $authMap)) { + $authResultString = $httpUtil->body; + } else { + echo "Http Connect Error\n"; + echo $httpUtil->errormsg; + + throw new Exception("Http Connect Error"); + } + + //############################################################ + //5.API 통신결과 처리(***가맹점 개발수정***) + //############################################################ + + $resultMap = json_decode($authResultString, true); + + $tid = $resultMap['tid']; + $oid = $resultMap['MOID']; + + /************************* 결제보안 추가 2016-05-18 START ****************************/ + $secureMap['mid'] = $mid; //mid + $secureMap['tstamp'] = $timestamp; //timestemp + $secureMap['MOID'] = $resultMap['MOID']; //MOID + $secureMap['TotPrice'] = $resultMap['TotPrice']; //TotPrice + + // signature 데이터 생성 + $secureSignature = $util->makeSignatureAuth($secureMap); + /************************* 결제보안 추가 2016-05-18 END ****************************/ + + $sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$oid' "; + $row = sql_fetch($sql); + + $data = unserialize(base64_decode($row['dt_data'])); + + if(isset($data['pp_id']) && $data['pp_id']) { + $page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.$data['pp_id']; + } else { + $page_return_url = G5_SHOP_URL.'/orderform.php'; + if($_SESSION['ss_direct']) + $page_return_url .= '?sw_direct=1'; + } + + if ((strcmp('0000', $resultMap['resultCode']) == 0) && (strcmp($secureSignature, $resultMap['authSignature']) == 0) ) { //결제보안 추가 2016-05-18 + /* * *************************************************************************** + * 여기에 가맹점 내부 DB에 결제 결과를 반영하는 관련 프로그램 코드를 구현한다. + + [중요!] 승인내용에 이상이 없음을 확인한 뒤 가맹점 DB에 해당건이 정상처리 되었음을 반영함 + 처리중 에러 발생시 망취소를 한다. + * **************************************************************************** */ + + //최종결제요청 결과 성공 DB처리 + $tno = $resultMap['tid']; + $amount = $resultMap['TotPrice']; + $app_time = $resultMap['applDate'].$resultMap['applTime']; + $pay_method = $resultMap['payMethod']; + $pay_type = $PAY_METHOD[$pay_method]; + $depositor = $resultMap['VACT_InputName']; + $commid = ''; + $mobile_no = $resultMap['HPP_Num']; + $app_no = $resultMap['applNum']; + $card_name = $CARD_CODE[$resultMap['CARD_Code']]; + switch($pay_type) { + case '계좌이체': + $bank_name = $BANK_CODE[$resultMap['ACCT_BankCode']]; + if ($default['de_escrow_use'] == 1) + $escw_yn = 'Y'; + break; + case '가상계좌': + $bankname = $BANK_CODE[$resultMap['VACT_BankCode']]; + $account = $resultMap['VACT_Num'].' '.$resultMap['VACT_Name']; + $app_no = $resultMap['VACT_Num']; + if ($default['de_escrow_use'] == 1) + $escw_yn = 'Y'; + break; + default: + break; + } + + $inicis_pay_result = true; + + } else { + $s = '(오류코드:'.$resultMap['resultCode'].') '.$resultMap['resultMsg']; + alert($s, $page_return_url); + } + + // 수신결과를 파싱후 resultCode가 "0000"이면 승인성공 이외 실패 + // 가맹점에서 스스로 파싱후 내부 DB 처리 후 화면에 결과 표시 + // payViewType을 popup으로 해서 결제를 하셨을 경우 + // 내부처리후 스크립트를 이용해 opener의 화면 전환처리를 하세요 + //throw new Exception("강제 Exception"); + } catch (Exception $e) { + // $s = $e->getMessage() . ' (오류코드:' . $e->getCode() . ')'; + //#################################### + // 실패시 처리(***가맹점 개발수정***) + //#################################### + //---- db 저장 실패시 등 예외처리----// + $s = $e->getMessage() . ' (오류코드:' . $e->getCode() . ')'; + echo $s; + + //##################### + // 망취소 API + //##################### + + $netcancelResultString = ""; // 망취소 요청 API url(고정, 임의 세팅 금지) + if ($httpUtil->processHTTP($netCancel, $authMap)) { + $netcancelResultString = $httpUtil->body; + } else { + echo "Http Connect Error\n"; + echo $httpUtil->errormsg; + + throw new Exception("Http Connect Error"); + } + + echo "## 망취소 API 결과 ##"; + + $netcancelResultString = str_replace("<", "<", $$netcancelResultString); + $netcancelResultString = str_replace(">", ">", $$netcancelResultString); + + echo "
", $netcancelResultString . "
"; + // 취소 결과 확인 + } + } else { + + //############# + // 인증 실패시 + //############# + echo "
"; + echo "####인증실패####"; + + echo "
" . var_dump($_REQUEST) . "
"; + } +} catch (Exception $e) { + $s = $e->getMessage() . ' (오류코드:' . $e->getCode() . ')'; + echo $s; +} + +if( !$inicis_pay_result ){ + die("

결제 에러가 일어났습니다. 에러 이유는 위와 같습니다."); +} ?> \ No newline at end of file diff --git a/shop/inicis/inistdpay_return.php b/shop/inicis/inistdpay_return.php new file mode 100644 index 000000000..773392873 --- /dev/null +++ b/shop/inicis/inistdpay_return.php @@ -0,0 +1,80 @@ +()\[\]\{\}]/i", "", strip_tags($_POST['orderNumber'])) : 0; +$session_order_num = get_session('ss_order_inicis_id'); + +if( !$orderNumber ){ + alert("주문번호가 없습니다."); +} + +$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$orderNumber' "; +$row = sql_fetch($sql); + +if( empty($row) ){ + alert("임시 주문정보가 저장되지 않았습니다."); +} + +$data = unserialize(base64_decode($row['dt_data'])); + +$params = array(); +$var_datas = array(); + +foreach($data as $key=>$value) { + if(is_array($value)) { + foreach($value as $k=>$v) { + $_POST[$key][$k] = $params[$key][$k] = clean_xss_tags(strip_tags($v)); + } + } else { + $_POST[$key] = $params[$key] = clean_xss_tags(strip_tags($value)); + } +} + +if(isset($data['pp_id']) && $data['pp_id']) { //개인결제 + + foreach($params as $key=>$value){ + + if( in_array($key, array('pp_name', 'pp_email', 'pp_hp', 'pp_settle_case')) ){ + + $var_datas[$key] = $value; + + } + + } + + @extract($var_datas); + + include_once(G5_SHOP_PATH.'/personalpayformupdate.php'); + +} else { //상점주문 + + foreach($params as $key=>$value){ + + if( in_array($key, array('od_price', 'od_name', 'od_tel', 'od_hp', 'od_email', 'od_memo', 'od_settle_case', 'max_temp_point', 'od_temp_point', 'od_bank_account', 'od_deposit_name', 'od_test', 'od_ip', 'od_zip', 'od_addr1', 'od_addr2', 'od_addr3', 'od_addr_jibeon', 'od_b_name', 'od_b_tel', 'od_b_hp', 'od_b_addr1', 'od_b_addr2', 'od_b_addr3', 'od_b_addr_jibeon', 'od_b_zip', 'od_send_cost', 'od_send_cost2', 'od_hope_date')) ){ + + $var_datas[$key] = $value; + + } + + } + + @extract($var_datas); + + $od_send_cost = (int) $_POST['od_send_cost']; + $od_send_cost2 = (int) $_POST['od_send_cost2']; + + include_once(G5_SHOP_PATH.'/orderformupdate.php'); +} +?> \ No newline at end of file diff --git a/shop/orderformupdate.php b/shop/orderformupdate.php index 32ba19746..ae775f6a2 100644 --- a/shop/orderformupdate.php +++ b/shop/orderformupdate.php @@ -283,7 +283,7 @@ else if ($od_settle_case == "계좌이체") include G5_SHOP_PATH.'/lg/xpay_result.php'; break; case 'inicis': - include G5_SHOP_PATH.'/inicis/inipay_result.php'; + include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; @@ -310,7 +310,7 @@ else if ($od_settle_case == "가상계좌") include G5_SHOP_PATH.'/lg/xpay_result.php'; break; case 'inicis': - include G5_SHOP_PATH.'/inicis/inipay_result.php'; + include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; $od_app_no = $app_no; break; default: @@ -335,7 +335,7 @@ else if ($od_settle_case == "휴대폰") include G5_SHOP_PATH.'/lg/xpay_result.php'; break; case 'inicis': - include G5_SHOP_PATH.'/inicis/inipay_result.php'; + include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; @@ -359,7 +359,7 @@ else if ($od_settle_case == "신용카드") include G5_SHOP_PATH.'/lg/xpay_result.php'; break; case 'inicis': - include G5_SHOP_PATH.'/inicis/inipay_result.php'; + include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; @@ -385,7 +385,7 @@ else if ($od_settle_case == "간편결제") include G5_SHOP_PATH.'/lg/xpay_result.php'; break; case 'inicis': - include G5_SHOP_PATH.'/inicis/inipay_result.php'; + include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; diff --git a/shop/personalpayformupdate.php b/shop/personalpayformupdate.php index b53d6f54b..a5a7c15d5 100644 --- a/shop/personalpayformupdate.php +++ b/shop/personalpayformupdate.php @@ -27,7 +27,7 @@ if ($pp_settle_case == "계좌이체") include G5_SHOP_PATH.'/lg/xpay_result.php'; break; case 'inicis': - include G5_SHOP_PATH.'/inicis/inipay_result.php'; + include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; @@ -49,7 +49,7 @@ else if ($pp_settle_case == "가상계좌") include G5_SHOP_PATH.'/lg/xpay_result.php'; break; case 'inicis': - include G5_SHOP_PATH.'/inicis/inipay_result.php'; + include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; @@ -71,7 +71,7 @@ else if ($pp_settle_case == "휴대폰") include G5_SHOP_PATH.'/lg/xpay_result.php'; break; case 'inicis': - include G5_SHOP_PATH.'/inicis/inipay_result.php'; + include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; @@ -91,7 +91,7 @@ else if ($pp_settle_case == "신용카드") include G5_SHOP_PATH.'/lg/xpay_result.php'; break; case 'inicis': - include G5_SHOP_PATH.'/inicis/inipay_result.php'; + include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; diff --git a/shop/settle_inicis.inc.php b/shop/settle_inicis.inc.php index f5ee8fb05..f5e4caacc 100644 --- a/shop/settle_inicis.inc.php +++ b/shop/settle_inicis.inc.php @@ -35,7 +35,7 @@ else { /************************** * 1. 라이브러리 인클루드 * **************************/ -require(G5_SHOP_PATH.'/inicis/libs/INILib.php'); +require_once(G5_SHOP_PATH.'/inicis/libs/INILib.php'); require_once(G5_SHOP_PATH.'/inicis/libs/INIStdPayUtil.php'); require_once(G5_SHOP_PATH.'/inicis/libs/sha256.inc.php'); @@ -67,7 +67,7 @@ $siteDomain = G5_SHOP_URL.'/inicis'; //가맹점 도메인 입력 // Ex) returnURL이 http://localhost:8082/demo/INIpayStdSample/INIStdPayReturn.php 라면 // http://localhost:8082/demo/INIpayStdSample 까지만 기입한다. -$returnUrl = $siteDomain.'/INIStdPayReturn.php'; +$returnUrl = $siteDomain.'/inistdpay_return.php'; $closeUrl = $siteDomain.'/close.php'; $popupUrl = $siteDomain.'/popup.php';