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