/home/mjc1/public_html/shop/personalpayformupdate.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
include_once('./_common.php');
include_once(
G5_LIB_PATH.'/mailer.lib.php');

if(
$default['de_pg_service'] == 'lg' && !$_POST['LGD_PAYKEY'])
    
alert('결제등록 요청 후 결제해 주십시오.');

if(
$default['de_pg_service'] == 'inicis' && !$_POST['P_HASH'])
    
alert('결제등록 요청 후 결제해 주십시오.');

// 개인결제 정보
$pp_check false;
$sql " select * from {$g5['g5_shop_personalpay_table']} where pp_id = '{$_POST['pp_id']}' and pp_use = '1' ";
$pp sql_fetch($sql);
if(!
$pp['pp_id'])
    
alert('개인결제 정보가 존재하지 않습니다.');

if(
$pp['pp_tno'])
    
alert('이미 결제하신 개인결제 내역입니다.');

$hash_data md5($_POST['pp_id'].$_POST['good_mny'].$pp['pp_time']);
if(
$_POST['pp_id'] != get_session('ss_personalpay_id') || $hash_data != get_session('ss_personalpay_hash'))
    die(
'개인결제 정보가 올바르지 않습니다.');


if (
$pp_settle_case == "계좌이체")
{
    switch(
$default['de_pg_service']) {
        case 
'lg':
            include 
G5_SHOP_PATH.'/lg/xpay_result.php';
            break;
        case 
'inicis':
            include 
G5_SHOP_PATH.'/inicis/inipay_result.php';
            break;
        case 
'nicepay':
            include 
G5_SHOP_PATH.'/nicepay/nicepay_result.php';
            break;
        default:
            include 
G5_SHOP_PATH.'/kcp/pp_ax_hub.php';
            
$bank_name  iconv("cp949""utf-8"$bank_name);
            break;
    }

    
$pp_tno             $tno;
    
$pp_receipt_price   $amount;
    
$pp_receipt_time    preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/""\\1-\\2-\\3 \\4:\\5:\\6"$app_time);
    
$pp_deposit_name    $pp_name;
    
$pp_bank_account    $bank_name;
    
$pg_price           $amount;
}
else if (
$pp_settle_case == "가상계좌")
{
    switch(
$default['de_pg_service']) {
        case 
'lg':
            include 
G5_SHOP_PATH.'/lg/xpay_result.php';
            break;
        case 
'inicis':
            include 
G5_SHOP_PATH.'/inicis/inipay_result.php';
            break;
        case 
'nicepay':
            include 
G5_SHOP_PATH.'/nicepay/nicepay_result.php';
            
$app_no $vbankNum;
            break;
        default:
            include 
G5_SHOP_PATH.'/kcp/pp_ax_hub.php';
            
$bankname   iconv("cp949""utf-8"$bankname);
            
$depositor  iconv("cp949""utf-8"$depositor);
            break;
    }

    
$pp_tno             $tno;
    
$pp_receipt_price   0;
    
$pp_bank_account    $bankname.' '.$account;
    
$pp_deposit_name    $depositor;
    
$pg_price           $amount;
}
else if (
$pp_settle_case == "휴대폰")
{
    switch(
$default['de_pg_service']) {
        case 
'lg':
            include 
G5_SHOP_PATH.'/lg/xpay_result.php';
            break;
        case 
'inicis':
            include 
G5_SHOP_PATH.'/inicis/inipay_result.php';
            break;
        case 
'nicepay':
            include 
G5_SHOP_PATH.'/nicepay/nicepay_result.php';
            break;
        default:
            include 
G5_SHOP_PATH.'/kcp/pp_ax_hub.php';
            break;
    }

    
$pp_tno             $tno;
    
$pp_receipt_price   $amount;
    
$pp_receipt_time    preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/""\\1-\\2-\\3 \\4:\\5:\\6"$app_time);
    
$pp_bank_account    $commid.' '.$mobile_no;
    
$pg_price           $amount;
}
else if (
$pp_settle_case == "신용카드")
{
    switch(
$default['de_pg_service']) {
        case 
'lg':
            include 
G5_SHOP_PATH.'/lg/xpay_result.php';
            break;
        case 
'inicis':
            include 
G5_SHOP_PATH.'/inicis/inipay_result.php';
            break;
        case 
'nicepay':
            include 
G5_SHOP_PATH.'/nicepay/nicepay_result.php';
            break;
        default:
            include 
G5_SHOP_PATH.'/kcp/pp_ax_hub.php';
            
$card_name  iconv("cp949""utf-8"$card_name);
            break;
    }

    
$pp_tno             $tno;
    
$pp_receipt_price   $amount;
    
$pp_receipt_time    preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/""\\1-\\2-\\3 \\4:\\5:\\6"$app_time);
    
$pp_bank_account    $card_name;
    
$pg_price           $amount;
}
else
{
    die(
"od_settle_case Error!!!");
}

