Merge pull request #57 from gnuboard/release/toss-version-update-squash

feat: 토스페이먼츠 v2 결제 모듈 연동 작업 완료
This commit is contained in:
2025-09-22 10:04:39 +09:00
committed by GitHub
44 changed files with 2627 additions and 27 deletions

View File

@ -743,14 +743,15 @@ a.nicepay_btn{display:inline-block;margin:5px 0 0;padding:5px 10px;background:#0
ul.de_pg_tab{margin:0;padding:0;zoom:1} ul.de_pg_tab{margin:0;padding:0;zoom:1}
ul.de_pg_tab:after{display:block;visibility:hidden;clear:both;content:"";} ul.de_pg_tab:after{display:block;visibility:hidden;clear:both;content:"";}
ul.de_pg_tab li{position:relative;display:inline-block;float:left;text-align:center;margin:0;padding:0;width:120px} ul.de_pg_tab li{position:relative;display:inline-block;float:left;text-align:center;margin:0;padding:0;min-width:130px}
ul.de_pg_tab li a{margin:0 2px;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:2.5;background-color:#f7f7f7;color:#74777b;font-weight:bold;font-size:1.2em;text-decoration:none} ul.de_pg_tab li a{margin:0 2px;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:2.5;background-color:#f7f7f7;color:#74777b;font-weight:bold;font-size:1.2em;text-decoration:none; padding:0px 10px;}
ul.de_pg_tab li a:hover{text-decoration:none} ul.de_pg_tab li a:hover{text-decoration:none}
ul.de_pg_tab li.tab-current a{background:#2CC185;color:#fff} ul.de_pg_tab li.tab-current a{background:#2CC185;color:#fff}
.pg_info_fld{position:relative} .pg_info_fld{position:relative}
.kcp_info_fld th{background-color:#F6FCFF} .kcp_info_fld th{background-color:#F6FCFF}
.lg_info_fld th{background-color:#FFF4FA} .lg_info_fld th{background-color:#FFF4FA}
.lg_info_fld_v2 th{background-color:#ffe8f5}
.inicis_info_fld th{background-color:#F6F1FF} .inicis_info_fld th{background-color:#F6F1FF}
.kakao_info_fld th{background-color:#FFFCED} .kakao_info_fld th{background-color:#FFFCED}
.naver_info_fld th{background-color:#F3FFF3} .naver_info_fld th{background-color:#F3FFF3}

View File

@ -125,12 +125,15 @@ function pg_setting_check($is_print=false){
$msg = ''; $msg = '';
$pg_msg = ''; $pg_msg = '';
$pg_test_conf_link = G5_ADMIN_URL.'/shop_admin/configform.php#de_card_test1';
if( $default['de_card_test'] ){ if( $default['de_card_test'] ){
if( $default['de_pg_service'] === 'kcp' && $default['de_kcp_mid'] && $default['de_kcp_site_key'] ){ if( $default['de_pg_service'] === 'kcp' && $default['de_kcp_mid'] && $default['de_kcp_site_key'] ){
$pg_msg = 'NHN KCP'; $pg_msg = 'NHN KCP';
} else if ( $default['de_pg_service'] === 'lg' && $config['cf_lg_mid'] && $config['cf_lg_mert_key'] ){ } else if ( $default['de_pg_service'] === 'lg' && $config['cf_lg_mid'] && $config['cf_lg_mert_key'] ){
$pg_msg = 'LG유플러스'; $pg_msg = 'LG유플러스';
} else if ( $default['de_pg_service'] === 'toss' && $config['cf_lg_mid'] && $config['cf_toss_client_key'] && $config['cf_toss_secret_key'] ){
$msg .= '<div class="admin_pg_notice od_test_caution">(주의!) 토스페이먼츠 결제의 결제 설정이 현재 테스트결제로 되어 있습니다.<br>반드시 <a href="#lg_info_anchor">상점 API키</a>를 <u>[테스트]키</u>로 설정한 후 테스트결제를 진행해야합니다.<br>쇼핑몰 운영 시에는 실결제로 전환하여 <u>[라이브]키</u>로 설정해 주시기 바랍니다.<br>아래 링크를 클릭하여 실결제로 설정하여 운영해 주세요.<br><a href="'.$pg_test_conf_link.'" class="pg_test_conf_link">'.$pg_test_conf_link.'</a></div>';
} else if ( $default['de_pg_service'] === 'inicis' && $default['de_inicis_mid'] && $default['de_inicis_sign_key'] ){ } else if ( $default['de_pg_service'] === 'inicis' && $default['de_inicis_mid'] && $default['de_inicis_sign_key'] ){
$pg_msg = 'KG이니시스'; $pg_msg = 'KG이니시스';
} else if ( $default['de_pg_service'] === 'nicepay' && $default['de_nicepay_mid'] && $default['de_nicepay_key'] ){ } else if ( $default['de_pg_service'] === 'nicepay' && $default['de_nicepay_mid'] && $default['de_nicepay_key'] ){
@ -147,7 +150,6 @@ function pg_setting_check($is_print=false){
} }
if( $pg_msg ){ if( $pg_msg ){
$pg_test_conf_link = G5_ADMIN_URL.'/shop_admin/configform.php#de_card_test1';
$msg .= '<div class="admin_pg_notice od_test_caution">(주의!) '.$pg_msg.' 결제의 결제 설정이 현재 테스트결제 로 되어 있습니다.<br>테스트결제시 실제 결제가 되지 않으므로, 쇼핑몰 운영중이면 반드시 실결제로 설정하여 운영하셔야 합니다.<br>아래 링크를 클릭하여 실결제로 설정하여 운영해 주세요.<br><a href="'.$pg_test_conf_link.'" class="pg_test_conf_link">'.$pg_test_conf_link.'</a></div>'; $msg .= '<div class="admin_pg_notice od_test_caution">(주의!) '.$pg_msg.' 결제의 결제 설정이 현재 테스트결제 로 되어 있습니다.<br>테스트결제시 실제 결제가 되지 않으므로, 쇼핑몰 운영중이면 반드시 실결제로 설정하여 운영하셔야 합니다.<br>아래 링크를 클릭하여 실결제로 설정하여 운영해 주세요.<br><a href="'.$pg_test_conf_link.'" class="pg_test_conf_link">'.$pg_test_conf_link.'</a></div>';
} }
@ -170,6 +172,10 @@ function is_cancel_shop_pg_order($od){
$is_od_pg_cancel = true; $is_od_pg_cancel = true;
} }
if($od['od_pg'] === 'toss' && in_array($od['od_settle_case'], array('계좌이체', '휴대폰'))) {
$is_od_pg_cancel = true;
}
return $is_od_pg_cancel; return $is_od_pg_cancel;
} }

View File

@ -215,6 +215,14 @@ if (! isset($default['de_nicepay_mid'])) {
sql_query($sql, false); sql_query($sql, false);
} }
// 토스페이먼츠 client, secret key 추가
if( ! isset($config['cf_toss_client_key']) ){
$sql = "ALTER TABLE `{$g5['config_table']}`
ADD COLUMN `cf_toss_client_key` VARCHAR(100) NOT NULL DEFAULT '' AFTER `cf_lg_mert_key`,
ADD COLUMN `cf_toss_secret_key` VARCHAR(100) NOT NULL DEFAULT '' AFTER `cf_toss_client_key`; ";
sql_query($sql, false);
}
if( function_exists('pg_setting_check') ){ if( function_exists('pg_setting_check') ){
pg_setting_check(true); pg_setting_check(true);
} }
@ -636,17 +644,23 @@ if(!$default['de_kakaopay_cancelpwd']){
<?php echo G5_SHOP_URL; ?>/settle_kcp_common.php</td> <?php echo G5_SHOP_URL; ?>/settle_kcp_common.php</td>
</tr> </tr>
<tr id="inicis_vbank_url" class="pg_vbank_url"> <tr id="inicis_vbank_url" class="pg_vbank_url">
<th scope="row">KG이니시스 가상계좌 입금통보 URL</th> <th scope="row">KG이니시스 가상계좌<br>입금통보 URL</th>
<td> <td>
<?php echo help("KG이니시스 가상계좌 사용시 다음 주소를 <strong><a href=\"https://iniweb.inicis.com/\" target=\"_blank\">KG이니시스 관리자</a> &gt; 거래내역 &gt; 가상계좌 &gt; 입금통보방식선택 &gt; URL 수신 설정</strong>에 넣으셔야 상점에 자동으로 입금 통보됩니다."); ?> <?php echo help("KG이니시스 가상계좌 사용시 다음 주소를 <strong><a href=\"https://iniweb.inicis.com/\" target=\"_blank\">KG이니시스 관리자</a> &gt; 거래내역 &gt; 가상계좌 &gt; 입금통보방식선택 &gt; URL 수신 설정</strong>에 넣으셔야 상점에 자동으로 입금 통보됩니다."); ?>
<?php echo G5_SHOP_URL; ?>/settle_inicis_common.php</td> <?php echo G5_SHOP_URL; ?>/settle_inicis_common.php</td>
</tr> </tr>
<tr id="nicepay_vbank_url" class="pg_vbank_url"> <tr id="nicepay_vbank_url" class="pg_vbank_url">
<th scope="row">NICEPAY 가상계좌 입금통보 URL</th> <th scope="row">NICEPAY 가상계좌<br>입금통보 URL</th>
<td> <td>
<?php echo help("NICEPAY 가상계좌 사용시 다음 주소를 <strong><a href=\"https://npg.nicepay.co.kr/\" target=\"_blank\">NICEPAY 관리자</a> &gt; 가맹점관리자페이지 설정 (메인화면 → 가맹점정보 클릭)</strong>에 넣으셔야 상점에 자동으로 입금 통보됩니다."); ?> <?php echo help("NICEPAY 가상계좌 사용시 다음 주소를 <strong><a href=\"https://npg.nicepay.co.kr/\" target=\"_blank\">NICEPAY 관리자</a> &gt; 가맹점관리자페이지 설정 (메인화면 → 가맹점정보 클릭)</strong>에 넣으셔야 상점에 자동으로 입금 통보됩니다."); ?>
<?php echo G5_SHOP_URL; ?>/settle_nicepay_common.php</td> <?php echo G5_SHOP_URL; ?>/settle_nicepay_common.php</td>
</tr> </tr>
<tr id="toss_vbank_url" class="pg_vbank_url">
<th scope="row">토스페이먼츠 가상계좌<br>입금통보 URL</th>
<td>
<?php echo help("토스페이먼츠 가상계좌 사용시 다음 주소를 <strong><a href=\"https://app.tosspayments.com/\" target=\"_blank\">토스페이먼츠 상점관리자</a> &gt; 개발자센터 &gt; 웹훅 &gt; 웹훅 등록하기에 URL</strong>에 넣으시고, <strong>구독할 이벤트를 [DEPOSIT_CALLBACK]</strong>을 선택하셔야 상점에 자동으로 입금 통보됩니다."); ?>
<?php echo G5_SHOP_URL; ?>/settle_toss_common.php</td>
</tr>
<tr> <tr>
<th scope="row"><label for="de_hp_use">휴대폰결제사용</label></th> <th scope="row"><label for="de_hp_use">휴대폰결제사용</label></th>
<td> <td>
@ -687,6 +701,7 @@ if(!$default['de_kakaopay_cancelpwd']){
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row"><label for="de_taxsave_use">현금영수증<br>발급사용</label></th> <th scope="row"><label for="de_taxsave_use">현금영수증<br>발급사용</label></th>
<td> <td>
@ -775,7 +790,8 @@ if(!$default['de_kakaopay_cancelpwd']){
<?php echo help('쇼핑몰에서 사용할 결제대행사를 선택합니다.'); ?> <?php echo help('쇼핑몰에서 사용할 결제대행사를 선택합니다.'); ?>
<ul class="de_pg_tab"> <ul class="de_pg_tab">
<li class="<?php if($default['de_pg_service'] == 'kcp') echo 'tab-current'; ?>"><a href="#kcp_info_anchor" data-value="kcp" title="NHN KCP 선택하기" >NHN KCP</a></li> <li class="<?php if($default['de_pg_service'] == 'kcp') echo 'tab-current'; ?>"><a href="#kcp_info_anchor" data-value="kcp" title="NHN KCP 선택하기" >NHN KCP</a></li>
<li class="<?php if($default['de_pg_service'] == 'lg') echo 'tab-current'; ?>"><a href="#lg_info_anchor" data-value="lg" title="토스페이먼츠 선택하기">토스페이먼츠</a></li> <li class="<?php if($default['de_pg_service'] == 'lg') echo 'tab-current'; ?>"><a href="#lg_info_anchor" data-value="lg" title="토스페이먼츠(구버전) 선택하기">토스페이먼츠(구버전)</a></li>
<li class="<?php if($default['de_pg_service'] == 'toss') echo 'tab-current'; ?>"><a href="#lg_info_anchor" data-value="toss" title="토스페이먼츠 선택하기">토스페이먼츠</a></li>
<li class="<?php if($default['de_pg_service'] == 'inicis') echo 'tab-current'; ?>"><a href="#inicis_info_anchor" data-value="inicis" title="KG이니시스 선택하기">KG이니시스</a></li> <li class="<?php if($default['de_pg_service'] == 'inicis') echo 'tab-current'; ?>"><a href="#inicis_info_anchor" data-value="inicis" title="KG이니시스 선택하기">KG이니시스</a></li>
<li class="<?php if($default['de_pg_service'] == 'nicepay') echo 'tab-current'; ?>"><a href="#nicepay_info_anchor" data-value="nicepay" title="NICEPAY 선택하기">NICEPAY</a></li> <li class="<?php if($default['de_pg_service'] == 'nicepay') echo 'tab-current'; ?>"><a href="#nicepay_info_anchor" data-value="nicepay" title="NICEPAY 선택하기">NICEPAY</a></li>
</ul> </ul>
@ -833,12 +849,26 @@ if(!$default['de_kakaopay_cancelpwd']){
</td> </td>
</tr> </tr>
<tr class="pg_info_fld lg_info_fld"> <tr class="pg_info_fld lg_info_fld">
<th scope="row"><label for="cf_lg_mert_key">토스페이먼츠 MERT KEY</label></th> <th scope="row"><label for="cf_lg_mert_key">토스페이먼츠(구버전) MERT KEY</label></th>
<td> <td>
<?php echo help("토스페이먼츠 상점MertKey는 상점관리자 -> 개발자센터 -> API키 -> 머트 키에서 확인하실 수 있습니다.\n예) 95160cce09854ef44d2edb2bfb05f9f3"); ?> <?php echo help("토스페이먼츠(구버전) 상점 MertKey는 상점관리자 -> 개발자센터 -> API키 -> 머트 키에서 확인하실 수 있습니다.\n예) 95160cce09854ef44d2edb2bfb05f9f3"); ?>
<input type="text" name="cf_lg_mert_key" value="<?php echo get_sanitize_input($config['cf_lg_mert_key']); ?>" id="cf_lg_mert_key" class="frm_input " size="36" maxlength="50"> <input type="text" name="cf_lg_mert_key" value="<?php echo get_sanitize_input($config['cf_lg_mert_key']); ?>" id="cf_lg_mert_key" class="frm_input " size="36" maxlength="50">
</td> </td>
</tr> </tr>
<tr class="pg_info_fld lg_info_fld_v2">
<th scope="row"><label for="cf_toss_client_key">토스페이먼츠 API Client Key</label></th>
<td>
<?php echo help("토스페이먼츠 API 클라이언트 키는 상점관리자 -> 개발자센터 -> API키 -> 클라이언트 키에서 확인하실 수 있습니다. 예) live_ck_tosspayment\n실결제용 [라이브] 키와 테스트용 [테스트] 키는 서로 다르므로, <b>테스트로 결제시에는 [테스트] 키</b>로 변경하여 사용해주시기 바랍니다. 예) 테스트 키: test_ck_tosspayment"); ?>
<input type="text" name="cf_toss_client_key" value="<?php echo get_sanitize_input($config['cf_toss_client_key']); ?>" id="cf_toss_client_key" class="frm_input " size="40" maxlength="50">
</td>
</tr>
<tr class="pg_info_fld lg_info_fld_v2">
<th scope="row"><label for="cf_toss_secret_key">토스페이먼츠 API Secret Key</label></th>
<td>
<?php echo help("토스페이먼츠 API 시크릿 키는 상점관리자 -> 개발자센터 -> API키 -> 시크릿 키에서 확인하실 수 있습니다. 예) live_sk_tosspayment\n실결제용 [라이브] 키와 테스트용 [테스트] 키는 서로 다르므로, <b>테스트로 결제시에는 [테스트] 키</b>로 변경하여 사용해주시기 바랍니다. 예) 테스트 키: test_sk_tosspayment"); ?>
<input type="text" name="cf_toss_secret_key" value="<?php echo get_sanitize_input($config['cf_toss_secret_key']); ?>" id="cf_toss_secret_key" class="frm_input " size="40" maxlength="50">
</td>
</tr>
<tr class="pg_info_fld inicis_info_fld" id="inicis_info_anchor"> <tr class="pg_info_fld inicis_info_fld" id="inicis_info_anchor">
<th scope="row"> <th scope="row">
<label for="de_inicis_mid">KG이니시스 상점아이디</label><br> <label for="de_inicis_mid">KG이니시스 상점아이디</label><br>
@ -1070,6 +1100,9 @@ if(!$default['de_kakaopay_cancelpwd']){
<a href="https://app.tosspayments.com/" target="_blank" class="btn_frmline">실결제 관리자</a> <a href="https://app.tosspayments.com/" target="_blank" class="btn_frmline">실결제 관리자</a>
<a href="https://pgweb.tosspayments.com/tmert" target="_blank" class="btn_frmline">테스트 관리자</a> <a href="https://pgweb.tosspayments.com/tmert" target="_blank" class="btn_frmline">테스트 관리자</a>
</div> </div>
<div class="scf_cardtest toss_cardtest">
<a href="https://app.tosspayments.com/" target="_blank" class="btn_frmline">상점 관리자</a>
</div>
<div class="scf_cardtest inicis_cardtest"> <div class="scf_cardtest inicis_cardtest">
<a href="https://iniweb.inicis.com/" target="_blank" class="btn_frmline">상점 관리자</a> <a href="https://iniweb.inicis.com/" target="_blank" class="btn_frmline">상점 관리자</a>
</div> </div>
@ -1095,6 +1128,9 @@ if(!$default['de_kakaopay_cancelpwd']){
<ul id="lg_cardtest_tip" class="scf_cardtest_tip_adm scf_cardtest_tip_adm_hide"> <ul id="lg_cardtest_tip" class="scf_cardtest_tip_adm scf_cardtest_tip_adm_hide">
<li>테스트결제의 <a href="https://pgweb.tosspayments.com/tmert" target="_blank">상점관리자</a> 로그인 정보는 토스페이먼츠 상점아이디 첫 글자에 t를 추가해서 로그인하시기 바랍니다. 예) tsi_lguplus</li> <li>테스트결제의 <a href="https://pgweb.tosspayments.com/tmert" target="_blank">상점관리자</a> 로그인 정보는 토스페이먼츠 상점아이디 첫 글자에 t를 추가해서 로그인하시기 바랍니다. 예) tsi_lguplus</li>
</ul> </ul>
<ul id="toss_cardtest_tip" class="scf_cardtest_tip_adm scf_cardtest_tip_adm_hide">
<li>테스트 결제 시 <a href="https://app.tosspayments.com/" target="_blank">상점관리자</a> 로그인 정보는 실결제용 키와는 다르니 반드시 <b>[테스트] API 연동 키</b>로 로그인해야 합니다. 예) test_ck_toss</li>
</ul>
<ul id="inicis_cardtest_tip" class="scf_cardtest_tip_adm scf_cardtest_tip_adm_hide"> <ul id="inicis_cardtest_tip" class="scf_cardtest_tip_adm scf_cardtest_tip_adm_hide">
<li><b>일반결제</b>의 테스트 사이트 mid는 <b>INIpayTest</b> 이며, <b>에스크로 결제</b>의 테스트 사이트 mid는 <b>iniescrow0</b> 입니다.</li> <li><b>일반결제</b>의 테스트 사이트 mid는 <b>INIpayTest</b> 이며, <b>에스크로 결제</b>의 테스트 사이트 mid는 <b>iniescrow0</b> 입니다.</li>
</ul> </ul>
@ -1769,7 +1805,11 @@ function fconfig_check(f)
} }
} else if ( f.de_pg_service.value == "lg" ) { } else if ( f.de_pg_service.value == "lg" ) {
if( f.cf_lg_mid.value && f.cf_lg_mert_key.value && parseInt(f.de_card_test.value) > 0 ){ if( f.cf_lg_mid.value && f.cf_lg_mert_key.value && parseInt(f.de_card_test.value) > 0 ){
pg_msg = "토스페이먼츠"; pg_msg = "토스페이먼츠(구버전)";
}
} else if ( f.de_pg_service.value == "toss" ) {
if( f.cf_lg_mid.value && f.cf_toss_client_key.value && f.cf_toss_secret_key.value && parseInt(f.de_card_test.value) > 0 ){
msg += "(주의!) 토스페이먼츠 결제의 결제 설정이 현재 테스트결제로 되어 있습니다.\n상점 API키를 [테스트]키로 설정한 후 테스트결제를 진행해주세요.\n쇼핑몰 운영중이면 반드시 실결제 전환 및 [라이브]키로 설정하여 운영하셔야 합니다.\n실결제로 변경하려면 결제설정 탭 -> 결제 테스트에서 실결제를 선택해 주세요.\n정말로 테스트결제로 설정하시겠습니까?";
} }
} else if ( f.de_pg_service.value == "inicis" ) { } else if ( f.de_pg_service.value == "inicis" ) {
if( f.de_inicis_mid.value && f.de_inicis_sign_key.value && parseInt(f.de_card_test.value) > 0 ){ if( f.de_inicis_mid.value && f.de_inicis_sign_key.value && parseInt(f.de_card_test.value) > 0 ){

View File

@ -159,6 +159,8 @@ $check_sanitize_keys = array(
'de_kcp_site_key', //NHN KCP SITE KEY 'de_kcp_site_key', //NHN KCP SITE KEY
'cf_lg_mid', //LG유플러스 상점아이디 'cf_lg_mid', //LG유플러스 상점아이디
'cf_lg_mert_key', //LG유플러스 MERT KEY 'cf_lg_mert_key', //LG유플러스 MERT KEY
'cf_toss_client_key', //토스페이먼츠 MERT KEY
'cf_toss_secret_key', //토스페이먼츠 MERT KEY
'de_inicis_mid', //KG이니시스 상점아이디 'de_inicis_mid', //KG이니시스 상점아이디
'de_inicis_iniapi_key', //KG이니시스 INIAPI KEY 'de_inicis_iniapi_key', //KG이니시스 INIAPI KEY
'de_inicis_iniapi_iv', //KG이니시스 INIAPI IV 'de_inicis_iniapi_iv', //KG이니시스 INIAPI IV
@ -465,7 +467,9 @@ $sql = " update {$g5['config_table']}
cf_icode_server_port = '{$_POST['cf_icode_server_port']}', cf_icode_server_port = '{$_POST['cf_icode_server_port']}',
cf_icode_token_key = '{$cf_icode_token_key}', cf_icode_token_key = '{$cf_icode_token_key}',
cf_lg_mid = '{$cf_lg_mid}', cf_lg_mid = '{$cf_lg_mid}',
cf_lg_mert_key = '{$cf_lg_mert_key}' "; cf_lg_mert_key = '{$cf_lg_mert_key}',
cf_toss_client_key = '{$cf_toss_client_key}',
cf_toss_secret_key = '{$cf_toss_secret_key}' ";
sql_query($sql); sql_query($sql);
run_event('shop_admin_configformupdate'); run_event('shop_admin_configformupdate');

View File

@ -283,7 +283,7 @@ add_javascript(G5_POSTCODE_JS, 0); //다음 주소 js
<div class="local_desc01 local_desc"> <div class="local_desc01 local_desc">
<p>주문, 입금, 준비, 배송, 완료는 장바구니와 주문서 상태를 모두 변경하지만, 취소, 반품, 품절은 장바구니의 상태만 변경하며, 주문서 상태는 변경하지 않습니다.</p> <p>주문, 입금, 준비, 배송, 완료는 장바구니와 주문서 상태를 모두 변경하지만, 취소, 반품, 품절은 장바구니의 상태만 변경하며, 주문서 상태는 변경하지 않습니다.</p>
<p>개별적인(이곳에서의) 상태 변경은 모든 작업을 수동으로 처리합니다. 예를 들어 주문에서 입금으로 상태 변경시 입금액(결제금액)을 포함한 모든 정보는 수동 입력으로 처리하셔야 합니다.</p> <p>개별적인(이곳에서의) 상태 변경은 모든 작업을 수동으로 처리합니다. 예를 들어 주문에서 입금으로 상태 변경시 입금액(결제금액)을 포함한 모든 정보는 수동 입력으로 처리하셔야 합니다.</p>
<?php if ($config['cf_kakaotalk_use']) { ?> <?php if (isset($config['cf_kakaotalk_use']) && $config['cf_kakaotalk_use']) { ?>
<p>* <b>알림톡 프리셋</b>: <b>[준비, 완료, 취소, 반품, 품절]</b>은 <b>자동</b>으로 발송되며, <b>[입금완료, 배송]</b>은 <b>결제상세정보에서 수동</b>으로 발송하셔야 합니다.</p> <p>* <b>알림톡 프리셋</b>: <b>[준비, 완료, 취소, 반품, 품절]</b>은 <b>자동</b>으로 발송되며, <b>[입금완료, 배송]</b>은 <b>결제상세정보에서 수동</b>으로 발송하셔야 합니다.</p>
<?php } ?> <?php } ?>
</div> </div>
@ -515,7 +515,7 @@ add_javascript(G5_POSTCODE_JS, 0); //다음 주소 js
switch($od['od_pg']) { switch($od['od_pg']) {
case 'lg': case 'lg':
$pg_url = 'https://app.tosspayments.com'; $pg_url = 'https://app.tosspayments.com';
$pg_test = '토스페이먼츠'; $pg_test = '토스페이먼츠(구버전)';
if ($default['de_card_test']) { if ($default['de_card_test']) {
$pg_url = 'https://pgweb.tosspayments.com/tmert'; $pg_url = 'https://pgweb.tosspayments.com/tmert';
$pg_test .= ' 테스트 '; $pg_test .= ' 테스트 ';
@ -533,6 +533,10 @@ add_javascript(G5_POSTCODE_JS, 0); //다음 주소 js
$pg_url = 'https://npg.nicepay.co.kr/'; $pg_url = 'https://npg.nicepay.co.kr/';
$pg_test = 'NICEPAY'; $pg_test = 'NICEPAY';
break; break;
case 'toss':
$pg_url = 'https://app.tosspayments.com';
$pg_test = '토스페이먼츠 ';
break;
default: default:
$pg_url = 'http://admin8.kcp.co.kr'; $pg_url = 'http://admin8.kcp.co.kr';
$pg_test = 'KCP'; $pg_test = 'KCP';
@ -634,6 +638,8 @@ add_javascript(G5_POSTCODE_JS, 0); //다음 주소 js
break; break;
} }
$cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');';
} else if($od['od_pg'] == 'toss') {
$cash_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/mids/si_'.$config['cf_lg_mid'].'/orders/'.$od['od_id'].'/cash-receipt?ref=dashboard\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') { } else if($od['od_pg'] == 'inicis') {
$cash = unserialize($od['od_cash_info']); $cash = unserialize($od['od_cash_info']);
$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';
@ -844,7 +850,7 @@ add_javascript(G5_POSTCODE_JS, 0); //다음 주소 js
<!-- 배송 알림톡 전송 --> <!-- 배송 알림톡 전송 -->
<?php <?php
$alimtalk = get_alimtalk_preset_info('CU-DE02'); $alimtalk = get_alimtalk_preset_info('CU-DE02');
if ($config['cf_kakaotalk_use'] && isset($alimtalk['success'])) { if (isset($config['cf_kakaotalk_use']) && $config['cf_kakaotalk_use'] && isset($alimtalk['success'])) {
?> ?>
<input type="checkbox" name="od_alimtalk_baesong_check" id="od_alimtalk_baesong_check"> <input type="checkbox" name="od_alimtalk_baesong_check" id="od_alimtalk_baesong_check">
<label for="od_alimtalk_baesong_check">배송 알림톡전송</label> <label for="od_alimtalk_baesong_check">배송 알림톡전송</label>

View File

@ -224,6 +224,10 @@ if (in_array($_POST['ct_status'], $status_cancel)) {
$pg_res_msg = $xpay->Response_Msg(); $pg_res_msg = $xpay->Response_Msg();
} }
break; break;
case 'toss':
$cancel_msg = '쇼핑몰 운영자 승인 취소';
include_once(G5_SHOP_PATH.'/toss/toss_cancel.php');
break;
case 'inicis': case 'inicis':
include_once(G5_SHOP_PATH.'/settle_inicis.inc.php'); include_once(G5_SHOP_PATH.'/settle_inicis.inc.php');
$cancel_msg = '쇼핑몰 운영자 승인 취소'; $cancel_msg = '쇼핑몰 운영자 승인 취소';

View File

@ -210,6 +210,8 @@ if(!sql_query(" select pp_cash from {$g5['g5_shop_personalpay_table']} limit 1 "
break; break;
} }
$cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$pp['pp_id'].'\',\''.$pp['pp_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$pp['pp_id'].'\',\''.$pp['pp_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');';
} else if($pp['pp_pg'] == 'toss') {
$cash_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/mids/si_'.$config['cf_lg_mid'].'/orders/'.$pp['pp_id'].'/cash-receipt?ref=dashboard\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'inicis') { } else if($pp['pp_pg'] == 'inicis') {
$cash = unserialize($pp['pp_cash_info']); $cash = unserialize($pp['pp_cash_info']);
$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';

View File

@ -300,6 +300,8 @@ CREATE TABLE IF NOT EXISTS `g5_config` (
`cf_cert_kcp_enckey` varchar(100) NOT NULL DEFAULT '', `cf_cert_kcp_enckey` varchar(100) NOT NULL DEFAULT '',
`cf_lg_mid` varchar(100) NOT NULL DEFAULT '', `cf_lg_mid` varchar(100) NOT NULL DEFAULT '',
`cf_lg_mert_key` varchar(100) NOT NULL DEFAULT '', `cf_lg_mert_key` varchar(100) NOT NULL DEFAULT '',
`cf_toss_client_key` varchar(100) NOT NULL DEFAULT '',
`cf_toss_secret_key` varchar(100) NOT NULL DEFAULT '',
`cf_cert_limit` int(11) NOT NULL DEFAULT '0', `cf_cert_limit` int(11) NOT NULL DEFAULT '0',
`cf_cert_req` tinyint(4) NOT NULL DEFAULT '0', `cf_cert_req` tinyint(4) NOT NULL DEFAULT '0',
`cf_sms_use` varchar(255) NOT NULL DEFAULT '', `cf_sms_use` varchar(255) NOT NULL DEFAULT '',

View File

@ -62,6 +62,9 @@ ob_start();
$comm_free_mny = 0; // 면세금액 $comm_free_mny = 0; // 면세금액
$tot_tax_mny = 0; $tot_tax_mny = 0;
// 토스페이먼츠 escrowProducts 배열 생성
$escrow_products = array();
for ($i=0; $row=sql_fetch_array($result); $i++) for ($i=0; $row=sql_fetch_array($result); $i++)
{ {
// 합계금액 계산 // 합계금액 계산
@ -114,6 +117,15 @@ ob_start();
$point = $sum['point']; $point = $sum['point'];
$sell_price = $sum['price']; $sell_price = $sum['price'];
// 토스페이먼츠 escrowProducts 배열에 상품 정보 추가
$escrow_products[] = array(
'id' => $row['ct_id'],
'name' => $row['it_name'],
'code' => $row['it_id'],
'unitPrice' => (int) $row['ct_price'],
'quantity' => (int) $row['ct_qty']
);
$cp_button = ''; $cp_button = '';
// 쿠폰 // 쿠폰
@ -577,7 +589,7 @@ if($is_kakaopay_use) {
// 계좌이체 사용 // 계좌이체 사용
if ($default['de_iche_use']) { if ($default['de_iche_use']) {
$multi_settle++; $multi_settle++;
echo '<li><input type="radio" id="od_settle_iche" name="od_settle_case" value="계좌이체" '.$checked.'> <label for="od_settle_iche" class="lb_icon iche_icon">'.$escrow_title.'계좌이체</label></li>'.PHP_EOL; echo '<li><input type="radio" id="od_settle_iche" name="od_settle_case" value="계좌이체" '.$checked.'> <label for="od_settle_iche" class="lb_icon iche_icon">'.$escrow_title. ($default['de_pg_service'] == 'toss' ? '퀵계좌이체' :'계좌이체') . '</label></li>'.PHP_EOL;
$checked = ''; $checked = '';
} }
@ -1412,6 +1424,55 @@ function pay_approval()
<?php if($default['de_tax_flag_use']) { ?> <?php if($default['de_tax_flag_use']) { ?>
f.LGD_TAXFREEAMOUNT.value = pf.comm_free_mny.value; f.LGD_TAXFREEAMOUNT.value = pf.comm_free_mny.value;
<?php } ?> <?php } ?>
<?php } else if($default['de_pg_service'] == 'toss') { ?>
var pay_method = "";
switch(settle_method) {
case "계좌이체":
pay_method = "TRANSFER";
break;
case "가상계좌":
pay_method = "VIRTUAL_ACCOUNT";
break;
case "휴대폰":
pay_method = "MOBILE_PHONE";
break;
case "신용카드":
pay_method = "CARD";
break;
case "간편결제":
pay_method = "CARD";
break;
}
f.method.value = pay_method;
f.orderId.value = '<?=$od_id?>';
f.orderName.value = '<?=$goods?>';
f.customerName.value = pf.od_name.value;
f.customerEmail.value = pf.od_email.value;
f.customerMobilePhone.value = pf.od_hp.value.replace(/[^0-9]/g, '');
if (f.customerMobilePhone.value == '') {
f.customerMobilePhone.value = pf.od_tel.value.replace(/[^0-9]/g, '');
}
f.cardUseCardPoint.value = false;
f.cardUseAppCardOnly.value = false;
<?php if($default['de_escrow_use']) { ?>
f.cardUseEscrow.value = 'true';
f.escrowProducts.value = JSON.stringify(<?php echo json_encode($escrow_products, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>);
<?php } ?>
if(settle_method == "간편결제") {
f.cardflowMode.value = 'DIRECT';
}
f.amountCurrency.value = 'KRW';
f.amountValue.value = f.good_mny.value;
<?php if($default['de_tax_flag_use']) { ?>
f.taxFreeAmount.value = pf.comm_free_mny.value;
<?php } ?>
f.windowTarget.value = 'self';
<?php } else if($default['de_pg_service'] == 'inicis') { ?> <?php } else if($default['de_pg_service'] == 'inicis') { ?>
var paymethod = ""; var paymethod = "";
var width = 330; var width = 330;

View File

@ -8,6 +8,7 @@ $post_enc_data = isset($_POST['enc_data']) ? $_POST['enc_data'] : '';
$post_enc_info = isset($_POST['enc_info']) ? $_POST['enc_info'] : ''; $post_enc_info = isset($_POST['enc_info']) ? $_POST['enc_info'] : '';
$post_tran_cd = isset($_POST['tran_cd']) ? $_POST['tran_cd'] : ''; $post_tran_cd = isset($_POST['tran_cd']) ? $_POST['tran_cd'] : '';
$post_lgd_paykey = isset($_POST['LGD_PAYKEY']) ? $_POST['LGD_PAYKEY'] : ''; $post_lgd_paykey = isset($_POST['LGD_PAYKEY']) ? $_POST['LGD_PAYKEY'] : '';
$paymentKey = isset($_POST['paymentKey']) ? $_POST['paymentKey'] : '';
//삼성페이 또는 lpay 또는 이니시스 카카오페이 요청으로 왔다면 현재 삼성페이 또는 lpay 또는 이니시스 카카오페이는 이니시스 밖에 없으므로 $default['de_pg_service'] 값을 이니시스로 변경한다. //삼성페이 또는 lpay 또는 이니시스 카카오페이 요청으로 왔다면 현재 삼성페이 또는 lpay 또는 이니시스 카카오페이는 이니시스 밖에 없으므로 $default['de_pg_service'] 값을 이니시스로 변경한다.
if( is_inicis_order_pay($od_settle_case) && !empty($_POST['P_HASH']) ){ if( is_inicis_order_pay($od_settle_case) && !empty($_POST['P_HASH']) ){
@ -42,6 +43,9 @@ if($od_settle_case != '무통장' && $od_settle_case != 'KAKAOPAY') {
if($default['de_pg_service'] == 'lg' && ! $post_lgd_paykey) if($default['de_pg_service'] == 'lg' && ! $post_lgd_paykey)
alert('결제등록 요청 후 주문해 주십시오.', $page_return_url); alert('결제등록 요청 후 주문해 주십시오.', $page_return_url);
if($default['de_pg_service'] == 'toss' && ! $paymentKey)
alert('결제등록 요청 후 주문해 주십시오.', $page_return_url);
if($default['de_pg_service'] == 'inicis' && ! $post_p_hash) if($default['de_pg_service'] == 'inicis' && ! $post_p_hash)
alert('결제등록 요청 후 주문해 주십시오.', $page_return_url); alert('결제등록 요청 후 주문해 주십시오.', $page_return_url);
} }
@ -358,6 +362,9 @@ else if ($od_settle_case == "계좌이체")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_MSHOP_PATH.'/inicis/pay_result.php'; include G5_MSHOP_PATH.'/inicis/pay_result.php';
break; break;
@ -387,6 +394,9 @@ else if ($od_settle_case == "가상계좌")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_MSHOP_PATH.'/inicis/pay_result.php'; include G5_MSHOP_PATH.'/inicis/pay_result.php';
break; break;
@ -416,6 +426,9 @@ else if ($od_settle_case == "휴대폰")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_MSHOP_PATH.'/inicis/pay_result.php'; include G5_MSHOP_PATH.'/inicis/pay_result.php';
break; break;
@ -443,6 +456,9 @@ else if ($od_settle_case == "신용카드")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_MSHOP_PATH.'/inicis/pay_result.php'; include G5_MSHOP_PATH.'/inicis/pay_result.php';
break; break;
@ -472,6 +488,9 @@ else if ($od_settle_case == "간편결제")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_MSHOP_PATH.'/inicis/pay_result.php'; include G5_MSHOP_PATH.'/inicis/pay_result.php';
break; break;
@ -543,6 +562,9 @@ if($tno) {
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_cancel.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;
@ -699,6 +721,9 @@ if(! $result || ! (isset($exists_order['od_id']) && $od_id && $exists_order['od_
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_cancel.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;
@ -761,6 +786,9 @@ if(!$result) {
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_cancel.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;

View File

@ -338,6 +338,8 @@ if($od['od_pg'] == 'lg') {
$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);
$hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; $hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
} else if($od['od_pg'] == 'toss') {
$hp_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/phone?transactionId='.$od['od_tno'].'&ref=PX\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') { } else if($od['od_pg'] == 'inicis') {
$hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'nicepay') { } else if($od['od_pg'] == 'nicepay') {
@ -359,6 +361,8 @@ if($od['od_pg'] == 'lg') {
$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);
$card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; $card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
} else if($od['od_pg'] == 'toss') {
$card_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/redirection?transactionId='.$od['od_tno'].'&ref=PX\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'nicepay') { } else if($od['od_pg'] == 'nicepay') {
$card_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=0&TID='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $card_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=0&TID='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') { } else if($od['od_pg'] == 'inicis') {
@ -432,6 +436,8 @@ if($od['od_pg'] == 'lg') {
break; break;
} }
$cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');';
} else if($od['od_pg'] == 'toss') {
$cash_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/mids/si_'.$config['cf_lg_mid'].'/orders/'.$od['od_id'].'/cash-receipt?ref=dashboard\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') { } else if($od['od_pg'] == 'inicis') {
$cash = unserialize($od['od_cash_info']); $cash = unserialize($od['od_cash_info']);
$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';

View File

@ -53,8 +53,18 @@ $tablet_size = "1.0"; // 화면 사이즈 조정 - 기기화면에 맞게 수정
$checked = ''; $checked = '';
$escrow_title = ""; $escrow_title = "";
$escrow_products = array(); // 토스페이먼츠 escrowProducts 배열 생성
if ($default['de_escrow_use']) { if ($default['de_escrow_use']) {
$escrow_title = "에스크로 "; $escrow_title = "에스크로 ";
// 토스페이먼츠 escrowProducts 배열에 상품 정보 추가
$escrow_products[] = array(
'id' => $pp['pp_id'],
'name' => $pp['pp_name'].'님 개인결제',
'code' => $pp['pp_id'],
'unitPrice' => (int) $pp['pp_price'],
'quantity' => (int) 1
);
} }
if ($default['de_vbank_use'] || $default['de_iche_use'] || $default['de_card_use'] || $default['de_hp_use']) { if ($default['de_vbank_use'] || $default['de_iche_use'] || $default['de_card_use'] || $default['de_hp_use']) {
@ -73,7 +83,7 @@ $tablet_size = "1.0"; // 화면 사이즈 조정 - 기기화면에 맞게 수정
// 계좌이체 사용 // 계좌이체 사용
if ($default['de_iche_use']) { if ($default['de_iche_use']) {
$multi_settle++; $multi_settle++;
echo '<li><input type="radio" id="pp_settle_iche" name="pp_settle_case" value="계좌이체" '.$checked.'> <label for="pp_settle_iche"><span></span>'.$escrow_title.'계좌이체</label></li>'.PHP_EOL; echo '<li><input type="radio" id="pp_settle_iche" name="pp_settle_case" value="계좌이체" '.$checked.'> <label for="pp_settle_iche"><span></span>'.$escrow_title. ($default['de_pg_service'] == 'toss' ? '퀵계좌이체' :'계좌이체') . '</label></li>'.PHP_EOL;
$checked = ''; $checked = '';
} }
@ -174,6 +184,51 @@ function pay_approval()
<?php if($default['de_tax_flag_use']) { ?> <?php if($default['de_tax_flag_use']) { ?>
f.LGD_TAXFREEAMOUNT.value = pf.comm_free_mny.value; f.LGD_TAXFREEAMOUNT.value = pf.comm_free_mny.value;
<?php } ?> <?php } ?>
<?php } else if($default['de_pg_service'] == 'toss') { ?>
var pay_method = "";
switch(settle_method) {
case "계좌이체":
pay_method = "TRANSFER";
break;
case "가상계좌":
pay_method = "VIRTUAL_ACCOUNT";
break;
case "휴대폰":
pay_method = "MOBILE_PHONE";
break;
case "신용카드":
pay_method = "CARD";
break;
case "간편결제":
pay_method = "CARD";
break;
}
f.method.value = pay_method;
f.orderId.value = '<?=$od_id?>';
f.orderName.value = '<?=$goods?>';
f.customerName.value = pf.pp_name.value;
f.customerEmail.value = pf.pp_email.value;
f.customerMobilePhone.value = pf.pp_hp.value.replace(/[^0-9]/g, '');
f.cardUseCardPoint.value = false;
f.cardUseAppCardOnly.value = false;
<?php if($default['de_escrow_use']) { ?>
f.cardUseEscrow.value = 'true';
f.escrowProducts.value = JSON.stringify(<?php echo json_encode($escrow_products, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>);
<?php } ?>
if(settle_method == "간편결제") {
f.cardflowMode.value = 'DIRECT';
}
f.amountCurrency.value = 'KRW';
f.amountValue.value = f.good_mny.value;
<?php if($default['de_tax_flag_use']) { ?>
f.taxFreeAmount.value = pf.comm_free_mny.value;
<?php } ?>
f.windowTarget.value = 'self';
<?php } else if($default['de_pg_service'] == 'inicis') { ?> <?php } else if($default['de_pg_service'] == 'inicis') { ?>
var paymethod = ""; var paymethod = "";
var width = 330; var width = 330;

View File

@ -9,6 +9,7 @@ $post_enc_info = isset($_POST['enc_info']) ? $_POST['enc_info'] : '';
$post_enc_data = isset($_POST['enc_data']) ? $_POST['enc_data'] : ''; $post_enc_data = isset($_POST['enc_data']) ? $_POST['enc_data'] : '';
$post_lgd_paykey = isset($_POST['LGD_PAYKEY']) ? $_POST['LGD_PAYKEY'] : ''; $post_lgd_paykey = isset($_POST['LGD_PAYKEY']) ? $_POST['LGD_PAYKEY'] : '';
$paymentKey = isset($_POST['paymentKey']) ? $_POST['paymentKey'] : '';
$post_p_hash = isset($_POST['P_HASH']) ? $_POST['P_HASH'] : ''; $post_p_hash = isset($_POST['P_HASH']) ? $_POST['P_HASH'] : '';
@ -22,6 +23,9 @@ if($default['de_pg_service'] == 'kcp' && ($post_tran_cd === '' || $post_enc_info
if($default['de_pg_service'] == 'lg' && ! $post_lgd_paykey) if($default['de_pg_service'] == 'lg' && ! $post_lgd_paykey)
alert('결제등록 요청 후 주문해 주십시오.', $page_return_url); alert('결제등록 요청 후 주문해 주십시오.', $page_return_url);
if($default['de_pg_service'] == 'toss' && ! $paymentKey)
alert('결제등록 요청 후 주문해 주십시오.', $page_return_url);
if($default['de_pg_service'] == 'inicis' && ! $post_p_hash) if($default['de_pg_service'] == 'inicis' && ! $post_p_hash)
alert('결제등록 요청 후 주문해 주십시오.', $page_return_url); alert('결제등록 요청 후 주문해 주십시오.', $page_return_url);
@ -32,6 +36,13 @@ $pp = sql_fetch($sql);
if(! (isset($pp['pp_id']) && $pp['pp_id'])) if(! (isset($pp['pp_id']) && $pp['pp_id']))
alert('개인결제 정보가 존재하지 않습니다.', G5_SHOP_URL.'/personalpay.php'); alert('개인결제 정보가 존재하지 않습니다.', G5_SHOP_URL.'/personalpay.php');
// PG사의 가상계좌 또는 계좌이체의 자동 현금영수증 초기배열값
$pg_receipt_infos = array(
'od_cash' => 0,
'od_cash_no' => '',
'od_cash_info' => '',
);
$hash_data = md5($pp_id.$good_mny.$pp['pp_time']); $hash_data = md5($pp_id.$good_mny.$pp['pp_time']);
if($pp['pp_tno']){ if($pp['pp_tno']){
@ -54,6 +65,9 @@ if ($pp_settle_case == "계좌이체")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_MSHOP_PATH.'/inicis/pay_result.php'; include G5_MSHOP_PATH.'/inicis/pay_result.php';
break; break;
@ -79,6 +93,9 @@ else if ($pp_settle_case == "가상계좌")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_MSHOP_PATH.'/inicis/pay_result.php'; include G5_MSHOP_PATH.'/inicis/pay_result.php';
break; break;
@ -105,6 +122,9 @@ else if ($pp_settle_case == "휴대폰")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_MSHOP_PATH.'/inicis/pay_result.php'; include G5_MSHOP_PATH.'/inicis/pay_result.php';
break; break;
@ -128,6 +148,9 @@ else if ($pp_settle_case == "신용카드")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_MSHOP_PATH.'/inicis/pay_result.php'; include G5_MSHOP_PATH.'/inicis/pay_result.php';
break; break;
@ -159,6 +182,9 @@ if((int)$pp['pp_price'] !== (int)$pg_price) {
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;
@ -186,7 +212,10 @@ $sql = " update {$g5['g5_shop_personalpay_table']}
pp_bank_account = '$pp_bank_account', pp_bank_account = '$pp_bank_account',
pp_deposit_name = '$pp_deposit_name', pp_deposit_name = '$pp_deposit_name',
pp_receipt_time = '$pp_receipt_time', pp_receipt_time = '$pp_receipt_time',
pp_receipt_ip = '{$_SERVER['REMOTE_ADDR']}' pp_receipt_ip = '{$_SERVER['REMOTE_ADDR']}',
pp_cash = '{$pg_receipt_infos['od_cash']}',
pp_cash_no = '{$pg_receipt_infos['od_cash_no']}',
pp_cash_info = '{$pg_receipt_infos['od_cash_info']}'
where pp_id = '{$pp['pp_id']}' "; where pp_id = '{$pp['pp_id']}' ";
$result = sql_query($sql, false); $result = sql_query($sql, false);
@ -197,6 +226,9 @@ if(!$result) {
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_cancel.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;
@ -224,6 +256,9 @@ if($pp_receipt_price > 0 && $pp['pp_id'] && $pp['od_id']) {
od_settle_case = '$pp_settle_case', od_settle_case = '$pp_settle_case',
od_deposit_name = '$pp_deposit_name', od_deposit_name = '$pp_deposit_name',
od_bank_account = '$pp_bank_account', od_bank_account = '$pp_bank_account',
od_cash = '{$pg_receipt_infos['od_cash']}',
od_cash_no = '{$pg_receipt_infos['od_cash_no']}',
od_cash_info = '{$pg_receipt_infos['od_cash_info']}',
od_shop_memo = concat(od_shop_memo, \"\\n개인결제 ".$pp['pp_id']." 로 결제완료 - ".$pp_receipt_time."\") od_shop_memo = concat(od_shop_memo, \"\\n개인결제 ".$pp['pp_id']." 로 결제완료 - ".$pp_receipt_time."\")
where od_id = '{$pp['od_id']}' "; where od_id = '{$pp['od_id']}' ";
$result = sql_query($sql, false); $result = sql_query($sql, false);
@ -235,6 +270,9 @@ if($pp_receipt_price > 0 && $pp['pp_id'] && $pp['od_id']) {
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;

View File

@ -145,6 +145,8 @@ if($pp['pp_pg'] == 'lg') {
$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);
$hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; $hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
} else if($pp['pp_pg'] == 'toss') {
$hp_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/phone?transactionId='.$pp['pp_tno'].'&ref=PX\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'inicis') { } else if($pp['pp_pg'] == 'inicis') {
$hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'nicepay') { } else if($pp['pp_pg'] == 'nicepay') {
@ -166,6 +168,8 @@ if($pp['pp_pg'] == 'lg') {
$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);
$card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; $card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
} else if($pp['pp_pg'] == 'toss') {
$card_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/redirection?transactionId='.$pp['pp_tno'].'&ref=PX\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'nicepay') { } else if($pp['pp_pg'] == 'nicepay') {
$card_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=0&TID='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $card_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=0&TID='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'inicis') { } else if($pp['pp_pg'] == 'inicis') {
@ -221,6 +225,8 @@ if($pp['pp_pg'] == 'lg') {
break; break;
} }
$cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$pp['pp_id'].'\',\''.$pp['pp_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$pp['pp_id'].'\',\''.$pp['pp_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');';
} else if($pp['pp_pg'] == 'toss') {
$cash_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/mids/si_'.$config['cf_lg_mid'].'/orders/'.$pp['pp_id'].'/cash-receipt?ref=dashboard\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'inicis') { } else if($pp['pp_pg'] == 'inicis') {
$cash = unserialize($pp['pp_cash_info']); $cash = unserialize($pp['pp_cash_info']);
$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';

View File

@ -0,0 +1,15 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
require_once(G5_SHOP_PATH.'/toss/toss.inc.php');
// var_dump($default['cf_toss_client_key']);
$toss = new TossPayments(
$config['cf_toss_client_key'],
$config['cf_toss_secret_key'],
$config['cf_lg_mid']
);
$toss->setPaymentHeader();
?>

View File

@ -0,0 +1,6 @@
<?php
include_once('../../../common.php');
if (!defined('G5_USE_SHOP') || !G5_USE_SHOP)
die('<p>쇼핑몰 설치 후 이용해 주십시오.</p>');
define('_SHOP_', true);

View File

@ -0,0 +1,33 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<form name="sm_form" method="POST" action="<?php echo G5_MSHOP_URL; ?>/toss/toss_approval.php">
<input type="hidden" name="method" value="">
<input type="hidden" name="orderId" value="<?php echo isset($od_id) ? $od_id : ''; ?>">
<input type="hidden" name="orderName" value="<?php echo isset($goods) ? $goods : ''; ?>">
<input type="hidden" name="customerName" value="<?php echo isset($od_name) ? $od_name : ''; ?>">
<input type="hidden" name="customerEmail" value="<?php echo isset($od_email) ? $od_email : ''; ?>">
<input type="hidden" name="customerMobilePhone" value="<?php echo isset($od_hp) ? $od_hp : ''; ?>">
<input type="hidden" name="cardUseEscrow" value="false">
<input type="hidden" name="escrowProducts" value=''>
<input type="hidden" name="cardflowMode" value="DEFAULT">
<input type="hidden" name="cardeasyPay" value="PAYCO">
<input type="hidden" name="cardUseCardPoint" value="false">
<input type="hidden" name="cardUseAppCardOnly" value="false">
<input type="hidden" name="amountCurrency" value="KRW">
<input type="hidden" name="amountValue" value="<?php echo isset($tot_price) ? $tot_price : 0; ?>">
<input type="hidden" name="taxFreeAmount" value="<?php echo isset($comm_free_mny) ? $comm_free_mny : 0; ?>">
<input type="hidden" name="windowTarget" value="iframe">
<input type="hidden" name="good_mny" value="<?php echo $tot_price; ?>">
<?php
if($default['de_tax_flag_use']) {
?>
<input type="hidden" name="comm_tax_mny" value="<?php echo isset($comm_tax_mny) ? $comm_tax_mny : 0; ?>"> <!-- 과세금액 -->
<input type="hidden" name="comm_vat_mny" value="<?php echo isset($comm_vat_mny) ? $comm_vat_mny : 0; ?>"> <!-- 부가세 -->
<input type="hidden" name="comm_free_mny" value="<?php echo isset($comm_free_mny) ? $comm_free_mny : 0; ?>"> <!-- 비과세 금액 -->
<?php
}
?>
</form>

View File

@ -0,0 +1,37 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<input type="hidden" name="method" value="">
<input type="hidden" name="orderId" value="<?php echo isset($od_id) ? $od_id : ''; ?>">
<input type="hidden" name="orderName" value="<?php echo isset($goods) ? $goods : ''; ?>">
<input type="hidden" name="customerName" value="<?php echo isset($od_name) ? $od_name : ''; ?>">
<input type="hidden" name="customerEmail" value="<?php echo isset($od_email) ? $od_email : ''; ?>">
<input type="hidden" name="customerMobilePhone" value="<?php echo isset($od_hp) ? $od_hp : ''; ?>">
<input type="hidden" name="cardUseEscrow" value="false">
<input type="hidden" name="escrowProducts" value=''>
<input type="hidden" name="cardflowMode" value="DEFAULT">
<input type="hidden" name="cardeasyPay" value="PAYCO">
<input type="hidden" name="cardUseCardPoint" value="false">
<input type="hidden" name="cardUseAppCardOnly" value="false">
<input type="hidden" name="amountCurrency" value="KRW">
<input type="hidden" name="amountValue" value="<?php echo isset($tot_price) ? $tot_price : 0; ?>">
<input type="hidden" name="taxFreeAmount" value="<?php echo isset($comm_free_mny) ? $comm_free_mny : 0; ?>">
<input type="hidden" name="windowTarget" value="iframe">
<input type="hidden" name="good_mny" value="<?php echo $tot_price; ?>">
<?php
if($default['de_tax_flag_use']) {
?>
<input type="hidden" name="comm_tax_mny" value="<?php echo isset($comm_tax_mny) ? $comm_tax_mny : 0; ?>"> <!-- 과세금액 -->
<input type="hidden" name="comm_vat_mny" value="<?php echo isset($comm_vat_mny) ? $comm_vat_mny : 0; ?>"> <!-- 부가세 -->
<input type="hidden" name="comm_free_mny" value="<?php echo isset($comm_free_mny) ? $comm_free_mny : 0; ?>"> <!-- 비과세 금액 -->
<?php
}
?>
<div id="display_pay_button" class="btn_confirm">
<span id="show_req_btn"><input type="button" name="submitChecked" onClick="pay_approval();" value="결제등록요청" class="btn_submit"></span>
<span id="show_pay_btn" style="display:none;"><input type="button" onClick="forderform_check();" value="주문하기" class="btn_submit"></span>
<a href="<?php echo G5_SHOP_URL; ?>" class="btn_cancel">취소</a>
</div>

View File

@ -0,0 +1,3 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>

View File

@ -0,0 +1,77 @@
<?php
include_once('./_common.php');
// 결제 실패 처리인 경우
if (isset($_REQUEST['mode']) && $_REQUEST['mode'] === 'fail') {
$code = isset($_REQUEST['code']) ? trim($_REQUEST['code']) : '';
$message = isset($_REQUEST['message']) ? trim($_REQUEST['message']) : '';
alert('결제에 실패하였습니다.\\n\\n[' . $code . '] ' . $message, G5_SHOP_URL . '/orderform.php');
exit;
}
if(!isset($_SESSION['PAYREQ_MAP'])){
alert('세션이 만료 되었거나 유효하지 않은 요청 입니다.', G5_MSHOP_URL);
}
$payReqMap = $_SESSION['PAYREQ_MAP']; //결제 요청시, Session에 저장했던 파라미터 MAP
$g5['title'] = '토스페이먼츠 결제인증 완료처리';
$g5['body_script'] = ' onload="setTossResult();"';
include_once(G5_PATH.'/head.sub.php');
// 토스페이먼츠 결제인증 성공시 인증키 주문 임시데이터에 업데이트
$paymentKey = isset($_REQUEST['paymentKey']) ? trim($_REQUEST['paymentKey']) : '';
$orderId = isset($_REQUEST['orderId']) ? trim($_REQUEST['orderId']) : '';
$amount = isset($_REQUEST['amount']) ? trim($_REQUEST['amount']) : '';
if (empty($paymentKey) || empty($orderId)) {
alert('결제정보가 올바르지 않습니다.', G5_MSHOP_URL);
exit;
}
$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$orderId' ";
$row = sql_fetch($sql);
$data = isset($row['dt_data']) ? unserialize(base64_decode($row['dt_data'])) : array();
// 주문 임시데이터에 paymentKey 업데이트
$data['paymentKey'] = $paymentKey;
$data_new = base64_encode(serialize($data));
$sql = " update {$g5['g5_shop_order_data_table']} set dt_data = '$data_new' where od_id = '$orderId' limit 1 ";
sql_query($sql);
if(isset($data['pp_id']) && $data['pp_id']) {
$order_action_url = G5_HTTPS_MSHOP_URL.'/personalpayformupdate.php';
} else {
$order_action_url = G5_HTTPS_MSHOP_URL.'/orderformupdate.php';
}
?>
<?php
$exclude = array();
echo '<form name="forderform" method="post" action="'.$order_action_url.'" autocomplete="off">'.PHP_EOL;
echo make_order_field($data, $exclude);
echo '</form>'.PHP_EOL;
?>
<div>
<div id="show_progress">
<span style="display:block; text-align:center;margin-top:120px"><img src="<?php echo G5_MOBILE_URL; ?>/shop/img/loading.gif" alt=""></span>
<span style="display:block; text-align:center;margin-top:10px; font-size:14px">주문완료 중입니다. 잠시만 기다려 주십시오.</span>
</div>
</div>
<script type="text/javascript">
function setTossResult() {
setTimeout( function() {
document.forderform.submit();
}, 300);
}
</script>
<?php
include_once(G5_PATH.'/tail.sub.php');

View File

@ -0,0 +1,192 @@
<?php
include_once('./_common.php');
// 토스페이먼츠 class
require_once(G5_SHOP_PATH.'/toss/toss.inc.php');
// 개인결제 ID와 주문 ID 설정
$ss_order_id = isset($_REQUEST['orderId']) ? $_REQUEST['orderId'] : '';
$ss_personalpay_id = get_session('ss_personalpay_id');
// 장바구니 ID 설정 (바로구매 여부 확인)
$ss_cart_id = get_session('ss_direct') ? get_session('ss_cart_direct') : get_session('ss_cart_id');
// WHERE 조건 추가용 변수
$addQuery = "";
if (!empty($ss_order_id)) {
$addQuery .= " AND od_id = '{$ss_order_id}'";
}
if (isset($member['mb_id']) && $member['mb_id'] !== '') {
$addQuery .= " AND mb_id = '{$member['mb_id']}'";
}
// 개인결제가 아닌 경우 장바구니 ID 조건 추가
if (empty($ss_personalpay_id)) {
if (!empty($ss_cart_id)) {
$addQuery .= " AND cart_id = '{$ss_cart_id}'";
}
}
// 최종 검증 (원래 로직 유지)
if (empty($ss_order_id) || (empty($ss_personalpay_id) && empty($ss_cart_id))) {
alert('주문정보가 올바르지 않습니다.');
exit;
}
// 기존 dt_data 가져오기
$sql = "
SELECT * FROM {$g5['g5_shop_order_data_table']}
WHERE 1=1
{$addQuery}
";
$res = sql_fetch($sql);
$dt_data = [];
if (isset($res['dt_data'])) {
$dt_data = unserialize(base64_decode($res['dt_data']));
}
$payReqMap = $dt_data;
$_SESSION['PAYREQ_MAP'] = $payReqMap;
if(isset($payReqMap['pp_id']) && $payReqMap['pp_id']) {
$page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.$payReqMap['pp_id'];
} else {
$page_return_url = G5_SHOP_URL.'/orderform.php';
if ($_SESSION['ss_direct']) {
$page_return_url .= '?sw_direct=1';
}
}
$g5['title'] = '토스페이먼츠 eCredit서비스 결제';
$g5['body_script'] = ' onload="launchCrossPlatform(frm);"';
include_once(G5_PATH.'/head.sub.php');
?>
<form name="forderform">
<?php
foreach($payReqMap as $key => $value) {
if (isset($_REQUEST[$key]) && $_REQUEST[$key]) {
$value = $_REQUEST[$key];
}
if (is_array($value)) {
$value = implode(',', $value);
}
if ($key === 'escrowProducts') {
$value = str_replace("\\", "", $value);
echo '<input type="hidden" name="'.$key.'" value=\''.$value.'\'>'.PHP_EOL;
} else {
echo '<input type="hidden" name="'.$key.'" value="'.$value.'">'.PHP_EOL;
}
}
?>
</form>
<script language="javascript" src="https://js.tosspayments.com/v2/standard"></script>
<script type="text/javascript">
/*
* 수정불가.
*/
const clientKey = "<?php echo $config['cf_toss_client_key']; ?>";
const customerKey = "<?php echo isset($member['mb_id']) ? $member['mb_id'] : ''; ?>";
const tossPayments = TossPayments(clientKey);
const payment = tossPayments.payment({ customerKey });
const frm = document.forderform;
/*
* 수정불가
*/
async function launchCrossPlatform(frm) {
// 필수 값들 체크
if (!frm.amountValue || !frm.amountValue.value) {
alert('결제 금액이 설정되지 않았습니다.');
return;
}
const amount = parseInt(frm.amountValue.value);
if (isNaN(amount) || amount <= 0) {
alert('올바른 결제 금액을 입력해주세요.');
return;
}
// 기본 결제 옵션
const paymentOptions = {
method: frm.method.value,
amount: {
currency: "KRW",
value: parseInt(frm.amountValue.value),
},
taxFreeAmount: parseInt(frm.taxFreeAmount.value),
orderId: frm.orderId.value, // 고유 주문번호
orderName: frm.orderName.value,
successUrl: "<?php echo G5_MSHOP_URL;?>/toss/returnurl.php", // 결제 요청이 성공하면 리다이렉트되는 URL
failUrl: "<?php echo G5_MSHOP_URL;?>/toss/returnurl.php?mode=fail", // 결제 요청이 실패하면 리다이렉트되는 URL
customerEmail: frm.customerEmail.value,
customerName: frm.customerName.value,
customerMobilePhone: frm.customerMobilePhone.value,
};
// escrowProducts 추가 함수
function addEscrowProducts(paymentMethodOptions) {
if (frm.cardUseEscrow.value === "true") {
if (frm.escrowProducts && frm.escrowProducts.value) {
paymentMethodOptions.escrowProducts = JSON.parse(frm.escrowProducts.value);
}
}
}
// 결제 방법에 따른 추가 옵션
if (frm.method.value == 'CARD') {
// 신용카드
paymentOptions.card = {
flowMode: frm.cardflowMode.value, // 통합결제창 여는 옵션
easyPay: frm.cardeasyPay.value,
useCardPoint: frm.cardUseCardPoint.value == "true" ? true : false,
useAppCardOnly: frm.cardUseAppCardOnly.value == "true" ? true : false,
useEscrow: frm.cardUseEscrow.value == "true" ? true : false,
};
// escrowProducts 추가
addEscrowProducts(paymentOptions.card);
} else if (frm.method.value == 'VIRTUAL_ACCOUNT') {
// 가상계좌
paymentOptions.virtualAccount = {
cashReceipt: {
type: "소득공제",
},
useEscrow: frm.cardUseEscrow.value == "true" ? true : false,
validHours: 168,
};
// escrowProducts 추가
addEscrowProducts(paymentOptions.virtualAccount);
} else if (frm.method.value == 'TRANSFER') {
// 계좌이체
paymentOptions.transfer = {
cashReceipt: {
type: "소득공제",
},
useEscrow: frm.cardUseEscrow.value == "true" ? true : false,
};
// escrowProducts 추가
addEscrowProducts(paymentOptions.transfer);
}
await payment.requestPayment(paymentOptions);
}
/*
* FORM 명만 수정 가능
*/
function getFormObject() {
return document.getElementById("forderform");
}
</script>
<?php
include_once(G5_PATH.'/tail.sub.php');

View File

@ -81,6 +81,9 @@ if($is_kakaopay_use) {
$comm_free_mny = 0; // 면세금액 $comm_free_mny = 0; // 면세금액
$tot_tax_mny = 0; $tot_tax_mny = 0;
// 토스페이먼츠 escrowProducts 배열 생성
$escrow_products = array();
for ($i=0; $row=sql_fetch_array($result); $i++) for ($i=0; $row=sql_fetch_array($result); $i++)
{ {
// 합계금액 계산 // 합계금액 계산
@ -132,6 +135,15 @@ if($is_kakaopay_use) {
$point = $sum['point']; $point = $sum['point'];
$sell_price = $sum['price']; $sell_price = $sum['price'];
// 토스페이먼츠 escrowProducts 배열에 상품 정보 추가
$escrow_products[] = array(
'id' => $row['ct_id'],
'name' => $row['it_name'],
'code' => $row['it_id'],
'unitPrice' => (int) $row['ct_price'],
'quantity' => (int) $row['ct_qty']
);
// 쿠폰 // 쿠폰
$cp_button = ''; $cp_button = '';
if($is_member) { if($is_member) {
@ -596,7 +608,8 @@ if($is_kakaopay_use) {
// 계좌이체 사용 // 계좌이체 사용
if ($default['de_iche_use']) { if ($default['de_iche_use']) {
$multi_settle++; $multi_settle++;
echo '<input type="radio" id="od_settle_iche" name="od_settle_case" value="계좌이체" '.$checked.'> <label for="od_settle_iche" class="lb_icon iche_icon">'.$escrow_title.'계좌이체</label>'.PHP_EOL; // 토스페이먼츠 v2 - 퀵계좌이체 명칭 사용
echo '<input type="radio" id="od_settle_iche" name="od_settle_case" value="계좌이체" '.$checked.'> <label for="od_settle_iche" class="lb_icon iche_icon">'.$escrow_title. ($default['de_pg_service'] == 'toss' ? '퀵계좌이체' :'계좌이체') . '</label>'.PHP_EOL;
$checked = ''; $checked = '';
} }
@ -1541,6 +1554,28 @@ function forderform_check(f)
f.LGD_CUSTOM_FIRSTPAY.value = "무통장"; f.LGD_CUSTOM_FIRSTPAY.value = "무통장";
break; break;
} }
<?php } else if($default['de_pg_service'] == 'toss') { ?>
switch(settle_method)
{
case "계좌이체":
f.method.value = "TRANSFER";
break;
case "가상계좌":
f.method.value = "VIRTUAL_ACCOUNT";
break;
case "휴대폰":
f.method.value = "MOBILE_PHONE";
break;
case "신용카드":
f.method.value = "CARD";
break;
case "간편결제":
f.method.value = "CARD";
break;
default:
f.method.value = "무통장";
break;
}
<?php } else if($default['de_pg_service'] == 'inicis') { ?> <?php } else if($default['de_pg_service'] == 'inicis') { ?>
switch(settle_method) switch(settle_method)
{ {
@ -1676,6 +1711,62 @@ function forderform_check(f)
f.submit(); f.submit();
} }
<?php } ?> <?php } ?>
<?php if($default['de_pg_service'] == 'toss') { ?>
f.orderId.value = '<?=$od_id?>';
f.orderName.value = '<?=$goods?>';
f.customerName.value = f.od_name.value;
f.customerEmail.value = f.od_email.value;
f.customerMobilePhone.value = f.od_hp.value.replace(/[^0-9]/g, '');
if (f.customerMobilePhone.value == '') {
f.customerMobilePhone.value = f.od_tel.value.replace(/[^0-9]/g, '');
}
f.cardUseCardPoint.value = false;
f.cardUseAppCardOnly.value = false;
<?php if($default['de_escrow_use']) { ?>
f.cardUseEscrow.value = 'true';
f.escrowProducts.value = JSON.stringify(<?php echo json_encode($escrow_products, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>);
<?php } ?>
if(settle_method == "간편결제") {
f.cardflowMode.value = 'DIRECT';
}
f.amountCurrency.value = 'KRW';
f.amountValue.value = f.good_mny.value;
<?php if($default['de_tax_flag_use']) { ?>
f.taxFreeAmount.value = f.comm_free_mny.value;
<?php } ?>
f.windowTarget.value = 'iframe';
if(f.method.value != "무통장") {
// 주문정보 임시저장
var order_data = $(f).serialize();
var save_result = "";
$.ajax({
type: "POST",
data: order_data,
url: g5_url+"/shop/ajax.orderdatasave.php",
cache: false,
async: false,
success: function(data) {
save_result = data;
}
});
if(save_result) {
alert(save_result);
return false;
}
launchCrossPlatform(f);
} else {
f.submit();
}
<?php } ?>
<?php if($default['de_pg_service'] == 'inicis') { ?> <?php if($default['de_pg_service'] == 'inicis') { ?>
f.price.value = f.good_mny.value; f.price.value = f.good_mny.value;
<?php if($default['de_tax_flag_use']) { ?> <?php if($default['de_tax_flag_use']) { ?>

View File

@ -20,6 +20,12 @@ if(($od_settle_case != '무통장' && $od_settle_case != 'KAKAOPAY') && $default
alert('결제등록 요청 후 주문해 주십시오.'); alert('결제등록 요청 후 주문해 주십시오.');
} }
// 토스 v2 대응
if(($od_settle_case != '무통장' && $od_settle_case != 'KAKAOPAY') && $default['de_pg_service'] == 'toss' && !$_POST['paymentKey']){
if(function_exists('add_order_post_log')) add_order_post_log('결제등록 요청 후 주문해 주십시오.');
alert('결제등록 요청 후 주문해 주십시오.');
}
// 장바구니가 비어있는가? // 장바구니가 비어있는가?
if (get_session("ss_direct")) if (get_session("ss_direct"))
$tmp_cart_id = get_session('ss_cart_direct'); $tmp_cart_id = get_session('ss_cart_direct');
@ -337,6 +343,9 @@ else if ($od_settle_case == "계좌이체")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; include G5_SHOP_PATH.'/inicis/inistdpay_result.php';
break; break;
@ -367,6 +376,10 @@ else if ($od_settle_case == "가상계좌")
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
$od_receipt_time = '0000-00-00 00:00:00'; $od_receipt_time = '0000-00-00 00:00:00';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
$od_receipt_time = '0000-00-00 00:00:00';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; include G5_SHOP_PATH.'/inicis/inistdpay_result.php';
$od_app_no = $app_no; $od_app_no = $app_no;
@ -395,6 +408,9 @@ else if ($od_settle_case == "휴대폰")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; include G5_SHOP_PATH.'/inicis/inistdpay_result.php';
break; break;
@ -422,6 +438,9 @@ else if ($od_settle_case == "신용카드")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; include G5_SHOP_PATH.'/inicis/inistdpay_result.php';
break; break;
@ -451,6 +470,9 @@ else if ($od_settle_case == "간편결제" || (($od_settle_case == "lpay" || $od
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; include G5_SHOP_PATH.'/inicis/inistdpay_result.php';
break; break;
@ -510,6 +532,9 @@ if($tno) {
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_cancel.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;
@ -653,6 +678,9 @@ if(! $result || ! (isset($exists_order['od_id']) && $od_id && $exists_order['od_
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_cancel.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;
@ -712,6 +740,9 @@ if(!$result) {
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_cancel.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;

View File

@ -65,6 +65,10 @@ if($od['od_tno']) {
alert($msg); alert($msg);
} }
break; break;
case 'toss':
$cancel_msg = '주문자 본인 취소-'.$cancel_memo;
include_once(G5_SHOP_PATH.'/toss/toss_cancel.php');
break;
case 'inicis': case 'inicis':
include_once(G5_SHOP_PATH.'/settle_inicis.inc.php'); include_once(G5_SHOP_PATH.'/settle_inicis.inc.php');
$cancel_msg = '주문자 본인 취소-'.$cancel_memo; $cancel_msg = '주문자 본인 취소-'.$cancel_memo;

View File

@ -334,6 +334,8 @@ if($od['od_pg'] == 'lg') {
$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);
$hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; $hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
} else if($od['od_pg'] == 'toss') {
$hp_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/phone?transactionId='.$od['od_tno'].'&ref=PX\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') { } else if($od['od_pg'] == 'inicis') {
$hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'nicepay') { } else if($od['od_pg'] == 'nicepay') {
@ -355,6 +357,8 @@ if($od['od_pg'] == 'lg') {
$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);
$card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; $card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
} else if($od['od_pg'] == 'toss') {
$card_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/redirection?transactionId='.$od['od_tno'].'&ref=PX\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') { } else if($od['od_pg'] == 'inicis') {
$card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'nicepay') { } else if($od['od_pg'] == 'nicepay') {
@ -429,6 +433,8 @@ if($od['od_pg'] == 'lg') {
break; break;
} }
$cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');';
} else if($od['od_pg'] == 'toss') {
$cash_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/mids/si_'.$config['cf_lg_mid'].'/orders/'.$od['od_id'].'/cash-receipt?ref=dashboard\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') { } else if($od['od_pg'] == 'inicis') {
$cash = unserialize($od['od_cash_info']); $cash = unserialize($od['od_cash_info']);
$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';

View File

@ -62,8 +62,18 @@ require_once(G5_SHOP_PATH.'/'.$default['de_pg_service'].'/orderform.1.php');
$checked = ''; $checked = '';
$escrow_title = ""; $escrow_title = "";
$escrow_products = array(); // 토스페이먼츠 escrowProducts 배열 생성
if ($default['de_escrow_use']) { if ($default['de_escrow_use']) {
$escrow_title = "에스크로<br>"; $escrow_title = "에스크로<br>";
// 토스페이먼츠 escrowProducts 배열에 상품 정보 추가
$escrow_products[] = array(
'id' => $pp['pp_id'],
'name' => $pp['pp_name'].'님 개인결제',
'code' => $pp['pp_id'],
'unitPrice' => (int) $pp['pp_price'],
'quantity' => (int) 1
);
} }
if ($default['de_vbank_use'] || $default['de_iche_use'] || $default['de_card_use'] || $default['de_hp_use']) { if ($default['de_vbank_use'] || $default['de_iche_use'] || $default['de_card_use'] || $default['de_hp_use']) {
@ -89,7 +99,7 @@ require_once(G5_SHOP_PATH.'/'.$default['de_pg_service'].'/orderform.1.php');
// 계좌이체 사용 // 계좌이체 사용
if ($default['de_iche_use']) { if ($default['de_iche_use']) {
$multi_settle++; $multi_settle++;
echo '<input type="radio" id="pp_settle_iche" name="pp_settle_case" value="계좌이체" '.$checked.'> <label for="pp_settle_iche" class="lb_icon"><span></span>'.$escrow_title.'계좌이체</label>'.PHP_EOL; echo '<input type="radio" id="pp_settle_iche" name="pp_settle_case" value="계좌이체" '.$checked.'> <label for="pp_settle_iche" class="lb_icon"><span></span>'.$escrow_title. ($default['de_pg_service'] == 'toss' ? '퀵계좌이체' :'계좌이체') . '</label>'.PHP_EOL;
$checked = ''; $checked = '';
} }
?> ?>
@ -233,6 +243,28 @@ function forderform_check(f)
f.LGD_CUSTOM_FIRSTPAY.value = "무통장"; f.LGD_CUSTOM_FIRSTPAY.value = "무통장";
break; break;
} }
<?php } else if($default['de_pg_service'] == 'toss') { ?>
switch(settle_method)
{
case "계좌이체":
f.method.value = "TRANSFER";
break;
case "가상계좌":
f.method.value = "VIRTUAL_ACCOUNT";
break;
case "휴대폰":
f.method.value = "MOBILE_PHONE";
break;
case "신용카드":
f.method.value = "CARD";
break;
case "간편결제":
f.method.value = "CARD";
break;
default:
f.method.value = "무통장";
break;
}
<?php } else if($default['de_pg_service'] == 'inicis') { ?> <?php } else if($default['de_pg_service'] == 'inicis') { ?>
switch(settle_method) switch(settle_method)
{ {
@ -310,6 +342,59 @@ function forderform_check(f)
f.submit(); f.submit();
} }
<?php } ?> <?php } ?>
<?php if($default['de_pg_service'] == 'toss') { ?>
f.orderId.value = '<?=$od_id?>';
f.orderName.value = '<?=$goods?>';
f.customerName.value = f.pp_name.value;
f.customerEmail.value = f.pp_email.value;
f.customerMobilePhone.value = f.pp_hp.value.replace(/[^0-9]/g, '');
f.cardUseCardPoint.value = false;
f.cardUseAppCardOnly.value = false;
<?php if($default['de_escrow_use']) { ?>
f.cardUseEscrow.value = 'true';
f.escrowProducts.value = JSON.stringify(<?php echo json_encode($escrow_products, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>);
<?php } ?>
if(settle_method == "간편결제") {
f.cardflowMode.value = 'DIRECT';
}
f.amountCurrency.value = 'KRW';
f.amountValue.value = f.good_mny.value;
<?php if($default['de_tax_flag_use']) { ?>
f.taxFreeAmount.value = f.comm_free_mny.value;
<?php } ?>
f.windowTarget.value = 'iframe';
if(f.method.value != "무통장") {
// 주문정보 임시저장
var order_data = $(f).serialize();
var save_result = "";
$.ajax({
type: "POST",
data: order_data,
url: g5_url+"/shop/ajax.orderdatasave.php",
cache: false,
async: false,
success: function(data) {
save_result = data;
}
});
if(save_result) {
alert(save_result);
return false;
}
launchCrossPlatform(f);
} else {
f.submit();
}
<?php } ?>
<?php if($default['de_pg_service'] == 'inicis') { ?> <?php if($default['de_pg_service'] == 'inicis') { ?>
f.price.value = f.good_mny.value; f.price.value = f.good_mny.value;
f.buyername.value = f.pp_name.value; f.buyername.value = f.pp_name.value;

View File

@ -2,28 +2,42 @@
include_once('./_common.php'); include_once('./_common.php');
include_once(G5_LIB_PATH.'/mailer.lib.php'); include_once(G5_LIB_PATH.'/mailer.lib.php');
$page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.get_session('ss_personalpay_id');
$pp_id = $_POST['pp_id'] = isset($_POST['pp_id']) ? preg_replace('/[^0-9]/', '', $_POST['pp_id']) : 0; $pp_id = $_POST['pp_id'] = isset($_POST['pp_id']) ? preg_replace('/[^0-9]/', '', $_POST['pp_id']) : 0;
$good_mny = $_POST['good_mny'] = isset($_POST['good_mny']) ? preg_replace('/[^0-9]/', '', $_POST['good_mny']) : 0; $good_mny = $_POST['good_mny'] = isset($_POST['good_mny']) ? preg_replace('/[^0-9]/', '', $_POST['good_mny']) : 0;
$post_lgd_paykey = isset($_POST['LGD_PAYKEY']) ? $_POST['LGD_PAYKEY'] : ''; $post_lgd_paykey = isset($_POST['LGD_PAYKEY']) ? $_POST['LGD_PAYKEY'] : '';
$paymentKey = isset($_POST['paymentKey']) ? $_POST['paymentKey'] : '';
$pp_deposit_name = ''; $pp_deposit_name = '';
if($default['de_pg_service'] == 'lg' && ! $post_lgd_paykey) if($default['de_pg_service'] == 'lg' && ! $post_lgd_paykey)
alert('결제등록 요청 후 결제해 주십시오.'); alert('결제등록 요청 후 결제해 주십시오.', $page_return_url);
if($default['de_pg_service'] == 'toss' && ! $paymentKey)
alert('결제등록 요청 후 주문해 주십시오.', $page_return_url);
set_session('ss_order_id', $pp_id);
// 개인결제 정보 // 개인결제 정보
$pp_check = false; $pp_check = false;
$sql = " select * from {$g5['g5_shop_personalpay_table']} where pp_id = '{$pp_id}' and pp_use = '1' "; $sql = " select * from {$g5['g5_shop_personalpay_table']} where pp_id = '{$pp_id}' and pp_use = '1' ";
$pp = sql_fetch($sql); $pp = sql_fetch($sql);
if(! (isset($pp['pp_id']) && $pp['pp_id'])) if(! (isset($pp['pp_id']) && $pp['pp_id']))
alert('개인결제 정보가 존재하지 않습니다.'); alert('개인결제 정보가 존재하지 않습니다.', $page_return_url);
if($pp['pp_tno']) if($pp['pp_tno'])
alert('이미 결제하신 개인결제 내역입니다.'); alert('이미 결제하신 개인결제 내역입니다.', $page_return_url);
$hash_data = md5($pp_id.$good_mny.$pp['pp_time']); $hash_data = md5($pp_id.$good_mny.$pp['pp_time']);
if($pp_id != get_session('ss_personalpay_id') || $hash_data != get_session('ss_personalpay_hash')) if($pp_id != get_session('ss_personalpay_id') || $hash_data != get_session('ss_personalpay_hash'))
die('개인결제 정보가 올바르지 않습니다.'); die('개인결제 정보가 올바르지 않습니다.');
// PG사의 가상계좌 또는 계좌이체의 자동 현금영수증 초기배열값
$pg_receipt_infos = array(
'od_cash' => 0,
'od_cash_no' => '',
'od_cash_info' => '',
);
if ($pp_settle_case == "계좌이체") if ($pp_settle_case == "계좌이체")
{ {
@ -31,6 +45,9 @@ if ($pp_settle_case == "계좌이체")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; include G5_SHOP_PATH.'/inicis/inistdpay_result.php';
break; break;
@ -56,6 +73,9 @@ else if ($pp_settle_case == "가상계좌")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; include G5_SHOP_PATH.'/inicis/inistdpay_result.php';
break; break;
@ -81,6 +101,9 @@ else if ($pp_settle_case == "휴대폰")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; include G5_SHOP_PATH.'/inicis/inistdpay_result.php';
break; break;
@ -104,6 +127,9 @@ else if ($pp_settle_case == "신용카드")
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_result.php'; include G5_SHOP_PATH.'/lg/xpay_result.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_result.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inistdpay_result.php'; include G5_SHOP_PATH.'/inicis/inistdpay_result.php';
break; break;
@ -134,6 +160,9 @@ if((int)$pp['pp_price'] !== (int)$pg_price) {
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_cancel.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;
@ -164,7 +193,10 @@ $sql = " update {$g5['g5_shop_personalpay_table']}
pp_bank_account = '$pp_bank_account', pp_bank_account = '$pp_bank_account',
pp_deposit_name = '$pp_deposit_name', pp_deposit_name = '$pp_deposit_name',
pp_receipt_time = '$pp_receipt_time', pp_receipt_time = '$pp_receipt_time',
pp_receipt_ip = '{$_SERVER['REMOTE_ADDR']}' pp_receipt_ip = '{$_SERVER['REMOTE_ADDR']}',
pp_cash = '{$pg_receipt_infos['od_cash']}',
pp_cash_no = '{$pg_receipt_infos['od_cash_no']}',
pp_cash_info = '{$pg_receipt_infos['od_cash_info']}'
where pp_id = '{$pp['pp_id']}' "; where pp_id = '{$pp['pp_id']}' ";
$result = sql_query($sql, false); $result = sql_query($sql, false);
@ -202,6 +234,9 @@ if($pp_receipt_price > 0 && $pp['pp_id'] && $pp['od_id']) {
od_settle_case = '$pp_settle_case', od_settle_case = '$pp_settle_case',
od_deposit_name = '$pp_deposit_name', od_deposit_name = '$pp_deposit_name',
od_bank_account = '$pp_bank_account', od_bank_account = '$pp_bank_account',
od_cash = '{$pg_receipt_infos['od_cash']}',
od_cash_no = '{$pg_receipt_infos['od_cash_no']}',
od_cash_info = '{$pg_receipt_infos['od_cash_info']}',
od_shop_memo = concat(od_shop_memo, \"\\n개인결제 ".$pp['pp_id']." 로 결제완료 - ".$pp_receipt_time."\") od_shop_memo = concat(od_shop_memo, \"\\n개인결제 ".$pp['pp_id']." 로 결제완료 - ".$pp_receipt_time."\")
where od_id = '{$pp['od_id']}' "; where od_id = '{$pp['od_id']}' ";
$result = sql_query($sql, false); $result = sql_query($sql, false);
@ -213,9 +248,12 @@ if($pp_receipt_price > 0 && $pp['pp_id'] && $pp['od_id']) {
case 'lg': case 'lg':
include G5_SHOP_PATH.'/lg/xpay_cancel.php'; include G5_SHOP_PATH.'/lg/xpay_cancel.php';
break; break;
case 'toss':
include G5_SHOP_PATH.'/toss/toss_cancel.php';
break;
case 'inicis': case 'inicis':
include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; include G5_SHOP_PATH.'/inicis/inipay_cancel.php';
break; break;
default: default:
include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php';
break; break;

View File

@ -149,6 +149,8 @@ if($pp['pp_pg'] == 'lg') {
$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);
$hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; $hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
} else if($pp['pp_pg'] == 'toss') {
$hp_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/phone?transactionId='.$pp['pp_tno'].'&ref=PX\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'inicis') { } else if($pp['pp_pg'] == 'inicis') {
$hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'nicepay') { } else if($pp['pp_pg'] == 'nicepay') {
@ -170,6 +172,8 @@ if($pp['pp_pg'] == 'lg') {
$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);
$card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; $card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
} else if($pp['pp_pg'] == 'toss') {
$card_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/redirection?transactionId='.$pp['pp_tno'].'&ref=PX\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'inicis') { } else if($pp['pp_pg'] == 'inicis') {
$card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'nicepay') { } else if($pp['pp_pg'] == 'nicepay') {
@ -225,6 +229,8 @@ if($pp['pp_pg'] == 'lg') {
break; break;
} }
$cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$pp['pp_id'].'\',\''.$pp['pp_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$pp['pp_id'].'\',\''.$pp['pp_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');';
} else if($pp['pp_pg'] == 'toss') {
$cash_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/mids/si_'.$config['cf_lg_mid'].'/orders/'.$pp['pp_id'].'/cash-receipt?ref=dashboard\',\'receipt\',\'width=430,height=700\');';
} else if($pp['pp_pg'] == 'inicis') { } else if($pp['pp_pg'] == 'inicis') {
$cash = unserialize($pp['pp_cash_info']); $cash = unserialize($pp['pp_cash_info']);
$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';

11
shop/settle_toss.inc.php Normal file
View File

@ -0,0 +1,11 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
require_once(G5_SHOP_PATH.'/toss/toss.inc.php');
$toss = new TossPayments(
$config['cf_toss_client_key'],
$config['cf_toss_secret_key'],
$config['cf_lg_mid']
);
$toss->setPaymentHeader();

422
shop/settle_toss_common.php Normal file
View File

@ -0,0 +1,422 @@
<?php
include_once('./_common.php');
include_once(G5_KAKAO5_PATH.'/kakao5.lib.php'); // 카카오톡 알림톡 설정
require_once(G5_SHOP_PATH.'/toss/toss.inc.php'); // 토스페이먼츠 v2 공통 설정
/*************************************************************************
**
** 토스페이먼츠 v2 가상계좌 입금 결과 처리 - 웹훅
**
*************************************************************************/
$payLog = true; // 로그 사용 여부
$log_file = G5_DATA_PATH . '/log/tosspayment_result_log.txt';
/**
* 로그 기록 함수
*/
function write_toss_log($reason, $orderId = '', $status = '')
{
global $payLog, $log_file;
if($payLog) {
$logfile = fopen($log_file, "a+");
fwrite( $logfile,"************************************************\r\n");
fwrite( $logfile,"Reason : ".$reason."\r\n");
fwrite( $logfile,"Status : ".$status."\r\n");
fwrite( $logfile,"OrderId : ".$orderId."\r\n");
fwrite( $logfile,"************************************************\r\n");
fclose( $logfile );
}
}
// 입금통보 결과 데이터 읽기
$raw = file_get_contents('php://input');
if ($raw == false) {
write_toss_log("입력 데이터 읽기 실패");
http_response_code(400);
exit;
}
// json 파싱 체크
$data = json_decode($raw, true);
if (!is_array($data)) {
$json_error = json_last_error_msg();
write_toss_log("데이터 파싱 실패: " . $json_error);
http_response_code(400);
exit;
}
// 공통 필드 정리
$TOSS_CREATEDAT = isset($data["createdAt"]) ? $data["createdAt"] : '';
$TOSS_SECRET = isset($data["secret"]) ? $data["secret"] : '';
$TOSS_ORDERID = isset($data["orderId"]) ? $data["orderId"] : '';
$TOSS_STATUS = isset($data["status"]) ? $data["status"] : '';
$TOSS_TRANSACTIONKEY = isset($data["transactionKey"]) ? $data["transactionKey"] : '';
// 결제 상세 조회
$toss = new TossPayments(
$config['cf_toss_client_key'],
$config['cf_toss_secret_key'],
$config['cf_lg_mid']
);
$toss->setPaymentHeader();
$orderResult = $toss->getPaymentByOrderId($TOSS_ORDERID);
$order_info = $toss->responseData;
if (!$orderResult || $order_info['secret'] !== $TOSS_SECRET) {
$error_msg = isset($order_info['message']) ? $order_info['message'] : '주문 정보 조회 실패';
$error_code = isset($order_info['code']) ? $order_info['code'] : 'UNKNOWN_ERROR';
write_toss_log("주문 정보 조회 실패 - {$error_code} : {$error_msg}", $TOSS_ORDERID, $TOSS_STATUS);
http_response_code(400);
exit;
}
// 결제 정보
$paymentKey = isset($order_info["paymentKey"]) ? clean_xss_tags($order_info["paymentKey"]) : ''; // 결제 키
$customerName = isset($order_info["virtualAccount"]["customerName"]) ? clean_xss_tags($order_info["virtualAccount"]["customerName"]) : ''; // 주문자명 (가상계좌 발급 시 고객명)
$depositorName = isset($order_info["virtualAccount"]["depositorName"]) ? clean_xss_tags($order_info["virtualAccount"]["depositorName"]) : ''; // 입금자명 (실제 입금자 입력 이름)
$totalAmount = isset($order_info["totalAmount"]) ? clean_xss_tags($order_info["totalAmount"]) : ''; // 입금 금액 (결제 총액)
$bankCode = isset($order_info["virtualAccount"]["bankCode"]) ? clean_xss_tags($order_info["virtualAccount"]["bankCode"]) : ''; // 은행코드 (가상계좌 발급 은행, 예: 11 → 농협)
$accountNumber = isset($order_info["virtualAccount"]["accountNumber"]) ? clean_xss_tags($order_info["virtualAccount"]["accountNumber"]) : ''; // 가상계좌 입금계좌번호
$approvedAt = isset($order_info['approvedAt']) ? clean_xss_tags($order_info['approvedAt']) : ''; //입금일시
$dueDate = isset($order_info["virtualAccount"]['dueDate']) ? clean_xss_tags($order_info['virtualAccount']['dueDate']) : ''; // 만료일시
$receipt_time = $approvedAt ? (strtotime($approvedAt) !== false ? date("Y-m-d H:i:s", strtotime($approvedAt)) : '') : '';
$due_time = $dueDate ? (strtotime($dueDate) !== false ? date("Y-m-d H:i:s", strtotime($dueDate)) : '') : '';
// 가상계좌 채번시 현금영수증 자동발급신청이 되었을 경우 전달되며
// RcptTID에 값이 있는 경우만 발급처리 됨
$RcptTID = isset($order_info['cashReceipt']['receiptKey']) ? clean_xss_tags($order_info['cashReceipt']['receiptKey']) : ''; // 현금영수증 거래번호
$RcptAuthCode = isset($order_info['cashReceipt']['issueNumber']) ? clean_xss_tags($order_info['cashReceipt']['issueNumber']) : ''; // 현금영수증 승인번호
// 현금영수증 구분(0:미발행, 1:소득공제용, 2:지출증빙용)
$RcptType = isset($order_info['cashReceipt']['type']) ? clean_xss_tags($order_info['cashReceipt']['type'] === '소득공제' ? '1' : ($order_info['cashReceipt']['type'] === '지출증빙' ? '2' : '0')) : '0';
$RcptReceiptUrl = isset($order_info['cashReceipt']['receiptUrl']) ? clean_xss_tags($order_info['cashReceipt']['receiptUrl']) : ''; // 현금영수증 URL
$result = false;
/**
* 입금 완료 처리
*/
if($TOSS_STATUS == "DONE"){
// 입금결과 처리
$sql = " select pp_id, od_id from {$g5['g5_shop_personalpay_table']} where pp_id = '{$TOSS_ORDERID}' and pp_tno = '{$paymentKey}'";
$row = sql_fetch($sql);
if($row['pp_id']) {
// 개인결제 UPDATE
$add_update_sql = '';
// 현금영수증 발급시 1 또는 2 이면
if ($RcptType) {
$add_update_sql = "
, pp_cash = '1',
pp_cash_no = '".$RcptAuthCode."',
pp_cash_info = '".serialize(array('TID'=>$RcptTID, 'ApplNum'=>$RcptAuthCode, 'AuthDate'=>$approvedAt, 'receiptUrl'=>$RcptReceiptUrl))."'
";
}
$sql = " update {$g5['g5_shop_personalpay_table']}
set pp_receipt_price = '$totalAmount',
pp_receipt_time = '$receipt_time',
pp_deposit_name = '$depositorName'
$add_update_sql
where pp_id = '$TOSS_ORDERID'";
$result = sql_query($sql, false);
if($row['od_id']) {
// 주문서 UPDATE
$sql = " update {$g5['g5_shop_order_table']}
set od_receipt_price = od_receipt_price + '$totalAmount',
od_receipt_time = '$receipt_time',
od_deposit_name = '$depositorName',
od_shop_memo = concat(od_shop_memo, \"\\n개인결제 ".$row['pp_id']." 로 결제완료 - ".$receipt_time."\")
where od_id = '{$row['od_id']}' ";
$result = sql_query($sql, FALSE);
}
} else {
// 주문내역에 secret 검증 추가
$sql = " select od_id from {$g5['g5_shop_order_table']} where od_id = '$TOSS_ORDERID' and od_tno = '$paymentKey'";
$row = sql_fetch($sql);
if(!$row['od_id']) {
write_toss_log("주문내역 조회 실패", $TOSS_ORDERID, $TOSS_STATUS);
http_response_code(400);
exit;
}
// 주문서 UPDATE
$sql = " update {$g5['g5_shop_order_table']}
set od_receipt_price = '$totalAmount',
od_receipt_time = '$receipt_time',
od_deposit_name = '$depositorName'
where od_id = '$TOSS_ORDERID'
and od_tno = '$paymentKey'";
$result = sql_query($sql, FALSE);
}
if($result) {
if (isset($row['od_id']) && $row['od_id'])
$od_id = $row['od_id'];
else
$od_id = $TOSS_ORDERID;
// 주문정보 체크
$sql = " select count(od_id) as cnt
from {$g5['g5_shop_order_table']}
where od_id = '$od_id'
and od_status = '주문' ";
$row = sql_fetch($sql);
if($row['cnt'] == 1) {
// 미수금 정보 업데이트
$info = get_order_info($od_id);
$add_update_sql = '';
// 현금영수증 발급시 1 또는 2 이면
if ($RcptType) {
$add_update_sql = "
, od_cash = '1',
od_cash_no = '".$RcptAuthCode."',
od_cash_info = '".serialize(array('TID'=>$RcptTID, 'ApplNum'=>$RcptAuthCode, 'AuthDate'=>$approvedAt, 'receiptUrl'=>$RcptReceiptUrl))."'
";
}
$sql = " update {$g5['g5_shop_order_table']}
set od_misu = '{$info['od_misu']}' $add_update_sql ";
if($info['od_misu'] == 0)
$sql .= " , od_status = '입금' ";
$sql .= " where od_id = '$od_id' ";
sql_query($sql, FALSE);
// 장바구니 상태변경
if($info['od_misu'] == 0) {
$sql = " update {$g5['g5_shop_cart_table']}
set ct_status = '입금'
where od_id = '$od_id' ";
sql_query($sql, FALSE);
}
}
}
}
/**
* 입금 오류 처리 (입금 오류로 인해 WAITING_FOR_DEPOSIT으로 되돌아온 경우)
*/
elseif($TOSS_STATUS == "WAITING_FOR_DEPOSIT")
{
// 개인결제 정보 조회
$sql = " select pp_id, od_id, pp_name, pp_hp, pp_tel from {$g5['g5_shop_personalpay_table']} where pp_id = '{$TOSS_ORDERID}' and pp_tno = '{$paymentKey}'";
$row = sql_fetch($sql);
if($row['pp_id']) {
// 개인결제 정보 롤백
$sql = " update {$g5['g5_shop_personalpay_table']}
set pp_receipt_price = 0,
pp_receipt_time = '',
pp_cash = 0,
pp_cash_no = '',
pp_cash_info = ''
where pp_id = '{$TOSS_ORDERID}' and pp_tno = '{$paymentKey}'";
$result = sql_query($sql, FALSE);
if($row['od_id']) {
// 주문서에서 개인결제 금액 차감
$sql = " update {$g5['g5_shop_order_table']}
set od_receipt_price = od_receipt_price - '$totalAmount',
od_shop_memo = concat(od_shop_memo, \"\\n개인결제 ".$row['pp_id']." 가상계좌 입금 오류로 취소 - ".date('Y-m-d H:i:s')."\")
where od_id = '{$row['od_id']}' ";
$result = sql_query($sql, FALSE);
}
} else {
// 일반 주문 롤백 전에 데이터 존재 확인
$sql = " select od_id, od_name, od_hp, od_tel from {$g5['g5_shop_order_table']} where od_id = '{$TOSS_ORDERID}' and od_tno = '{$paymentKey}'";
$row = sql_fetch($sql);
if(empty($row['od_id'])) {
write_toss_log("주문 데이터가 존재하지 않음", $TOSS_ORDERID, $TOSS_STATUS);
http_response_code(400);
exit;
}
// 일반 주문 입금완료 - 주문 상태 롤백 (입금 → 주문)
$sql = " update {$g5['g5_shop_order_table']}
set od_status = '주문',
od_receipt_price = 0,
od_receipt_time = '',
od_shop_memo = concat(od_shop_memo, \"\\n가상계좌 입금 오류로 취소 - ".date('Y-m-d H:i:s')."\"),
od_cash = 0,
od_cash_no = '',
od_cash_info = ''
where od_id = '{$TOSS_ORDERID}' and od_tno = '{$paymentKey}' ";
$result = sql_query($sql, FALSE);
}
// 공통 처리: 미수금 정보 재계산 및 상태 롤백
if($result) {
if (isset($row['od_id']) && $row['od_id'])
$od_id = $row['od_id'];
else
$od_id = $TOSS_ORDERID;
// 미수금 정보 재계산
$info = get_order_info($od_id);
if($info) {
$sql = " update {$g5['g5_shop_order_table']}
set od_misu = '{$info['od_misu']}',
od_status = '주문',
od_cash = 0,
od_cash_no = '',
od_cash_info = ''
where od_id = '{$od_id}' ";
sql_query($sql, FALSE);
// 장바구니 상태 롤백 (입금 → 주문)
$sql = " update {$g5['g5_shop_cart_table']}
set ct_status = '주문'
where od_id = '{$od_id}' ";
sql_query($sql, FALSE);
}
// SMS 발송 - 재입금 안내
$sms_message = '';
// 개인결제인지 일반주문인지 확인하여 연락처 조회
if($row['pp_id']) {
// 개인결제인 경우
$customer_name = $row['pp_name'];
$customer_phone = $row['pp_hp'] ? $row['pp_hp'] : ($row['pp_tel'] ? $row['pp_tel'] : '');
$title = "개인결제번호 {$TOSS_ORDERID}";
} else {
// 일반주문인 경우
$customer_name = $row['od_name'];
$customer_phone = $row['od_hp'] ? $row['od_hp'] : ($row['od_tel'] ? $row['od_tel'] : '');
$title = "주문번호 {$od_id}";
}
if($customer_phone) {
$sms_message = "{$customer_name}님, {$title} 가상계좌 입금이 완료되지 않았습니다. 재입금 또는 관리자 문의 바랍니다.\n";
$sms_message .= $default['de_admin_company_name'];
}
// 전화번호가 있고 SMS 발송 설정이 활성화된 경우에만 발송
if($customer_phone && $sms_message && $config['cf_icode_id'] && $config['cf_icode_pw']) {
// SMS 발송
$sms_messages = array();
$receive_number = preg_replace("/[^0-9]/", "", $customer_phone); // 수신자번호
$send_number = preg_replace("/[^0-9]/", "", $default['de_admin_company_tel']); // 발신자번호
$sms_messages[] = array('recv' => $receive_number, 'send' => $send_number, 'cont' => $sms_message);
// SMS 발송 처리
if($config['cf_sms_type'] == 'LMS') {
include_once(G5_LIB_PATH.'/icode.lms.lib.php');
$port_setting = get_icode_port_type($config['cf_icode_id'], $config['cf_icode_pw']);
if($port_setting !== false) {
$SMS = new LMS;
$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $port_setting);
for($s=0; $s<count($sms_messages); $s++) {
$strDest = array();
$strDest[] = $sms_messages[$s]['recv'];
$strCallBack = $sms_messages[$s]['send'];
$strCaller = iconv_euckr(trim($default['de_admin_company_name']));
$strSubject = '';
$strURL = '';
$strData = iconv_euckr($sms_messages[$s]['cont']);
$strDate = '';
$nCount = count($strDest);
$res = $SMS->Add($strDest, $strCallBack, $strCaller, $strSubject, $strURL, $strData, $strDate, $nCount);
$SMS->Send();
$SMS->Init();
}
}
} else {
include_once(G5_LIB_PATH.'/icode.sms.lib.php');
$SMS = new SMS;
$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']);
for($s=0; $s<count($sms_messages); $s++) {
$recv_number = $sms_messages[$s]['recv'];
$send_number = $sms_messages[$s]['send'];
$sms_content = iconv_euckr($sms_messages[$s]['cont']);
$SMS->Add($recv_number, $send_number, $config['cf_icode_id'], $sms_content, "");
}
$SMS->Send();
$SMS->Init();
}
// SMS 발송 로그 기록
write_toss_log("가상계좌 재입금 안내 SMS 발송 완료", $TOSS_ORDERID, "SMS_SENT");
}
}
}
/**
* 입금 전 취소 처리
*/
elseif($TOSS_STATUS == "CANCELED")
{
$sql = " update {$g5['g5_shop_order_table']}
set od_shop_memo = concat(od_shop_memo, \"\\n가상계좌 입금 전 취소 - ".date('Y-m-d H:i:s')."\")
where od_id = '{$TOSS_ORDERID}' ";
$result = sql_query($sql, FALSE);
}
//************************************************************************************
// 위에서 상점 데이터베이스에 등록 성공유무에 따라서 성공시에는 성공응답인 `HTTP 200` 상태 코드를 리턴해야 합니다.
// (주의) 성공응답인 `HTTP 200` 상태 코드를 리턴하지 않으면 토스페이먼츠에서 7회까지 재전송에 실패하면 웹훅 상태가 실패로 변경됩니다.
// 로그 기록
if($payLog) {
$logfile = fopen($log_file, "a+");
// 은행명 조회
$bankName = '';
if($bankCode && isset($toss->bankCode[$bankCode])) {
$bankName = $toss->bankCode[$bankCode];
}
fwrite( $logfile,"************************************************\r\n");
fwrite( $logfile,"GoodsName : 토스페이먼츠 가상계좌\r\n");
fwrite( $logfile,"OrderId : ".$TOSS_ORDERID."\r\n");
fwrite( $logfile,"Status : ".$TOSS_STATUS."\r\n");
fwrite( $logfile,"ResultMsg : ".($result ? "SUCCESS" : "FAIL")."\r\n");
fwrite( $logfile,"Amt : ".$totalAmount."\r\n");
fwrite( $logfile,"name : ".$customerName."\r\n");
fwrite( $logfile,"TID : ".$paymentKey."\r\n");
fwrite( $logfile,"AuthDate : ".$approvedAt."\r\n");
fwrite( $logfile,"VbankNum : ".$accountNumber."\r\n");
fwrite( $logfile,"VbankCode : ".$bankCode."\r\n");
fwrite( $logfile,"VbankName : ".$bankName."\r\n");
fwrite( $logfile,"VbankInputName: ".$depositorName."\r\n");
fwrite( $logfile,"RcptTID : ".$RcptTID."\r\n");
fwrite( $logfile,"RcptAuthCode : ".$RcptAuthCode."\r\n");
fwrite( $logfile,"RcptType : ".$RcptType."\r\n");
fwrite( $logfile,"************************************************\r\n");
fclose( $logfile );
}
if ($result)
{
http_response_code(200); // 절대로 지우지마세요
echo "OK";
exit;
}
else
{
http_response_code(400);
echo "FAIL";
exit;
}
//*************************************************************************************

2
shop/toss/_common.php Normal file
View File

@ -0,0 +1,2 @@
<?php
include_once('../../common.php');

111
shop/toss/orderform.1.php Normal file
View File

@ -0,0 +1,111 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 전자결제를 사용할 때만 실행
if($default['de_iche_use'] || $default['de_vbank_use'] || $default['de_hp_use'] || $default['de_card_use'] || $default['de_easy_pay_use']) {
?>
<script language="javascript" src="https://js.tosspayments.com/v2/standard"></script>
<script type="text/javascript">
/*
* 수정불가.
*/
const clientKey = "<?php echo $config['cf_toss_client_key']; ?>";
const customerKey = "<?php echo isset($member['mb_id']) ? $member['mb_id'] : ''; ?>";
const tossPayments = TossPayments(clientKey);
const payment = tossPayments.payment({ customerKey });
/*
* 수정불가
*/
async function launchCrossPlatform(frm) {
// 필수 값들 체크
if (!frm.amountValue || !frm.amountValue.value) {
alert('결제 금액이 설정되지 않았습니다.');
return;
}
const amount = parseInt(frm.amountValue.value);
if (isNaN(amount) || amount <= 0) {
alert('올바른 결제 금액을 입력해주세요.');
return;
}
// 기본 결제 옵션
const paymentOptions = {
method: frm.method.value,
amount: {
currency: "KRW",
value: parseInt(frm.amountValue.value),
},
taxFreeAmount: parseInt(frm.taxFreeAmount.value),
orderId: frm.orderId.value, // 고유 주문번호
orderName: frm.orderName.value,
successUrl: "<?php echo G5_SHOP_URL;?>/toss/returnurl.php", // 결제 요청이 성공하면 리다이렉트되는 URL
failUrl: "<?php echo G5_SHOP_URL;?>/toss/returnurl.php?mode=fail", // 결제 요청이 실패하면 리다이렉트되는 URL
customerEmail: frm.customerEmail.value,
customerName: frm.customerName.value,
customerMobilePhone: frm.customerMobilePhone.value,
};
// escrowProducts 추가 함수
function addEscrowProducts(paymentMethodOptions) {
if (frm.cardUseEscrow.value === "true") {
if (frm.escrowProducts && frm.escrowProducts.value) {
paymentMethodOptions.escrowProducts = JSON.parse(frm.escrowProducts.value);
}
}
}
// 결제 방법에 따른 추가 옵션
if (frm.method.value == 'CARD') {
// 신용카드
paymentOptions.card = {
flowMode: frm.cardflowMode.value, // 통합결제창 여는 옵션
easyPay: frm.cardeasyPay.value,
useCardPoint: frm.cardUseCardPoint.value == "true" ? true : false,
useAppCardOnly: frm.cardUseAppCardOnly.value == "true" ? true : false,
useEscrow: frm.cardUseEscrow.value == "true" ? true : false,
};
// escrowProducts 추가
addEscrowProducts(paymentOptions.card);
} else if (frm.method.value == 'VIRTUAL_ACCOUNT') {
// 가상계좌
paymentOptions.virtualAccount = {
cashReceipt: {
type: "소득공제",
},
useEscrow: frm.cardUseEscrow.value == "true" ? true : false,
validHours: 168,
};
// escrowProducts 추가
addEscrowProducts(paymentOptions.virtualAccount);
} else if (frm.method.value == 'TRANSFER') {
// 계좌이체
paymentOptions.transfer = {
cashReceipt: {
type: "소득공제",
},
useEscrow: frm.cardUseEscrow.value == "true" ? true : false,
};
// escrowProducts 추가
addEscrowProducts(paymentOptions.transfer);
}
await payment.requestPayment(paymentOptions);
}
/*
* FORM 명만 수정 가능
*/
function getFormObject() {
return document.getElementById("forderform");
}
</script>
<?php }

31
shop/toss/orderform.2.php Normal file
View File

@ -0,0 +1,31 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<input type="hidden" name="method" value="">
<input type="hidden" name="orderId" value="<?php echo isset($od_id) ? $od_id : ''; ?>">
<input type="hidden" name="orderName" value="<?php echo isset($goods) ? $goods : ''; ?>">
<input type="hidden" name="customerName" value="<?php echo isset($od_name) ? $od_name : ''; ?>">
<input type="hidden" name="customerEmail" value="<?php echo isset($od_email) ? $od_email : ''; ?>">
<input type="hidden" name="customerMobilePhone" value="<?php echo isset($od_hp) ? $od_hp : ''; ?>">
<input type="hidden" name="cardUseEscrow" value="false">
<input type="hidden" name="escrowProducts" value=''>
<input type="hidden" name="cardflowMode" value="DEFAULT">
<input type="hidden" name="cardeasyPay" value="PAYCO">
<input type="hidden" name="cardUseCardPoint" value="false">
<input type="hidden" name="cardUseAppCardOnly" value="false">
<input type="hidden" name="amountCurrency" value="KRW">
<input type="hidden" name="amountValue" value="<?php echo isset($tot_price) ? $tot_price : 0; ?>">
<input type="hidden" name="taxFreeAmount" value="<?php echo isset($comm_free_mny) ? $comm_free_mny : 0; ?>">
<input type="hidden" name="windowTarget" value="iframe">
<input type="hidden" name="good_mny" value="<?php echo $tot_price; ?>">
<?php
if($default['de_tax_flag_use']) {
?>
<input type="hidden" name="comm_tax_mny" value="<?php echo isset($comm_tax_mny) ? $comm_tax_mny : 0; ?>"> <!-- 과세금액 -->
<input type="hidden" name="comm_vat_mny" value="<?php echo isset($comm_vat_mny) ? $comm_vat_mny : 0; ?>"> <!-- 부가세 -->
<input type="hidden" name="comm_free_mny" value="<?php echo isset($comm_free_mny) ? $comm_free_mny : 0; ?>"> <!-- 비과세 금액 -->
<?php
}
?>

16
shop/toss/orderform.3.php Normal file
View File

@ -0,0 +1,16 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<div id="display_pay_button" class="btn_confirm" style="display:none">
<input type="button" value="주문하기" class="btn_submit" onclick="forderform_check(this.form);"/>
<a href="javascript:history.go(-1);" class="btn01">취소</a>
</div>
<div id="display_pay_process" style="display:none">
<img src="<?php echo G5_URL; ?>/shop/img/loading.gif" alt="">
<span>주문완료 중입니다. 잠시만 기다려 주십시오.</span>
</div>
<script>
document.getElementById("display_pay_button").style.display = "" ;
</script>

View File

@ -0,0 +1,3 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가;
?>

View File

@ -0,0 +1,61 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
if($od['od_pg'] != 'toss') return;
// 토스 공통 설정
require_once(G5_SHOP_PATH.'/toss/toss.inc.php');
if (empty($mod_memo)) {
alert('취소사유를 입력해 주세요.');
}
$toss = new TossPayments(
$config['cf_toss_client_key'],
$config['cf_toss_secret_key'],
$config['cf_lg_mid']
);
$toss->setPaymentHeader();
$od_id = isset($od['od_id']) ? $od['od_id'] : (isset($pp['pp_id']) ? $pp['pp_id'] : '');
if (!$toss->getPaymentByOrderId($od_id)) {
alert('결제정보를 가져올 수 없습니다.');
}
$toss->setCancelData(array(
'paymentKey' => $toss->responseData['paymentKey'],
'cancelReason' => $mod_memo,
'cancelAmount' => (int)$tax_mny + (int)$free_mny,
'taxFreeAmount' => (int)$free_mny,
));
if (!$toss->cancelPayment()) {
$msg = '결제 부분취소 요청이 실패하였습니다.\\n\\n';
if (isset($toss->responseData['message'])) {
$msg .= '사유 : ' . $toss->responseData['message'] . '\\n';
}
if (isset($toss->responseData['code'])) {
$msg .= '코드 : ' . $toss->responseData['code'];
}
alert($msg);
}
// 환불금액 기록
$mod_mny = (int)$tax_mny + (int)$free_mny;
$sql = " update {$g5['g5_shop_order_table']}
set od_refund_price = od_refund_price + '$mod_mny',
od_shop_memo = concat(od_shop_memo, \"$mod_memo\")
where od_id = '{$od['od_id']}'";
sql_query($sql);
// 미수금 등의 정보 업데이트
$info = get_order_info($od_id);
$sql = " update {$g5['g5_shop_order_table']}
set od_misu = '{$info['od_misu']}',
od_tax_mny = '{$info['od_tax_mny']}',
od_vat_mny = '{$info['od_vat_mny']}',
od_free_mny = '{$info['od_free_mny']}'
where od_id = '$od_id' ";
sql_query($sql);

67
shop/toss/returnurl.php Normal file
View File

@ -0,0 +1,67 @@
<?php
include_once('./_common.php');
// 결제 실패 처리인 경우
if (isset($_REQUEST['mode']) && $_REQUEST['mode'] === 'fail') {
$code = isset($_REQUEST['code']) ? trim($_REQUEST['code']) : '';
$message = isset($_REQUEST['message']) ? trim($_REQUEST['message']) : '';
alert('결제에 실패하였습니다.\\n\\n[' . $code . '] ' . $message, G5_SHOP_URL . '/orderform.php');
exit;
}
$g5['title'] = '토스페이먼츠 결제인증 완료처리';
$g5['body_script'] = ' onload="setTossResult();"';
include_once(G5_PATH.'/head.sub.php');
// 토스페이먼츠 결제인증 성공시 인증키 주문 임시데이터에 업데이트
$paymentKey = isset($_REQUEST['paymentKey']) ? trim($_REQUEST['paymentKey']) : '';
$orderId = isset($_REQUEST['orderId']) ? trim($_REQUEST['orderId']) : '';
$amount = isset($_REQUEST['amount']) ? trim($_REQUEST['amount']) : '';
if (empty($paymentKey) || empty($orderId)) {
alert('결제정보가 올바르지 않습니다.', G5_SHOP_URL);
exit;
}
$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$orderId' ";
$row = sql_fetch($sql);
$data = isset($row['dt_data']) ? unserialize(base64_decode($row['dt_data'])) : array();
// 주문 임시데이터에 paymentKey 업데이트
$data['paymentKey'] = $paymentKey;
$data_new = base64_encode(serialize($data));
$sql = " update {$g5['g5_shop_order_data_table']} set dt_data = '$data_new' where od_id = '$orderId' limit 1 ";
sql_query($sql);
if(isset($data['pp_id']) && $data['pp_id']) {
$order_action_url = G5_HTTPS_SHOP_URL.'/personalpayformupdate.php';
} else {
$order_action_url = G5_HTTPS_SHOP_URL.'/orderformupdate.php';
}
?>
<?php
$exclude = array();
echo '<form name="forderform" method="post" action="'.$order_action_url.'" autocomplete="off">'.PHP_EOL;
echo make_order_field($data, $exclude);
echo '</form>'.PHP_EOL;
?>
<script type="text/javascript">
function setTossResult() {
try {
document.forderform.submit();
} catch (e) {
alert(e.message);
}
}
</script>
<?php
include_once(G5_PATH.'/tail.sub.php');

197
shop/toss/taxsave_form.php Normal file
View File

@ -0,0 +1,197 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<script>
// 현금영수증 MAIN FUNC
function jsf__pay_cash( form )
{
jsf__show_progress(true);
if ( jsf__chk_cash( form ) == false )
{
jsf__show_progress(false);
return;
}
form.submit();
}
// 진행 바
function jsf__show_progress( show )
{
if ( show == true )
{
window.show_pay_btn.style.display = "none";
window.show_progress.style.display = "inline";
}
else
{
window.show_pay_btn.style.display = "inline";
window.show_progress.style.display = "none";
}
}
// 포맷 체크
function jsf__chk_cash( form )
{
if ( form.tr_code[0].checked )
{
if ( form.id_info.value.length != 10 &&
form.id_info.value.length != 11 &&
form.id_info.value.length != 13 )
{
alert("주민번호 또는 휴대폰번호를 정확히 입력해 주시기 바랍니다.");
form.id_info.select();
form.id_info.focus();
return false;
}
}
else if ( form.tr_code[1].checked )
{
if ( form.id_info.value.length != 10 )
{
alert("사업자번호를 정확히 입력해 주시기 바랍니다.");
form.id_info.select();
form.id_info.focus();
return false;
}
}
return true;
}
function jsf__chk_tr_code( form )
{
var span_tr_code_0 = document.getElementById( "span_tr_code_0" );
var span_tr_code_1 = document.getElementById( "span_tr_code_1" );
if ( form.tr_code[0].checked )
{
span_tr_code_0.style.display = "inline";
span_tr_code_1.style.display = "none";
}
else if (form.tr_code[1].checked )
{
span_tr_code_0.style.display = "none";
span_tr_code_1.style.display = "inline";
}
}
</script>
<div id="scash" class="new_win">
<h1 id="win_title"><?php echo $g5['title']; ?></h1>
<section>
<h2>주문정보</h2>
<div class="tbl_head01 tbl_wrap">
<table>
<colgroup>
<col class="grid_3">
<col>
</colgroup>
<tbody>
<tr>
<th scope="row">주문 번호</th>
<td><?php echo $od_id; ?></td>
</tr>
<tr>
<th scope="row">상품 정보</th>
<td><?php echo $goods_name; ?></td>
</tr>
<tr>
<th scope="row">주문자 이름</th>
<td><?php echo $od_name; ?></td>
</tr>
<tr>
<th scope="row">주문자 E-Mail</th>
<td><?php echo $od_email; ?></td>
</tr>
<tr>
<th scope="row">주문자 전화번호</th>
<td><?php echo $od_tel; ?></td>
</tr>
</tbody>
</table>
</div>
</section>
<section>
<h2>현금영수증 발급 정보</h2>
<form method="post" action="<?php echo G5_SHOP_URL; ?>/toss/taxsave_result.php">
<input type="hidden" name="tx" value="<?php echo $tx; ?>">
<input type="hidden" name="od_id" value="<?php echo $od_id; ?>">
<div class="tbl_head01 tbl_wrap">
<table>
<colgroup>
<col class="grid_3">
<col>
</colgroup>
<tbody>
<tr>
<th scope="row">원 거래 시각</th>
<td><?php echo $trad_time; ?></td>
</tr>
<tr>
<th scope="row">발행 용도</th>
<td>
<input type="radio" name="tr_code" value="0" id="tr_code1" onClick="jsf__chk_tr_code( this.form )" checked>
<label for="tr_code1">소득공제용</label>
<input type="radio" name="tr_code" value="1" id="tr_code2" onClick="jsf__chk_tr_code( this.form )">
<label for="tr_code2">지출증빙용</label>
</td>
</tr>
<tr>
<th scope="row">
<label for="id_info">
<span id="span_tr_code_0" style="display:inline">주민(휴대폰)번호</span>
<span id="span_tr_code_1" style="display:none">사업자번호</span>
</label>
</th>
<td>
<input type="text" name="id_info" id="id_info" class="frm_input" size="16" maxlength="13"> ("-" 생략)
</td>
</tr>
<tr>
<th scope="row"><label for="buyeremail">이메일</label></th>
<td><input type="text" name="buyeremail" id="buyeremail" value="<?php echo $od_email; ?>" required class="required frm_input" size="30"></td>
</tr>
<tr>
<th scope="row"><label for="buyertel">휴대폰</label></th>
<td><input type="text" name="buyertel" id="buyertel" value="" required class="required frm_input" size="20"></td>
</tr>
<tr>
<th scope="row">거래금액 총합</th>
<td><?php echo number_format($amt_tot); ?>원</td>
</tr>
<tr>
<th scope="row">공급가액</th>
<td><?php echo number_format($amt_sup); ?>원<!-- ((거래금액 총합 * 10) / 11) --></td>
</tr>
<tr>
<th scope="row">봉사료</th>
<td><?php echo number_format($amt_svc); ?>원</td>
</tr>
<tr>
<th scope="row">부가가치세</th>
<td><?php echo number_format($amt_tax); ?>원<!-- 거래금액 총합 - 공급가액 - 봉사료 --></td>
</tr>
</tbody>
</table>
</div>
<div id="scash_apply">
<span id="show_pay_btn">
<button type="button" onclick="jsf__pay_cash( this.form )">등록요청</button>
</span>
<span id="show_progress" style="display:none">
<b>등록 진행중입니다. 잠시만 기다려주십시오</b>
</span>
</div>
</form>
</section>
</div>

View File

@ -0,0 +1,192 @@
<?php
include_once('./_common.php');
require_once(G5_SHOP_PATH.'/settle_toss.inc.php');
$od_id = isset($_REQUEST['od_id']) ? safe_replace_regex($_REQUEST['od_id'], 'od_id') : '';
$tx = isset($_REQUEST['tx']) ? clean_xss_tags($_REQUEST['tx'], 1, 1) : '';
if($tx == 'personalpay') {
$od = sql_fetch(" select * from {$g5['g5_shop_personalpay_table']} where pp_id = '$od_id' ");
if (!$od)
die('<p id="scash_empty">개인결제 내역이 존재하지 않습니다.</p>');
$od_tno = $od['pp_tno'];
$goods_name = $od['pp_name'].'님 개인결제';
$settle_case = $od['pp_settle_case'];
$order_price = $od['pp_receipt_price'];
$od_casseqno = $od['pp_casseqno'];
$od_name = $od['pp_name'];
$od_email = $od['pp_email'];
$od_tel = $od['pp_hp'];
} else {
$od = sql_fetch(" select * from {$g5['g5_shop_order_table']} where od_id = '$od_id' ");
if (!$od)
die('<p id="scash_empty">주문서가 존재하지 않습니다.</p>');
$od_tno = $od['od_tno'];
$goods = get_goods($od['od_id']);
$goods_name = $goods['full_name'];
$settle_case = $od['od_settle_case'];
$order_price = $od['od_tax_mny'] + $od['od_vat_mny'] + $od['od_free_mny'];
$od_casseqno = $od['od_casseqno'];
$od_name = $od['od_name'];
$od_email = $od['od_email'];
$od_tel = $od['od_tel'];
}
switch($settle_case) {
case '가상계좌':
case '계좌이체':
case '무통장':
// 토스페이먼츠는 결제수단 구분 없이 현금영수증 발급 가능
break;
default:
die('<p id="scash_empty">현금영수증은 무통장, 가상계좌, 계좌이체에 한해 발급요청이 가능합니다.</p>');
break;
}
// 토스페이먼츠 현금영수증 발급 요청
$orderId = $od_id;
$amount = $order_price;
$type = ($_POST['tr_code'] == '0') ? '소득공제' : '지출증빙';
$customerIdentityNumber = $_POST['id_info'];
$orderName = $od_name;
$customerEmail = $_POST['buyeremail'] ?: $od_email;
$customerMobilePhone = $_POST['buyertel'] ?: $od_tel;
// 토스페이먼츠 현금영수증 발급 API 호출
$toss->setCashReceiptsData([
'orderId' => $orderId,
'amount' => $amount,
'type' => $type,
'customerIdentityNumber' => $customerIdentityNumber,
'orderName' => $goods_name,
]);
$toss_result = $toss->issueCashReceipt();
/*
* 토스페이먼츠 현금영수증 발급 요청 결과처리
*/
if ($toss_result && isset($toss->responseData['receiptKey'])) {
// 현금영수증 발급 성공
$data = $toss->responseData;
$receiptKey = $data['receiptKey']; // 현금영수증 발급 키
$cash_no = $data['issueNumber']; // 현금영수증 발급 번호
$approvedAt = $data['requestedAt'];
$cash = array();
$cash['receiptKey'] = $receiptKey;
$cash['approvedAt'] = $approvedAt;
$cash['orderId'] = $data['orderId'];
$cash['amount'] = $data['amount'];
$cash['type'] = $data['type'];
$cash['receiptUrl'] = $data['receiptUrl'];
$cash_info = serialize($cash);
if($tx == 'personalpay') {
$sql = " update {$g5['g5_shop_personalpay_table']}
set pp_cash = '1',
pp_cash_no = '$cash_no',
pp_cash_info = '$cash_info'
where pp_id = '$orderId' ";
} else {
$sql = " update {$g5['g5_shop_order_table']}
set od_cash = '1',
od_cash_no = '$cash_no',
od_cash_info = '$cash_info'
where od_id = '$orderId' ";
}
$result = sql_query($sql, false);
if(!$result) { // DB 정보갱신 실패시 취소
$cancel_result = $toss->cancelCashReceipt($receiptKey, 'DB 업데이트 실패로 인한 취소');
if (!$cancel_result) {
$msg = '현금영수증 취소 요청처리가 정상적으로 완료되지 않았습니다.\\n'. $toss->responseData['message'];
alert_close($msg);
}
}
} else {
// API 요청 실패 화면처리
$msg = '현금영수증 발급 요청처리가 정상적으로 완료되지 않았습니다.\\n'. $toss->responseData['message'];
alert($msg);
}
$g5['title'] = '';
include_once(G5_PATH.'/head.sub.php');
?>
<script>
function showreceipt() // 현금 영수증 출력
{
var showreceiptUrl = "https://dashboard.tosspayments.com/receipt/mids/si_<?php echo $config['cf_lg_mid']; ?>/orders/<?php echo $orderId; ?>/cash-receipt?ref=dashboard";
window.open(showreceiptUrl,"showreceipt","width=380,height=540, scrollbars=no,resizable=no");
}
</script>
<div id="toss_req_tx" class="new_win">
<h1 id="win_title">현금영수증 - 토스페이먼츠</h1>
<div class="tbl_head01 tbl_wrap">
<table>
<colgroup>
<col class="grid_4">
<col>
</colgroup>
<tbody>
<?php if ($toss_result && isset($toss->responseData['receiptKey'])): ?>
<tr>
<th scope="row">결과</th>
<td>발급 완료</td>
</tr>
<tr>
<th scope="row">현금영수증 발급번호</th>
<td><?php echo $toss->responseData['issueNumber']; ?></td>
</tr>
<tr>
<th scope="row">주문번호</th>
<td><?php echo $toss->responseData['orderId']; ?></td>
</tr>
<tr>
<th scope="row">발급 유형</th>
<td><?php echo $toss->responseData['type']; ?></td>
</tr>
<tr>
<th scope="row">금액</th>
<td><?php echo number_format($toss->responseData['amount']); ?>원</td>
</tr>
<tr>
<th scope="row">승인시간</th>
<td><?php echo date('Y-m-d H:i:s', strtotime($toss->responseData['requestedAt'])); ?></td>
</tr>
<tr>
<th scope="row">현금영수증 확인</th>
<td>
<button type="button" name="receiptView" class="btn_frmline" onClick="javascript:showreceipt();">영수증 확인</button>
<p>영수증 확인은 실 등록의 경우에만 가능합니다.</p>
</td>
</tr>
<?php else: ?>
<tr>
<th scope="row">결과</th>
<td>발급 실패</td>
</tr>
<tr>
<th scope="row">오류 메시지</th>
<td><?php echo isset($toss_result['error']) ? $toss_result['error'] : '알 수 없는 오류가 발생했습니다.'; ?></td>
</tr>
<?php endif; ?>
<tr>
<td colspan="2"></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php
include_once(G5_PATH.'/tail.sub.php');

373
shop/toss/toss.inc.php Normal file
View File

@ -0,0 +1,373 @@
<?php
class TossPayments {
// 클라이언트, 시크릿 키, 상점아이디
public string $clientKey;
public string $secretKey;
public string $mId;
public string $headerSecretKey = "";
public string $paymentUrl = "https://api.tosspayments.com/v1/payments/orders/{orderId}";
public string $acceptUrl = "https://api.tosspayments.com/v1/payments/confirm";
public string $cancelUrl = "https://api.tosspayments.com/v1/payments/{paymentKey}/cancel";
public string $cashReceiptsUrl = "https://api.tosspayments.com/v1/cash-receipts";
// 결제데이터
public array $headers = array();
public array $paymentData = array();
public array $cancelData = array();
public array $cashReceiptsData = array();
public array $responseData = array();
public array $bankCode = array(
// 은행
'02' => '한국산업은행',
'03' => 'IBK기업은행',
'06' => 'KB국민은행',
'07' => 'Sh수협은행',
'11' => 'NH농협은행',
'12' => '단위농협(지역농축협)',
'20' => '우리은행',
'23' => 'SC제일은행',
'27' => '씨티은행',
'31' => 'iM뱅크(대구)',
'32' => '부산은행',
'34' => '광주은행',
'35' => '제주은행',
'37' => '전북은행',
'39' => '경남은행',
'45' => '새마을금고',
'48' => '신협',
'50' => '저축은행중앙회',
'54' => '홍콩상하이은행',
'64' => '산림조합',
'71' => '우체국예금보험',
'81' => '하나은행',
'88' => '신한은행',
'89' => '케이뱅크',
'90' => '카카오뱅크',
'92' => '토스뱅크',
// 증권
'S0' => '유안타증권',
'S2' => '신한금융투자',
'S3' => '삼성증권',
'S4' => 'KB증권',
'S5' => '미래에셋증권',
'S6' => '한국투자증권',
'S8' => '교보증권',
'S9' => '아이엠증권',
'SA' => '현대차증권',
'SB' => '키움증권',
'SD' => 'SK증권',
'SE' => '대신증권',
'SG' => '한화투자증권',
'SH' => '하나금융투자',
'SI' => 'DB금융투자',
'SJ' => '유진투자증권',
'SK' => '메리츠증권',
'SM' => '부국증권',
'SN' => '신영증권',
'SO' => 'LIG투자증권',
'SP' => 'KTB투자증권(다올투자증권)',
'SQ' => '카카오페이증권',
'SR' => '펀드온라인코리아(한국포스증권)',
'ST' => '토스증권'
);
public array $cardCode = array(
'3K' => '기업 BC',
'46' => '광주은행',
'71' => '롯데카드',
'30' => '한국산업은행',
'31' => 'BC카드',
'51' => '삼성카드',
'38' => '새마을금고',
'41' => '신한카드',
'62' => '신협',
'36' => '씨티카드',
'33' => '우리BC카드(BC 매입)',
'W1' => '우리카드(우리 매입)',
'37' => '우체국예금보험',
'39' => '저축은행중앙회',
'35' => '전북은행',
'42' => '제주은행',
'15' => '카카오뱅크',
'3A' => '케이뱅크',
'24' => '토스뱅크',
'21' => '하나카드',
'61' => '현대카드',
'11' => 'KB국민카드',
'91' => 'NH농협카드',
'34' => 'Sh수협은행',
'PCP' => '페이코',
'KBS' => 'KB증권'
);
// 간편결제 제공업체 코드
public array $easyPayCode = array(
'TOSSPAY' => '토스페이',
'NAVERPAY' => '네이버페이',
'SAMSUNGPAY' => '삼성페이',
'APPLEPAY' => '애플페이',
'LPAY' => '엘페이',
'KAKAOPAY' => '카카오페이',
'PINPAY' => '핀페이',
'PAYCO' => '페이코',
'SSG' => 'SSG페이'
);
public function __construct(string $clientKey, string $secretKey, string $mId) {
$this->clientKey = $clientKey;
$this->secretKey = $secretKey;
$this->mId = $mId;
}
/**
* 헤더 시크릿 키 설정
* @return void
*/
private function setHeaderSecretKey(): void
{
$this->headerSecretKey = base64_encode($this->secretKey . ':');
}
/**
* 헤더 설정
* @return void
*/
public function setPaymentHeader(): void
{
$this->setHeaderSecretKey();
$this->headers = array(
'Authorization: Basic ' . $this->headerSecretKey,
'Content-Type' => 'Content-Type: application/json'
);
}
/**
* 결제 데이터 설정
*
* @param array $request
* @return void
*/
public function setPaymentData(array $request): void
{
$this->paymentData = array(
'amount' => $request['amount'],
'orderId' => $request['orderId'],
'paymentKey' => $request['paymentKey'],
);
}
/**
* 주문번호로 결제정보 조회
*
* @param string $orderId
* @return bool
*/
public function getPaymentByOrderId(string $orderId): bool
{
if (empty($orderId)) {
return false;
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, str_replace('{orderId}', $orderId, $this->paymentUrl));
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($curl, CURLOPT_SSLVERSION, 6);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
$response = curl_exec($curl);
$return_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$this->responseData = json_decode($response, true);
curl_close($curl);
// 결제 실패 상황인 경우
if ($return_status != 200) {
return false;
}
return true;
}
/**
* 결제 승인
*
* @return bool
*/
public function approvePayment(): bool {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->acceptUrl);
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($this->paymentData));
curl_setopt($curl, CURLOPT_SSLVERSION, 6);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
$response = curl_exec($curl);
$return_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$this->responseData = json_decode($response, true);
curl_close($curl);
// 결제 실패 상황인 경우
if ($return_status != 200 || ($this->responseData['status'] != 'DONE' && $this->responseData['status'] != 'WAITING_FOR_DEPOSIT')) {
return false;
}
return true;
}
/**
* 결제 취소 데이터 설정
*
* @param array $request
* @return void
*/
public function setCancelData(array $request): void
{
$this->cancelData = array(
'paymentKey' => $request['paymentKey'],
'cancelReason' => $request['cancelReason'],
);
// 부분취소 금액이 있는 경우
if (isset($request['cancelAmount']) && $request['cancelAmount'] > 0) {
$this->cancelData['cancelAmount'] = $request['cancelAmount'];
}
// 면세금액이 있는 경우
if (isset($request['taxFreeAmount']) && $request['taxFreeAmount'] > 0) {
$this->cancelData['taxFreeAmount'] = $request['taxFreeAmount'];
}
// 환불 계좌정보가 있는 경우 (가상계좌)
if (isset($request['refundReceiveAccount']) && is_array($request['refundReceiveAccount'])) {
$this->cancelData['refundReceiveAccount'] = array(
'bank' => $request['refundReceiveAccount']['bank'],
'accountNumber' => $request['refundReceiveAccount']['accountNumber'],
'holderName' => $request['refundReceiveAccount']['holderName'],
);
}
}
/**
* 결제 취소
*
* @return bool
*/
public function cancelPayment(): bool
{
// 취소에 필요한 결제 키가 있는지 여부
if (empty($this->cancelData['paymentKey'])) {
return false;
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, str_replace('{paymentKey}', $this->cancelData['paymentKey'], $this->cancelUrl));
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($this->cancelData));
curl_setopt($curl, CURLOPT_SSLVERSION, 6);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
$response = curl_exec($curl);
$return_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$this->responseData = json_decode($response, true);
curl_close($curl);
// 결제 실패 상황인 경우
if ($return_status != 200) {
return false;
}
return true;
}
/**
* 현금영수증 발급 데이터 설정
*/
public function setCashReceiptsData(array $request): void
{
$this->cashReceiptsData = array(
'amount' => $request['amount'],
'orderId' => $request['orderId'],
'type' => $request['type'],
'customerIdentityNumber' => $request['customerIdentityNumber'],
'orderName' => $request['orderName'],
);
}
/**
* 현금영수증 발급
*/
public function issueCashReceipt(): bool
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->cashReceiptsUrl);
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($this->cashReceiptsData));
curl_setopt($curl, CURLOPT_SSLVERSION, 6);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_ENCODING, "");
curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
$response = curl_exec($curl);
$return_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$this->responseData = json_decode($response, true);
curl_close($curl);
// 결제 실패 상황인 경우
if ($return_status != 200) {
return false;
}
return true;
}
/**
* 현금영수증 발급 취소
*/
public function cancelCashReceipt($receiptKey): bool
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->cashReceiptsUrl."/".$receiptKey."/cancel");
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($curl, CURLOPT_SSLVERSION, 6);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_ENCODING, "");
curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
$response = curl_exec($curl);
$return_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$this->responseData = json_decode($response, true);
curl_close($curl);
// 결제 실패 상황인 경우
if ($return_status != 200) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,79 @@
<?php
include_once('./_common.php');
// 토스페이먼츠 class
require_once(G5_SHOP_PATH.'/toss/toss.inc.php');
$toss = new TossPayments(
$config['cf_toss_client_key'],
$config['cf_toss_secret_key'],
$config['cf_lg_mid']
);
$orderId = isset($_REQUEST['orderId']) ? $_REQUEST['orderId'] : '';
$amount = isset($_REQUEST['amount']) ? $_REQUEST['amount'] : '';
$paymentKey = isset($_REQUEST['paymentKey']) ? $_REQUEST['paymentKey'] : '';
$toss->setPaymentData([
'orderId' => $orderId,
'amount' => $amount,
'paymentKey' => $paymentKey,
]);
// 장바구니 ID 설정 (바로구매 여부 확인)
$ss_cart_id = get_session('ss_direct') ? get_session('ss_cart_direct') : get_session('ss_cart_id');
// 임시데이터에 결제 데이터 저장
$addQuery = "";
if (isset($orderId)) {
$addQuery .= " AND od_id = '$orderId'";
}
if (isset($ss_cart_id)) {
$addQuery .= " AND cart_id = '$ss_cart_id'";
}
if (isset($member['mb_id'])) {
$addQuery .= " AND mb_id = '{$member['mb_id']}'";
}
if (empty($orderId) && empty($ss_cart_id)) {
alert('주문정보가 올바르지 않습니다.');
exit;
}
// 기존 dt_data 가져오기
$sql = "
SELECT * FROM {$g5['g5_shop_order_data_table']}
WHERE 1=1
{$addQuery}
LIMIT 1
";
$res = sql_fetch($sql);
$dt_data = [];
if (isset($res['dt_data'])) {
$dt_data = unserialize(base64_decode($res['dt_data']));
}
// dt_data 에 결제 키 추가
if (isset($paymentKey)) {
$dt_data['paymentKey'] = $paymentKey;
$dt_data_new = base64_encode(serialize($dt_data));
// 업데이트
$sql = "
UPDATE {$g5['g5_shop_order_data_table']} SET
dt_data = '".$dt_data_new."'
WHERE od_id = '$orderId'
{$addQuery}
";
sql_query($sql);
}
if(isset($payReqMap['pp_id']) && $payReqMap['pp_id']) {
$page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.$payReqMap['pp_id'];
} else {
$page_return_url = G5_SHOP_URL.'/orderform.php';
if ($_SESSION['ss_direct']) {
$page_return_url .= '?sw_direct=1';
}
}
?>

38
shop/toss/toss_cancel.php Normal file
View File

@ -0,0 +1,38 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 토스 공통 설정
require_once(G5_SHOP_PATH.'/toss/toss.inc.php');
if (empty($cancel_msg)) {
alert('취소사유를 입력해 주세요.');
}
$toss = new TossPayments(
$config['cf_toss_client_key'],
$config['cf_toss_secret_key'],
$config['cf_lg_mid']
);
$toss->setPaymentHeader();
$od_id = isset($od['od_id']) ? $od['od_id'] : (isset($pp['pp_id']) ? $pp['pp_id'] : '');
if (!$toss->getPaymentByOrderId($od_id)) {
alert('결제정보를 가져올 수 없습니다.');
}
$toss->setCancelData(array(
'paymentKey' => $toss->responseData['paymentKey'],
'cancelReason' => $cancel_msg,
));
if (!$toss->cancelPayment()) {
$msg = '결제 취소에 실패하였습니다.\\n';
if (isset($toss->responseData['message'])) {
$msg .= '사유 : ' . $toss->responseData['message'] . '\\n';
}
if (isset($toss->responseData['code'])) {
$msg .= '코드 : ' . $toss->responseData['code'];
}
alert($msg);
}

108
shop/toss/toss_result.php Normal file
View File

@ -0,0 +1,108 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 토스페이먼츠 v2 공통 설정
require_once(G5_SHOP_PATH.'/toss/toss.inc.php');
$orderId = isset($_REQUEST['orderId']) ? $_REQUEST['orderId'] : '';
$paymentKey = isset($_POST['paymentKey']) ? $_POST['paymentKey'] : '';
if (empty($orderId) || empty($paymentKey)) {
alert('주문정보가 올바르지 않습니다.', G5_SHOP_URL);
}
$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$orderId' limit 1 ";
$row = sql_fetch($sql);
$data = isset($row['dt_data']) ? unserialize(base64_decode($row['dt_data'])) : array();
$amount = isset($data['amountValue']) ? $data['amountValue'] : 0;
if ($amount <= 0) {
alert('결제금액이 올바르지 않습니다.', G5_SHOP_URL);
}
$toss = new TossPayments(
$config['cf_toss_client_key'],
$config['cf_toss_secret_key'],
$config['cf_lg_mid']
);
// 결제데이터 셋팅
$toss->setPaymentData([
'amount' => $amount,
'orderId' => $orderId,
'paymentKey' => $paymentKey
]);
$toss->setPaymentHeader();
// 결제승인 요청
$result = $toss->approvePayment();
if ($result) {
// 결제승인 성공시 처리
$status = isset($toss->responseData['status']) ? $toss->responseData['status'] : '';
$method = isset($toss->responseData['method']) ? $toss->responseData['method'] : '';
// 가상계좌(VIRTUAL_ACCOUNT)만 입금대기(WAITING_FOR_DEPOSIT) 상태 값을 가질 수 있음
if ($status === 'DONE' || ($status === 'WAITING_FOR_DEPOSIT' && $method === '가상계좌')) {
// 공통 DB처리 변수 설정
$tno = isset($toss->responseData['paymentKey']) ? $toss->responseData['paymentKey'] : '';
$amount = isset($toss->responseData['totalAmount']) ? $toss->responseData['totalAmount'] : 0;
$escw_yn = $toss->responseData['useEscrow'] === true ? 'Y' : 'N';
$app_time = isset($toss->responseData['approvedAt']) ? date('Y-m-d H:i:s', strtotime($toss->responseData['approvedAt'])) : '';
// 결제수단별 데이터 처리 (카드, 가상계좌, 계좌이체, 휴대폰, 간편결제 순)
if ($method === '카드') {
// 카드
$app_no = $od_app_no = isset($toss->responseData['card']['approveNo']) ? $toss->responseData['card']['approveNo'] : '00000000';
$card_name = isset($toss->cardCode[$toss->responseData['card']['issuerCode']]) ? $toss->cardCode[$toss->responseData['card']['issuerCode']] : '';
} else if ($method === '가상계좌') {
// 가상계좌
$bank_name = $bankname = isset($toss->bankCode[$toss->responseData['virtualAccount']['bankCode']]) ? $toss->bankCode[$toss->responseData['virtualAccount']['bankCode']] : '';
$depositor = isset($toss->responseData['virtualAccount']['customerName']) ? $toss->responseData['virtualAccount']['customerName'] : '';
$account = isset($toss->responseData['virtualAccount']['accountNumber']) ? $toss->responseData['virtualAccount']['accountNumber'] : '';
} else if ($method === '계좌이체') {
// 계좌이체
$bank_name = isset($toss->bankCode[$toss->responseData['transfer']['bankCode']]) ? $toss->bankCode[$toss->responseData['transfer']['bankCode']] : '';
// 현금영수증 데이터 처리
$cashReceiptType = isset($toss->responseData['cashReceipt']['type']) ? $toss->responseData['cashReceipt']['type'] : '';
$RcptType = $cashReceiptType === '소득공제' ? '1' : ($cashReceiptType === '지출증빙' ? '2' : '0');
$RcptTID = isset($toss->responseData['cashReceipt']['receiptKey']) ? $toss->responseData['cashReceipt']['receiptKey'] : ''; // 현금영수증 TID, 현금영수증 거래인 경우 리턴
$RcptAuthCode = isset($toss->responseData['cashReceipt']['issueNumber']) ? $toss->responseData['cashReceipt']['issueNumber'] : ''; // 현금영수증 승인번호, 현금영수증 거래인 경우 리턴
$RcptReceiptUrl = isset($toss->responseData['cashReceipt']['receiptUrl']) ? $toss->responseData['cashReceipt']['receiptUrl'] : ''; // 현금영수증 URL
// 현금영수증 발급시 1 또는 2 이면
if ($RcptType) {
$pg_receipt_infos['od_cash'] = 1; // 현금영수증 발급인것으로 처리
$pg_receipt_infos['od_cash_no'] = $RcptAuthCode; // 현금영수증 승인번호
$pg_receipt_infos['od_cash_info'] = serialize(array('TID'=>$RcptTID, 'ApplNum'=>$RcptAuthCode, 'receiptUrl'=>$RcptReceiptUrl));
}
} else if ($method === '휴대폰') {
// 휴대폰
$mobile_no = isset($toss->responseData['mobilePhone']['customerMobilePhone']) ? $toss->responseData['mobilePhone']['customerMobilePhone'] : '';
} else if ($method === '간편결제') {
// 간편결제
$provider = isset($toss->responseData['easyPay']['provider']) ? $toss->responseData['easyPay']['provider'] : '';
$card_name = isset($toss->easyPayCode[$provider]) ? $toss->easyPayCode[$provider] : $provider;
}
} else {
if(G5_IS_MOBILE) {
if(isset($_POST['pp_id']) && $_POST['pp_id']) {
$page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.get_session('ss_personalpay_id');
} else {
$page_return_url = G5_SHOP_URL.'/orderform.php';
if(get_session('ss_direct'))
$page_return_url .= '?sw_direct=1';
}
alert($toss->responseData['message'].' 코드 : '.$toss->responseData['code'], $page_return_url);
} else {
alert($toss->responseData['message'].' 코드 : '.$toss->responseData['code'], G5_SHOP_URL.'/orderform.php');
}
}
} else {
alert($toss->responseData['message'].' 코드 : '.$toss->responseData['code'], G5_SHOP_URL);
}

View File

@ -461,7 +461,9 @@ if($od['od_pg'] == 'lg') {
$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);
$hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; $hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
} else if($od['od_pg'] == 'inicis') { } else if($od['od_pg'] == 'toss') {
$hp_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/phone?transactionId='.$od['od_tno'].'&ref=PX\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') {
$hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'nicepay') { } else if($od['od_pg'] == 'nicepay') {
$hp_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=0&TID='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $hp_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=0&TID='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
@ -482,7 +484,9 @@ if($od['od_pg'] == 'lg') {
$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);
$card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; $card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
} else if($od['od_pg'] == 'inicis') { } else if($od['od_pg'] == 'toss') {
$card_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/redirection?transactionId='.$od['od_tno'].'&ref=PX\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') {
$card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'nicepay') { } else if($od['od_pg'] == 'nicepay') {
$card_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=0&TID='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; $card_receipt_script = 'window.open(\'https://npg.nicepay.co.kr/issue/IssueLoader.do?type=0&TID='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
@ -555,7 +559,9 @@ if($od['od_pg'] == 'lg') {
break; break;
} }
$cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');';
} else if($od['od_pg'] == 'inicis') { } else if($od['od_pg'] == 'toss') {
$cash_receipt_script = 'window.open(\'https://dashboard.tosspayments.com/receipt/mids/si_'.$config['cf_lg_mid'].'/orders/'.$od['od_id'].'/cash-receipt?ref=dashboard\',\'receipt\',\'width=430,height=700\');';
} else if($od['od_pg'] == 'inicis') {
$cash = unserialize($od['od_cash_info']); $cash = unserialize($od['od_cash_info']);
$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';
} else if($od['od_pg'] == 'nicepay') { } else if($od['od_pg'] == 'nicepay') {