| @@ -1,901 +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_log('remise construct : '.$_POST['X-TRANID'], 'acting_transaction.log'); | |
| 17 | - usces_set_acting_notification_time( $rand ); | |
| 18 | - } | |
| 19 | - | |
| 20 | - }elseif( in_array($_SERVER['REMOTE_ADDR'], array('210.164.6.67', '202.221.139.50')) ){//zeus | |
| 21 | - | |
| 22 | - $rand = $_REQUEST['sendpoint']; | |
| 23 | - $datas = usces_get_order_acting_data($rand); | |
| 24 | - $_GET['uscesid'] = $datas['sesid']; | |
| 25 | - if( empty($datas['sesid']) ){ | |
| 26 | - usces_log('zeus construct : error1', 'acting_transaction.log'); | |
| 27 | - }else{ | |
| 28 | - usces_log('zeus construct : '.$_REQUEST['sendpoint'], 'acting_transaction.log'); | |
| 29 | - } | |
| 30 | - | |
| 31 | - } elseif( isset($_POST['res_result']) && isset($_POST['res_pay_method']) ) {//SoftBankPayment | |
| 32 | - | |
| 33 | - $rand = $_REQUEST['order_id']; | |
| 34 | - $datas = usces_get_order_acting_data($rand); | |
| 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 : '.$_REQUEST['order_id'], 'acting_transaction.log'); | |
| 40 | - } | |
| 41 | - | |
| 42 | - } elseif( isset($_POST['SID']) && isset($_POST['FUKA']) && isset($_POST['CVS']) ) {//digitalcheck_conv | |
| 43 | - | |
| 44 | - $rand = $_REQUEST['SID']; | |
| 45 | - $datas = usces_get_order_acting_data($rand); | |
| 46 | - $_GET['uscesid'] = $datas['sesid']; | |
| 47 | - if( empty($datas['sesid']) ) { | |
| 48 | - usces_log('digitalcheck construct : error1', 'acting_transaction.log'); | |
| 49 | - } else { | |
| 50 | - usces_log('digitalcheck construct : '.$_REQUEST['SID'], 'acting_transaction.log'); | |
| 51 | - } | |
| 52 | - } | |
| 53 | -} | |
| 54 | - | |
| 55 | -function usces_action_acting_transaction(){ | |
| 56 | - global $usces, $wpdb; | |
| 57 | - | |
| 58 | - //*** remise_card ***// | |
| 59 | - if(isset($_POST['X-TRANID']) && !isset($_POST['OPT'])){ | |
| 60 | - foreach( $_POST as $key => $value ){ | |
| 61 | - $data[$key] = mb_convert_encoding($value, 'UTF-8', 'SJIS'); | |
| 62 | - } | |
| 63 | - usces_log('remise acting_transaction : '.print_r($data, true), 'acting_transaction.log'); | |
| 64 | - | |
| 65 | - $rand = $_POST['X-S_TORIHIKI_NO']; | |
| 66 | -// if( empty($rand) ){ | |
| 67 | -// usces_log('remise card error1 : '.print_r($data, true), 'acting_transaction.log'); | |
| 68 | -// die('error1'); | |
| 69 | -// }else{ | |
| 70 | -// $res = usces_check_notification_time( $rand, 15 ); | |
| 71 | -// if( !$res ) | |
| 72 | -// die('error : time over'); | |
| 73 | -// } | |
| 74 | -// | |
| 75 | -// if( 0 !== (int)$_POST['X-ERRLEVEL'] ){ | |
| 76 | -// usces_log('remise card error2 : '.print_r($data, true), 'acting_transaction.log'); | |
| 77 | -// die('error2'); | |
| 78 | -// } | |
| 79 | - | |
| 80 | - if( '0000000' === substr($rand, 0, 7) ){//card up | |
| 81 | - usces_log('remise card_update : '.print_r($data, true), 'acting_transaction.log'); | |
| 82 | - if( isset($_POST['X-EXPIRE']) ){ | |
| 83 | - $expire = substr($_POST['X-EXPIRE'], 0, 2) . '/' . substr($_POST['X-EXPIRE'], 2, 2); | |
| 84 | - $usces->set_member_meta_value('limitofcard', $expire, $_POST['X-AC_S_KAIIN_NO']); | |
| 85 | - } | |
| 86 | - if( isset($_POST['X-PARTOFCARD']) ) | |
| 87 | - $usces->set_member_meta_value('partofcard', $_POST['X-PARTOFCARD'], $_POST['X-AC_S_KAIIN_NO']); | |
| 88 | - | |
| 89 | -//20120510ysk start | |
| 90 | - //die('<SDBKDATA>STATUS=800</SDBKDATA>'); | |
| 91 | - $status = (isset($_POST['CARIER_TYPE'])) ? '900' : '800'; | |
| 92 | - die('<SDBKDATA>STATUS='.$status.'</SDBKDATA>'); | |
| 93 | -//20120510ysk end | |
| 94 | - } | |
| 95 | - | |
| 96 | -//20110203ysk start | |
| 97 | -// $res = $usces->order_processing(); | |
| 98 | -// if( 'error' == $res ){ | |
| 99 | -// usces_log('remise card error3 : '.print_r($data, true), 'acting_transaction.log'); | |
| 100 | -// die('error3'); | |
| 101 | -// }else{ | |
| 102 | - if( isset($_POST['X-PAYQUICKID']) ) | |
| 103 | - $usces->set_member_meta_value('remise_pcid', $_POST['X-PAYQUICKID']); | |
| 104 | - if( isset($_POST['X-AC_MEMBERID']) ) | |
| 105 | - $usces->set_member_meta_value('remise_memid', $_POST['X-AC_MEMBERID']); | |
| 106 | -//20120511ysk start | |
| 107 | - if( isset($_POST['X-EXPIRE']) ) { | |
| 108 | - $limitofcard = substr($_POST['X-EXPIRE'], 0, 2) . '/' . substr($_POST['X-EXPIRE'], 2, 2); | |
| 109 | - $usces->set_member_meta_value('limitofcard', $limitofcard); | |
| 110 | - } | |
| 111 | - if( isset($_POST['X-PARTOFCARD']) ) | |
| 112 | - $usces->set_member_meta_value('partofcard', $_POST['X-PARTOFCARD']); | |
| 113 | -//20120511ysk end | |
| 114 | - usces_log('remise card transaction : '.$_POST['X-TRANID'], 'acting_transaction.log'); | |
| 115 | -//20120510ysk start | |
| 116 | - //die('<SDBKDATA>STATUS=800</SDBKDATA>'); | |
| 117 | - $status = (isset($_POST['CARIER_TYPE'])) ? '900' : '800'; | |
| 118 | - die('<SDBKDATA>STATUS='.$status.'</SDBKDATA>'); | |
| 119 | -//20120510ysk end | |
| 120 | -// } | |
| 121 | -//20110203ysk end | |
| 122 | - | |
| 123 | - //*** remise_conv ***// | |
| 124 | - }elseif( isset($_POST['S_TORIHIKI_NO']) && isset($_POST['REC_FLG']) ){ | |
| 125 | - foreach( $_POST as $key => $value ){ | |
| 126 | - $data[$key] = mb_convert_encoding($value, 'UTF-8', 'SJIS'); | |
| 127 | - } | |
| 128 | - | |
| 129 | - $table_name = $wpdb->prefix . "usces_order"; | |
| 130 | - $table_meta_name = $wpdb->prefix . "usces_order_meta"; | |
| 131 | - | |
| 132 | - $mquery = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_POST['S_TORIHIKI_NO']); | |
| 133 | - $order_id = $wpdb->get_var( $mquery ); | |
| 134 | - if( $order_id == NULL ){ | |
| 135 | - usces_log('remise conv error1 : '.print_r($data, true), 'acting_transaction.log'); | |
| 136 | - die('error1'); | |
| 137 | - } | |
| 138 | - | |
| 139 | - $mquery = $wpdb->prepare(" | |
| 140 | - UPDATE $table_name SET order_status = | |
| 141 | - CASE | |
| 142 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted') | |
| 143 | - WHEN LOCATE('receipted', order_status) > 0 THEN order_status | |
| 144 | - ELSE CONCAT('receipted,', order_status ) | |
| 145 | - END | |
| 146 | - WHERE ID = %d", $order_id); | |
| 147 | - $res = $wpdb->query( $mquery ); | |
| 148 | - if( $res === false ){ | |
| 149 | - usces_log('remise conv error2 : '.print_r($data, true), 'acting_transaction.log'); | |
| 150 | - die('error2'); | |
| 151 | - } | |
| 152 | - | |
| 153 | - $datastr = serialize( $data ); | |
| 154 | - $mquery = $wpdb->prepare( | |
| 155 | - "UPDATE $table_meta_name SET meta_value = %s WHERE meta_key = %s AND order_id = %d", $datastr, 'settlement_id', $order_id); | |
| 156 | - $res = $wpdb->query( $mquery ); | |
| 157 | - if( $res === false ){ | |
| 158 | - usces_log('remise conv error3 : '.print_r($data, true), 'acting_transaction.log'); | |
| 159 | - die('error3'); | |
| 160 | - } | |
| 161 | - | |
| 162 | - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324 | |
| 163 | - | |
| 164 | - //usces_send_receipted_mail( $order_id, 'remise_conv' ); | |
| 165 | - usces_log('remise conv transaction : '.$_POST['S_TORIHIKI_NO'], 'acting_transaction.log'); | |
| 166 | - die('<SDBKDATA>STATUS=800</SDBKDATA>'); | |
| 167 | - | |
| 168 | - //*** zeus_card ***// | |
| 169 | - }elseif( isset($_REQUEST['acting']) && 'zeus_card' == $_REQUEST['acting'] && isset($_REQUEST['result']) && isset($_REQUEST['ordd']) ){ | |
| 170 | - foreach( $_REQUEST as $key => $value ){ | |
| 171 | - $data[$key] = $value; | |
| 172 | - } | |
| 173 | -//usces_log('zeus card : '.print_r($data, true), 'acting_transaction.log'); | |
| 174 | - | |
| 175 | - $acting_opts = $usces->options['acting_settings']['zeus']; | |
| 176 | - | |
| 177 | - $rand = $_GET['sendpoint']; | |
| 178 | - if( empty($rand) ){ | |
| 179 | - usces_log('zeus card error1 : '.print_r($data, true), 'acting_transaction.log'); | |
| 180 | - die('error1'); | |
| 181 | - } | |
| 182 | - | |
| 183 | - if( 'OK' == $_REQUEST['result'] ){ | |
| 184 | - header("HTTP/1.0 200 OK"); | |
| 185 | - die('zeus'); | |
| 186 | - }else{ | |
| 187 | - usces_log('zeus card error3 : '.print_r($data, true), 'acting_transaction.log'); | |
| 188 | - header("HTTP/1.0 200 OK"); | |
| 189 | - die('error3'); | |
| 190 | - } | |
| 191 | - | |
| 192 | - //*** zeus_bank ***// | |
| 193 | - }elseif( isset($_REQUEST['acting']) && 'zeus_bank' == $_REQUEST['acting'] && isset($_REQUEST['order_no']) && isset($_REQUEST['tracking_no']) ){ | |
| 194 | - foreach( $_REQUEST as $key => $value ){ | |
| 195 | - $data[$key] = $value; | |
| 196 | - } | |
| 197 | - usces_log('zeus construct_data : '.print_r($data,true), 'acting_transaction.log'); | |
| 198 | - | |
| 199 | - $acting_opts = $usces->options['acting_settings']['zeus']; | |
| 200 | - | |
| 201 | - $table_name = $wpdb->prefix . "usces_order"; | |
| 202 | - $table_meta_name = $wpdb->prefix . "usces_order_meta"; | |
| 203 | - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['tracking_no']); | |
| 204 | - $values = $wpdb->get_row( $mquery, ARRAY_A ); | |
| 205 | - //usces_log('zeus construct_values1 : '.print_r($values,true), 'acting_transaction.log'); | |
| 206 | - if( $values == NULL ){ | |
| 207 | - | |
| 208 | -//20110203ysk start | |
| 209 | - $res = $usces->order_processing(); | |
| 210 | - if( 'error' == $res ){ | |
| 211 | - usces_log('zeus bank error1 : '.print_r($data, true), 'acting_transaction.log'); | |
| 212 | - die('error1'); | |
| 213 | - }else{ | |
| 214 | - $order_id = $usces->cart->get_order_entry('ID'); | |
| 215 | - $value = serialize($_GET); | |
| 216 | - $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); | |
| 217 | - $res = $wpdb->query( $query ); | |
| 218 | - | |
| 219 | - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['tracking_no']); | |
| 220 | - $values = $wpdb->get_row( $mquery, ARRAY_A ); | |
| 221 | - $usces->cart->crear_cart(); | |
| 222 | - } | |
| 223 | -//20110203ysk end | |
| 224 | - } | |
| 225 | - | |
| 226 | - //usces_log('zeus construct_values2 : '.print_r($values,true), 'acting_transaction.log'); | |
| 227 | - $value = unserialize($values['meta_value']); | |
| 228 | - $status = ( '03' === $_REQUEST['status'] ) ? 'receipted,' : 'noreceipt,'; | |
| 229 | - $order_id = $values['order_id']; | |
| 230 | - $add_point = true;//20120306ysk 0000324 | |
| 231 | - if( 'receipted,' == $status ){ | |
| 232 | - $mquery = $wpdb->prepare(" | |
| 233 | - UPDATE $table_name SET order_status = | |
| 234 | - CASE | |
| 235 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted') | |
| 236 | - WHEN LOCATE('receipted', order_status) > 0 THEN order_status | |
| 237 | - ELSE CONCAT('receipted,', order_status ) | |
| 238 | - END | |
| 239 | - WHERE ID = %d", $order_id); | |
| 240 | - }else{ | |
| 241 | - $mquery = $wpdb->prepare(" | |
| 242 | - UPDATE $table_name SET order_status = | |
| 243 | - CASE | |
| 244 | - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt') | |
| 245 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status | |
| 246 | - ELSE CONCAT('noreceipt,', order_status ) | |
| 247 | - END | |
| 248 | - WHERE ID = %d", $order_id); | |
| 249 | - $add_point = false;//20120306ysk 0000324 | |
| 250 | - } | |
| 251 | - $res = $wpdb->query( $mquery ); | |
| 252 | - if( false === $res ){ | |
| 253 | - usces_log('zeus bank error2 : '.print_r($data, true), 'acting_transaction.log'); | |
| 254 | - die('error2'); | |
| 255 | - } | |
| 256 | - usces_action_acting_getpoint( $order_id, $add_point );//20120306ysk 0000324 | |
| 257 | - | |
| 258 | - $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'] ); | |
| 259 | - $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']); | |
| 260 | - //usces_log('mquery2 : '.print_r($mquery, true), 'acting_transaction.log'); | |
| 261 | - $res = $wpdb->query( $mquery ); | |
| 262 | - if(!$res){ | |
| 263 | - usces_log('zeus bank error3 : '.print_r($data, true), 'acting_transaction.log'); | |
| 264 | - die('error3'); | |
| 265 | - } | |
| 266 | - | |
| 267 | - usces_log('zeus bank transaction : '.$_REQUEST['tracking_no'], 'acting_transaction.log'); | |
| 268 | - die('zeus'); | |
| 269 | - | |
| 270 | - //*** zeus_conv ***// | |
| 271 | - }elseif( isset($_REQUEST['acting']) && 'zeus_conv' == $_REQUEST['acting'] && isset($_REQUEST['status']) && isset($_REQUEST['sendpoint']) ){ | |
| 272 | - foreach( $_REQUEST as $key => $value ){ | |
| 273 | - $data[$key] = $value; | |
| 274 | - } | |
| 275 | - | |
| 276 | - $acting_opts = $usces->options['acting_settings']['zeus']; | |
| 277 | - | |
| 278 | - $table_name = $wpdb->prefix . "usces_order"; | |
| 279 | - $table_meta_name = $wpdb->prefix . "usces_order_meta"; | |
| 280 | - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['sendpoint']); | |
| 281 | - $values = $wpdb->get_row( $mquery, ARRAY_A ); | |
| 282 | - if( $values == NULL ){ | |
| 283 | - | |
| 284 | -//20110203ysk start | |
| 285 | - $res = $usces->order_processing(); | |
| 286 | - if( 'error' == $res ){ | |
| 287 | - usces_log('zeus conv error1 : '.print_r($data, true), 'acting_transaction.log'); | |
| 288 | - die('error1'); | |
| 289 | - }else{ | |
| 290 | - $order_id = $usces->cart->get_order_entry('ID'); | |
| 291 | - $value = serialize($_GET); | |
| 292 | - $query = $wpdb->prepare("INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $order_id, 'acting_'.$_REQUEST['sendpoint'], $value); | |
| 293 | - $res = $wpdb->query( $query ); | |
| 294 | - } | |
| 295 | -//20110203ysk end | |
| 296 | - | |
| 297 | - | |
| 298 | - }else{ | |
| 299 | - | |
| 300 | - $value = unserialize($values['meta_value']); | |
| 301 | - $status = ( '04' === $_REQUEST['status'] ) ? 'receipted,' : 'noreceipt,'; | |
| 302 | - $order_id = $values['order_id']; | |
| 303 | - $add_point = true;//20120306ysk 0000324 | |
| 304 | - if( 'receipted,' == $status ){ | |
| 305 | - $mquery = $wpdb->prepare(" | |
| 306 | - UPDATE $table_name SET order_status = | |
| 307 | - CASE | |
| 308 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted') | |
| 309 | - WHEN LOCATE('receipted', order_status) > 0 THEN order_status | |
| 310 | - ELSE CONCAT('receipted,', order_status ) | |
| 311 | - END | |
| 312 | - WHERE ID = %d", $order_id); | |
| 313 | - }else{ | |
| 314 | - $mquery = $wpdb->prepare(" | |
| 315 | - UPDATE $table_name SET order_status = | |
| 316 | - CASE | |
| 317 | - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt') | |
| 318 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status | |
| 319 | - ELSE CONCAT('noreceipt,', order_status ) | |
| 320 | - END | |
| 321 | - WHERE ID = %d", $order_id); | |
| 322 | - $add_point = false;//20120306ysk 0000324 | |
| 323 | - } | |
| 324 | - $res = $wpdb->query( $mquery ); | |
| 325 | - if(!$res){ | |
| 326 | - usces_log('zeus conv error2 : '.print_r($data, true), 'acting_transaction.log'); | |
| 327 | - die('error2'); | |
| 328 | - } | |
| 329 | - foreach( $_GET as $key => $v ){ | |
| 330 | - $newvalue[$key] = mb_convert_encoding($v, 'UTF-8', 'SJIS'); | |
| 331 | - } | |
| 332 | - $value = serialize($newvalue); | |
| 333 | - $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']); | |
| 334 | - $res = $wpdb->query( $mquery ); | |
| 335 | - if(!$res){ | |
| 336 | - usces_log('zeus conv error3 : '.print_r($data, true), 'acting_transaction.log'); | |
| 337 | - die('error3'); | |
| 338 | - } | |
| 339 | - usces_action_acting_getpoint( $order_id, $add_point );//20120306ysk 0000324 | |
| 340 | - } | |
| 341 | - | |
| 342 | - usces_log('zeus conv transaction : '.$_REQUEST['sendpoint'], 'acting_transaction.log'); | |
| 343 | - die('zeus'); | |
| 344 | - | |
| 345 | -//20101018ysk start | |
| 346 | - //*** jpayment_card ***// | |
| 347 | - } elseif(isset($_REQUEST['acting']) && 'jpayment_card' == $_REQUEST['acting']) { | |
| 348 | - //$args=''; | |
| 349 | - //foreach((array)$_GET as $key => $value) { | |
| 350 | - // $args.='&('.$key.')=('.$value.')'; | |
| 351 | - //} | |
| 352 | - //usces_log('jpayment card : '.$args, 'acting_transaction.log'); | |
| 353 | - | |
| 354 | - //*** jpayment_conv ***// | |
| 355 | - } elseif(isset($_REQUEST['acting']) && 'jpayment_conv' == $_REQUEST['acting'] && isset($_GET['ap'])) { | |
| 356 | - //$args=''; | |
| 357 | - //foreach((array)$_GET as $key => $value) { | |
| 358 | - // $args.='&('.$key.')=('.$value.')'; | |
| 359 | - //} | |
| 360 | - //usces_log('jpayment conv : '.$args, 'acting_transaction.log'); | |
| 361 | - foreach( $_REQUEST as $key => $value ){ | |
| 362 | - $data[$key] = $value; | |
| 363 | - } | |
| 364 | - | |
| 365 | - switch($_GET['ap']) { | |
| 366 | - case 'CPL_PRE'://コンビニペーパーレス決済識別コード | |
| 367 | - break; | |
| 368 | - | |
| 369 | - case 'CPL'://入金確定 | |
| 370 | - $table_name = $wpdb->prefix."usces_order"; | |
| 371 | - $table_meta_name = $wpdb->prefix."usces_order_meta"; | |
| 372 | - | |
| 373 | - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']); | |
| 374 | - $order_id = $wpdb->get_var($query); | |
| 375 | - if($order_id == NULL) { | |
| 376 | - usces_log('jpayment conv error1 : '.print_r($data, true), 'acting_transaction.log'); | |
| 377 | - die('error1'); | |
| 378 | - } | |
| 379 | - | |
| 380 | - $query = $wpdb->prepare(" | |
| 381 | - UPDATE $table_name SET order_status = | |
| 382 | - CASE | |
| 383 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted') | |
| 384 | - WHEN LOCATE('receipted', order_status) > 0 THEN order_status | |
| 385 | - ELSE CONCAT('receipted,', order_status ) | |
| 386 | - END | |
| 387 | - WHERE ID = %d", $order_id); | |
| 388 | - $res = $wpdb->query($query); | |
| 389 | - if($res === false) { | |
| 390 | - usces_log('jpayment conv error2 : '.print_r($data, true), 'acting_transaction.log'); | |
| 391 | - die('error2'); | |
| 392 | - } | |
| 393 | - | |
| 394 | - foreach($_GET as $key => $value) { | |
| 395 | - $data[$key] = mysql_real_escape_string($value); | |
| 396 | - } | |
| 397 | - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id); | |
| 398 | - if($res === false) { | |
| 399 | - usces_log('jpayment conv error3 : '.print_r($data, true), 'acting_transaction.log'); | |
| 400 | - die('error3'); | |
| 401 | - } | |
| 402 | - | |
| 403 | - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324 | |
| 404 | - | |
| 405 | - usces_log('J-Payment conv transaction : '.$_GET['gid'], 'acting_transaction.log'); | |
| 406 | - die('J-Payment'); | |
| 407 | - break; | |
| 408 | - | |
| 409 | - case 'CVS_CAN'://入金取消 | |
| 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('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt') | |
| 424 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status | |
| 425 | - ELSE CONCAT('noreceipt,', 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] = mysql_real_escape_string($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, false );//20120306ysk 0000324 | |
| 444 | - | |
| 445 | - usces_log('J-Payment conv transaction : '.$_GET['gid'], 'acting_transaction.log'); | |
| 446 | - die('J-Payment'); | |
| 447 | - break; | |
| 448 | - } | |
| 449 | - | |
| 450 | - //*** jpayment_bank ***// | |
| 451 | - } elseif(isset($_REQUEST['acting']) && 'jpayment_bank' == $_REQUEST['acting']) { | |
| 452 | - //$args=''; | |
| 453 | - //foreach((array)$_GET as $key => $value) { | |
| 454 | - // $args.='&('.$key.')=('.$value.')'; | |
| 455 | - //} | |
| 456 | - //usces_log('jpayment bank : '.$args, 'acting_transaction.log'); | |
| 457 | - foreach( $_REQUEST as $key => $value ){ | |
| 458 | - $data[$key] = $value; | |
| 459 | - } | |
| 460 | - | |
| 461 | - switch($_GET['ap']) { | |
| 462 | - case 'BANK'://受付完了 | |
| 463 | - break; | |
| 464 | - | |
| 465 | - case 'BAN_SAL'://入金完了 | |
| 466 | - if($_GET['mf'] == '1') {//入金マッチングの場合 | |
| 467 | - $table_name = $wpdb->prefix."usces_order"; | |
| 468 | - $table_meta_name = $wpdb->prefix."usces_order_meta"; | |
| 469 | - | |
| 470 | - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']); | |
| 471 | - $order_id = $wpdb->get_var($query); | |
| 472 | - if($order_id == NULL) { | |
| 473 | - usces_log('jpayment bank error1 : '.print_r($data, true), 'acting_transaction.log'); | |
| 474 | - die('error1'); | |
| 475 | - } | |
| 476 | - | |
| 477 | - $query = $wpdb->prepare(" | |
| 478 | - UPDATE $table_name SET order_status = | |
| 479 | - CASE | |
| 480 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted') | |
| 481 | - WHEN LOCATE('receipted', order_status) > 0 THEN order_status | |
| 482 | - ELSE CONCAT('receipted,', order_status ) | |
| 483 | - END | |
| 484 | - WHERE ID = %d", $order_id); | |
| 485 | - $res = $wpdb->query($query); | |
| 486 | - if($res === false) { | |
| 487 | - usces_log('jpayment bank error2 : '.print_r($data, true), 'acting_transaction.log'); | |
| 488 | - die('error2'); | |
| 489 | - } | |
| 490 | - | |
| 491 | - foreach($_GET as $key => $value) { | |
| 492 | - $data[$key] = mysql_real_escape_string($value); | |
| 493 | - } | |
| 494 | - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id); | |
| 495 | - if($res === false) { | |
| 496 | - usces_log('jpayment bank error3 : '.print_r($data, true), 'acting_transaction.log'); | |
| 497 | - die('error3'); | |
| 498 | - } | |
| 499 | - | |
| 500 | - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324 | |
| 501 | - } | |
| 502 | - | |
| 503 | - usces_log('J-Payment bank transaction : '.$_REQUEST['gid'], 'acting_transaction.log'); | |
| 504 | - die('J-Payment'); | |
| 505 | - break; | |
| 506 | - } | |
| 507 | -//20101018ysk end | |
| 508 | - //*** epsilon ***// | |
| 509 | - }elseif( !isset($_GET['acting_return']) && isset($_GET['trans_code']) && isset($_GET['user_id']) && isset($_GET['result']) && isset($_GET['order_number']) ){ | |
| 510 | - $query = 'trans_code=' . $_GET['trans_code'] . '&user_id=' . $_GET['user_id'] . '&result=' . $_GET['result'] . '&order_number=' . $_GET['order_number']; | |
| 511 | - usces_log('epsilon (acting_transaction) : ' . $query, 'acting_transaction.log'); | |
| 512 | - $permalink_structure = get_option('permalink_structure'); | |
| 513 | - $delim = ( !$usces->use_ssl && $permalink_structure) ? '?' : '&'; | |
| 514 | - | |
| 515 | - header('location: ' . USCES_CART_URL . $delim . 'acting=epsilon&acting_return=1&' . $query ); | |
| 516 | - exit; | |
| 517 | -//20110208ysk start | |
| 518 | - } elseif( !isset($_GET['acting_return']) && (isset($_GET['acting']) && 'paypal_ipn' == $_GET['acting']) ) { | |
| 519 | - foreach( $_REQUEST as $key => $value ){ | |
| 520 | - $data[$key] = $value; | |
| 521 | - } | |
| 522 | - usces_log('paypal_ipn in '.print_r($data,true), 'acting_transaction.log'); | |
| 523 | - require_once($usces->options['settlement_path'] . 'paypal.php'); | |
| 524 | - $ipn_res = paypal_ipn_check($usces_paypal_url); | |
| 525 | - if( $ipn_res[0] === true ){ | |
| 526 | - $res = $usces->order_processing( $ipn_res ); | |
| 527 | - if( 'ordercompletion' == $res ){ | |
| 528 | - $usces->cart->crear_cart(); | |
| 529 | - }else{ | |
| 530 | - usces_log('paypal_ipn error : '.print_r($data, true), 'acting_transaction.log'); | |
| 531 | - die('error1'); | |
| 532 | - } | |
| 533 | - do_action('usces_action_paypal_ipn', $res, $ipn_res); | |
| 534 | - } | |
| 535 | - usces_log('PayPal IPN transaction : '.$_REQUEST['txn_id'], 'acting_transaction.log'); | |
| 536 | - die('PayPal'); | |
| 537 | -//20110523ysk start | |
| 538 | - //*** paypal ipn ***// | |
| 539 | - } elseif( isset($_GET['ipn_track_id']) ) { | |
| 540 | - foreach( $_REQUEST as $key => $value ){ | |
| 541 | - $data[$key] = $value; | |
| 542 | - } | |
| 543 | - usces_log('paypal ipn : '.print_r($data, true), 'acting_transaction.log'); | |
| 544 | - die('PayPal'); | |
| 545 | -//20110523ysk end | |
| 546 | -//20120413ysk start | |
| 547 | - //*** SoftBankPayment ***// | |
| 548 | - } elseif( !isset($_GET['acting_return']) && isset($_POST['res_result']) && isset($_POST['res_pay_method']) ) { | |
| 549 | - //usces_log('SoftBankPayment : '.print_r($_REQUEST, true), 'acting_transaction.log'); | |
| 550 | - foreach( $_POST as $key => $value ) { | |
| 551 | - $data[$key] = mb_convert_encoding($value, 'UTF-8', 'SJIS'); | |
| 552 | - } | |
| 553 | - $acting = $data['free1']; | |
| 554 | - | |
| 555 | - switch( $data['res_result'] ) { | |
| 556 | - case 'OK'://決済処理OK | |
| 557 | - $table_meta_name = $wpdb->prefix."usces_order_meta"; | |
| 558 | - $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']); | |
| 559 | - $order_id = $wpdb->get_var($query); | |
| 560 | - if( !$order_id ) { | |
| 561 | - | |
| 562 | - $res = $usces->order_processing(); | |
| 563 | - if( 'ordercompletion' == $res ){ | |
| 564 | - $usces->cart->crear_cart(); | |
| 565 | - } else { | |
| 566 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' order processing error : '.print_r($data, true), 'acting_transaction.log'); | |
| 567 | - die('NG,order processing error'); | |
| 568 | - } | |
| 569 | - } | |
| 570 | - | |
| 571 | - //$acting_opts = $usces->options['acting_settings']['sbps']; | |
| 572 | - //if( 'on' == $acting_opts['cust'] ) { | |
| 573 | - // $usces->set_member_meta_value( 'sbps_cust_no', $data['res_sps_cust_no'], $data['cust_code'] ); | |
| 574 | - // $usces->set_member_meta_value( 'sbps_payment_no', $data['res_sps_payment_no'], $data['cust_code'] ); | |
| 575 | - //} | |
| 576 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' [OK] transaction : '.$data['res_tracking_id'], 'acting_transaction.log'); | |
| 577 | - die('OK,'); | |
| 578 | - break; | |
| 579 | - | |
| 580 | - case 'PY'://入金結果通知 | |
| 581 | - $table_name = $wpdb->prefix."usces_order"; | |
| 582 | - $table_meta_name = $wpdb->prefix."usces_order_meta"; | |
| 583 | - $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']); | |
| 584 | - $order_id = $wpdb->get_var($query); | |
| 585 | - if( $order_id == NULL ) { | |
| 586 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error1 : '.print_r($data, true), 'acting_transaction.log'); | |
| 587 | - die('NG,order_id error'); | |
| 588 | - } | |
| 589 | - | |
| 590 | - $query = $wpdb->prepare(" | |
| 591 | - UPDATE $table_name SET order_status = | |
| 592 | - CASE | |
| 593 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted') | |
| 594 | - WHEN LOCATE('receipted', order_status) > 0 THEN order_status | |
| 595 | - ELSE CONCAT('receipted,', order_status ) | |
| 596 | - END | |
| 597 | - WHERE ID = %d", $order_id); | |
| 598 | - $res = $wpdb->query($query); | |
| 599 | - if( $res === false ) { | |
| 600 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error2 : '.print_r($data, true), 'acting_transaction.log'); | |
| 601 | - die('NG,usces_order update error'); | |
| 602 | - } | |
| 603 | - | |
| 604 | - $res = $usces->set_order_meta_value($acting, serialize($data), $order_id); | |
| 605 | - if( $res === false ) { | |
| 606 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error3 : '.print_r($data, true), 'acting_transaction.log'); | |
| 607 | - die('NG,usces_order_meta update error'); | |
| 608 | - } | |
| 609 | - | |
| 610 | - usces_action_acting_getpoint( $order_id ); | |
| 611 | - | |
| 612 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] transaction : '.$order_id, 'acting_transaction.log'); | |
| 613 | - die('OK,'); | |
| 614 | - | |
| 615 | - case 'CN'://期限切通知 | |
| 616 | - $table_name = $wpdb->prefix."usces_order"; | |
| 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 == NULL ) { | |
| 621 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error1 : '.print_r($data, true), 'acting_transaction.log'); | |
| 622 | - die('NG,order_id error'); | |
| 623 | - } | |
| 624 | - | |
| 625 | - $query = $wpdb->prepare(" | |
| 626 | - UPDATE $table_name SET order_status = | |
| 627 | - CASE | |
| 628 | - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt') | |
| 629 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status | |
| 630 | - ELSE CONCAT('noreceipt,', order_status ) | |
| 631 | - END | |
| 632 | - WHERE ID = %d", $order_id); | |
| 633 | - $res = $wpdb->query($query); | |
| 634 | - if( $res === false ) { | |
| 635 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error2 : '.print_r($data, true), 'acting_transaction.log'); | |
| 636 | - die('NG,usces_order update error'); | |
| 637 | - } | |
| 638 | - | |
| 639 | - $res = $usces->set_order_meta_value($acting, serialize($data), $order_id); | |
| 640 | - if( $res === false ) { | |
| 641 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error3 : '.print_r($data, true), 'acting_transaction.log'); | |
| 642 | - die('NG,usces_order_meta update error'); | |
| 643 | - } | |
| 644 | - | |
| 645 | - usces_action_acting_getpoint( $order_id, false ); | |
| 646 | - | |
| 647 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] transaction : '.$order_id, 'acting_transaction.log'); | |
| 648 | - die('OK,'); | |
| 649 | - | |
| 650 | - default: | |
| 651 | - usces_log('SoftBankPayment '.$data['res_pay_method'].' ['.$data['res_result'].'] : '.print_r($data,true), 'acting_transaction.log'); | |
| 652 | - die('OK,'); | |
| 653 | - } | |
| 654 | -//20120413ysk end | |
| 655 | -//20121030ysk start | |
| 656 | - //*** telecom credit ***// | |
| 657 | - } elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && (isset($_REQUEST['acting']) && 'telecom_edy' == $_REQUEST['acting']) ) { | |
| 658 | - foreach( $_REQUEST as $key => $value ) { | |
| 659 | - $data[$key] = $value; | |
| 660 | - } | |
| 661 | - usces_log('telecom edy : '.print_r($data, true), 'acting_transaction.log'); | |
| 662 | - //die('SuccessOK'); | |
| 663 | - } elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && isset($_REQUEST['edy']) ) { | |
| 664 | - foreach( $_REQUEST as $key => $value ) { | |
| 665 | - $data[$key] = $value; | |
| 666 | - } | |
| 667 | - if( $_REQUEST['rel'] === 'yes' && isset($_REQUEST['option']) ) { | |
| 668 | - $table_meta_name = $wpdb->prefix."usces_order_meta"; | |
| 669 | - $mquery = $wpdb->prepare( "SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", $_REQUEST['option'] ); | |
| 670 | - $mvalue = $wpdb->get_row( $mquery, ARRAY_A ); | |
| 671 | - $value = unserialize( $mvalue['meta_value'] ); | |
| 672 | - $_SESSION['usces_cart'] = $value['usces_cart']; | |
| 673 | - $_SESSION['usces_entry'] = $value['usces_entry']; | |
| 674 | - $_SESSION['usces_member'] = $value['usces_member']; | |
| 675 | - $res = $usces->order_processing(); | |
| 676 | - if( 'ordercompletion' == $res ) { | |
| 677 | - $query = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $_REQUEST['option'] ); | |
| 678 | - $res = $wpdb->query( $query ); | |
| 679 | - usces_log('telecom edy - Payment confirmation : '.print_r($data, true), 'acting_transaction.log'); | |
| 680 | - } else { | |
| 681 | - usces_log('telecom edy - Error 1 : '.print_r($data, true), 'acting_transaction.log'); | |
| 682 | - } | |
| 683 | - } else { | |
| 684 | - usces_log('telecom edy - Error 2 : '.print_r($data, true), 'acting_transaction.log'); | |
| 685 | - } | |
| 686 | - die('SuccessOK'); | |
| 687 | -//20121030ysk end | |
| 688 | -//20120618ysk start | |
| 689 | - //*** telecom credit ***// | |
| 690 | - }elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && isset($_REQUEST['rel']) ){ | |
| 691 | - foreach( $_REQUEST as $key => $value ){ | |
| 692 | - $data[$key] = $value; | |
| 693 | - } | |
| 694 | - usces_log('telecom card : '.print_r($data, true), 'acting_transaction.log'); | |
| 695 | - die('SuccessOK'); | |
| 696 | -//20120618ysk end | |
| 697 | -//20121206ysk start | |
| 698 | - //*** digitalcheck card ***// | |
| 699 | - } elseif( isset($_REQUEST['SID']) && isset($_REQUEST['FUKA']) && substr($_REQUEST['FUKA'], 0, 24) == 'acting_digitalcheck_card' ) { | |
| 700 | - foreach( $_REQUEST as $key => $value ) { | |
| 701 | - $data[$key] = $value; | |
| 702 | - } | |
| 703 | - $sid = ( isset($data['SID']) ) ? $data['SID'] : ''; | |
| 704 | -//usces_log('digitalcheck card : '.print_r($data, true), 'digitalcheck.log'); | |
| 705 | - | |
| 706 | - if( isset($data['SEQ']) ) { | |
| 707 | - $acting_opts = $usces->options['acting_settings']['digitalcheck']; | |
| 708 | - $ip_user_id = substr($data['FUKA'], 24); | |
| 709 | -//usces_log('ip_user_id : '.$ip_user_id, 'digitalcheck.log'); | |
| 710 | - if( 'on' == $acting_opts['card_user_id'] and !empty($ip_user_id) ) { | |
| 711 | - $usces->set_member_meta_value('digitalcheck_ip_user_id', $ip_user_id, $ip_user_id); | |
| 712 | - } | |
| 713 | - | |
| 714 | - $res = $usces->order_processing(); | |
| 715 | - if( 'ordercompletion' == $res ) { | |
| 716 | - $order_id = $usces->cart->get_order_entry('ID'); | |
| 717 | - $usces->set_order_meta_value( 'acting_digitalcheck_card', serialize( $data ), $order_id ); | |
| 718 | - } else { | |
| 719 | - usces_log('digitalcheck card : order processing error', 'acting_transaction.log'); | |
| 720 | - } | |
| 721 | - | |
| 722 | - header('content-type : text/plain;charset=Shift_JIS'); | |
| 723 | - die("0"); | |
| 724 | - } | |
| 725 | - | |
| 726 | - //*** digitalcheck conv ***// | |
| 727 | - } elseif( isset($_REQUEST['SID']) && isset($_REQUEST['FUKA']) && substr($_REQUEST['FUKA'], 0, 24) == 'acting_digitalcheck_conv' ) { | |
| 728 | - foreach( $_REQUEST as $key => $value ) { | |
| 729 | - $data[$key] = $value; | |
| 730 | - } | |
| 731 | - $sid = ( isset($data['SID']) ) ? $data['SID'] : ''; | |
| 732 | -//usces_log("digitalcheck conv : ".print_r($_REQUEST,true), 'digitalcheck.log'); | |
| 733 | - | |
| 734 | - if( isset($data['SEQ']) ) { | |
| 735 | - $table_name = $wpdb->prefix."usces_order"; | |
| 736 | - $table_meta_name = $wpdb->prefix."usces_order_meta"; | |
| 737 | - | |
| 738 | - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $sid ); | |
| 739 | - $order_id = $wpdb->get_var( $query ); | |
| 740 | - if( $order_id == NULL ) { | |
| 741 | - usces_log( 'digitalcheck conv error1 : '.print_r($data, true), 'acting_transaction.log' ); | |
| 742 | - header('content-type : text/plain;charset=Shift_JIS'); | |
| 743 | - die('9'); | |
| 744 | - } | |
| 745 | - | |
| 746 | - if( isset($data['CVS']) ) {//入金 | |
| 747 | - $mquery = $wpdb->prepare(" | |
| 748 | - UPDATE $table_name SET order_status = | |
| 749 | - CASE | |
| 750 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted') | |
| 751 | - WHEN LOCATE('receipted', order_status) > 0 THEN order_status | |
| 752 | - ELSE CONCAT('receipted,', order_status ) | |
| 753 | - END | |
| 754 | - WHERE ID = %d", $order_id ); | |
| 755 | - $res = $wpdb->query( $mquery ); | |
| 756 | - if( $res === false ) { | |
| 757 | - usces_log('digitalcheck conv error2 : '.print_r($data, true), 'acting_transaction.log'); | |
| 758 | - header('content-type : text/plain;charset=Shift_JIS'); | |
| 759 | - die('9'); | |
| 760 | - } | |
| 761 | - | |
| 762 | - usces_action_acting_getpoint( $order_id ); | |
| 763 | - | |
| 764 | - } else {//取消 | |
| 765 | - $mquery = $wpdb->prepare(" | |
| 766 | - UPDATE $table_name SET order_status = | |
| 767 | - CASE | |
| 768 | - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt') | |
| 769 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status | |
| 770 | - ELSE CONCAT('noreceipt,', order_status ) | |
| 771 | - END | |
| 772 | - WHERE ID = %d", $order_id ); | |
| 773 | - $res = $wpdb->query( $mquery ); | |
| 774 | - if( $res === false ) { | |
| 775 | - usces_log('digitalcheck conv error3 : '.print_r($data, true), 'acting_transaction.log'); | |
| 776 | - header('content-type : text/plain;charset=Shift_JIS'); | |
| 777 | - die('9'); | |
| 778 | - } | |
| 779 | - | |
| 780 | - usces_action_acting_getpoint( $order_id, false ); | |
| 781 | - } | |
| 782 | - | |
| 783 | - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id ); | |
| 784 | - | |
| 785 | - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $sid ); | |
| 786 | - $res = $wpdb->query( $dquery ); | |
| 787 | - | |
| 788 | - header('content-type : text/plain;charset=Shift_JIS'); | |
| 789 | - die("0"); | |
| 790 | - | |
| 791 | - } else { | |
| 792 | - if( isset($data['CVS']) and isset($data['SHNO']) ) {//決済 | |
| 793 | - $table_meta_name = $wpdb->prefix."usces_order_meta"; | |
| 794 | - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $sid ); | |
| 795 | - $order_id = $wpdb->get_var($query); | |
| 796 | - if( $order_id ) { | |
| 797 | - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id ); | |
| 798 | - | |
| 799 | - } else { | |
| 800 | - $res = $usces->order_processing(); | |
| 801 | - if( 'ordercompletion' == $res ) { | |
| 802 | - $order_id = $usces->cart->get_order_entry('ID'); | |
| 803 | - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id ); | |
| 804 | - } else { | |
| 805 | - usces_log('digitalcheck conv : order processing error', 'acting_transaction.log'); | |
| 806 | - } | |
| 807 | - } | |
| 808 | - header('content-type : text/plain;charset=Shift_JIS'); | |
| 809 | - die("0"); | |
| 810 | - | |
| 811 | - } elseif( isset($data['purchase']) ) { | |
| 812 | - | |
| 813 | - } else { | |
| 814 | - $permalink_structure = get_option('permalink_structure'); | |
| 815 | - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&'; | |
| 816 | - header( 'location: '.USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=1&SID='.$sid ); | |
| 817 | - exit; | |
| 818 | - } | |
| 819 | - } | |
| 820 | -//20121206ysk end | |
| 821 | -//20130225ysk start | |
| 822 | - //*** mizuho card ***// | |
| 823 | - } elseif( ( isset($_GET['p_ver']) && $_GET['p_ver'] == '0200' ) && ( isset($_GET['bkcode']) && $_GET['bkcode'] == 'bg01' ) ) { | |
| 824 | - //usces_log('mizuho card : '.print_r($_GET,true),'mizuho.log'); | |
| 825 | - $stran = ( array_key_exists('stran', $_REQUEST) ) ? $_REQUEST['stran'] : ''; | |
| 826 | - $mbtran = ( array_key_exists('mbtran', $_REQUEST) ) ? $_REQUEST['mbtran'] : ''; | |
| 827 | - $rsltcd = ( array_key_exists('rsltcd', $_REQUEST) ) ? $_REQUEST['rsltcd'] : ''; | |
| 828 | - $permalink_structure = get_option( 'permalink_structure' ); | |
| 829 | - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&'; | |
| 830 | - if( '108' == substr($rsltcd, 0, 3) or '208' == substr($rsltcd, 0, 3) or '308' == substr($rsltcd, 0, 3 ) ) {//キャンセル | |
| 831 | - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' ); | |
| 832 | - } elseif( '109' == substr($rsltcd, 0, 3) or '209' == substr($rsltcd, 0, 3) or '309' == substr($rsltcd, 0, 3) ) {//エラー | |
| 833 | - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' ); | |
| 834 | - } else { | |
| 835 | - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_card&acting_return=1&stran='.$stran.'&mbtran='.$mbtran.'&rsltcd='.$rsltcd ); | |
| 836 | - } | |
| 837 | - die(); | |
| 838 | - | |
| 839 | - //*** mizuho conv ***// | |
| 840 | - } elseif( ( isset($_GET['p_ver']) && $_GET['p_ver'] == '0200' ) && ( isset($_GET['bkcode']) && ( $_GET['bkcode'] == 'cv01' or $_GET['bkcode'] == 'cv02' ) ) ) { | |
| 841 | - usces_log('mizuho conv : '.print_r($_GET,true),'mizuho.log'); | |
| 842 | - $stran = ( array_key_exists('stran', $_REQUEST) ) ? $_REQUEST['stran'] : ''; | |
| 843 | - $mbtran = ( array_key_exists('mbtran', $_REQUEST) ) ? $_REQUEST['mbtran'] : ''; | |
| 844 | - $bktrans = ( array_key_exists('bktrans', $_REQUEST) ) ? $_REQUEST['bktrans'] : ''; | |
| 845 | - $tranid = ( array_key_exists('tranid', $_REQUEST) ) ? $_REQUEST['tranid'] : ''; | |
| 846 | - $tdate = ( array_key_exists('tdate', $_REQUEST) ) ? $_REQUEST['tdate'] : ''; | |
| 847 | - $rsltcd = ( array_key_exists('rsltcd', $_REQUEST) ) ? $_REQUEST['rsltcd'] : ''; | |
| 848 | - $permalink_structure = get_option( 'permalink_structure' ); | |
| 849 | - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&'; | |
| 850 | - if( '' != $tdate ) {//入金通知 | |
| 851 | - foreach( $_REQUEST as $key => $value ) { | |
| 852 | - $data[$key] = $value; | |
| 853 | - } | |
| 854 | - if( $rsltcd == "0000000000000" ) { | |
| 855 | - $table_name = $wpdb->prefix."usces_order"; | |
| 856 | - $table_meta_name = $wpdb->prefix."usces_order_meta"; | |
| 857 | - | |
| 858 | - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'stran', $stran ); | |
| 859 | - $order_id = $wpdb->get_var( $query ); | |
| 860 | - if( $order_id == NULL ) { | |
| 861 | - usces_log( 'mizuho conv error1 : '.print_r($data, true), 'acting_transaction.log' ); | |
| 862 | - | |
| 863 | - } else { | |
| 864 | - $mquery = $wpdb->prepare(" | |
| 865 | - UPDATE $table_name SET order_status = | |
| 866 | - CASE | |
| 867 | - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted') | |
| 868 | - WHEN LOCATE('receipted', order_status) > 0 THEN order_status | |
| 869 | - ELSE CONCAT('receipted,', order_status ) | |
| 870 | - END | |
| 871 | - WHERE ID = %d", $order_id ); | |
| 872 | - $res = $wpdb->query( $mquery ); | |
| 873 | - if( $res === false ) { | |
| 874 | - usces_log( 'mizuho conv error2 : '.print_r($data, true), 'acting_transaction.log' ); | |
| 875 | - | |
| 876 | - } else { | |
| 877 | - usces_action_acting_getpoint( $order_id ); | |
| 878 | - | |
| 879 | - $usces->set_order_meta_value( 'acting_mizuho_conv', serialize($data), $order_id ); | |
| 880 | - | |
| 881 | - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $stran ); | |
| 882 | - $res = $wpdb->query( $dquery ); | |
| 883 | - } | |
| 884 | - } | |
| 885 | - | |
| 886 | - } else { | |
| 887 | - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' ); | |
| 888 | - } | |
| 889 | - | |
| 890 | - } elseif( '108' == substr($rsltcd, 0, 3) or '208' == substr($rsltcd, 0, 3) or '308' == substr($rsltcd, 0, 3) ) {//キャンセル | |
| 891 | - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' ); | |
| 892 | - } elseif( '109' == substr($rsltcd, 0, 3) or '209' == substr($rsltcd, 0, 3) or '309' == substr($rsltcd, 0, 3) ) {//エラー | |
| 893 | - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' ); | |
| 894 | - } else { | |
| 895 | - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_conv&acting_return=1&stran='.$stran.'&mbtran='.$mbtran.'&bktrans='.$_GET['bktrans'].'&tranid='.$tranid.'&rsltcd='.$rsltcd ); | |
| 896 | - } | |
| 897 | - die(); | |
| 898 | -//20130225ysk end | |
| 899 | - } | |
| 900 | -} | |
| 901 | -?> | |
| 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 | + | |
| 677 | + $res = $usces->order_processing(); | |
| 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 ); | |
| 682 | + } else { | |
| 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' ); | |
| 691 | + } | |
| 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 | + } | |
| 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' ); | |
| 809 | + } | |
| 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; | |
| 822 | + } | |
| 823 | + } | |
| 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; | |
| 866 | + } | |
| 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 | +} | |