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 +948 -1067 1.4.12.12.4 View file →
@@ -1,1099 +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 - }
1 +<?php
2 +/**
3 + * Hoock functions.
4 + *
5 + * @package Welcart
6 + */
61 7
62 - } elseif( isset($_POST['orderId']) and isset($_POST['merchantEncryptionKey']) ) {//Veritrans
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 );
63 14
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');
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' );
68 53 } else {
69 - usces_log('Veritrans construct : '.$_POST['orderId'], 'acting_transaction.log');
54 + usces_log( 'digitalcheck construct : ' . $sid, 'acting_transaction.log' );
70 55 }
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( 'on' == $acting_opts['quickcharge'] ) {
204 - $usces->set_member_meta_value( 'zeus_pcid', '8888888888888888' );
205 - }
206 - if( isset($_GET['cardnumber']) ) $usces->set_member_meta_value( 'zeus_partofcard', $_GET['cardnumber'] );
207 - }
208 -
209 - header("HTTP/1.0 200 OK");
210 - die('zeus');
211 - }else{
212 - header("HTTP/1.0 200 OK");
213 - die('error3');
214 - }
215 -
216 - //*** zeus_bank ***//
217 - }elseif( isset($_REQUEST['acting']) && 'zeus_bank' == $_REQUEST['acting'] && isset($_REQUEST['order_no']) && isset($_REQUEST['tracking_no']) ){
218 - foreach( $_REQUEST as $key => $value ){
219 - $data[$key] = $value;
220 - }
221 - usces_log('zeus bank cgi data : '.print_r($data,true), 'acting_transaction.log');
222 -
223 -//20130426ysk start 0000701
224 - if( '04' === $_REQUEST['status'] or '05' === $_REQUEST['status'] ) {
225 - usces_log( 'zeus bank error0 : status='.$_REQUEST['status'], 'acting_transaction.log' );
226 - die('error0');
227 - }
228 -//20130426ysk end
229 -
230 - $acting_opts = $usces->options['acting_settings']['zeus'];
231 -
232 - $table_name = $wpdb->prefix . "usces_order";
233 - $table_meta_name = $wpdb->prefix . "usces_order_meta";
234 - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['tracking_no']);
235 - $values = $wpdb->get_row( $mquery, ARRAY_A );
236 -
237 - if( $values == NULL ){
238 -
239 -//20110203ysk start
240 - $res = $usces->order_processing();
241 - if( 'error' == $res ){
242 - usces_log('zeus bank error1 : order_processing', 'acting_transaction.log');
243 - die('error1');
244 - }else{
245 - usces_log('zeus bank order : OK', 'acting_transaction.log');
246 - $order_id = $usces->cart->get_order_entry('ID');
247 - $value = serialize($_GET);
248 - $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);
249 - $res = $wpdb->query( $query );
250 -
251 - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['tracking_no']);
252 - $values = $wpdb->get_row( $mquery, ARRAY_A );
253 - $usces->cart->crear_cart();
254 - }
255 -//20110203ysk end
256 - }
257 -
258 - //usces_log('zeus construct_values2 : '.print_r($values,true), 'acting_transaction.log');
259 - $value = unserialize($values['meta_value']);
260 - $status = ( '03' === $_REQUEST['status'] ) ? 'receipted,' : 'noreceipt,';
261 - $order_id = $values['order_id'];
262 - //$add_point = true;//20120306ysk 0000324
263 - if( 'receipted,' == $status ){
264 - $mquery = $wpdb->prepare("
265 - UPDATE $table_name SET order_status =
266 - CASE
267 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
268 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
269 - ELSE CONCAT('receipted,', order_status )
270 - END
271 - WHERE ID = %d", $order_id);
272 - }else{
273 - $mquery = $wpdb->prepare("
274 - UPDATE $table_name SET order_status =
275 - CASE
276 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
277 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
278 - ELSE CONCAT('noreceipt,', order_status )
279 - END
280 - WHERE ID = %d", $order_id);
281 - //$add_point = false;//20120306ysk 0000324
282 - }
283 - $res = $wpdb->query( $mquery );
284 - if( false === $res ){
285 - //usces_log('zeus bank error2 : '.print_r($data, true), 'acting_transaction.log');
286 - usces_log('zeus bank error2 : update usces_order', 'acting_transaction.log');
287 - die('error2');
288 - }
289 - //usces_action_acting_getpoint( $order_id, $add_point );//20120306ysk 0000324
290 - if( '03' === $_REQUEST['status'] ) usces_action_acting_getpoint( $order_id );//20140130ysk
291 -
292 - $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'] );
293 - $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']);
294 - //usces_log('mquery2 : '.print_r($mquery, true), 'acting_transaction.log');
295 - $res = $wpdb->query( $mquery );
296 - if(!$res){
297 - //usces_log('zeus bank error3 : '.print_r($data, true), 'acting_transaction.log');
298 - usces_log('zeus bank error3 : update usces_order_meta', 'acting_transaction.log');
299 - die('error3');
300 - }
301 -
302 - usces_log('zeus bank transaction : '.$_REQUEST['tracking_no'], 'acting_transaction.log');
303 - die('zeus');
304 -
305 - //*** zeus_conv ***//
306 - }elseif( isset($_REQUEST['acting']) && 'zeus_conv' == $_REQUEST['acting'] && isset($_REQUEST['status']) && isset($_REQUEST['sendpoint']) ){
307 - foreach( $_REQUEST as $key => $value ){
308 - $data[$key] = $value;
309 - }
310 - usces_log('zeus conv cgi data : '.print_r($data,true), 'acting_transaction.log');
311 -
312 - $acting_opts = $usces->options['acting_settings']['zeus'];
313 -
314 - $table_name = $wpdb->prefix . "usces_order";
315 - $table_meta_name = $wpdb->prefix . "usces_order_meta";
316 - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['sendpoint']);
317 - $values = $wpdb->get_row( $mquery, ARRAY_A );
318 - if( $values == NULL ){
319 -
320 -//20110203ysk start
321 - $res = $usces->order_processing();
322 -
323 - if( 'error' == $res ){
324 - usces_log('zeus conv error1 : '.print_r($data, true), 'acting_transaction.log');
325 - die('error1');
326 - }else{
327 - $order_id = $usces->cart->get_order_entry('ID');
328 - $value = serialize($_GET);
329 - $query = $wpdb->prepare("INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $order_id, 'acting_'.$_REQUEST['sendpoint'], $value);
330 - $res = $wpdb->query( $query );
331 - usces_log('zeus conv ordered : OK', 'acting_transaction.log');
332 - }
333 -//20110203ysk end
334 -
335 - }else{
336 - if( '05' !== $_REQUEST['status'] ) {//20131128ysk 0000794
337 - $value = unserialize($values['meta_value']);
338 - $status = ( '04' === $_REQUEST['status'] ) ? 'receipted,' : 'noreceipt,';
339 - $order_id = $values['order_id'];
340 - //$add_point = true;//20120306ysk 0000324
341 - if( 'receipted,' == $status ){
342 - $mquery = $wpdb->prepare("
343 - UPDATE $table_name SET order_status =
344 - CASE
345 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
346 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
347 - ELSE CONCAT('receipted,', order_status )
348 - END
349 - WHERE ID = %d", $order_id);
350 - }else{
351 - $mquery = $wpdb->prepare("
352 - UPDATE $table_name SET order_status =
353 - CASE
354 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
355 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
356 - ELSE CONCAT('noreceipt,', order_status )
357 - END
358 - WHERE ID = %d", $order_id);
359 - //$add_point = false;//20120306ysk 0000324
360 - }
361 - $res = $wpdb->query( $mquery );
362 - if(!$res){
363 - usces_log('zeus conv error2 : '.print_r($data, true), 'acting_transaction.log');
364 - die('error2');
365 - }
366 -
367 - foreach( $_GET as $key => $v ){
368 - $newvalue[$key] = mb_convert_encoding($v, 'UTF-8', 'SJIS');
369 - }
370 - $value = serialize($newvalue);
371 - $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']);
372 - $res = $wpdb->query( $mquery );
373 - if(!$res){
374 - usces_log('zeus conv error3 : '.print_r($data, true), 'acting_transaction.log');
375 - die('error3');
376 - }
377 - //usces_action_acting_getpoint( $order_id, $add_point );//20120306ysk 0000324
378 - if( '04' === $_REQUEST['status'] ) usces_action_acting_getpoint( $order_id );//20140130ysk
379 - }
380 - }
381 -
382 - usces_log('zeus conv transaction : '.$_REQUEST['sendpoint'], 'acting_transaction.log');
383 - die('zeus');
384 -
385 -//20101018ysk start
386 - //*** jpayment_card ***//
387 - } elseif(isset($_REQUEST['acting']) && 'jpayment_card' == $_REQUEST['acting']) {
388 - //$args='';
389 - //foreach((array)$_GET as $key => $value) {
390 - // $args.='&('.$key.')=('.$value.')';
391 - //}
392 - //usces_log('jpayment card : '.$args, 'acting_transaction.log');
393 56
394 - //*** jpayment_conv ***//
395 - } elseif(isset($_REQUEST['acting']) && 'jpayment_conv' == $_REQUEST['acting'] && isset($_GET['ap'])) {
396 - //$args='';
397 - //foreach((array)$_GET as $key => $value) {
398 - // $args.='&('.$key.')=('.$value.')';
399 - //}
400 - //usces_log('jpayment conv : '.$args, 'acting_transaction.log');
401 - foreach( $_REQUEST as $key => $value ){
402 - $data[$key] = $value;
403 - }
404 -
405 - switch($_GET['ap']) {
406 - case 'CPL_PRE'://コンビニペーパーレス決済識別コード
407 - break;
408 -
409 - case 'CPL'://入金確定
410 - $table_name = $wpdb->prefix."usces_order";
411 - $table_meta_name = $wpdb->prefix."usces_order_meta";
412 -
413 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']);
414 - $order_id = $wpdb->get_var($query);
415 - if($order_id == NULL) {
416 - usces_log('jpayment conv error1 : '.print_r($data, true), 'acting_transaction.log');
417 - die('error1');
418 - }
419 -
420 - $query = $wpdb->prepare("
421 - UPDATE $table_name SET order_status =
422 - CASE
423 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
424 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
425 - ELSE CONCAT('receipted,', order_status )
426 - END
427 - WHERE ID = %d", $order_id);
428 - $res = $wpdb->query($query);
429 - if($res === false) {
430 - usces_log('jpayment conv error2 : '.print_r($data, true), 'acting_transaction.log');
431 - die('error2');
432 - }
433 -
434 - foreach($_GET as $key => $value) {
435 - $data[$key] = esc_sql($value);
436 - }
437 - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id);
438 - if($res === false) {
439 - usces_log('jpayment conv error3 : '.print_r($data, true), 'acting_transaction.log');
440 - die('error3');
441 - }
442 -
443 - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324
444 -
445 - usces_log('J-Payment conv transaction : '.$_GET['gid'], 'acting_transaction.log');
446 - die('J-Payment');
447 - break;
448 -
449 - case 'CVS_CAN'://入金取消
450 - $table_name = $wpdb->prefix."usces_order";
451 - $table_meta_name = $wpdb->prefix."usces_order_meta";
452 -
453 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']);
454 - $order_id = $wpdb->get_var($query);
455 - if($order_id == NULL) {
456 - usces_log('jpayment conv error1 : '.print_r($data, true), 'acting_transaction.log');
457 - die('error1');
458 - }
459 -
460 - $query = $wpdb->prepare("
461 - UPDATE $table_name SET order_status =
462 - CASE
463 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
464 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
465 - ELSE CONCAT('noreceipt,', order_status )
466 - END
467 - WHERE ID = %d", $order_id);
468 - $res = $wpdb->query($query);
469 - if($res === false) {
470 - usces_log('jpayment conv error2 : '.print_r($data, true), 'acting_transaction.log');
471 - die('error2');
472 - }
473 -
474 - foreach($_GET as $key => $value) {
475 - $data[$key] = esc_sql($value);
476 - }
477 - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id);
478 - if($res === false) {
479 - usces_log('jpayment conv error3 : '.print_r($data, true), 'acting_transaction.log');
480 - die('error3');
481 - }
482 -
483 - usces_action_acting_getpoint( $order_id, false );//20120306ysk 0000324
484 -
485 - usces_log('J-Payment conv transaction : '.$_GET['gid'], 'acting_transaction.log');
486 - die('J-Payment');
487 - break;
488 - }
489 -
490 - //*** jpayment_bank ***//
491 - } elseif(isset($_REQUEST['acting']) && 'jpayment_bank' == $_REQUEST['acting']) {
492 - //$args='';
493 - //foreach((array)$_GET as $key => $value) {
494 - // $args.='&('.$key.')=('.$value.')';
495 - //}
496 - //usces_log('jpayment bank : '.$args, 'acting_transaction.log');
497 - foreach( $_REQUEST as $key => $value ){
498 - $data[$key] = $value;
499 - }
500 -
501 - switch($_GET['ap']) {
502 - case 'BANK'://受付完了
503 - break;
504 -
505 - case 'BAN_SAL'://入金完了
506 - if($_GET['mf'] == '1') {//入金マッチングの場合
507 - $table_name = $wpdb->prefix."usces_order";
508 - $table_meta_name = $wpdb->prefix."usces_order_meta";
509 -
510 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']);
511 - $order_id = $wpdb->get_var($query);
512 - if($order_id == NULL) {
513 - usces_log('jpayment bank error1 : '.print_r($data, true), 'acting_transaction.log');
514 - die('error1');
515 - }
516 -
517 - $query = $wpdb->prepare("
518 - UPDATE $table_name SET order_status =
519 - CASE
520 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
521 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
522 - ELSE CONCAT('receipted,', order_status )
523 - END
524 - WHERE ID = %d", $order_id);
525 - $res = $wpdb->query($query);
526 - if($res === false) {
527 - usces_log('jpayment bank error2 : '.print_r($data, true), 'acting_transaction.log');
528 - die('error2');
529 - }
530 -
531 - foreach($_GET as $key => $value) {
532 - $data[$key] = esc_sql($value);
533 - }
534 - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id);
535 - if($res === false) {
536 - usces_log('jpayment bank error3 : '.print_r($data, true), 'acting_transaction.log');
537 - die('error3');
538 - }
539 -
540 - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324
541 - }
542 -
543 - usces_log('J-Payment bank transaction : '.$_REQUEST['gid'], 'acting_transaction.log');
544 - die('J-Payment');
545 - break;
546 - }
547 -//20101018ysk end
548 - //*** epsilon ***//
549 - }elseif( !isset($_GET['acting_return']) && isset($_GET['trans_code']) && isset($_GET['user_id']) && isset($_GET['result']) && isset($_GET['order_number']) ){
550 - $query = 'trans_code=' . $_GET['trans_code'] . '&user_id=' . $_GET['user_id'] . '&result=' . $_GET['result'] . '&order_number=' . $_GET['order_number'];
551 - usces_log('epsilon (acting_transaction) : ' . $query, 'acting_transaction.log');
552 - $permalink_structure = get_option('permalink_structure');
553 - $delim = ( !$usces->use_ssl && $permalink_structure) ? '?' : '&';
554 -
555 - header('location: ' . USCES_CART_URL . $delim . 'acting=epsilon&acting_return=1&' . $query );
556 - exit;
557 -//20110208ysk start
558 - } elseif( !isset($_GET['acting_return']) && (isset($_GET['acting']) && 'paypal_ipn' == $_GET['acting']) ) {
559 - foreach( $_REQUEST as $key => $value ){
560 - $data[$key] = $value;
561 - }
562 - usces_log('paypal_ipn in '.print_r($data,true), 'acting_transaction.log');
563 - require_once($usces->options['settlement_path'] . 'paypal.php');
564 - $ipn_res = paypal_ipn_check($usces_paypal_url);
565 - if( $ipn_res[0] === true ){
566 - $res = $usces->order_processing( $ipn_res );
567 - if( 'ordercompletion' == $res ){
568 - $usces->cart->crear_cart();
569 - }else{
570 - usces_log('paypal_ipn error : '.print_r($data, true), 'acting_transaction.log');
571 - die('error1');
572 - }
573 - do_action('usces_action_paypal_ipn', $res, $ipn_res);
574 - }
575 - usces_log('PayPal IPN transaction : '.$_REQUEST['txn_id'], 'acting_transaction.log');
576 - die('PayPal');
577 -//20110523ysk start
578 - //*** paypal ipn ***//
579 - } elseif( isset($_REQUEST['ipn_track_id']) ) {//20131121ysk
580 - foreach( $_REQUEST as $key => $value ){
581 - $data[$key] = $value;
582 - }
583 - usces_log('paypal ipn : '.print_r($data, true), 'acting_transaction.log');
584 -//20131121ysk start
585 - $table_name = $wpdb->prefix."usces_order";
586 - $table_meta_name = $wpdb->prefix."usces_order_meta";
587 - if( isset($_REQUEST['txn_id']) or isset($_REQUEST['recurring_payment_id']) ) {
588 - if( ( isset($_REQUEST['payment_status']) and 'Completed' == $_REQUEST['payment_status'] ) or
589 - ( isset($_REQUEST['profile_status']) and 'Active' == $_REQUEST['profile_status'] ) ) {
590 - $settlement_id = ( isset($_REQUEST['recurring_payment_id']) ) ? $_REQUEST['recurring_payment_id'] : $_REQUEST['txn_id'];
591 - $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 );
592 - $order_data = $wpdb->get_row( $query, ARRAY_A );
593 - if( $order_data ) {
594 - if( $usces->is_status( 'pending', $order_data['order_status'] ) ) {
595 - $order_status = str_replace( 'pending', 'receipted', $order_data['order_status'] );
596 - $query = $wpdb->prepare( "UPDATE $table_name SET order_status = %s WHERE ID = %d", $order_status, $order_data['ID'] );
597 - $res = $wpdb->query( $query );
598 - }
599 - do_action( 'usces_action_paypal_ipn_status_completed', $order_data );
600 - }
601 - }
602 - }
603 -//20131121ysk end
604 - die('PayPal');
605 -//20110523ysk end
606 -//20120413ysk start
607 - //*** SoftBankPayment ***//
608 - } elseif( !isset($_GET['acting_return']) && isset($_POST['res_result']) && isset($_POST['res_pay_method']) ) {
609 - //usces_log('SoftBankPayment : '.print_r($_REQUEST, true), 'acting_transaction.log');
610 - foreach( $_POST as $key => $value ) {
611 - $data[$key] = mb_convert_encoding($value, 'UTF-8', 'SJIS');
612 - }
613 - $acting = $data['free1'];
614 -
615 - switch( $data['res_result'] ) {
616 - case 'OK'://決済処理OK
617 - $table_meta_name = $wpdb->prefix."usces_order_meta";
618 - $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']);
619 - $order_id = $wpdb->get_var($query);
620 - if( !$order_id ) {
621 -
622 - $res = $usces->order_processing();
623 - if( 'ordercompletion' == $res ){
624 - //$usces->cart->crear_cart();
625 - } else {
626 - usces_log('SoftBankPayment '.$data['res_pay_method'].' order processing error : '.print_r($data, true), 'acting_transaction.log');
627 - die('NG,order processing error');
628 - }
629 - }
630 -
631 - //$acting_opts = $usces->options['acting_settings']['sbps'];
632 - //if( 'on' == $acting_opts['cust'] ) {
633 - // $usces->set_member_meta_value( 'sbps_cust_no', $data['res_sps_cust_no'], $data['cust_code'] );
634 - // $usces->set_member_meta_value( 'sbps_payment_no', $data['res_sps_payment_no'], $data['cust_code'] );
635 - //}
636 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [OK] transaction : '.$data['res_tracking_id'], 'acting_transaction.log');
637 - die('OK,');
638 - break;
639 -
640 - case 'PY'://入金結果通知
641 - $table_name = $wpdb->prefix."usces_order";
642 - $table_meta_name = $wpdb->prefix."usces_order_meta";
643 - $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']);
644 - $order_id = $wpdb->get_var($query);
645 - if( $order_id == NULL ) {
646 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error1 : '.print_r($data, true), 'acting_transaction.log');
647 - die('NG,order_id error');
648 - }
649 -
650 - $query = $wpdb->prepare("
651 - UPDATE $table_name SET order_status =
652 - CASE
653 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
654 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
655 - ELSE CONCAT('receipted,', order_status )
656 - END
657 - WHERE ID = %d", $order_id);
658 - $res = $wpdb->query($query);
659 - if( $res === false ) {
660 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error2 : '.print_r($data, true), 'acting_transaction.log');
661 - die('NG,usces_order update error');
662 - }
663 -
664 - $res = $usces->set_order_meta_value($acting, serialize($data), $order_id);
665 - if( $res === false ) {
666 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error3 : '.print_r($data, true), 'acting_transaction.log');
667 - die('NG,usces_order_meta update error');
668 - }
669 -
670 - usces_action_acting_getpoint( $order_id );
671 -
672 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] transaction : '.$order_id, 'acting_transaction.log');
673 - die('OK,');
674 -
675 - case 'CN'://期限切通知
676 - $table_name = $wpdb->prefix."usces_order";
677 - $table_meta_name = $wpdb->prefix."usces_order_meta";
678 - $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']);
679 - $order_id = $wpdb->get_var($query);
680 - if( $order_id == NULL ) {
681 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error1 : '.print_r($data, true), 'acting_transaction.log');
682 - die('NG,order_id error');
683 - }
684 -
685 - $query = $wpdb->prepare("
686 - UPDATE $table_name SET order_status =
687 - CASE
688 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
689 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
690 - ELSE CONCAT('noreceipt,', order_status )
691 - END
692 - WHERE ID = %d", $order_id);
693 - $res = $wpdb->query($query);
694 - if( $res === false ) {
695 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error2 : '.print_r($data, true), 'acting_transaction.log');
696 - die('NG,usces_order update error');
697 - }
698 -
699 - $res = $usces->set_order_meta_value($acting, serialize($data), $order_id);
700 - if( $res === false ) {
701 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error3 : '.print_r($data, true), 'acting_transaction.log');
702 - die('NG,usces_order_meta update error');
703 - }
704 -
705 - //usces_action_acting_getpoint( $order_id, false );
706 -
707 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] transaction : '.$order_id, 'acting_transaction.log');
708 - die('OK,');
709 -
710 - default:
711 - usces_log('SoftBankPayment '.$data['res_pay_method'].' ['.$data['res_result'].'] : '.print_r($data,true), 'acting_transaction.log');
712 - die('OK,');
713 - }
714 -//20120413ysk end
715 -//20121030ysk start
716 - //*** telecom credit ***//
717 - } elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && (isset($_REQUEST['acting']) && 'telecom_edy' == $_REQUEST['acting']) ) {
718 - foreach( $_REQUEST as $key => $value ) {
719 - $data[$key] = $value;
720 - }
721 - usces_log('telecom edy : '.print_r($data, true), 'acting_transaction.log');
722 - //die('SuccessOK');
723 - } elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && isset($_REQUEST['edy']) ) {
724 - foreach( $_REQUEST as $key => $value ) {
725 - $data[$key] = $value;
726 - }
727 - if( $_REQUEST['rel'] === 'yes' && isset($_REQUEST['option']) ) {
728 - $table_meta_name = $wpdb->prefix."usces_order_meta";
729 - $mquery = $wpdb->prepare( "SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", $_REQUEST['option'] );
730 - $mvalue = $wpdb->get_row( $mquery, ARRAY_A );
731 - $value = unserialize( $mvalue['meta_value'] );
732 - $_SESSION['usces_cart'] = $value['usces_cart'];
733 - $_SESSION['usces_entry'] = $value['usces_entry'];
734 - $_SESSION['usces_member'] = $value['usces_member'];
735 - $res = $usces->order_processing();
736 - if( 'ordercompletion' == $res ) {
737 - $query = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $_REQUEST['option'] );
738 - $res = $wpdb->query( $query );
739 - usces_log('telecom edy - Payment confirmation : '.print_r($data, true), 'acting_transaction.log');
740 - } else {
741 - usces_log('telecom edy - Error 1 : '.print_r($data, true), 'acting_transaction.log');
742 - }
743 - } else {
744 - usces_log('telecom edy - Error 2 : '.print_r($data, true), 'acting_transaction.log');
745 - }
746 - die('SuccessOK');
747 -//20121030ysk end
748 -//20120618ysk start
749 - //*** telecom credit ***//
750 - }elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && isset($_REQUEST['rel']) ){
751 - foreach( $_REQUEST as $key => $value ){
752 - $data[$key] = $value;
753 - }
754 - usces_log('telecom card : '.print_r($data, true), 'acting_transaction.log');
755 - die('SuccessOK');
756 -//20120618ysk end
757 -//20121206ysk start
758 - //*** digitalcheck card ***//
759 - } elseif( isset($_REQUEST['SID']) && isset($_REQUEST['FUKA']) && substr($_REQUEST['FUKA'], 0, 24) == 'acting_digitalcheck_card' ) {
760 - foreach( $_REQUEST as $key => $value ) {
761 - $data[$key] = $value;
762 - }
763 - $sid = ( isset($data['SID']) ) ? $data['SID'] : '';
764 -//usces_log('digitalcheck card : '.print_r($data, true), 'digitalcheck.log');
765 -
766 - if( isset($data['SEQ']) ) {
767 - $acting_opts = $usces->options['acting_settings']['digitalcheck'];
768 - $ip_user_id = substr($data['FUKA'], 24);
769 -//usces_log('ip_user_id : '.$ip_user_id, 'digitalcheck.log');
770 - if( 'on' == $acting_opts['card_user_id'] and !empty($ip_user_id) ) {
771 - $usces->set_member_meta_value('digitalcheck_ip_user_id', $ip_user_id, $ip_user_id);
772 - }
773 -
774 - $res = $usces->order_processing();
775 - if( 'ordercompletion' == $res ) {
776 - $order_id = $usces->cart->get_order_entry('ID');
777 - $usces->set_order_meta_value( 'acting_digitalcheck_card', serialize( $data ), $order_id );
778 - } else {
779 - usces_log('digitalcheck card : order processing error', 'acting_transaction.log');
780 - }
781 -
782 - header('content-type : text/plain;charset=Shift_JIS');
783 - die("0");
784 - }
785 -
786 - //*** digitalcheck conv ***//
787 - } elseif( isset($_REQUEST['SID']) && isset($_REQUEST['FUKA']) && substr($_REQUEST['FUKA'], 0, 24) == 'acting_digitalcheck_conv' ) {
788 - foreach( $_REQUEST as $key => $value ) {
789 - $data[$key] = $value;
790 - }
791 - $sid = ( isset($data['SID']) ) ? $data['SID'] : '';
792 -//usces_log("digitalcheck conv : ".print_r($_REQUEST,true), 'digitalcheck.log');
793 -
794 - if( isset($data['SEQ']) ) {
795 - $table_name = $wpdb->prefix."usces_order";
796 - $table_meta_name = $wpdb->prefix."usces_order_meta";
797 -
798 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $sid );
799 - $order_id = $wpdb->get_var( $query );
800 - if( $order_id == NULL ) {
801 - usces_log( 'digitalcheck conv error1 : '.print_r($data, true), 'acting_transaction.log' );
802 - header('content-type : text/plain;charset=Shift_JIS');
803 - die('9');
804 - }
805 -
806 - if( isset($data['CVS']) ) {//入金
807 - $mquery = $wpdb->prepare("
808 - UPDATE $table_name SET order_status =
809 - CASE
810 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
811 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
812 - ELSE CONCAT('receipted,', order_status )
813 - END
814 - WHERE ID = %d", $order_id );
815 - $res = $wpdb->query( $mquery );
816 - if( $res === false ) {
817 - usces_log('digitalcheck conv error2 : '.print_r($data, true), 'acting_transaction.log');
818 - header('content-type : text/plain;charset=Shift_JIS');
819 - die('9');
820 - }
821 -
822 - usces_action_acting_getpoint( $order_id );
823 -
824 - } else {//取消
825 - $mquery = $wpdb->prepare("
826 - UPDATE $table_name SET order_status =
827 - CASE
828 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
829 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
830 - ELSE CONCAT('noreceipt,', order_status )
831 - END
832 - WHERE ID = %d", $order_id );
833 - $res = $wpdb->query( $mquery );
834 - if( $res === false ) {
835 - usces_log('digitalcheck conv error3 : '.print_r($data, true), 'acting_transaction.log');
836 - header('content-type : text/plain;charset=Shift_JIS');
837 - die('9');
838 - }
839 -
840 - usces_action_acting_getpoint( $order_id, false );
841 - }
842 -
843 - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
844 -
845 - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $sid );
846 - $res = $wpdb->query( $dquery );
847 -
848 - header('content-type : text/plain;charset=Shift_JIS');
849 - die("0");
850 -
851 - } else {
852 - if( isset($data['CVS']) and isset($data['SHNO']) ) {//決済
853 - $table_meta_name = $wpdb->prefix."usces_order_meta";
854 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $sid );
855 - $order_id = $wpdb->get_var($query);
856 - if( $order_id ) {
857 - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
858 -
859 - } else {
860 - $res = $usces->order_processing();
861 - if( 'ordercompletion' == $res ) {
862 - $order_id = $usces->cart->get_order_entry('ID');
863 - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
864 - } else {
865 - usces_log('digitalcheck conv : order processing error', 'acting_transaction.log');
866 - }
867 - }
868 - header('content-type : text/plain;charset=Shift_JIS');
869 - die("0");
870 -
871 - } elseif( isset($data['purchase']) ) {
872 -
873 - } else {
874 - $permalink_structure = get_option('permalink_structure');
875 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
876 - header( 'location: '.USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=1&SID='.$sid );
877 - exit;
878 - }
879 - }
880 -//20121206ysk end
881 -//20130225ysk start
882 - //*** mizuho card ***//
883 - } elseif( ( isset($_GET['p_ver']) && $_GET['p_ver'] == '0200' ) && ( isset($_GET['bkcode']) && $_GET['bkcode'] == 'bg01' ) ) {
884 - //usces_log('mizuho card : '.print_r($_GET,true),'mizuho.log');
885 - $stran = ( array_key_exists('stran', $_REQUEST) ) ? $_REQUEST['stran'] : '';
886 - $mbtran = ( array_key_exists('mbtran', $_REQUEST) ) ? $_REQUEST['mbtran'] : '';
887 - $rsltcd = ( array_key_exists('rsltcd', $_REQUEST) ) ? $_REQUEST['rsltcd'] : '';
888 - $rsltdcd = ( array_key_exists('rsltdcd', $_REQUEST) ) ? $_REQUEST['rsltdcd'] : '';
889 - $permalink_structure = get_option( 'permalink_structure' );
890 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
891 - if( '108' == substr($rsltcd, 0, 3) or '208' == substr($rsltcd, 0, 3) or '308' == substr($rsltcd, 0, 3 ) ) {//キャンセル
892 - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
893 - } elseif( '109' == substr($rsltcd, 0, 3) or '209' == substr($rsltcd, 0, 3) or '309' == substr($rsltcd, 0, 3) ) {//エラー
894 - usces_log( 'mizuho card : '.print_r( $_GET, true ), 'acting_transaction.log' );
895 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_card&acting_return=0&rsltdcd='.$rsltdcd );
896 - } else {
897 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_card&acting_return=1&stran='.$stran.'&mbtran='.$mbtran.'&rsltcd='.$rsltcd );
898 - }
899 - die();
900 -
901 - //*** mizuho conv ***//
902 - } elseif( ( isset($_GET['p_ver']) && $_GET['p_ver'] == '0200' ) && ( isset($_GET['bkcode']) && ( $_GET['bkcode'] == 'cv01' or $_GET['bkcode'] == 'cv02' ) ) ) {
903 - //usces_log('mizuho conv : '.print_r($_GET,true),'mizuho.log');
904 - $stran = ( array_key_exists('stran', $_REQUEST) ) ? $_REQUEST['stran'] : '';
905 - $mbtran = ( array_key_exists('mbtran', $_REQUEST) ) ? $_REQUEST['mbtran'] : '';
906 - $bktrans = ( array_key_exists('bktrans', $_REQUEST) ) ? $_REQUEST['bktrans'] : '';
907 - $tranid = ( array_key_exists('tranid', $_REQUEST) ) ? $_REQUEST['tranid'] : '';
908 - $tdate = ( array_key_exists('tdate', $_REQUEST) ) ? $_REQUEST['tdate'] : '';
909 - $rsltcd = ( array_key_exists('rsltcd', $_REQUEST) ) ? $_REQUEST['rsltcd'] : '';
910 - $permalink_structure = get_option( 'permalink_structure' );
911 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
912 - if( '' != $tdate ) {//入金通知
913 - foreach( $_REQUEST as $key => $value ) {
914 - $data[$key] = $value;
915 - }
916 - if( $rsltcd == "0000000000000" ) {
917 - $table_name = $wpdb->prefix."usces_order";
918 - $table_meta_name = $wpdb->prefix."usces_order_meta";
919 -
920 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'stran', $stran );
921 - $order_id = $wpdb->get_var( $query );
922 - if( $order_id == NULL ) {
923 - usces_log( 'mizuho conv error1 : '.print_r($data, true), 'acting_transaction.log' );
924 -
925 - } else {
926 - $mquery = $wpdb->prepare("
927 - UPDATE $table_name SET order_status =
928 - CASE
929 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
930 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
931 - ELSE CONCAT('receipted,', order_status )
932 - END
933 - WHERE ID = %d", $order_id );
934 - $res = $wpdb->query( $mquery );
935 - if( $res === false ) {
936 - usces_log( 'mizuho conv error2 : '.print_r($data, true), 'acting_transaction.log' );
937 -
938 - } else {
939 - usces_action_acting_getpoint( $order_id );
940 -
941 - $usces->set_order_meta_value( 'acting_mizuho_conv', serialize($data), $order_id );
942 -
943 - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $stran );
944 - $res = $wpdb->query( $dquery );
945 - }
946 - }
947 -
948 - } else {
949 - //header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
950 - usces_log( 'mizuho conv : '.print_r( $_GET, true ), 'acting_transaction.log' );
951 - }
952 -
953 - } elseif( '108' == substr($rsltcd, 0, 3) or '208' == substr($rsltcd, 0, 3) or '308' == substr($rsltcd, 0, 3) ) {//キャンセル
954 - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
955 - } elseif( '109' == substr($rsltcd, 0, 3) or '209' == substr($rsltcd, 0, 3) or '309' == substr($rsltcd, 0, 3) ) {//エラー
956 - usces_log( 'mizuho conv : '.print_r( $_GET, true ), 'acting_transaction.log' );
957 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_card&acting_return=0' );
958 - } else {
959 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_conv&acting_return=1&stran='.$stran.'&mbtran='.$mbtran.'&bktrans='.$_GET['bktrans'].'&tranid='.$tranid.'&rsltcd='.$rsltcd );
960 - }
961 - die();
962 -//20130225ysk end
963 -//20131220ysk start
964 - //*** AnotherLane credit ***//
965 - } elseif( isset($_GET['SiteId']) && isset($_GET['TransactionId']) && isset($_GET['Result']) ) {
966 - $acting_opts = $usces->options['acting_settings']['anotherlane'];
967 - foreach( $_GET as $key => $value ) {
968 - $data[$key] = $value;
969 - }
970 - if( $acting_opts['siteid'] == $_GET['SiteId'] && 'OK' == $_GET['Result'] ) {
971 - $table_meta_name = $wpdb->prefix."usces_order_meta";
972 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'TransactionId', $data['TransactionId'] );
973 - $order_id = $wpdb->get_var( $query );
974 - if( !$order_id ) {
975 - $res = $usces->order_processing();
976 - if( 'ordercompletion' == $res ) {
977 - $usces->cart->crear_cart();
978 - usces_log( 'AnotherLane [OK] transaction : '.$data['TransactionId'], 'acting_transaction.log' );
979 - } else {
980 - usces_log( 'AnotherLane order processing error : '.print_r($data, true), 'acting_transaction.log' );
981 - }
982 - }
983 - }
984 - exit;
985 -
986 - } elseif( isset($_GET['ali_back']) && isset($_POST['SiteId']) && isset($_POST['Result']) ) {
987 - $acting_opts = $usces->options['acting_settings']['anotherlane'];
988 - if( $acting_opts['siteid'] == $_POST['SiteId'] && 'NG' == $_POST['Result'] ) {
989 - $permalink_structure = get_option( 'permalink_structure' );
990 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
991 - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
992 - exit;
993 - } elseif( $acting_opts['siteid'] == $_POST['SiteId'] && 'OK' == $_POST['Result'] ) {
994 - $permalink_structure = get_option( 'permalink_structure' );
995 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
996 - header( 'location: '.USCES_CART_URL.$delim.'acting=anotherlane_card&acting_return=1' );
997 - exit;
998 - }
999 -//20131220ysk end
1000 -//20140206ysk start
1001 - //*** Veritrans card ***//
1002 - } elseif( isset($_GET['acting']) and 'veritrans_card' == $_GET['acting'] and isset($_POST['orderId']) and isset($_POST['merchantEncryptionKey']) ) {
1003 - if( isset($_POST['mStatus']) and 'success' == $_POST['mStatus'] ) {
1004 - $table_meta_name = $wpdb->prefix."usces_order_meta";
1005 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'orderId', $_POST['orderId'] );
1006 - $order_id = $wpdb->get_var( $query );
1007 - if( !$order_id ) {
1008 - $res = $usces->order_processing();
1009 - if( 'ordercompletion' == $res ) {
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 ) {
1010 570 $usces->cart->crear_cart();
1011 - usces_log( 'Veritrans [OK] transaction : '.$_POST['orderId'], 'acting_transaction.log' );
1012 571 } else {
1013 - usces_log( 'Veritrans order processing error : '.print_r( $_POST, true ), 'acting_transaction.log' );
572 + usces_log( 'paypal_ipn error : ' . print_r( $data, true ), 'acting_transaction.log' );
573 + die( 'error1' );
1014 574 }
575 + do_action( 'usces_action_paypal_ipn', $res, $ipn_res );
1015 576 }
577 + usces_log( 'PayPal IPN transaction : ' . wp_unslash( $_REQUEST['txn_id'] ), 'acting_transaction.log' );
1016 578 }
1017 - exit;
579 + die( 'PayPal' );
1018 580
1019 - //*** Veritrans conv ***//
1020 - } elseif( isset($_GET['acting']) and 'veritrans_conv' == $_GET['acting'] and isset($_POST['orderId']) and isset($_POST['merchantEncryptionKey']) ) {
1021 - //決済結果通知
1022 - if( isset($_POST['mStatus']) and 'success' == $_POST['mStatus'] ) {
1023 - $table_meta_name = $wpdb->prefix."usces_order_meta";
1024 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'orderId', $_POST['orderId'] );
1025 - $order_id = $wpdb->get_var( $query );
1026 - if( !$order_id ) {
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 +
1027 677 $res = $usces->order_processing();
1028 - if( 'ordercompletion' == $res ) {
1029 - $usces->cart->crear_cart();
1030 - usces_log( 'Veritrans [OK] transaction : '.$_POST['orderId'], 'acting_transaction.log' );
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 );
1031 682 } else {
1032 - usces_log( 'Veritrans order processing error : '.print_r( $_POST, true ), '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' );
1033 691 }
1034 692 }
693 +
694 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
695 + die( "0\r\n" );
696 +
697 + } elseif ( isset( $data['purchase'] ) ) {
698 + return;
699 +
700 + } else {
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 + }
1035 708 }
1036 - exit;
1037 709
1038 - } elseif( isset($_REQUEST['numberOfNotify']) and isset($_REQUEST['pushTime']) and isset($_REQUEST['pushId']) ) {
1039 - //支払通知
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 +
1040 719 $data = array();
1041 - foreach( $_REQUEST as $key => $value ) {
1042 - $num = substr( $key, -4 );
1043 - if( preg_match( "/^[0-9]+$/", $num ) ) {
1044 - $nkey = substr( $key, 0, strpos( $key, $num ) );
1045 - $data[$nkey][(int)$num] = $value;
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' );
809 + }
810 + }
811 +
812 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
813 + die( "0\r\n" );
814 +
815 + } elseif ( isset( $data['purchase'] ) ) {
816 +
1046 817 } else {
1047 - $data[$key] = $value;
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;
1048 822 }
1049 823 }
1050 824
1051 - $count = count( $data['orderId'] );
1052 - if( 0 < $count ) {
1053 - $table_name = $wpdb->prefix."usces_order";
1054 - $table_meta_name = $wpdb->prefix."usces_order_meta";
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();
1055 850
1056 - for( $i = 0; $i < $count; $i++ ) {
1057 - if( isset( $data['orderId'][$i] ) ) {
1058 - $sdata = array();
1059 - $sdata['acting'] = 'veritrans_conv';
1060 - $sdata['orderId'] = $data['orderId'][$i];
1061 - $sdata['cvsType'] = isset( $data['cvsType'][$i] ) ? $data['cvsType'][$i] : '';
1062 - $sdata['receiptNo'] = isset( $data['receiptNo'][$i] ) ? $data['receiptNo'][$i] : '';
1063 - $sdata['receiptDate'] = isset( $data['receiptDate'][$i] ) ? $data['receiptDate'][$i] : '';
1064 - $sdata['rcvAmount'] = isset( $data['rcvAmount'][$i] ) ? $data['rcvAmount'][$i] : '';
1065 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'orderId', $sdata['orderId'] );
1066 - $order_id = $wpdb->get_var( $query );
1067 - if( $order_id == NULL ) {
1068 - usces_log( 'Veritrans conv error1 : '.print_r( $sdata, true ), 'acting_transaction.log' );
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;
866 + }
867 + if ( '0000000000000' == $rsltcd ) {
868 + $table_name = $wpdb->prefix . 'usces_order';
869 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
1069 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 +
1070 894 } else {
1071 - $mquery = $wpdb->prepare("
1072 - UPDATE $table_name SET order_status =
1073 - CASE
1074 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
1075 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
1076 - ELSE CONCAT('receipted,', order_status )
1077 - END
1078 - WHERE ID = %d", $order_id );
1079 - $res = $wpdb->query( $mquery );
1080 - if( $res === false ) {
1081 - usces_log( 'Veritrans conv error2 : '.print_r( $sdata, true ), 'acting_transaction.log' );
895 + usces_action_acting_getpoint( $order_id );
1082 896
1083 - } else {
1084 - usces_action_acting_getpoint( $order_id );
897 + $usces->set_order_meta_value( 'acting_mizuho_conv', serialize( $data ), $order_id );
1085 898
1086 - $usces->set_order_meta_value( 'acting_veritrans_conv', serialize( $sdata ), $order_id );
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 + */
1087 923
1088 - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $sdata['orderId'] );
1089 - $res = $wpdb->query( $dquery );
1090 - }
1091 - }
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' );
1092 967 }
1093 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 );
1094 977 }
1095 978 exit;
1096 -//20140206ysk end
1097 - }
1098 -}
1099 -?>
979 + }
980 +}