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