나이스페이 결제 검증과 영수증 처리 보강

(cherry picked from commit 8bcd1bcbea25371bd0a5b196b71d2c1b4308479a)
This commit is contained in:
thisgun committed 2026-08-24 07:44:22 +00:00
1 parent 5a36b2d85d
commit 8e7ec335c3
9 files changed
+136 -39

No files matched your search

+22
View File
@@ -48,6 +48,14 @@ if ($Signature != $authSignData) {
alert("유효성 검증이 틀려서 결제를 진행할수 없습니다.");
}
if (! nicepay_is_allowed_api_url($nextAppURL, array('/webapi/pay_process.jsp'))) {
alert("승인 요청 url이 올바르지 않습니다.", G5_SHOP_URL);
}
if (! nicepay_is_allowed_api_url($netCancelURL, array('/webapi/cancel_process.jsp'))) {
alert("망취소 요청 url이 올바르지 않습니다.", G5_SHOP_URL);
}
// API CALL foreach example
if (! function_exists('jsonRespDump')) {
function jsonRespDump($resp){
@@ -118,6 +126,8 @@ if($authResultCode === "0000"){
$ResultMsg = nicepay_res('ResultMsg', $respArr);
$tno = nicepay_res('TID', $respArr);
$response_amt = nicepay_res('Amt', $respArr, 0);
$response_mid = nicepay_res('MID', $respArr);
$response_moid = nicepay_res('Moid', $respArr);
$amount = (int) $response_amt;
$app_time = nicepay_res('AuthDate', $respArr);
$pay_method = nicepay_res('PayMethod', $respArr);
@@ -137,6 +147,18 @@ if($authResultCode === "0000"){
alert("승인 응답 유효성 검증이 틀려서 결제를 진행할수 없습니다.", G5_SHOP_URL);
}
if ($response_mid != $mid || $response_moid != $moid) {
if($amount > 0) {
$od_id = $moid;
$cancel_msg = '승인 응답 주문정보 불일치';
$cancelAmt = $amount;
$partialCancelCode = 0;
include G5_SHOP_PATH.'/nicepay/cancel_process.php';
}
alert("승인 응답 주문정보가 틀려서 결제를 진행할수 없습니다.", G5_SHOP_URL);
}
if ($amount != $order_price) {
if($amount > 0) {
$od_id = $moid;
+10
View File
@@ -352,6 +352,13 @@ $order_price = $tot_od_price + $send_cost + $send_cost2 - $tot_sc_cp_price - $od
$od_status = '주문';
$od_tno = '';
// PG사의 가상계좌 또는 계좌이체의 자동 현금영수증 초기배열값
$pg_receipt_infos = array(
'od_cash' => 0,
'od_cash_no' => '',
'od_cash_info' => '',
);
if (function_exists('check_payment_method')) {
check_payment_method($od_settle_case);
}
@@ -699,6 +706,9 @@ $sql = " insert {$g5['g5_shop_order_table']}
od_ip = '$REMOTE_ADDR',
od_settle_case = '$od_settle_case',
od_other_pay_type = '$od_other_pay_type',
od_cash = '{$pg_receipt_infos['od_cash']}',
od_cash_no = '{$pg_receipt_infos['od_cash_no']}',
od_cash_info = '{$pg_receipt_infos['od_cash_info']}',
od_test = '{$default['de_card_test']}'
";
$result = sql_query($sql, false);
+11 -7
View File
@@ -438,13 +438,17 @@ if($od['od_pg'] == 'lg') {
$cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');';
} else if($od['od_pg'] == 'toss') {
$cash_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/mids/si_'.$config['cf_lg_mid'].'/orders/'.$od['od_id'].'/cash-receipt?ref=dashboard\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') {
$cash = unserialize($od['od_cash_info']);
$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';
} else if($od['od_pg'] == 'nicepay') {
$cash_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=1&TID='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else {
require_once G5_SHOP_PATH.'/settle_kcp.inc.php';
} else if($od['od_pg'] == 'inicis') {
$cash = unserialize($od['od_cash_info']);
$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';
} else if($od['od_pg'] == 'nicepay') {
$cash = $od['od_cash_info'] ? unserialize($od['od_cash_info']) : array();
if(!is_array($cash))
$cash = array();
$cash_tid = isset($cash['TID']) && $cash['TID'] ? $cash['TID'] : $od['od_tno'];
$cash_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=1&TID='.$cash_tid.'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else {
require_once G5_SHOP_PATH.'/settle_kcp.inc.php';
$cash = unserialize($od['od_cash_info']);
$cash_receipt_script = 'window.open(\''.G5_CASH_RECEIPT_URL.$default['de_kcp_mid'].'&orderid='.$od_id.'&bill_yn=Y&authno='.$cash['receipt_no'].'\', \'taxsave_receipt\', \'width=360,height=647,scrollbars=0,menus=0\');';
+6 -2
View File
@@ -232,7 +232,11 @@ if($pp['pp_pg'] == 'lg') {
$cash = unserialize($pp['pp_cash_info']);
$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';
} else if($pp['pp_pg'] == 'nicepay') {
$cash_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=1&TID='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
$cash = $pp['pp_cash_info'] ? unserialize($pp['pp_cash_info']) : array();
if(!is_array($cash))
$cash = array();
$cash_tid = isset($cash['TID']) && $cash['TID'] ? $cash['TID'] : $pp['pp_tno'];
$cash_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=1&TID='.$cash_tid.'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else {
require_once G5_SHOP_PATH.'/settle_kcp.inc.php';
@@ -326,4 +330,4 @@ if($pp['pp_pg'] == 'lg') {
<!-- } 개인결제상세내역 끝 -->
<?php
include_once(G5_MSHOP_PATH.'/_tail.php');
include_once(G5_MSHOP_PATH.'/_tail.php');