현금영수증 등록 모듈 수정

This commit is contained in:
chicpro
2013-03-27 17:35:28 +09:00
parent 93d083c8f7
commit ec9b621df9
3 changed files with 961 additions and 0 deletions

383
shop/kcp/pp_cli_hub.php Normal file
View File

@ -0,0 +1,383 @@
<?
include './_common.php';
include G4_LIB_PATH.'/etc.lib.php';
// 현금영수증 필드생성
$sql = " ALTER TABLE `{$g4['yc4_order_table']}` ADD `od_cash_no` VARCHAR( 255 ) NOT NULL ,
ADD `od_cash_receipt_no` VARCHAR( 255 ) NOT NULL ,
ADD `od_cash_app_time` VARCHAR( 255 ) NOT NULL ,
ADD `od_cash_reg_stat` VARCHAR( 255 ) NOT NULL ,
ADD `od_cash_reg_desc` VARCHAR( 255 ) NOT NULL ,
ADD `od_cash_tr_code` VARCHAR( 255 ) NOT NULL ,
ADD `od_cash_id_info` VARCHAR( 255 ) NOT NULL ";
sql_query($sql, false);
// 현금영수증 사용, 미사용 구분
$sql = " ALTER TABLE `{$g4['yc4_order_table']}` ADD `od_cash` TINYINT NOT NULL ";
sql_query($sql, false);
$sql = " select count(*) as cnt from {$g4['yc4_order_table']} where od_id = '{$_POST['ordr_idxx']}' and od_cash = 1 ";
$row = sql_fetch($sql);
if ($row['cnt']) {
alert('이미 등록된 현금영수증 입니다.');
}
//write_log("$g4[path]/data/log/cash.log", $_POST);
/* ============================================================================== */
/* = PAGE : 등록/변경 처리 PAGE = */
/* = -------------------------------------------------------------------------- = */
/* = Copyright (c) 2007 KCP Inc. All Rights Reserverd. = */
/* ============================================================================== */
?>
<?
/* ============================================================================== */
/* = 라이브러리 및 사이트 정보 include = */
/* = -------------------------------------------------------------------------- = */
require G4_SHOP_PATH.'/kcp/pp_cli_hub_lib.php';
/* ============================================================================== */
/* = 01. KCP 지불 서버 정보 설정 = */
/* = -------------------------------------------------------------------------- = */
$g_conf_home_dir = G4_SHOP_PATH.'/kcp'; // ※ 쇼핑몰 모듈 설치 절대 경로 bin전까지
$g_conf_log_level = "3";
if ($default['de_card_test']) {
$default['de_kcp_mid'] = 'T0000';
}
if ($default['de_kcp_mid'] == 'T0000') {
$g_conf_pa_url = "testpaygw.kcp.co.kr"; // ※ 테스트: testpaygw.kcp.co.kr, 리얼: paygw.kcp.co.kr
$g_conf_pa_port = "8090"; // ※ 테스트: 8090, 리얼: 8090
}
else {
$g_conf_pa_url = "paygw.kcp.co.kr";
$g_conf_pa_port = "8090";
}
$g_conf_tx_mode = 0;
/* ============================================================================== */
/* ============================================================================== */
/* = 02. 쇼핑몰 지불 정보 설정 = */
/* = -------------------------------------------------------------------------- = */
// ※ V6 가맹점의 경우
$g_conf_user_type = "PGNW"; // 변경 불가
//$g_conf_site_id = $default[de_kcp_mid]; // 리얼 반영시 KCP에 발급된 site_cd 사용 ex) T0000
$g_conf_site_id = strlen($default['de_kcp_mid']) == 3 ? "SR".$default['de_kcp_mid'] : $default['de_kcp_mid']; // 리얼 반영시 KCP에 발급된 site_cd 사용 ex) T0000
/* ============================================================================== */
/* ============================================================================== */
/* = 01. 요청 정보 설정 = */
/* = -------------------------------------------------------------------------- = */
$req_tx = $_POST[ "req_tx" ]; // 요청 종류
$trad_time = $_POST[ "trad_time" ]; // 원거래 시각
/* = -------------------------------------------------------------------------- = */
$ordr_idxx = $_POST[ "ordr_idxx" ]; // 주문 번호
$buyr_name = $_POST[ "buyr_name" ]; // 주문자 이름
$buyr_tel1 = $_POST[ "buyr_tel1" ]; // 주문자 전화번호
$buyr_mail = $_POST[ "buyr_mail" ]; // 주문자 E-Mail
$good_name = $_POST[ "good_name" ]; // 상품 정보
$comment = $_POST[ "comment" ]; // 비고
/* = -------------------------------------------------------------------------- = */
$corp_type = $_POST[ "corp_type" ]; // 사업장 구분
$corp_tax_type = $_POST[ "corp_tax_type" ]; // 과세/면세 구분
$corp_tax_no = $_POST[ "corp_tax_no" ]; // 발행 사업자 번호
$corp_nm = $_POST[ "corp_nm" ]; // 상호
$corp_owner_nm = $_POST[ "corp_owner_nm" ]; // 대표자명
$corp_addr = $_POST[ "corp_addr" ]; // 사업장 주소
$corp_telno = $_POST[ "corp_telno" ]; // 사업장 대표 연락처
/* = -------------------------------------------------------------------------- = */
$tr_code = $_POST[ "tr_code" ]; // 발행용도
$id_info = $_POST[ "id_info" ]; // 신분확인 ID
$amt_tot = $_POST[ "amt_tot" ]; // 거래금액 총 합
$amt_sup = $_POST[ "amt_sup" ]; // 공급가액
$amt_svc = $_POST[ "amt_svc" ]; // 봉사료
$amt_tax = $_POST[ "amt_tax" ]; // 부가가치세
/* = -------------------------------------------------------------------------- = */
$mod_type = $_POST[ "mod_type" ]; // 변경 타입
$mod_value = $_POST[ "mod_value" ]; // 변경 요청 거래번호
$mod_gubn = $_POST[ "mod_gubn" ]; // 변경 요청 거래번호 구분
$mod_mny = $_POST[ "mod_mny" ]; // 변경 요청 금액
$rem_mny = $_POST[ "rem_mny" ]; // 변경처리 이전 금액
/* = -------------------------------------------------------------------------- = */
$cust_ip = getenv( "REMOTE_ADDR" ); // 요청 IP
/* ============================================================================== */
$buyr_name = iconv("utf8", "cp949", $buyr_name);
$good_name = iconv("utf8", "cp949", $good_name);
/* ============================================================================== */
/* = 02. 인스턴스 생성 및 초기화 = */
/* = -------------------------------------------------------------------------- = */
$c_PayPlus = new C_PAYPLUS_CLI;
$c_PayPlus->mf_clear();
/* ============================================================================== */
/* ============================================================================== */
/* = 03. 처리 요청 정보 설정, 실행 = */
/* = -------------------------------------------------------------------------- = */
/* = -------------------------------------------------------------------------- = */
/* = 03-1. 승인 요청 = */
/* = -------------------------------------------------------------------------- = */
// 업체 환경 정보
if ( $req_tx == "pay" )
{
$tx_cd = "07010000"; // 현금영수증 등록 요청
// 현금영수증 정보
$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "user_type", $g_conf_user_type );
$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "trad_time", $trad_time );
$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "tr_code", $tr_code );
$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "id_info", $id_info );
$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "amt_tot", $amt_tot );
$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "amt_sup", $amt_sup );
$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "amt_svc", $amt_svc );
$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "amt_tax", $amt_tax );
$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "pay_type", "PAXX" ); // 선 결제 서비스 구분(PABK - 계좌이체, PAVC - 가상계좌, PAXX - 기타)
//$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "pay_trade_no", $pay_trade_no ); // 결제 거래번호(PABK, PAVC일 경우 필수)
//$rcpt_data_set .= $c_PayPlus->mf_set_data_us( "pay_tx_id", $pay_tx_id ); // 가상계좌 입금통보 TX_ID(PAVC일 경우 필수)
// 주문 정보
$c_PayPlus->mf_set_ordr_data( "ordr_idxx", $ordr_idxx );
$c_PayPlus->mf_set_ordr_data( "good_name", $good_name );
$c_PayPlus->mf_set_ordr_data( "buyr_name", $buyr_name );
$c_PayPlus->mf_set_ordr_data( "buyr_tel1", $buyr_tel1 );
$c_PayPlus->mf_set_ordr_data( "buyr_mail", $buyr_mail );
$c_PayPlus->mf_set_ordr_data( "comment", $comment );
// 가맹점 정보
$corp_data_set .= $c_PayPlus->mf_set_data_us( "corp_type", $corp_type );
if ( $corp_type == "1" ) // 입점몰인 경우 판매상점 DATA 전문 생성
{
$corp_data_set .= $c_PayPlus->mf_set_data_us( "corp_tax_type", $corp_tax_type );
$corp_data_set .= $c_PayPlus->mf_set_data_us( "corp_tax_no", $corp_tax_no );
$corp_data_set .= $c_PayPlus->mf_set_data_us( "corp_sell_tax_no",$corp_tax_no );
$corp_data_set .= $c_PayPlus->mf_set_data_us( "corp_nm", $corp_nm );
$corp_data_set .= $c_PayPlus->mf_set_data_us( "corp_owner_nm", $corp_owner_nm );
$corp_data_set .= $c_PayPlus->mf_set_data_us( "corp_addr", $corp_addr );
$corp_data_set .= $c_PayPlus->mf_set_data_us( "corp_telno", $corp_telno );
}
$c_PayPlus->mf_set_ordr_data( "rcpt_data", $rcpt_data_set );
$c_PayPlus->mf_set_ordr_data( "corp_data", $corp_data_set );
}
/* = -------------------------------------------------------------------------- = */
/* = 03-2. 취소 요청 = */
/* = -------------------------------------------------------------------------- = */
else if ( $req_tx == "mod" )
{
if ( $mod_type == "STSQ" )
{
$tx_cd = "07030000"; // 조회 요청
}
else
{
$tx_cd = "07020000"; // 취소 요청
}
$c_PayPlus->mf_set_modx_data( "mod_type", $mod_type ); // 원거래 변경 요청 종류
$c_PayPlus->mf_set_modx_data( "mod_value", $mod_value );
$c_PayPlus->mf_set_modx_data( "mod_gubn", $mod_gubn );
$c_PayPlus->mf_set_modx_data( "trad_time", $trad_time );
if ( $mod_type == "STPC" ) // 부분취소
{
$c_PayPlus->mf_set_modx_data( "mod_mny", $mod_mny );
$c_PayPlus->mf_set_modx_data( "rem_mny", $rem_mny );
}
}
/* ============================================================================== */
/* ============================================================================== */
/* = 03-3. 실행 = */
/* ------------------------------------------------------------------------------ */
if ( strlen($tx_cd) > 0 )
{
$c_PayPlus->mf_do_tx( "", $g_conf_home_dir, $g_conf_site_id,
"", $tx_cd, "",
$g_conf_pa_url, $g_conf_pa_port, "payplus_cli_slib",
$ordr_idxx, $cust_ip, $g_conf_log_level,
"", $g_conf_tx_mode );
}
else
{
$c_PayPlus->m_res_cd = "9562";
$c_PayPlus->m_res_msg = "연동 오류";
}
$res_cd = $c_PayPlus->m_res_cd; // 결과 코드
$res_msg = $c_PayPlus->m_res_msg; // 결과 메시지
/* ============================================================================== */
/* ============================================================================== */
/* = 04. 승인 결과 처리 = */
/* = -------------------------------------------------------------------------- = */
if ( $req_tx == "pay" )
{
if ( $res_cd == "0000" )
{
$cash_no = $c_PayPlus->mf_get_res_data( "cash_no" ); // 현금영수증 거래번호
$receipt_no = $c_PayPlus->mf_get_res_data( "receipt_no" ); // 현금영수증 승인번호
$app_time = $c_PayPlus->mf_get_res_data( "app_time" ); // 승인시간(YYYYMMDDhhmmss)
$reg_stat = $c_PayPlus->mf_get_res_data( "reg_stat" ); // 등록 상태 코드
$reg_desc = $c_PayPlus->mf_get_res_data( "reg_desc" ); // 등록 상태 설명
/* = -------------------------------------------------------------------------- = */
/* = 04-1. 승인 결과를 업체 자체적으로 DB 처리 작업하시는 부분입니다. = */
/* = -------------------------------------------------------------------------- = */
/* = 승인 결과를 DB 작업 하는 과정에서 정상적으로 승인된 건에 대해 = */
/* = DB 작업을 실패하여 DB update 가 완료되지 않은 경우, 자동으로 = */
/* = 승인 취소 요청을 하는 프로세스가 구성되어 있습니다. = */
/* = DB 작업이 실패 한 경우, bSucc 라는 변수(String)의 값을 "false" = */
/* = 로 세팅해 주시기 바랍니다. (DB 작업 성공의 경우에는 "false" 이외의 = */
/* = 값을 세팅하시면 됩니다.) = */
/* = -------------------------------------------------------------------------- = */
$bSucc = ""; // DB 작업 실패일 경우 "false" 로 세팅
$sql = " update {$g4['yc4_order_table']}
set od_cash_no = '$cash_no',
od_cash_receipt_no = '$receipt_no',
od_cash_app_time = '$app_time',
od_cash_reg_stat = '$reg_stat',
od_cash_reg_desc = '".iconv("cp949", "utf-8", $reg_desc)."',
od_cash_tr_code = '$tr_code',
od_cash_id_info = '$id_info',
od_cash = '1'
where od_id = '$ordr_idxx' ";
$result = sql_query($sql);
if (!$result) $bSucc = "false";
/* = -------------------------------------------------------------------------- = */
/* = 04-2. DB 작업 실패일 경우 자동 승인 취소 = */
/* = -------------------------------------------------------------------------- = */
if ( $bSucc == "false" )
{
$c_PayPlus->mf_clear();
$tx_cd = "07020000"; // 취소 요청
$c_PayPlus->mf_set_modx_data( "mod_type", "STSC" ); // 원거래 변경 요청 종류
$c_PayPlus->mf_set_modx_data( "mod_value", $cash_no );
$c_PayPlus->mf_set_modx_data( "mod_gubn", "MG01" );
$c_PayPlus->mf_set_modx_data( "trad_time", $trad_time );
$c_PayPlus->mf_do_tx( "", $g_conf_home_dir, $g_conf_site_id,
"", $tx_cd, "",
$g_conf_pa_url, $g_conf_pa_port, "payplus_cli_slib",
$ordr_idxx, $cust_ip, $g_conf_log_level,
"", $g_conf_tx_mode );
$res_cd = $c_PayPlus->m_res_cd;
$res_msg = $c_PayPlus->m_res_msg;
}
} // End of [res_cd = "0000"]
/* = -------------------------------------------------------------------------- = */
/* = 04-3. 등록 실패를 업체 자체적으로 DB 처리 작업하시는 부분입니다. = */
/* = -------------------------------------------------------------------------- = */
else
{
}
}
/* ============================================================================== */
/* ============================================================================== */
/* = 05. 변경 결과 처리 = */
/* = -------------------------------------------------------------------------- = */
else if ( $req_tx == "mod" )
{
if ( $res_cd == "0000" )
{
$cash_no = $c_PayPlus->mf_get_res_data( "cash_no" ); // 현금영수증 거래번호
$receipt_no = $c_PayPlus->mf_get_res_data( "receipt_no" ); // 현금영수증 승인번호
$app_time = $c_PayPlus->mf_get_res_data( "app_time" ); // 승인시간(YYYYMMDDhhmmss)
$reg_stat = $c_PayPlus->mf_get_res_data( "reg_stat" ); // 등록 상태 코드
$reg_desc = $c_PayPlus->mf_get_res_data( "reg_desc" ); // 등록 상태 설명
}
/* = -------------------------------------------------------------------------- = */
/* = 05-1. 변경 실패를 업체 자체적으로 DB 처리 작업하시는 부분입니다. = */
/* = -------------------------------------------------------------------------- = */
else
{
}
}
/* ============================================================================== */
/* ============================================================================== */
/* = 06. 인스턴스 CleanUp = */
/* = -------------------------------------------------------------------------- = */
$c_PayPlus->mf_clear();
/* ============================================================================== */
/* ============================================================================== */
/* = 07. 폼 구성 및 결과페이지 호출 = */
/* ============================================================================== */
?>
<html>
<head>
<script language = 'javascript'>
function goResult()
{
document.pay_info.submit();
}
</script>
</head>
<body onload="goResult();">
<form name="pay_info" method="post" action="./pp_cli_result.php">
<input type="hidden" name="req_tx" value="<?=$req_tx?>"> <!-- 요청 구분 -->
<input type="hidden" name="bSucc" value="<?=$bSucc?>"> <!-- 쇼핑몰 DB 처리 성공 여부 -->
<input type="hidden" name="res_cd" value="<?=$res_cd?>"> <!-- 결과 코드 -->
<input type="hidden" name="res_msg" value="<?=iconv("cp949", "utf-8", $res_msg)?>"> <!-- 결과 메세지 -->
<input type="hidden" name="ordr_idxx" value="<?=$ordr_idxx?>"> <!-- 주문번호 -->
<input type="hidden" name="good_name" value="<?=$good_name?>"> <!-- 상품명 -->
<input type="hidden" name="buyr_name" value="<?=$buyr_name?>"> <!-- 주문자명 -->
<input type="hidden" name="buyr_tel1" value="<?=$buyr_tel1?>"> <!-- 주문자 전화번호 -->
<input type="hidden" name="buyr_mail" value="<?=$buyr_mail?>"> <!-- 주문자 E-mail -->
<input type="hidden" name="comment" value="<?=$comment?>"> <!-- 비고 -->
<input type="hidden" name="corp_type" value="<?=$corp_type?>"> <!-- 사업장 구분 -->
<input type="hidden" name="corp_tax_type" value="<?=$corp_tax_type?>"> <!-- 과세/면세 구분 -->
<input type="hidden" name="corp_tax_no" value="<?=$corp_tax_no?>"> <!-- 발행 사업자 번호 -->
<input type="hidden" name="corp_nm" value="<?=$corp_nm?>"> <!-- 상호 -->
<input type="hidden" name="corp_owner_nm" value="<?=$corp_owner_nm?>"> <!-- 대표자명 -->
<input type="hidden" name="corp_addr" value="<?=$corp_addr?>"> <!-- 사업장주소 -->
<input type="hidden" name="corp_telno" value="<?=$corp_telno?>"> <!-- 사업장 대표 연락처 -->
<input type="hidden" name="tr_code" value="<?=$tr_code?>"> <!-- 발행용도 -->
<input type="hidden" name="id_info" value="<?=$id_info?>"> <!-- 신분확인 ID -->
<input type="hidden" name="amt_tot" value="<?=$amt_tot?>"> <!-- 거래금액 총 합 -->
<input type="hidden" name="amt_sub" value="<?=$amt_sup?>"> <!-- 공급가액 -->
<input type="hidden" name="amt_svc" value="<?=$amt_svc?>"> <!-- 봉사료 -->
<input type="hidden" name="amt_tax" value="<?=$amt_tax?>"> <!-- 부가가치세 -->
<input type="hidden" name="pay_type" value="<?=$pay_type?>"> <!-- 결제 서비스 구분 -->
<input type="hidden" name="pay_trade_no" value="<?=$pay_trade_no?>"> <!-- 결제 거래번호 -->
<input type="hidden" name="mod_type" value="<?=$mod_type?>"> <!-- 변경 타입 -->
<input type="hidden" name="mod_value" value="<?=$mod_value?>"> <!-- 변경 요청 거래번호 -->
<input type="hidden" name="mod_gubn" value="<?=$mod_gubn?>"> <!-- 변경 요청 거래번호 구분 -->
<input type="hidden" name="mod_mny" value="<?=$mod_mny?>"> <!-- 변경 요청 금액 -->
<input type="hidden" name="rem_mny" value="<?=$rem_mny?>"> <!-- 변경처리 이전 금액 -->
<input type="hidden" name="cash_no" value="<?=$cash_no?>"> <!-- 현금영수증 거래번호 -->
<input type="hidden" name="receipt_no" value="<?=$receipt_no?>"> <!-- 현금영수증 승인번호 -->
<input type="hidden" name="app_time" value="<?=$app_time?>"> <!-- 승인시간(YYYYMMDDhhmmss) -->
<input type="hidden" name="reg_stat" value="<?=$reg_stat?>"> <!-- 등록 상태 코드 -->
<input type="hidden" name="reg_desc" value="<?=iconv("cp949", "utf-8", $reg_desc)?>"> <!-- 등록 상태 설명 -->
</form>
</body>
</html>

