PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
← All changes | functions/hoock_func.php +970 -1115 1.4.102.12.4 View file →
@@ -1,1125 +1,980 @@
1 -<?php
2 -// Hoock functions
3 -add_action('usces_construct', 'usces_action_acting_construct', 10);
4 -add_action('usces_after_cart_instant', 'usces_action_acting_transaction', 10);
5 -
6 -function usces_action_acting_construct(){
7 -
8 - if(isset($_POST['X-TRANID']) && !isset($_POST['OPT'])){//remise
9 -
10 - $rand = $_POST['X-S_TORIHIKI_NO'];
11 - $datas = usces_get_order_acting_data($rand);
12 - $_GET['uscesid'] = $datas['sesid'];
13 - if( empty($datas['sesid']) ){
14 - usces_log('remise construct : error1', 'acting_transaction.log');
15 - }else{
16 - //usces_auth_order_acting_data($rand);
17 - usces_log('remise construct : '.$_POST['X-TRANID'], 'acting_transaction.log');
18 - usces_set_acting_notification_time( $rand );
19 - }
20 -
21 - }elseif( in_array($_SERVER['REMOTE_ADDR'], array('210.164.6.67', '202.221.139.50')) ){//zeus
22 -
23 - $rand = $_REQUEST['sendpoint'];
24 - $datas = usces_get_order_acting_data($rand);
25 - $_GET['uscesid'] = $datas['sesid'];
26 - if( empty($datas['sesid']) ){
27 - usces_log('zeus construct : error1', 'acting_transaction.log');
28 - }else{
29 - usces_log('zeus construct : '.$_REQUEST['sendpoint'], 'acting_transaction.log');
30 - }
31 -
32 - } elseif( isset($_POST['res_result']) && isset($_POST['res_pay_method']) && isset($_POST['order_id']) ) {//SoftBankPayment
33 -
34 - $datas = usces_get_order_acting_data( $_POST['order_id'] );
35 - $_GET['uscesid'] = $datas['sesid'];
36 - if( empty($datas['sesid']) ) {
37 - usces_log('SoftBankPayment construct : error1', 'acting_transaction.log');
38 - } else {
39 - usces_log('SoftBankPayment construct : '.$_POST['order_id'], 'acting_transaction.log');
40 - }
41 -
42 - } elseif( isset($_POST['SID']) && isset($_POST['FUKA']) && isset($_POST['CVS']) ) {//digitalcheck_conv
43 -
44 - $datas = usces_get_order_acting_data( $_POST['SID'] );
45 - $_GET['uscesid'] = $datas['sesid'];
46 - if( empty($datas['sesid']) ) {
47 - usces_log('digitalcheck construct : error1', 'acting_transaction.log');
48 - } else {
49 - usces_log('digitalcheck construct : '.$_POST['SID'], 'acting_transaction.log');
50 - }
51 -
52 - } elseif( isset($_REQUEST['SiteId']) && isset($_REQUEST['rand']) ) {//AnotherLane
53 -
54 - $datas = usces_get_order_acting_data( $_REQUEST['rand'] );
55 - $_GET['uscesid'] = $datas['sesid'];
56 - if( empty($datas['sesid']) ) {
57 - usces_log('anotherlane construct : error1', 'acting_transaction.log');
58 - } else {
59 - usces_log('anotherlane construct : '.$_REQUEST['rand'], 'acting_transaction.log');
60 - }
61 -
62 - } elseif( isset($_POST['orderId']) and isset($_POST['merchantEncryptionKey']) ) {//Veritrans
63 -
64 - $datas = usces_get_order_acting_data( $_POST['orderId'] );
65 - $_GET['uscesid'] = $datas['sesid'];
66 - if( empty($datas['sesid']) ) {
67 - usces_log('Veritrans construct : error1', 'acting_transaction.log');
68 - } else {
69 - usces_log('Veritrans construct : '.$_POST['orderId'], 'acting_transaction.log');
70 - }
71 - }
72 -}
73 -
74 -function usces_action_acting_transaction(){
75 - global $usces, $wpdb;
76 -
77 - //*** remise_card ***//
78 - if(isset($_POST['X-TRANID']) && !isset($_POST['OPT'])){
79 - foreach( $_POST as $key => $value ){
80 - $data[$key] = mb_convert_encoding($value, 'UTF-8', 'SJIS');
81 - }
82 - usces_log('remise acting_transaction : '.print_r($data, true), 'acting_transaction.log');
83 -
84 - $rand = $_POST['X-S_TORIHIKI_NO'];
85 -// if( empty($rand) ){
86 -// usces_log('remise card error1 : '.print_r($data, true), 'acting_transaction.log');
87 -// die('error1');
88 -// }else{
89 -// $res = usces_check_notification_time( $rand, 15 );
90 -// if( !$res )
91 -// die('error : time over');
92 -// }
93 -//
94 -// if( 0 !== (int)$_POST['X-ERRLEVEL'] ){
95 -// usces_log('remise card error2 : '.print_r($data, true), 'acting_transaction.log');
96 -// die('error2');
97 -// }
98 -
99 - if( '0000000' === substr($rand, 0, 7) ){//card up
100 - usces_log('remise card_update : '.print_r($data, true), 'acting_transaction.log');
101 - if( isset($_POST['X-EXPIRE']) ){
102 - $expire = substr($_POST['X-EXPIRE'], 0, 2) . '/' . substr($_POST['X-EXPIRE'], 2, 2);
103 - $usces->set_member_meta_value('limitofcard', $expire, $_POST['X-AC_S_KAIIN_NO']);
104 - }
105 - if( isset($_POST['X-PARTOFCARD']) )
106 - $usces->set_member_meta_value('partofcard', $_POST['X-PARTOFCARD'], $_POST['X-AC_S_KAIIN_NO']);
107 -
108 -//20120510ysk start
109 - //die('<SDBKDATA>STATUS=800</SDBKDATA>');
110 - $status = (isset($_POST['CARIER_TYPE'])) ? '900' : '800';
111 - die('<SDBKDATA>STATUS='.$status.'</SDBKDATA>');
112 -//20120510ysk end
113 - }
114 -
115 -//20110203ysk start
116 -// $res = $usces->order_processing();
117 -// if( 'error' == $res ){
118 -// usces_log('remise card error3 : '.print_r($data, true), 'acting_transaction.log');
119 -// die('error3');
120 -// }else{
121 - if( isset($_POST['X-PAYQUICKID']) )
122 - $usces->set_member_meta_value('remise_pcid', $_POST['X-PAYQUICKID']);
123 - if( isset($_POST['X-AC_MEMBERID']) )
124 - $usces->set_member_meta_value('remise_memid', $_POST['X-AC_MEMBERID']);
125 -//20120511ysk start
126 - if( isset($_POST['X-EXPIRE']) ) {
127 - $limitofcard = substr($_POST['X-EXPIRE'], 0, 2) . '/' . substr($_POST['X-EXPIRE'], 2, 2);
128 - $usces->set_member_meta_value('limitofcard', $limitofcard);
129 - }
130 - if( isset($_POST['X-PARTOFCARD']) )
131 - $usces->set_member_meta_value('partofcard', $_POST['X-PARTOFCARD']);
132 -//20120511ysk end
133 - usces_log('remise card transaction : '.$_POST['X-TRANID'], 'acting_transaction.log');
134 -//20120510ysk start
135 - //die('<SDBKDATA>STATUS=800</SDBKDATA>');
136 - $status = (isset($_POST['CARIER_TYPE'])) ? '900' : '800';
137 - die('<SDBKDATA>STATUS='.$status.'</SDBKDATA>');
138 -//20120510ysk end
139 -// }
140 -//20110203ysk end
141 -
142 - //*** remise_conv ***//
143 - }elseif( isset($_POST['S_TORIHIKI_NO']) && isset($_POST['REC_FLG']) ){
144 - foreach( $_POST as $key => $value ){
145 - $data[$key] = mb_convert_encoding($value, 'UTF-8', 'SJIS');
146 - }
147 -
148 - $table_name = $wpdb->prefix . "usces_order";
149 - $table_meta_name = $wpdb->prefix . "usces_order_meta";
150 -
151 - $mquery = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_POST['S_TORIHIKI_NO']);
152 - $order_id = $wpdb->get_var( $mquery );
153 - if( $order_id == NULL ){
154 - usces_log('remise conv error1 : '.print_r($data, true), 'acting_transaction.log');
155 - die('error1');
156 - }
157 -
158 - $mquery = $wpdb->prepare("
159 - UPDATE $table_name SET order_status =
160 - CASE
161 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
162 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
163 - ELSE CONCAT('receipted,', order_status )
164 - END
165 - WHERE ID = %d", $order_id);
166 - $res = $wpdb->query( $mquery );
167 - if( $res === false ){
168 - usces_log('remise conv error2 : '.print_r($data, true), 'acting_transaction.log');
169 - die('error2');
170 - }
171 -
172 - $datastr = serialize( $data );
173 - $mquery = $wpdb->prepare(
174 - "UPDATE $table_meta_name SET meta_value = %s WHERE meta_key = %s AND order_id = %d", $datastr, 'settlement_id', $order_id);
175 - $res = $wpdb->query( $mquery );
176 - if( $res === false ){
177 - usces_log('remise conv error3 : '.print_r($data, true), 'acting_transaction.log');
178 - die('error3');
179 - }
180 -
181 - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324
182 -
183 - //usces_send_receipted_mail( $order_id, 'remise_conv' );
184 - usces_log('remise conv transaction : '.$_POST['S_TORIHIKI_NO'], 'acting_transaction.log');
185 - die('<SDBKDATA>STATUS=800</SDBKDATA>');
186 -
187 - //*** zeus_card ***//
188 - }elseif( isset($_REQUEST['acting']) && 'zeus_card' == $_REQUEST['acting'] && isset($_REQUEST['result']) && isset($_REQUEST['ordd']) ){
189 - foreach( $_REQUEST as $key => $value ){
190 - $data[$key] = $value;
191 - }
192 - usces_log('zeus card cgi : '.print_r($data, true), 'acting_transaction.log');
193 -
194 - $rand = $_GET['sendpoint'];
195 - if( empty($rand) ){
196 - usces_log('zeus card error1 : '.print_r($data, true), 'acting_transaction.log');
197 - die('error1');
198 - }
199 -
200 - if( 'OK' == $_REQUEST['result'] ){
201 - $acting_opts = $usces->options['acting_settings']['zeus'];
202 - if( $usces->is_member_logged_in() ) {
203 - if( isset($_GET['cardnumber']) ) {
204 - $usces->set_member_meta_value( 'zeus_partofcard', $_GET['cardnumber'] );
205 - if( 'on' == $acting_opts['quickcharge'] ) {
206 - $usces->set_member_meta_value( 'zeus_pcid', '8888888888888888' );
207 - }
208 - }
209 - }
210 - header("HTTP/1.0 200 OK");
211 - die('zeus');
212 -
213 - }else{
214 - header("HTTP/1.0 200 OK");
215 - die('error3');
216 - }
217 -
218 - //*** zeus_bank ***//
219 - }elseif( isset($_REQUEST['acting']) && 'zeus_bank' == $_REQUEST['acting'] && isset($_REQUEST['order_no']) && isset($_REQUEST['tracking_no']) ){
220 - foreach( $_REQUEST as $key => $value ){
221 - $data[$key] = $value;
222 - }
223 - usces_log('zeus bank cgi data : '.print_r($data,true), 'acting_transaction.log');
224 -
225 -//20130426ysk start 0000701
226 - if( '04' === $_REQUEST['status'] or '05' === $_REQUEST['status'] ) {
227 - usces_log( 'zeus bank error0 : status='.$_REQUEST['status'], 'acting_transaction.log' );
228 - die('error0');
229 - }
230 -//20130426ysk end
231 -
232 - $acting_opts = $usces->options['acting_settings']['zeus'];
233 -
234 - $table_name = $wpdb->prefix . "usces_order";
235 - $table_meta_name = $wpdb->prefix . "usces_order_meta";
236 - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['tracking_no']);
237 - $values = $wpdb->get_row( $mquery, ARRAY_A );
238 -
239 - if( $values == NULL ){
240 -
241 -//20110203ysk start
242 - $res = $usces->order_processing();
243 - if( 'error' == $res ){
244 - usces_log('zeus bank error1 : order_processing', 'acting_transaction.log');
245 - die('error1');
246 - }else{
247 - usces_log('zeus bank order : OK', 'acting_transaction.log');
248 - $order_id = $usces->cart->get_order_entry('ID');
249 - $value = serialize($_GET);
250 - $query = $wpdb->prepare("INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $order_id, 'acting_'.$_REQUEST['tracking_no'], $value);
251 - $res = $wpdb->query( $query );
252 -
253 - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['tracking_no']);
254 - $values = $wpdb->get_row( $mquery, ARRAY_A );
255 - $usces->cart->crear_cart();
256 - }
257 -//20110203ysk end
258 - }
259 -
260 - //usces_log('zeus construct_values2 : '.print_r($values,true), 'acting_transaction.log');
261 - $value = unserialize($values['meta_value']);
262 - $status = ( '03' === $_REQUEST['status'] ) ? 'receipted,' : 'noreceipt,';
263 - $order_id = $values['order_id'];
264 - //$add_point = true;//20120306ysk 0000324
265 - if( 'receipted,' == $status ){
266 - $mquery = $wpdb->prepare("
267 - UPDATE $table_name SET order_status =
268 - CASE
269 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
270 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
271 - ELSE CONCAT('receipted,', order_status )
272 - END
273 - WHERE ID = %d", $order_id);
274 - }else{
275 - $mquery = $wpdb->prepare("
276 - UPDATE $table_name SET order_status =
277 - CASE
278 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
279 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
280 - ELSE CONCAT('noreceipt,', order_status )
281 - END
282 - WHERE ID = %d", $order_id);
283 - //$add_point = false;//20120306ysk 0000324
284 - }
285 - $res = $wpdb->query( $mquery );
286 - if( false === $res ){
287 - //usces_log('zeus bank error2 : '.print_r($data, true), 'acting_transaction.log');
288 - usces_log('zeus bank error2 : update usces_order', 'acting_transaction.log');
289 - die('error2');
290 - }
291 - //usces_action_acting_getpoint( $order_id, $add_point );//20120306ysk 0000324
292 - if( '03' === $_REQUEST['status'] ) usces_action_acting_getpoint( $order_id );//20140130ysk
293 -
294 - $upvalue = array( 'acting' => $_GET['acting'], 'order_no' => $_GET['order_no'], 'tracking_no' => $_GET['tracking_no'], 'status' => $_GET['status'], 'error_message' => $_GET['error_message'], 'money' => $_GET['money'] );
295 - $mquery = $wpdb->prepare("UPDATE $table_meta_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s", serialize($upvalue), $order_id, 'acting_'.$_REQUEST['tracking_no']);
296 - //usces_log('mquery2 : '.print_r($mquery, true), 'acting_transaction.log');
297 - $res = $wpdb->query( $mquery );
298 - if(!$res){
299 - //usces_log('zeus bank error3 : '.print_r($data, true), 'acting_transaction.log');
300 - usces_log('zeus bank error3 : update usces_order_meta', 'acting_transaction.log');
301 - die('error3');
302 - }
303 -
304 - usces_log('zeus bank transaction : '.$_REQUEST['tracking_no'], 'acting_transaction.log');
305 - die('zeus');
306 -
307 - //*** zeus_conv ***//
308 - }elseif( isset($_REQUEST['acting']) && 'zeus_conv' == $_REQUEST['acting'] && isset($_REQUEST['status']) && isset($_REQUEST['sendpoint']) ){
309 - foreach( $_REQUEST as $key => $value ){
310 - $data[$key] = $value;
311 - }
312 - usces_log('zeus conv cgi data : '.print_r($data,true), 'acting_transaction.log');
313 -
314 - $acting_opts = $usces->options['acting_settings']['zeus'];
315 -
316 - $table_name = $wpdb->prefix . "usces_order";
317 - $table_meta_name = $wpdb->prefix . "usces_order_meta";
318 - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['sendpoint']);
319 - $values = $wpdb->get_row( $mquery, ARRAY_A );
320 - if( $values == NULL ){
321 -
322 -//20110203ysk start
323 -/* $res = $usces->order_processing();
324 -
325 - if( 'error' == $res ){
326 - usces_log('zeus conv error1 : '.print_r($data, true), 'acting_transaction.log');
327 - die('error1');
328 - }else{
329 - $order_id = $usces->cart->get_order_entry('ID');
330 - $value = serialize($_GET);
331 - $query = $wpdb->prepare("INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $order_id, 'acting_'.$_REQUEST['sendpoint'], $value);
332 - $res = $wpdb->query( $query );
333 - usces_log('zeus conv ordered : OK', 'acting_transaction.log');
334 - }*/
335 -//20110203ysk end
336 -
337 - }else{
338 - if( '05' !== $_REQUEST['status'] ) {//20131128ysk 0000794
339 - $value = unserialize($values['meta_value']);
340 - $status = ( '04' === $_REQUEST['status'] ) ? 'receipted,' : 'noreceipt,';
341 - $order_id = $values['order_id'];
342 - //$add_point = true;//20120306ysk 0000324
343 - if( 'receipted,' == $status ){
344 - $mquery = $wpdb->prepare("
345 - UPDATE $table_name SET order_status =
346 - CASE
347 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
348 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
349 - ELSE CONCAT('receipted,', order_status )
350 - END
351 - WHERE ID = %d", $order_id);
352 - }else{
353 - $mquery = $wpdb->prepare("
354 - UPDATE $table_name SET order_status =
355 - CASE
356 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
357 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
358 - ELSE CONCAT('noreceipt,', order_status )
359 - END
360 - WHERE ID = %d", $order_id);
361 - //$add_point = false;//20120306ysk 0000324
362 - }
363 - $res = $wpdb->query( $mquery );
364 - if(!$res){
365 - usces_log('zeus conv error2 : '.print_r($data, true), 'acting_transaction.log');
366 - die('error2');
367 - }
368 -
369 - foreach( $_GET as $key => $v ){
370 - $newvalue[$key] = mb_convert_encoding($v, 'UTF-8', 'SJIS');
371 - }
372 - $value = serialize($newvalue);
373 - $mquery = $wpdb->prepare("UPDATE $table_meta_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s", $value, $order_id, 'acting_'.$_REQUEST['sendpoint']);
374 - $res = $wpdb->query( $mquery );
375 - if(!$res){
376 - usces_log('zeus conv error3 : '.print_r($data, true), 'acting_transaction.log');
377 - die('error3');
378 - }
379 - //usces_action_acting_getpoint( $order_id, $add_point );//20120306ysk 0000324
380 - if( '04' === $_REQUEST['status'] ) usces_action_acting_getpoint( $order_id );//20140130ysk
381 - }
382 - }
383 -
384 - usces_log('zeus conv transaction : '.$_REQUEST['sendpoint'], 'acting_transaction.log');
385 - die('zeus');
386 -
387 -//20101018ysk start
388 - //*** jpayment_card ***//
389 - } elseif(isset($_REQUEST['acting']) && 'jpayment_card' == $_REQUEST['acting']) {
390 - //$args='';
391 - //foreach((array)$_GET as $key => $value) {
392 - // $args.='&('.$key.')=('.$value.')';
393 - //}
394 - //usces_log('jpayment card : '.$args, 'acting_transaction.log');
395 -
396 - //*** jpayment_conv ***//
397 - } elseif(isset($_REQUEST['acting']) && 'jpayment_conv' == $_REQUEST['acting'] && isset($_GET['ap'])) {
398 - //$args='';
399 - //foreach((array)$_GET as $key => $value) {
400 - // $args.='&('.$key.')=('.$value.')';
401 - //}
402 - //usces_log('jpayment conv : '.$args, 'acting_transaction.log');
403 - foreach( $_REQUEST as $key => $value ){
404 - $data[$key] = $value;
405 - }
406 -
407 - switch($_GET['ap']) {
408 - case 'CPL_PRE'://コンビニペーパーレス決済識別コード
409 - break;
410 -
411 - case 'CPL'://入金確定
412 - $table_name = $wpdb->prefix."usces_order";
413 - $table_meta_name = $wpdb->prefix."usces_order_meta";
414 -
415 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']);
416 - $order_id = $wpdb->get_var($query);
417 - if($order_id == NULL) {
418 - usces_log('jpayment conv error1 : '.print_r($data, true), 'acting_transaction.log');
419 - die('error1');
420 - }
421 -
422 - $query = $wpdb->prepare("
423 - UPDATE $table_name SET order_status =
424 - CASE
425 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
426 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
427 - ELSE CONCAT('receipted,', order_status )
428 - END
429 - WHERE ID = %d", $order_id);
430 - $res = $wpdb->query($query);
431 - if($res === false) {
432 - usces_log('jpayment conv error2 : '.print_r($data, true), 'acting_transaction.log');
433 - die('error2');
434 - }
435 -
436 - foreach($_GET as $key => $value) {
437 - $data[$key] = esc_sql($value);
438 - }
439 - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id);
440 - if($res === false) {
441 - usces_log('jpayment conv error3 : '.print_r($data, true), 'acting_transaction.log');
442 - die('error3');
443 - }
444 -
445 - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324
446 -
447 - usces_log('J-Payment conv transaction : '.$_GET['gid'], 'acting_transaction.log');
448 - die('J-Payment');
449 - break;
450 -
451 - case 'CVS_CAN'://入金取消
452 - $table_name = $wpdb->prefix."usces_order";
453 - $table_meta_name = $wpdb->prefix."usces_order_meta";
454 -
455 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']);
456 - $order_id = $wpdb->get_var($query);
457 - if($order_id == NULL) {
458 - usces_log('jpayment conv error1 : '.print_r($data, true), 'acting_transaction.log');
459 - die('error1');
460 - }
461 -
462 - $query = $wpdb->prepare("
463 - UPDATE $table_name SET order_status =
464 - CASE
465 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
466 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
467 - ELSE CONCAT('noreceipt,', order_status )
468 - END
469 - WHERE ID = %d", $order_id);
470 - $res = $wpdb->query($query);
471 - if($res === false) {
472 - usces_log('jpayment conv error2 : '.print_r($data, true), 'acting_transaction.log');
473 - die('error2');
474 - }
475 -
476 - foreach($_GET as $key => $value) {
477 - $data[$key] = esc_sql($value);
478 - }
479 - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id);
480 - if($res === false) {
481 - usces_log('jpayment conv error3 : '.print_r($data, true), 'acting_transaction.log');
482 - die('error3');
483 - }
484 -
485 - usces_action_acting_getpoint( $order_id, false );//20120306ysk 0000324
486 -
487 - usces_log('J-Payment conv transaction : '.$_GET['gid'], 'acting_transaction.log');
488 - die('J-Payment');
489 - break;
490 - }
491 -
492 - //*** jpayment_bank ***//
493 - } elseif(isset($_REQUEST['acting']) && 'jpayment_bank' == $_REQUEST['acting']) {
494 - //$args='';
495 - //foreach((array)$_GET as $key => $value) {
496 - // $args.='&('.$key.')=('.$value.')';
497 - //}
498 - //usces_log('jpayment bank : '.$args, 'acting_transaction.log');
499 - foreach( $_REQUEST as $key => $value ){
500 - $data[$key] = $value;
501 - }
502 -
503 - switch($_GET['ap']) {
504 - case 'BANK'://受付完了
505 - break;
506 -
507 - case 'BAN_SAL'://入金完了
508 - if($_GET['mf'] == '1') {//入金マッチングの場合
509 - $table_name = $wpdb->prefix."usces_order";
510 - $table_meta_name = $wpdb->prefix."usces_order_meta";
511 -
512 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']);
513 - $order_id = $wpdb->get_var($query);
514 - if($order_id == NULL) {
515 - usces_log('jpayment bank error1 : '.print_r($data, true), 'acting_transaction.log');
516 - die('error1');
517 - }
518 -
519 - $query = $wpdb->prepare("
520 - UPDATE $table_name SET order_status =
521 - CASE
522 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
523 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
524 - ELSE CONCAT('receipted,', order_status )
525 - END
526 - WHERE ID = %d", $order_id);
527 - $res = $wpdb->query($query);
528 - if($res === false) {
529 - usces_log('jpayment bank error2 : '.print_r($data, true), 'acting_transaction.log');
530 - die('error2');
531 - }
532 -
533 - foreach($_GET as $key => $value) {
534 - $data[$key] = esc_sql($value);
535 - }
536 - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id);
537 - if($res === false) {
538 - usces_log('jpayment bank error3 : '.print_r($data, true), 'acting_transaction.log');
539 - die('error3');
540 - }
541 -
542 - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324
543 - }
544 -
545 - usces_log('J-Payment bank transaction : '.$_REQUEST['gid'], 'acting_transaction.log');
546 - die('J-Payment');
547 - break;
548 - }
549 -//20101018ysk end
550 - //*** epsilon ***//
551 - }elseif( !isset($_GET['acting_return']) && isset($_GET['trans_code']) && isset($_GET['user_id']) && isset($_GET['result']) && isset($_GET['order_number']) ){
552 - $query = 'trans_code=' . $_GET['trans_code'] . '&user_id=' . $_GET['user_id'] . '&result=' . $_GET['result'] . '&order_number=' . $_GET['order_number'];
553 - usces_log('epsilon (acting_transaction) : ' . $query, 'acting_transaction.log');
554 - $permalink_structure = get_option('permalink_structure');
555 - $delim = ( !$usces->use_ssl && $permalink_structure) ? '?' : '&';
556 -
557 - header('location: ' . USCES_CART_URL . $delim . 'acting=epsilon&acting_return=1&' . $query );
558 - exit;
559 -//20110208ysk start
560 - } elseif( !isset($_GET['acting_return']) && (isset($_GET['acting']) && 'paypal_ipn' == $_GET['acting']) ) {
561 - foreach( $_REQUEST as $key => $value ){
562 - $data[$key] = $value;
563 - }
564 - usces_log('paypal_ipn in '.print_r($data,true), 'acting_transaction.log');
565 - require_once($usces->options['settlement_path'] . 'paypal.php');
566 - $ipn_res = paypal_ipn_check($usces_paypal_url);
567 - if( $ipn_res[0] === true ){
568 - $res = $usces->order_processing( $ipn_res );
569 - if( 'ordercompletion' == $res ){
570 - $usces->cart->crear_cart();
571 - }else{
572 - usces_log('paypal_ipn error : '.print_r($data, true), 'acting_transaction.log');
573 - die('error1');
574 - }
575 - do_action('usces_action_paypal_ipn', $res, $ipn_res);
576 - }
577 - usces_log('PayPal IPN transaction : '.$_REQUEST['txn_id'], 'acting_transaction.log');
578 - die('PayPal');
579 -//20110523ysk start
580 - //*** paypal ipn ***//
581 - } elseif( isset($_REQUEST['ipn_track_id']) ) {//20131121ysk
582 - foreach( $_REQUEST as $key => $value ){
583 - $data[$key] = $value;
584 - }
585 - usces_log('paypal ipn : '.print_r($data, true), 'acting_transaction.log');
586 -//20140908ysk start
587 - //*** PayPal Webpayment Plus ***//
588 - if( isset($_POST['txn_type']) && 'pro_hosted' == $_POST['txn_type'] ) {
589 - $acting_opts = $usces->options['acting_settings']['paypal_wpp'];
590 - $key = isset( $_POST['custom'] ) ? $_POST['custom'] : '';
591 - usces_log( serialize($data), 'db', 'paypal_ipn', $key );
592 - $ipn_res = usces_paypal_ipn_check( $acting_opts['host_url'] );
593 - if( $ipn_res[0] === true ) {
594 - $order_id = $ipn_res['order_id'];
595 - usces_restore_order_acting_data( $order_id );
1 +<?php
2 +/**
3 + * Hoock functions.
4 + *
5 + * @package Welcart
6 + */
7 +
8 +add_action( 'usces_construct', 'usces_action_acting_construct', 10 );
9 +add_action( 'usces_after_cart_instant', 'usces_action_acting_transaction', 10 );
10 +// A3 (Layer 3 / uscesid removal): restore the shopper's cart/entry for settlement notifications
11 +// from the transaction-keyed DB store, uscesid-independently. Must run after usces_session_start()
12 +// (constructor end) and before usces_main()'s `new usces_cart()`, hence the usces_main hook.
13 +add_action( 'usces_main', 'usces_restore_acting_session_from_store', 1 );
14 +
15 +/**
16 + * Settlement Result Notification Processing.
17 + * usces_construct
18 + */
19 +function usces_action_acting_construct() {
20 + /* remise */
21 + if ( isset( $_POST['X-TRANID'] ) && ! isset( $_POST['OPT'] ) ) {
22 +
23 + $rand = wp_unslash( $_POST['X-S_TORIHIKI_NO'] );
24 + $datas = array();
25 + /* 決済成功の時のみセッション復帰 */
26 + if ( 0 == $_POST['X-ERRLEVEL'] ) {
27 + $datas = usces_get_order_acting_data( $rand );
28 + // A3: uscesid ブリッジは廃止。セッション復元は usces_restore_acting_session_from_store()(usces_main)で DBストアから実施.
29 + if ( empty( $datas['sesid'] ) ) {
30 + /* sesidが無い場合はファイルログのみ */
31 + usces_log( 'remise construct : error1', 'acting_transaction.log' );
32 + } else {
33 + /* 復帰できた場合のログ */
34 + usces_log( 'remise construct OK : ' . wp_unslash( $_POST['X-TRANID'] ), 'acting_transaction.log' );
35 + }
36 + }
37 +
38 + /* digitalcheck_conv */
39 + } elseif ( isset( $_POST['SID'] ) && isset( $_POST['FUKA'] ) && isset( $_POST['CVS'] ) ) {
40 +
41 + $sid = wp_unslash( $_POST['SID'] );
42 + $datas = usces_get_order_acting_data( $sid );
43 + // A3: uscesid ブリッジは廃止。セッション復元は usces_restore_acting_session_from_store()(usces_main)で DBストアから実施.
44 + if ( empty( $datas['sesid'] ) ) {
45 + $log = array(
46 + 'acting' => 'digitalcheck',
47 + 'key' => $sid,
48 + 'result' => 'SESSION ERROR',
49 + 'data' => wp_unslash( $_POST ),
50 + );
51 + usces_save_order_acting_error( $log );
52 + usces_log( 'digitalcheck construct : error1', 'acting_transaction.log' );
53 + } else {
54 + usces_log( 'digitalcheck construct : ' . $sid, 'acting_transaction.log' );
55 + }
56 +
57 + /* AnotherLane */
58 + } elseif ( isset( $_REQUEST['SiteId'] ) && isset( $_REQUEST['rand'] ) ) {
59 +
60 + $rand = wp_unslash( $_REQUEST['rand'] );
61 + $datas = usces_get_order_acting_data( $rand );
62 + // A3: uscesid ブリッジは廃止。セッション復元は usces_restore_acting_session_from_store()(usces_main)で DBストアから実施.
63 + if ( empty( $datas['sesid'] ) ) {
64 + $log = array(
65 + 'acting' => 'anotherlane',
66 + 'key' => $rand,
67 + 'result' => 'SESSION ERROR',
68 + 'data' => wp_unslash( $_REQUEST ),
69 + );
70 + usces_save_order_acting_error( $log );
71 + usces_log( 'anotherlane construct : error1', 'acting_transaction.log' );
72 + } else {
73 + usces_log( 'anotherlane construct : ' . $rand, 'acting_transaction.log' );
74 + }
75 +
76 + /* Veritrans */
77 + } elseif ( isset( $_POST['orderId'] ) && isset( $_POST['merchantEncryptionKey'] ) ) {
78 +
79 + $orderid = wp_unslash( $_POST['orderId'] );
80 + $datas = usces_get_order_acting_data( $orderid );
81 + // A3: uscesid ブリッジは廃止($_GET['uscesid'] を読む処理は撤廃済みのため代入は無意味だった)。
82 + // ベリトランス Air-Web は選択可能な決済から除外済み(settlement.class.php)のため、DBストアからの
83 + // セッション復元(usces_restore_acting_session_from_store)の対象外とする.
84 + if ( empty( $datas['sesid'] ) ) {
85 + $log = array(
86 + 'acting' => 'veritrans',
87 + 'key' => $orderid,
88 + 'result' => 'SESSION ERROR',
89 + 'data' => wp_unslash( $_POST ),
90 + );
91 + usces_save_order_acting_error( $log );
92 + usces_log( 'Veritrans construct : error1', 'acting_transaction.log' );
93 + } else {
94 + usces_log( 'Veritrans construct : ' . $orderid, 'acting_transaction.log' );
95 + }
96 + }
97 +}
98 +
99 +/**
100 + * 決済通知(サーバー間・ブラウザ Cookie 無し)で、確定時に保存したカート/エントリを DBストア
101 + * (usces_access)から $_SESSION へ復元する。uscesid セッション橋渡しの置き換え(Layer 3 / A3)。
102 + *
103 + * usces_session_start()(コンストラクタ末尾)より後・usces_main() の `new usces_cart()` より前に
104 + * 実行する必要があるため usces_main フックに登録する(construct では直後の @session_start() に
105 + * 上書きされてしまうため)。復元後、usces_cart 生成 → usces_after_cart_instant
106 + * (usces_action_acting_transaction)が $usces->cart->get_cart() を参照して処理する。
107 + *
108 + * 対象はサーバー間通知でセッション復元が要る remise / digitalcheck_conv / AnotherLane。
109 + *
110 + * usces_main
111 + */
112 +function usces_restore_acting_session_from_store() {
113 + $rand = '';
114 + if ( isset( $_POST['X-TRANID'] ) && ! isset( $_POST['OPT'] ) && isset( $_POST['X-S_TORIHIKI_NO'] ) ) {
115 + /* remise: 決済成功時(X-ERRLEVEL == 0)のみ復元 */
116 + if ( isset( $_POST['X-ERRLEVEL'] ) && 0 == $_POST['X-ERRLEVEL'] ) {
117 + $rand = wp_unslash( $_POST['X-S_TORIHIKI_NO'] );
118 + }
119 + } elseif ( isset( $_POST['SID'] ) && isset( $_POST['FUKA'] ) && isset( $_POST['CVS'] ) ) {
120 + /* digitalcheck_conv */
121 + $rand = wp_unslash( $_POST['SID'] );
122 + } elseif ( isset( $_REQUEST['SiteId'] ) && isset( $_REQUEST['rand'] ) ) {
123 + /* AnotherLane: 通知は $_REQUEST(GET/POST 両様)。旧 usces_action_acting_construct の
124 + * $_GET['uscesid']=$datas['sesid'] ブリッジの置き換え。KickType サーバー通知で order_processing()
125 + * がカートを読む前にここで DBストアから復元する。 */
126 + $rand = wp_unslash( $_REQUEST['rand'] );
127 + }
128 +
129 + if ( '' === $rand ) {
130 + return;
131 + }
132 +
133 + $datas = usces_get_order_acting_data( $rand );
134 + if ( empty( $datas ) || empty( $datas['order_data'] ) ) {
135 + return;
136 + }
137 +
138 + $order_data = wel_safe_maybe_unserialize( $datas['order_data'] );
139 + if ( ! is_array( $order_data ) ) {
140 + return;
141 + }
142 +
143 + if ( isset( $order_data['cart'] ) && is_array( $order_data['cart'] ) ) {
144 + /*
145 + * DBストア(usces_access)の cart は save_order_acting_data() が保存した
146 + * $usces->cart->get_cart() の「出力形式」= [ i => array( serial, post_id, sku, options,
147 + * price, unit_price, quantity, advance ) ](インデックス配列)。
148 + * 一方 $_SESSION['usces_cart'] の「内部形式」は
149 + * [ '<serial>' => array( 'price', 'unit_price', 'quant', 'advance' ) ](serial をキーにしたマップ)で、
150 + * usces_cart::get_cart()/key_unserialize() はこの内部形式を前提に読む
151 + * (キー=serial/数量キーは 'quant')。そのまま代入すると整数キー 0 が serial として
152 + * unserialize され false → array_keys(false) で致命的エラーになるため、内部形式へ変換して復元する。
153 + */
154 + $session_cart = array();
155 + foreach ( $order_data['cart'] as $item ) {
156 + if ( ! is_array( $item ) || ! isset( $item['serial'] ) ) {
157 + continue;
158 + }
159 + $session_cart[ $item['serial'] ] = array(
160 + 'price' => isset( $item['price'] ) ? $item['price'] : 0,
161 + 'unit_price' => isset( $item['unit_price'] ) ? $item['unit_price'] : 0,
162 + 'quant' => isset( $item['quantity'] ) ? $item['quantity'] : 0,
163 + 'advance' => isset( $item['advance'] ) ? $item['advance'] : '',
164 + );
165 + }
166 + $_SESSION['usces_cart'] = $session_cart;
167 + }
168 + if ( isset( $order_data['entry'] ) ) {
169 + $_SESSION['usces_entry'] = $order_data['entry'];
170 + }
171 + usces_log( 'acting session restored from DB store (uscesid-independent) : ' . $rand, 'acting_transaction.log' );
172 +}
173 +
174 +/**
175 + * 決済結果通知の送信元IPが許可リストに含まれるか判定する。
176 + *
177 + * @param string $remote_addr Source IP address of the notification.
178 + * @param array|string $allowed Allowed IP addresses / CIDR ranges.
179 + * @return bool True when the source IP is allowed.
180 + */
181 +function usces_acting_notice_ip_allowed( $remote_addr, $allowed ) {
182 + if ( empty( $remote_addr ) || empty( $allowed ) ) {
183 + return false;
184 + }
185 + $remote_long = ip2long( $remote_addr );
186 + if ( false === $remote_long ) {
187 + return false;
188 + }
189 + foreach ( (array) $allowed as $entry ) {
190 + $entry = trim( (string) $entry );
191 + if ( '' === $entry ) {
192 + continue;
193 + }
194 + if ( false !== strpos( $entry, '/' ) ) {
195 + list( $subnet, $bits ) = explode( '/', $entry, 2 );
196 + $subnet_long = ip2long( $subnet );
197 + $bits = (int) $bits;
198 + if ( false === $subnet_long || $bits < 1 || 32 < $bits ) {
199 + continue;
200 + }
201 + $mask = ( 0xFFFFFFFF << ( 32 - $bits ) ) & 0xFFFFFFFF;
202 + if ( ( $remote_long & $mask ) === ( $subnet_long & $mask ) ) {
203 + return true;
204 + }
205 + } elseif ( ip2long( $entry ) === $remote_long ) {
206 + return true;
207 + }
208 + }
209 + return false;
210 +}
211 +
212 +/**
213 + * Settlement Result Notification Processing.
214 + * usces_after_cart_instant
215 + */
216 +function usces_action_acting_transaction() {
217 + global $usces, $wpdb;
218 +
219 + /* remise_card */
220 + if ( isset( $_POST['X-TRANID'] ) && ! isset( $_POST['OPT'] ) ) {
221 + $data = array();
222 + foreach ( $_POST as $key => $value ) {
223 + $data[ $key ] = mb_convert_encoding( $value, 'UTF-8', 'SJIS' );
224 + }
225 + /* 決済エラーの場合は、エラーログを残してdie */
226 + if ( 0 != $data['X-ERRLEVEL'] ) {
227 + $log = array(
228 + 'acting' => 'remise_card',
229 + 'key' => $data['S_TORIHIKI_NO'],
230 + 'result' => $data['X-ERRCODE'],
231 + 'data' => $data,
232 + );
233 + usces_save_order_acting_error( $log );
234 + $status = ( isset( $_POST['CARIER_TYPE'] ) ) ? '900' : '800';
235 + die( '<SDBKDATA>STATUS=' . $status . '</SDBKDATA>' );
236 + }
237 + usces_log( 'remise acting_transaction : ' . print_r( $data, true ), 'acting_transaction.log' );
238 +
239 + $rand = wp_unslash( $_POST['X-S_TORIHIKI_NO'] );
240 +
241 + /* カード情報更新 */
242 + if ( '0000000' === substr( $rand, 0, 7 ) ) { /* card up */
243 + usces_log( 'remise card_update : ' . print_r( $data, true ), 'acting_transaction.log' );
244 + if ( isset( $_POST['X-AC_S_KAIIN_NO'] ) ) {
245 + if ( isset( $_POST['X-EXPIRE'] ) ) {
246 + $expire = wp_unslash( $_POST['X-EXPIRE'] );
247 + $limitofcard = substr( $expire, 0, 2 ) . '/' . substr( $expire, 2, 2 );
248 + $usces->set_member_meta_value( 'limitofcard', $limitofcard, wp_unslash( $_POST['X-AC_S_KAIIN_NO'] ) );
249 + }
250 + if ( isset( $_POST['X-PARTOFCARD'] ) ) {
251 + $usces->set_member_meta_value( 'partofcard', wp_unslash( $_POST['X-PARTOFCARD'] ), wp_unslash( $_POST['X-AC_S_KAIIN_NO'] ) );
252 + }
253 + } elseif ( isset( $_POST['X-PAYQUICKID'] ) ) {
254 + $member_id = substr( $rand, 7 );
255 + if ( $member_id ) {
256 + $usces->set_member_meta_value( 'remise_pcid', wp_unslash( $_POST['X-PAYQUICKID'] ), (int) $member_id );
257 + if ( isset( $_POST['X-EXPIRE'] ) ) {
258 + $expire = wp_unslash( $_POST['X-EXPIRE'] );
259 + $limitofcard = substr( $expire, 0, 2 ) . '/' . substr( $expire, 2, 2 );
260 + $usces->set_member_meta_value( 'limitofcard', $limitofcard, (int) $member_id );
261 + }
262 + if ( isset( $_POST['X-PARTOFCARD'] ) ) {
263 + $usces->set_member_meta_value( 'partofcard', wp_unslash( $_POST['X-PARTOFCARD'] ), (int) $member_id );
264 + }
265 + }
266 + }
267 +
268 + $status = ( isset( $_POST['CARIER_TYPE'] ) ) ? '900' : '800';
269 + die( '<SDBKDATA>STATUS=' . $status . '</SDBKDATA>' );
270 + }
271 +
272 + $cart = $usces->cart->get_cart();
273 + /* カートが無い(セッションが無い)場合、エラーログを残し、ルミーズにはerrorを返却 */
274 + if ( empty( $cart ) ) {
275 + usces_log( 'remise card error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
276 + $log = array(
277 + 'acting' => 'remise',
278 + 'key' => wp_unslash( $_POST['X-S_TORIHIKI_NO'] ),
279 + 'result' => 'SESSION TIME OUT',
280 + 'data' => wp_unslash( $_POST ),
281 + );
282 + usces_save_order_acting_error( $log );
283 + die( 'SESSION TIME OUT' );
284 +
285 + /* セッションが存在する場合は、STATUSを返却 */
286 + } else {
287 + if ( isset( $_POST['X-PAYQUICKID'] ) ) {
288 + $usces->set_member_meta_value( 'remise_pcid', wp_unslash( $_POST['X-PAYQUICKID'] ) );
289 + }
290 + if ( isset( $_POST['X-AC_MEMBERID'] ) ) {
291 + $usces->set_member_meta_value( 'remise_memid', wp_unslash( $_POST['X-AC_MEMBERID'] ) );
292 + }
293 + if ( isset( $_POST['X-EXPIRE'] ) ) {
294 + $expire = wp_unslash( $_POST['X-EXPIRE'] );
295 + $limitofcard = substr( $expire, 0, 2 ) . '/' . substr( $expire, 2, 2 );
296 + $usces->set_member_meta_value( 'limitofcard', $limitofcard );
297 + }
298 + if ( isset( $_POST['X-PARTOFCARD'] ) ) {
299 + $usces->set_member_meta_value( 'partofcard', wp_unslash( $_POST['X-PARTOFCARD'] ) );
300 + }
301 + usces_log( 'remise card transaction : ' . wp_unslash( $_POST['X-TRANID'] ), 'acting_transaction.log' );
302 + $status = ( isset( $_POST['CARIER_TYPE'] ) ) ? '900' : '800';
303 + die( '<SDBKDATA>STATUS=' . $status . '</SDBKDATA>' );
304 + }
305 +
306 + /* remise_conv */
307 + } elseif ( isset( $_POST['S_TORIHIKI_NO'] ) && isset( $_POST['REC_FLG'] ) ) {
308 + $data = array();
309 + foreach ( $_POST as $key => $value ) {
310 + $data[ $key ] = mb_convert_encoding( $value, 'UTF-8', 'SJIS' );
311 + }
312 + REMISE_SETTLEMENT::get_instance()->acting_notice_ip_guard( $data );
313 +
314 + $table_name = $wpdb->prefix . 'usces_order';
315 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
316 +
317 + $mquery = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', wp_unslash( $_POST['S_TORIHIKI_NO'] ) );
318 + $order_id = $wpdb->get_var( $mquery );
319 + if ( null == $order_id ) {
320 + $log = array(
321 + 'acting' => 'remise_conv',
322 + 'key' => wp_unslash( $_POST['S_TORIHIKI_NO'] ),
323 + 'result' => 'ORDER DATA KEY ERROR',
324 + 'data' => wp_unslash( $_POST ),
325 + );
326 + usces_save_order_acting_error( $log );
327 + usces_log( 'remise conv error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
328 + die( 'error1' );
329 + }
330 +
331 + $res = usces_change_order_receipt( $order_id, 'receipted' );
332 + if ( false === $res ) {
333 + $log = array(
334 + 'acting' => 'remise_conv',
335 + 'key' => wp_unslash( $_POST['S_TORIHIKI_NO'] ),
336 + 'result' => 'ORDER DATA UPDATE ERROR',
337 + 'data' => wp_unslash( $_POST ),
338 + );
339 + usces_save_order_acting_error( $log );
340 + usces_log( 'remise conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
341 + die( 'error2' );
342 + }
343 +
344 + $datastr = serialize( $data );
345 + $mquery = $wpdb->prepare( "UPDATE $table_meta_name SET meta_value = %s WHERE meta_key = %s AND order_id = %d", $datastr, 'settlement_id', $order_id );
346 + $res = $wpdb->query( $mquery );
347 + if ( false === $res ) {
348 + $log = array(
349 + 'acting' => 'remise_conv',
350 + 'key' => wp_unslash( $_POST['S_TORIHIKI_NO'] ),
351 + 'result' => 'ORDER META DATA UPDATE ERROR',
352 + 'data' => wp_unslash( $_POST ),
353 + );
354 + usces_save_order_acting_error( $log );
355 + usces_log( 'remise conv error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
356 + die( 'error3' );
357 + }
358 +
359 + usces_action_acting_getpoint( $order_id );
360 +
361 + usces_log( 'remise conv transaction : ' . wp_unslash( $_POST['S_TORIHIKI_NO'] ), 'acting_transaction.log' );
362 + die( '<SDBKDATA>STATUS=800</SDBKDATA>' );
363 +
364 + /* jpayment_card */
365 + } elseif ( isset( $_REQUEST['acting'] ) && 'jpayment_card' == $_REQUEST['acting'] ) {
366 +
367 + /* jpayment_conv */
368 + } elseif ( isset( $_REQUEST['acting'] ) && 'jpayment_conv' == $_REQUEST['acting'] && isset( $_GET['ap'] ) ) {
369 + switch ( $_GET['ap'] ) {
370 + case 'CPL_PRE': /* コンビニペーパーレス決済識別コード */
371 + break;
372 +
373 + case 'CPL': /* 入金確定 */
374 + JPAYMENT_SETTLEMENT::get_instance()->acting_notice_ip_guard();
375 + $acting = wp_unslash( $_REQUEST['acting'] );
376 + $data = array();
377 + foreach ( $_GET as $key => $value ) {
378 + $data[ $key ] = esc_sql( $value );
379 + }
380 + $cod = ( isset( $data['cod'] ) ) ? $data['cod'] : '';
381 +
382 + $table_name = $wpdb->prefix . 'usces_order';
383 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
384 +
385 + $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $cod );
386 + $order_id = $wpdb->get_var( $query );
387 + if ( null == $order_id ) {
388 + $log = array(
389 + 'acting' => $acting,
390 + 'key' => $cod,
391 + 'result' => 'ORDER DATA KEY ERROR',
392 + 'data' => $data,
393 + );
394 + usces_save_order_acting_error( $log );
395 + usces_log( 'ROBOT PAYMENT conv error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
396 + die( 'error1' );
397 + }
398 +
399 + $res = usces_change_order_receipt( $order_id, 'receipted' );
400 + if ( false === $res ) {
401 + $log = array(
402 + 'acting' => $acting,
403 + 'key' => $cod,
404 + 'result' => 'ORDER DATA UPDATE ERROR',
405 + 'data' => $data,
406 + );
407 + usces_save_order_acting_error( $log );
408 + usces_log( 'ROBOT PAYMENT conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
409 + die( 'error2' );
410 + }
411 +
412 + $res = $usces->set_order_meta_value( 'acting_' . $acting, serialize( $data ), $order_id );
413 + if ( false === $res ) {
414 + $log = array(
415 + 'acting' => $acting,
416 + 'key' => $cod,
417 + 'result' => 'ORDER META DATA UPDATE ERROR',
418 + 'data' => $data,
419 + );
420 + usces_save_order_acting_error( $log );
421 + usces_log( 'ROBOT PAYMENT conv error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
422 + die( 'error3' );
423 + }
424 +
425 + usces_action_acting_getpoint( $order_id );
426 +
427 + usces_log( 'ROBOT PAYMENT conv transaction : ' . $data['gid'], 'acting_transaction.log' );
428 + die( 'ROBOT PAYMENT' );
429 + break;
430 +
431 + case 'CVS_CAN': /* 入金取消 */
432 + JPAYMENT_SETTLEMENT::get_instance()->acting_notice_ip_guard();
433 + $acting = wp_unslash( $_REQUEST['acting'] );
434 + $data = array();
435 + foreach ( $_GET as $key => $value ) {
436 + $data[ $key ] = esc_sql( $value );
437 + }
438 + $cod = ( isset( $data['cod'] ) ) ? $data['cod'] : '';
439 +
440 + $table_name = $wpdb->prefix . 'usces_order';
441 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
442 +
443 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'settlement_id', $cod );
444 + $order_id = $wpdb->get_var( $query );
445 + if ( null == $order_id ) {
446 + $log = array(
447 + 'acting' => $acting,
448 + 'key' => $cod,
449 + 'result' => 'ORDER DATA KEY ERROR',
450 + 'data' => $data,
451 + );
452 + usces_save_order_acting_error( $log );
453 + usces_log( 'ROBOT PAYMENT conv error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
454 + die( 'error1' );
455 + }
456 +
457 + $res = usces_change_order_receipt( $order_id, 'noreceipt' );
458 + if ( false === $res ) {
459 + $log = array(
460 + 'acting' => $acting,
461 + 'key' => $cod,
462 + 'result' => 'ORDER DATA UPDATE ERROR',
463 + 'data' => $data,
464 + );
465 + usces_save_order_acting_error( $log );
466 + usces_log( 'ROBOT PAYMENT conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
467 + die( 'error2' );
468 + }
469 +
470 + $res = $usces->set_order_meta_value( 'acting_' . $acting, serialize( $data ), $order_id );
471 + if ( false === $res ) {
472 + $log = array(
473 + 'acting' => $acting,
474 + 'key' => $cod,
475 + 'result' => 'ORDER META DATA UPDATE ERROR',
476 + 'data' => $data,
477 + );
478 + usces_save_order_acting_error( $log );
479 + usces_log( 'ROBOT PAYMENT conv error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
480 + die( 'error3' );
481 + }
482 +
483 + usces_action_acting_getpoint( $order_id, false );
484 +
485 + usces_log( 'ROBOT PAYMENT conv transaction : ' . $data['gid'], 'acting_transaction.log' );
486 + die( 'ROBOT PAYMENT' );
487 + break;
488 + }
489 +
490 + /* jpayment_bank */
491 + } elseif ( isset( $_REQUEST['acting'] ) && 'jpayment_bank' == $_REQUEST['acting'] && isset( $_GET['ap'] ) ) {
492 + switch ( $_GET['ap'] ) {
493 + case 'BANK': /* 受付完了 */
494 + break;
495 +
496 + case 'BAN_SAL': /* 入金完了 */
497 + JPAYMENT_SETTLEMENT::get_instance()->acting_notice_ip_guard();
498 + if ( isset( $_GET['mf'] ) && '1' == wp_unslash( $_GET['mf'] ) ) { /* 入金マッチングの場合 */
499 + $acting = wp_unslash( $_REQUEST['acting'] );
500 + $data = array();
501 + foreach ( $_GET as $key => $value ) {
502 + $data[ $key ] = esc_sql( $value );
503 + }
504 + $cod = ( isset( $data['cod'] ) ) ? $data['cod'] : '';
505 +
506 + $table_name = $wpdb->prefix . 'usces_order';
507 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
508 +
509 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'settlement_id', $cod );
510 + $order_id = $wpdb->get_var( $query );
511 + if ( null == $order_id ) {
512 + $log = array(
513 + 'acting' => $acting,
514 + 'key' => $cod,
515 + 'result' => 'ORDER DATA KEY ERROR',
516 + 'data' => $data,
517 + );
518 + usces_save_order_acting_error( $log );
519 + usces_log( 'ROBOT PAYMENT bank error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
520 + die( 'error1' );
521 + }
522 +
523 + $res = usces_change_order_receipt( $order_id, 'receipted' );
524 + if ( false === $res ) {
525 + $log = array(
526 + 'acting' => $acting,
527 + 'key' => $cod,
528 + 'result' => 'ORDER DATA UPDATE ERROR',
529 + 'data' => $data,
530 + );
531 + usces_save_order_acting_error( $log );
532 + usces_log( 'ROBOT PAYMENT bank error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
533 + die( 'error2' );
534 + }
535 +
536 + $res = $usces->set_order_meta_value( 'acting_' . $acting, serialize( $data ), $order_id );
537 + if ( false === $res ) {
538 + $log = array(
539 + 'acting' => $acting,
540 + 'key' => $cod,
541 + 'result' => 'ORDER META DATA UPDATE ERROR',
542 + 'data' => $data,
543 + );
544 + usces_save_order_acting_error( $log );
545 + usces_log( 'ROBOT PAYMENT bank error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
546 + die( 'error3' );
547 + }
548 +
549 + usces_action_acting_getpoint( $order_id );
550 + }
551 +
552 + usces_log( 'ROBOT PAYMENT bank transaction : ' . $data['gid'], 'acting_transaction.log' );
553 + die( 'ROBOT PAYMENT' );
554 + break;
555 + }
556 +
557 + /* PayPal ipn */
558 + } elseif ( ! isset( $_GET['acting_return'] ) && ( isset( $_GET['acting'] ) && 'paypal_ipn' == wp_unslash( $_GET['acting'] ) ) ) {
559 + if ( file_exists( $usces->options['settlement_path'] . 'paypal.php' ) ) {
560 + $data = array();
561 + foreach ( $_REQUEST as $key => $value ) {
562 + $data[ $key ] = $value;
563 + }
564 + usces_log( 'paypal_ipn in ' . print_r( $data, true ), 'acting_transaction.log' );
565 + require_once( $usces->options['settlement_path'] . 'paypal.php' );
566 + $ipn_res = paypal_ipn_check( $usces_paypal_url );
567 + if ( true === $ipn_res[0] ) {
568 + $res = $usces->order_processing( $ipn_res );
569 + if ( 'ordercompletion' == $res ) {
570 + $usces->cart->crear_cart();
571 + } else {
572 + usces_log( 'paypal_ipn error : ' . print_r( $data, true ), 'acting_transaction.log' );
573 + die( 'error1' );
574 + }
575 + do_action( 'usces_action_paypal_ipn', $res, $ipn_res );
576 + }
577 + usces_log( 'PayPal IPN transaction : ' . wp_unslash( $_REQUEST['txn_id'] ), 'acting_transaction.log' );
578 + }
579 + die( 'PayPal' );
580 +
581 + /* telecom edy 提供対象外のため無効化. CVE-2026-19887(PHP Object Injection)対応.
582 + } elseif ( isset( $_REQUEST['clientip'] ) && isset( $_REQUEST['sendid'] ) && ( isset( $_REQUEST['acting'] ) && 'telecom_edy' == $_REQUEST['acting'] ) ) {
583 + $data = array();
584 + foreach ( $_REQUEST as $key => $value ) {
585 + $data[ $key ] = $value;
586 + }
587 + usces_log( 'telecom edy : ' . print_r( $data, true ), 'acting_transaction.log' );
588 +
589 + } elseif ( isset( $_REQUEST['clientip'] ) && isset( $_REQUEST['sendid'] ) && isset( $_REQUEST['edy'] ) ) {
590 + $data = array();
591 + foreach ( $_REQUEST as $key => $value ) {
592 + $data[ $key ] = $value;
593 + }
594 + if ( 'yes' === wp_unslash( $_REQUEST['rel'] ) && isset( $_REQUEST['option'] ) ) {
595 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
596 + $mquery = $wpdb->prepare( "SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", wp_unslash( $_REQUEST['option'] ) );
597 + $mvalue = $wpdb->get_row( $mquery, ARRAY_A );
598 + $value = wel_safe_maybe_unserialize( $mvalue['meta_value'] );
599 + $_SESSION['usces_cart'] = $value['usces_cart'];
600 + $_SESSION['usces_entry'] = $value['usces_entry'];
601 + $_SESSION['usces_member'] = $value['usces_member'];
602 + $res = $usces->order_processing();
603 + if ( 'ordercompletion' == $res ) {
604 + $query = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", wp_unslash( $_REQUEST['option'] ) );
605 + $res = $wpdb->query( $query );
606 + usces_log( 'telecom edy - Payment confirmation : ' . print_r( $data, true ), 'acting_transaction.log' );
607 + } else {
608 + $log = array(
609 + 'acting' => 'telecom_edy',
610 + 'key' => wp_unslash( $_REQUEST['option'] ),
611 + 'result' => 'ORDER DATA REGISTERED ERROR',
612 + 'data' => wp_unslash( $_REQUEST ),
613 + );
614 + usces_save_order_acting_error( $log );
615 + usces_log( 'telecom edy - Error 1 : ' . print_r( $data, true ), 'acting_transaction.log' );
616 + }
617 + } else {
618 + $log = array(
619 + 'acting' => 'telecom_edy',
620 + 'key' => wp_unslash( $_REQUEST['option'] ),
621 + 'result' => wp_unslash( $_REQUEST['rel'] ),
622 + 'data' => wp_unslash( $_REQUEST ),
623 + );
624 + usces_save_order_acting_error( $log );
625 + usces_log( 'telecom edy - Error 2 : ' . print_r( $data, true ), 'acting_transaction.log' );
626 + }
627 + die( 'SuccessOK' );
628 + */
629 +
630 + /* telecom credit */
631 + } elseif ( isset( $_REQUEST['clientip'] ) && isset( $_REQUEST['sendid'] ) && isset( $_REQUEST['rel'] ) ) {
632 + $acting_clientip = ( isset( $usces->options['acting_settings']['telecom']['clientip'] ) ) ? (string) $usces->options['acting_settings']['telecom']['clientip'] : '';
633 + if ( '' === $acting_clientip || (string) wp_unslash( $_REQUEST['clientip'] ) !== $acting_clientip ) {
634 + /* 設定済みクライアントIPと一致しない通知は正規のものではないため記録せず終了 */
635 + die( 'SuccessOK' );
636 + }
637 + $data = array();
638 + foreach ( $_REQUEST as $key => $value ) {
639 + $data[ $key ] = $value;
640 + }
641 + if ( 'yes' === wp_unslash( $_REQUEST['rel'] ) && isset( $_REQUEST['option'] ) ) {
642 + } else {
643 + $log = array(
644 + 'acting' => 'telecom_card',
645 + 'key' => wp_unslash( $_REQUEST['option'] ),
646 + 'result' => wp_unslash( $_REQUEST['rel'] ),
647 + 'data' => wp_unslash( $_REQUEST ),
648 + );
649 + usces_save_order_acting_error( $log );
650 + }
651 + usces_log( 'telecom card : ' . print_r( $data, true ), 'acting_transaction.log' );
652 + die( 'SuccessOK' );
653 +
654 + /* digitalcheck card */
655 + } elseif ( isset( $_REQUEST['SID'] ) && isset( $_REQUEST['FUKA'] ) && 'acting_digitalcheck_card' == substr( wp_unslash( $_REQUEST['FUKA'] ), 0, 24 ) ) {
656 + if ( isset( $_GET['acting_return'] ) && isset( $_GET['acting'] ) && 'digitalcheck_card' === $_GET['acting'] ) {
657 + return;
658 + }
659 +
660 + $data = array();
661 + foreach ( $_REQUEST as $key => $value ) {
662 + $data[ $key ] = $value;
663 + }
664 + $sid = ( isset( $data['SID'] ) ) ? $data['SID'] : '';
665 +
666 + if ( isset( $data['SEQ'] ) ) {
667 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
668 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'SID', $sid );
669 + $order_id = $wpdb->get_var( $query );
670 + if ( ! $order_id ) {
671 + $acting_opts = $usces->options['acting_settings']['digitalcheck'];
672 + $ip_user_id = substr( $data['FUKA'], 24 );
673 + if ( 'on' == $acting_opts['card_user_id'] && ! empty( $ip_user_id ) ) {
674 + $usces->set_member_meta_value( 'digitalcheck_ip_user_id', $ip_user_id, $ip_user_id );
675 + }
676 +
596 677 $res = $usces->order_processing();
597 - if( 'ordercompletion' == $res ) {
598 - usces_log( 'PayPal Webpayment Plus : Payment confirmation', 'acting_transaction.log' );
599 - $usces->cart->crear_cart();
678 + if ( 'ordercompletion' == $res ) {
679 + $order_id = $usces->cart->get_order_entry( 'ID' );
680 + $usces->set_order_meta_value( 'acting_digitalcheck_card', serialize( $data ), $order_id );
681 + $usces->set_order_meta_value( 'wc_trans_id', $sid, $order_id );
600 682 } else {
601 - usces_log( 'PayPal Webpayment Plus : Error', 'acting_transaction.log' );
683 + $log = array(
684 + 'acting' => 'digitalcheck_card',
685 + 'key' => $sid,
686 + 'result' => 'ORDER DATA REGISTERED ERROR',
687 + 'data' => wp_unslash( $_REQUEST ),
688 + );
689 + usces_save_order_acting_error( $log );
690 + // usces_log( 'digitalcheck card : order processing error', 'acting_transaction.log' );
602 691 }
603 692 }
604 - exit;
605 -//20140908ysk end
693 +
694 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
695 + die( "0\r\n" );
696 +
697 + } elseif ( isset( $data['purchase'] ) ) {
698 + return;
699 +
606 700 } else {
607 -//20131121ysk start
608 - $table_name = $wpdb->prefix."usces_order";
609 - $table_meta_name = $wpdb->prefix."usces_order_meta";
610 - if( isset($_REQUEST['txn_id']) or isset($_REQUEST['recurring_payment_id']) ) {
611 - if( ( isset($_REQUEST['payment_status']) and 'Completed' == $_REQUEST['payment_status'] ) or
612 - ( isset($_REQUEST['profile_status']) and 'Active' == $_REQUEST['profile_status'] ) ) {
613 - $settlement_id = ( isset($_REQUEST['recurring_payment_id']) ) ? $_REQUEST['recurring_payment_id'] : $_REQUEST['txn_id'];
614 - $query = $wpdb->prepare( "SELECT ID, order_status FROM $table_name INNER JOIN $table_meta_name ON ID = order_id WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $settlement_id );
615 - $order_data = $wpdb->get_row( $query, ARRAY_A );
616 - if( $order_data ) {
617 - if( $usces->is_status( 'pending', $order_data['order_status'] ) ) {
618 - $order_status = str_replace( 'pending', 'receipted', $order_data['order_status'] );
619 - $query = $wpdb->prepare( "UPDATE $table_name SET order_status = %s WHERE ID = %d", $order_status, $order_data['ID'] );
620 - $res = $wpdb->query( $query );
621 - }
622 - do_action( 'usces_action_paypal_ipn_status_completed', $order_data );
701 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
702 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'SID', $sid );
703 + $order_id = $wpdb->get_var( $query );
704 + if ( $order_id ) {
705 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
706 + die( "0\r\n" );
707 + }
708 + }
709 +
710 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
711 + die( "0\r\n" );
712 +
713 + /* digitalcheck conv */
714 + } elseif ( isset( $_REQUEST['SID'] ) && isset( $_REQUEST['FUKA'] ) && 'acting_digitalcheck_conv' == substr( wp_unslash( $_REQUEST['FUKA'] ), 0, 24 ) ) {
715 + if ( isset( $_GET['acting_return'] ) && isset( $_GET['acting'] ) && 'digitalcheck_conv' === $_GET['acting'] ) {
716 + return;
717 + }
718 +
719 + $data = array();
720 + foreach ( $_REQUEST as $key => $value ) {
721 + $data[ $key ] = $value;
722 + }
723 + $sid = ( isset( $data['SID'] ) ) ? $data['SID'] : '';
724 +
725 + if ( isset( $data['SEQ'] ) ) {
726 + DIGITALCHECK_SETTLEMENT::get_instance()->acting_notice_ip_guard( $data );
727 + $table_name = $wpdb->prefix . 'usces_order';
728 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
729 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'SID', $sid );
730 + $order_id = $wpdb->get_var( $query );
731 + if ( null == $order_id ) {
732 + $log = array(
733 + 'acting' => 'digitalcheck_conv',
734 + 'key' => $sid,
735 + 'result' => 'ORDER DATA KEY ERROR',
736 + 'data' => wp_unslash( $_REQUEST ),
737 + );
738 + usces_save_order_acting_error( $log );
739 + usces_log( 'digitalcheck conv error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
740 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
741 + die( "9\r\n" );
742 + }
743 +
744 + if ( isset( $data['CVS'] ) ) { /* 入金 */
745 + $res = usces_change_order_receipt( $order_id, 'receipted' );
746 + if ( false === $res ) {
747 + $log = array(
748 + 'acting' => 'digitalcheck_conv',
749 + 'key' => $sid,
750 + 'result' => 'ORDER DATA UPDATE ERROR',
751 + 'data' => wp_unslash( $_REQUEST ),
752 + );
753 + usces_save_order_acting_error( $log );
754 + usces_log( 'digitalcheck conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
755 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
756 + die( "9\r\n" );
757 + }
758 +
759 + usces_action_acting_getpoint( $order_id );
760 +
761 + } else { /* 取消 */
762 + $res = usces_change_order_receipt( $order_id, 'noreceipt' );
763 + if ( false === $res ) {
764 + $log = array(
765 + 'acting' => 'digitalcheck_conv',
766 + 'key' => $sid,
767 + 'result' => 'ORDER DATA UPDATE ERROR',
768 + 'data' => wp_unslash( $_REQUEST ),
769 + );
770 + usces_save_order_acting_error( $log );
771 + usces_log( 'digitalcheck conv error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
772 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
773 + die( "9\r\n" );
774 + }
775 +
776 + usces_action_acting_getpoint( $order_id, false );
777 + }
778 +
779 + $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
780 +
781 + $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $sid );
782 + $res = $wpdb->query( $dquery );
783 +
784 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
785 + die( "0\r\n" );
786 +
787 + } else {
788 + if ( isset( $data['CVS'] ) && isset( $data['SHNO'] ) ) { /* 決済 */
789 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
790 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'SID', $sid );
791 + $order_id = $wpdb->get_var( $query );
792 + if ( $order_id ) {
793 + $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
794 +
795 + } else {
796 + $res = $usces->order_processing();
797 + if ( 'ordercompletion' == $res ) {
798 + $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
799 + $usces->set_order_meta_value( 'wc_trans_id', $sid, $order_id );
800 + } else {
801 + $log = array(
802 + 'acting' => 'digitalcheck_conv',
803 + 'key' => $sid,
804 + 'result' => 'ORDER DATA REGISTERED ERROR',
805 + 'data' => wp_unslash( $_REQUEST ),
806 + );
807 + usces_save_order_acting_error( $log );
808 + usces_log( 'digitalcheck conv : order processing error', 'acting_transaction.log' );
623 809 }
624 810 }
811 +
812 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
813 + die( "0\r\n" );
814 +
815 + } elseif ( isset( $data['purchase'] ) ) {
816 +
817 + } else {
818 + $permalink_structure = get_option( 'permalink_structure' );
819 + $delim = ( ! $usces->use_ssl && $permalink_structure ) ? '?' : '&';
820 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=digitalcheck_conv&acting_return=1&SID=' . $sid );
821 + exit;
625 822 }
626 -//20131121ysk end
627 - die('PayPal');
628 823 }
629 -//20110523ysk end
630 -//20120413ysk start
631 - //*** SoftBankPayment ***//
632 - } elseif( !isset($_GET['acting_return']) && isset($_POST['res_result']) && isset($_POST['res_pay_method']) ) {
633 - //usces_log('SoftBankPayment : '.print_r($_REQUEST, true), 'acting_transaction.log');
634 - foreach( $_POST as $key => $value ) {
635 - $data[$key] = mb_convert_encoding($value, 'UTF-8', 'SJIS');
636 - }
637 - $acting = $data['free1'];
638 -
639 - switch( $data['res_result'] ) {
640 - case 'OK'://決済処理OK
641 - $table_meta_name = $wpdb->prefix."usces_order_meta";
642 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'res_tracking_id', $data['res_tracking_id']);
643 - $order_id = $wpdb->get_var($query);
644 - if( !$order_id ) {
645 -
646 - $res = $usces->order_processing();
647 - if( 'ordercompletion' == $res ){
648 - //$usces->cart->crear_cart();
649 - } else {
650 - usces_log('SoftBankPayment '.$data['res_pay_method'].' order processing error : '.print_r($data, true), 'acting_transaction.log');
651 - die('NG,order processing error');
652 - }
653 - }
654 -
655 - //$acting_opts = $usces->options['acting_settings']['sbps'];
656 - //if( 'on' == $acting_opts['cust'] ) {
657 - // $usces->set_member_meta_value( 'sbps_cust_no', $data['res_sps_cust_no'], $data['cust_code'] );
658 - // $usces->set_member_meta_value( 'sbps_payment_no', $data['res_sps_payment_no'], $data['cust_code'] );
659 - //}
660 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [OK] transaction : '.$data['res_tracking_id'], 'acting_transaction.log');
661 - die('OK,');
662 - break;
663 -
664 - case 'PY'://入金結果通知
665 - $table_name = $wpdb->prefix."usces_order";
666 - $table_meta_name = $wpdb->prefix."usces_order_meta";
667 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'res_tracking_id', $data['res_tracking_id']);
668 - $order_id = $wpdb->get_var($query);
669 - if( $order_id == NULL ) {
670 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error1 : '.print_r($data, true), 'acting_transaction.log');
671 - die('NG,order_id error');
672 - }
673 -
674 - $query = $wpdb->prepare("
675 - UPDATE $table_name SET order_status =
676 - CASE
677 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
678 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
679 - ELSE CONCAT('receipted,', order_status )
680 - END
681 - WHERE ID = %d", $order_id);
682 - $res = $wpdb->query($query);
683 - if( $res === false ) {
684 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error2 : '.print_r($data, true), 'acting_transaction.log');
685 - die('NG,usces_order update error');
686 - }
687 -
688 - $res = $usces->set_order_meta_value($acting, serialize($data), $order_id);
689 - if( $res === false ) {
690 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error3 : '.print_r($data, true), 'acting_transaction.log');
691 - die('NG,usces_order_meta update error');
692 - }
693 -
694 - usces_action_acting_getpoint( $order_id );
695 -
696 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] transaction : '.$order_id, 'acting_transaction.log');
697 - die('OK,');
698 -
699 - case 'CN'://期限切通知
700 - $table_name = $wpdb->prefix."usces_order";
701 - $table_meta_name = $wpdb->prefix."usces_order_meta";
702 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'res_tracking_id', $data['res_tracking_id']);
703 - $order_id = $wpdb->get_var($query);
704 - if( $order_id == NULL ) {
705 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error1 : '.print_r($data, true), 'acting_transaction.log');
706 - die('NG,order_id error');
707 - }
708 -
709 - $query = $wpdb->prepare("
710 - UPDATE $table_name SET order_status =
711 - CASE
712 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
713 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
714 - ELSE CONCAT('noreceipt,', order_status )
715 - END
716 - WHERE ID = %d", $order_id);
717 - $res = $wpdb->query($query);
718 - if( $res === false ) {
719 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error2 : '.print_r($data, true), 'acting_transaction.log');
720 - die('NG,usces_order update error');
721 - }
722 -
723 - $res = $usces->set_order_meta_value($acting, serialize($data), $order_id);
724 - if( $res === false ) {
725 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error3 : '.print_r($data, true), 'acting_transaction.log');
726 - die('NG,usces_order_meta update error');
727 - }
728 -
729 - //usces_action_acting_getpoint( $order_id, false );
730 -
731 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] transaction : '.$order_id, 'acting_transaction.log');
732 - die('OK,');
733 -
734 - default:
735 - usces_log('SoftBankPayment '.$data['res_pay_method'].' ['.$data['res_result'].'] : '.print_r($data,true), 'acting_transaction.log');
736 - die('OK,');
737 - }
738 -//20120413ysk end
739 -//20121030ysk start
740 - //*** telecom credit ***//
741 - } elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && (isset($_REQUEST['acting']) && 'telecom_edy' == $_REQUEST['acting']) ) {
742 - foreach( $_REQUEST as $key => $value ) {
743 - $data[$key] = $value;
744 - }
745 - usces_log('telecom edy : '.print_r($data, true), 'acting_transaction.log');
746 - //die('SuccessOK');
747 - } elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && isset($_REQUEST['edy']) ) {
748 - foreach( $_REQUEST as $key => $value ) {
749 - $data[$key] = $value;
750 - }
751 - if( $_REQUEST['rel'] === 'yes' && isset($_REQUEST['option']) ) {
752 - $table_meta_name = $wpdb->prefix."usces_order_meta";
753 - $mquery = $wpdb->prepare( "SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", $_REQUEST['option'] );
754 - $mvalue = $wpdb->get_row( $mquery, ARRAY_A );
755 - $value = unserialize( $mvalue['meta_value'] );
756 - $_SESSION['usces_cart'] = $value['usces_cart'];
757 - $_SESSION['usces_entry'] = $value['usces_entry'];
758 - $_SESSION['usces_member'] = $value['usces_member'];
759 - $res = $usces->order_processing();
760 - if( 'ordercompletion' == $res ) {
761 - $query = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $_REQUEST['option'] );
762 - $res = $wpdb->query( $query );
763 - usces_log('telecom edy - Payment confirmation : '.print_r($data, true), 'acting_transaction.log');
764 - } else {
765 - usces_log('telecom edy - Error 1 : '.print_r($data, true), 'acting_transaction.log');
766 - }
767 - } else {
768 - usces_log('telecom edy - Error 2 : '.print_r($data, true), 'acting_transaction.log');
769 - }
770 - die('SuccessOK');
771 -//20121030ysk end
772 -//20120618ysk start
773 - //*** telecom credit ***//
774 - }elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && isset($_REQUEST['rel']) ){
775 - foreach( $_REQUEST as $key => $value ){
776 - $data[$key] = $value;
777 - }
778 - usces_log('telecom card : '.print_r($data, true), 'acting_transaction.log');
779 - die('SuccessOK');
780 -//20120618ysk end
781 -//20121206ysk start
782 - //*** digitalcheck card ***//
783 - } elseif( isset($_REQUEST['SID']) && isset($_REQUEST['FUKA']) && substr($_REQUEST['FUKA'], 0, 24) == 'acting_digitalcheck_card' ) {
784 - foreach( $_REQUEST as $key => $value ) {
785 - $data[$key] = $value;
786 - }
787 - $sid = ( isset($data['SID']) ) ? $data['SID'] : '';
788 -//usces_log('digitalcheck card : '.print_r($data, true), 'digitalcheck.log');
789 -
790 - if( isset($data['SEQ']) ) {
791 - $acting_opts = $usces->options['acting_settings']['digitalcheck'];
792 - $ip_user_id = substr($data['FUKA'], 24);
793 -//usces_log('ip_user_id : '.$ip_user_id, 'digitalcheck.log');
794 - if( 'on' == $acting_opts['card_user_id'] and !empty($ip_user_id) ) {
795 - $usces->set_member_meta_value('digitalcheck_ip_user_id', $ip_user_id, $ip_user_id);
824 +
825 + /* mizuho card */
826 + } elseif ( ( isset( $_GET['p_ver'] ) && '0200' == wp_unslash( $_GET['p_ver'] ) ) && ( isset( $_GET['bkcode'] ) && 'bg01' == wp_unslash( $_GET['bkcode'] ) ) ) {
827 + usces_log( 'mizuho card : ' . print_r( wp_unslash( $_GET ), true ), 'acting_transaction.log' );
828 + $stran = ( array_key_exists( 'stran', $_REQUEST ) ) ? wp_unslash( $_REQUEST['stran'] ) : '';
829 + $mbtran = ( array_key_exists( 'mbtran', $_REQUEST ) ) ? wp_unslash( $_REQUEST['mbtran'] ) : '';
830 + $rsltcd = ( array_key_exists( 'rsltcd', $_REQUEST ) ) ? wp_unslash( $_REQUEST['rsltcd'] ) : '';
831 + $rsltdcd = ( array_key_exists( 'rsltdcd', $_REQUEST ) ) ? wp_unslash( $_REQUEST['rsltdcd'] ) : '';
832 + $permalink_structure = get_option( 'permalink_structure' );
833 + $delim = ( ! $usces->use_ssl && $permalink_structure ) ? '?' : '&';
834 + if ( '108' == substr( $rsltcd, 0, 3 ) || '208' == substr( $rsltcd, 0, 3 ) || '308' == substr( $rsltcd, 0, 3 ) ) { /* キャンセル */
835 + header( 'location: ' . USCES_CART_URL . $delim . 'confirm=1' );
836 + } elseif ( '109' == substr( $rsltcd, 0, 3 ) || '209' == substr( $rsltcd, 0, 3 ) || '309' == substr( $rsltcd, 0, 3 ) ) { /* エラー */
837 + $log = array(
838 + 'acting' => 'mizuho_card',
839 + 'key' => $stran,
840 + 'result' => $rsltcd,
841 + 'data' => wp_unslash( $_GET ),
842 + );
843 + usces_save_order_acting_error( $log );
844 + usces_log( 'mizuho card : ' . print_r( wp_unslash( $_GET ), true ), 'acting_transaction.log' );
845 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=mizuho_card&acting_return=0&rsltdcd=' . $rsltdcd );
846 + } else {
847 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=mizuho_card&acting_return=1&stran=' . $stran . '&mbtran=' . $mbtran . '&rsltcd=' . $rsltcd );
848 + }
849 + die();
850 +
851 + /* mizuho conv 提供対象外のため無効化。
852 + } elseif ( ( isset( $_GET['p_ver'] ) && '0200' == wp_unslash( $_GET['p_ver'] ) ) && ( isset( $_GET['bkcode'] ) && ( 'cv01' == wp_unslash( $_GET['bkcode'] ) || 'cv02' == wp_unslash( $_GET['bkcode'] ) ) ) ) {
853 + usces_log( 'mizuho conv : ' . print_r( $_GET, true ), 'acting_transaction.log' );
854 + $stran = ( array_key_exists( 'stran', $_REQUEST ) ) ? wp_unslash( $_REQUEST['stran'] ) : '';
855 + $mbtran = ( array_key_exists( 'mbtran', $_REQUEST ) ) ? wp_unslash( $_REQUEST['mbtran'] ) : '';
856 + $bktrans = ( array_key_exists( 'bktrans', $_REQUEST ) ) ? wp_unslash( $_REQUEST['bktrans'] ) : '';
857 + $tranid = ( array_key_exists( 'tranid', $_REQUEST ) ) ? wp_unslash( $_REQUEST['tranid'] ) : '';
858 + $tdate = ( array_key_exists( 'tdate', $_REQUEST ) ) ? wp_unslash( $_REQUEST['tdate'] ) : '';
859 + $rsltcd = ( array_key_exists( 'rsltcd', $_REQUEST ) ) ? wp_unslash( $_REQUEST['rsltcd'] ) : '';
860 + $permalink_structure = get_option( 'permalink_structure' );
861 + $delim = ( ! $usces->use_ssl && $permalink_structure ) ? '?' : '&';
862 + if ( '' != $tdate ) { // 入金通知
863 + $data = array();
864 + foreach ( $_REQUEST as $key => $value ) {
865 + $data[ $key ] = $value;
796 866 }
797 -
798 - $res = $usces->order_processing();
799 - if( 'ordercompletion' == $res ) {
800 - $order_id = $usces->cart->get_order_entry('ID');
801 - $usces->set_order_meta_value( 'acting_digitalcheck_card', serialize( $data ), $order_id );
802 - } else {
803 - usces_log('digitalcheck card : order processing error', 'acting_transaction.log');
804 - }
805 -
806 - header('content-type : text/plain;charset=Shift_JIS');
807 - die("0");
808 - }
809 -
810 - //*** digitalcheck conv ***//
811 - } elseif( isset($_REQUEST['SID']) && isset($_REQUEST['FUKA']) && substr($_REQUEST['FUKA'], 0, 24) == 'acting_digitalcheck_conv' ) {
812 - foreach( $_REQUEST as $key => $value ) {
813 - $data[$key] = $value;
814 - }
815 - $sid = ( isset($data['SID']) ) ? $data['SID'] : '';
816 -//usces_log("digitalcheck conv : ".print_r($_REQUEST,true), 'digitalcheck.log');
817 -
818 - if( isset($data['SEQ']) ) {
819 - $table_name = $wpdb->prefix."usces_order";
820 - $table_meta_name = $wpdb->prefix."usces_order_meta";
821 -
822 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $sid );
823 - $order_id = $wpdb->get_var( $query );
824 - if( $order_id == NULL ) {
825 - usces_log( 'digitalcheck conv error1 : '.print_r($data, true), 'acting_transaction.log' );
826 - header('content-type : text/plain;charset=Shift_JIS');
827 - die('9');
828 - }
829 -
830 - if( isset($data['CVS']) ) {//入金
831 - $mquery = $wpdb->prepare("
832 - UPDATE $table_name SET order_status =
833 - CASE
834 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
835 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
836 - ELSE CONCAT('receipted,', order_status )
837 - END
838 - WHERE ID = %d", $order_id );
839 - $res = $wpdb->query( $mquery );
840 - if( $res === false ) {
841 - usces_log('digitalcheck conv error2 : '.print_r($data, true), 'acting_transaction.log');
842 - header('content-type : text/plain;charset=Shift_JIS');
843 - die('9');
844 - }
845 -
846 - usces_action_acting_getpoint( $order_id );
847 -
848 - } else {//取消
849 - $mquery = $wpdb->prepare("
850 - UPDATE $table_name SET order_status =
851 - CASE
852 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
853 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
854 - ELSE CONCAT('noreceipt,', order_status )
855 - END
856 - WHERE ID = %d", $order_id );
857 - $res = $wpdb->query( $mquery );
858 - if( $res === false ) {
859 - usces_log('digitalcheck conv error3 : '.print_r($data, true), 'acting_transaction.log');
860 - header('content-type : text/plain;charset=Shift_JIS');
861 - die('9');
862 - }
863 -
864 - usces_action_acting_getpoint( $order_id, false );
865 - }
866 -
867 - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
868 -
869 - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $sid );
870 - $res = $wpdb->query( $dquery );
871 -
872 - header('content-type : text/plain;charset=Shift_JIS');
873 - die("0");
874 -
875 - } else {
876 - if( isset($data['CVS']) and isset($data['SHNO']) ) {//決済
877 - $table_meta_name = $wpdb->prefix."usces_order_meta";
878 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $sid );
879 - $order_id = $wpdb->get_var($query);
880 - if( $order_id ) {
881 - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
882 -
883 - } else {
884 - $res = $usces->order_processing();
885 - if( 'ordercompletion' == $res ) {
886 - $order_id = $usces->cart->get_order_entry('ID');
887 - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
888 - } else {
889 - usces_log('digitalcheck conv : order processing error', 'acting_transaction.log');
890 - }
891 - }
892 - header('content-type : text/plain;charset=Shift_JIS');
893 - die("0");
894 -
895 - } elseif( isset($data['purchase']) ) {
896 -
897 - } else {
898 - $permalink_structure = get_option('permalink_structure');
899 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
900 - header( 'location: '.USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=1&SID='.$sid );
901 - exit;
902 - }
903 - }
904 -//20121206ysk end
905 -//20130225ysk start
906 - //*** mizuho card ***//
907 - } elseif( ( isset($_GET['p_ver']) && $_GET['p_ver'] == '0200' ) && ( isset($_GET['bkcode']) && $_GET['bkcode'] == 'bg01' ) ) {
908 - //usces_log('mizuho card : '.print_r($_GET,true),'mizuho.log');
909 - $stran = ( array_key_exists('stran', $_REQUEST) ) ? $_REQUEST['stran'] : '';
910 - $mbtran = ( array_key_exists('mbtran', $_REQUEST) ) ? $_REQUEST['mbtran'] : '';
911 - $rsltcd = ( array_key_exists('rsltcd', $_REQUEST) ) ? $_REQUEST['rsltcd'] : '';
912 - $rsltdcd = ( array_key_exists('rsltdcd', $_REQUEST) ) ? $_REQUEST['rsltdcd'] : '';
913 - $permalink_structure = get_option( 'permalink_structure' );
914 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
915 - if( '108' == substr($rsltcd, 0, 3) or '208' == substr($rsltcd, 0, 3) or '308' == substr($rsltcd, 0, 3 ) ) {//キャンセル
916 - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
917 - } elseif( '109' == substr($rsltcd, 0, 3) or '209' == substr($rsltcd, 0, 3) or '309' == substr($rsltcd, 0, 3) ) {//エラー
918 - usces_log( 'mizuho card : '.print_r( $_GET, true ), 'acting_transaction.log' );
919 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_card&acting_return=0&rsltdcd='.$rsltdcd );
920 - } else {
921 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_card&acting_return=1&stran='.$stran.'&mbtran='.$mbtran.'&rsltcd='.$rsltcd );
922 - }
923 - die();
924 -
925 - //*** mizuho conv ***//
926 - } elseif( ( isset($_GET['p_ver']) && $_GET['p_ver'] == '0200' ) && ( isset($_GET['bkcode']) && ( $_GET['bkcode'] == 'cv01' or $_GET['bkcode'] == 'cv02' ) ) ) {
927 - //usces_log('mizuho conv : '.print_r($_GET,true),'mizuho.log');
928 - $stran = ( array_key_exists('stran', $_REQUEST) ) ? $_REQUEST['stran'] : '';
929 - $mbtran = ( array_key_exists('mbtran', $_REQUEST) ) ? $_REQUEST['mbtran'] : '';
930 - $bktrans = ( array_key_exists('bktrans', $_REQUEST) ) ? $_REQUEST['bktrans'] : '';
931 - $tranid = ( array_key_exists('tranid', $_REQUEST) ) ? $_REQUEST['tranid'] : '';
932 - $tdate = ( array_key_exists('tdate', $_REQUEST) ) ? $_REQUEST['tdate'] : '';
933 - $rsltcd = ( array_key_exists('rsltcd', $_REQUEST) ) ? $_REQUEST['rsltcd'] : '';
934 - $permalink_structure = get_option( 'permalink_structure' );
935 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
936 - if( '' != $tdate ) {//入金通知
937 - foreach( $_REQUEST as $key => $value ) {
938 - $data[$key] = $value;
939 - }
940 - if( $rsltcd == "0000000000000" ) {
941 - $table_name = $wpdb->prefix."usces_order";
942 - $table_meta_name = $wpdb->prefix."usces_order_meta";
943 -
944 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'stran', $stran );
945 - $order_id = $wpdb->get_var( $query );
946 - if( $order_id == NULL ) {
947 - usces_log( 'mizuho conv error1 : '.print_r($data, true), 'acting_transaction.log' );
948 -
949 - } else {
950 - $mquery = $wpdb->prepare("
951 - UPDATE $table_name SET order_status =
952 - CASE
953 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
954 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
955 - ELSE CONCAT('receipted,', order_status )
956 - END
957 - WHERE ID = %d", $order_id );
958 - $res = $wpdb->query( $mquery );
959 - if( $res === false ) {
960 - usces_log( 'mizuho conv error2 : '.print_r($data, true), 'acting_transaction.log' );
961 -
962 - } else {
963 - usces_action_acting_getpoint( $order_id );
964 -
965 - $usces->set_order_meta_value( 'acting_mizuho_conv', serialize($data), $order_id );
966 -
967 - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $stran );
968 - $res = $wpdb->query( $dquery );
969 - }
970 - }
971 -
972 - } else {
973 - //header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
974 - usces_log( 'mizuho conv : '.print_r( $_GET, true ), 'acting_transaction.log' );
975 - }
976 -
977 - } elseif( '108' == substr($rsltcd, 0, 3) or '208' == substr($rsltcd, 0, 3) or '308' == substr($rsltcd, 0, 3) ) {//キャンセル
978 - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
979 - } elseif( '109' == substr($rsltcd, 0, 3) or '209' == substr($rsltcd, 0, 3) or '309' == substr($rsltcd, 0, 3) ) {//エラー
980 - usces_log( 'mizuho conv : '.print_r( $_GET, true ), 'acting_transaction.log' );
981 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_card&acting_return=0' );
982 - } else {
983 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_conv&acting_return=1&stran='.$stran.'&mbtran='.$mbtran.'&bktrans='.$_GET['bktrans'].'&tranid='.$tranid.'&rsltcd='.$rsltcd );
984 - }
985 - die();
986 -//20130225ysk end
987 -//20131220ysk start
988 - //*** AnotherLane credit ***//
989 - } elseif( isset($_GET['SiteId']) && isset($_GET['TransactionId']) && isset($_GET['Result']) ) {
990 - $acting_opts = $usces->options['acting_settings']['anotherlane'];
991 - foreach( $_GET as $key => $value ) {
992 - $data[$key] = $value;
993 - }
994 - if( $acting_opts['siteid'] == $_GET['SiteId'] && 'OK' == $_GET['Result'] ) {
995 - $table_meta_name = $wpdb->prefix."usces_order_meta";
996 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'TransactionId', $data['TransactionId'] );
997 - $order_id = $wpdb->get_var( $query );
998 - if( !$order_id ) {
999 - $res = $usces->order_processing();
1000 - if( 'ordercompletion' == $res ) {
1001 - $usces->cart->crear_cart();
1002 - usces_log( 'AnotherLane [OK] transaction : '.$data['TransactionId'], 'acting_transaction.log' );
1003 - } else {
1004 - usces_log( 'AnotherLane order processing error : '.print_r($data, true), 'acting_transaction.log' );
1005 - }
1006 - }
1007 - }
1008 - exit;
1009 -
1010 - } elseif( isset($_GET['ali_back']) && isset($_POST['SiteId']) && isset($_POST['Result']) ) {
1011 - $acting_opts = $usces->options['acting_settings']['anotherlane'];
1012 - if( $acting_opts['siteid'] == $_POST['SiteId'] && 'NG' == $_POST['Result'] ) {
1013 - $permalink_structure = get_option( 'permalink_structure' );
1014 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
1015 - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
1016 - exit;
1017 - } elseif( $acting_opts['siteid'] == $_POST['SiteId'] && 'OK' == $_POST['Result'] ) {
1018 - $permalink_structure = get_option( 'permalink_structure' );
1019 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
1020 - header( 'location: '.USCES_CART_URL.$delim.'acting=anotherlane_card&acting_return=1' );
1021 - exit;
1022 - }
1023 -//20131220ysk end
1024 -//20140206ysk start
1025 - //*** Veritrans card ***//
1026 - } elseif( isset($_GET['acting']) and 'veritrans_card' == $_GET['acting'] and isset($_POST['orderId']) and isset($_POST['merchantEncryptionKey']) ) {
1027 - if( isset($_POST['mStatus']) and 'success' == $_POST['mStatus'] ) {
1028 - $table_meta_name = $wpdb->prefix."usces_order_meta";
1029 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'orderId', $_POST['orderId'] );
1030 - $order_id = $wpdb->get_var( $query );
1031 - if( !$order_id ) {
1032 - $res = $usces->order_processing();
1033 - if( 'ordercompletion' == $res ) {
1034 - do_action( 'usces_action_veritrans_card_completion' );
1035 - $usces->cart->crear_cart();
1036 - usces_log( 'Veritrans [OK] transaction : '.$_POST['orderId'], 'acting_transaction.log' );
1037 - } else {
1038 - usces_log( 'Veritrans order processing error : '.print_r( $_POST, true ), 'acting_transaction.log' );
1039 - }
1040 - }
1041 - }
1042 - exit;
1043 -
1044 - //*** Veritrans conv ***//
1045 - } elseif( isset($_GET['acting']) and 'veritrans_conv' == $_GET['acting'] and isset($_POST['orderId']) and isset($_POST['merchantEncryptionKey']) ) {
1046 - //決済結果通知
1047 - if( isset($_POST['mStatus']) and 'success' == $_POST['mStatus'] ) {
1048 - $table_meta_name = $wpdb->prefix."usces_order_meta";
1049 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'orderId', $_POST['orderId'] );
1050 - $order_id = $wpdb->get_var( $query );
1051 - if( !$order_id ) {
1052 - $res = $usces->order_processing();
1053 - if( 'ordercompletion' == $res ) {
1054 - do_action( 'usces_action_veritrans_conv_completion' );
1055 - $usces->cart->crear_cart();
1056 - usces_log( 'Veritrans [OK] transaction : '.$_POST['orderId'], 'acting_transaction.log' );
1057 - } else {
1058 - usces_log( 'Veritrans order processing error : '.print_r( $_POST, true ), 'acting_transaction.log' );
1059 - }
1060 - }
1061 - }
1062 - exit;
1063 -
1064 - } elseif( isset($_REQUEST['numberOfNotify']) and isset($_REQUEST['pushTime']) and isset($_REQUEST['pushId']) ) {
1065 - //支払通知
1066 - $data = array();
1067 - foreach( $_REQUEST as $key => $value ) {
1068 - $num = substr( $key, -4 );
1069 - if( preg_match( "/^[0-9]+$/", $num ) ) {
1070 - $nkey = substr( $key, 0, strpos( $key, $num ) );
1071 - $data[$nkey][(int)$num] = $value;
1072 - } else {
1073 - $data[$key] = $value;
1074 - }
1075 - }
1076 -
1077 - $count = count( $data['orderId'] );
1078 - if( 0 < $count ) {
1079 - $table_name = $wpdb->prefix."usces_order";
1080 - $table_meta_name = $wpdb->prefix."usces_order_meta";
1081 -
1082 - for( $i = 0; $i < $count; $i++ ) {
1083 - if( isset( $data['orderId'][$i] ) ) {
1084 - $sdata = array();
1085 - $sdata['acting'] = 'veritrans_conv';
1086 - $sdata['orderId'] = $data['orderId'][$i];
1087 - $sdata['cvsType'] = isset( $data['cvsType'][$i] ) ? $data['cvsType'][$i] : '';
1088 - $sdata['receiptNo'] = isset( $data['receiptNo'][$i] ) ? $data['receiptNo'][$i] : '';
1089 - $sdata['receiptDate'] = isset( $data['receiptDate'][$i] ) ? $data['receiptDate'][$i] : '';
1090 - $sdata['rcvAmount'] = isset( $data['rcvAmount'][$i] ) ? $data['rcvAmount'][$i] : '';
1091 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'orderId', $sdata['orderId'] );
1092 - $order_id = $wpdb->get_var( $query );
1093 - if( $order_id == NULL ) {
1094 - usces_log( 'Veritrans conv error1 : '.print_r( $sdata, true ), 'acting_transaction.log' );
1095 -
1096 - } else {
1097 - $mquery = $wpdb->prepare("
1098 - UPDATE $table_name SET order_status =
1099 - CASE
1100 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
1101 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
1102 - ELSE CONCAT('receipted,', order_status )
1103 - END
1104 - WHERE ID = %d", $order_id );
1105 - $res = $wpdb->query( $mquery );
1106 - if( $res === false ) {
1107 - usces_log( 'Veritrans conv error2 : '.print_r( $sdata, true ), 'acting_transaction.log' );
1108 -
1109 - } else {
1110 - usces_action_acting_getpoint( $order_id );
1111 -
1112 - $usces->set_order_meta_value( 'acting_veritrans_conv', serialize( $sdata ), $order_id );
1113 -
1114 - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $sdata['orderId'] );
1115 - $res = $wpdb->query( $dquery );
1116 - }
1117 - }
1118 - }
1119 - }
1120 - }
1121 - exit;
1122 -//20140206ysk end
1123 - }
1124 -}
1125 -?>
867 + if ( '0000000000000' == $rsltcd ) {
868 + $table_name = $wpdb->prefix . 'usces_order';
869 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
870 +
871 + $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'stran', $stran );
872 + $order_id = $wpdb->get_var( $query );
873 + if ( null == $order_id ) {
874 + $log = array(
875 + 'acting' => 'mizuho_conv',
876 + 'key' => $stran,
877 + 'result' => 'ORDER DATA KEY ERROR',
878 + 'data' => wp_unslash( $_GET ),
879 + );
880 + usces_save_order_acting_error( $log );
881 + usces_log( 'mizuho conv error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
882 + } else {
883 + $res = usces_change_order_receipt( $order_id, 'receipted' );
884 + if ( false === $res ) {
885 + $log = array(
886 + 'acting' => 'mizuho_conv',
887 + 'key' => $stran,
888 + 'result' => 'ORDER DATA UPDATE ERROR',
889 + 'data' => wp_unslash( $_GET ),
890 + );
891 + usces_save_order_acting_error( $log );
892 + usces_log( 'mizuho conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
893 +
894 + } else {
895 + usces_action_acting_getpoint( $order_id );
896 +
897 + $usces->set_order_meta_value( 'acting_mizuho_conv', serialize( $data ), $order_id );
898 +
899 + $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $stran );
900 + $res = $wpdb->query( $dquery );
901 + }
902 + }
903 + } else {
904 + usces_log( 'mizuho conv : ' . print_r( wp_unslash( $_GET ), true ), 'acting_transaction.log' );
905 + }
906 + } elseif ( '108' == substr( $rsltcd, 0, 3 ) || '208' == substr( $rsltcd, 0, 3 ) || '308' == substr( $rsltcd, 0, 3 ) ) { // キャンセル
907 + header( 'location: ' . USCES_CART_URL . $delim . 'confirm=1' );
908 + } elseif ( '109' == substr( $rsltcd, 0, 3 ) || '209' == substr( $rsltcd, 0, 3 ) || '309' == substr( $rsltcd, 0, 3 ) ) { // エラー
909 + $log = array(
910 + 'acting' => 'mizuho_conv',
911 + 'key' => $stran,
912 + 'result' => $rsltcd,
913 + 'data' => wp_unslash( $_GET ),
914 + );
915 + usces_save_order_acting_error( $log );
916 + usces_log( 'mizuho conv : ' . print_r( wp_unslash( $_GET ), true ), 'acting_transaction.log' );
917 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=mizuho_card&acting_return=0' );
918 + } else {
919 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=mizuho_conv&acting_return=1&stran=' . $stran . '&mbtran=' . $mbtran . '&bktrans=' . wp_unslash( $_GET['bktrans'] ) . '&tranid=' . $tranid . '&rsltcd=' . $rsltcd );
920 + }
921 + die();
922 + */
923 +
924 + /* AnotherLane credit */
925 + } elseif ( isset( $_REQUEST['SiteId'] ) && isset( $_REQUEST['TransactionId'] ) && isset( $_REQUEST['Result'] ) ) {
926 + $data = array();
927 + foreach ( $_REQUEST as $key => $value ) {
928 + $data[ $key ] = $value;
929 + }
930 +
931 + $acting_opts = $usces->options['acting_settings']['anotherlane'];
932 + if ( ! isset( $_REQUEST['KickType'] ) && isset( $_REQUEST['TransactionId'] ) ) {
933 + $permalink_structure = get_option( 'permalink_structure' );
934 + $delim = ( ! $usces->use_ssl && $permalink_structure ) ? '?' : '&';
935 + if ( $acting_opts['siteid'] == wp_unslash( $_REQUEST['SiteId'] ) && 'NG' == wp_unslash( $_REQUEST['Result'] ) ) {
936 + $log = array(
937 + 'acting' => 'anotherlane_card',
938 + 'key' => wp_unslash( $_REQUEST['TransactionId'] ),
939 + 'result' => wp_unslash( $_REQUEST['Result'] ),
940 + 'data' => wp_unslash( $_REQUEST ),
941 + );
942 + usces_save_order_acting_error( $log );
943 + header( 'location: ' . USCES_CART_URL . $delim . 'confirm=1' );
944 + exit;
945 + } elseif ( $acting_opts['siteid'] == wp_unslash( $_REQUEST['SiteId'] ) && 'OK' == wp_unslash( $_REQUEST['Result'] ) ) {
946 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=anotherlane_card&acting_return=1' );
947 + exit;
948 + }
949 + } elseif ( isset( $_REQUEST['KickType'] ) && $acting_opts['siteid'] == wp_unslash( $_GET['SiteId'] ) && 'OK' == wp_unslash( $_GET['Result'] ) ) {
950 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
951 + $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'TransactionId', $data['TransactionId'] );
952 + $order_id = $wpdb->get_var( $query );
953 + if ( ! $order_id ) {
954 + $res = $usces->order_processing();
955 + if ( 'ordercompletion' == $res ) {
956 + $usces->set_order_meta_value( 'wc_trans_id', $data['TransactionId'], $order_id );
957 + usces_log( 'AnotherLane [OK] transaction : ' . $data['TransactionId'], 'acting_transaction.log' );
958 + } else {
959 + $log = array(
960 + 'acting' => 'anotherlane_card',
961 + 'key' => $data['TransactionId'],
962 + 'result' => 'ORDER DATA REGISTERED ERROR',
963 + 'data' => wp_unslash( $_GET ),
964 + );
965 + usces_save_order_acting_error( $log );
966 + usces_log( 'AnotherLane order processing error : ' . print_r( $data, true ), 'acting_transaction.log' );
967 + }
968 + }
969 + } else {
970 + $log = array(
971 + 'acting' => 'anotherlane_card',
972 + 'key' => $data['TransactionId'],
973 + 'result' => $data['Result'],
974 + 'data' => wp_unslash( $_GET ),
975 + );
976 + usces_save_order_acting_error( $log );
977 + }
978 + exit;
979 + }
980 +}