나이스페이 결제 검증 보강
(cherry picked from commit 8c8099c63eb30c5cfd4678cecedbfd029471065e)
This commit is contained in:
1 parent
c4b54a6219
commit
d80289ff28
11 files changed
+358
-138
No files matched your search
@@ -21,10 +21,18 @@ $amt = isset($_POST['Amt']) ? (int) preg_replace('/[^0-9]/', '', $_POST['Amt'])
|
||||
$reqReserved = isset($_POST['ReqReserved']) ? clean_xss_tags($_POST['ReqReserved']) : ''; // mall custom field
|
||||
$netCancelURL = isset($_POST['NetCancelURL']) ? clean_xss_tags($_POST['NetCancelURL']) : ''; // netCancelURL
|
||||
$Signature = isset($_POST['Signature']) ? clean_xss_tags($_POST['Signature']) : ''; // authentication signature
|
||||
|
||||
if (isset($pp['pp_id']) && $pp['pp_id']) { //개인결제
|
||||
$session_order_id = get_session('ss_personalpay_id');
|
||||
$order_price = (int) $pp['pp_price'];
|
||||
|
||||
if($authResultCode !== "0000"){
|
||||
//When authentication fail
|
||||
$ResultCode = $authResultCode;
|
||||
$ResultMsg = $authResultMsg;
|
||||
|
||||
alert($ResultMsg.' 실패 코드 : '.$ResultCode);
|
||||
}
|
||||
|
||||
if (isset($pp['pp_id']) && $pp['pp_id']) { //개인결제
|
||||
$session_order_id = get_session('ss_personalpay_id');
|
||||
$order_price = (int) $pp['pp_price'];
|
||||
} else {
|
||||
$session_order_id = get_session('ss_order_id'); // 쇼핑몰 일반결제
|
||||
}
|
||||
@@ -51,13 +59,27 @@ if (! function_exists('jsonRespDump')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('nicepay_res')) {
|
||||
function nicepay_res($key, $data, $default_val='') {
|
||||
$response_val = isset($data[$key]) ? $data[$key] : $default_val;
|
||||
|
||||
return ($response_val ? $response_val : $default_val);
|
||||
}
|
||||
}
|
||||
if (! function_exists('nicepay_res')) {
|
||||
function nicepay_res($key, $data, $default_val='') {
|
||||
$response_val = isset($data[$key]) ? $data[$key] : $default_val;
|
||||
|
||||
return ($response_val ? $response_val : $default_val);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('nicepay_expected_pay_result')) {
|
||||
function nicepay_expected_pay_result($settle_case) {
|
||||
$pay_results = array(
|
||||
'신용카드' => array('PayMethod'=>'CARD', 'ResultCode'=>'3001'),
|
||||
'간편결제' => array('PayMethod'=>'CARD', 'ResultCode'=>'3001'),
|
||||
'계좌이체' => array('PayMethod'=>'BANK', 'ResultCode'=>'4000'),
|
||||
'가상계좌' => array('PayMethod'=>'VBANK', 'ResultCode'=>'4100'),
|
||||
'휴대폰' => array('PayMethod'=>'CELLPHONE', 'ResultCode'=>'A000')
|
||||
);
|
||||
|
||||
return isset($pay_results[$settle_case]) ? $pay_results[$settle_case] : false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************************
|
||||
@@ -132,8 +154,8 @@ if($authResultCode === "0000"){
|
||||
$app_time = nicepay_res('AuthDate', $respArr);
|
||||
$pay_method = nicepay_res('PayMethod', $respArr);
|
||||
$od_app_no = $app_no = nicepay_res('AuthCode', $respArr); // 승인 번호 (신용카드, 계좌이체, 휴대폰)
|
||||
$pay_type = $NICEPAY_METHOD[$pay_method];
|
||||
|
||||
$pay_type = isset($NICEPAY_METHOD[$pay_method]) ? $NICEPAY_METHOD[$pay_method] : '';
|
||||
|
||||
// 승인된 코드가 아니면 결제가 되지 않게 합니다.
|
||||
if (! in_array($ResultCode, array('3001', '4000', '4100', 'A000', '7001'))) {
|
||||
alert($ResultMsg.' 코드 : '.$ResultCode, G5_SHOP_URL);
|
||||
@@ -171,9 +193,29 @@ if($authResultCode === "0000"){
|
||||
alert("승인된 결제금액이 틀리므로 결제를 진행할수 없습니다.", G5_SHOP_URL);
|
||||
}
|
||||
|
||||
$nicepay_settle_case = '';
|
||||
if (isset($pp['pp_id']) && $pp['pp_id'] && isset($pp_settle_case)) {
|
||||
$nicepay_settle_case = $pp_settle_case;
|
||||
} else if (isset($od_settle_case)) {
|
||||
$nicepay_settle_case = $od_settle_case;
|
||||
}
|
||||
|
||||
$expected_pay_result = nicepay_expected_pay_result($nicepay_settle_case);
|
||||
if ($expected_pay_result && ($pay_method !== $expected_pay_result['PayMethod'] || $ResultCode !== $expected_pay_result['ResultCode'])) {
|
||||
if($amount > 0 && $tno) {
|
||||
$od_id = $moid;
|
||||
$cancel_msg = '결제수단 불일치';
|
||||
$cancelAmt = $amount;
|
||||
$partialCancelCode = 0;
|
||||
include G5_SHOP_PATH.'/nicepay/cancel_process.php';
|
||||
}
|
||||
|
||||
alert("선택한 결제수단과 승인된 결제수단이 일치하지 않아 결제를 진행할수 없습니다.", G5_SHOP_URL);
|
||||
}
|
||||
|
||||
if ($ResultCode == '3001') { // 신용카드
|
||||
|
||||
$card_cd = nicepay_res('CardCode', $respArr); // 카드사 코드
|
||||
|
||||
$card_cd = nicepay_res('CardCode', $respArr); // 카드사 코드
|
||||
$card_name = nicepay_res('CardName', $respArr); // 카드 종류
|
||||
|
||||
} else if ($ResultCode == '4100') { // 가상계좌
|
||||
|
||||
@@ -7,13 +7,36 @@ $authResultMsg = isset($_POST['AuthResultMsg']) ? clean_xss_tags($_POST['AuthRes
|
||||
$mid = isset($_POST['MID']) ? clean_xss_tags($_POST['MID']) : ''; // merchant id
|
||||
$moid = isset($_POST['Moid']) ? addslashes(clean_xss_tags(stripslashes($_POST['Moid']))) : ''; // order number
|
||||
|
||||
$session_order_id = get_session('ss_order_id');
|
||||
$session_personalpay_id = get_session('ss_personalpay_id');
|
||||
|
||||
if ($authResultCode !== '0000') {
|
||||
$page_return_url = G5_SHOP_URL;
|
||||
|
||||
if ($moid && ($session_order_id == $moid || $session_personalpay_id == $moid)) {
|
||||
$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$moid' and dt_pg = 'nicepay' ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
if (!empty($row)) {
|
||||
$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(isset($_SESSION['ss_direct']) && $_SESSION['ss_direct'])
|
||||
$page_return_url .= '?sw_direct=1';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
alert('오류 : '.$authResultMsg.' 코드 : '.$authResultCode, $page_return_url);
|
||||
}
|
||||
|
||||
if ($default['de_nicepay_mid'] != $mid) {
|
||||
alert("요청한 상점 mid와 설정된 mid가 틀리므로 결제를 진행할수 없습니다.", G5_SHOP_URL);
|
||||
}
|
||||
|
||||
$session_order_id = get_session('ss_order_id');
|
||||
$session_personalpay_id = get_session('ss_personalpay_id');
|
||||
|
||||
if (!$moid || ($session_order_id != $moid && $session_personalpay_id != $moid)) {
|
||||
alert("요청한 주문번호가 틀려서 결제를 진행할수 없습니다.", G5_SHOP_URL);
|
||||
}
|
||||
|
||||
@@ -728,9 +728,9 @@ if(! $result && (isset($exists_order['od_id']) && $od_id && $exists_order['od_id
|
||||
// 주문정보 입력 오류시 결제 취소
|
||||
if(! $result || ! (isset($exists_order['od_id']) && $od_id && $exists_order['od_id'] === $od_id)) {
|
||||
if($tno) {
|
||||
$cancel_msg = '주문정보 입력 오류 : '.$sql;
|
||||
include G5_SHOP_PATH.'/cancel_pg.inc.php';
|
||||
}
|
||||
$cancel_msg = '주문정보 입력 오류';
|
||||
include G5_SHOP_PATH.'/cancel_pg.inc.php';
|
||||
}
|
||||
|
||||
// 관리자에게 오류 알림 메일발송
|
||||
$error = 'order';
|
||||
|
||||
@@ -256,6 +256,7 @@ if(!$result) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(function_exists('add_order_post_log')) add_order_post_log($cancel_msg);
|
||||
die('개인결제 정보를 처리하는 중 오류가 발생했습니다. 결제 취소 여부를 관리자에게 문의해 주십시오.');
|
||||
}
|
||||
|
||||
@@ -307,6 +308,7 @@ if($pp_receipt_price > 0 && $pp['pp_id'] && $pp['od_id']) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(function_exists('add_order_post_log')) add_order_post_log($cancel_msg);
|
||||
die('주문 결제정보를 처리하는 중 오류가 발생했습니다. 결제 취소 여부를 관리자에게 문의해 주십시오.');
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user