lg 부분취소 기능 추가

This commit is contained in:
chicpro
2014-06-13 16:35:39 +09:00
parent c74af86e5a
commit 43b41354e6
6 changed files with 265 additions and 165 deletions

View File

@ -721,7 +721,7 @@ if($od['od_pg'] == 'lg') {
<?php if($od['od_status'] == '주문' && $od['od_misu'] > 0) { ?>
<a href="./personalpayform.php?popup=yes&amp;od_id=<?php echo $od_id; ?>" id="personalpay_add">개인결제추가</a>
<?php } ?>
<?php if($od['od_pg'] == 'kcp' && ($od['od_misu'] < 0 && ($od['od_receipt_price'] - $od['od_refund_price']) > 0 && ($od['od_settle_case'] == '신용카드' || $od['od_settle_case'] == '계좌이체'))) { ?>
<?php if($od['od_misu'] < 0 && ($od['od_receipt_price'] - $od['od_refund_price']) > 0 && ($od['od_settle_case'] == '신용카드' || $od['od_settle_case'] == '계좌이체')) { ?>
<a href="./orderpartcancel.php?od_id=<?php echo $od_id; ?>" id="orderpartcancel"><?php echo $od['od_settle_case']; ?> 부분취소</a>
<?php } ?>
<a href="./orderlist.php?<?php echo $qstr; ?>">목록</a>

View File

@ -19,13 +19,8 @@ if($od['od_receipt_price'] - $od['od_refund_price'] <= 0)
$g5['title'] = $od['od_settle_case'].' 부분취소';
include_once(G5_PATH.'/head.sub.php');
// 과세, 비과세 취소가능 금액계산
$sql = " select SUM( IF( ct_notax = 0, ( IF(io_type = 1, (io_price * ct_qty), ( (ct_price + io_price) * ct_qty) ) - cp_price ), 0 ) ) as tax_mny,
SUM( IF( ct_notax = 1, ( IF(io_type = 1, (io_price * ct_qty), ( (ct_price + io_price) * ct_qty) ) - cp_price ), 0 ) ) as free_mny
from {$g5['g5_shop_cart_table']}
where od_id = '$od_id'
and ct_status IN ( '취소', '반품', '품절' ) ";
$sum = sql_fetch($sql);
// 취소가능금액
$od_misu = abs($od['od_misu']);
?>
<form name="forderpartcancel" method="post" action="./orderpartcancelupdate.php" onsubmit="return form_check(this);">
@ -43,12 +38,9 @@ $sum = sql_fetch($sql);
</colgroup>
<tbody>
<tr>
<th scope="row">과세 취소가능 금액</th>
<td><?php echo display_price($sum['tax_mny']); ?></td>
<th scope="row">취소가능 금액</th>
<td><?php echo display_price($od_misu); ?></td>
</tr>
<tr>
<th scope="row">비과세 취소가능 금액</th>
<td><?php echo display_price($sum['free_mny']); ?></td>
</tr>
<tr>
<th scope="row"><label for="mod_tax_mny">과세 취소금액</label></th>
@ -76,8 +68,7 @@ $sum = sql_fetch($sql);
<script>
function form_check(f)
{
var max_tax_mny = parseInt(<?php echo $sum['tax_mny']; ?>);
var max_free_mny = parseInt(<?php echo $sum['free_mny']; ?>);
var max_mny = parseInt(<?php echo $od_misu; ?>);
var tax_mny = parseInt(f.mod_tax_mny.value.replace("/[^0-9]/g", ""));
var free_mny = parseInt(f.mod_free_mny.value.replace("/[^0-9]/g", ""));
@ -86,13 +77,18 @@ function form_check(f)
return false;
}
if(tax_mny && tax_mny > max_tax_mny) {
alert("과세 취소금액을 "+number_format(String(max_tax_mny))+"원 이하로 입력해 주십시오.");
if((tax_mny && free_mny) && (tax_mny + free_mny) > max_mny) {
alert("과세, 비과세 취소금액의 합을 "+number_format(String(max_mny))+"원 이하로 입력해 주십시오.");
return false;
}
if(free_mny && free_mny > max_free_mny) {
alert("과세 취소금액을 "+number_format(String(max_free_mny))+"원 이하로 입력해 주십시오.");
if(tax_mny && tax_mny > max_mny) {
alert("과세 취소금액을 "+number_format(String(max_mny))+"원 이하로 입력해 주십시오.");
return false;
}
if(free_mny && free_mny > max_mny) {
alert("비과세 취소금액을 "+number_format(String(max_mny))+"원 이하로 입력해 주십시오.");
return false;
}

View File

@ -25,155 +25,19 @@ if($od['od_settle_case'] == '계좌이체' && substr($od['od_receipt_time'], 0,
alert_close('실시간 계좌이체건의 부분취소 요청은 결제일 익일에 가능합니다.');
// 금액비교
// 과세, 비과세 취소가능 금액계산
$sql = " select SUM( IF( ct_notax = 0, ( IF(io_type = 1, (io_price * ct_qty), ( (ct_price + io_price) * ct_qty) ) - cp_price ), 0 ) ) as tax_mny,
SUM( IF( ct_notax = 1, ( IF(io_type = 1, (io_price * ct_qty), ( (ct_price + io_price) * ct_qty) ) - cp_price ), 0 ) ) as free_mny
from {$g5['g5_shop_cart_table']}
where od_id = '$od_id'
and ct_status IN ( '취소', '반품', '품절' ) ";
$sum = sql_fetch($sql);
$od_misu = abs($od['od_misu']);
if($tax_mny && $tax_mny > $sum['tax_mny'])
alert('과세 취소금액을 '.number_format($sum['tax_mny']).' 이하로 입력해 주십시오.');
if(($tax_mny && $free_mny) && ($tax_mny + $free_mny) > $od_misu)
alert('과세, 비과세 취소금액의 합을 '.display_price($od_misu).' 이하로 입력해 주십시오.');
if($free_mny && $free_mny > $sum['free_mny'])
alert('과세 취소금액을 '.number_format($sum['free_mny']).' 이하로 입력해 주십시오.');
if($tax_mny && $tax_mny > $od_misu)
alert('과세 취소금액을 '.display_price($od_misu).' 이하로 입력해 주십시오.');
// locale ko_KR.euc-kr 로 설정
setlocale(LC_CTYPE, 'ko_KR.euc-kr');
if($free_mny && $free_mny > $od_misu)
alert('비과세 취소금액을 '.display_price($od_misu).' 이하로 입력해 주십시오.');
// 부분취소 실행
$g_conf_site_cd = $default['de_kcp_mid'];
$g_conf_site_key = $default['de_kcp_site_key'];
$g_conf_home_dir = G5_SHOP_PATH.'/kcp';
$g_conf_key_dir = '';
$g_conf_log_dir = '';
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
$g_conf_key_dir = G5_SHOP_PATH.'/kcp/bin/pub.key';
$g_conf_log_dir = G5_SHOP_PATH.'/kcp/log';
}
if (preg_match("/^T000/", $g_conf_site_cd) || $default['de_card_test']) {
$g_conf_gw_url = "testpaygw.kcp.co.kr";
}
else {
$g_conf_gw_url = "paygw.kcp.co.kr";
if (!preg_match("/^SR/", $g_conf_site_cd)) {
alert("SR 로 시작하지 않는 KCP SITE CODE 는 지원하지 않습니다.");
}
}
include G5_SHOP_PATH.'/kcp/pp_cli_hub_lib.php';
$tno = $od['od_tno'];
$req_tx = 'mod';
$mod_desc = $cancel_memo;
$cust_ip = getenv('REMOTE_ADDR');
$rem_mny = (int)$od['od_receipt_price'] - (int)$od['od_refund_price'];;
$mod_mny = (int)$tax_mny;
$mod_free_mny = (int)$free_mny;
$mod_type = 'RN07';
if($od['od_settle_case'] == '계좌이체')
$mod_type = 'STPA';
if($od['od_tax_flag']) {
$mod_mny = $tax_mny + $free_mny;
}
$c_PayPlus = new C_PAYPLUS_CLI;
$c_PayPlus->mf_clear();
if ( $req_tx == "mod" )
{
$tran_cd = "00200000";
$c_PayPlus->mf_set_modx_data( "tno" , $tno ); // KCP 원거래 거래번호
$c_PayPlus->mf_set_modx_data( "mod_type" , $mod_type ); // 원거래 변경 요청 종류
$c_PayPlus->mf_set_modx_data( "mod_ip" , $cust_ip ); // 변경 요청자 IP
$c_PayPlus->mf_set_modx_data( "mod_desc" , $mod_desc ); // 변경 사유
$c_PayPlus->mf_set_modx_data( "rem_mny" , strval($rem_mny) ); // 취소 가능 잔액
$c_PayPlus->mf_set_modx_data( "mod_mny" , strval($mod_mny) ); // 취소 요청 금액
if($od['od_tax_flag'])
{
$mod_tax_mny = round((int)$tax_mny / 1.1);
$mod_vat_mny = (int)$tax_mny - $mod_tax_mny;
$c_PayPlus->mf_set_modx_data( "tax_flag" , "TG03" ); // 복합과세 구분
$c_PayPlus->mf_set_modx_data( "mod_tax_mny" , strval($mod_tax_mny) ); // 공급가 부분 취소 요청 금액
$c_PayPlus->mf_set_modx_data( "mod_vat_mny" , strval($mod_vat_mny) ); // 부과세 부분 취소 요청 금액
$c_PayPlus->mf_set_modx_data( "mod_free_mny" , strval($mod_free_mny) ); // 비관세 부분 취소 요청 금액
}
}
if ( $tran_cd != "" )
{
$c_PayPlus->mf_do_tx( "", $g_conf_home_dir, $g_conf_site_cd,
$g_conf_site_key, $tran_cd, "",
$g_conf_gw_url, $g_conf_gw_port, "payplus_cli_slib",
$ordr_idxx, $cust_ip, $g_conf_log_level,
"", 0 );
$res_cd = $c_PayPlus->m_res_cd; // 결과 코드
$res_msg = $c_PayPlus->m_res_msg; // 결과 메시지
/* $res_en_msg = $c_PayPlus->mf_get_res_data( "res_en_msg" ); // 결과 영문 메세지 */
}
else
{
$c_PayPlus->m_res_cd = "9562";
$c_PayPlus->m_res_msg = "연동 오류|Payplus Plugin이 설치되지 않았거나 tran_cd값이 설정되지 않았습니다.";
}
if ($res_cd != '0000')
{
$res_msg = iconv("euc-kr", "utf-8", $res_msg);
alert("$res_cd : $res_msg");
}
/* ============================================================================== */
/* = 취소 결과 처리 = */
/* = -------------------------------------------------------------------------- = */
if ( $req_tx == "mod" )
{
if ( $res_cd == "0000" )
{
$tno = $c_PayPlus->mf_get_res_data( "tno" ); // KCP 거래 고유 번호
$amount = $c_PayPlus->mf_get_res_data( "amount" ); // 원 거래금액
$mod_mny = $c_PayPlus->mf_get_res_data( "panc_mod_mny" ); // 취소요청된 금액
$rem_mny = $c_PayPlus->mf_get_res_data( "panc_rem_mny" ); // 취소요청후 잔액
// 환불금액기록
$sql = " update {$g5['g5_shop_order_table']}
set od_refund_price = od_refund_price + '$mod_mny',
od_shop_memo = concat(od_shop_memo, \"$mod_memo\")
where od_id = '{$od['od_id']}'
and od_tno = '$tno' ";
sql_query($sql);
// 미수금 등의 정보 업데이트
$info = get_order_info($od_id);
$sql = " update {$g5['g5_shop_order_table']}
set od_misu = '{$info['od_misu']}',
od_tax_mny = '{$info['od_tax_mny']}',
od_vat_mny = '{$info['od_vat_mny']}',
od_free_mny = '{$info['od_free_mny']}'
where od_id = '$od_id' ";
sql_query($sql);
} // End of [res_cd = "0000"]
/* = -------------------------------------------------------------------------- = */
/* = 취소 실패 결과 처리 = */
/* = -------------------------------------------------------------------------- = */
else
{
}
}
// locale 설정 초기화
setlocale(LC_CTYPE, '');
// PG사별 부분취소 실행
include_once(G5_SHOP_PATH.'/'.$od['od_pg'].'/orderpartcancel.inc.php');
include_once(G5_PATH.'/head.sub.php');
?>

View File

@ -0,0 +1,141 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
if($od['od_pg'] != 'kcp') return;
// locale ko_KR.euc-kr 로 설정
setlocale(LC_CTYPE, 'ko_KR.euc-kr');
// 부분취소 실행
$g_conf_site_cd = $default['de_kcp_mid'];
$g_conf_site_key = $default['de_kcp_site_key'];
$g_conf_home_dir = G5_SHOP_PATH.'/kcp';
$g_conf_key_dir = '';
$g_conf_log_dir = '';
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
$g_conf_key_dir = G5_SHOP_PATH.'/kcp/bin/pub.key';
$g_conf_log_dir = G5_SHOP_PATH.'/kcp/log';
}
if (preg_match("/^T000/", $g_conf_site_cd) || $default['de_card_test']) {
$g_conf_gw_url = "testpaygw.kcp.co.kr";
}
else {
$g_conf_gw_url = "paygw.kcp.co.kr";
if (!preg_match("/^SR/", $g_conf_site_cd)) {
alert("SR 로 시작하지 않는 KCP SITE CODE 는 지원하지 않습니다.");
}
}
include G5_SHOP_PATH.'/kcp/pp_cli_hub_lib.php';
$tno = $od['od_tno'];
$req_tx = 'mod';
$mod_desc = $mod_memo;
$cust_ip = getenv('REMOTE_ADDR');
$rem_mny = (int)$od['od_receipt_price'] - (int)$od['od_refund_price'];
$mod_mny = (int)$tax_mny;
$mod_free_mny = (int)$free_mny;
$mod_type = 'RN07';
if($od['od_settle_case'] == '계좌이체')
$mod_type = 'STPA';
if($od['od_tax_flag']) {
$mod_mny = $tax_mny + $free_mny;
}
$c_PayPlus = new C_PAYPLUS_CLI;
$c_PayPlus->mf_clear();
if ( $req_tx == "mod" )
{
$tran_cd = "00200000";
$c_PayPlus->mf_set_modx_data( "tno" , $tno ); // KCP 원거래 거래번호
$c_PayPlus->mf_set_modx_data( "mod_type" , $mod_type ); // 원거래 변경 요청 종류
$c_PayPlus->mf_set_modx_data( "mod_ip" , $cust_ip ); // 변경 요청자 IP
$c_PayPlus->mf_set_modx_data( "mod_desc" , $mod_desc ); // 변경 사유
$c_PayPlus->mf_set_modx_data( "rem_mny" , strval($rem_mny) ); // 취소 가능 잔액
$c_PayPlus->mf_set_modx_data( "mod_mny" , strval($mod_mny) ); // 취소 요청 금액
if($od['od_tax_flag'])
{
$mod_tax_mny = round((int)$tax_mny / 1.1);
$mod_vat_mny = (int)$tax_mny - $mod_tax_mny;
$c_PayPlus->mf_set_modx_data( "tax_flag" , "TG03" ); // 복합과세 구분
$c_PayPlus->mf_set_modx_data( "mod_tax_mny" , strval($mod_tax_mny) ); // 공급가 부분 취소 요청 금액
$c_PayPlus->mf_set_modx_data( "mod_vat_mny" , strval($mod_vat_mny) ); // 부과세 부분 취소 요청 금액
$c_PayPlus->mf_set_modx_data( "mod_free_mny" , strval($mod_free_mny) ); // 비관세 부분 취소 요청 금액
}
}
if ( $tran_cd != "" )
{
$c_PayPlus->mf_do_tx( "", $g_conf_home_dir, $g_conf_site_cd,
$g_conf_site_key, $tran_cd, "",
$g_conf_gw_url, $g_conf_gw_port, "payplus_cli_slib",
$ordr_idxx, $cust_ip, $g_conf_log_level,
"", 0 );
$res_cd = $c_PayPlus->m_res_cd; // 결과 코드
$res_msg = $c_PayPlus->m_res_msg; // 결과 메시지
/* $res_en_msg = $c_PayPlus->mf_get_res_data( "res_en_msg" ); // 결과 영문 메세지 */
}
else
{
$c_PayPlus->m_res_cd = "9562";
$c_PayPlus->m_res_msg = "연동 오류|Payplus Plugin이 설치되지 않았거나 tran_cd값이 설정되지 않았습니다.";
}
if ($res_cd != '0000')
{
$res_msg = iconv("euc-kr", "utf-8", $res_msg);
alert("$res_cd : $res_msg");
}
/* ============================================================================== */
/* = 취소 결과 처리 = */
/* = -------------------------------------------------------------------------- = */
if ( $req_tx == "mod" )
{
if ( $res_cd == "0000" )
{
$tno = $c_PayPlus->mf_get_res_data( "tno" ); // KCP 거래 고유 번호
$amount = $c_PayPlus->mf_get_res_data( "amount" ); // 원 거래금액
$mod_mny = $c_PayPlus->mf_get_res_data( "panc_mod_mny" ); // 취소요청된 금액
$rem_mny = $c_PayPlus->mf_get_res_data( "panc_rem_mny" ); // 취소요청후 잔액
// 환불금액기록
$sql = " update {$g5['g5_shop_order_table']}
set od_refund_price = od_refund_price + '$mod_mny',
od_shop_memo = concat(od_shop_memo, \"$mod_memo\")
where od_id = '{$od['od_id']}'
and od_tno = '$tno' ";
sql_query($sql);
// 미수금 등의 정보 업데이트
$info = get_order_info($od_id);
$sql = " update {$g5['g5_shop_order_table']}
set od_misu = '{$info['od_misu']}',
od_tax_mny = '{$info['od_tax_mny']}',
od_vat_mny = '{$info['od_vat_mny']}',
od_free_mny = '{$info['od_free_mny']}'
where od_id = '$od_id' ";
sql_query($sql);
} // End of [res_cd = "0000"]
/* = -------------------------------------------------------------------------- = */
/* = 취소 실패 결과 처리 = */
/* = -------------------------------------------------------------------------- = */
else
{
}
}
// locale 설정 초기화
setlocale(LC_CTYPE, '');
?>

View File

@ -7,7 +7,7 @@ $LGD_CUSTOM_PROCESSTYPE = 'TWOTR';
<input type="hidden" name="CST_PLATFORM" id="CST_PLATFORM" value="<?php echo $CST_PLATFORM; ?>"> <!-- 테스트, 서비스 구분 -->
<input type="hidden" name="CST_MID" id="CST_MID" value="<?php echo $CST_MID; ?>"> <!-- 상점아이디 -->
<input type="hidden" name="LGD_MID" id="LGD_MID" value="<?php echo $LGD_MID; ?>"> <!-- 상점아이디 -->
<input type="hidden" name="LGD_OID" id="LGD_OID" value="<?php echo $od_id; ?>"> <!-- 주문번호 -->
<input type="hidden" name="LGD_OID" id="LGD_OID" value="<?php echo $od_id; ?>"> <!-- 주문번호 -->
<input type="hidden" name="LGD_BUYER" id="LGD_BUYER" value=""> <!-- 구매자 -->
<input type="hidden" name="LGD_PRODUCTINFO" id="LGD_PRODUCTINFO" value="<?php echo $goods; ?>"> <!-- 상품정보 -->
<input type="hidden" name="LGD_AMOUNT" id="LGD_AMOUNT" value=""> <!-- 결제금액 -->

View File

@ -0,0 +1,99 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
if($od['od_pg'] != 'lg') return;
include_once(G5_SHOP_PATH.'/settle_lg.inc.php');
/*
* [결제 부분취소 요청 페이지]
*
* LG유플러스으로 부터 내려받은 거래번호(LGD_TID)를 가지고 취소 요청을 합니다.(파라미터 전달시 POST를 사용하세요)
* (승인시 LG유플러스으로 부터 내려받은 PAYKEY와 혼동하지 마세요.)
*/
$LGD_TID = $od['od_tno']; //LG유플러스으로 부터 내려받은 거래번호(LGD_TID)
$LGD_CANCELAMOUNT = (int)$tax_mny; //부분취소 금액
$LGD_REMAINAMOUNT = (int)$od['od_receipt_price'] - (int)$od['od_refund_price']; //취소전 남은금액
$LGD_CANCELTAXFREEAMOUNT = (int)$free_mny; //면세대상 부분취소 금액 (과세/면세 혼용상점만 적용)
$LGD_CANCELREASON = iconv_euckr($mod_memo); //취소사유
$LGD_RFACCOUNTNUM = $_POST['LGD_RFACCOUNTNUM']; //환불계좌 번호(가상계좌 환불인경우만 필수)
$LGD_RFBANKCODE = $_POST['LGD_RFBANKCODE']; //환불계좌 은행코드(가상계좌 환불인경우만 필수)
$LGD_RFCUSTOMERNAME = $_POST['LGD_RFCUSTOMERNAME']; //환불계좌 예금주(가상계좌 환불인경우만 필수)
$LGD_RFPHONE = $_POST['LGD_RFPHONE']; //요청자 연락처(가상계좌 환불인경우만 필수)
$xpay = new XPay($configPath, $CST_PLATFORM);
// Mert Key 설정
$xpay->set_config_value('t'.$LGD_MID, $config['cf_lg_mert_key']);
$xpay->set_config_value($LGD_MID, $config['cf_lg_mert_key']);
$xpay->Init_TX($LGD_MID);
$xpay->Set("LGD_TXNAME", "PartialCancel");
$xpay->Set("LGD_TID", $LGD_TID);
$xpay->Set("LGD_CANCELAMOUNT", $LGD_CANCELAMOUNT);
$xpay->Set("LGD_REMAINAMOUNT", $LGD_REMAINAMOUNT);
$xpay->Set("LGD_CANCELTAXFREEAMOUNT", $LGD_CANCELTAXFREEAMOUNT);
$xpay->Set("LGD_CANCELREASON", $LGD_CANCELREASON);
$xpay->Set("LGD_RFACCOUNTNUM", $LGD_RFACCOUNTNUM);
$xpay->Set("LGD_RFBANKCODE", $LGD_RFBANKCODE);
$xpay->Set("LGD_RFCUSTOMERNAME", $LGD_RFCUSTOMERNAME);
$xpay->Set("LGD_RFPHONE", $LGD_RFPHONE);
$xpay->Set("LGD_REQREMAIN", "0");
/*
* 1. 결제 부분취소 요청 결과처리
*
*/
if ($xpay->TX()) {
//1)결제 부분취소결과 화면처리(성공,실패 결과 처리를 하시기 바랍니다.)
/*
echo "결제 부분취소 요청이 완료되었습니다. <br>";
echo "TX Response_code = " . $xpay->Response_Code() . "<br>";
echo "TX Response_msg = " . $xpay->Response_Msg() . "<p>";
$keys = $xpay->Response_Names();
foreach($keys as $name) {
echo $name . " = " . $xpay->Response($name, 0) . "<br>";
}
echo "<p>";
*/
if( '0000' == $xpay->Response_Code() ) {
// 환불금액기록
$tno = $xpay->Response("LGD_TID", 0);
$mod_mny = (int)$tax_mny + (int)$free_mny;
$sql = " update {$g5['g5_shop_order_table']}
set od_refund_price = od_refund_price + '$mod_mny',
od_shop_memo = concat(od_shop_memo, \"$mod_memo\")
where od_id = '{$od['od_id']}'
and od_tno = '$tno' ";
sql_query($sql);
// 미수금 등의 정보 업데이트
$info = get_order_info($od_id);
$sql = " update {$g5['g5_shop_order_table']}
set od_misu = '{$info['od_misu']}',
od_tax_mny = '{$info['od_tax_mny']}',
od_vat_mny = '{$info['od_vat_mny']}',
od_free_mny = '{$info['od_free_mny']}'
where od_id = '$od_id' ";
sql_query($sql);
} else {
alert($xpay->Response_Msg().' 코드 : '.$xpay->Response_Code());
}
} else {
//2)API 요청 실패 화면처리
/*
echo "결제 부분취소 요청이 실패하였습니다. <br>";
echo "TX Response_code = " . $xpay->Response_Code() . "<br>";
echo "TX Response_msg = " . $xpay->Response_Msg() . "<p>";
*/
alert('결제 부분취소 요청이 실패하였습니다.\\n\\n'.$xpay->Response_Code().' : '.$xpay->Response_Msg());
}
?>