나이스페이 결제 검증 보강

(cherry picked from commit 8c8099c63eb30c5cfd4678cecedbfd029471065e)
This commit is contained in:
thisgun
2026-08-24 07:44:22 +00:00
parent c4b54a6219
commit d80289ff28
11 changed files with 358 additions and 138 deletions
+1 -1
View File
@@ -402,7 +402,7 @@ if (in_array($_POST['ct_status'], $status_cancel)) {
if (isset($result['ResultCode'])) {
// 실패했다면
if ($result['ResultCode'] !== '2001') {
if (! in_array($result['ResultCode'], array('2001', '2211'), true)) {
$pg_res_cd = $result['ResultCode'];
$pg_res_msg = $result['ResultMsg'];
}
+57 -15
View File
@@ -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') { // 가상계좌
+26 -3
View File
@@ -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);
}
+3 -3
View File
@@ -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';
+2
View File
@@ -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('주문 결제정보를 처리하는 중 오류가 발생했습니다. 결제 취소 여부를 관리자에게 문의해 주십시오.');
}
+28 -23
View File
@@ -46,32 +46,37 @@ $data = array(
'CharSet' => $charSet
);
$response = nicepay_reqPost($data, $escrowRequestURL);
$nice_result = json_decode($response, true);
// 성공이면
if (isset($nice_result['ResultCode']) && $nice_result['ResultCode'] === 'C000') {
} else {
// C000 이 아니면 다 실패
$response = nicepay_reqPost($data, $escrowRequestURL);
$nice_result = json_decode($response, true);
if (!is_array($nice_result)) {
$nice_result = array();
}
/**********************
* 4. 배송 등록 결과 *
**********************/
$resultCode = isset($nice_result['ResultCode']) ? $nice_result['ResultCode'] : ''; // 결과코드
$resultMsg = isset($nice_result['ResultMsg']) ? $nice_result['ResultMsg'] : '나이스페이 응답을 확인할 수 없습니다.'; // 결과내용
$dlv_date = isset($nice_result['ProcessDate']) ? $nice_result['ProcessDate'] : '';
$dlv_time = isset($nice_result['ProcessTime']) ? $nice_result['ProcessTime'] : '';
// 성공이면
if ($resultCode === 'C000') {
} else {
// C000 이 아니면 다 실패
/*
C002 에스크로 가맹점 아님
C003 에스크로 거래만 배송등록 가능
C004 에스크로결제 신청내역 미존재
C005 에스크로배송등록 불가상태
C006 거래내역이 존재하지 않음.
C007 취소된 거래는 배송등록 불가
*/
}
/**********************
* 4. 배송 등록 결과 *
**********************/
$resultCode = $nice_result['ResultCode']; // 결과코드 ("00"이면 지불 성공)
$resultMsg = $nice_result['ResultMsg']; // 결과내용 (지불결과에 대한 설명)
$dlv_date = $nice_result['ProcessDate'];
$dlv_time = $nice_result['ProcessTime'];
C007 취소된 거래는 배송등록 불가
*/
alert('나이스페이 에스크로 배송등록이 실패했습니다.\\n\\n'.$resultCode.' : '.$resultMsg);
}
+61 -19
View File
@@ -17,14 +17,22 @@ $authToken = isset($_POST['AuthToken']) ? clean_xss_tags($_POST['AuthToken']) :
$payMethod = isset($_POST['PayMethod']) ? clean_xss_tags($_POST['PayMethod']) : ''; // payment method
$mid = isset($_POST['MID']) ? clean_xss_tags($_POST['MID']) : ''; // merchant id
$moid = isset($_POST['Moid']) ? addslashes(clean_xss_tags(stripslashes($_POST['Moid']))) : ''; // order number
$amt = isset($_POST['Amt']) ? (int) preg_replace('/[^0-9]/', '', $_POST['Amt']) : 0; // Amount of payment
$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']) : ''; // netCancelURL
if (isset($pp['pp_id']) && $pp['pp_id']) { //개인결제
$session_order_id = get_session('ss_personalpay_id');
$order_price = (int) $pp['pp_price'];
$amt = isset($_POST['Amt']) ? (int) preg_replace('/[^0-9]/', '', $_POST['Amt']) : 0; // Amount of payment
$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']) : ''; // netCancelURL
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,9 +154,9 @@ 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);
die();
@@ -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') { // 가상계좌
+175 -71
View File
@@ -1,15 +1,95 @@
<?php
include_once('./_common.php');
include_once(G5_SHOP_PATH.'/settle_nicepay.inc.php');
/*
*
* 현금결제(실시간 은행계좌이체, 무통장입금)에 대한 현금결제 영수증 발행 요청한다.
*
*/
$od_id = isset($_REQUEST['od_id']) ? safe_replace_regex($_REQUEST['od_id'], 'od_id') : '';
$tx = isset($_REQUEST['tx']) ? clean_xss_tags($_REQUEST['tx'], 1, 1) : '';
include_once('./_common.php');
include_once(G5_SHOP_PATH.'/settle_nicepay.inc.php');
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
alert('올바른 방법으로 이용해 주십시오.', G5_SHOP_URL);
}
if (function_exists('check_request_origin')) {
check_request_origin(G5_SHOP_URL);
}
/*
*
* 현금결제(실시간 은행계좌이체, 무통장입금)에 대한 현금결제 영수증 발행 요청한다.
*
*/
$od_id = isset($_POST['od_id']) ? safe_replace_regex($_POST['od_id'], 'od_id') : '';
$tx = isset($_POST['tx']) ? clean_xss_tags($_POST['tx'], 1, 1) : '';
$reg_num = isset($_POST['id_info']) ? preg_replace('/[^0-9]/', '', $_POST['id_info']) : '';
$useopt = isset($_POST['tr_code']) ? (int)$_POST['tr_code'] : 0;
$buyeremail = isset($_POST['buyeremail']) ? clean_xss_tags($_POST['buyeremail'], 1, 1) : '';
$buyertel = isset($_POST['buyertel']) ? clean_xss_tags($_POST['buyertel'], 1, 1) : '';
if (!$od_id) {
alert('주문번호가 누락되었습니다.', G5_SHOP_URL);
}
if (!in_array($useopt, array(1, 2))) {
alert('현금영수증 발행용도가 올바르지 않습니다.');
}
if (($useopt == 1 && !in_array(strlen($reg_num), array(10, 11, 13))) || ($useopt == 2 && strlen($reg_num) != 10)) {
alert('현금영수증 발급번호를 정확히 입력해 주시기 바랍니다.');
}
if (!function_exists('nicepay_cancel_cash_receipt')) {
function nicepay_cancel_cash_receipt($tid, $order_id, $reason)
{
global $default;
if (!$tid || !$order_id) {
return array('resultCode' => '', 'resultMsg' => '취소 요청 정보가 올바르지 않습니다.');
}
$ediDate = date('c', G5_SERVER_TIME);
$merchantKey = $default['de_nicepay_key'];
$data = array(
'orderId' => $order_id,
'reason' => $reason,
'ediDate' => $ediDate,
'signData' => bin2hex(hash('sha256', $tid.$ediDate.$merchantKey, true)),
'returnCharSet' => 'utf-8'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.nicepay.co.kr/v1/receipt/'.rawurlencode($tid).'/cancel');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json;charset=utf-8',
'Authorization: Basic '.base64_encode($default['de_nicepay_mid'].':'.$merchantKey)
));
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if (!is_array($result)) {
return array('resultCode' => '', 'resultMsg' => '나이스페이 현금영수증 취소 응답을 확인할 수 없습니다.');
}
if (isset($result['signature']) && $result['signature']) {
$response_tid = isset($result['tid']) ? $result['tid'] : '';
$response_order_id = isset($result['orderId']) ? $result['orderId'] : '';
$response_edi_date = isset($result['ediDate']) ? $result['ediDate'] : '';
$response_signature = bin2hex(hash('sha256', $response_tid.$response_order_id.$response_edi_date.$merchantKey, true));
if ($result['signature'] != $response_signature) {
$result['resultCode'] = '9998';
$result['resultMsg'] = '현금영수증 취소 응답 유효성 검증 실패';
}
}
return $result;
}
}
if($tx == 'personalpay') {
$od = sql_fetch(" select * from {$g5['g5_shop_personalpay_table']} where pp_id = '$od_id' ");
@@ -53,10 +133,7 @@ if($tx == 'personalpay') {
$amt_free = (int)$od['od_free_mny'];
}
$reg_num = $id_info;
$useopt = $tr_code;
$currency = 'WON';
$currency = 'WON';
//step1. 요청을 위한 파라미터 설정
$goodName = $goodname; // 상품명
@@ -95,24 +172,39 @@ $data = array(
'CharSet' => 'utf-8',
);
$response = nicepay_reqPost($data, "https://pg-api.nicepay.co.kr/webapi/cash_receipt.jsp");
$result = json_decode($response, true);
// 성공이면
if (isset($result['ResultCode']) && $result['ResultCode'] === '7001') {
// DB 반영
$cash_no = $result['AuthCode']; // 현금영수증 승인번호
$cash = array();
$cash['TID'] = $result['TID'];
$cash['ApplNum'] = $cash_no;
$cash['AuthDate'] = $result['AuthDate'];
$cash_info = serialize($cash);
if($tx == 'personalpay') {
$sql = " update {$g5['g5_shop_personalpay_table']}
$response = nicepay_reqPost($data, "https://pg-api.nicepay.co.kr/webapi/cash_receipt.jsp");
$result = json_decode($response, true);
if (!is_array($result)) {
alert('현금영수증 발급 요청처리가 정상적으로 완료되지 않았습니다.\\n나이스페이 응답을 확인할 수 없습니다.');
}
$result_code = isset($result['ResultCode']) ? $result['ResultCode'] : '';
$result_msg = isset($result['ResultMsg']) ? $result['ResultMsg'] : '';
$result_tid = isset($result['TID']) ? $result['TID'] : '';
$result_auth_code = isset($result['AuthCode']) ? $result['AuthCode'] : '';
$result_auth_date = isset($result['AuthDate']) ? $result['AuthDate'] : '';
// 성공이면
if ($result_code === '7001') {
if (!$result_tid || !$result_auth_code) {
alert('현금영수증 발급 응답 정보가 올바르지 않습니다.');
}
// DB 반영
$cash_no = $result_auth_code; // 현금영수증 승인번호
$cash = array();
$cash['TID'] = $result_tid;
$cash['ApplNum'] = $cash_no;
$cash['AuthDate'] = $result_auth_date;
$cash_info = sql_escape_string(serialize($cash));
$cash_no = sql_escape_string($cash_no);
if($tx == 'personalpay') {
$sql = " update {$g5['g5_shop_personalpay_table']}
set pp_cash = '1',
pp_cash_no = '$cash_no',
pp_cash_info = '$cash_info'
@@ -123,30 +215,42 @@ if (isset($result['ResultCode']) && $result['ResultCode'] === '7001') {
od_cash_no = '$cash_no',
od_cash_info = '$cash_info'
where od_id = '$od_id' ";
}
$sql_result = sql_query($sql, false);
} else {
//2)API 요청 실패 화면처리
$msg = '현금영수증 발급 요청처리가 정상적으로 완료되지 않았습니다.';
$msg .= '\\nTX Response_code = '.$result['ResultCode'];
$msg .= '\\nTX Response_msg = '.$result['ResultMsg'];
alert($msg);
}
}
$sql_result = sql_query($sql, false);
if (!$sql_result) {
$cancel_result = nicepay_cancel_cash_receipt($result_tid, $moid, '쇼핑몰 DB 반영 실패');
$cancel_code = isset($cancel_result['resultCode']) ? $cancel_result['resultCode'] : '';
$cancel_msg = isset($cancel_result['resultMsg']) ? $cancel_result['resultMsg'] : '';
if ($cancel_code === '0000') {
alert_close('현금영수증은 나이스페이에 발급 요청되었으나 쇼핑몰 DB 반영에 실패하여 자동 취소를 요청했습니다.\\n관리자에게 문의해 주세요.\\n현금영수증 거래번호 : '.$result_tid);
}
alert_close('현금영수증은 나이스페이에 발급 요청되었으나 쇼핑몰 DB 반영에 실패했습니다.\\n자동 취소 요청도 정상적으로 완료되지 않았습니다.\\n관리자에게 문의해 주세요.\\n현금영수증 거래번호 : '.$result_tid.'\\n취소 응답 : '.$cancel_code.' '.$cancel_msg);
}
} else {
//2)API 요청 실패 화면처리
$msg = '현금영수증 발급 요청처리가 정상적으로 완료되지 않았습니다.';
$msg .= '\\nTX Response_code = '.$result_code;
$msg .= '\\nTX Response_msg = '.$result_msg;
alert($msg);
}
$g5['title'] = '현금영수증 발급';
include_once(G5_PATH.'/head.sub.php');
?>
<script>
function showreceipt() // 현금 영수증 출력
{
var showreceiptUrl = "https://npg.nicepay.co.kr/issue/IssueLoader.do?type=1&TID=<?php echo($result['TID']); ?>";
window.open(showreceiptUrl,"showreceipt","width=430,height=700, scrollbars=no,resizable=no");
}
function showreceipt() // 현금 영수증 출력
{
var showreceiptUrl = "https://npg.nicepay.co.kr/issue/IssueLoader.do?type=1&TID=" + <?php echo function_exists('get_js_safe_string') ? get_js_safe_string($result_tid) : '"'.str_replace('"', '\\"', $result_tid).'"'; ?>;
window.open(showreceiptUrl,"showreceipt","width=430,height=700, scrollbars=no,resizable=no");
}
</script>
<div id="lg_req_tx" class="new_win">
@@ -159,26 +263,26 @@ function showreceipt() // 현금 영수증 출력
<col>
</colgroup>
<tbody>
<tr>
<th scope="row">결과코드</th>
<td><?php echo $result['ResultCode']; ?></td>
</tr>
<tr>
<th scope="row">결과 메세지</th>
<td><?php echo $result['ResultMsg']; ?></td>
</tr>
<tr>
<th scope="row">현금영수증 거래번호</th>
<td><?php echo $result['TID']; ?></td>
</tr>
<tr>
<th scope="row">현금영수증 승인번호</th>
<td><?php echo $result['AuthCode']; ?></td>
</tr>
<tr>
<th scope="row">승인시간</th>
<td><?php echo preg_replace("/([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/", "\\1-\\2-\\3 \\4:\\5:\\6", $result['AuthDate']); ?></td>
</tr>
<tr>
<th scope="row">결과코드</th>
<td><?php echo get_text($result_code); ?></td>
</tr>
<tr>
<th scope="row">결과 메세지</th>
<td><?php echo get_text($result_msg); ?></td>
</tr>
<tr>
<th scope="row">현금영수증 거래번호</th>
<td><?php echo get_text($result_tid); ?></td>
</tr>
<tr>
<th scope="row">현금영수증 승인번호</th>
<td><?php echo get_text($result_auth_code); ?></td>
</tr>
<tr>
<th scope="row">승인시간</th>
<td><?php echo get_text(preg_replace("/([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/", "\\1-\\2-\\3 \\4:\\5:\\6", $result_auth_date)); ?></td>
</tr>
<tr>
<th scope="row">현금영수증 URL</th>
<td>
+1 -1
View File
@@ -672,7 +672,7 @@ $exists_order = sql_fetch($exists_sql);
// 주문정보 입력 오류시 결제 취소
if(! $result || ! (isset($exists_order['od_id']) && $od_id && $exists_order['od_id'] === $od_id)) {
if($tno) {
$cancel_msg = '주문정보 입력 오류 : '.$sql;
$cancel_msg = '주문정보 입력 오류';
include G5_SHOP_PATH.'/cancel_pg.inc.php';
}
+2 -2
View File
@@ -144,12 +144,12 @@ if($od['od_tno']) {
$res_cd = $result['ResultCode'];
// 실패했다면
if ($result['ResultCode'] !== '2001') {
if (! in_array($result['ResultCode'], array('2001', '2211'), true)) {
$res_msg = $result['ResultMsg'];
}
}
if($res_cd != '2001') {
if(! in_array($res_cd, array('2001', '2211'), true)) {
alert($res_msg.' 코드 : '.$res_cd);
}
break;
+2
View File
@@ -234,6 +234,7 @@ if(!$result) {
break;
}
if(function_exists('add_order_post_log')) add_order_post_log($cancel_msg);
die('개인결제 정보를 처리하는 중 오류가 발생했습니다. 결제 취소 여부를 관리자에게 문의해 주십시오.');
}
@@ -285,6 +286,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('주문 결제정보를 처리하는 중 오류가 발생했습니다. 결제 취소 여부를 관리자에게 문의해 주십시오.');
}