security: KVE-2026-2140 주문 보호와 5.6.39 보안 업데이트 배포
This commit is contained in:
1 parent
2517343d51
commit
f7aa440a80
43 files changed
+1510
-328
No files matched your search
+51
-14
@@ -7,12 +7,8 @@ if (function_exists('check_request_origin')) check_request_origin(G5_SHOP_URL);
|
||||
if(empty($_POST))
|
||||
die('정보가 넘어오지 않았습니다.');
|
||||
|
||||
// 일정 기간이 경과된 임시 데이터 삭제
|
||||
/*
|
||||
$limit_time = date("Y-m-d H:i:s", (G5_SERVER_TIME - 86400 * 1));
|
||||
$sql = " delete from {$g5['g5_shop_order_data_table']} where dt_type = '1' and dt_time < '$limit_time' ";
|
||||
sql_query($sql);
|
||||
*/
|
||||
include_once(G5_LIB_PATH.'/shop_order_access.lib.php');
|
||||
shop_order_checkout_restore();
|
||||
|
||||
$od_settle_case = isset($_POST['od_settle_case']) ? clean_xss_tags($_POST['od_settle_case'], 1, 1) : '';
|
||||
if ($od_settle_case === 'KAKAOPAY') {
|
||||
@@ -29,10 +25,14 @@ $_POST['od_ip'] = function_exists('get_real_client_ip') ? get_real_client_ip()
|
||||
if(isset($_POST['pp_id']) && $_POST['pp_id']) {
|
||||
$od_id = get_session('ss_personalpay_id');
|
||||
$cart_id = 0;
|
||||
if (!is_string($_POST['pp_id']) || $_POST['pp_id'] !== (string)$od_id ||
|
||||
!shop_order_access_id((string)$od_id) || !get_session('ss_personalpay_hash')) shop_order_access_fail();
|
||||
|
||||
$sql = "select pp_use, pp_tno from {$g5['g5_shop_personalpay_table']} where pp_id = '$od_id' ";
|
||||
$sql = "select pp_use, pp_tno, pp_price, pp_time from {$g5['g5_shop_personalpay_table']} where pp_id = '$od_id' ";
|
||||
$pp_row = sql_fetch($sql);
|
||||
|
||||
if (!$pp_row || md5($od_id.$pp_row['pp_price'].$pp_row['pp_time']) !== get_session('ss_personalpay_hash')) shop_order_access_fail();
|
||||
|
||||
if( $pp_row['pp_tno'] ){
|
||||
die('해당 개인결제는 이미 결제되었습니다.');
|
||||
} else if( ! $pp_row['pp_use'] ){
|
||||
@@ -55,6 +55,29 @@ if(isset($_POST['pp_id']) && $_POST['pp_id']) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!shop_order_access_id((string)$od_id) || (empty($_POST['pp_id']) && !$cart_id)) shop_order_access_fail();
|
||||
|
||||
// 비회원 비밀번호는 HTML 복원용 데이터와 분리하고 서버 세션에 해시만 보관한다.
|
||||
$order_password_hash = '';
|
||||
if (empty($member['mb_id']) && empty($_POST['pp_id'])) {
|
||||
if (isset($_POST['od_pwd']) && !is_string($_POST['od_pwd'])) shop_order_access_fail();
|
||||
$order_password_hash = get_encrypt_string(isset($_POST['od_pwd']) ? $_POST['od_pwd'] : shop_order_random_hex(16));
|
||||
}
|
||||
unset($_POST['od_pwd']);
|
||||
|
||||
|
||||
$default_pg = $default['de_pg_service'];
|
||||
if (function_exists('is_use_easypay') && is_use_easypay('global_nhnkcp') &&
|
||||
isset($_POST['nhnkcp_pay_case']) && $_POST['nhnkcp_pay_case'] === 'naverpay') {
|
||||
$default_pg = 'kcp';
|
||||
}
|
||||
|
||||
if( $od_settle_case == '삼성페이' ){ //현재 삼성페이인 경우에는 pg를 inicis로 처리
|
||||
$default_pg = 'inicis';
|
||||
}
|
||||
|
||||
shop_order_state_can_save((string)$od_id);
|
||||
$_POST = shop_order_filter_data($_POST, $default_pg);
|
||||
$dt_data = base64_encode(serialize($_POST));
|
||||
|
||||
// 동일한 주문번호가 있는지 체크
|
||||
@@ -63,12 +86,6 @@ $row = sql_fetch($sql);
|
||||
if($row['cnt'])
|
||||
sql_query(" delete from {$g5['g5_shop_order_data_table']} where od_id = '$od_id' ");
|
||||
|
||||
$default_pg = $default['de_pg_service'];
|
||||
|
||||
if( $od_settle_case == '삼성페이' ){ //현재 삼성페이인 경우에는 pg를 inicis로 처리
|
||||
$default_pg = 'inicis';
|
||||
}
|
||||
|
||||
$sql = " insert into {$g5['g5_shop_order_data_table']}
|
||||
set od_id = '$od_id',
|
||||
cart_id = '$cart_id',
|
||||
@@ -76,6 +93,26 @@ $sql = " insert into {$g5['g5_shop_order_data_table']}
|
||||
dt_pg = '$default_pg',
|
||||
dt_data = '$dt_data',
|
||||
dt_time = '".G5_TIME_YMDHIS."' ";
|
||||
sql_query($sql);
|
||||
if (!sql_query($sql, false)) shop_order_access_fail();
|
||||
|
||||
// 요청 본문을 그대로 인증 상태로 사용하지 않는다. 세션은 응답 HTML에 노출하지 않는다.
|
||||
$states = get_session('ss_order_data_access');
|
||||
if (!is_array($states)) $states = array();
|
||||
foreach ($states as $key => $state) {
|
||||
if ($state['expires'] < G5_SERVER_TIME) unset($states[$key]);
|
||||
}
|
||||
$states[(string)$od_id] = array(
|
||||
'pg' => $default_pg,
|
||||
'member' => isset($member['mb_id']) ? (string)$member['mb_id'] : '',
|
||||
'cart' => (string)$cart_id,
|
||||
'personal' => !empty($_POST['pp_id']),
|
||||
'personal_hash' => get_session('ss_personalpay_hash'),
|
||||
'direct' => (bool)get_session('ss_direct'),
|
||||
'time' => G5_TIME_YMDHIS,
|
||||
'expires' => G5_SERVER_TIME + (defined('G5_ORDER_DATA_ACCESS_TTL') ? G5_ORDER_DATA_ACCESS_TTL : 7200),
|
||||
'digest' => hash('sha256', $dt_data),
|
||||
'password_hash' => $order_password_hash,
|
||||
);
|
||||
$states[(string)$od_id] = shop_order_state_save((string)$od_id, $states[(string)$od_id]);
|
||||
|
||||
die('');
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
|
||||
if (function_exists('shop_order_state_cancel')) shop_order_state_cancel('cancel_pending');
|
||||
|
||||
// locale ko_KR.euc-kr 로 설정
|
||||
setlocale(LC_CTYPE, 'ko_KR.euc-kr');
|
||||
|
||||
@@ -75,4 +77,5 @@ if ( $req_tx == "pay" )
|
||||
/* ============================================================================== */
|
||||
|
||||
// locale 설정 초기화
|
||||
setlocale(LC_CTYPE, '');
|
||||
setlocale(LC_CTYPE, '');
|
||||
if (isset($res_cd) && $res_cd === '0000' && function_exists('shop_order_state_cancel')) shop_order_state_cancel('cancelled');
|
||||
+14
-11
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||
include_once(G5_LIB_PATH.'/shop_order_access.lib.php');
|
||||
|
||||
require_once(G5_SHOP_PATH.'/settle_'.$default['de_pg_service'].'.inc.php');
|
||||
|
||||
@@ -24,7 +25,9 @@ if(function_exists('is_use_easypay') && is_use_easypay('global_nhnkcp')){ //
|
||||
|
||||
?>
|
||||
|
||||
<script src="<?php echo G5_JS_URL; ?>/shop.order-state.js"></script>
|
||||
<form name="forderform" id="forderform" method="post" action="<?php echo $order_action_url; ?>" autocomplete="off">
|
||||
<?php echo shop_order_checkout_fields((string)$od_id, false); ?>
|
||||
<div id="sod_frm" class="sod_frm_pc">
|
||||
<!-- 주문상품 확인 시작 { -->
|
||||
<div class="tbl_head03 tbl_wrap od_prd_list">
|
||||
@@ -1622,14 +1625,14 @@ function forderform_check(f)
|
||||
|
||||
<?php if($default['de_escrow_use']) { ?>
|
||||
f.cardUseEscrow.value = 'true';
|
||||
f.escrowProducts.value = JSON.stringify(<?php echo json_encode($escrow_products, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>);
|
||||
f.escrowProducts.value = JSON.stringify(<?php echo json_encode($escrow_products); ?>);
|
||||
<?php } ?>
|
||||
|
||||
f.cardflowMode.value = 'DEFAULT';
|
||||
f.cardeasyPay.value = '';
|
||||
if(settle_method == "간편결제") {
|
||||
var provider = $("input[name=od_settle_case]:checked").attr("data-pay");
|
||||
var providers = <?php echo json_encode(array_values(array_map(function ($provider) { return $provider[1]; }, shop_easypay_catalog('toss')))); ?>;
|
||||
var providers = <?php echo json_encode(shop_order_toss_providers()); ?>;
|
||||
if (providers.indexOf(provider) === -1) {
|
||||
alert('간편결제 수단을 다시 선택해 주세요.');
|
||||
return false;
|
||||
@@ -1648,15 +1651,15 @@ function forderform_check(f)
|
||||
if(f.method.value != "무통장") {
|
||||
// 주문정보 임시저장
|
||||
var order_data = $(f).serialize();
|
||||
var save_result = "";
|
||||
var save_result = "결제 요청을 저장하지 못했습니다.";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: order_data,
|
||||
url: g5_url+"/shop/ajax.orderdatasave.php",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
save_result = data;
|
||||
success: function(data, textStatus, xhr) {
|
||||
save_result = data || g5_order_state_accept(xhr);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1687,15 +1690,15 @@ function forderform_check(f)
|
||||
if(f.gopaymethod.value != "무통장") {
|
||||
// 주문정보 임시저장
|
||||
var order_data = $(f).serialize();
|
||||
var save_result = "";
|
||||
var save_result = "결제 요청을 저장하지 못했습니다.";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: order_data,
|
||||
url: g5_url+"/shop/ajax.orderdatasave.php",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
save_result = data;
|
||||
success: function(data, textStatus, xhr) {
|
||||
save_result = data || g5_order_state_accept(xhr);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1730,15 +1733,15 @@ function forderform_check(f)
|
||||
if(f.PayMethod.value != "무통장") {
|
||||
// 주문정보 임시저장
|
||||
var order_data = $(f).serialize();
|
||||
var save_result = "";
|
||||
var save_result = "결제 요청을 저장하지 못했습니다.";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: order_data,
|
||||
url: g5_url+"/shop/ajax.orderdatasave.php",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
save_result = data;
|
||||
success: function(data, textStatus, xhr) {
|
||||
save_result = data || g5_order_state_accept(xhr);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
include_once(G5_LIB_PATH.'/shop_order_access.lib.php');
|
||||
shop_order_state_prepare(false);
|
||||
// PG 호출 전에 저장된 비회원 비밀번호 해시의 주문 소유권을 확인한다.
|
||||
$saved_order_password = ($is_member || $od_settle_case === '무통장') ? null : shop_order_access_password((string)get_session('ss_order_id'));
|
||||
|
||||
|
||||
// 구 주문서나 직접 POST로도 SIRK 전용 결제를 다시 시작하지 않는다.
|
||||
if (isset($od_settle_case) && $od_settle_case === 'KAKAOPAY') {
|
||||
@@ -553,7 +558,8 @@ if($tno) {
|
||||
if ($is_member)
|
||||
$od_pwd = $member['mb_password'];
|
||||
else
|
||||
$od_pwd = isset($_POST['od_pwd']) ? get_encrypt_string($_POST['od_pwd']) : get_encrypt_string(mt_rand());
|
||||
$od_pwd = $saved_order_password !== null ? $saved_order_password :
|
||||
(isset($_POST['od_pwd']) ? get_encrypt_string($_POST['od_pwd']) : get_encrypt_string(mt_rand()));
|
||||
|
||||
// 주문번호를 얻는다.
|
||||
$od_id = get_session('ss_order_id');
|
||||
@@ -653,6 +659,7 @@ $sql = " insert {$g5['g5_shop_order_table']}
|
||||
od_cash_info = '{$pg_receipt_infos['od_cash_info']}',
|
||||
od_test = '{$default['de_card_test']}'
|
||||
";
|
||||
shop_order_state_finalizing();
|
||||
$result = sql_query($sql, false);
|
||||
|
||||
// 정말로 insert 가 되었는지 한번더 체크한다.
|
||||
@@ -984,14 +991,13 @@ $uid = function_exists('get_shop_uid') ? get_shop_uid('order', $od_id, G5_TIME_Y
|
||||
set_session('ss_orderview_uid', $uid);
|
||||
|
||||
// 주문 정보 임시 데이터 삭제
|
||||
if($od_pg == 'inicis') {
|
||||
$sql = " delete from {$g5['g5_shop_order_data_table']} where od_id = '$od_id' and dt_pg = '$od_pg' ";
|
||||
sql_query($sql);
|
||||
}
|
||||
$sql = " delete from {$g5['g5_shop_order_data_table']} where od_id = '$od_id' and dt_pg = '$od_pg' ";
|
||||
sql_query($sql);
|
||||
|
||||
if(function_exists('add_order_post_log')) add_order_post_log('', 'delete');
|
||||
|
||||
// 주문번호제거
|
||||
shop_order_access_forget((string)$od_id);
|
||||
set_session('ss_order_id', '');
|
||||
|
||||
// 기존자료 세션에서 제거
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||
include_once(G5_LIB_PATH.'/shop_order_access.lib.php');
|
||||
|
||||
require_once(G5_SHOP_PATH.'/settle_'.$default['de_pg_service'].'.inc.php');
|
||||
|
||||
@@ -7,7 +8,9 @@ require_once(G5_SHOP_PATH.'/settle_'.$default['de_pg_service'].'.inc.php');
|
||||
require_once(G5_SHOP_PATH.'/'.$default['de_pg_service'].'/orderform.1.php');
|
||||
?>
|
||||
|
||||
<script src="<?php echo G5_JS_URL; ?>/shop.order-state.js"></script>
|
||||
<form name="forderform" id="forderform" method="post" action="<?php echo $order_action_url; ?>" autocomplete="off">
|
||||
<?php echo shop_order_checkout_fields((string)$pp['pp_id'], true); ?>
|
||||
<input type="hidden" name="pp_id" value="<?php echo $pp['pp_id']; ?>">
|
||||
|
||||
<?php
|
||||
@@ -373,15 +376,15 @@ function forderform_check(f)
|
||||
if(f.method.value != "무통장") {
|
||||
// 주문정보 임시저장
|
||||
var order_data = $(f).serialize();
|
||||
var save_result = "";
|
||||
var save_result = "결제 요청을 저장하지 못했습니다.";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: order_data,
|
||||
url: g5_url+"/shop/ajax.orderdatasave.php",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
save_result = data;
|
||||
success: function(data, textStatus, xhr) {
|
||||
save_result = data || g5_order_state_accept(xhr);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -404,15 +407,15 @@ function forderform_check(f)
|
||||
if(f.gopaymethod.value != "무통장") {
|
||||
// 주문정보 임시저장
|
||||
var order_data = $(f).serialize();
|
||||
var save_result = "";
|
||||
var save_result = "결제 요청을 저장하지 못했습니다.";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: order_data,
|
||||
url: g5_url+"/shop/ajax.orderdatasave.php",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
save_result = data;
|
||||
success: function(data, textStatus, xhr) {
|
||||
save_result = data || g5_order_state_accept(xhr);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -447,15 +450,15 @@ function forderform_check(f)
|
||||
if(f.PayMethod.value != "무통장") {
|
||||
// 주문정보 임시저장
|
||||
var order_data = $(f).serialize();
|
||||
var save_result = "";
|
||||
var save_result = "결제 요청을 저장하지 못했습니다.";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: order_data,
|
||||
url: g5_url+"/shop/ajax.orderdatasave.php",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
save_result = data;
|
||||
success: function(data, textStatus, xhr) {
|
||||
save_result = data || g5_order_state_accept(xhr);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
include_once(G5_LIB_PATH.'/shop_order_access.lib.php');
|
||||
shop_order_state_prepare(true);
|
||||
include_once(G5_LIB_PATH.'/mailer.lib.php');
|
||||
|
||||
$page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.get_session('ss_personalpay_id');
|
||||
@@ -215,6 +217,7 @@ $sql = " update {$g5['g5_shop_personalpay_table']}
|
||||
pp_cash_no = '{$pg_receipt_infos['od_cash_no']}',
|
||||
pp_cash_info = '{$pg_receipt_infos['od_cash_info']}'
|
||||
where pp_id = '{$pp['pp_id']}' ";
|
||||
shop_order_state_finalizing();
|
||||
$result = sql_query($sql, false);
|
||||
|
||||
// 결제정보 입력 오류시 결제 취소
|
||||
@@ -314,10 +317,16 @@ if($pp_receipt_price > 0 && $pp['pp_id'] && $pp['od_id']) {
|
||||
}
|
||||
}
|
||||
|
||||
// 완료한 개인결제의 임시 데이터 삭제
|
||||
$sql = " delete from {$g5['g5_shop_order_data_table']} where od_id = '{$pp['pp_id']}' and dt_pg = '$pp_pg' ";
|
||||
sql_query($sql);
|
||||
|
||||
// 개인결제번호제거
|
||||
if (!empty($_POST['inicis_pro']) && function_exists('inicis_pro_audit_order_saved'))
|
||||
inicis_pro_audit_order_saved($pp['pp_id'], $pp_tno, 'personal', 'web');
|
||||
|
||||
include_once(G5_LIB_PATH.'/shop_order_access.lib.php');
|
||||
shop_order_access_forget((string)$pp['pp_id']);
|
||||
set_session('ss_personalpay_id', '');
|
||||
set_session('ss_personalpay_hash', '');
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ async function launchCrossPlatform(frm) {
|
||||
taxFreeAmount: parseInt(frm.taxFreeAmount.value),
|
||||
orderId: frm.orderId.value, // 고유 주문번호
|
||||
orderName: frm.orderName.value,
|
||||
successUrl: "<?php echo G5_SHOP_URL;?>/toss/returnurl.php", // 결제 요청이 성공하면 리다이렉트되는 URL
|
||||
failUrl: "<?php echo G5_SHOP_URL;?>/toss/returnurl.php?mode=fail", // 결제 요청이 실패하면 리다이렉트되는 URL
|
||||
successUrl: g5_order_state_url("<?php echo G5_SHOP_URL;?>/toss/returnurl.php", frm), // 결제 요청이 성공하면 리다이렉트되는 URL
|
||||
failUrl: g5_order_state_url("<?php echo G5_SHOP_URL;?>/toss/returnurl.php?mode=fail", frm), // 결제 요청이 실패하면 리다이렉트되는 URL
|
||||
customerEmail: frm.customerEmail.value,
|
||||
customerName: frm.customerName.value,
|
||||
customerMobilePhone: frm.customerMobilePhone.value,
|
||||
|
||||
+8
-29
@@ -1,41 +1,20 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
|
||||
// 결제 실패 처리인 경우
|
||||
if (isset($_REQUEST['mode']) && $_REQUEST['mode'] === 'fail') {
|
||||
$code = isset($_REQUEST['code']) ? trim($_REQUEST['code']) : '';
|
||||
$message = isset($_REQUEST['message']) ? trim($_REQUEST['message']) : '';
|
||||
include_once(G5_LIB_PATH.'/shop_order_access.lib.php');
|
||||
header('Cache-Control: no-store, private');
|
||||
header('Referrer-Policy: no-referrer');
|
||||
|
||||
alert('결제에 실패하였습니다.\\n\\n[' . $code . '] ' . $message, G5_SHOP_URL . '/orderform.php');
|
||||
exit;
|
||||
}
|
||||
if (isset($_REQUEST['mode']) && $_REQUEST['mode'] === 'fail') shop_order_state_abort_pending();
|
||||
$orderId = isset($_REQUEST['orderId']) ? $_REQUEST['orderId'] : '';
|
||||
$paymentKey = isset($_REQUEST['paymentKey']) ? $_REQUEST['paymentKey'] : '';
|
||||
$amount = isset($_REQUEST['amount']) ? $_REQUEST['amount'] : '';
|
||||
$data = shop_order_access_payment($orderId, $paymentKey, $amount);
|
||||
|
||||
$g5['title'] = '토스페이먼츠 결제인증 완료처리';
|
||||
$g5['body_script'] = ' onload="setTossResult();"';
|
||||
include_once(G5_PATH.'/head.sub.php');
|
||||
|
||||
// 토스페이먼츠 결제인증 성공시 인증키 주문 임시데이터에 업데이트
|
||||
$paymentKey = isset($_REQUEST['paymentKey']) ? trim($_REQUEST['paymentKey']) : '';
|
||||
$orderId = isset($_REQUEST['orderId']) ? trim($_REQUEST['orderId']) : '';
|
||||
$amount = isset($_REQUEST['amount']) ? trim($_REQUEST['amount']) : '';
|
||||
|
||||
if (empty($paymentKey) || empty($orderId)) {
|
||||
alert('결제정보가 올바르지 않습니다.', G5_SHOP_URL);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$orderId' ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
$data = isset($row['dt_data']) ? unserialize(base64_decode($row['dt_data'])) : array();
|
||||
|
||||
|
||||
// 주문 임시데이터에 paymentKey 업데이트
|
||||
$data['paymentKey'] = $paymentKey;
|
||||
$data_new = base64_encode(serialize($data));
|
||||
$sql = " update {$g5['g5_shop_order_data_table']} set dt_data = '$data_new' where od_id = '$orderId' limit 1 ";
|
||||
sql_query($sql);
|
||||
|
||||
if(isset($data['pp_id']) && $data['pp_id']) {
|
||||
$order_action_url = G5_HTTPS_SHOP_URL.'/personalpayformupdate.php';
|
||||
} else {
|
||||
|
||||
+34
-34
@@ -2,24 +2,24 @@
|
||||
class TossPayments {
|
||||
|
||||
// 클라이언트, 시크릿 키, 상점아이디
|
||||
public string $clientKey;
|
||||
public string $secretKey;
|
||||
public string $mId;
|
||||
public string $headerSecretKey = "";
|
||||
public $clientKey;
|
||||
public $secretKey;
|
||||
public $mId;
|
||||
public $headerSecretKey = "";
|
||||
|
||||
public string $paymentUrl = "https://api.tosspayments.com/v1/payments/orders/{orderId}";
|
||||
public string $acceptUrl = "https://api.tosspayments.com/v1/payments/confirm";
|
||||
public string $cancelUrl = "https://api.tosspayments.com/v1/payments/{paymentKey}/cancel";
|
||||
public string $cashReceiptsUrl = "https://api.tosspayments.com/v1/cash-receipts";
|
||||
public $paymentUrl = "https://api.tosspayments.com/v1/payments/orders/{orderId}";
|
||||
public $acceptUrl = "https://api.tosspayments.com/v1/payments/confirm";
|
||||
public $cancelUrl = "https://api.tosspayments.com/v1/payments/{paymentKey}/cancel";
|
||||
public $cashReceiptsUrl = "https://api.tosspayments.com/v1/cash-receipts";
|
||||
|
||||
// 결제데이터
|
||||
public array $headers = array();
|
||||
public array $paymentData = array();
|
||||
public array $cancelData = array();
|
||||
public array $cashReceiptsData = array();
|
||||
public array $responseData = array();
|
||||
public $headers = array();
|
||||
public $paymentData = array();
|
||||
public $cancelData = array();
|
||||
public $cashReceiptsData = array();
|
||||
public $responseData = array();
|
||||
|
||||
public array $bankCode = array(
|
||||
public $bankCode = array(
|
||||
// 은행
|
||||
'02' => '한국산업은행',
|
||||
'03' => 'IBK기업은행',
|
||||
@@ -75,7 +75,7 @@ class TossPayments {
|
||||
'ST' => '토스증권'
|
||||
);
|
||||
|
||||
public array $cardCode = array(
|
||||
public $cardCode = array(
|
||||
'3K' => '기업 BC',
|
||||
'46' => '광주은행',
|
||||
'71' => '롯데카드',
|
||||
@@ -105,7 +105,7 @@ class TossPayments {
|
||||
);
|
||||
|
||||
// 간편결제 제공업체 코드
|
||||
public array $easyPayCode = array(
|
||||
public $easyPayCode = array(
|
||||
'TOSSPAY' => '토스페이',
|
||||
'NAVERPAY' => '네이버페이',
|
||||
'SAMSUNGPAY' => '삼성페이',
|
||||
@@ -117,7 +117,7 @@ class TossPayments {
|
||||
'SSG' => 'SSG페이'
|
||||
);
|
||||
|
||||
public function __construct(string $clientKey, string $secretKey, string $mId) {
|
||||
public function __construct($clientKey, $secretKey, $mId) {
|
||||
$this->clientKey = $clientKey;
|
||||
$this->secretKey = $secretKey;
|
||||
$this->mId = $mId;
|
||||
@@ -127,7 +127,7 @@ class TossPayments {
|
||||
* 헤더 시크릿 키 설정
|
||||
* @return void
|
||||
*/
|
||||
private function setHeaderSecretKey(): void
|
||||
private function setHeaderSecretKey()
|
||||
{
|
||||
$this->headerSecretKey = base64_encode($this->secretKey . ':');
|
||||
}
|
||||
@@ -136,7 +136,7 @@ class TossPayments {
|
||||
* 헤더 설정
|
||||
* @return void
|
||||
*/
|
||||
public function setPaymentHeader(): void
|
||||
public function setPaymentHeader()
|
||||
{
|
||||
$this->setHeaderSecretKey();
|
||||
|
||||
@@ -152,7 +152,7 @@ class TossPayments {
|
||||
* @param array $request
|
||||
* @return void
|
||||
*/
|
||||
public function setPaymentData(array $request): void
|
||||
public function setPaymentData(array $request)
|
||||
{
|
||||
$this->paymentData = array(
|
||||
'amount' => $request['amount'],
|
||||
@@ -164,10 +164,10 @@ class TossPayments {
|
||||
/**
|
||||
* 주문번호로 결제정보 조회
|
||||
*
|
||||
* @param string $orderId
|
||||
* @param $orderId
|
||||
* @return bool
|
||||
*/
|
||||
public function getPaymentByOrderId(string $orderId): bool
|
||||
public function getPaymentByOrderId($orderId)
|
||||
{
|
||||
if (empty($orderId)) {
|
||||
return false;
|
||||
@@ -183,7 +183,7 @@ class TossPayments {
|
||||
$response = curl_exec($curl);
|
||||
|
||||
$return_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
$this->responseData = json_decode($response, true);
|
||||
$this->responseData = (array) json_decode((string)$response, true);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
@@ -200,7 +200,7 @@ class TossPayments {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function approvePayment(): bool {
|
||||
public function approvePayment() {
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $this->acceptUrl);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);
|
||||
@@ -213,12 +213,12 @@ class TossPayments {
|
||||
$response = curl_exec($curl);
|
||||
|
||||
$return_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
$this->responseData = json_decode($response, true);
|
||||
$this->responseData = (array) json_decode((string)$response, true);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
// 결제 실패 상황인 경우
|
||||
if ($return_status != 200 || ($this->responseData['status'] != 'DONE' && $this->responseData['status'] != 'WAITING_FOR_DEPOSIT')) {
|
||||
if ($return_status != 200 || !isset($this->responseData['status']) || ($this->responseData['status'] != 'DONE' && $this->responseData['status'] != 'WAITING_FOR_DEPOSIT')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ class TossPayments {
|
||||
* @param array $request
|
||||
* @return void
|
||||
*/
|
||||
public function setCancelData(array $request): void
|
||||
public function setCancelData(array $request)
|
||||
{
|
||||
$this->cancelData = array(
|
||||
'paymentKey' => $request['paymentKey'],
|
||||
@@ -263,7 +263,7 @@ class TossPayments {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function cancelPayment(): bool
|
||||
public function cancelPayment()
|
||||
{
|
||||
// 취소에 필요한 결제 키가 있는지 여부
|
||||
if (empty($this->cancelData['paymentKey'])) {
|
||||
@@ -282,7 +282,7 @@ class TossPayments {
|
||||
$response = curl_exec($curl);
|
||||
|
||||
$return_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
$this->responseData = json_decode($response, true);
|
||||
$this->responseData = (array) json_decode((string)$response, true);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
@@ -297,7 +297,7 @@ class TossPayments {
|
||||
/**
|
||||
* 현금영수증 발급 데이터 설정
|
||||
*/
|
||||
public function setCashReceiptsData(array $request): void
|
||||
public function setCashReceiptsData(array $request)
|
||||
{
|
||||
$this->cashReceiptsData = array(
|
||||
'amount' => $request['amount'],
|
||||
@@ -311,7 +311,7 @@ class TossPayments {
|
||||
/**
|
||||
* 현금영수증 발급
|
||||
*/
|
||||
public function issueCashReceipt(): bool
|
||||
public function issueCashReceipt()
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $this->cashReceiptsUrl);
|
||||
@@ -328,7 +328,7 @@ class TossPayments {
|
||||
$response = curl_exec($curl);
|
||||
|
||||
$return_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
$this->responseData = json_decode($response, true);
|
||||
$this->responseData = (array) json_decode((string)$response, true);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
@@ -343,7 +343,7 @@ class TossPayments {
|
||||
/**
|
||||
* 현금영수증 발급 취소
|
||||
*/
|
||||
public function cancelCashReceipt($receiptKey): bool
|
||||
public function cancelCashReceipt($receiptKey)
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $this->cashReceiptsUrl."/".$receiptKey."/cancel");
|
||||
@@ -359,7 +359,7 @@ class TossPayments {
|
||||
$response = curl_exec($curl);
|
||||
|
||||
$return_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
$this->responseData = json_decode($response, true);
|
||||
$this->responseData = (array) json_decode((string)$response, true);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
|
||||
@@ -1,79 +1,8 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
|
||||
// 토스페이먼츠 class
|
||||
require_once(G5_SHOP_PATH.'/toss/toss.inc.php');
|
||||
|
||||
$toss = new TossPayments(
|
||||
$config['cf_toss_client_key'],
|
||||
$config['cf_toss_secret_key'],
|
||||
$config['cf_lg_mid']
|
||||
);
|
||||
include_once(G5_LIB_PATH.'/shop_order_access.lib.php');
|
||||
|
||||
$orderId = isset($_REQUEST['orderId']) ? $_REQUEST['orderId'] : '';
|
||||
$amount = isset($_REQUEST['amount']) ? $_REQUEST['amount'] : '';
|
||||
$paymentKey = isset($_REQUEST['paymentKey']) ? $_REQUEST['paymentKey'] : '';
|
||||
|
||||
$toss->setPaymentData(array(
|
||||
'orderId' => $orderId,
|
||||
'amount' => $amount,
|
||||
'paymentKey' => $paymentKey,
|
||||
));
|
||||
|
||||
// 장바구니 ID 설정 (바로구매 여부 확인)
|
||||
$ss_cart_id = get_session('ss_direct') ? get_session('ss_cart_direct') : get_session('ss_cart_id');
|
||||
|
||||
// 임시데이터에 결제 데이터 저장
|
||||
$addQuery = "";
|
||||
if (isset($orderId)) {
|
||||
$addQuery .= " AND od_id = '$orderId'";
|
||||
}
|
||||
if (isset($ss_cart_id)) {
|
||||
$addQuery .= " AND cart_id = '$ss_cart_id'";
|
||||
}
|
||||
if (isset($member['mb_id'])) {
|
||||
$addQuery .= " AND mb_id = '{$member['mb_id']}'";
|
||||
}
|
||||
|
||||
if (empty($orderId) && empty($ss_cart_id)) {
|
||||
alert('주문정보가 올바르지 않습니다.');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 기존 dt_data 가져오기
|
||||
$sql = "
|
||||
SELECT * FROM {$g5['g5_shop_order_data_table']}
|
||||
WHERE 1=1
|
||||
{$addQuery}
|
||||
LIMIT 1
|
||||
";
|
||||
$res = sql_fetch($sql);
|
||||
$dt_data = array();
|
||||
if (isset($res['dt_data'])) {
|
||||
$dt_data = unserialize(base64_decode($res['dt_data']));
|
||||
}
|
||||
|
||||
// dt_data 에 결제 키 추가
|
||||
if (isset($paymentKey)) {
|
||||
$dt_data['paymentKey'] = $paymentKey;
|
||||
$dt_data_new = base64_encode(serialize($dt_data));
|
||||
|
||||
// 업데이트
|
||||
$sql = "
|
||||
UPDATE {$g5['g5_shop_order_data_table']} SET
|
||||
dt_data = '".$dt_data_new."'
|
||||
WHERE od_id = '$orderId'
|
||||
{$addQuery}
|
||||
";
|
||||
sql_query($sql);
|
||||
}
|
||||
|
||||
if(isset($payReqMap['pp_id']) && $payReqMap['pp_id']) {
|
||||
$page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.$payReqMap['pp_id'];
|
||||
} else {
|
||||
$page_return_url = G5_SHOP_URL.'/orderform.php';
|
||||
if ($_SESSION['ss_direct']) {
|
||||
$page_return_url .= '?sw_direct=1';
|
||||
}
|
||||
}
|
||||
?>
|
||||
$amount = isset($_REQUEST['amount']) ? $_REQUEST['amount'] : '';
|
||||
shop_order_access_payment($orderId, $paymentKey, $amount);
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
|
||||
if (function_exists('shop_order_state_cancel')) shop_order_state_cancel('cancel_pending');
|
||||
|
||||
// 토스 공통 설정
|
||||
require_once(G5_SHOP_PATH.'/toss/toss.inc.php');
|
||||
|
||||
@@ -16,11 +18,23 @@ $toss = new TossPayments(
|
||||
|
||||
$toss->setPaymentHeader();
|
||||
|
||||
$od_id = isset($od['od_id']) ? $od['od_id'] : (isset($pp['pp_id']) ? $pp['pp_id'] : '');
|
||||
$cancel_runtime = function_exists('shop_order_runtime') ? shop_order_runtime() : array('active'=>'');
|
||||
$cancel_order_id = $cancel_runtime['active'] !== '' ? $cancel_runtime['active'] :
|
||||
(isset($od['od_id']) ? (string)$od['od_id'] : (isset($pp['pp_id']) ? (string)$pp['pp_id'] : (string)get_session('ss_order_id')));
|
||||
|
||||
if (!$toss->getPaymentByOrderId($od_id)) {
|
||||
if (!$toss->getPaymentByOrderId($cancel_order_id)) {
|
||||
alert('결제정보를 가져올 수 없습니다.');
|
||||
}
|
||||
if ($cancel_runtime['active'] !== '') {
|
||||
$cancel_state = shop_order_state_row($cancel_order_id);
|
||||
if (!isset($toss->responseData['orderId'],$toss->responseData['paymentKey']) ||
|
||||
$toss->responseData['orderId'] !== $cancel_order_id || $toss->responseData['paymentKey'] !== $cancel_state['payment_key']) shop_order_access_fail();
|
||||
}
|
||||
if (isset($toss->responseData['status']) && $toss->responseData['status'] === 'CANCELED') {
|
||||
if (function_exists('shop_order_state_cancel')) shop_order_state_cancel('cancelled');
|
||||
return;
|
||||
}
|
||||
$toss->headers[] = 'Idempotency-Key: g5-cancel-'.hash('sha256', $cancel_order_id.$toss->responseData['paymentKey']);
|
||||
|
||||
$toss->setCancelData(array(
|
||||
'paymentKey' => $toss->responseData['paymentKey'],
|
||||
@@ -35,4 +49,5 @@ if (!$toss->cancelPayment()) {
|
||||
$msg .= '코드 : ' . $toss->responseData['code'];
|
||||
}
|
||||
alert($msg);
|
||||
}
|
||||
}
|
||||
if (function_exists('shop_order_state_cancel')) shop_order_state_cancel('cancelled');
|
||||
+11
-14
@@ -7,20 +7,14 @@ require_once(G5_SHOP_PATH.'/toss/toss.inc.php');
|
||||
$orderId = isset($_REQUEST['orderId']) ? $_REQUEST['orderId'] : '';
|
||||
$paymentKey = isset($_POST['paymentKey']) ? $_POST['paymentKey'] : '';
|
||||
|
||||
if (empty($orderId) || empty($paymentKey)) {
|
||||
alert('주문정보가 올바르지 않습니다.', G5_SHOP_URL);
|
||||
}
|
||||
|
||||
$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$orderId' limit 1 ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
$data = isset($row['dt_data']) ? unserialize(base64_decode($row['dt_data'])) : array();
|
||||
|
||||
include_once(G5_LIB_PATH.'/shop_order_access.lib.php');
|
||||
$data = shop_order_access_payment($orderId, $paymentKey);
|
||||
$is_personal = !empty($data['pp_id']);
|
||||
if ($is_personal !== !empty($_POST['pp_id']) ||
|
||||
($is_personal && (string)$_POST['pp_id'] !== $orderId)) shop_order_access_fail();
|
||||
$amount = isset($data['amountValue']) ? (int)$data['amountValue'] : 0;
|
||||
|
||||
if ($amount <= 0 || $amount !== (int)$order_price) {
|
||||
alert('결제금액이 올바르지 않습니다.', G5_SHOP_URL);
|
||||
}
|
||||
$expected_amount = $is_personal ? (int)$pp['pp_price'] : (int)$order_price;
|
||||
if ($amount <= 0 || $amount !== $expected_amount) shop_order_access_fail();
|
||||
|
||||
$toss = new TossPayments(
|
||||
$config['cf_toss_client_key'],
|
||||
@@ -37,9 +31,12 @@ $toss->setPaymentData(array(
|
||||
$toss->setPaymentHeader();
|
||||
|
||||
// 결제승인 요청
|
||||
$result = $toss->approvePayment();
|
||||
$result = shop_order_toss_approve($toss, $orderId, $paymentKey, $expected_amount);
|
||||
|
||||
if ($result) {
|
||||
if (!isset($toss->responseData['orderId'], $toss->responseData['paymentKey'], $toss->responseData['totalAmount']) ||
|
||||
$toss->responseData['orderId'] !== $orderId || $toss->responseData['paymentKey'] !== $paymentKey ||
|
||||
(int)$toss->responseData['totalAmount'] !== $expected_amount) shop_order_access_fail();
|
||||
// 결제승인 성공시 처리
|
||||
$status = isset($toss->responseData['status']) ? $toss->responseData['status'] : '';
|
||||
$method = isset($toss->responseData['method']) ? $toss->responseData['method'] : '';
|
||||
|
||||
Reference in new issue
Block a user