256
shop/kcp/pp_cli_hub_lib.php Normal file
View File

@ -0,0 +1,256 @@
<?php
/* ====================================================================== */
/* = PAGE : 지불 연동 PHP 라이브러리 = */
/* = ------------------------------------------------------------------ = */
/* = Copyright (c) 2006 KCP Inc. All Rights Reserverd. = */
/* ====================================================================== */
/* ====================================================================== */
/* = 지불 연동 CLASS = */
/* ====================================================================== */
class C_PAYPLUS_CLI
{
var $m_payx_data;
var $m_ordr_data;
var $m_rcvr_data;
var $m_escw_data;
var $m_modx_data;
var $m_encx_data;
/* -------------------------------------------------------------------- */
/* - 처리 결과 값 - */
/* -------------------------------------------------------------------- */
var $m_res_data;
var $m_res_cd;
var $m_res_msg;
/* -------------------------------------------------------------------- */
/* - 생성자 - */
/* -------------------------------------------------------------------- */
function C_PAYPLUS_CLI()
{
$this->m_payx_data="payx_data=";
$this->m_payx_common="";
$this->m_payx_card="";
$this->m_ordr_data="";
$this->m_rcvr_data="";
$this->m_escw_data="";
$this->m_modx_data="";
$this->m_encx_data="";
}
function mf_init( $mode )
{
if ( $mode == "1" )
{
if ( !extension_loaded( 'pp_cli_dl_php' ) )
{
dl( "pp_cli_dl_php.so" );
}
}
}
function mf_clear()
{
$this->m_payx_data="payx_data=";
$this->m_payx_common="";
$this->m_payx_card="";
$this->m_ordr_data="";
$this->m_rcvr_data="";
$this->m_escw_data="";
$this->m_modx_data="";
$this->m_encx_data="";
}
function mf_gen_trace_no( $site_cd, $ip, $mode )
{
if ( $mode == "1" )
{
$trace_no = lfPP_CLI_DL__gen_trace_no( $site_cd, $ip );
}
else
{
$trace_no = "";
}
return $trace_no;
}
function mf_set_data_us( $name, $val )
{
$data = "";
if ( $name != "" && $val != "" )
{
$data = $name . '=' . $val . chr( 31 );
}
return $data;
}
function mf_add_payx_data( $pay_type, $payx_data )
{
$this->m_payx_data .= ( $pay_type . '=' . $payx_data . chr( 30 ) );
}
function mf_set_ordr_data( $name, $val )
{
if ( $val != "" )
{
$this->m_ordr_data .= ( $name . '=' . $val . chr( 31 ) );
}
}
function mf_set_rcvr_data( $name, $val )
{
if ( $val != "" )
{
$this->m_rcvr_data .= ( $name . '=' . $val . chr( 31 ) );
}
}
function mf_set_escw_data( $name, $val )
{
if ( $val != "" )
{
$this->m_escw_data .= ( $name . '=' . $val . chr( 29 ) );
}
}
function mf_set_modx_data( $name, $val )
{
if ( $val != "" )
{
$this->m_modx_data .= ( $name . '=' . $val . chr( 31 ) );
}
}
/* -------------------------------------------------------------------- */
/* - FUNC : 지불 처리 함수 - */
/* -------------------------------------------------------------------- */
function mf_do_tx( $trace_no, $home_dir, $site_cd,
$site_key, $tx_cd, $pub_key_str,
$pa_url, $pa_port, $user_agent,
$ordr_idxx, $cust_ip,
$log_level, $opt, $mode )
{
$payx_data = $this->m_payx_data;
$ordr_data = $this->mf_get_data( "ordr_data", $this->m_ordr_data );
$rcvr_data = $this->mf_get_data( "rcvr_data", $this->m_rcvr_data );
$escw_data = $this->mf_get_data( "escw_data", $this->m_escw_data );
$modx_data = $this->mf_get_data( "mod_data", $this->m_modx_data );
if ( $mode == "1" )
{
$res_data = lfPP_CLI_DL__do_tx_2( $trace_no, $home_dir, $site_cd,
$site_key, $tx_cd, $pub_key_str,
$pa_url, $pa_port, $user_agent,
$ordr_idxx,
$payx_data, $ordr_data,
$rcvr_data, $escw_data,
$modx_data,
$this->m_encx_data, $this->m_encx_info,
$log_level, $opt );
}
else
{
$res_data = $this->mf_exec( $home_dir . "/bin/pp_cli",
"-h",
"home=" . $home_dir . "," .
"site_cd=" . $site_cd . "," .
"site_key=" . $site_key . "," .
"tx_cd=" . $tx_cd . "," .
"pa_url=" . $pa_url . "," .
"pa_port=" . $pa_port . "," .
"ordr_idxx=" . $ordr_idxx . "," .
"payx_data=" . $payx_data . "," .
"ordr_data=" . $ordr_data . "," .
"rcvr_data=" . $rcvr_data . "," .
"escw_data=" . $escw_data . "," .
"modx_data=" . $modx_data . "," .
"enc_data=" . $this->m_encx_data . "," .
"enc_info=" . $this->m_encx_info . "," .
"trace_no=" . $trace_no . "," .
"cust_ip=" . $cust_ip . "," .
"log_level=" . $log_level . "," .
"opt=" . $opt . "" );
if ( $res_data == "" )
{
$res_data = "res_cd=9502" . chr( 31 ) . "res_msg=연동 모듈 호출 오류";
}
}
parse_str( str_replace( chr( 31 ), "&", $res_data ), $this->m_res_data );
$this->m_res_cd = $this->m_res_data[ "res_cd" ];
$this->m_res_msg = $this->m_res_data[ "res_msg" ];
}
/* -------------------------------------------------------------------- */
/* - FUNC : 처리 결과 값을 리턴하는 함수 - */
/* -------------------------------------------------------------------- */
function mf_get_res_data( $name )
{
return $this->m_res_data[ $name ];
}
function mf_get_payx_data()
{
$my_data = "";
if ( $this->m_payx_common != "" || $this->m_payx_card != "" )
{
$my_data = "payx_data=";
}
if ( $this->m_payx_common != "" )
{
$my_data .= "common=" . $this->m_payx_common . chr( 30 );
}
if ( $this->m_payx_card != "" )
{
$my_data .= ( "card=" . $this->m_payx_card . chr( 30 ) );
}
return $my_data;
}
function mf_get_data( $data_name, $data )
{
$my_data = "";
if ( $data != "" )
{
$my_data = $data_name . "=" . $data;
}
else
{
$my_data = "";
}
return $my_data;
}
function mf_exec()
{
$arg = func_get_args();
if ( is_array( $arg[0] ) ) $arg = $arg[0];
$exec_cmd = array_shift( $arg );
while ( list(,$i) = each($arg) )
{
$exec_cmd .= " " . escapeshellarg( $i );
}
$rt = exec( $exec_cmd );
return $rt;
}
}
?>