// 주문금액과 결제금액이 일치하는지 체크
if((int)$pp['pp_price'] !== (int)$pg_price) {
    
$cancel_msg '결제금액 불일치';
    switch(
$default['de_pg_service']) {
        case 
'lg':
            include 
G5_SHOP_PATH.'/lg/xpay_cancel.php';
            break;
        case 
'inicis':
            include 
G5_SHOP_PATH.'/inicis/inipay_cancel.php';
            break;
        default:
            include 
G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php';
            break;
    }

    die(
"Receipt Amount Error");
}

$pp_pg $default['de_pg_service'];
$pp_email get_email_address($pp_email);

// 결제정보 입력
$sql " update {$g5['g5_shop_personalpay_table']}
            set pp_email            = '
$pp_email',
                pp_hp               = '
$pp_hp',
                pp_pg               = '
$pp_pg',
                pp_tno              = '
$pp_tno',
                pp_app_no           = '
$app_no',
                pp_receipt_price    = '
$pp_receipt_price',
                pp_settle_case      = '
$pp_settle_case',
                pp_bank_account     = '
$pp_bank_account',
                pp_deposit_name     = '
$pp_deposit_name',
                pp_receipt_time     = '
$pp_receipt_time',
                pp_receipt_ip       = '
{$_SERVER['REMOTE_ADDR']}'
            where pp_id = '
{$pp['pp_id']}' ";
$result sql_query($sqlfalse);

// 결제정보 입력 오류시 결제 취소
if(!$result) {
    
$cancel_msg '결제정보 입력 오류';
    switch(
$default['de_pg_service']) {
        case 
'lg':
            include 
G5_SHOP_PATH.'/lg/xpay_cancel.php';
            break;
        case 
'inicis':
            include 
G5_SHOP_PATH.'/inicis/inipay_cancel.php';
            break;
        default:
            include 
G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php';
            break;
    }

    die(
"<p>$sql<p>" mysql_errno() . " : " .  mysql_error() . "<p>error file : {$_SERVER['SCRIPT_NAME']}");
}

// 주문번호가 있으면 결제정보 반영
if($pp_receipt_price && $pp['pp_id'] && $pp['od_id']) {
    
$od_escrow 0;
    if(
$escw_yn == 'Y')
        
$od_escrow 1;

    
$sql " update {$g5['g5_shop_order_table']}
                set od_receipt_price    = od_receipt_price + '
$pp_receipt_price',
                    od_receipt_time     = '
$pp_receipt_time',
                    od_pg               = '
$pp_pg',
                    od_tno              = '
$pp_tno',
                    od_app_no           = '
$app_no',
                    od_escrow           = '
$od_escrow',
                    od_settle_case      = '
$pp_settle_case',
                    od_deposit_name     = '
$pp_deposit_name',
                    od_bank_account     = '
$pp_bank_account',
                    od_shop_memo = concat(od_shop_memo, \"\\n개인결제 "
.$pp['pp_id']." 로 결제완료 - ".$pp_receipt_time."\")
                where od_id = '
{$pp['od_id']}' ";
    
$result sql_query($sqlfalse);

    
// 결제정보 입력 오류시 결제 취소
    
if(!$result) {
        
$cancel_msg '결제정보 입력 오류';
        switch(
$default['de_pg_service']) {
            case 
'lg':
                include 
G5_SHOP_PATH.'/lg/xpay_cancel.php';
                break;
            case 
'inicis':
            include 
G5_SHOP_PATH.'/inicis/inipay_cancel.php';
            break;
            default:
                include 
G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php';
                break;
        }

        die(
"<p>$sql<p>" mysql_errno() . " : " .  mysql_error() . "<p>error file : {$_SERVER['SCRIPT_NAME']}");
    }

    
// 미수금 정보 업데이트
    
$info get_order_info($pp['od_id']);

    
$sql " update {$g5['g5_shop_order_table']}
                set od_misu     = '
{$info['od_misu']}' ";
    if(
$info['od_misu'] == 0)
        
$sql .= " , od_status = '입금' ";
    
$sql .= " where od_id = '{$pp['od_id']}' ";
    
sql_query($sqlFALSE);

    
// 장바구니 상태변경
    
if($info['od_misu'] == 0) {
        
$sql " update {$g5['g5_shop_cart_table']}
                    set ct_status = '입금'
                    where od_id = '
{$pp['od_id']}' ";
        
sql_query($sqlFALSE);
    }
}

// 개인결제번호제거
set_session('ss_personalpay_id''');
set_session('ss_personalpay_hash''');

$uid md5($pp['pp_id'].$pp['pp_time'].$_SERVER['REMOTE_ADDR']);
set_session('ss_personalpay_uid'$uid);

goto_url(G5_SHOP_URL.'/personalpayresult.php?pp_id='.$pp['pp_id'].'&amp;uid='.$uid);
?>

<html>
    <head>
        <title>개인결제정보 기록</title>
        <script>
            // 결제 중 새로고침 방지 샘플 스크립트 (중복결제 방지)
            function noRefresh()
            {
                /* CTRL + N키 막음. */
                if ((event.keyCode == 78) && (event.ctrlKey == true))
                {
                    event.keyCode = 0;
                    return false;
                }
                /* F5 번키 막음. */
                if(event.keyCode == 116)
                {
                    event.keyCode = 0;
                    return false;
                }
            }

            document.onkeydown = noRefresh ;
        </script>
    </head>
</html>