네이버페이 적용
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
include_once(G5_SHOP_PATH.'/settle_naverpay.inc.php');
|
||||
|
||||
// 보관기간이 지난 상품 삭제
|
||||
cart_item_clean();
|
||||
@ -200,6 +201,9 @@ include_once('./_head.php');
|
||||
<button type="button" onclick="return form_check('buy');" class="btn_submit">주문하기</button>
|
||||
<button type="button" onclick="return form_check('seldelete');" class="btn01">선택삭제</button>
|
||||
<button type="button" onclick="return form_check('alldelete');" class="btn01">비우기</button>
|
||||
<?php if ($naverpay_button_js) { ?>
|
||||
<div class="cart-naverpay"><?php echo $naverpay_request_js.$naverpay_button_js; ?></div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
@ -249,6 +253,15 @@ $(function() {
|
||||
|
||||
});
|
||||
|
||||
function fsubmit_check(f) {
|
||||
if($("input[name^=ct_chk]:checked").size() < 1) {
|
||||
alert("구매하실 상품을 하나이상 선택해 주십시오.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function form_check(act) {
|
||||
var f = document.frmcartlist;
|
||||
var cnt = f.records.value;
|
||||
|
||||
@ -233,6 +233,8 @@ function pg_anchor($anc_id) {
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
include_once(G5_SHOP_PATH.'/settle_naverpay.inc.php');
|
||||
?>
|
||||
|
||||
<?php if($is_orderable) { ?>
|
||||
|
||||
4
shop/naverpay/_common.php
Normal file
4
shop/naverpay/_common.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
define('_SHOP_', true);
|
||||
include_once('../../common.php');
|
||||
?>
|
||||
80
shop/naverpay/naverpay_item.php
Normal file
80
shop/naverpay/naverpay_item.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
include_once(G5_LIB_PATH.'/naverpay.lib.php');
|
||||
|
||||
$query = $_SERVER['QUERY_STRING'];
|
||||
|
||||
$vars = array();
|
||||
|
||||
foreach(explode('&', $query) as $pair) {
|
||||
list($key, $value) = explode('=', $pair);
|
||||
$key = urldecode($key);
|
||||
$value = urldecode($value);
|
||||
$vars[$key][] = $value;
|
||||
}
|
||||
|
||||
$itemIds = $vars['ITEM_ID'];
|
||||
|
||||
if (count($itemIds) < 1) {
|
||||
exit('ITEM_ID 는 필수입니다.');
|
||||
}
|
||||
|
||||
header('Content-Type: application/xml;charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
?>
|
||||
<response>
|
||||
<?php
|
||||
foreach($itemIds as $it_id) {
|
||||
$sql = " select * from {$g5['g5_shop_item_table']} where it_id = '$it_id' ";
|
||||
$it = sql_fetch($sql);
|
||||
if(!$it['it_id'])
|
||||
continue;
|
||||
|
||||
$id = $it['it_id'];
|
||||
$name = $it['it_name'];
|
||||
$description = $it['it_basic'];
|
||||
$price = get_price($it);
|
||||
$image = get_naverpay_item_image_url($it_id);
|
||||
$quantity = get_naverpay_item_stock($it_id);
|
||||
$ca_name = '';
|
||||
$ca_name2 = '';
|
||||
$ca_name3 = '';
|
||||
$returnInfo = get_naverpay_return_info($it['it_seller']);
|
||||
$option = get_naverpay_item_option($it_id, $it['it_option_subject']);
|
||||
|
||||
if($it['ca_id']) {
|
||||
$cat = sql_fetch(" select ca_name from {$g5['g5_shop_category_table']} where ca_id = '{$it['ca_id']}' ");
|
||||
$ca_name = $cat['ca_name'];
|
||||
}
|
||||
if($it['ca_id2']) {
|
||||
$cat = sql_fetch(" select ca_name from {$g5['g5_shop_category_table']} where ca_id = '{$it['ca_id2']}' ");
|
||||
$ca_name2 = $cat['ca_name'];
|
||||
}
|
||||
if($it['ca_id3']) {
|
||||
$cat = sql_fetch(" select ca_name from {$g5['g5_shop_category_table']} where ca_id = '{$it['ca_id3']}' ");
|
||||
$ca_name3 = $cat['ca_name'];
|
||||
}
|
||||
?>
|
||||
<item id="<?php echo $id; ?>">
|
||||
<?php if($it['ec_mall_pid']) { ?>
|
||||
<name><![CDATA[<?php echo $it['ec_mall_pid']; ?>]]></name>
|
||||
<?php } ?>
|
||||
<name><![CDATA[<?php echo $name; ?>]]></name>
|
||||
<url><?php echo G5_SHOP_URL.'/item.php?it_id='.$it_id; ?></url>
|
||||
<description><![CDATA[<?php echo $description; ?>]]></description>
|
||||
<image><?php echo $image; ?></image>
|
||||
<thumb><?php echo $image; ?></thumb>
|
||||
<price><?php echo $price; ?></price>
|
||||
<quantity><?php echo $quantity; ?></quantity>
|
||||
<category>
|
||||
<first id="MJ01"><![CDATA[<?php echo $ca_name; ?>]]></first>
|
||||
<second id="ML01"><![CDATA[<?php echo $ca_name2; ?>]]></second>
|
||||
<third id="MN01"><![CDATA[<?php echo $ca_name3; ?>]]></third>
|
||||
</category>
|
||||
<?php echo $option; ?>
|
||||
<?php echo $returnInfo; ?>
|
||||
</item>
|
||||
<?php
|
||||
}
|
||||
echo('</response>');
|
||||
?>
|
||||
228
shop/naverpay/naverpay_order.php
Normal file
228
shop/naverpay/naverpay_order.php
Normal file
@ -0,0 +1,228 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
include_once(G5_SHOP_PATH.'/settle_naverpay.inc.php');
|
||||
include_once(G5_LIB_PATH.'/naverpay.lib.php');
|
||||
|
||||
if($_POST['naverpay_form'] == 'cart.php') {
|
||||
if(!count($_POST['ct_chk']))
|
||||
return_error2json('구매하실 상품을 하나이상 선택해 주십시오.');
|
||||
|
||||
$s_cart_id = get_session('ss_cart_id');
|
||||
$fldcnt = count($_POST['it_id']);
|
||||
$items = array();
|
||||
|
||||
for($i=0; $i<$fldcnt; $i++) {
|
||||
$ct_chk = $_POST['ct_chk'][$i];
|
||||
|
||||
if(!$ct_chk)
|
||||
continue;
|
||||
|
||||
$it_id = $_POST['it_id'][$i];
|
||||
|
||||
// 장바구니 상품
|
||||
$sql = " select ct_id, it_id, ct_option, io_id, io_type, ct_qty from {$g5['g5_shop_cart_table']} where od_id = '$s_cart_id' and it_id = '$it_id' and ct_status = '쇼핑' order by ct_id asc ";
|
||||
$result = sql_query($sql);
|
||||
|
||||
for($k=0; $row=sql_fetch_array($result); $k++) {
|
||||
$_POST['io_id'][$it_id][] = $row['io_id'];
|
||||
$_POST['io_type'][$it_id][] = $row['io_type'];
|
||||
$_POST['ct_qty'][$it_id][] = $row['ct_qty'];
|
||||
$_POST['io_value'][$it_id][] = $row['ct_option'];
|
||||
}
|
||||
|
||||
if($k > 0)
|
||||
$items[] = $it_id;
|
||||
}
|
||||
|
||||
$_POST['it_id'] = $items;
|
||||
}
|
||||
|
||||
$count = count($_POST['it_id']);
|
||||
if ($count < 1)
|
||||
return_error2json('구매하실 상품을 선택하여 주십시오.');
|
||||
|
||||
$itm_ids = array();
|
||||
$sel_options = array();
|
||||
$sup_options = array();
|
||||
|
||||
if($_POST['naverpay_form'] == 'item.php')
|
||||
$back_uri = '/item.php?it_id='.$_POST['it_id'][0];
|
||||
else if($_POST['naverpay_form'] == 'cart.php')
|
||||
$back_uri = '/cart.php';
|
||||
else
|
||||
$back_uri = '';
|
||||
|
||||
define('NAVERPAY_BACK_URL', G5_SHOP_URL.$back_uri);
|
||||
|
||||
for($i=0; $i<$count; $i++) {
|
||||
$it_id = $_POST['it_id'][$i];
|
||||
$opt_count = count($_POST['io_id'][$it_id]);
|
||||
|
||||
if($opt_count && $_POST['io_type'][$it_id][0] != 0)
|
||||
return_error2json('상품의 선택옵션을 선택해 주십시오.');
|
||||
|
||||
for($k=0; $k<$opt_count; $k++) {
|
||||
if ($_POST['ct_qty'][$it_id][$k] < 1)
|
||||
return_error2json('수량은 1 이상 입력해 주십시오.');
|
||||
}
|
||||
|
||||
// 상품정보
|
||||
$sql = " select * from {$g5['g5_shop_item_table']} where it_id = '$it_id' ";
|
||||
$it = sql_fetch($sql);
|
||||
if(!$it['it_id'])
|
||||
return_error2json('상품정보가 존재하지 않습니다.');
|
||||
|
||||
if(!$it['it_use'] || $it['it_soldout'] || $it['it_tel_inq'])
|
||||
return_error2json($it['it_name'].' 는(은) 구매할 수 없는 상품입니다.');
|
||||
|
||||
// 최소, 최대 수량 체크
|
||||
if($it['it_buy_min_qty'] || $it['it_buy_max_qty']) {
|
||||
$sum_qty = 0;
|
||||
for($k=0; $k<$opt_count; $k++) {
|
||||
if($_POST['io_type'][$it_id][$k] == 0)
|
||||
$sum_qty += $_POST['ct_qty'][$it_id][$k];
|
||||
}
|
||||
|
||||
if($it['it_buy_min_qty'] > 0 && $sum_qty < $it['it_buy_min_qty'])
|
||||
return_error2json($it['it_name'].'의 선택옵션 개수 총합 '.number_format($it['it_buy_min_qty']).'개 이상 주문해 주십시오.');
|
||||
|
||||
if($it['it_buy_max_qty'] > 0 && $sum_qty > $it['it_buy_max_qty'])
|
||||
return_error2json($it['it_name'].'의 선택옵션 개수 총합 '.number_format($it['it_buy_max_qty']).'개 이하로 주문해 주십시오.');
|
||||
}
|
||||
|
||||
// 옵션정보를 얻어서 배열에 저장
|
||||
$opt_list = array();
|
||||
$sql = " select * from {$g5['g5_shop_item_option_table']} where it_id = '$it_id' order by io_no asc ";
|
||||
$result = sql_query($sql);
|
||||
$lst_count = 0;
|
||||
for($k=0; $row=sql_fetch_array($result); $k++) {
|
||||
$opt_list[$row['io_type']][$row['io_id']]['id'] = $row['io_id'];
|
||||
$opt_list[$row['io_type']][$row['io_id']]['use'] = $row['io_use'];
|
||||
$opt_list[$row['io_type']][$row['io_id']]['price'] = $row['io_price'];
|
||||
$opt_list[$row['io_type']][$row['io_id']]['stock'] = $row['io_stock_qty'];
|
||||
|
||||
// 선택옵션 개수
|
||||
if(!$row['io_type'])
|
||||
$lst_count++;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
// 재고 검사
|
||||
//--------------------------------------------------------
|
||||
for($k=0; $k<$opt_count; $k++) {
|
||||
$io_id = $_POST['io_id'][$it_id][$k];
|
||||
$io_type = $_POST['io_type'][$it_id][$k];
|
||||
$io_value = $_POST['io_value'][$it_id][$k];
|
||||
|
||||
// 재고 구함
|
||||
$ct_qty = $_POST['ct_qty'][$it_id][$k];
|
||||
if(!$io_id)
|
||||
$it_stock_qty = get_it_stock_qty($it_id);
|
||||
else
|
||||
$it_stock_qty = get_option_stock_qty($it_id, $io_id, $io_type);
|
||||
|
||||
if ($ct_qty > $it_stock_qty)
|
||||
{
|
||||
return_error2json($io_value." 의 재고수량이 부족합니다.\\n\\n현재 재고수량 : " . number_format($it_stock_qty) . " 개");
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------
|
||||
|
||||
$itm_ids[] = $it_id;
|
||||
|
||||
for($k=0; $k<$opt_count; $k++) {
|
||||
$io_id = $_POST['io_id'][$it_id][$k];
|
||||
$io_type = $_POST['io_type'][$it_id][$k];
|
||||
$io_value = $_POST['io_value'][$it_id][$k];
|
||||
|
||||
// 선택옵션정보가 존재하는데 선택된 옵션이 없으면 건너뜀
|
||||
if($lst_count && $io_id == '')
|
||||
continue;
|
||||
|
||||
// 구매할 수 없는 옵션은 건너뜀
|
||||
if($io_id && !$opt_list[$io_type][$io_id]['use'])
|
||||
continue;
|
||||
|
||||
$io_price = $opt_list[$io_type][$io_id]['price'];
|
||||
$ct_qty = $_POST['ct_qty'][$it_id][$k];
|
||||
|
||||
$it_price = get_price($it);
|
||||
|
||||
// 구매가격이 음수인지 체크
|
||||
if($io_type) {
|
||||
if((int)$io_price <= 0)
|
||||
return_error2json('구매금액이 음수 또는 0원인 상품은 구매할 수 없습니다.');
|
||||
} else {
|
||||
if((int)$it_price + (int)$io_price <= 0)
|
||||
return_error2json('구매금액이 음수 또는 0원인 상품은 구매할 수 없습니다.');
|
||||
}
|
||||
|
||||
// 배송비결제
|
||||
if($it['it_sc_type'] == 1)
|
||||
$ct_send_cost = 2; // 무료
|
||||
else if($it['it_sc_type'] > 1 && $it['it_sc_method'] == 1)
|
||||
$ct_send_cost = 1; // 착불
|
||||
|
||||
// 옵션정보배열에 저장
|
||||
$options[$it_id][] = array(
|
||||
'option' => $io_value,
|
||||
'price' => $io_price,
|
||||
'qty' => $ct_qty,
|
||||
'send_cost' => $ct_send_cost,
|
||||
'type' => $io_type,
|
||||
'io_id' => $io_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$order = new naverpay_register($options, $ct_send_cost);
|
||||
$query = $order->query();
|
||||
$totalPrice = $order->total_price;
|
||||
|
||||
//echo $query.'<br>'.PHP_EOL;
|
||||
|
||||
$nc_sock = @fsockopen($req_addr, $req_port, $errno, $errstr);
|
||||
if ($nc_sock) {
|
||||
fwrite($nc_sock, $buy_req_url."\r\n" );
|
||||
fwrite($nc_sock, "Host: ".$req_host.":".$req_port."\r\n" );
|
||||
fwrite($nc_sock, "Content-type: application/x-www-form-urlencoded; charset=utf-8\r\n");
|
||||
fwrite($nc_sock, "Content-length: ".strlen($query)."\r\n");
|
||||
fwrite($nc_sock, "Accept: */*\r\n");
|
||||
fwrite($nc_sock, "\r\n");
|
||||
fwrite($nc_sock, $query."\r\n");
|
||||
fwrite($nc_sock, "\r\n");
|
||||
|
||||
// get header
|
||||
while(!feof($nc_sock)) {
|
||||
$header=fgets($nc_sock,4096);
|
||||
if($header=="\r\n") {
|
||||
break;
|
||||
} else {
|
||||
$headers .= $header;
|
||||
}
|
||||
}
|
||||
// get body
|
||||
while(!feof($nc_sock)) {
|
||||
$bodys.=fgets($nc_sock,4096);
|
||||
}
|
||||
|
||||
fclose($nc_sock);
|
||||
|
||||
$resultCode = substr($headers,9,3);
|
||||
if ($resultCode == 200) {
|
||||
// success
|
||||
$orderId = $bodys;
|
||||
} else {
|
||||
// fail
|
||||
return_error2json($bodys);
|
||||
}
|
||||
} else {
|
||||
//echo "$errstr ($errno)<br>\n";
|
||||
return_error2json($errstr ($errno));
|
||||
exit(-1);
|
||||
//에러처리
|
||||
}
|
||||
|
||||
if($resultCode == 200)
|
||||
die(json_encode(array('error'=>'', 'ORDER_ID'=>$orderId, 'SHOP_ID'=>$default['de_naverpay_mid'], 'TOTAL_PRICE'=>$totalPrice)));
|
||||
?>
|
||||
112
shop/naverpay/naverpay_wish.php
Normal file
112
shop/naverpay/naverpay_wish.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
include_once(G5_SHOP_PATH.'/settle_naverpay.inc.php');
|
||||
include_once(G5_LIB_PATH.'/naverpay.lib.php');
|
||||
|
||||
$count = count($_POST['it_id']);
|
||||
if ($count < 1)
|
||||
alert_close('찜하실 상품을 선택하여 주십시오.');
|
||||
|
||||
$query = '';
|
||||
$item = '';
|
||||
|
||||
for($i=0; $i<$count; $i++) {
|
||||
$it_id = $_POST['it_id'][$i];
|
||||
|
||||
// 상품정보
|
||||
$sql = " select * from {$g5['g5_shop_item_table']} where it_id = '$it_id' ";
|
||||
$it = sql_fetch($sql);
|
||||
if(!$it['it_id'])
|
||||
alert_close('상품정보가 존재하지 않습니다.');
|
||||
|
||||
$id = urlencode($it['it_id']);
|
||||
$name = urlencode($it['it_name']);
|
||||
$description = urlencode($it['it_basic']);
|
||||
$price = get_price($it);
|
||||
$image = urlencode(get_naverpay_item_image_url($it_id));
|
||||
$item_url = urlencode($g5_shop_base_url.'/item.php?it_id='.$it_id);
|
||||
|
||||
$item .= '&ITEM_ID='.$id;
|
||||
if($it['ec_mall_pid'])
|
||||
$item .= '&EC_MALL_PID='.urlencode($it['ec_mall_pid']);
|
||||
$item .= '&ITEM_NAME='.$name;
|
||||
$item .= '&ITEM_DESC='.$description;
|
||||
$item .= '&ITEM_UPRICE='.$price;
|
||||
$item .= '&ITEM_IMAGE='.$image;
|
||||
$item .= '&ITEM_THUMB='.$image;
|
||||
$item .= '&ITEM_URL='.$item_url;
|
||||
}
|
||||
|
||||
if($item) {
|
||||
$query .= 'SHOP_ID='.urlencode($default['de_naverpay_mid']);
|
||||
$query .= '&CERTI_KEY='.urlencode($default['de_naverpay_cert_key']);
|
||||
$query .= $item;
|
||||
}
|
||||
|
||||
$nc_sock = @fsockopen($req_addr, $req_port, $errno, $errstr);
|
||||
if ($nc_sock) {
|
||||
fwrite($nc_sock, $wish_req_url."\r\n" );
|
||||
fwrite($nc_sock, "Host: ".$req_host.":".$req_port."\r\n" );
|
||||
fwrite($nc_sock, "Content-type: application/x-www-form-urlencoded; charset=utf-8\r\n");
|
||||
fwrite($nc_sock, "Content-length: ".strlen($query)."\r\n");
|
||||
fwrite($nc_sock, "Accept: */*\r\n");
|
||||
fwrite($nc_sock, "\r\n");
|
||||
fwrite($nc_sock, $query."\r\n");
|
||||
fwrite($nc_sock, "\r\n");
|
||||
|
||||
// get header
|
||||
while(!feof($nc_sock)) {
|
||||
$header=fgets($nc_sock,4096);
|
||||
if($header=="\r\n") {
|
||||
break;
|
||||
} else {
|
||||
$headers .= $header;
|
||||
}
|
||||
}
|
||||
// get body
|
||||
while(!feof($nc_sock)) {
|
||||
$bodys.=fgets($nc_sock,4096);
|
||||
}
|
||||
|
||||
fclose($nc_sock);
|
||||
|
||||
$resultCode = substr($headers,9,3);
|
||||
|
||||
if ($resultCode == 200) {
|
||||
// success
|
||||
$itemIds = trim($bodys);
|
||||
$itemIdList = explode(',',$itemIds);
|
||||
} else {
|
||||
// fail
|
||||
die($bodys);
|
||||
}
|
||||
} else {
|
||||
echo "$errstr ($errno)<br>\n";
|
||||
exit(-1);
|
||||
//에러처리
|
||||
}
|
||||
|
||||
$count = count($itemIdList);
|
||||
|
||||
if ($resultCode == 200) {
|
||||
?>
|
||||
<html>
|
||||
<body>
|
||||
<form name="frm" method="get" action="<?php echo $wishUrl; ?>">
|
||||
<input type="hidden" name="SHOP_ID" value="<?php echo $default['de_naverpay_mid']; ?>">
|
||||
<?php
|
||||
for($i=0; $i<$count; $i++) {
|
||||
?>
|
||||
<input type="hidden" name="ITEM_ID" value="<?php echo $itemIdList[$i]; ?>">
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
document.frm.target = "_top";
|
||||
document.frm.submit();
|
||||
</script>
|
||||
</html>
|
||||
<?php } ?>
|
||||
149
shop/settle_naverpay.inc.php
Normal file
149
shop/settle_naverpay.inc.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||
|
||||
if(!$is_admin && !$default['de_card_test'] && $default['de_naverpay_test']) {
|
||||
if($default['de_naverpay_mb_id'] && ($is_guest || $member['mb_id'] != $default['de_naverpay_mb_id']))
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$default['de_naverpay_cert_key'] || !$default['de_naverpay_button_key'])
|
||||
return;
|
||||
|
||||
if(basename($_SERVER['SCRIPT_NAME']) == 'item.php') {
|
||||
if(!$is_orderable)
|
||||
return;
|
||||
}
|
||||
|
||||
$naverpay_button_js = '';
|
||||
|
||||
$is_mobile_order = is_mobile();
|
||||
//$is_mobile_order = G5_IS_MOBILE;
|
||||
$naverpay_button_enable = 'Y';
|
||||
|
||||
$naverpay_button_count = 2;
|
||||
if(basename($_SERVER['SCRIPT_NAME']) == 'cart.php')
|
||||
$naverpay_button_count = 1;
|
||||
|
||||
if($is_mobile_order) {
|
||||
if($default['de_naverpay_test'])
|
||||
$naverpay_button_js_url = 'https://test-pay.naver.com/customer/js/mobile/naverPayButton.js';
|
||||
else
|
||||
$naverpay_button_js_url = 'https://pay.naver.com/customer/js/mobile/naverPayButton.js';
|
||||
|
||||
$naverpay_button_js = '<script type="text/javascript" src="'.$naverpay_button_js_url.'" charset="UTF-8"></script>
|
||||
<script type="text/javascript" >//<![CDATA[
|
||||
naver.NaverPayButton.apply({
|
||||
BUTTON_KEY: "'.$default['de_naverpay_button_key'].'", // 네이버페이에서 제공받은 버튼 인증 키 입력
|
||||
TYPE: "MA", // 버튼 모음 종류 설정
|
||||
COLOR: 1, // 버튼 모음의 색 설정
|
||||
COUNT: '.$naverpay_button_count.', // 버튼 개수 설정. 구매하기 버튼만 있으면 1, 찜하기 버튼도 있으면 2를 입력.
|
||||
ENABLE: "'.$naverpay_button_enable.'", // 품절 등의 이유로 버튼 모음을 비활성화할 때에는 "N" 입력
|
||||
BUY_BUTTON_HANDLER : buy_nc, // 구매하기 버튼 이벤트 Handler 함수 등록, 품절인 경우 not_buy_nc 함수 사용
|
||||
WISHLIST_BUTTON_HANDLER : wishlist_nc, // 찜하기 버튼 이벤트 Handler 함수 등록
|
||||
"":""
|
||||
});
|
||||
//]]></script>'.PHP_EOL;
|
||||
} else {
|
||||
$naverpay_button_js = '<script type="text/javascript" src="https://pay.naver.com/customer/js/naverPayButton.js" charset="UTF-8"></script>
|
||||
<script type="text/javascript" >//<![CDATA[
|
||||
naver.NaverPayButton.apply({
|
||||
BUTTON_KEY: "'.$default['de_naverpay_button_key'].'", // 페이에서 제공받은 버튼 인증 키 입력
|
||||
TYPE: "A", // 버튼 모음 종류 설정
|
||||
COLOR: 1, // 버튼 모음의 색 설정
|
||||
COUNT: '.$naverpay_button_count.', // 버튼 개수 설정. 구매하기 버튼만 있으면 1, 찜하기 버튼도 있으면 2를 입력.
|
||||
ENABLE: "'.$naverpay_button_enable.'", // 품절 등의 이유로 버튼 모음을 비활성화할 때에는 "N" 입력
|
||||
BUY_BUTTON_HANDLER : buy_nc, // 구매하기 버튼 이벤트 Handler 함수 등록, 품절인 경우 not_buy_nc 함수 사용
|
||||
WISHLIST_BUTTON_HANDLER : wishlist_nc, // 찜하기 버튼 이벤트 Handler 함수 등록
|
||||
"":""
|
||||
});
|
||||
//]]></script>'.PHP_EOL;
|
||||
}
|
||||
|
||||
$naverpay_button_js .= '<input type="hidden" name="naverpay_form" value="'.basename($_SERVER['SCRIPT_NAME']).'">'.PHP_EOL;
|
||||
|
||||
if($default['de_naverpay_test'] || $default['de_card_test']) {
|
||||
$req_addr = 'ssl://test-pay.naver.com';
|
||||
$buy_req_url = 'POST /customer/api/order.nhn HTTP/1.1';
|
||||
$wish_req_url = 'POST /customer/api/wishlist.nhn HTTP/1.1';
|
||||
$req_host = 'test-pay.naver.com';
|
||||
$req_port = 443;
|
||||
if($is_mobile_order) {
|
||||
$orderUrl = 'https://test-m.pay.naver.com/mobile/customer/order.nhn';
|
||||
$wishUrl = 'https://m.pay.naver.com/mobile/customer/wishList.nhn';
|
||||
} else {
|
||||
$orderUrl = 'https://test-pay.naver.com/customer/order.nhn';
|
||||
$wishUrl = 'https://test-pay.naver.com/customer/wishlistPopup.nhn';
|
||||
}
|
||||
} else {
|
||||
$req_addr = 'ssl://pay.naver.com';
|
||||
$buy_req_url = 'POST /customer/api/order.nhn HTTP/1.1';
|
||||
$wish_req_url = 'POST /customer/api/wishlist.nhn HTTP/1.1';
|
||||
$req_host = 'pay.naver.com';
|
||||
$req_port = 443;
|
||||
if($is_mobile_order) {
|
||||
$orderUrl = 'https://m.pay.naver.com/mobile/customer/order.nhn';
|
||||
$wishUrl = 'https://m.pay.naver.com/mobile/customer/wishList.nhn';
|
||||
} else {
|
||||
$orderUrl = 'https://pay.naver.com/customer/order.nhn';
|
||||
$wishUrl = 'https://pay.naver.com/customer/wishlistPopup.nhn';
|
||||
}
|
||||
}
|
||||
|
||||
define('SHIPPING_ADDITIONAL_PRICE', $default['de_naverpay_sendcost']);
|
||||
|
||||
$naverpay_request_js = '<script type="text/javascript" >//<![CDATA[
|
||||
function buy_nc(url)
|
||||
{
|
||||
var f = $(this).closest("form").get(0);
|
||||
|
||||
var check = fsubmit_check(f);
|
||||
if ( check ) {
|
||||
//네이버페이로 주문 정보를 등록하는 가맹점 페이지로 이동.
|
||||
//해당 페이지에서 주문 정보 등록 후 네이버페이 주문서 페이지로 이동.
|
||||
//location.href=url;
|
||||
|
||||
//var win_buy_nc = window.open("_blank", "win_buy_nc", "scrollbars=yes,width=900,height=700,top=10,left=10");
|
||||
//f.action = "'.G5_SHOP_URL.'/naverpay/naverpay_order.php";
|
||||
//f.target = "win_buy_nc";
|
||||
//f.submit();
|
||||
//return false;
|
||||
|
||||
$.ajax({
|
||||
url : "'.G5_SHOP_URL.'/naverpay/naverpay_order.php",
|
||||
type : "POST",
|
||||
data : $(f).serialize(),
|
||||
async : false,
|
||||
cache : false,
|
||||
dataType : "json",
|
||||
success : function(data) {
|
||||
if(data.error) {
|
||||
alert(data.error);
|
||||
return false;
|
||||
}
|
||||
|
||||
document.location.href = "'.$orderUrl.'?ORDER_ID="+data.ORDER_ID+"&SHOP_ID="+data.SHOP_ID+"&TOTAL_PRICE="+data.TOTAL_PRICE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
function wishlist_nc(url)
|
||||
{
|
||||
var f = $(this).closest("form").get(0);
|
||||
|
||||
// 네이버페이로 찜 정보를 등록하는 가맹점 페이지 팝업 창 생성.
|
||||
// 해당 페이지에서 찜 정보 등록 후 네이버페이 찜 페이지로 이동.
|
||||
'.($is_mobile_order ? '' : 'var win_wishlist_nc = window.open(url,"win_wishlist_nc","scrollbars=yes,width=400,height=267");'.PHP_EOL.'f.target = "win_wishlist_nc";').'
|
||||
f.action = "'.G5_SHOP_URL.'/naverpay/naverpay_wish.php";
|
||||
f.submit();
|
||||
|
||||
return false;
|
||||
}
|
||||
function not_buy_nc()
|
||||
{
|
||||
alert("죄송합니다. 네이버페이로 구매가 불가한 상품입니다.");
|
||||
return false;
|
||||
}
|
||||
//]]></script>'.PHP_EOL;
|
||||
?>
|
||||
Reference in New Issue
Block a user