322
shop/kcp/pp_cli_result.php Normal file
View File

@ -0,0 +1,322 @@
<?
include './_common.php';
/* ============================================================================== */
/* = PAGE : 결과 처리 PAGE = */
/* = -------------------------------------------------------------------------- = */
/* = Copyright (c) 2007 KCP Inc. All Rights Reserverd. = */
/* ============================================================================== */
?>
<?
/* ============================================================================== */
/* = 01. KCP 지불 서버 정보 설정 = */
/* = -------------------------------------------------------------------------- = */
$g_conf_home_dir = G4_SHOP_PATH.'/kcp'; // ※ 쇼핑몰 모듈 설치 절대 경로 bin전까지
$g_conf_log_level = "3";
if ($default['de_card_test']) {
$default['de_kcp_mid'] = 'T0000';
}
if ($default['de_kcp_mid'] == 'T0000') {
$g_conf_pa_url = "testpaygw.kcp.co.kr"; // ※ 테스트: testpaygw.kcp.co.kr, 리얼: paygw.kcp.co.kr
$g_conf_pa_port = "8090"; // ※ 테스트: 8090, 리얼: 8090
}
else {
$g_conf_pa_url = "paygw.kcp.co.kr";
$g_conf_pa_port = "8090";
}
$g_conf_tx_mode = 0;
/* ============================================================================== */
/* ============================================================================== */
/* = 지불 결과 = */
/* = -------------------------------------------------------------------------- = */
$req_tx = $_POST[ "req_tx" ]; // 요청 종류
$bSucc = $_POST[ "bSucc" ]; // DB처리 여부
$trad_time = $_POST[ "trad_time" ]; // 원거래 시각
/* = -------------------------------------------------------------------------- = */
$ordr_idxx = $_POST[ "ordr_idxx" ]; // 주문번호
$buyr_name = $_POST[ "buyr_name" ]; // 주문자 이름
$buyr_tel1 = $_POST[ "buyr_tel1" ]; // 주문자 전화번호
$buyr_mail = $_POST[ "buyr_mail" ]; // 주문자 메일
$good_name = $_POST[ "good_name" ]; // 주문상품명
$comment = $_POST[ "comment" ]; // 비고
/* = -------------------------------------------------------------------------- = */
$corp_type = $_POST[ "corp_type" ]; // 사업장 구분
$corp_tax_type = $_POST[ "corp_tax_type" ]; // 과세/면세 구분
$corp_tax_no = $_POST[ "corp_tax_no" ]; // 발행 사업자 번호
$corp_nm = $_POST[ "corp_nm" ]; // 상호
$corp_owner_nm = $_POST[ "corp_owner_nm" ]; // 대표자명
$corp_addr = $_POST[ "corp_addr" ]; // 사업장 주소
$corp_telno = $_POST[ "corp_telno" ]; // 사업장 대표 연락처
/* = -------------------------------------------------------------------------- = */
$tr_code = $_POST[ "tr_code" ]; // 발행용도
$id_info = $_POST[ "id_info" ]; // 신분확인 ID
$amt_tot = $_POST[ "amt_tot" ]; // 거래금액 총 합
$amt_sup = $_POST[ "amt_sup" ]; // 공급가액
$amt_svc = $_POST[ "amt_svc" ]; // 봉사료
$amt_tax = $_POST[ "amt_tax" ]; // 부가가치세
/* = -------------------------------------------------------------------------- = */
$pay_type = $_POST[ "pay_type" ]; // 결제 서비스 구분
$pay_trade_no = $_POST[ "pay_trade_no" ]; // 결제 거래번호
/* = -------------------------------------------------------------------------- = */
$mod_type = $_POST[ "mod_type" ]; // 변경 타입
$mod_value = $_POST[ "mod_value" ]; // 변경 요청 거래번호
$mod_gubn = $_POST[ "mod_gubn" ]; // 변경 요청 거래번호 구분
$mod_mny = $_POST[ "mod_mny" ]; // 변경 요청 금액
$rem_mny = $_POST[ "rem_mny" ]; // 변경처리 이전 금액
/* = -------------------------------------------------------------------------- = */
$res_cd = $_POST[ "res_cd" ]; // 응답코드
$res_msg = $_POST[ "res_msg" ]; // 응답메시지
$cash_no = $_POST[ "cash_no" ]; // 현금영수증 거래번호
$receipt_no = $_POST[ "receipt_no" ]; // 현금영수증 승인번호
$app_time = $_POST[ "app_time" ]; // 승인시간(YYYYMMDDhhmmss)
$reg_stat = $_POST[ "reg_stat" ]; // 등록 상태 코드
$reg_desc = $_POST[ "reg_desc" ]; // 등록 상태 설명
/* ============================================================================== */
$req_tx_name = "";
if( $req_tx == "pay" )
{
$req_tx_name = "등록";
}
else if( $req_tx == "mod" )
{
$req_tx_name = "변경/조회";
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8>">
<link href="css/sample.css" rel="stylesheet" type="text/css">
<script language="javascript">
//현금영수증 연동 스크립트
function receiptView(cash_no)
{
var receiptWin = "http://admin.kcp.co.kr/Modules/Service/Cash/Cash_Bill_Common_View.jsp?cash_no="+cash_no;
window.open(receiptWin , "" , "width=360, height=647")
}
</script>
</head>
<body>
<center>
<table border="0" cellpadding="0" cellspacing="1" width="500" align="center">
<tr>
<td align="left" height="25"><img src="./img/KcpLogo.jpg" border="0" width="65" height="50"></td>
<td align="right" class="txt_main">KCP Online Payment System</td>
</tr>
<tr>
<td bgcolor="CFCFCF" height="3" colspan="2"></td>
</tr>
<tr>
<td colspan="2">
<br>
<table width="90%" align="center">
<tr>
<td bgcolor="CFCFCF" height="2"></td>
</tr>
<tr>
<td align="center">결과 페이지(현금영수증 <?=$req_tx_name?>)</td>
</tr>
<tr>
<td bgcolor="CFCFCF" height="2"></td>
</tr>
</table>
<?
if ($req_tx == "pay") // 거래 구분 : 등록
{
if (!$bSucc == "false") // 업체 DB 처리 정상
{
if ($res_cd == "0000") // 정상 승인
{
?>
<table width="85%" align="center" border="0" cellpadding="0" cellspacing="1">
<tr>
<td>결과코드</td>
<td><?=$res_cd?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>결과 메세지</td>
<td><?=$res_msg?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>현금영수증 거래번호</td>
<td><?=$cash_no?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>현금영수증 승인번호</td>
<td><?=$receipt_no?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>등록 상태 코드</td>
<td><?=$reg_stat?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>등록 상태 설명</td>
<td><?=$reg_desc?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>승인시간</td>
<td><?=$app_time?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>현금영수증 URL</td>
<td><input type="button" name="receiptView" value="영수증 확인" class="box" onClick="javascript:receiptView('<?=$cash_no?>')"></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td colspan="2">※ 영수증 확인은 실 등록의 경우에만 가능합니다.</td>
</tr>
</table>
<?
}
else // 승인 실패
{
?>
<table width="85%" align="center" border="0" cellpadding="0" cellspacing="1">
<tr>
<td>결과코드</td>
<td><?=$res_cd?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>결과 메세지</td>
<td><?=$res_msg?></td>
</tr>
</table>
<?
}
}
else // 업체 DB 처리 실패
{
?>
<table width="85%" align="center" border="0" cellpadding="0" cellspacing="1">
<tr>
<td nowrap>취소 결과코드</td>
<td><?=$res_cd?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td nowrap>취소 결과 메세지</td>
<td><?=$res_msg?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td nowrap>상세메세지</td>
<td>
<?
if ($res_cd == "0000")
{
echo "결제는 정상적으로 이루어졌지만 쇼핑몰에서 결제 결과를 처리하는 중 오류가 발생하여 시스템에서 자동으로 취소 요청을 하였습니다. <br> 쇼핑몰로 전화하여 확인하시기 바랍니다.";
}
else
{
echo "결제는 정상적으로 이루어졌지만 쇼핑몰에서 결제 결과를 처리하는 중 오류가 발생하여 시스템에서 자동으로 취소 요청을 하였으나, <br> <b>취소가 실패 되었습니다.</b><br> 쇼핑몰로 전화하여 확인하시기 바랍니다.";
}
?>
</td>
</tr>
</table>
<?
}
}
else if ($req_tx == "mod") // 거래 구분 : 조회/취소 요청
{
if ($res_cd == "0000")
{
?>
<table width="85%" align="center" border="0" cellpadding="0" cellspacing="1">
<tr>
<td>결과코드</td>
<td><?=$res_cd?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>결과 메세지</td>
<td><?=$res_msg?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>현금영수증 거래번호</td>
<td><?=$cash_no?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>현금영수증 승인번호</td>
<td><?=$receipt_no?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>등록 상태 코드</td>
<td><?=$reg_stat?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>등록 상태 설명</td>
<td><?=$reg_desc?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>승인시간</td>
<td><?=$app_time?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>현금영수증 URL</td>
<td><input type="button" name="receiptView" value="영수증 확인" class="box" onClick="javascript:receiptView('<?=$cash_no?>')"></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td colspan="2">※ 영수증 확인은 실 등록의 경우에만 가능합니다.</td>
</tr>
</table>
<?
}
else
{
?>
<table width="85%" align="center" border="0" cellpadding="0" cellspacing="1">
<tr>
<td>결과코드</td>
<td><?=$res_cd?></td>
</tr>
<tr><td colspan="2"><IMG SRC="./img/dot_line.gif" width="100%"></td></tr>
<tr>
<td>결과 메세지</td>
<td><?=$res_msg?></td>
</tr>
</table>
<?
}
}
?>
<table width="90%" align="center">
<tr>
<td bgcolor="CFCFCF" height="2"></td>
</tr>
<tr>
<td height="2">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="CFCFCF" height="3" colspan="2"></td>
</tr>
</table>
</center>
</body>
</html>