이니시스 모바일 IOS의 경우 isp에서 리다이렉트로 인한 문제 수정
This commit is contained in:
@ -1,5 +1,35 @@
|
||||
<?php
|
||||
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
|
||||
if(!function_exists('get_inicis_app_scheme')){
|
||||
function get_inicis_app_scheme(){
|
||||
$user_agent = $_SERVER['HTTP_USER_AGENT'];
|
||||
|
||||
$iPod = stripos($user_agent,"iPod");
|
||||
$iPhone = stripos($user_agent,"iPhone");
|
||||
$iPad = stripos($user_agent,"iPad");
|
||||
|
||||
if( $iPod || $iPhone || $iPad ){ //IOS 의 앱브라우저에서 ISP결제시 리다이렉트 safari로 돌아가는 문제가 있음
|
||||
if( preg_match('/NAVER\(inapp;/', $user_agent) ){ //네이버
|
||||
return 'app_scheme=naversearchapp://&';
|
||||
}
|
||||
else if( preg_match('/CriOS/', $user_agent) ){ //크롬
|
||||
return 'app_scheme=googlechromes://&';
|
||||
}
|
||||
else if( preg_match('/DaumDevice/', $user_agent) ){ //다음
|
||||
return 'app_scheme=daumapps://&';
|
||||
}
|
||||
else if( preg_match('/KAKAOTALK/', $user_agent) ){ //카카오톡
|
||||
return 'app_scheme=kakaotalk://&';
|
||||
}
|
||||
else if( preg_match('/(FBAN|FBAV)/', $user_agent) ){ //페이스북
|
||||
return 'app_scheme=fb://&';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<form name="sm_form" method="POST" action="" accept-charset="euc-kr">
|
||||
@ -14,8 +44,8 @@ if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
<input type="hidden" name="P_NOTI_URL" value="<?php echo $noti_url; ?>">
|
||||
<input type="hidden" name="P_RETURN_URL" value="">
|
||||
<input type="hidden" name="P_HPP_METHOD" value="2">
|
||||
<input type="hidden" name="P_RESERVED" value="bank_receipt=N&twotrs_isp=Y&block_isp=Y<?php echo $useescrow.$inicis_cardpoint; ?>">
|
||||
<input type="hidden" name="DEF_RESERVED" value="bank_receipt=N&twotrs_isp=Y&block_isp=Y<?php echo $useescrow; ?>">
|
||||
<input type="hidden" name="P_RESERVED" value="<?php echo get_inicis_app_scheme(); ?>bank_receipt=N&twotrs_isp=Y&block_isp=Y<?php echo $useescrow.$inicis_cardpoint; ?>">
|
||||
<input type="hidden" name="DEF_RESERVED" value="<?php echo get_inicis_app_scheme(); ?>bank_receipt=N&twotrs_isp=Y&block_isp=Y<?php echo $useescrow.$inicis_cardpoint; ?>">
|
||||
<input type="hidden" name="P_NOTI" value="<?php echo $od_id; ?>">
|
||||
<input type="hidden" name="P_QUOTABASE" value="01:02:03:04:05:06:07:08:09:10:11:12"> <!-- 할부기간 설정 01은 일시불 -->
|
||||
<input type="hidden" name="P_SKIP_TERMS" value="">
|
||||
|
||||
@ -10,6 +10,20 @@ set_session('P_HASH', '');
|
||||
$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$oid' ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
if( empty($row) ){ //이미 결제가 완료 되었다면
|
||||
if( $exist_order = get_shop_order_data($oid) ){ //상품주문
|
||||
if($exist_order['od_tno']){
|
||||
exists_inicis_shop_order($oid, array(), $exist_order['od_time'], $exist_order['od_ip']);
|
||||
exit;
|
||||
}
|
||||
} else if( $pp = get_shop_order_data($oid, 'personal') ){ //개인결제
|
||||
if($pp['pp_tno']){ //이미 결제가 완료되었다면
|
||||
exists_inicis_shop_order($oid, $pp, $pp['pp_time'], $pp['pp_ip']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = unserialize(base64_decode($row['dt_data']));
|
||||
|
||||
if(isset($data['pp_id']) && $data['pp_id']) {
|
||||
|
||||
@ -17,7 +17,6 @@ $PGIP = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
if($PGIP == "211.219.96.165" || $PGIP == "118.129.210.25" || $PGIP == "183.109.71.153") //PG에서 보냈는지 IP로 체크
|
||||
{
|
||||
|
||||
// 이니시스 NOTI 서버에서 받은 Value
|
||||
$P_TID; // 거래번호
|
||||
$P_MID; // 상점아이디
|
||||
@ -54,6 +53,185 @@ if($PGIP == "211.219.96.165" || $PGIP == "118.129.210.25" || $PGIP == "183.109.7
|
||||
$P_AUTH_NO = $_POST['P_AUTH_NO'];
|
||||
$P_SRC_CODE = $_POST['P_SRC_CODE'];
|
||||
|
||||
// 결과 incis log 테이블 기록
|
||||
if($P_TYPE == 'BANK' || $P_SRC_CODE == 'A') {
|
||||
|
||||
if(!sql_query(" select post_data from {$g5['g5_shop_inicis_log_table']} limit 1 ", false)) {
|
||||
sql_query(" ALTER TABLE `{$g5['g5_shop_inicis_log_table']}`
|
||||
ADD `post_data` text NOT NULL AFTER `P_RMESG1`,
|
||||
ADD `is_mail_send` tinyint(4) NOT NULL DEFAULT '1' AFTER `post_data` ", false);
|
||||
}
|
||||
|
||||
$sql = " insert into {$g5['g5_shop_inicis_log_table']}
|
||||
set oid = '$P_OID',
|
||||
P_TID = '$P_TID',
|
||||
P_MID = '$P_MID',
|
||||
P_AUTH_DT = '$P_AUTH_DT',
|
||||
P_STATUS = '$P_STATUS',
|
||||
P_TYPE = '$P_TYPE',
|
||||
P_OID = '$P_OID',
|
||||
P_FN_NM = '".iconv_utf8($P_FN_NM)."',
|
||||
P_AUTH_NO = '$P_AUTH_NO',
|
||||
P_AMT = '$P_AMT',
|
||||
P_RMESG1 = '".iconv_utf8($P_RMESG1)."',
|
||||
post_data = '".base64_encode(serialize($_POST))."',
|
||||
is_mail_send = 0 ";
|
||||
sql_query($sql, false);
|
||||
}
|
||||
|
||||
if( $P_STATUS == "00" && $P_TID && $P_MID && $P_TYPE != "VBANK" ){
|
||||
|
||||
// 주문이 있는지 체크
|
||||
$sql = "select count(od_id) as cnt from {$g5['g5_shop_order_table']} where od_id = '$P_OID' and od_tno = '$P_TID' ";
|
||||
$exist_order = sql_fetch($sql);
|
||||
|
||||
if( !$exist_order['cnt'] ){
|
||||
//주문정보를 insert 합니다.
|
||||
|
||||
include_once(G5_MSHOP_PATH.'/settle_inicis.inc.php');
|
||||
|
||||
$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = $P_OID ";
|
||||
$od = sql_fetch($sql);
|
||||
$data = unserialize(base64_decode($od['dt_data']));
|
||||
|
||||
//개인결제
|
||||
if(isset($data['pp_id']) && !empty($data['pp_id'])) {
|
||||
|
||||
// 개인결제 정보
|
||||
$pp_check = false;
|
||||
$sql = " select * from {$g5['g5_shop_personalpay_table']} where pp_id = '$P_OID' and pp_tno = '$P_TID' and pp_use = '1' ";
|
||||
$pp = sql_fetch($sql);
|
||||
|
||||
if( !$pp['pp_tno'] && $data['pp_id'] == $P_OID ){
|
||||
|
||||
$res_cd = $P_STATUS;
|
||||
$pp_id = $P_OID;
|
||||
|
||||
$exclude = array('res_cd', 'P_HASH', 'P_TYPE', 'P_AUTH_DT', 'P_VACT_BANK', 'LGD_PAYKEY', 'pp_id', 'good_mny', 'pp_name', 'pp_email', 'pp_hp', 'pp_settle_case');
|
||||
|
||||
$params = array();
|
||||
|
||||
foreach($data as $key=>$v) {
|
||||
if( !in_array($key, $exclude) ){
|
||||
$_POST[$key] = $params[$key] = clean_xss_tags(strip_tags($v));
|
||||
}
|
||||
}
|
||||
|
||||
extract($params);
|
||||
|
||||
$good_mny = $P_AMT;
|
||||
$pp_name = clean_xss_tags($data['pp_name']);
|
||||
$pp_email = clean_xss_tags($data['pp_email']);
|
||||
$pp_hp = clean_xss_tags($data['pp_hp']);
|
||||
$pp_settle_case = clean_xss_tags($data['pp_settle_case']);
|
||||
|
||||
set_session('P_TID', $P_TID);
|
||||
set_session('P_AMT', $P_AMT);
|
||||
$_POST['P_HASH'] = md5(get_session('P_TID').$default['de_inicis_mid'].$P_AMT);
|
||||
$_POST['P_AUTH_NO'] = $P_AUTH_NO;
|
||||
$_POST['pp_id'] = $P_OID;
|
||||
$_POST['good_mny'] = $P_AMT;
|
||||
$is_noti_pay = true;
|
||||
|
||||
$sql = " select pp_time from {$g5['g5_shop_personalpay_table']} where pp_id = '$P_OID' and pp_use = '1' ";
|
||||
$pp_time = sql_fetch($sql);
|
||||
|
||||
set_session('ss_personalpay_id', $P_OID);
|
||||
set_session('ss_personalpay_hash', md5($P_OID.$P_AMT.$pp_time['pp_time']));
|
||||
|
||||
include_once( G5_MSHOP_PATH.'/personalpayformupdate.php' );
|
||||
|
||||
if( !$order_id ){
|
||||
echo "FAIL";
|
||||
} else {
|
||||
$sql = " delete from {$g5['g5_shop_inicis_log_table']} where (oid = '$P_OID' and P_TID = '$P_TID') OR substr(P_AUTH_DT, 1, 8) < '".date('Ymd', strtotime('-3 month', G5_SERVER_TIME))."' ";
|
||||
sql_query( $sql , false);
|
||||
}
|
||||
}
|
||||
|
||||
//상품주문
|
||||
} else {
|
||||
|
||||
if($od && isset($data['it_id']) && !empty($data['it_id'])) {
|
||||
|
||||
$PAY = array(
|
||||
'oid' => $P_OID,
|
||||
'P_TID' => $P_TID,
|
||||
'P_MID' => $P_MID,
|
||||
'P_AUTH_DT' => $P_AUTH_DT,
|
||||
'P_STATUS' => $P_STATUS,
|
||||
'P_TYPE' => $P_TYPE,
|
||||
'P_OID' => $P_OID,
|
||||
'P_FN_NM' => iconv_utf8($P_FN_NM),
|
||||
'P_AUTH_NO' => $P_AUTH_NO,
|
||||
'P_AMT' => $P_AMT,
|
||||
'P_RMESG1' => iconv_utf8($P_RMESG1)
|
||||
);
|
||||
|
||||
// TID, AMT 를 세션으로 주문완료 페이지 전달
|
||||
$hash = md5($PAY['P_TID'].$PAY['P_MID'].$PAY['P_AMT']);
|
||||
set_session('P_TID', $PAY['P_TID']);
|
||||
set_session('P_AMT', $PAY['P_AMT']);
|
||||
set_session('P_HASH', $hash);
|
||||
set_session('ss_order_id', $P_OID);
|
||||
|
||||
$params = array();
|
||||
$exclude = array('res_cd', 'P_HASH', 'P_TYPE', 'P_AUTH_DT', 'P_VACT_BANK', 'P_AUTH_NO');
|
||||
|
||||
foreach($data as $key=>$value) {
|
||||
if(!empty($exclude) && in_array($key, $exclude))
|
||||
continue;
|
||||
|
||||
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( !empty($params['sw_direct']) && !empty($params['post_cart_id']) ){
|
||||
set_session('ss_direct', $params['sw_direct']);
|
||||
set_session('ss_cart_direct', $params['post_cart_id']);
|
||||
} else if ( $params['post_cart_id'] ){
|
||||
set_session('ss_cart_id', $params['post_cart_id']);
|
||||
}
|
||||
|
||||
try {
|
||||
unset($params['sw_direct']);
|
||||
unset($params['post_cart_id']);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
$_POST['res_cd'] = $params['res_cd'] = $PAY['P_STATUS'];
|
||||
$_POST['P_HASH'] = $params['P_HASH'] = $hash;
|
||||
$_POST['P_TYPE'] = $params['P_TYPE'] = $PAY['P_TYPE'];
|
||||
$_POST['P_AUTH_DT'] = $params['P_AUTH_DT'] = $PAY['P_AUTH_DT'];
|
||||
$_POST['P_VACT_BANK'] = $params['P_VACT_BANK'] = $PAY['P_FN_NM'];
|
||||
$_POST['P_AUTH_NO'] = $params['P_AUTH_NO'] = $PAY['P_AUTH_NO'];
|
||||
|
||||
extract($params);
|
||||
|
||||
if( $od['mb_id'] ){
|
||||
$is_member = true;
|
||||
$member = get_member($od['mb_id']);
|
||||
}
|
||||
|
||||
$is_noti_pay = true;
|
||||
include_once( G5_MSHOP_PATH.'/orderformupdate.php' );
|
||||
|
||||
if( !$order_id ){
|
||||
echo "FAIL";
|
||||
} else {
|
||||
$sql = " delete from {$g5['g5_shop_inicis_log_table']} where (oid = '$P_OID' and P_TID = '$P_TID') OR substr(P_AUTH_DT, 1, 8) < '".date('Ymd', strtotime('-3 month', G5_SERVER_TIME))."' ";
|
||||
sql_query( $sql , false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//WEB 방식의 경우 가상계좌 채번 결과 무시 처리
|
||||
//(APP 방식의 경우 해당 내용을 삭제 또는 주석 처리 하시기 바랍니다.)
|
||||
@ -166,23 +344,6 @@ if($PGIP == "211.219.96.165" || $PGIP == "118.129.210.25" || $PGIP == "183.109.7
|
||||
"P_SRC_CODE" => $P_SRC_CODE
|
||||
);
|
||||
|
||||
// 결과 incis log 테이블 기록
|
||||
if($P_TYPE == 'BANK' || $P_SRC_CODE == 'A') {
|
||||
$sql = " insert into {$g5['g5_shop_inicis_log_table']}
|
||||
set oid = '$P_OID',
|
||||
P_TID = '$P_TID',
|
||||
P_MID = '$P_MID',
|
||||
P_AUTH_DT = '$P_AUTH_DT',
|
||||
P_STATUS = '$P_STATUS',
|
||||
P_TYPE = '$P_TYPE',
|
||||
P_OID = '$P_OID',
|
||||
P_FN_NM = '".iconv_utf8($P_FN_NM)."',
|
||||
P_AUTH_NO = '$P_AUTH_NO',
|
||||
P_AMT = '$P_AMT',
|
||||
P_RMESG1 = '".iconv_utf8($P_RMESG1)."' ";
|
||||
@sql_query($sql);
|
||||
}
|
||||
|
||||
// 결제처리에 관한 로그 기록
|
||||
//writeLog($value);
|
||||
|
||||
|
||||
@ -7,6 +7,15 @@ if( $od_settle_case == '삼성페이' && !empty($_POST['P_HASH']) ){
|
||||
$default['de_pg_service'] = 'inicis';
|
||||
}
|
||||
|
||||
if( $default['de_pg_service'] == 'inicis' && get_session('ss_order_id') ){
|
||||
if( $exist_order = get_shop_order_data(get_session('ss_order_id')) ){ //이미 상품이 주문되었다면 리다이렉트
|
||||
if($exist_order['od_tno']){
|
||||
exists_inicis_shop_order(get_session('ss_order_id'), array(), $exist_order['od_time'], $exist_order['od_ip']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page_return_url = G5_SHOP_URL.'/orderform.php';
|
||||
if(get_session('ss_direct'))
|
||||
$page_return_url .= '?sw_direct=1';
|
||||
@ -497,6 +506,10 @@ else
|
||||
// 주문번호를 얻는다.
|
||||
$od_id = get_session('ss_order_id');
|
||||
|
||||
if( !$od_id ){
|
||||
die("주문번호가 없습니다.");
|
||||
}
|
||||
|
||||
$od_escrow = 0;
|
||||
if($escw_yn == 'Y')
|
||||
$od_escrow = 1;
|
||||
@ -618,6 +631,9 @@ if(!$result) {
|
||||
$error = 'order';
|
||||
include G5_SHOP_PATH.'/ordererrormail.php';
|
||||
|
||||
// 주문삭제
|
||||
sql_query(" delete from {$g5['g5_shop_order_table']} where od_id = '$od_id' ", false);
|
||||
|
||||
die('<p>고객님의 주문 정보를 처리하는 중 오류가 발생해서 주문이 완료되지 않았습니다.</p><p>'.strtoupper($od_pg).'를 이용한 전자결제(신용카드, 계좌이체, 가상계좌 등)은 자동 취소되었습니다.');
|
||||
}
|
||||
|
||||
@ -854,6 +870,12 @@ set_session('ss_orderview_uid', $uid);
|
||||
$sql = " delete from {$g5['g5_shop_order_data_table']} where od_id = '$od_id' and dt_pg = '$od_pg' ";
|
||||
sql_query($sql);
|
||||
|
||||
if( $od_pg == 'inicis' && $od_tno ){
|
||||
$sql = "delete from {$g5['g5_shop_inicis_log_table']} where oid = '$od_id' and P_TID = '$od_tno' ";
|
||||
sql_query($sql, false);
|
||||
}
|
||||
|
||||
|
||||
// 주문번호제거
|
||||
set_session('ss_order_id', '');
|
||||
|
||||
@ -911,5 +933,12 @@ if($is_member) {
|
||||
sql_query($sql);
|
||||
}
|
||||
|
||||
$is_noti_pay = isset($is_noti_pay) ? $is_noti_pay : false;
|
||||
|
||||
if( $is_noti_pay ){
|
||||
$order_id = $od_id;
|
||||
return;
|
||||
}
|
||||
|
||||
goto_url(G5_SHOP_URL.'/orderinquiryview.php?od_id='.$od_id.'&uid='.$uid);
|
||||
?>
|
||||
|
||||
@ -237,5 +237,12 @@ set_session('ss_personalpay_hash', '');
|
||||
$uid = md5($pp['pp_id'].$pp['pp_time'].$_SERVER['REMOTE_ADDR']);
|
||||
set_session('ss_personalpay_uid', $uid);
|
||||
|
||||
$is_noti_pay = isset($is_noti_pay) ? $is_noti_pay : false;
|
||||
|
||||
if( $is_noti_pay ){
|
||||
$order_id = $pp['pp_id'];
|
||||
return;
|
||||
}
|
||||
|
||||
goto_url(G5_SHOP_URL.'/personalpayresult.php?pp_id='.$pp['pp_id'].'&uid='.$uid);
|
||||
?>
|
||||
|
||||
@ -4,7 +4,11 @@ include_once('./_common.php');
|
||||
$sql = "select * from {$g5['g5_shop_personalpay_table']} where pp_id = '$pp_id' ";
|
||||
$pp = sql_fetch($sql);
|
||||
if (!$pp['pp_id'] || (md5($pp['pp_id'].$pp['pp_time'].$_SERVER['REMOTE_ADDR']) != get_session('ss_personalpay_uid'))) {
|
||||
alert("조회하실 개인결제 내역이 없습니다.", G5_SHOP_URL);
|
||||
if( isset($_GET['ini_noti']) && $pp['pp_tno'] ){
|
||||
alert("해당 개인결제는 정상적으로 결제되었습니다.", G5_SHOP_URL."/personalpay.php");
|
||||
} else {
|
||||
alert("조회하실 개인결제 내역이 없습니다.", G5_SHOP_URL."/personalpay.php");
|
||||
}
|
||||
}
|
||||
|
||||
// 결제방법
|
||||
|
||||
Reference in New Issue
Block a user