KG이니시스 TX모듈을 사용하는 코드를 API로 전환 건

This commit is contained in:
thisgun
2023-04-13 20:10:48 +09:00
parent b01adc51c7
commit 4b92543c61
35 changed files with 457 additions and 6716 deletions

View File

@ -13,8 +13,6 @@ if ($config['cf_sms_use'] && $config['cf_icode_id'] && $config['cf_icode_pw']) {
$userinfo = get_icode_userinfo($config['cf_icode_id'], $config['cf_icode_pw']);
}
check_log_folder(G5_SHOP_PATH.'/inicis/key', false);
$g5['title'] = '쇼핑몰설정';
include_once (G5_ADMIN_PATH.'/admin.head.php');
@ -68,8 +66,7 @@ if(!isset($default['de_pg_service'])) {
// inicis 필드 추가
if(!isset($default['de_inicis_mid'])) {
sql_query(" ALTER TABLE `{$g5['g5_shop_default_table']}`
ADD `de_inicis_mid` varchar(255) NOT NULL DEFAULT '' AFTER `de_kcp_site_key`,
ADD `de_inicis_admin_key` varchar(255) NOT NULL DEFAULT '' AFTER `de_inicis_mid` ", true);
ADD `de_inicis_mid` varchar(255) NOT NULL DEFAULT '' AFTER `de_kcp_site_key` ", true);
}
// 모바일 초기화면 이미지 줄 수 필드 추가
@ -137,7 +134,7 @@ if(!isset($default['de_kakaopay_mid'])) {
// 이니시스 웹결제 사인키 필드 추가
if(!isset($default['de_inicis_sign_key'])) {
sql_query(" ALTER TABLE `{$g5['g5_shop_default_table']}`
ADD `de_inicis_sign_key` varchar(255) NOT NULL DEFAULT '' AFTER `de_inicis_admin_key` ", true);
ADD `de_inicis_sign_key` varchar(255) NOT NULL DEFAULT '' ", true);
}
// 네이버페이 필드추가
@ -202,6 +199,14 @@ if( ! isset($default['de_easy_pay_services']) ){
sql_query($sql, false);
}
// KG 이니시스 iniapi_key 추가
if( ! isset($default['de_inicis_iniapi_key']) ){
$sql = "ALTER TABLE `{$g5['g5_shop_default_table']}`
ADD COLUMN `de_inicis_iniapi_key` VARCHAR(30) NOT NULL DEFAULT '' AFTER `de_inicis_sign_key`,
ADD COLUMN `de_inicis_iniapi_iv` VARCHAR(30) NOT NULL DEFAULT '' AFTER `de_inicis_iniapi_key`; ";
sql_query($sql, false);
}
if( function_exists('pg_setting_check') ){
pg_setting_check(true);
}
@ -830,17 +835,24 @@ if(!$default['de_kakaopay_cancelpwd']){
</td>
</tr>
<tr class="pg_info_fld inicis_info_fld">
<th scope="row"><label for="de_inicis_admin_key">KG이니시스 키패스워드</label></th>
<th scope="row"><label for="de_inicis_sign_key">KG이니시스 웹결제 사인키</label></th>
<td>
<?php echo help("KG이니시스에서 발급받은 4자리 상점 키패스워드를 입력합니다.\nKG이니시스 점관리자 패스워드와 관련이 없습니다.\n키패스워드 값을 확인하시려면 상점측에 발급된 키파일 안의 readme.txt 파일을 참조해 주십시오"); ?>
<input type="text" name="de_inicis_admin_key" value="<?php echo get_sanitize_input($default['de_inicis_admin_key']); ?>" id="de_inicis_admin_key" class="frm_input" size="5" maxlength="4">
<?php echo help("KG이니시스에서 발급받은 웹결제 사인키를 입력합니다.\n<a href='https://iniweb.inicis.com/' target='_blank'>KG이니시스 가맹점관리자</a> > 상점정보 > 계약정보 > 부가정보의 웹결제 signkey생성 조회 버튼 클릭, 팝업창에서 생성 버튼 클릭 후 해당 값을 입력합니다."); ?>
<input type="text" name="de_inicis_sign_key" value="<?php echo get_sanitize_input($default['de_inicis_sign_key']); ?>" id="de_inicis_sign_key" class="frm_input" size="40" maxlength="50">
</td>
</tr>
<tr class="pg_info_fld inicis_info_fld">
<th scope="row"><label for="de_inicis_sign_key">KG이니시스 웹결제 사인키</label></th>
<th scope="row"><label for="de_inicis_iniapi_key">KG이니시스 INIAPI KEY</label></th>
<td>
<?php echo help("KG이니시스에서 발급받은 웹결제 사인키를 입력합니다.\nKG이니시스 점관리자 > 상점정보 > 계약정보 > 부가정보의 웹결제 signkey생성 조회 버튼 클릭, 팝업창에서 생성 버튼 클릭 후 해당 값을 입력합니다."); ?>
<input type="text" name="de_inicis_sign_key" value="<?php echo get_sanitize_input($default['de_inicis_sign_key']); ?>" id="de_inicis_sign_key" class="frm_input" size="40" maxlength="50">
<?php echo help("<a href='https://iniweb.inicis.com/' target='_blank'>KG이니시스 가맹점관리자</a> > 상점정보 > 계약정보 > 부가정보 > INIAPI key 생성 조회 하여 KEY를 여기에 입력합니다.\n이 항목은 영카트 주문에서 kg이니시스 PG 결제 취소, 부분취소, 에스크로 배송등록, 현금영수증 발급에 필요합니다."); ?>
<input type="text" name="de_inicis_iniapi_key" value="<?php echo get_sanitize_input($default['de_inicis_iniapi_key']); ?>" id="de_inicis_iniapi_key" class="frm_input" size="30" maxlength="30">
</td>
</tr>
<tr class="pg_info_fld inicis_info_fld">
<th scope="row"><label for="de_inicis_iniapi_iv">KG이니시스 INIAPI IV</label></th>
<td>
<?php echo help("<a href='https://iniweb.inicis.com/' target='_blank'>KG이니시스 가맹점관리자</a> > 상점정보 > 계약정보 > 부가정보 > INIAPI IV 생성 조회 하여 KEY를 여기에 입력합니다.\n이 항목은 영카트 주문에서 kg이니시스 현금영수증 발급에 필요합니다."); ?>
<input type="text" name="de_inicis_iniapi_iv" value="<?php echo get_sanitize_input($default['de_inicis_iniapi_iv']); ?>" id="de_inicis_iniapi_iv" class="frm_input" size="30" maxlength="30">
</td>
</tr>
<tr class="pg_info_fld inicis_info_fld">
@ -849,7 +861,7 @@ if(!$default['de_kakaopay_cancelpwd']){
<a href="http://sir.kr/main/service/samsungpay.php" target="_blank" class="kg_btn">삼성페이 서비스신청하기</a>
</th>
<td>
<?php echo help("KG이니시스와 별도로 <strong>삼성페이 사용 계약을 하신 경우</strong>에만 체크해주세요. (모바일 주문서 결제수단에 삼성페이가 노출됩니다.) <br >실결제시 반드시 결제대행사 KG이니시스 항목에 상점 아이디와 키패스워드를 입력해 주세요.", 50); ?>
<?php echo help("KG이니시스와 별도로 <strong>삼성페이 사용 계약을 하신 경우</strong>에만 체크해주세요. (모바일 주문서 결제수단에 삼성페이가 노출됩니다.) <br >실결제시 반드시 결제대행사 KG이니시스 항목에 상점 아이디와 웹결제 사인키를 입력해 주세요.", 50); ?>
<input type="checkbox" name="de_samsung_pay_use" value="1" id="de_samsung_pay_use"<?php echo $default['de_samsung_pay_use']?' checked':''; ?>> <label for="de_samsung_pay_use">사용</label>
</td>
</tr>
@ -858,7 +870,7 @@ if(!$default['de_kakaopay_cancelpwd']){
<label for="de_inicis_lpay_use">KG이니시스 L.pay 사용</label>
</th>
<td>
<?php echo help("체크시 KG이니시스 L.pay를 사용합니다. <br >실결제시 반드시 결제대행사 KG이니시스 항목의 상점 정보( 아이디, 키패스워드, 웹결제 사인키 )를 입력해 주세요.", 50); ?>
<?php echo help("체크시 KG이니시스 L.pay를 사용합니다. <br >실결제시 반드시 결제대행사 KG이니시스 항목의 상점 정보( 아이디, 웹결제 사인키 )를 입력해 주세요.", 50); ?>
<input type="checkbox" name="de_inicis_lpay_use" value="1" id="de_inicis_lpay_use"<?php echo $default['de_inicis_lpay_use']?' checked':''; ?>> <label for="de_inicis_lpay_use">사용</label>
</td>
</tr>
@ -867,7 +879,7 @@ if(!$default['de_kakaopay_cancelpwd']){
<label for="de_inicis_kakaopay_use">KG이니시스 카카오페이 사용</label>
</th>
<td>
<?php echo help("체크시 KG이니시스 결제의 카카오페이를 사용합니다. 주문서 결제수단에 카카오페이가 노출됩니다. <br>실결제시 반드시 결제대행사 KG이니시스 항목의 상점 정보( 아이디, 키패스워드, 웹결제 사인키 )를 입력해 주세요.", 50); ?>
<?php echo help("체크시 KG이니시스 결제의 카카오페이를 사용합니다. 주문서 결제수단에 카카오페이가 노출됩니다. <br>실결제시 반드시 결제대행사 KG이니시스 항목의 상점 정보( 아이디, 웹결제 사인키 )를 입력해 주세요.", 50); ?>
<input type="checkbox" name="de_inicis_kakaopay_use" value="1" id="de_inicis_kakaopay_use"<?php echo $default['de_inicis_kakaopay_use']?' checked':''; ?>> <label for="de_inicis_kakaopay_use">사용</label>
</td>
</tr>
@ -2012,20 +2024,8 @@ if($default['de_iche_use'] || $default['de_vbank_use'] || $default['de_hp_use']
} catch(Exception $e) {
}
if(!is_dir($log_path)) {
echo '<script>'.PHP_EOL;
echo 'alert("'.str_replace(G5_PATH.'/', '', G5_SHOP_PATH).'/inicis 폴더 안에 log 폴더를 생성하신 후 쓰기권한을 부여해 주십시오.\n> mkdir log\n> chmod 707 log");'.PHP_EOL;
echo '</script>'.PHP_EOL;
} else {
if(!is_writable($log_path)) {
echo '<script>'.PHP_EOL;
echo 'alert("'.str_replace(G5_PATH.'/', '',$log_path).' 폴더에 쓰기권한을 부여해 주십시오.\n> chmod 707 log");'.PHP_EOL;
echo '</script>'.PHP_EOL;
} else {
if( function_exists('check_log_folder') && is_writable($log_path) ){
check_log_folder($log_path);
}
}
if( function_exists('check_log_folder') && is_writable($log_path) ){
check_log_folder($log_path);
}
}

View File

@ -160,7 +160,8 @@ $check_sanitize_keys = array(
'cf_lg_mid', //LG유플러스 상점아이디
'cf_lg_mert_key', //LG유플러스 MERT KEY
'de_inicis_mid', //KG이니시스 상점아이디
'de_inicis_admin_key', //KG이니시스 키패스워드
'de_inicis_iniapi_key', //KG이니시스 INIAPI KEY
'de_inicis_iniapi_iv', //KG이니시스 INIAPI IV
'de_inicis_sign_key', //KG이니시스 웹결제 사인키
'de_samsung_pay_use', //KG이니시스 삼성페이 사용
'de_inicis_lpay_use', //KG이니시스 Lpay 사용
@ -399,7 +400,8 @@ $sql = " update {$g5['g5_shop_default_table']}
de_kcp_mid = '{$de_kcp_mid}',
de_kcp_site_key = '{$de_kcp_site_key}',
de_inicis_mid = '{$de_inicis_mid}',
de_inicis_admin_key = '{$de_inicis_admin_key}',
de_inicis_iniapi_key = '{$de_inicis_iniapi_key}',
de_inicis_iniapi_iv = '{$de_inicis_iniapi_iv}',
de_inicis_sign_key = '{$de_inicis_sign_key}',
de_iche_use = '{$de_iche_use}',
de_sms_cont1 = '{$_POST['de_sms_cont1']}',

View File

@ -222,46 +222,27 @@ if (in_array($_POST['ct_status'], $status_cancel)) {
break;
case 'inicis':
include_once(G5_SHOP_PATH.'/settle_inicis.inc.php');
$cancel_msg = iconv_euckr('쇼핑몰 운영자 승인 취소');
$cancel_msg = '쇼핑몰 운영자 승인 취소';
$args = array(
'paymethod' => get_type_inicis_paymethod($od['od_settle_case']),
'tid' => $od['od_tno'],
'msg' => $cancel_msg
);
/*********************
* 3. 취소 정보 설정 *
*********************/
$inipay->SetField("type", "cancel"); // 고정 (절대 수정 불가)
$inipay->SetField("mid", $default['de_inicis_mid']); // 상점아이디
/**************************************************************************************************
* admin 은 키패스워드 변수명입니다. 수정하시면 안됩니다. 1111의 부분만 수정해서 사용하시기 바랍니다.
* 키패스워드는 상점관리자 페이지(https://iniweb.inicis.com)의 비밀번호가 아닙니다. 주의해 주시기 바랍니다.
* 키패스워드는 숫자 4자리로만 구성됩니다. 이 값은 키파일 발급시 결정됩니다.
* 키패스워드 값을 확인하시려면 상점측에 발급된 키파일 안의 readme.txt 파일을 참조해 주십시오.
**************************************************************************************************/
$inipay->SetField("admin", $default['de_inicis_admin_key']); //비대칭 사용키 키패스워드
$inipay->SetField("tid", $od['od_tno']); // 취소할 거래의 거래아이디
$inipay->SetField("cancelmsg", $cancel_msg); // 취소사유
$response = inicis_tid_cancel($args);
$result = json_decode($response, true);
/****************
* 4. 취소 요청 *
****************/
$inipay->startAction();
/****************************************************************
* 5. 취소 결과 *
* *
* 결과코드 : $inipay->getResult('ResultCode') ("00"이면 취소 성공) *
* 결과내용 : $inipay->getResult('ResultMsg') (취소결과에 대한 설명) *
* 취소날짜 : $inipay->getResult('CancelDate') (YYYYMMDD) *
* 취소시각 : $inipay->getResult('CancelTime') (HHMMSS) *
* 현금영수증 취소 승인번호 : $inipay->getResult('CSHR_CancelNum') *
* (현금영수증 발급 취소시에만 리턴됨) *
****************************************************************/
$res_cd = $inipay->getResult('ResultCode');
$res_msg = $inipay->getResult('ResultMsg');
if($res_cd != '00') {
$pg_res_cd = $res_cd;
$pg_res_msg = iconv_utf8($res_msg);
if (isset($result['resultCode'])) {
if ($result['resultCode'] != '00') {
$pg_res_cd = $result['resultCode'];
$pg_res_msg = $result['resultMsg'];
}
} else {
$pg_res_cd = '';
$pg_res_msg = 'curl 로 데이터를 받지 못했습니다.';
}
break;
case 'KAKAOPAY':
include_once(G5_SHOP_PATH.'/settle_kakaopay.inc.php');

View File

@ -349,7 +349,8 @@ CREATE TABLE IF NOT EXISTS `g5_shop_default` (
`de_kcp_mid` varchar(255) NOT NULL DEFAULT '',
`de_kcp_site_key` varchar(255) NOT NULL DEFAULT '',
`de_inicis_mid` varchar(255) NOT NULL DEFAULT '',
`de_inicis_admin_key` varchar(255) NOT NULL DEFAULT '',
`de_inicis_iniapi_key` varchar(30) NOT NULL DEFAULT '',
`de_inicis_iniapi_iv` varchar(30) NOT NULL DEFAULT '',
`de_inicis_sign_key` varchar(255) NOT NULL DEFAULT '',
`de_iche_use` tinyint(4) NOT NULL DEFAULT '0',
`de_easy_pay_use` tinyint(4) NOT NULL DEFAULT '0',

View File

@ -14,12 +14,10 @@ if ($default['de_card_test']) {
if ($default['de_escrow_use'] == 1) {
// 에스크로결제 테스트
$default['de_inicis_mid'] = 'iniescrow0';
$default['de_inicis_admin_key'] = '1111';
}
else {
// 일반결제 테스트
$default['de_inicis_mid'] = 'INIpayTest';
$default['de_inicis_admin_key'] = '1111';
}
}
else {
@ -109,6 +107,8 @@ $inicis_cardpoint = $default['de_inicis_cartpoint_use'] ? '&cp_yn=Y' : '';
// 예) BC 2,3,6개월, 국민 3,6개월, 삼성 6,9개월 무이자 : 11-2:3:6^06-3:6^12-3:6:4
//$inicis_cardpoint .= ''; // &merc_noint=Y&noint_quota=카드사코드-개월:개월^추가카드사코드-개월:개월:개월 형식으로 설정
require_once(G5_SHOP_PATH.'/inicis/libs/inicis_youngcart_fn.php');
$noti_url = G5_MSHOP_URL.'/inicis/settle_common.php';
$next_url = G5_MSHOP_URL.'/inicis/pay_approval.php';
$return_url = G5_MSHOP_URL.'/inicis/pay_return.php?oid=';

View File

@ -5,27 +5,12 @@ if($od['od_pg'] != 'inicis') return;
include_once(G5_SHOP_PATH.'/settle_inicis.inc.php');
$oid = $od['od_id'];
$EscrowType = 'I';
$invoice = $escrow_numb;
$dlv_charge = 'SH'; // 배송비 지급형태 (SH : 판매자부담, BH : 구매자부담)
$sendName = iconv_euckr($od['od_name']);
$sendPost = $od['od_zip1'].$od['od_zip2'];
$sendAddr1 = iconv_euckr($od['od_addr1']);
$sendAddr2 = iconv_euckr($od['od_addr2']);
$sendTel = $od['od_tel'];
$recvName = iconv_euckr($od['od_b_name']);
$recvPost = $od['od_b_zip1'].$od['od_b_zip2'];
$recvAddr = iconv_euckr($od['od_b_addr1'].($od['od_b_addr2'] ? ' ' : '').$od['od_b_addr2']);
$recvTel = $od['od_b_tel'];
$price = $od['od_receipt_price'];
// 택배회사 코드
// 택배회사 코드, https://manual.inicis.com/iniweb/code.html 에서 조회
$exCode = array(
'대한통운' => 'korex',
'아주택배' => 'ajutb',
'KT로지스' => 'ktlogistics',
'현대택배' => 'hyundai',
'롯데택배(구.현대)' => 'hyundai',
'CJ대한통운' => 'cjgls',
'한진택배' => 'hanjin',
'트라넷' => 'tranet',
@ -39,76 +24,109 @@ $exCode = array(
'동부택배' => 'dongbu',
'우체국' => 'EPOST',
'우편등기' => 'registpost',
'경동택배' => 'kdexp',
'천일택배' => 'chunil',
'대신택배' => 'daesin',
'일양로지스' => 'ilyang',
'호남택배' => 'honam',
'편의점택배' => 'cvsnet',
'합동택배' => 'hdexp',
'기타택배' => '9999'
);
$dlv_exName = $escrow_corp;
$dlv_exCode = $exCode[$dlv_exName];
if(!$dlv_exCode)
$dlv_exCode = '9999';
//step1. 요청을 위한 파라미터 설정
// 가맹점관리자 > 상점정보 > 계약정보 > 부가정보 > INIAPI key 생성조회
if (function_exists('get_inicis_iniapi_key')) {
$key = get_inicis_iniapi_key();
} else {
$key = ! $default['de_card_test'] ? $default['de_inicis_iniapi_key'] : "ItEQKi3rY7uvDS8l";
}
/*********************
* 3. 지불 정보 설정 *
*********************/
$inipay->SetField("tid", $escrow_tno); // 거래아이디
$inipay->SetField("mid", $default['de_inicis_mid']); // 상점아이디
/**************************************************************************************************
* admin 은 키패스워드 변수명입니다. 수정하시면 안됩니다. 1111의 부분만 수정해서 사용하시기 바랍니다.
* 키패스워드는 상점관리자 페이지(https://iniweb.inicis.com)의 비밀번호가 아닙니다. 주의해 주시기 바랍니다.
* 키패스워드는 숫자 4자리로만 구성됩니다. 이 값은 키파일 발급시 결정됩니다.
* 키패스워드 값을 확인하시려면 상점측에 발급된 키파일 안의 readme.txt 파일을 참조해 주십시오.
**************************************************************************************************/
$inipay->SetField("admin", $default['de_inicis_admin_key']); // 키패스워드(상점아이디에 따라 변경)
$inipay->SetField("type", "escrow"); // 고정 (절대 수정 불가)
$inipay->SetField("escrowtype", "dlv"); // 고정 (절대 수정 불가)
$inipay->SetField("dlv_ip", getenv("REMOTE_ADDR")); // 고정
$dlv_exName = $escrow_corp;
$type = "Dlv"; //"Dlv" 고정
$mid = $default['de_inicis_mid'];
$clientIp = $_SERVER['SERVER_ADDR']; // 가맹점 요청 서버IP, 상점 임의 설정 가능 (상점측 서버 구분을 위함)
$timestamp = date("YmdHis");
$tid = $escrow_tno; //에스크로 결제 승인TID
$oid = $od['od_id'];
$price = $od['od_receipt_price'];
$report = "I"; //에스크로 등록형태 ["I":등록, "U":변경]
$invoice = $escrow_numb; //운송장번호
$registName = $member['mb_id'];
$exCode = isset($exCode[$dlv_exName]) ? $exCode[$dlv_exName] : ''; //택배사코드 참고(https://manual.inicis.com/code/#gls)
$exName = $dlv_exName;
$charge = "SH"; //배송비 지급형태 ("SH":판매자부담, "BH":구매자부담)
$invoiceDay = G5_TIME_YMDHIS; //배송등록 확인일자 (String 으로 timestamp 사용 가능)
$sendName = $od['od_name'];
$sendTel = $od['od_tel'];
$sendPost = $od['od_zip1'].$od['od_zip2'];
$sendAddr1 = $od['od_addr1'].' '.$od['od_addr2'];
$recvName = $od['od_b_name'];
$recvTel = $od['od_b_tel'];
$recvPost = $od['od_b_zip1'].$od['od_b_zip2'];
$recvAddr = $od['od_b_addr1'].($od['od_b_addr2'] ? ' ' : '').$od['od_b_addr2'];
$inipay->SetField("oid", $oid);
$inipay->SetField("soid", "1");
//$inipay->SetField("dlv_date", $dlv_date);
//$inipay->SetField("dlv_time", $dlv_time);
$inipay->SetField("dlv_report", $EscrowType);
$inipay->SetField("dlv_invoice", $invoice);
$inipay->SetField("dlv_name", $member['mb_id']);
if(!$exCode)
$exCode = '9999';
$inipay->SetField("dlv_excode", $dlv_exCode);
$inipay->SetField("dlv_exname", $dlv_exName);
$inipay->SetField("dlv_charge", $dlv_charge);
// hash => INIAPIKey + type + timestamp + clientIp + mid + oid + tid + price
$plainText = (string)$key.(string)$type.(string)$timestamp.(string)$clientIp.(string)$mid.(string)$oid.(string)$tid.(string)$price;
$inipay->SetField("dlv_invoiceday", G5_TIME_YMDHIS);
$inipay->SetField("dlv_sendname", $sendName);
$inipay->SetField("dlv_sendpost", $sendPost);
$inipay->SetField("dlv_sendaddr1", $sendAddr1);
$inipay->SetField("dlv_sendaddr2", $sendAddr2);
$inipay->SetField("dlv_sendtel", $sendTel);
// hash 암호화
$hashData = hash("sha512", $plainText);
$inipay->SetField("dlv_recvname", $recvName);
$inipay->SetField("dlv_recvpost", $recvPost);
$inipay->SetField("dlv_recvaddr", $recvAddr);
$inipay->SetField("dlv_recvtel", $recvTel);
//step2. key=value 로 post 요청
$inipay->SetField("dlv_goodscode", $goodsCode);
$inipay->SetField("dlv_goods", $goods);
$inipay->SetField("dlv_goodscnt", $goodCnt);
$inipay->SetField("price", $price);
$inipay->SetField("dlv_reserved1", $reserved1);
$inipay->SetField("dlv_reserved2", $reserved2);
$inipay->SetField("dlv_reserved3", $reserved3);
$data = array(
'type' => $type,
'mid' => $mid,
'clientIp' => $clientIp,
'timestamp' => $timestamp,
'tid' => $tid,
'oid' => $oid,
'price' => $price,
'report' => $report,
'invoice' => $invoice,
'registName' => $registName,
'exCode' => $exCode,
'exName' => $exName,
'charge' => $charge,
'invoiceDay' => $invoiceDay,
'sendName' => $sendName,
'sendTel' => $sendTel,
'sendPost' => $sendPost,
'sendAddr1' => $sendAddr1,
'recvName' => $recvName,
'recvTel' => $recvTel,
'recvPost' => $recvPost,
'recvAddr' => $recvAddr,
'hashData'=> $hashData
);
$inipay->SetField("pgn", $pgn);
// Request URL
$url = "https://iniapi.inicis.com/api/v1/escrow";
/*********************
* 3. 배송 등록 요청 *
*********************/
$inipay->startAction();
$ch = curl_init(); // curl 초기화
curl_setopt($ch, CURLOPT_URL, $url); // 전송 URL 지정하기
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 요청 결과를 문자열로 반환
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // connection timeout 10초
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); // POST data
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // (※ 로컬 테스트에서만 사용) 원격 서버의 인증서가 유효한지 검사 안함
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded; charset=utf-8')); // 전송헤더 설정
curl_setopt($ch, CURLOPT_POST, 1); // post 전송
$response = curl_exec($ch);
curl_close($ch);
//step3. 요청 결과
$ini_result = json_decode($response, true);
/**********************
* 4. 배송 등록 결과 *
**********************/
$tid = $inipay->GetResult("tid"); // 거래번호
$resultCode = $inipay->GetResult("ResultCode"); // 결과코드 ("00"이면 지불 성공)
$resultMsg = $inipay->GetResult("ResultMsg"); // 결과내용 (지불결과에 대한 설명)
$dlv_date = $inipay->GetResult("DLV_Date");
$dlv_time = $inipay->GetResult("DLV_Time");
$resultCode = $ini_result['resultCode']; // 결과코드 ("00"이면 지불 성공)
$resultMsg = $ini_result['resultMsg']; // 결과내용 (지불결과에 대한 설명)
$dlv_date = $ini_result['resultDate'];
$dlv_time = $ini_result['resultTime'];

View File

@ -46,18 +46,16 @@ if($cancelFlag == "true")
sql_query($sql, false);
}
$ini_paymethod = get_type_inicis_paymethod($od_settle_case);
$TID = $tno;
$inipay->SetField("type", "cancel"); // 고정
if( $default['de_inicis_admin_key'] ){
$inipay->SetField("mid", $mid);
$inipay->SetField("admin", $default['de_inicis_admin_key']);
}
$inipay->SetField("tid", $TID); // 고정
$inipay->SetField("cancelmsg", "DB FAIL"); // 취소사유
$inipay->startAction();
if($inipay->GetResult('ResultCode') == "00")
{
$inipay->MakeTXErrMsg(MERCHANT_DB_ERR,"Merchant DB FAIL");
if ($ini_paymethod){
$args = array(
'paymethod' => $ini_paymethod,
'tid' => $tno,
'msg' => 'DB FAIL' // 취소사유
);
$response = inicis_tid_cancel($args);
}
}

View File

@ -1,2 +0,0 @@
Order deny,allow
Deny from all

View File

@ -1 +0,0 @@
pm/4rSNJdLw=

View File

@ -1,16 +0,0 @@
-----BEGIN CERTIFICATE-----
MIICmzCCAgQCAQAwDQYJKoZIhvcNAQEEBQAwgZUxCzAJBgNVBAYTAktSMRUwEwYD
VQQIDAzrjIDtlZzrr7zqta0xDTALBgNVBAcTBG51bGwxGjAYBgNVBAoMESjso7wp
7J2064uI7Iuc7IqkMQswCQYDVQQLEwJFQzETMBEGA1UEAxMKSU5JcGF5VGVzdDEi
MCAGCgmSJomT8ixkAQMUEmx5dGFrNzFAaW5pY2lzLmNvbTAeFw0wNDAzMTUxMDAx
MjNaFw0wNTAzMTUxMDAxMjNaMIGVMQswCQYDVQQGEwJLUjEVMBMGA1UECAwM64yA
7ZWc66+86rWtMQ0wCwYDVQQHEwRudWxsMRowGAYDVQQKDBEo7KO8KeydtOuLiOyL
nOyKpDELMAkGA1UECxMCRUMxEzARBgNVBAMTCklOSXBheVRlc3QxIjAgBgoJkiaJ
k/IsZAEDFBJseXRhazcxQGluaWNpcy5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0A
MIGJAoGBAP6a/WaRyDMxHDgKHtahbZTnv+cayR0b052y2sCAGdgMc6CK0GxyvudV
KR7mltKhexur/ikaPKXXApK+SlXUvwNS7pdQ13BTNCeLlEg0WLjGoVi9n96AcjR/
QqlmkFaVAQQe9X95uwAcCoIrkErrpFJNPhppTXfsPH8YpzegogPnAgMBAAEwDQYJ
KoZIhvcNAQEEBQADgYEAvmKuNAD7oPxOfRxj1EyBrKt2YdrhzMTvZXz7IIGCeKf0
tsAKiuxuh20i6zWbD4N+twZvDYG23DFBsLb5Iw3pft5RK9OOVZJ8+ChAaDFHBa4a
RzLDmsdD9NsF7UfYb0KXFUnZMTW5ZKirWUq21MdQiqVNhuLs0zy2hAqABBwhICk=
-----END CERTIFICATE-----

View File

@ -1,18 +0,0 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,1E6B60D94624128F
+9VjCYsbhvQIrQVWRmTV1dBc3HpHbjDrnwEu8znuxO9dgN7ZKKahSOo/iZv9tzWr
SpEnbaGiRivO7/jTfJxgcy7wqjV+jYiwpBzL640JdOditUMoIxx3Rzxq+Dheuz13
1dwt6f3d11zzXjIA5eQQXf1dBTjNCrxhAHqtHccWc5eP1QScQA+KdDAT+vQ6qTVq
aZOI+7BkfWt5YMYBienXwEZSK5ZJ0GU91xSwDApIwsq7E7JGBExPIXGJeZ/RDAVN
sKuO5Ny0JBNJN2Lym39Nb9lF0sKAedMiQNfaEnRqG37fh4H1ONo9NTYilENCIrg6
tgYw/G9FrY8UvNLBsdUEUSV3bSqlRXZxP2TcPPrpYVbYZ1CQAH3fhVjAo9dpSNeI
KuGv3x+JAkuJ+SjhANUU+ChOm27tF7scUxDTfwzTGfyB3P1UFHDwf0nWMU5cuJRY
1+DLxEVL9FaZmonf5SZdf14Ln8a0cVdm+5rujFpFecSaw9K6gNFUvu6qF6CLx9/O
UgcL90Ga+EvMG1iWyCFGvbr53r4i776JG+rVergIcgT5winvYpKiOS9AOV5NXPPI
ev5PCXmDbnalmK6IrgrV0bAJD3d+NcN9JGFSx+GYKlw4OTrz/hxxuojPW6em4cfi
mEIl5JIiLoC2BqM+Jcs8UMq0TOS8Pcki4O05H9Juws5nh6+d5d2p2BcvkXc+SWF7
ClfjMZDaniMzPZr1dQj5XFZwptN6jATYL/4u1CpXYKi3N6TwHbOtQD/2l4e+DNPR
JsSAW8ftyLAK0QJUTLhvA9Np9pzmO4hE7LfeRKBKpoU2PwKyXoO+PA==
-----END RSA PRIVATE KEY-----

View File

@ -1,10 +0,0 @@
Ű <20><><EFBFBD><EFBFBD> 3<><33> - mcert.pem, mpriv.pem, keypass.enc - <20><>
"key/{<7B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD>}/" <20><> <20><><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD> <20><> <20><><EFBFBD>α׷<CEB1> <20>ҽ<EFBFBD><D2BD><EFBFBD> <20><><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ݿ<EFBFBD><DDBF>Ͻʽÿ<CABD>(<28>޴<EFBFBD><DEB4><EFBFBD> <20><><EFBFBD><EFBFBD>).
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD> : INIpayTest
Ű<EFBFBD>н<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : 1111
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ <20>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD> : 1111
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> https://iniweb.inicis.com<6F≯<EFBFBD>,
<EFBFBD>α<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5>Դϴ<D4B4>.

View File

@ -1 +0,0 @@
pm/4rSNJdLw=

View File

@ -1,17 +0,0 @@
-----BEGIN CERTIFICATE-----
MIICnTCCAgYCAQAwDQYJKoZIhvcNAQEEBQAwgZYxCzAJBgNVBAYTAktSMRUwEwYD
VQQIDAzrjIDtlZzrr7zqta0xDTALBgNVBAcTBG51bGwxGjAYBgNVBAoMESjso7wp
7J2064uI7Iuc7IqkMQswCQYDVQQLEwJFQzETMBEGA1UEAxMKaW5pZXNjcm93MDEj
MCEGCgmSJomT8ixkAQMUE2RkYWVtaXJpQGluaWNpcy5jb20wHhcNMDgwMTE2MDQ0
MTU1WhcNMDkwMTE1MDQ0MTU1WjCBljELMAkGA1UEBhMCS1IxFTATBgNVBAgMDOuM
gO2VnOuvvOq1rTENMAsGA1UEBxMEbnVsbDEaMBgGA1UECgwRKOyjvCnsnbTri4js
i5zsiqQxCzAJBgNVBAsTAkVDMRMwEQYDVQQDEwppbmllc2Nyb3cwMSMwIQYKCZIm
iZPyLGQBAxQTZGRhZW1pcmlAaW5pY2lzLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOB
jQAwgYkCgYEAxElWzHNgDFZpwNvPGbWtA0PKTDPfeP1r7xE/k2n2XMzBFQFxbjSC
EBKbQzFRVbNJv4Jyon/OzlywSR3A1DYMm5Oy9Vh3OOrH2FiYxMXClp7MynnmFEug
ysHuYOHlMnoEfI5k8h9hIXlYbRFDLdY7IxVzqkaYJ37HX01Apuxo8sUCAwEAATAN
BgkqhkiG9w0BAQQFAAOBgQCPrVeBW8+anq3CORMYU5TX1tfrYeCzLFH2hkDJF0Rr
1xWxgjhdFZxtBtYSbxr3UKFe6/EWrlv7k37LoM8ORYcNZun+Rd1jz5xwTOjLBTsd
UGwgUpgBLB1z9GoZgaeJJOm7BFUE0Jp7laI0zWkpWeova2RUT1PODnQMvRNi2d88
vQ==
-----END CERTIFICATE-----

View File

@ -1,18 +0,0 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,FBB268FC75417BD4
G4/3WRZg/9peL3ym0S2LsTWvFkSCT/Co+qcCeKBunQ1UPH/pVyQjW0oxtmjBpBfp
YFNJmc5mEhwV30uKXLEYP6bhpHKlLDQWv926+UBIkSZ4cOkm9JNZUETlb+tlSgIN
i5l5KLaX198rGlQAEYX+TxTaxlfXxoBiXkoqxs64Jn0RApy1SPTXKjLffXHP2Yk5
q3jOZ4z4REdnmkH5NYuRHz6cyRr4XdmvPFMwBpzOL08go6yToYfYRvyO4hf2T1Kl
ug1ws6e1HNSm1t3PrZP2kj1oIQef80/DQf9eu1mOP0VQD1GlQSydt2+kAdEBba4d
FIlpO3oGCbCB1UhBOBCllFlXvd4sqj1inZhHS/g9R0vAwAPVpsssXYnWL2qnb+zj
gfSyk+ao56sOBIwhyFXX9IdLcFKMGVQDrxZhDxVieStwk9iVK4zGZW+clS+TzFY7
8qPDP53vXenumSnVq11Mj5gKwJzy40wGm61bQR1B5ldJJW7978Njahh0T0ZCxu48
n5H0FbVu9wrILehWxEI5IrXAAGbRYDlurSSvHtOX1qL0WvJa4EQD9De3u8kqD3Yx
soKJqII277UQBpPuyyE+eP1F+7i4cQdfCU31sK1LMz/wiJxRrG1CiOpV1FH22ABy
vxAh1gpTRgYHvNVWG37P9rYbrW2UcM4cjhbgOzTLhrThxteAgosaXWowc/lcobSB
G444RQXVPZEetqt2In2kBr7UmE2WuvM0CrC6sD336K2t0q/5HLPLntGozdadZ4F5
OS8Oi8I9Ygiqwz95JSUaOfETGZ6RpGRJXL9ysimBeEDuQmQ2lxtkZA==
-----END RSA PRIVATE KEY-----

View File

@ -1,19 +0,0 @@
please read this README.TXT file
ZIP file contains following 3 files.
- mcert.pem
- mpriv.pem
- keypass.enc
Copy these 3 files to directory [key/iniescrow0].
Merchant ID : iniescrow0
Key Password : 1111
Admin Password: 1111
please visit https://iniweb.inicis.com
for your Merchant Administration.
This site provides your payment transaction details and account details by calculation period.
You can also log on this site using your Merchant ID(iniescrow0).

View File

@ -1 +0,0 @@
pm/4rSNJdLw=

View File

@ -1,17 +0,0 @@
-----BEGIN CERTIFICATE-----
MIICtDCCAhwCAQAwDQYJKoZIhvcNAQEEBQAwgaExCzAJBgNVBAYTAktSMRUwEwYD
VQQIDAzrjIDtlZzrr7zqta0xDTALBgNVBAcTBG51bGwxJTAjBgNVBAoMHFNL7Luk
666k64uI7LyA7J207IWY7KaIKOyjvCkxCzAJBgNVBAsTAkVDMRMwEQYDVQQDEwpD
eXdvcmxkMDE0MSMwIQYKCZImiZPyLGQBAxQTc3VuZ21vY2tAaW5pY2lzLmNvbTAe
Fw0wNzExMTIwNjExMzBaFw0wODExMTEwNjExMzBaMIGhMQswCQYDVQQGEwJLUjEV
MBMGA1UECAwM64yA7ZWc66+86rWtMQ0wCwYDVQQHEwRudWxsMSUwIwYDVQQKDBxT
S+y7pOuupOuLiOy8gOydtOyFmOymiCjso7wpMQswCQYDVQQLEwJFQzETMBEGA1UE
AxMKQ3l3b3JsZDAxNDEjMCEGCgmSJomT8ixkAQMUE3N1bmdtb2NrQGluaWNpcy5j
b20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAV0zuTBHq1SZWArRHCNz1jlU
WUyTK3Gv6BGq3J6Tly/o6g51Nbjcu2TYMXLIhMgsqDPeJzOnXbSvnh3FWgAMcFm/
EZEs9oKw+jkiPfIEeSc7KZThqDm1oG4FgJZrXim6Y3jlLLaW1h0WyapCV2u60759
LX8YzmmFmUuXGZOb5s7DAgMBAAEwDQYJKoZIhvcNAQEEBQADgYIAAN4AumokztkK
z5UBScG4Ccvu3nwcuFlCqzDUm9xnZyfy96RIjTJjVelkLwk6NFPqbDEyDLmHm6fe
Zus+fvZBKQAyHigfuS/RVitcup52OkWCZerbcWsziX8Pzqb/MHu19Elt+y/QYe5x
ysyIsZn47Bp+7kbQtlMjJecXGEFfmoi1
-----END CERTIFICATE-----

View File

@ -1,18 +0,0 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,6B92FB59B7AB8A00
NSplji6yUKrk1LXAid9TcBIOSkA+oE+5b52s7GaebioGsGSMIW7RrK8VHWlTOpxs
GnFkTNg3ALZucdhYiAdm6vzaGmmJogoPnmpevs2JIDl3rkgcQH0AVU6nkKg9EcuP
QP/2DknfqzNO46fTMjUIRSrJ7AauDz6836Mm3GVNl7cA42ecM7xHSVK3ZvCvpTrJ
A9ik1zWZbzCIKg/mgMJkHu8xO8K9GKQAY1OM0KxK+oqS/Txmi6RplCHlrTAR+Ahb
J3W8vG3tCu6orlczvPYEnB0a1E/dycDPziBFm6nVAk8cb+yPbZnl/Nqfu6nvPsSx
iJYJR9YZ6L5i/IIhBc8tjNWeDB1KLsXZY41B//D/pjr9nfFUcJex8uPpOA0+GnGz
EhDT8j/WMylgAxKKIYjFqE7HnMQ+n+ZZqLKO6JLdu3HHNz0QC7nz/SZtEMw/of4e
1DlFHDTLTg0vJxwuLSBHVQN3H7SiFbxc/U5UmZEEVPprwbS9m0ok9JmBdfCv8iqu
vuJiYc3HCdJaTRu0U3fJM33yr//BrZxXw0RjABePprcQDf590Vws8tygc/L5voF6
lw8JYXuWKuRn4soNKwhrLL9YvQ0FNy1ITS2MpKGNYRPp5l3YCKO19y1dLMwrA33k
SL1laFxrXLDaaE7MJZ8VD9hIymnn0aivtJHelW9DNoWJdI/DgTNKRhgT2TWBqR09
VVCCKF3RLAQMvOFq/49A68px8/xHKxd6pYis/l8BONlZBMYRyIgjZ0IU81pmvHm+
8UphsgRGx1ZvNtP0ApnTMF9DdpPN6vkxmpDWTe93HWJTp3TV1wyZPA==
-----END RSA PRIVATE KEY-----

View File

@ -1,21 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDcTCCAtqgAwIBAgIBHjANBgkqhkiG9w0BAQQFADCBiDELMAkGA1UEBhMCS1Ix
DjAMBgNVBAgTBVNlb3VsMRgwFgYDVQQKEw9JbmljaXMgQ28sIEx0ZC4xDzANBgNV
BAsTBklOSXBheTEfMB0GA1UEAxMWSU5JcGF5IFBheW1lbnQgR2F0ZXdheTEdMBsG
CSqGSIb3DQEJARYOZGV2QGluaWNpcy5jb20wHhcNMDcwOTA2MDYxNTI0WhcNMTcw
OTAzMDYxNTI0WjCBiDELMAkGA1UEBhMCS1IxDjAMBgNVBAgTBVNlb3VsMRgwFgYD
VQQKEw9JbmljaXMgQ28sIEx0ZC4xDzANBgNVBAsTBklOSXBheTEfMB0GA1UEAxMW
SU5JcGF5IFBheW1lbnQgR2F0ZXdheTEdMBsGCSqGSIb3DQEJARYOZGV2QGluaWNp
cy5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOC8v1rxqoo7tonq7t4d
c3FVfIlLyA9ku+l9+d5pUQrbiUXDe8NoJZnoSyud4WhOUrN2ZpzNmjGxuPquYrT/
LkXoR+ib9OAhFBp7izstjHEA+oUNTVO24MRRvOHWWaLrCeTNX9PeaZl9ploojyHc
Uxm5/gIlPEojiaWNc3HVnb55AgMBAAGjgegwgeUwHQYDVR0OBBYEFGgqMfJUMSUQ
pjyGnurepI+NUf6JMIG1BgNVHSMEga0wgaqAFGgqMfJUMSUQpjyGnurepI+NUf6J
oYGOpIGLMIGIMQswCQYDVQQGEwJLUjEOMAwGA1UECBMFU2VvdWwxGDAWBgNVBAoT
D0luaWNpcyBDbywgTHRkLjEPMA0GA1UECxMGSU5JcGF5MR8wHQYDVQQDExZJTklw
YXkgUGF5bWVudCBHYXRld2F5MR0wGwYJKoZIhvcNAQkBFg5kZXZAaW5pY2lzLmNv
bYIBHjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4GBANUj8vYzU2Q9pebQ
yX+6U9e36DeO/+15iDgU2PRK63uPaEa6vMqN2ibI8twolZB2t2oqIRgO44Hf3Nyf
1XKNzCP1eRF1XreGOnrPZtJ5UeUs3RNBqvQkIAdSW80jkXw0i/7i95BYxRIJWSIE
2fLjemy6r8gAQgWRAPv32F0xwRRT
-----END CERTIFICATE-----

View File

@ -1,19 +0,0 @@
please read this README.TXT file
ZIP file contains following 3 files.
- mcert.pem
- mpriv.pem
- keypass.enc
Copy these 3 files to directory [key/Cyworld014].
Merchant ID : Cyworld014
Key Password : 1111
Admin Password: 1111
please visit https://iniweb.inicis.com
for your Merchant Administration.
This site provides your payment transaction details and account details by calculation period.
You can also log on this site using your Merchant ID(Cyworld014).

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,673 +0,0 @@
<?php
/**
* Copyright (C) 2007 INICIS Inc.
*
* 해당 라이브러리는 절대 수정되어서는 안됩니다.
* 임의로 수정된 코드에 대한 책임은 전적으로 수정자에게 있음을 알려드립니다.
*
* @version 5.0
* @author ddaemiri
*
* @buildno 5000
* @date 2007.12.27
* @note first release
*
* @buildno 5001
* @date 2008.01.15
* @note 자체에스크로 추가, DNS Lookup Timeout 추가, DNS Lookup 실패시 socket close안하는 부분 추가
* @date 2008.01.16
* @note Encrypt,Decrypt 모듈 개선, pkcs5 padding 추가
* @date 2008.01.24
* @note non block connect immediate return check code/str
* @date 2008.02.11
* @note key load 후 read에러발생시 fclose 추가
* @date 2008.03.03
* @note 참조에 의한 전달(passing by reference) 수정
* @date 2008.03.11
* @note 에스크로 망취소 Cmd 추가
* @date 2008.03.12
* @note 기존 연결된 IP로 망취소 수정
* @buildno 5002
* @note 망취소시 Sign추가(기존에 안했음->5001은 망취소시 서버측에서 서명오류가 남,그래도 망취소처리는 됨)
* @date 2008.03.12
* @buildno 5016
* @note pg1ip, pg2ip 추가/취소 원거래없음시 drpg로 재시도
* @date 2008.04.02
* @buildno 5017
* @note 1)chkfake시 파라미터 로깅 삭제(중복)
* 2)call-time pass-by-reference => pass-by-value로 수정
* @date 2009.01.12
* @buildno 5019
* @note delete UIP
* @date 2009.01.21
* @note add mkey/mergelog ( for Makeshop )
* @date 2009.02.24
* @note 1)define MKEY deprecated 2009.02.19 ( Makeshop 초기 한번나감. 서비스되고 있는지는 모름)
* 2)Makeshop PG Updrade용으로 새로나감 2009.02.19 (interface에서 mkey값을 받아 처리하게 변경)
* 3)Makeshop PG Updrade용으로 새로나감 2009.02.24 (interface에서 mergelog값을 받아 처리하게 변경)
* @date 2009.05.07
* @note add BUILDDATE in TXVersion
* @date 2009.08.05
* @buildno 5030
* @note add vacct refund
* @date 2009.12.16
* @buildno 5030
* @note add recv info
* @date 2010.07.14
* @note add Tax, TaxFree info(TX_TAX, TX_TAXFREE)
* @date 2010.09.09
* @note 취소요청시 PG 설정 변경(도메인->IP, INILib.php)
* @note BUILDDATE update(100414 -> 100909)
* @note 2011.05.23 5030 XML ELEMENT 중 ROOT 를 ROOTINFO로 수정
* @buildno 5032
* @note 2012.07.09 거래조회 추가 (TYPE_INQUIRY)
* @note 2012.07.09 PHP ini 파일 error display setting 추가
* @buildno 5036
* @note 2014.12.09 add gather parameter tid, type
* @note 20151113 주문번호 거래조회 추가
*/
ini_set('error_reporting', E_ALL ^ E_NOTICE);
ini_set('display_errors', 'Off');
/* GLOBAL */
define("PROGRAM", "INIPHP");
define("LANG", "PHP");
define("VERSION", "NV5053");
define("BUILDDATE", "20190404");
if( ! defined('TID_LEN')) define("TID_LEN", 40);
define("MAX_KEY_LEN", 24);
define("MAX_IV_LEN", 8);
/* TIMEOUT */
define("TIMEOUT_CONNECT", 5);
define("TIMEOUT_WRITE", 2);
define("TIMEOUT_READ", 20);
define("G_TIMEOUT_CONNECT", 2);
define("DNS_LOOKUP_TIMEOUT", 5);
/* LOG LEVEL */
define("CRITICAL", 1);
define("ERROR", 2);
define("NOTICE", 3);
define("INFO", 5);
define("DEBUG", 7);
/* SERVER INFO */
define("PG_HOST", "formpg.inicis.com");
define("PG_IP", "203.238.37.3");
define("KSPG_IP", "39.115.212.10");
define("PG_PORT", 34049);
define("G_SERVER", "gthr.inicis.com");
define("G_CGI", "/cgi-bin/g.cgi");
define("G_PORT", 80);
define("OK", "0");
define("IV", "Initiative Tech");
define("IMHK", "SFBQSU5JTkZPUk1BVElPTg==");
define("IMHV", "SU5JQ0lTIENJUEhFUi4uLg==");
define("IMJK", "UkVHSVNUX05PX1JDNEtFWQ==");
define("IMJV", "UkVHSVNUX05PX1JDNElW");
//define for mkey
//deprecated 2009.02.19 ( Makeshop 초기 한번나감. 서비스되고 있는지는 모름)
//Makeshop PG Updrade용으로 새로나감 2009.02.19 (interface에서 mkey값을 받아 처리하게 변경)
//define("MKEY", 1);
//non block connect immediate return check code/str
define("ERRSTR_INPROGRESS", "Operation now in progress");
define("ERRCODE_INPROGRESS_LINUX", 115);
define("ERRCODE_INPROGRESS_FREEBSD", 36);
define("ERRCODE_INPROGRESS_WIN", 10035);
//------------------------------------------------------
// IFD Header
//------------------------------------------------------
define("MSGHEADER_LEN", 150);
define("BODY_LEN", 5);
define("TAIL_LEN", 5);
define("FLGCRYPTO_LEN", 1);
define("FLGSIGN_LEN", 5);
define("MPUBSN_LEN", 20);
define("PIPGPUBSN_LEN", 20);
define("TXPGPUBSN_LEN", 20);
define("CMD_LEN", 4);
define("MID_LEN", 10);
define("TOTPRICE_LEN", 20);
//------------------------------------------------------
// IFD CMD
//------------------------------------------------------
define("CMD_REQ_PAY", "0200");
define("CMD_RES_PAY", "0210");
define("CMD_REQ_CAP", "0300");
define("CMD_RES_CAP", "0310");
define("CMD_REQ_CAN", "0420");
define("CMD_RES_CAN", "0430");
define("CMD_REQ_NETC", "0520");
define("CMD_RES_NETC", "0530");
define("CMD_REQ_PRTC", "0620");
define("CMD_RES_PRTC", "0630");
define("CMD_REQ_ACK", "0800");
define("CMD_RES_ACK", "0810");
//자체에스크로
//added 2008.01.08
define("CMD_REQ_DLV", "3020"); //배송등록
define("CMD_REQ_CNF", "3030"); //구매확인
define("CMD_REQ_DNY", "3040"); //구매거절
define("CMD_REQ_DNY_CNF", "3080"); //거절확인
define("CMD_REQ_DLV_NETC", "3520"); //배송등록망상취소
define("CMD_REQ_CNF_NETC", "3530"); //구매확인망상취소
define("CMD_REQ_DNY_NETC", "3540"); //구매거절망상취소
//가상계좌환불(09.08.05)
define("CMD_REQ_RFD", "0421");
define("CMD_RES_RFD", "0431");
//거래조회(12.04.20)
define("CMS_REQ_INQR", "0900");
define("CMS_RES_INQR", "0910");
//서브몰하위가맹점등록(14.03.06)
define("CMS_REQ_OPEN_SUB", "1040");
define("CMS_RES_OPEN_SUB", "1041");
//------------------------------------------------------
// HEADER FLAGS
//------------------------------------------------------
define("FLAG_TEST", "T");
define("FLAG_REAL", "R");
define("FLAG_CRYPTO_NONE", "N");
define("FLAG_CRYPTO_SEED", "S");
define("FLAG_CRYPTO_RC4", "R");
define("FLAG_CRYPTO_3DES", "D");
define("FLAG_SIGN_SHA", "SHA");
define("FLAG_SIGN_SHA1", "SHA1");
define("FLAG_SIGN_MD5", "MD5");
//------------------------------------------------------
//TYPE(서비스별)
//------------------------------------------------------
define("TYPE_SECUREPAY", "securepay");
define("TYPE_CANCEL", "cancel");
define("TYPE_FORMPAY", "formpay");
define("TYPE_RECEIPT", "receipt");
define("TYPE_REPAY", "repay");
define("TYPE_ESCROW", "escrow"); //자체에스크로!
define("TYPE_CONFIRM", "confirm");
define("TYPE_OCBQUERY", "ocbquery");
define("TYPE_OCBSAVE", "ocbsave");
define("TYPE_OCBPOINT", "OCBPoint");
define("TYPE_AUTH", "auth");
define("TYPE_AUTHBILL", "auth_bill");
define("TYPE_CAPTURE", "capture");
define("TYPE_CMS", "CMS");
define("TYPE_VBANK", "VBank");
define("TYPE_REQREALBILL", "reqrealbill");
define("TYPE_FORMAUTH", "formauth");
define("TYPE_CHKFAKE", "chkfake");
//가상계좌환불(09.08.05)
define("TYPE_REFUND", "refund");
//가상계좌부분환불(12.06.05)
define("TYPE_VACCTREPAY", "vacctrepay");
//거래조회(12.04.20)
define("TYPE_INQUIRY", "inquiry");
//서브몰하위가맹점등록(14.03.06)
define("TYPE_OPENSUB", "opensub");
//------------------------------------------------------
//EscrowType(자체에스크로 타입)
//added 2008.01.08
//------------------------------------------------------
define("TYPE_ESCROW_DLV", "dlv");
define("TYPE_ESCROW_CNF", "confirm"); //구매확인/거절(플러그인)
define("TYPE_ESCROW_DNY", "deny"); //위에서 처리됨,의미없음
define("TYPE_ESCROW_DNY_CNF", "dcnf");
//------------------------------------------------------
//PayMethod(서비스별, TX)
//------------------------------------------------------
define("NM_TX_ISP", "VCard");
define("NM_TX_CARD", "Card");
define("NM_TX_HPP", "HPP");
define("NM_TX_ACCT", "DirectBank");
define("NM_TX_VACT", "VBank");
define("NM_TX_OCB", "OCBPoint");
define("NM_TX_CSHR", "CASH");
define("NM_TX_ARSB", "Ars1588Bill");
define("NM_TX_PHNB", "PhoneBill");
define("NM_TX_CULT", "Culture");
define("NM_TX_GAMG", "DGCL");
define("NM_TX_EDUG", "EDCL");
define("NM_TX_TEEN", "TEEN");
define("NM_TX_ESCR", "Escrow");
//------------------------------------------------------
//PayMethod(서비스별, PG)
//------------------------------------------------------
define("NM_ISP", "ISP");
define("NM_CARD", "CARD");
define("NM_HPP", "HPP");
define("NM_ACCT", "ACCT");
define("NM_VACT", "VACT");
define("NM_OCB", "OCB");
define("NM_CSHR", "CASH");
define("NM_ARSB", "ARSB");
define("NM_PHNB", "PHNB");
define("NM_CULT", "CULT");
define("NM_GAMG", "DGCL");
define("NM_EDUG", "EDCL");
define("NM_TEEN", "TEEN");
define("NM_ESCR", "Escrow");
//------------------------------------------------------
//Charset
//------------------------------------------------------
define("EUCKR", "EUC-KR");
define("UTF8", "UTF-8");
//------------------------------------------------------
//URL Encoding/Decoding Name
//------------------------------------------------------
define("URLENCODE", "urlencode");
define("URLDECODE", "urldecode");
//------------------------------------------------------
//요청전문
//------------------------------------------------------
define("TX_GOOSCNT", "GoodsCnt");
define("TX_MOID", "MOID");
define("TX_CURRENCY", "Currency");
define("TX_SMID", "SMID");
define("TX_GOODSCNTS", "GoodsCnts");
define("TX_GOODSNAME", "GoodsName");
define("TX_GOODSPRICE", "GoodsPrice");
define("TX_BUYERNAME", "BuyerName");
define("TX_BUYEREMAIL", "BuyerEmail");
define("TX_BUYERTEL", "BuyerTel");
define("TX_PARENTEMAIL", "ParentEmail");
define("TX_RECVNAME", "RecvName");
define("TX_RECVTEL", "RecvTel");
define("TX_RECVMSG", "RecvMsg");
define("TX_RECVADDR", "RecvAddr");
define("TX_RECVPOSTNUM", "RecvPostNum");
define("TX_TAXFREE", "TaxFree");
define("TX_TAX", "Tax");
//PaymentInfo
define("TX_PAYMETHOD", "PayMethod");
define("TX_JOINCARD", "JoinCard");
define("TX_JOINEXPIRE", "JoinExpire");
define("TX_MAILORDER", "MailOrder");
define("TX_SESSIONKEY", "SessionKey");
define("TX_ENCRYPTED", "Encrypted");
//ReservedInfo
define("TX_MRESERVED1", "MReserved1");
define("TX_MRESERVED2", "MReserved2");
define("TX_MRESERVED3", "MReserved3");
//ManageInfo
define("TX_LANGUAGE", "Language");
define("TX_URL", "URL");
define("TX_TXVERSION", "TXVersion");
define("TX_TXUSERIP", "TXUserIP");
define("TX_TXUSERID", "TXUserID");
define("TX_TXREGNUM", "TXRegNum");
define("TX_ACK", "Ack");
define("TX_RN", "TXRN");
//CancelInfo
define("TX_CANCELTID", "CancelTID");
define("TX_CANCELMSG", "CancelMsg");
define("TX_CANCELREASON", "CancelReason"); //2012-10-19 취소사유코드 추가
//가상계좌환불(09.08.05)
define("TX_REFUNDACCTNUM", "RefundAcctNum");
define("TX_REFUNDBANKCODE", "RefundBankCode");
define("TX_REFUNDACCTNAME", "RefundAcctName");
define("TX_REFUNDFLGREMIT", "RefundFlgRemit");
//PartCancelInfo
define("TX_PRTC_TID", "PRTC_TID");
define("TX_PRTC_PRICE", "PRTC_Price");
define("TX_PRTC_REMAINS", "PRTC_Remains");
define("TX_PRTC_QUOTA", "PRTC_Quota");
define("TX_PRTC_INTEREST", "PRTC_Interest");
define("TX_PRTC_TAX", "Tax");
define("TX_PRTC_TAXFREE", "TaxFree");
define("TX_PRTC_CURRENCY", "Currency");
//국민은행 I계좌이체 부분취소시 계좌번호/계좌주성명추가 2011-10-06
define("TX_PRTC_NOACCT", "PRTC_NoAcctFNBC");
define("TX_PRTC_NMACCT", "PRTC_NmAcctFNBC");
//가상계좌 부분환불 관련 추가
define("TX_PRTC_REFUNDFLGREMIT", "PRTC_RefundFlgRemit");
define("TX_PRTC_REFUNDBANKCODE", "PRTC_RefundBankCode");
//CaptureInfo
define("TX_CAPTURETID", "CaptureTID");
//현금영수증
define("TX_CSHR_APPLPRICE", "CSHR_ApplPrice");
define("TX_CSHR_SUPPLYPRICE", "CSHR_SupplyPrice");
define("TX_CSHR_TAX", "CSHR_Tax");
define("TX_CSHR_SERVICEPRICE", "CSHR_ServicePrice");
define("TX_CSHR_REGNUM", "CSHR_RegNum");
define("TX_CSHR_TYPE", "CSHR_Type");
define("TX_CSHR_COMPANYNUM", "CSHR_CompanyNum");
define("TX_CSHR_OPENMARKET", "CSHR_OpenMarket");
define("TX_CSHR_SUBCNT", "CSHR_SubCnt");
define("TX_CSHR_SUBCOMPANYNAME1", "CSHR_SubCompanyName1");
define("TX_CSHR_SUBCOMPANYNUM1", "CSHR_SubCompanyNum1");
define("TX_CSHR_SUBREGNUM1", "CSHR_SubRegNum1");
define("TX_CSHR_SUBMID1", "CSHR_SubMID1");
define("TX_CSHR_SUBAPPLPRICE1", "CSHR_SubApplPrice1");
define("TX_CSHR_SUBSERVICEPRICE1", "CSHR_SubServicePrice1");
//거래조회(12.04.20)
define("TX_INQR_TID", "INQR_TID");
define("TX_INQR_OID", "INQR_OID");
//서브몰하위가맹점등록(14.03.06)
define("TX_OPENREG_TID", "OrgTID");
define("TX_OPENREG_MID", "MID");
define("TX_OPENREG_SUBCNT", "SubCnt");
define("TX_OPENREG_SUBGOODS", "SubGoods");
define("TX_OPENREG_SUBCOMPNO", "SubCompNo");
define("TX_OPENREG_SUBCOMPNM", "SubCompNm");
define("TX_OPENREG_SUBPRSUPPLY", "SubPrSupply");
define("TX_OPENREG_SUBPRFREE", "SubPrFree");
define("TX_OPENREG_SUBPRTAX", "SubPrTax");
define("TX_OPENREG_SUBPRSERVICE", "SubPrService");
define("TX_OPENREG_SUBPRICE", "SubPrice");
//------------------------------------------------------
//
//응답전문
//
//------------------------------------------------------
//HEAD
define("NM_MID", "MID");
define("NM_TID", "TID");
define("NM_TOTPRICE", "TotPrice");
//BODY
define("NM_GOODSCNT", "GoodsCnt");
define("NM_MOID", "MOID");
define("NM_CURRENCY", "Currency");
define("NM_SMID", "SMID");
define("NM_GOODSNAME", "GoodsName");
define("NM_GOODSPRICE", "GoodsPrice");
define("NM_PAYMETHOD", "PayMethod");
define("NM_RESULTCODE", "ResultCode");
define("NM_RESULTERRORCODE", "ResultErrorCode");
define("NM_RESULTMSG", "ResultMsg");
define("NM_SESSIONKEY", "SessionKey");
define("NM_ENCRYPTED", "Encrypted");
define("NM_CANCELDATE", "CancelDate");
define("NM_CANCELTIME", "CancelTime");
define("NM_EVENTCODE", "EventCode");
define("NM_ORGCURRENCY", "OrgCurrency");
define("NM_ORGPRICE", "OrgPrice");
define("NM_EXCHANGERATE", "ExchangeRate");
define("NM_RESERVEDINFO", "ReservedInfo");
define("NM_MRESERVED1", "MReserved1");
define("NM_MRESERVED2", "MReserved2");
define("NM_MRESERVED3", "MReserved3");
define("PRTC_TID", "PRTC_TID");
define("PRTC_PRICE", "PRTC_Price");
define("PRTC_REMAINS", "PRTC_Remains");
define("PRTC_QUOTA", "PRTC_Quota");
define("PRTC_INTEREST", "PRTC_Interest");
define("PRTC_TYPE", "PRTC_Type");
define("PRTC_CNT", "PRTC_Cnt");
define("NM_CAPTUREDATE", "CaptureDate");
define("NM_CAPTURETIME", "CaptureTime");
define("NM_PGPUBKEY", "PGcertKey");
//RECV DATA XPATH
//XML XPATH
define("ROOTINFO", "INIpay");
define("GOODSINFO", "GoodsInfo");
define("GOODS", "Goods");
define("BUYERINFO", "BuyerInfo");
define("PAYMENTINFO", "PaymentInfo");
define("PAYMENT", "Payment");
define("MANAGEINFO", "ManageInfo");
define("RESERVEDINFO", "ReservedInfo");
//Cancel(NetCancel)
define("CANCELINFO", "CancelInfo");
//PartCancel Encrypt
define("PARTCANCELINFO", "PartCancelInfo");
//Capture
define("CAPTUREINFO", "CaptureInfo");
//거래조회(12.04.20)
define("INQUIRYINFO", "InquiryInfo");
//서브몰하위가맹점등록(14.03.06)
define("OPENSUBINFO", "OpenSubInfo");
//Escrow
//added 2008.01.09
define("ESCROWINFO", "EscrowInfo");
define("ESCROW_DELIVERY", "Delivery");
define("ESCROW_CONFIRM", "Confirm");
define("ESCROW_DENY", "Deny");
define("ESCROW_DENYCONFIRM", "DenyConfirm");
//------------------------------------------------------
//Auth Encrypt XPATH
//------------------------------------------------------
//CARD COMMON
define("APPLDATE", "ApplDate");
define("APPLTIME", "ApplTime");
define("APPLNUM", "ApplNum");
//CARD
define("CARD_NUM", "CARD_Num");
define("CARD_EXPIRE", "CARD_Expire");
define("CARD_CODE", "CARD_Code");
define("CARD_APPLPRICE", "CARD_ApplPrice");
define("CARD_BANKCODE", "CARD_BankCode");
define("CARD_QUOTA", "CARD_Quota");
define("CARD_INTEREST", "CARD_Interest");
define("CARD_POINT", "CARD_Point");
define("CARD_AUTHTYPE", "CARD_AuthType");
define("CARD_REGNUM", "CARD_RegNum");
define("CARD_APPLDATE", "CARD_ApplDate");
define("CARD_APPLTIME", "CARD_ApplTime");
define("CARD_APPLNUM", "CARD_ApplNum");
define("CARD_RESULTCODE", "CARD_ResultCode");
define("CARD_RESULTMSG", "CARD_ResultMsg");
define("CARD_TERMINALNUM", "CARD_TerminalNum");
define("CARD_MEMBERNUM", "CARD_MemberNum");
define("CARD_PURCHASECODE", "CARD_PurchaseCode");
//ISP
define("ISP_BANKCODE", "ISP_BankCode");
define("ISP_QUOTA", "ISP_Quota");
define("ISP_INTEREST", "ISP_Interest");
define("ISP_APPLPRICE", "ISP_ApplPrice");
define("ISP_CARDCODE", "ISP_CardCode");
define("ISP_CARDNUM", "ISP_CardNum");
define("ISP_POINT", "ISP_Point");
define("ISP_APPLDATE", "ISP_ApplDate");
define("ISP_APPLTIME", "ISP_ApplTime");
define("ISP_APPLNUM", "ISP_ApplNum");
define("ISP_RESULTCODE", "ISP_ResultCode");
define("ISP_RESULTMSG", "ISP_ResultMsg");
define("ISP_TERMINALNUM", "ISP_TerminalNum");
define("ISP_MEMBERNUM", "ISP_MemberNum");
define("ISP_PURCHASECODE", "ISP_PurchaseCode");
//ACCT
define("ACCT_APPLDATE", "ACCT_ApplDate");
define("ACCT_APPLTIME", "ACCT_ApplTime");
define("ACCT_APPLNUM", "ACCT_ApplNum");
//HPP
define("HPP_APPLDATE", "HPP_ApplDate");
define("HPP_APPLTIME", "HPP_ApplTime");
define("HPP_APPLNUM", "HPP_ApplNum");
//VACT
define("VACT_APPLDATE", "VACT_ApplDate");
define("VACT_APPLTIME", "VACT_ApplTime");
//CASH
define("CSHR_APPLDATE", "CSHR_ApplDate");
define("CSHR_APPLTIME", "CSHR_ApplTime");
define("CSHR_APPLNUM", "CSHR_ApplNum");
//ARSB
define("ARSB_APPLDATE", "ARSB_ApplDate");
define("ARSB_APPLTIME", "ARSB_ApplTime");
define("ARSB_APPLNUM", "ARSB_ApplNum");
//PHNB
define("PHNB_APPLDATE", "PHNB_ApplDate");
define("PHNB_APPLTIME", "PHNB_ApplTime");
define("PHNB_APPLNUM", "PHNB_ApplNum");
//CULT
define("CULT_APPLDATE", "CULT_ApplDate");
define("CULT_APPLTIME", "CULT_ApplTime");
define("CULT_APPLNUM", "CULT_ApplNum");
//DGCL
define("GAMG_CNT", "GAMG_Cnt");
define("GAMG_APPLDATE", "GAMG_ApplDate");
define("GAMG_APPLTIME", "GAMG_ApplTime");
define("GAMG_APPLNUM", "GAMG_ApplNum");
function MakePathGAMG($cnt) {
for ($i = 1; $i <= $cnt; $i++) {
define("GAMG_NUM$i", "GAMG_Num$i");
define("GAMG_REMAINS$i", "GAMG_Remains$i");
define("GAMG_ERRMSG$i", "GAMG_ErrMsg$i");
}
}
//EDUG
define("EDUG_APPLDATE", "EDUG_ApplDate");
define("EDUG_APPLTIME", "EDUG_ApplTime");
define("EDUG_APPLNUM", "EDUG_ApplNum");
//TEEN
define("TEEN_APPLDATE", "TEEN_ApplDate");
define("TEEN_APPLTIME", "TEEN_ApplTime");
define("TEEN_APPLNUM", "TEEN_ApplNum");
//----------------------------------
//ERROR CODE
//----------------------------------
//!!신TX에 추가된 에러!!!
define("NULL_DIR_ERR", "TX9001");
define("NULL_TYPE_ERR", "TX9002");
define("NULL_NOINTEREST_ERR", "TX9003");
define("NULL_QUOTABASE_ERR", "TX9004");
define("DNS_LOOKUP_ERR", "TX9005");
define("MERCHANT_DB_ERR", "TX9006");
define("DNS_LOOKUP_TIMEOUT_ERR", "TX9007");
define("PGPUB_UPDATE_ERR", "TX9612");
//암복호화 에러
define("B64DECODE_UPDATE_ERR", "TX9101");
define("B64DECODE_FINAL_ERR", "TX9102");
define("B64DECODE_LENGTH_ERR", "TX9103");
define("GET_KEYPW_EVP_B2K_ERR", "TX9104");
define("GET_KEYPW_FILE_OPEN_ERR", "TX9105");
define("GET_KEYPW_FILE_READ_ERR", "TX9106");
define("GET_KEYPW_DECRYPT_INIT_ERR", "TX9107");
define("GET_KEYPW_DECRYPT_UPDATE_ERR", "TX9108");
define("GET_KEYPW_DECRYPT_FINAL_ERR", "TX9109");
define("ENC_RAND_BYTES_ERR", "TX9110");
define("ENC_INIT_ERR", "TX9111");
define("ENC_UPDATE_ERR", "TX9112");
define("ENC_FINAL_ERR", "TX9113");
define("ENC_RSA_ERR", "TX9114");
define("DEC_RSA_ERR", "TX9115");
define("DEC_CIPHER_ERR", "TX9116");
define("DEC_INIT_ERR", "TX9117");
define("DEC_UPDATE_ERR", "TX9118");
define("DEC_FINAL_ERR", "TX9119");
define("SIGN_FINAL_ERR", "TX9120");
define("SIGN_CHECK_ERR", "TX9121");
define("ENC_NULL_F_ERR", "TX9122");
define("ENC_INIT_RAND_ERR", "TX9123");
define("ENC_PUTENV_ERR", "TX9124");
//필드체크
define("NULL_KEYPW_ERR", "TX9201");
define("NULL_MID_ERR", "TX9202");
define("NULL_PGID_ERR", "TX9203");
define("NULL_TID_ERR", "TX9204");
define("NULL_UIP_ERR", "TX9205");
define("NULL_URL_ERR", "TX9206");
define("NULL_PRICE_ERR", "TX9207");
define("NULL_PRICE1_ERR", "TX9208");
define("NULL_PRICE2_ERR", "TX9209");
define("NULL_CARDNUMBER_ERR", "TX9210");
define("NULL_CARDEXPIRE_ERR", "TX9211");
define("NULL_ENCRYPTED_ERR", "TX9212");
define("NULL_CARDQUOTA_ERR", "TX9213");
define("NULL_QUOTAINTEREST_ERR", "TX9214");
define("NULL_AUTHENTIFICATION_ERR", "TX9215");
define("NULL_AUTHFIELD1_ERR", "TX9216");
define("NULL_AUTHFIELD2_ERR", "TX9217");
define("NULL_BANKCODE_ERR", "TX9218");
define("NULL_BANKACCOUNT_ERR", "TX9219");
define("NULL_REGNUMBER_ERR", "TX9220");
define("NULL_OCBCARDNUM_ERR", "TX9221");
define("NULL_OCBPASSWD_ERR", "TX9222");
define("NULL_PASSWD_ERR", "TX9223");
define("NULL_CURRENCY_ERR", "TX9224");
define("NULL_PAYMETHOD_ERR", "TX9225");
define("NULL_GOODNAME_ERR", "TX9226");
define("NULL_BUYERNAME_ERR", "TX9227");
define("NULL_BUYERTEL_ERR", "TX9228");
define("NULL_BUYEREMAIL_ERR", "TX9229");
define("NULL_SESSIONKEY_ERR", "TX9230");
//pg공개키 로드 오류
define("NULL_PGCERT_FP_ERR", "TX9231");
define("NULL_X509_ERR", "TX9232");
define("NULL_PGCERT_ERR", "TX9233");
define("RESULT_MSG_FORMAT_ERR", "TX9234");
// 가상 계좌 이체 예약
define("NULL_PERNO_ERR", "TX9235"); // 주민번호 빠짐
define("NULL_OID_ERR", "TX9236"); // 주문번호 빠짐
define("NULL_VCDBANK_ERR", "TX9237"); // 은행코드 빠짐
define("NULL_DTINPUT_ERR", "TX9238"); // 입금 예정일 빠짐
define("NULL_NMINPUT_ERR", "TX9239"); // 송금자 성명 빠짐
//실시간 빌링
define("NULL_BILLKEY_ERR", "TX9240"); // 빌키 빠짐
define("NULL_CARDPASS_ERR", "TX9241"); // 카드 비번 빠짐
define("NULL_BILLTYPE_ERR", "TX9242"); // 빌타입 누락
// CMS 계좌이체
define("NULL_PRICE_ORG_ERR", "TX9250"); // CMS 출금총금액 빠짐
define("NULL_CMSDAY_ERR", "TX9251"); // CMS 출금일자 빠짐
define("NULL_CMSDATEFROM_ERR", "TX9252"); // CMS 출금시작월 빠짐
define("NULL_CMSDATETO_ERR", "TX9253"); // CMS 출금종료월 빠짐
// 부분취소
define("NULL_CONFIRM_PRICE_ERR", "TX9260"); // 재승인 요청금액 누락 에러
// 현금영수증 발행
define("NULL_CR_PRICE_ERR", "TX9270"); // 현금결제 금액 빠짐
define("NULL_SUP_PRICE_ERR", "TX9271"); // 공급가액 빠짐
define("NULL_TAX_ERR", "TX9272"); // 부가세 빠짐
define("NULL_SRVC_PRICE_ERR", "TX9273"); // 봉사료 빠짐
define("NULL_REG_NUM_ERR", "TX9274"); // 주민번호(사업자번호)
define("NULL_USEOPT_ERR", "TX9275"); // 현금영수증 용도 구분자 빠짐
define("PRIVKEY_FILE_OPEN_ERR", "TX9301");
define("INVALID_KEYPASS_ERR", "TX9302");
define("MAKE_TID_ERR", "TX9401");
define("ACK_CHECKSUM_ERR", "TX9402");
define("NETCANCEL_SOCK_CREATE_ERR", "TX9403");
define("NETCANCEL_SOCK_SEND_ERR", "TX9404");
define("NETCANCEL_SOCK_RECV_ERR", "TX9405");
define("LOG_OPEN_ERR", "TX9406");
define("LOG_WRITE_ERR", "TX9407");
define("SOCK_MAKE_EP_ERR", "TX9501");
define("SOCK_CONN_ERR", "TX9502");
define("SOCK_SEND1_ERR", "TX9503");
define("SOCK_SEND2_ERR", "TX9504");
define("SOCK_CLOSED_BY_PEER_ERR", "TX9505");
define("SOCK_RECV1_ERR", "TX9506");
define("SOCK_RECV2_ERR", "TX9507");
define("SOCK_RECV_LEN_ERR", "TX9508");
define("SOCK_TIMEO_ERR", "TX9509");
define("SOCK_ETC1_ERR", "TX9510");
define("SOCK_ETC2_ERR", "TX9511");
define("NULL_ESCROWTYPE_ERR", "TX6000");
define("NULL_ESCROWMSG_ERR", "TX6001");
define("NULL_FIELD_REFUNDACCTNUM", "TX9245");
define("NULL_FIELD_REFUNDBANKCODE", "TX9243");
define("NULL_FIELD_REFUNDACCTNAME", "TX9244");

View File

@ -1,735 +0,0 @@
<?php
/**
* Copyright (C) 2007 INICIS Inc.
*
* 해당 라이브러리는 절대 수정되어서는 안됩니다.
* 임의로 수정된 코드에 대한 책임은 전적으로 수정자에게 있음을 알려드립니다.
*
*/
require_once('INICls.php');
require_once('INISoc.php');
class INIpay50 {
var $m_type; // 거래 유형
var $m_resulterrcode; // 결과메세지 에러코드
var $m_connIP;
var $m_cancelRC = 0;
var $m_Data;
var $m_Log;
var $m_Socket;
var $m_Crypto;
var $m_REQUEST = array();
var $m_REQUEST2 = array();
var $m_RESULT = array();
function INIpay() {
$this->UnsetField();
}
function UnsetField() {
unset($this->m_REQUEST);
unset($this->m_RESULT);
}
/* -------------------------------------------------- */
/* */
/* 결제/취소 요청값 Set or Add */
/* */
/* -------------------------------------------------- */
function SetField($key, $val) { //Default Entity
$this->m_REQUEST[$key] = $val;
}
function SetXPath($xpath, $val) { //User Defined Entity
$this->m_REQUEST2[$xpath] = $val;
}
/* -------------------------------------------------- */
/* */
/* 결제/취소 결과값 fetch */
/* */
/* -------------------------------------------------- */
function GetResult($name) { //Default Entity
$result = isset($this->m_RESULT[$name]) ? $this->m_RESULT[$name] : '';
if ($result == "")
$result = $this->m_Data->GetXMLData($name);
if ($result == "")
$result = $this->m_Data->m_RESULT[$name];
return $result;
}
/* -------------------------------------------------- */
/* */
/* 결제/취소 처리 메인 */
/* */
/* -------------------------------------------------- */
function startAction() {
/* -------------------------------------------------- */
/* Overhead Operation */
/* -------------------------------------------------- */
$this->m_Data = new INIData($this->m_REQUEST, $this->m_REQUEST2);
/* -------------------------------------------------- */
/* Log Start */
/* -------------------------------------------------- */
$this->m_Log = new INILog($this->m_REQUEST);
if (!$this->m_Log->StartLog()) {
$this->MakeTXErrMsg(LOG_OPEN_ERR, "로그파일을 열수가 없습니다.[" . $this->m_REQUEST["inipayhome"] . "]");
return;
}
/* -------------------------------------------------- */
/* Logging Request Parameter */
/* -------------------------------------------------- */
$this->m_Log->WriteLog(DEBUG, $this->m_REQUEST);
/* -------------------------------------------------- */
/* Set Type */
/* -------------------------------------------------- */
$this->m_type = $this->m_REQUEST["type"];
/* -------------------------------------------------- */
/* Check Field */
/* -------------------------------------------------- */
if (!$this->m_Data->CheckField()) {
$err_msg = "필수항목(" . $this->m_Data->m_ErrMsg . ")이 누락되었습니다.";
$this->MakeTXErrMsg($this->m_Data->m_ErrCode, $err_msg);
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
return;
}
$this->m_Log->WriteLog(INFO, "Check Field OK");
/* -------------------------------------------------- */
//웹페이지위변조용 키생성. 여기서 끝!!
/* -------------------------------------------------- */
if ($this->m_type == TYPE_CHKFAKE) {
return $this->MakeChkFake();
}
//TID 인입 기반 거래의 경우 TID 를 기록함
$temp_request = array_change_key_case($this->m_REQUEST, CASE_LOWER);
if(isset($temp_request['tid'])){
$this->m_Log->WriteLog(INFO, "INPUT TID > ".$temp_request['tid']);
}
/* -------------------------------------------------- */
//Generate TID
/* -------------------------------------------------- */
if ($this->m_type == TYPE_SECUREPAY || $this->m_type == TYPE_FORMPAY || $this->m_type == TYPE_OCBSAVE ||
$this->m_type == TYPE_AUTHBILL || $this->m_type == TYPE_FORMAUTH || $this->m_type == TYPE_REQREALBILL ||
$this->m_type == TYPE_REPAY || $this->m_type == TYPE_VACCTREPAY || $this->m_type == TYPE_RECEIPT || $this->m_type == TYPE_AUTH
) {
if (!$this->m_Data->MakeTID()) {
$err_msg = "TID생성에 실패했습니다.::" . $this->m_Data->m_sTID;
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg(MAKE_TID_ERR, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
return;
}
$this->m_Log->WriteLog(INFO, 'Make TID OK ' . $this->m_Data->m_sTID);
}
$this->m_Crypto = new INICrypto($this->m_REQUEST);
/* -------------------------------------------------- */
//PI공개키 로드
/* -------------------------------------------------- */
$this->m_Data->ParsePIEncrypted();
$this->m_Log->WriteLog(INFO, "PI PUB KEY LOAD OK [" . $this->m_Data->m_PIPGPubSN . "]");
/* -------------------------------------------------- */
//PG공개키 로드
/* -------------------------------------------------- */
if (($rtv = $this->m_Crypto->LoadPGPubKey($pg_cert_SN)) != OK) {
$err_msg = "PG공개키 로드오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
return;
}
$this->m_Data->m_TXPGPubSN = $pg_cert_SN;
$this->m_Log->WriteLog(INFO, "PG PUB KEY LOAD OK [" . $this->m_Data->m_TXPGPubSN . "]");
/* -------------------------------------------------- */
//상점개인키 로드
/* -------------------------------------------------- */
if (($rtv = $this->m_Crypto->LoadMPrivKey()) != OK) {
$err_msg = "상점개인키 로드오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreePubKey();
return;
}
$this->m_Log->WriteLog(INFO, "MERCHANT PRIV KEY LOAD OK");
/* -------------------------------------------------- */
//상점 공개키 로드(SN 를 알기위해!!)
/* -------------------------------------------------- */
if (($rtv = $this->m_Crypto->LoadMPubKey($m_cert_SN)) != OK) {
$err_msg = "상점공개키 로드오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
return;
}
$this->m_Data->m_MPubSN = $m_cert_SN;
$this->m_Log->WriteLog(INFO, "MERCHANT PUB KEY LOAD OK [" . $this->m_Data->m_MPubSN . "]");
/* -------------------------------------------------- */
//폼페이 암호화( formpay, cancel, repay, recept, inquiry, opensub)
/* -------------------------------------------------- */
if ($this->m_type == TYPE_CANCEL || $this->m_type == TYPE_REPAY || $this->m_type == TYPE_VACCTREPAY ||
$this->m_type == TYPE_FORMPAY || $this->m_type == TYPE_RECEIPT ||
$this->m_type == TYPE_CAPTURE || $this->m_type == TYPE_INQUIRY || $this->m_type == TYPE_OPENSUB ||
($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_DLV ) ||
($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_DNY_CNF ) ||
$this->m_type == TYPE_REFUND
) {
if (($rtv = $this->m_Data->MakeEncrypt($this->m_Crypto)) != OK) {
$err_msg = "암호화 오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
return;
}
//$this->m_Log->WriteLog( DEBUG, "MAKE ENCRYPT OK" );
$this->m_Log->WriteLog(DEBUG, "MAKE ENCRYPT OK[" . $this->m_Data->m_EncBody . "]");
}
/* -------------------------------------------------- */
//전문생성(Body)
/* -------------------------------------------------- */
$this->m_Data->MakeBody();
$this->m_Log->WriteLog(INFO, "MAKE BODY OK");
//$this->m_Log->WriteLog( INFO, "MAKE BODY OK[".$this->m_Data->m_sBody."]" );
/* -------------------------------------------------- */
//서명(sign)
/* -------------------------------------------------- */
if (($rtv = $this->m_Crypto->Sign($this->m_Data->m_sBody, $sign)) != OK) {
$err_msg = "싸인실패";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreeAllKey();
return;
}
$this->m_Data->m_sTail = $sign;
$this->m_Log->WriteLog(INFO, "SIGN OK");
//$this->m_Log->WriteLog( INFO, "SIGN OK[".$sign."]" );
/* -------------------------------------------------- */
//전문생성(Head)
/* -------------------------------------------------- */
$this->m_Data->MakeHead();
$this->m_Log->WriteLog(INFO, "MAKE HEAD OK");
//$this->m_Log->WriteLog( INFO, "MAKE HEAD OK[".$head."]" );
$this->m_Log->WriteLog(DEBUG, "MSG_TO_PG:[" . $this->m_Data->m_sMsg . "]");
/* -------------------------------------------------- */
//소켓생성
/* -------------------------------------------------- */
//플러그인 에스크로 결제 구분 설정
$is_plugin_escrow = FALSE;
if($this->m_type == TYPE_ESCROW && ($this->m_Data->m_EscrowType == TYPE_ESCROW_CNF || $this->m_Data->m_EscrowType == TYPE_ESCROW_DNY)) $is_plugin_escrow = TRUE;
if(isset($this->m_REQUEST["pgn"]) && $this->m_REQUEST["pgn"] != "") {
$host = $this->m_REQUEST["pgn"];
} else {
if ($this->m_type == TYPE_SECUREPAY || $is_plugin_escrow == TRUE) { //plugin
$host = $this->m_Data->m_PG1;
} else if ($this->m_cancelRC == 1){ //원거래없음
$host = KSPG_IP;
} else {
$host = PG_HOST;
}
}
$this->m_Socket = new INISocket($host);
//1차 NSLOOKUP FAIL
if (($rtv = $this->m_Socket->DNSLookup()) != OK) {
$err_msg = "[" . $host . "] 1차 DNS LOOKUP 실패" . $this->m_Socket->getErr();
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
if ($this->m_type == TYPE_SECUREPAY || $is_plugin_escrow == TRUE) {
$this->m_Socket->ip = $this->m_Data->m_PG1IP;
} else {
if ($this->m_cancelRC == 1) $this->m_Socket->ip = KSPG_IP;
else $this->m_Socket->ip = PG_IP;
}
}
$this->m_Log->WriteLog(INFO, "DNS LOOKUP OK(" . $this->m_Socket->host . ", " . $this->m_Socket->ip . ":" . $this->m_Socket->port . ") laptime:" . $this->m_Socket->dns_laptime);
if (($rtv = $this->m_Socket->open()) != OK) {
$this->m_Socket->close();
//PG2로 전환
$err_msg = "[" . $host."(". $this->m_Socket->ip .") 소켓연결오류(1차):: 2차 연결시도";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
if ($this->m_type == TYPE_SECUREPAY || $is_plugin_escrow == TRUE) {
$host = $this->m_Data->m_PG2;
} else {
$host = $this->m_Socket->ip == PG_IP ? KSPG_IP:PG_IP;
}
$this->m_Socket = new INISocket($host);
//SECUREPAY만 2차 NSLOOKUP 진행, 이외는 IP통신
if ($this->m_type == TYPE_SECUREPAY || $is_plugin_escrow == TRUE) {
if (($rtv = $this->m_Socket->DNSLookup()) != OK) {
$err_msg = "[" . $host . "] 2차 DNS LOOKUP 실패" . $this->m_Socket->getErr();
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Socket->ip = $this->m_Data->m_PG2IP;
}
} else {
$this->m_Socket->ip = $host;
}
$this->m_Log->WriteLog(INFO, "DNS LOOKUP OK(" . $this->m_Socket->host . ", " . $this->m_Socket->ip . ":" . $this->m_Socket->port . ") laptime:" . $this->m_Socket->dns_laptime);
if (($rtv = $this->m_Socket->open()) != OK) {
$err_msg = "[" . $host . "소켓연결오류(2차)::" . $this->m_Socket->getErr();
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Socket->close();
$this->m_Crypto->FreeAllKey();
return;
}
}
$this->m_connIP = $this->m_Socket->ip;
$this->m_Log->WriteLog(INFO, "SOCKET CONNECT OK");
/* -------------------------------------------------- */
//전문송신
/* -------------------------------------------------- */
if (($rtv = $this->m_Socket->send($this->m_Data->m_sMsg)) != OK) {
$err_msg = "소켓송신오류(MAIN)::" . $this->m_Socket->getErr();
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreeAllKey();
$this->m_Socket->close();
return;
}
$this->m_Log->WriteLog(INFO, "SEND OK");
/* -------------------------------------------------- */
//전문수신
/* -------------------------------------------------- */
if (($rtv = $this->m_Socket->recv($head, $body, $tail)) != OK) {
$err_msg = "소켓수신오류(MAIN)::" . $this->m_Socket->getErr();
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Socket->close();
$this->NetCancel();
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreeAllKey();
return;
}
$this->m_Log->WriteLog(INFO, "RECV OK");
$this->m_Log->WriteLog(INFO, "MSG_FROM_PG:[" . $head . $body . $tail . "]");
$this->m_Data->m_Body = $body;
/* -------------------------------------------------- */
//서명확인
/* -------------------------------------------------- */
if (($rtv = $this->m_Crypto->Verify($body, $tail)) != OK) {
$err_msg = "VERIFY FAIL";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Socket->close();
$this->NetCancel();
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreeAllKey();
return;
}
$this->m_Log->WriteLog(INFO, "VERIFY OK");
/* -------------------------------------------------- */
//Head 파싱
/* -------------------------------------------------- */
if (($rtv = $this->m_Data->ParseHead($head)) != OK) {
$err_msg = "수신전문(HEAD) 파싱 오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Socket->close();
$this->NetCancel();
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreeAllKey();
return;
}
$this->m_Log->WriteLog(INFO, "PARSE HEAD OK");
/* -------------------------------------------------- */
//Body 파싱
/* -------------------------------------------------- */
if (($rtv = $this->m_Data->ParseBody($body, $encrypted, $sessionkey)) != OK) {
$err_msg = "수신전문(Body) 파싱 오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Socket->close();
$this->NetCancel();
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreeAllKey();
return;
}
$this->m_Log->WriteLog(INFO, "PARSE BODY OK");
/* -------------------------------------------------- */
//복호화
/* -------------------------------------------------- */
if ($this->m_type == TYPE_SECUREPAY || $this->m_type == TYPE_FORMPAY || $this->m_type == TYPE_OCBSAVE ||
$this->m_type == TYPE_CANCEL || $this->m_type == TYPE_AUTHBILL || $this->m_type == TYPE_FORMAUTH ||
$this->m_type == TYPE_REQREALBILL || $this->m_type == TYPE_REPAY || $this->m_type == TYPE_VACCTREPAY || $this->m_type == TYPE_RECEIPT ||
$this->m_type == TYPE_AUTH || $this->m_type == TYPE_CAPTURE || $this->m_type == TYPE_ESCROW ||
$this->m_type == TYPE_REFUND || $this->m_type == TYPE_INQUIRY || $this->m_type == TYPE_OPENSUB
) {
if (($rtv = $this->m_Crypto->Decrypt($sessionkey, $encrypted, $decrypted)) != OK) {
$err_msg = "복호화 실패[" . $this->GetResult(NM_RESULTMSG) . "]";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Socket->close();
$this->NetCancel();
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreeAllKey();
return;
}
$this->m_Log->WriteLog(INFO, "DECRYPT OK");
$this->m_Log->WriteLog(DEBUG, "DECRYPT MSG:[" . $decrypted . "]");
//Parse Decrypt
$this->m_Data->ParseDecrypt($decrypted);
$this->m_Log->WriteLog(INFO, "DECRYPT PARSE OK");
}
/* -------------------------------------------------- */
//Assign Interface Variables
/* -------------------------------------------------- */
$this->m_RESULT = $this->m_Data->m_RESULT;
/* -------------------------------------------------- */
//ACK
/* -------------------------------------------------- */
//if( $this->GetResult(NM_RESULTCODE) == "00" &&
if ((strcmp($this->GetResult(NM_RESULTCODE), "00") == 0) &&
( $this->m_type == TYPE_SECUREPAY || $this->m_type == TYPE_OCBSAVE ||
$this->m_type == TYPE_FORMPAY || $this->m_type == TYPE_RECEIPT
)
) {
$this->m_Log->WriteLog(INFO, "WAIT ACK INVOKING");
if (($rtv = $this->Ack()) != OK) {
//ERROR
$err_msg = "ACK 실패";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Socket->close();
$this->NetCancel();
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreeAllKey();
return;
}
$this->m_Log->WriteLog(INFO, "SUCCESS ACK INVOKING");
}
/* -------------------------------------------------- */
//PG 공개키가 바뀌었으면 공개키 UPDATE
/* -------------------------------------------------- */
$pgpubkey = $this->m_Data->GetXMLData(NM_PGPUBKEY);
if ($pgpubkey != "") {
if (($rtv = $this->m_Crypto->UpdatePGPubKey($pgpubkey)) != OK) {
$err_msg = "PG공개키 업데이트 실패";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->m_Data->GTHR($rtv, $err_msg);
} else
$this->m_Log->WriteLog(INFO, "PGPubKey UPDATED!!");
}
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreeAllKey();
$this->m_Socket->close();
return;
}
// End of StartAction
/* -------------------------------------------------- */
/* */
/* 웹페이지 위변조 방지용 데이타 생성 */
/* */
/* -------------------------------------------------- */
function MakeChkFake() {
$this->m_Crypto = new INICrypto($this->m_REQUEST);
/* -------------------------------------------------- */
//상점개인키 로드
/* -------------------------------------------------- */
if (($rtv = $this->m_Crypto->LoadMPrivKey()) != OK) {
$err_msg = "상점개인키 로드오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreePubKey();
return;
}
$this->m_Log->WriteLog(INFO, "MERCHANT PRIV KEY LOAD OK");
/* -------------------------------------------------- */
//상점 공개키 로드(SN 를 알기위해!!)
/* -------------------------------------------------- */
if (($rtv = $this->m_Crypto->LoadMPubKey($m_cert_SN)) != OK) {
$err_msg = "상점공개키 로드오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
return;
}
$this->m_Log->WriteLog(INFO, "MERCHANT PUB KEY LOAD OK [" . $this->m_Data->m_MPubSN . "]");
foreach ($this->m_REQUEST as $key => $val) {
if ($key == "inipayhome" || $key == "type" || $key == "debug" ||
$key == "admin" || $key == "checkopt" || $key == "enctype")
continue;
if ($key == "mid")
$temp1 .= $key . "=" . $val . "&"; //msg
else
$temp2 .= $key . "=" . $val . "&"; //hashmsg
}
//Make RN
$this->m_RESULT["rn"] = $this->m_Data->MakeRN();
$temp1 .= "rn=" . $this->m_RESULT["rn"] . "&";
$checkMsg = $temp1;
$checkHashMsg = $temp2;
$retHashStr = Base64Encode(sha1($checkHashMsg, TRUE));
$checkMsg .= "data=" . $retHashStr;
$HashMid = Base64Encode(sha1($this->m_REQUEST["mid"], TRUE));
$this->m_Crypto->RSAMPrivEncrypt($checkMsg, $RSATemp);
$this->m_RESULT["encfield"] = "enc=" . $RSATemp . "&src=" . Base64Encode($checkHashMsg);
$this->m_RESULT["certid"] = $HashMid . $m_cert_SN;
$this->m_Log->WriteLog(INFO, "CHKFAKE KEY MAKE OK:" . $this->m_RESULT["rn"]);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Crypto->FreeAllKey();
$this->m_RESULT[NM_RESULTCODE] = "00";
return;
}
/* -------------------------------------------------- */
/* */
/* 결제처리 확인 메세지 전송 */
/* */
/* -------------------------------------------------- */
function Ack() {
//ACK용 Data
$this->m_Data->m_sBody = "";
$this->m_Data->m_sTail = "";
$this->m_Data->m_sCmd = CMD_REQ_ACK;
//전문생성(Head)
$this->m_Data->MakeHead();
$this->m_Log->WriteLog(DEBUG, "MAKE HEAD OK");
//$this->m_Log->WriteLog( DEBUG, "MSG_TO_PG:[".$this->m_Data->m_sMsg."]" );
//Send
if (($rtv = $this->m_Socket->send($this->m_Data->m_sMsg)) != OK) {
$err_msg = "ACK 전송오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
return ACK_CHECKSUM_ERR;
}
//$this->m_Log->WriteLog( DEBUG, "SEND OK" );
if (($rtv = $this->m_Socket->recv($head, $body, $tail)) != OK) {
$err_msg = "ACK 수신오류(ACK)";
$this->m_Log->WriteLog(ERROR, $err_msg);
return ACK_CHECKSUM_ERR;
}
//$this->m_Log->WriteLog( DEBUG, "RECV OK" );
//$this->m_Log->WriteLog( INFO, "MSG_FROM_PG:[".$recv."]" );
return OK;
}
/* -------------------------------------------------- */
/* */
/* 망취소 메세지 전송 */
/* */
/* -------------------------------------------------- */
function NetCancel() {
$this->m_Log->WriteLog(INFO, "WAIT NETCANCEL INVOKING");
if ($this->m_type == TYPE_CANCEL || $this->m_type == TYPE_REPAY || $this->m_type == TYPE_VACCTREPAY || $this->m_type == TYPE_RECEIPT ||
$this->m_type == TYPE_CONFIRM || $this->m_type == TYPE_OCBQUERY || $this->m_type == TYPE_ESCROW ||
$this->m_type == TYPE_CAPTURE || $this->m_type == TYPE_AUTH || $this->m_type == TYPE_AUTHBILL ||
($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_DNY_CNF ) ||
$this->m_type == TYPE_NETCANCEL
) {
$this->m_Log->WriteLog(INFO, "DON'T NEED NETCANCEL");
return true;
}
//NetCancel용 Data
$this->m_Data->m_REQUEST["cancelmsg"] = "망취소";
$body = "";
$sign = "";
$this->m_Data->m_Type = TYPE_CANCEL; //망취소 전문은 취소전문과 같음.헤더만틀리고..쩝~
//added escrow netcancel, 08.03.11
if ($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_DLV)
$this->m_Data->m_sCmd = CMD_REQ_DLV_NETC;
else if ($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_CNF)
$this->m_Data->m_sCmd = CMD_REQ_CNF_NETC;
else if ($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_DNY)
$this->m_Data->m_sCmd = CMD_REQ_DNY_NETC;
else
$this->m_Data->m_sCmd = CMD_REQ_NETC;
$this->m_Data->m_sCrypto = FLAG_CRYPTO_3DES;
//암호화
if (($rtv = $this->m_Data->MakeEncrypt($this->m_Crypto)) != OK) {
$err_msg = "암호화 오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
//$this->MakeTXErrMsg( $rtv, $err_msg );
return;
}
$this->m_Log->WriteLog(DEBUG, "MAKE ENCRYPT OK[" . $this->m_Data->m_EncBody . "]");
//전문생성(Body)
$this->m_Data->MakeBody();
$this->m_Log->WriteLog(INFO, "MAKE BODY OK");
//서명(sign)
if (($rtv = $this->m_Crypto->Sign($this->m_Data->m_sBody, $sign)) != OK) {
$err_msg = "싸인실패";
$this->m_Log->WriteLog(ERROR, $err_msg);
//$this->MakeTXErrMsg( $rtv, $err_msg );
return false;
}
$this->m_Data->m_sTail = $sign;
$this->m_Log->WriteLog(INFO, "SIGN OK");
//전문생성(Head)
$this->m_Data->MakeHead();
$this->m_Log->WriteLog(INFO, "MAKE HEAD OK");
$this->m_Log->WriteLog(DEBUG, "MSG_TO_PG:[" . $this->m_Data->m_sMsg . "]");
//소켓생성
$this->m_Socket = new INISocket("");
$this->m_Socket->ip = $this->m_connIP; //기존연결된 IP 사용, 08.03.12
if (($rtv = $this->m_Socket->open()) != OK) {
$err_msg = "[" . $this->m_Socket->ip . "]소켓연결오류(NETC)::" . $this->m_Socket->getErr();
$this->m_Log->WriteLog(ERROR, $err_msg);
//$this->MakeTXErrMsg( $rtv, $err_msg );
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
$this->m_Socket->close();
$this->m_Crypto->FreeAllKey();
return;
}
$this->m_Log->WriteLog(INFO, "SOCKET CONNECT OK::" . $this->m_Socket->ip);
//전문송신
if (($rtv = $this->m_Socket->send($this->m_Data->m_sMsg)) != OK) {
$err_msg = "소켓송신오류(NETC)" . $this->m_Socket->getErr();
$this->m_Log->WriteLog(ERROR, $err_msg);
//$this->MakeTXErrMsg( $rtv, $err_msg );
$this->m_Socket->close();
return false;
}
$this->m_Log->WriteLog(INFO, "SEND OK");
//전문수신
if (($rtv = $this->m_Socket->recv($head, $body, $tail)) != OK) {
$err_msg = "소켓수신오류(NETC)";
$this->m_Log->WriteLog(ERROR, $err_msg);
//$this->MakeTXErrMsg( $rtv, $err_msg );
$this->m_Socket->close();
return false;
}
$this->m_Log->WriteLog(INFO, "RECV OK");
$this->m_Log->WriteLog(DEBUG, "MSG_FROM_PG:[" . $head . $body . $tail . "]");
//서명확인
if (($rtv = $this->m_Crypto->Verify($body, $tail)) != OK) {
$err_msg = "VERIFY FAIL";
$this->m_Log->WriteLog(ERROR, $err_msg);
//$this->MakeTXErrMsg( $rtv, $err_msg );
$this->m_Socket->close();
return false;
}
$this->m_Log->WriteLog(INFO, "VERIFY OK");
//이하 헤더나 본문은 파싱하지 않는다!!!!
//그냥 여기서 끝내자 피곤하다.-_-;;
//Head 파싱
if (($rtv = $this->m_Data->ParseHead($head)) != OK) {
$err_msg = "수신전문(HEAD) 파싱 오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
//$this->MakeTXErrMsg( $rtv, $err_msg );
$this->m_Socket->close();
return;
}
//Body 파싱
if (($rtv = $this->m_Data->ParseBody($body, $encrypted, $sessionkey)) != OK) {
$err_msg = "수신전문(Body) 파싱 오류";
$this->m_Log->WriteLog(ERROR, $err_msg);
//$this->MakeTXErrMsg( $rtv, $err_msg );
$this->m_Socket->close();
return;
}
//if( $this->GetResult(NM_RESULTCODE) == "00" )
if (strcmp($this->GetResult(NM_RESULTCODE), "00") == 0)
$this->m_Log->WriteLog(INFO, "SUCCESS NETCANCEL");
else
$this->m_Log->WriteLog(ERROR, "ERROR NETCANCEL[" . $this->GetResult(NM_RESULTMSG) . "]");
return true;
}
function MakeIMStr($s, $t) {
$this->m_Crypto = new INICrypto($this->m_REQUEST);
if ($t == "H")
return $this->m_Crypto->MakeIMStr($s, base64_decode(IMHK));
else if ($t == "J")
return $this->m_Crypto->MakeIMStr($s, base64_decode(IMJK));
}
/* -------------------------------------------------- */
/* */
/* 에러메세지 Make */
/* */
/* -------------------------------------------------- */
function MakeTXErrMsg($err_code, $err_msg) {
$this->m_RESULT[NM_RESULTCODE] = "01";
$this->m_RESULT[NM_RESULTERRORCODE] = $err_code;
$this->m_RESULT[NM_RESULTMSG] = "[" . $err_code . "|" . $err_msg . "]";
$this->m_Data->GTHR($err_code, $err_msg);
return;
}
}

View File

@ -1,226 +0,0 @@
<?php
/**
* Copyright (C) 2007 INICIS Inc.
*
* 해당 라이브러리는 절대 수정되어서는 안됩니다.
* 임의로 수정된 코드에 대한 책임은 전적으로 수정자에게 있음을 알려드립니다.
*
*/
class INISocket {
var $hnd;
var $host;
var $ip;
var $port;
var $type;
var $family;
var $protocol;
var $bConnected;
var $sBuffer;
var $sSocErr;
var $dns_laptime;
function error($msg = null) {
$errCode = socket_last_error($this->hnd);
if ($errCode != 0) {
//Connection reset by peer
if ($errCode == 104)
$this->bConnected = false;
$errMsg = socket_strerror($errCode);
$this->sSocErr = "(" . $errCode . ")(" . $errMsg . ")";
socket_clear_error($this->hnd);
}
elseif (strlen($msg)) {
$this->sSocErr = $errMsg;
}
return false;
}
function __construct($host) {
$this->family = AF_INET;
$this->type = SOCK_STREAM;
$this->protocol = SOL_TCP;
$this->hnd = @socket_create($this->family, $this->type, $this->protocol);
$this->error();
$this->sBuffer = false;
$this->ip = null;
$this->host = $host;
$this->port = PG_PORT;
}
function DNSLookUP() {
$starttime = GetMicroTime();
$ip = @gethostbyname($this->host);
if ($ip == PG_IP || $ip == KSPG_IP) {
$this->ip = $ip;
} else {
$this->error("Hostname " . $this->host . " could not be resolved");
return DNS_LOOKUP_ERR;
}
$this->dns_laptime = round(GetMicroTime() - $starttime, 3);
if ($this->dns_laptime > DNS_LOOKUP_TIMEOUT)
return DNS_LOOKUP_TIMEOUT_ERR;
return OK;
}
function open() {
//Connect timeout Trickkkkkkkkk ##2. NONBLOCKING NEED , less CPU clocking!!^^
//modified by ddaemiri, 2007.08.30
socket_set_nonblock($this->hnd);
if (!@socket_connect($this->hnd, $this->ip, $this->port)) {
$err = socket_last_error($this->hnd);
$err_str = socket_strerror($err);
if ($err == 106) { //EISCONN
$this->bConnected = true;
socket_set_block($this->hnd);
return OK;
}
//EINPROGRESS( Linux:115, Window Socket:10035, FreeBSD4.10:36, 모든 OS 체크 불가능해서 str으로도 검색 )
if ($err != ERRCODE_INPROGRESS_LINUX && $err != ERRCODE_INPROGRESS_WIN &&
$err != ERRCODE_INPROGRESS_FREEBSD && $err_str != ERRSTR_INPROGRESS) {
$this->error();
socket_close($this->hnd);
return SOCK_CONN_ERR;
}
}
$read = array($this->hnd);
$write = array($this->hnd);
$except = NULL;
$rtv = @socket_select($read, $write, $except, TIMEOUT_CONNECT);
if ($rtv == 0) { //TIMEOUT
$this->error();
socket_close($this->hnd);
return SOCK_TIMEO_ERR;
} else if ($rtv === FALSE) {
$this->error();
socket_close($this->hnd);
return SOCK_ETC1_ERR;
}
if (in_array($this->hnd, $read) || in_array($this->hnd, $write)) {
if (@socket_get_option($this->hnd, SOL_SOCKET, SO_ERROR) === FALSE) {
$this->error();
socket_close($this->hnd);
return SOCK_ETC2_ERR;
}
}
$this->bConnected = true;
socket_set_block($this->hnd);
return OK;
}
function close() {
//if(!$this->bConnected) return;
@socket_shutdown($this->hnd, 2);
@socket_close($this->hnd);
}
function send($sBuf) {
if (!$this->bConnected) {
$this->error("Socket error. Cannot send data on a closed socket.");
return SOCK_SEND1_ERR;
}
$vWrite = array($this->hnd);
$vRead = null;
$vExcept = null;
while (($rtv = @socket_select($vRead, $vWrite, $vExcept, TIMEOUT_WRITE)) === FALSE);
if ($rtv == 0) {
$this->error();
//return SOCK_TIMEO_ERR;
return SOCK_CONN_ERR; //modify 2008.04.01
}
if ($rtv === FALSE) {
$this->error();
return SOCK_SEND2_ERR;
}
$tmpBuf = strlen($sBuf) ? $sBuf : $this->sBuffer;
$iBufLen = strlen($tmpBuf);
$res = @socket_send($this->hnd, $tmpBuf, $iBufLen, 0);
if ($res === FALSE) {
$this->error();
return SOCK_SEND2_ERR;
} elseif ($res < $iBufLen) {
$tmpBuf = substr($tmpBuf, $res);
$this->send($tmpBuf);
}
return OK;
}
function WaitRecv(&$recv_buf, $nleft) {
$recv_buf = null;
$read = array($this->hnd);
$buf = null;
while ($nleft > 0) {
$write = null;
$except = null;
$rtv = @socket_select($read, $write, $except, TIMEOUT_READ);
if ($rtv == 0) {
$this->error();
return SOCK_TIMEO_ERR;
} else if ($rtv === FALSE) {
$this->error();
return SOCK_ETC1_ERR;
}
if (!in_array($this->hnd, $read)) {
$this->error();
return SOCK_RECV1_ERR;
}
if ($buf = @socket_read($this->hnd, $nleft)) {
$recv_buf .= $buf;
} else {
$this->error();
return SOCK_RECV1_ERR;
}
$nleft -= strlen($buf);
}
return OK;
}
function recv(&$head, &$body, &$tail) {
if (!$this->bConnected) {
$this->error("Socket error. Cannot read any data on a closed socket.");
return SOCK_RECV1_ERR;
}
//------------------------------------------------------
//head
//------------------------------------------------------
if (($rtv = $this->WaitRecv($head, MSGHEADER_LEN)) != OK)
return $rtv;
if ($head == "")
return SOCK_RECV2_ERR;
$body_len = intval(substr($head, 0, BODY_LEN));
$tail_len = intval(substr($head, BODY_LEN, TAIL_LEN));
//------------------------------------------------------
//body
//------------------------------------------------------
if (($rtv = $this->WaitRecv($body, $body_len)) != OK)
return $rtv;
//------------------------------------------------------
//tail
//------------------------------------------------------
if (($rtv = $this->WaitRecv($tail, $tail_len)) != OK)
return $rtv;
return OK;
}
function getErr() {
return $this->sSocErr;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,134 @@
<?php
if (!defined('_GNUBOARD_')) exit;
function get_inicis_iniapi_key() {
global $default;
// iniapi_key 는 전체취소, 부분취소, 현금영수증, 에스크로 배송등록에 사용됨
if ($default['de_card_test']) { // 테스트결제이면
if ($default['de_inicis_mid'] === 'iniescrow0') { // 에스크로 테스트용 mid
return 'yERbIlJ3NhTeObsA';
} else if ($default['de_inicis_mid'] === 'INIpayTest'){ // 일반 테스트용 mid
return 'ItEQKi3rY7uvDS8l';
}
}
return $default['de_inicis_iniapi_key'];
}
function get_inicis_iniapi_iv() {
global $default;
// iniapi_iv 는 현금영수증 발급에 사용됨
if ($default['de_card_test']) { // 테스트결제이면
if ($default['de_inicis_mid'] === 'iniescrow0') { // 에스크로 테스트용 mid
return 'tOGDXbfoajk2DQ==';
} else if ($default['de_inicis_mid'] === 'INIpayTest'){ // 일반 테스트용 mid
return 'HYb3yQ4f65QL89==';
}
}
return $default['de_inicis_iniapi_iv'];
}
// KG 이니시스 일반 주문 취소 함수
// $args 변수의 타입은 array, $is_part 변수는 부분취소 구분 변수
function inicis_tid_cancel($args, $is_part=false){
global $default;
// step1. 요청을 위한 파라미터 설정
// 가맹점관리자 > 상점정보 > 계약정보 > 부가정보 > INIAPI key 생성조회
$key = isset($args['key']) ? $args['key'] : get_inicis_iniapi_key();
$type = "Refund"; // 고정
$paymethod = isset($args['paymethod']) ? $args['paymethod'] : "Card";
$timestamp = isset($args['timestamp']) ? $args['timestamp'] : date("YmdHis");
$clientIp = isset($args['clientIp']) ? $args['clientIp'] : $_SERVER['SERVER_ADDR'];
$mid = isset($args['mid']) ? $args['mid'] : $default['de_inicis_mid'];
$tid = $args['tid'];
$msg = $args['msg'];
// 부분취소인 경우
if ($is_part){
$type = 'PartialRefund';
$price = $args['price'];
$confirmPrice = $args['confirmPrice'];
// INIAPIKey + type + paymethod + timestamp + clientIp + mid + tid + price + confirmPrice
$hashData = hash("sha512",(string)$key.(string)$type.(string)$paymethod.(string)$timestamp.(string)$clientIp.(string)$mid.(string)$tid.(string)$price.(string)$confirmPrice); // hash 암호화
//step2. key=value 로 post 요청
$data = array(
'type' => $type,
'paymethod' => $paymethod,
'timestamp' => $timestamp,
'clientIp' => $clientIp,
'mid' => $mid,
'tid' => $tid,
'price' => $price,
'confirmPrice' => $confirmPrice,
'msg' => $msg,
'hashData'=> $hashData
);
} else {
// 전체취소인 경우
// INIAPIKey + type + paymethod + timestamp + clientIp + mid + tid
$hashData = hash("sha512", (string)$key.(string)$type.(string)$paymethod.(string)$timestamp.(string)$clientIp.(string)$mid.(string)$tid); // hash 암호화
//step2. key=value 로 post 요청
$data = array(
'type' => $type,
'paymethod' => $paymethod,
'timestamp' => $timestamp,
'clientIp' => $clientIp,
'mid' => $mid,
'tid' => $tid,
'msg' => $msg,
'hashData'=> $hashData
);
}
$url = "https://iniapi.inicis.com/api/v1/refund";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded; charset=utf-8'));
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
curl_close($ch);
//step3. 요청 결과
return $response;
}
function get_type_inicis_paymethod($od_settle_case){
$ini_paymethod = '';
switch ($od_settle_case) {
case '신용카드':
case '간편결제':
$ini_paymethod = 'Card';
break;
case '가상계좌':
$ini_paymethod = 'GVacct'; // 가상계좌 (입금전, 채번취소 시 사용)
break;
case '계좌이체':
$ini_paymethod = 'Acct';
break;
case '휴대폰':
$ini_paymethod = 'HPP';
break;
}
if (! $ini_paymethod) {
if (is_inicis_order_pay($od_settle_case)) {
$ini_paymethod = 'Card';
}
}
return $ini_paymethod;
}

View File

@ -9,52 +9,29 @@ $vat_mny = round((int)$tax_mny / 1.1);
$currency = 'WON';
$oldtid = $od['od_tno'];
$price = (int)$tax_mny + (int)$free_mny;
$confirm_price = (int)$od['od_receipt_price'] - (int)$od['od_refund_price'] - $price;
$price = (int)$tax_mny + (int)$free_mny; // 취소요청 금액
$confirm_price = (int)$od['od_receipt_price'] - (int)$od['od_refund_price'] - $price; // 부분취소 후 남은금액
$buyeremail = $od['od_email'];
$tax = (int)$tax_mny - $vat_mny;
$taxfree = (int)$free_mny;
$tax = (int)$tax_mny - $vat_mny; // 부가세
$taxfree = (int)$free_mny; // 비과세
/***********************
* 3. 재승인 정보 설정 *
***********************/
$inipay->SetField("type", "repay"); // 고정 (절대 수정 불가)
$inipay->SetField("pgid", "INIphpRPAY"); // 고정 (절대 수정 불가)
$inipay->SetField("subpgip", "203.238.3.10"); // 고정
$inipay->SetField("mid", $default['de_inicis_mid']); // 상점아이디
$inipay->SetField("admin", $default['de_inicis_admin_key']); //비대칭 사용키 키패스워드
$inipay->SetField("oldtid", $oldtid); // 취소할 거래의 거래아이디
$inipay->SetField("currency", $currency); // 화폐단위
$inipay->SetField("price", $price); // 취소금액
$inipay->SetField("confirm_price", $confirm_price); // 승인요청금액
$inipay->SetField("buyeremail", $buyeremail); // 구매자 이메일 주소
$inipay->SetField("tax", $tax); // 부가세금액
$inipay->SetField("taxfree", $taxfree); // 비과세금액
$args = array(
'paymethod' => get_type_inicis_paymethod($od['od_settle_case']),
'tid' => $od['od_tno'],
'msg' => $od['od_id'].' '.$mod_memo,
'price' => $price,
'confirmPrice' => $confirm_price,
'tax' => $tax,
'taxFree' => $taxfree
);
/******************
* 4. 재승인 요청 *
******************/
$inipay->startAction();
$response = inicis_tid_cancel($args, true); // KG 이니시스 부분취소일 경우 inicis_tid_cancel 함수 2번째 인자값을 true로
$result = json_decode($response, true);
/*******************************************************************
* 5. 재승인 결과 *
* *
* 신거래번호 : $inipay->getResult('TID') *
* 결과코드 : $inipay->getResult('ResultCode') ("00"이면 재승인 성공) *
* 결과내용 : $inipay->getResult('ResultMsg') (재승인결과에 대한 설명) *
* 원거래 번호 : $inipay->getResult('PRTC_TID') *
* 최종결제 금액 : $inipay->getResult('PRTC_Remains') *
* 부분취소 금액 : $inipay->getResult('PRTC_Price') *
* 부분취소,재승인 구분값 : $inipay->getResult('PRTC_Type') *
* ("0" : 재승인, "1" : 부분취소) *
* 부분취소(재승인) 요청횟수 : $inipay->getResult('PRTC_Cnt') *
*******************************************************************/
if($inipay->getResult('ResultCode') == '00') {
if(isset($result['resultCode']) && $result['resultCode'] == '00') {
// 환불금액기록
$tno = $inipay->getResult('PRTC_TID');
$re_price = $inipay->getResult('PRTC_Price');
$tno = $result['prtcTid'];
$re_price = $result['prtcPrice'];
$sql = " update {$g5['g5_shop_order_table']}
set od_refund_price = od_refund_price + '$re_price',
@ -74,5 +51,9 @@ $inipay->startAction();
where od_id = '$od_id' ";
sql_query($sql);
} else {
alert(iconv_utf8($inipay->GetResult("ResultMsg")).' 코드 : '.$inipay->GetResult("ResultCode"));
if (isset($result['resultCode'])){
alert($result['resultMsg'].' 코드 : '.$result['resultCode']);
} else {
alert('curl 오류로 부분환불에 실패했습니다.');
}
}

View File

@ -2,14 +2,18 @@
include_once('./_common.php');
include_once(G5_SHOP_PATH.'/settle_inicis.inc.php');
/* INIreceipt.php
$iv = get_inicis_iniapi_iv();
if (strlen($iv) !== 16){
alert('쇼핑몰설정 < KG이니시스 INIAPI IV 값을 16자리로 설정 후 이용해 주세요.');
}
/*
*
* 현금결제(실시간 은행계좌이체, 무통장입금)에 대한 현금결제 영수증 발행 요청한다.
*
*
* http://www.inicis.com
* http://support.inicis.com
* Copyright (C) 2006 Inicis, Co. All rights reserved.
*/
$companynumber = isset($_REQUEST['companynumber']) ? clean_xss_tags($_REQUEST['companynumber'], 1, 1) : '';
@ -50,66 +54,90 @@ $reg_num = $id_info;
$useopt = $tr_code;
$currency = 'WON';
/*********************
* 3. 발급 정보 설정 *
*********************/
$inipay->SetField("type" ,"receipt"); // 고정
$inipay->SetField("pgid" ,"INIphpRECP"); // 고정
$inipay->SetField("paymethod" ,"CASH"); // 고정 (요청분류)
$inipay->SetField("currency" ,$currency); // 화폐단위 (고정)
/**************************************************************************************************
* admin 은 키패스워드 변수명입니다. 수정하시면 안됩니다. 1111의 부분만 수정해서 사용하시기 바랍니다.
* 키패스워드는 상점관리자 페이지(https://iniweb.inicis.com)의 비밀번호가 아닙니다. 주의해 주시기 바랍니다.
* 키패스워드는 숫자 4자리로만 구성됩니다. 이 값은 키파일 발급시 결정됩니다.
* 키패스워드 값을 확인하시려면 상점측에 발급된 키파일 안의 readme.txt 파일을 참조해 주십시오.
**************************************************************************************************/
$inipay->SetField("admin" ,$default['de_inicis_admin_key']); // 키패스워드(상점아이디에 따라 변경)
$inipay->SetField("mid" ,$default['de_inicis_mid']); // 상점아이디
$inipay->SetField("goodname" ,iconv_euckr($goodname)); // 상품명
$inipay->SetField("cr_price" ,$amt_tot); // 총 현금결제 금액
$inipay->SetField("sup_price" ,$amt_sup); // 공급가액
$inipay->SetField("tax" ,$amt_tax); // 부가세
$inipay->SetField("srvc_price" ,$amt_svc); // 봉사료
$inipay->SetField("buyername" ,iconv_euckr($buyername)); // 구매자 성명
$inipay->SetField("buyeremail" ,$buyeremail); // 구매자 이메일 주소
$inipay->SetField("buyertel" ,$buyertel); // 구매자 전화번호
$inipay->SetField("reg_num" ,$reg_num); // 현금결제자 주민등록번호
$inipay->SetField("useopt" ,$useopt); // 현금영수증 발행용도 ("1" - 소비자 소득공제용, "2" - 사업자 지출증빙용)
$inipay->SetField("companynumber" ,$companynumber); // 서브몰 사업자번호
//step1. 요청을 위한 파라미터 설정
// 가맹점관리자 > 상점정보 > 계약정보 > 부가정보 > INIAPI key 생성조회, IV 도 조회 가능
$key = get_inicis_iniapi_key();
$iv = get_inicis_iniapi_iv();
$type = "Issue";// 고정
$paymethod = "Receipt";// 고정
$timestamp = date("YmdHis");
$clientIp = $_SERVER['SERVER_ADDR'];// 가맹점 요청 서버IP (추후 거래 확인 등에 사용됨)
$mid = $default['de_inicis_mid'];
$goodName = $goodname; // 상품명
$crPrice = $amt_tot;// 총 현금결제 금액
$supPrice = $amt_sup;// 공급가액
$tax = $amt_tax;// 부가세
$srcvPrice = $amt_svc;// 봉사료
$buyerName = $buyername;// 구매자 성명
$buyerEmail = $buyeremail;// 구매자 이메일 주소
$buyerTel = $buyertel;// 구매자 전화번호
$useOpt = $useopt;// 현금영수증 발행용도 ("1" - 소비자 소득공제용, "2" - 사업자 지출증빙용)
$regNum = $reg_num;// 현금결제자 주민등록번호
// AES 암호화 (regNum)
if (function_exists('openssl_encrypt')) {
$enregNum = base64_encode(openssl_encrypt($regNum, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv));
} else if (function_exists('mcrypt_encrypt')) {
$padSize = 16 - (strlen($regNum) % 16);
$value = $regNum.str_repeat(chr($padSize), $padSize);
$enregNum = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $value, MCRYPT_MODE_CBC, $iv));
} else {
alert('openssl_encrypt 함수가 없어서 실행할수 없습니다.');
}
/****************
* 4. 발급 요청 *
****************/
$inipay->startAction();
// SHA512 Hash 암호화
// INIAPIKey + type + paymethod + timestamp + clientIp + mid + tid + crPrice + supPrice + srcvPrice + enregNum
$hashData = hash("sha512", (string)$key.(string)$type.(string)$paymethod.(string)$timestamp.(string)$clientIp.(string)$mid.(string)$crPrice.(string)$supPrice.(string)$srcvPrice.(string)$enregNum);
//step2. key=value 로 post 요청
/********************************************************************************
* 5. 발급 결과 *
* *
* 결과코드 : $inipay->GetResult('ResultCode') ("00" 이면 발행 성공) *
* 승인번호 : $inipay->GetResult('ApplNum') (현금영수증 발행 승인번호) *
* 승인날짜 : $inipay->GetResult('ApplDate') (YYYYMMDD) *
* 승인시각 : $inipay->GetResult('ApplTime') (HHMMSS) *
* 거래번호 : $inipay->GetResult('TID') *
* 총현금결제 금액 : $inipay->GetResult('CSHR_ApplPrice') *
* 공급가액 : $inipay->GetResult('CSHR_SupplyPrice') *
* 부가세 : $inipay->GetResult('CSHR_Tax') *
* 봉사료 : $inipay->GetResult('CSHR_ServicePrice') *
* 사용구분 : $inipay->GetResult('CSHR_Type') *
********************************************************************************/
$data = array(
'type' => $type,
'paymethod' => $paymethod,
'timestamp' => $timestamp,
'clientIp' => $clientIp,
'mid' => $mid,
'goodName' => $goodName,
'crPrice' => $crPrice,
'supPrice' => $supPrice,
'tax' => $tax,
'srcvPrice' => $srcvPrice,
'buyerName' => $buyerName,
'buyerEmail' => $buyerEmail,
'buyerTel' => $buyerTel,
'regNum' => $enregNum,
'useOpt' => $useOpt,
'compayNumber' => $companynumber,
'hashData'=> $hashData
);
$url = "https://iniapi.inicis.com/api/v1/receipt";
// DB 반영
if($inipay->GetResult('ResultCode') == '00') {
$cash_no = $inipay->GetResult('ApplNum');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded; charset=utf-8'));
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
curl_close($ch);
//step3. 요청 결과
$ini_result = json_decode($response, true);
if (isset($ini_result['resultCode']) && $ini_result['resultCode'] == '00') {
// DB 반영
$cash_no = $ini_result['authNo']; // 현금영수증 승인번호
$cash = array();
$cash['TID'] = $inipay->GetResult('TID');
$cash['ApplNum'] = $inipay->GetResult('ApplNum');
$cash['ApplDate'] = $inipay->GetResult('ApplDate');
$cash['ApplTime'] = $inipay->GetResult('ApplTime');
$cash['CSHR_Type'] = $inipay->GetResult('CSHR_Type');
$cash['TID'] = $ini_result['tid'];
$cash['ApplNum'] = $cash_no;
$cash['ApplDate'] = $ini_result['authDate'];
$cash['ApplTime'] = $ini_result['authTime'];
$cash['CSHR_Type'] = $ini_result['authUseOpt'];
$cash_info = serialize($cash);
if($tx == 'personalpay') {
@ -128,8 +156,6 @@ if($inipay->GetResult('ResultCode') == '00') {
$result = sql_query($sql, false);
if(!$result)
include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
}
$g5['title'] = '현금영수증 발급';
@ -139,7 +165,7 @@ include_once(G5_PATH.'/head.sub.php');
<script>
function showreceipt() // 현금 영수증 출력
{
var showreceiptUrl = "https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid=<?php echo($inipay->GetResult('TID')); ?>" + "&clpaymethod=22";
var showreceiptUrl = "https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid=<?php echo($ini_result['tid']); ?>" + "&clpaymethod=22";
window.open(showreceiptUrl,"showreceipt","width=380,height=540, scrollbars=no,resizable=no");
}
</script>
@ -156,23 +182,23 @@ function showreceipt() // 현금 영수증 출력
<tbody>
<tr>
<th scope="row">결과코드</th>
<td><?php echo $inipay->GetResult('ResultCode'); ?></td>
<td><?php echo $ini_result['resultCode']; ?></td>
</tr>
<tr>
<th scope="row">결과 메세지</th>
<td><?php echo iconv_utf8($inipay->GetResult('ResultMsg')); ?></td>
<td><?php echo $ini_result['resultMsg']; ?></td>
</tr>
<tr>
<th scope="row">현금영수증 거래번호</th>
<td><?php echo $inipay->GetResult('TID'); ?></td>
<td><?php echo $ini_result['tid']; ?></td>
</tr>
<tr>
<th scope="row">현금영수증 승인번호</th>
<td><?php echo $inipay->GetResult('ApplNum'); ?></td>
<td><?php echo $ini_result['authNo']; ?></td>
</tr>
<tr>
<th scope="row">승인시간</th>
<td><?php echo preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/", "\\1-\\2-\\3 \\4:\\5:\\6",$inipay->GetResult('ApplDate').$inipay->GetResult('ApplTime')); ?></td>
<td><?php echo preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/", "\\1-\\2-\\3 \\4:\\5:\\6",$ini_result['authDate'].$ini_result['authTime']); ?></td>
</tr>
<tr>
<th scope="row">현금영수증 URL</th>

View File

@ -62,27 +62,24 @@ if($cancelFlag == "true")
}
if(! (isset($inipay) && method_exists($inipay, 'SetField'))) return;
$args = array(
'key' => isset($default['de_kakaopay_iniapi_key']) ? $default['de_kakaopay_iniapi_key'] : '',
'mid' => $default['de_kakaopay_mid'],
'paymethod' => 'Card',
'tid' => $tno,
'msg' => $cancel_msg // 취소사유
);
$TID = $tno;
$inipay->SetField("type", "cancel"); // 고정
if( $default['de_kakaopay_cancelpwd'] ){
$inipay->SetField("mid", $default['de_kakaopay_mid']);
$inipay->SetField("admin", $default['de_kakaopay_cancelpwd']);
}
$inipay->SetField("tid", $TID); // 고정
$inipay->SetField("cancelmsg", $cancel_msg); // 취소사유
$inipay->startAction();
if($inipay->GetResult('ResultCode') == "00" && $db_check)
{
$inipay->MakeTXErrMsg(MERCHANT_DB_ERR,"Merchant DB FAIL");
}
$response = inicis_tid_cancel($args);
$result = json_decode($response, true);
$res_cd = $inipay->getResult('ResultCode');
$res_msg = $inipay->getResult('ResultMsg');
if($res_cd != '00') {
$pg_res_cd = $res_cd;
$pg_res_msg = iconv_utf8($res_msg);
if (isset($result['resultCode'])) {
if ($result['resultCode'] != '00') {
$pg_res_cd = $result['resultCode'];
$pg_res_msg = $result['resultMsg'];
}
} else {
$pg_res_cd = '';
$pg_res_msg = 'curl 로 데이터를 받지 못했습니다.';
}
}

View File

@ -15,46 +15,25 @@ $buyeremail = $od['od_email'];
$tax = (int)$tax_mny - $vat_mny;
$taxfree = (int)$free_mny;
/***********************
* 3. 재승인 정보 설정 *
***********************/
$inipay->SetField("type", "repay"); // 고정 (절대 수정 불가)
$inipay->SetField("pgid", "INIphpRPAY"); // 고정 (절대 수정 불가)
$inipay->SetField("subpgip", "203.238.3.10"); // 고정
$inipay->SetField("mid", $default['de_kakaopay_mid']); // 상점아이디
$inipay->SetField("admin", $default['de_kakaopay_cancelpwd']); //비대칭 사용키 키패스워드
$inipay->SetField("oldtid", $oldtid); // 취소할 거래의 거래아이디
$inipay->SetField("currency", $currency); // 화폐단위
$inipay->SetField("price", $price); // 취소금액
$inipay->SetField("confirm_price", $confirm_price); // 승인요청금액
$inipay->SetField("buyeremail", $buyeremail); // 구매자 이메일 주소
$inipay->SetField("tax", $tax); // 부가세금액
$inipay->SetField("taxfree", $taxfree); // 비과세금액
$args = array(
'key' => isset($default['de_kakaopay_iniapi_key']) ? $default['de_kakaopay_iniapi_key'] : '',
'mid' => $default['de_kakaopay_mid'],
'paymethod' => get_type_inicis_paymethod($od['od_settle_case']),
'tid' => $od['od_tno'],
'msg' => $od['od_id'].' '.$mod_memo,
'price' => $price,
'confirmPrice' => $confirm_price,
'tax' => $tax,
'taxFree' => $taxfree
);
/******************
* 4. 재승인 요청 *
******************/
$inipay->startAction();
$response = inicis_tid_cancel($args, true); // KG 이니시스 부분취소일 경우 inicis_tid_cancel 함수 2번째 인자값을 true로
$result = json_decode($response, true);
/*******************************************************************
* 5. 재승인 결과 *
* *
* 신거래번호 : $inipay->getResult('TID') *
* 결과코드 : $inipay->getResult('ResultCode') ("00"이면 재승인 성공) *
* 결과내용 : $inipay->getResult('ResultMsg') (재승인결과에 대한 설명) *
* 원거래 번호 : $inipay->getResult('PRTC_TID') *
* 최종결제 금액 : $inipay->getResult('PRTC_Remains') *
* 부분취소 금액 : $inipay->getResult('PRTC_Price') *
* 부분취소,재승인 구분값 : $inipay->getResult('PRTC_Type') *
* ("0" : 재승인, "1" : 부분취소) *
* 부분취소(재승인) 요청횟수 : $inipay->getResult('PRTC_Cnt') *
*******************************************************************/
if($inipay->getResult('ResultCode') == '00') {
if (isset($result['resultCode']) && $result['resultCode'] == '00') {
// 환불금액기록
$tno = $inipay->getResult('PRTC_TID');
$re_price = $inipay->getResult('PRTC_Price');
$tno = $result['prtcTid'];
$re_price = $result['prtcPrice'];
$sql = " update {$g5['g5_shop_order_table']}
set od_refund_price = od_refund_price + '$re_price',
@ -74,5 +53,9 @@ $inipay->startAction();
where od_id = '$od_id' ";
sql_query($sql);
} else {
alert(iconv_utf8($inipay->GetResult("ResultMsg")).' 코드 : '.$inipay->GetResult("ResultCode"));
if (isset($result['resultCode'])){
alert($result['resultMsg'].' 코드 : '.$result['resultCode']);
} else {
alert('curl 오류로 부분환불에 실패했습니다.');
}
}

View File

@ -66,44 +66,30 @@ if($od['od_tno']) {
break;
case 'inicis':
include_once(G5_SHOP_PATH.'/settle_inicis.inc.php');
$cancel_msg = iconv_euckr('주문자 본인 취소-'.$cancel_memo);
$cancel_msg = '주문자 본인 취소-'.$cancel_memo;
/*********************
* 3. 취소 정보 설정 *
*********************/
$inipay->SetField("type", "cancel"); // 고정 (절대 수정 불가)
$inipay->SetField("mid", $default['de_inicis_mid']); // 상점아이디
/**************************************************************************************************
* admin 은 키패스워드 변수명입니다. 수정하시면 안됩니다. 1111의 부분만 수정해서 사용하시기 바랍니다.
* 키패스워드는 상점관리자 페이지(https://iniweb.inicis.com)의 비밀번호가 아닙니다. 주의해 주시기 바랍니다.
* 키패스워드는 숫자 4자리로만 구성됩니다. 이 값은 키파일 발급시 결정됩니다.
* 키패스워드 값을 확인하시려면 상점측에 발급된 키파일 안의 readme.txt 파일을 참조해 주십시오.
**************************************************************************************************/
$inipay->SetField("admin", $default['de_inicis_admin_key']); //비대칭 사용키 키패스워드
$inipay->SetField("tid", $od['od_tno']); // 취소할 거래의 거래아이디
$inipay->SetField("cancelmsg", $cancel_msg); // 취소사유
$args = array(
'paymethod' => get_type_inicis_paymethod($od['od_settle_case']),
'tid' => $od['od_tno'],
'msg' => $cancel_msg
);
/****************
* 4. 취소 요청 *
****************/
$inipay->startAction();
$response = inicis_tid_cancel($args);
$result = json_decode($response, true);
/****************************************************************
* 5. 취소 결과 *
* *
* 결과코드 : $inipay->getResult('ResultCode') ("00"이면 취소 성공) *
* 결과내용 : $inipay->getResult('ResultMsg') (취소결과에 대한 설명) *
* 취소날짜 : $inipay->getResult('CancelDate') (YYYYMMDD) *
* 취소시각 : $inipay->getResult('CancelTime') (HHMMSS) *
* 현금영수증 취소 승인번호 : $inipay->getResult('CSHR_CancelNum') *
* (현금영수증 발급 취소시에만 리턴됨) *
****************************************************************/
$res_cd = '';
$res_msg = 'curl 로 데이터를 받지 못했습니다.';
$res_cd = $inipay->getResult('ResultCode');
$res_msg = $inipay->getResult('ResultMsg');
if (isset($result['resultCode'])) {
$res_cd = $result['resultCode'];
$res_msg = $result['resultMsg'];
} else {
$res_cd = '';
$res_msg = 'curl 로 데이터를 받지 못했습니다.';
}
if($res_cd != '00') {
alert(iconv_utf8($res_msg).' 코드 : '.$res_cd);
alert($res_msg.' 코드 : '.$res_cd);
}
break;
default:

View File

@ -7,13 +7,11 @@ if ($default['de_card_test']) {
if ($default['de_escrow_use'] == 1) {
// 에스크로결제 테스트
$default['de_inicis_mid'] = 'iniescrow0';
$default['de_inicis_admin_key'] = '1111';
$default['de_inicis_sign_key'] = 'SU5JTElURV9UUklQTEVERVNfS0VZU1RS';
}
else {
// 일반결제 테스트
$default['de_inicis_mid'] = 'INIpayTest';
$default['de_inicis_admin_key'] = '1111';
$default['de_inicis_sign_key'] = 'SU5JTElURV9UUklQTEVERVNfS0VZU1RS';
}
@ -41,25 +39,13 @@ else {
/**************************
* 1. 라이브러리 인클루드 *
**************************/
require_once(G5_SHOP_PATH.'/inicis/libs/INILib.php');
require_once(G5_SHOP_PATH.'/inicis/libs/INIStdPayUtil.php');
require_once(G5_SHOP_PATH.'/inicis/libs/sha256.inc.php');
require_once(G5_SHOP_PATH.'/inicis/libs/inicis_youngcart_fn.php');
$mid = $default['de_inicis_mid'];
$signKey = $default['de_inicis_sign_key'];
/***************************************
* 2. INIpay50 클래스의 인스턴스 생성 *
***************************************/
$inipay = new INIpay50;
$inipay->SetField("inipayhome", G5_SHOP_PATH.'/inicis'); // 이니페이 홈디렉터리(상점수정 필요)
$inipay->SetField("debug", "false");
if( ! function_exists('mcrypt_encrypt')) { // mcrypt 관련 함수가 없다면 취소시 openssl로 합니다.
$inipay->SetField("encMethod", "openssl");
}
$util = new INIStdPayUtil();
$timestamp = $util->getTimestamp(); // util에 의해서 자동생성