| 1 |
<?php |
| 2 |
/** |
| 3 |
* ロボットペイメント |
| 4 |
* (旧 Cloud Payment ) |
| 5 |
* (旧 J-Payment ) |
| 6 |
* |
| 7 |
* @package Welcart |
| 8 |
* @author Collne Inc. |
| 9 |
* @version 1.0.0 |
| 10 |
* @since 1.9.20 |
| 11 |
*/ |
| 12 |
|
| 13 |
/** |
| 14 |
* ロボットペイメント |
| 15 |
*/ |
| 16 |
class JPAYMENT_SETTLEMENT { |
| 17 |
/** |
| 18 |
* 決済結果通知(キックバック)の送信� |
| 19 |
�IP許可リスト |
| 20 |
* |
| 21 |
* @var array |
| 22 |
*/ |
| 23 |
const ACTING_NOTICE_IPADDRS = array( '54.95.223.30', '54.168.57.171' ); |
| 24 |
|
| 25 |
/** |
| 26 |
* Instance of this class. |
| 27 |
* |
| 28 |
* @var object |
| 29 |
*/ |
| 30 |
protected static $instance = null; |
| 31 |
|
| 32 |
/** |
| 33 |
* 決済代行会社ID |
| 34 |
* |
| 35 |
* @var string |
| 36 |
*/ |
| 37 |
protected $paymod_id; |
| 38 |
|
| 39 |
/** |
| 40 |
* 決済種別 |
| 41 |
* |
| 42 |
* @var string |
| 43 |
*/ |
| 44 |
protected $pay_method; |
| 45 |
|
| 46 |
/** |
| 47 |
* 決済代行会社略称 |
| 48 |
* |
| 49 |
* @var string |
| 50 |
*/ |
| 51 |
protected $acting_name; |
| 52 |
|
| 53 |
/** |
| 54 |
* 決済代行会社正式名称 |
| 55 |
* |
| 56 |
* @var string |
| 57 |
*/ |
| 58 |
protected $acting_formal_name; |
| 59 |
|
| 60 |
/** |
| 61 |
* 決済代行会社URL |
| 62 |
* |
| 63 |
* @var string |
| 64 |
*/ |
| 65 |
protected $acting_company_url; |
| 66 |
|
| 67 |
/** |
| 68 |
* エラーメッセージ |
| 69 |
* |
| 70 |
* @var string |
| 71 |
*/ |
| 72 |
protected $error_mes; |
| 73 |
|
| 74 |
/** |
| 75 |
* Construct. |
| 76 |
*/ |
| 77 |
public function __construct() { |
| 78 |
|
| 79 |
$this->paymod_id = 'jpayment'; |
| 80 |
$this->pay_method = array( |
| 81 |
'acting_jpayment_card', |
| 82 |
'acting_jpayment_conv', |
| 83 |
'acting_jpayment_bank', |
| 84 |
); |
| 85 |
$this->acting_name = 'ROBOT PAYMENT'; |
| 86 |
$this->acting_formal_name = 'ROBOT PAYMENT'; |
| 87 |
$this->acting_company_url = 'https://www.robotpayment.co.jp/'; |
| 88 |
|
| 89 |
$this->initialize_data(); |
| 90 |
|
| 91 |
if ( is_admin() ) { |
| 92 |
// add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) ); |
| 93 |
add_action( 'usces_action_admin_settlement_update', array( $this, 'settlement_update' ) ); |
| 94 |
add_action( 'usces_action_settlement_tab_title', array( $this, 'settlement_tab_title' ) ); |
| 95 |
add_action( 'usces_action_settlement_tab_body', array( $this, 'settlement_tab_body' ) ); |
| 96 |
} |
| 97 |
|
| 98 |
if ( $this->is_activate_card() || $this->is_activate_conv() || $this->is_activate_bank() ) { |
| 99 |
add_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) ); |
| 100 |
} |
| 101 |
|
| 102 |
if ( $this->is_activate_conv() || $this->is_activate_bank() ) { |
| 103 |
add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'order_confirm_mail_payment' ), 10, 5 ); |
| 104 |
add_filter( 'usces_filter_send_order_mail_payment', array( $this, 'send_order_mail_payment' ), 10, 6 ); |
| 105 |
} |
| 106 |
|
| 107 |
if ( $this->is_validity_acting( 'conv' ) ) { |
| 108 |
add_filter( 'usces_filter_payment_detail', array( $this, 'payment_detail' ), 10, 2 ); |
| 109 |
add_action( 'usces_filter_completion_settlement_message', array( $this, 'completion_settlement_message' ), 10, 2 ); |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* Return an instance of this class. |
| 115 |
*/ |
| 116 |
public static function get_instance() { |
| 117 |
if ( null == self::$instance ) { |
| 118 |
self::$instance = new self(); |
| 119 |
} |
| 120 |
return self::$instance; |
| 121 |
} |
| 122 |
|
| 123 |
/** |
| 124 |
* Initialize. |
| 125 |
*/ |
| 126 |
public function initialize_data() { |
| 127 |
$options = get_option( 'usces', array() ); |
| 128 |
if ( ! isset( $options['acting_settings'] ) || ! isset( $options['acting_settings']['jpayment'] ) ) { |
| 129 |
$options['acting_settings']['jpayment']['activate'] = ''; |
| 130 |
$options['acting_settings']['jpayment']['aid'] = ''; |
| 131 |
$options['acting_settings']['jpayment']['card_activate'] = 'off'; |
| 132 |
$options['acting_settings']['jpayment']['card_jb'] = ''; |
| 133 |
$options['acting_settings']['jpayment']['conv_activate'] = 'off'; |
| 134 |
$options['acting_settings']['jpayment']['conv_limit'] = '14'; |
| 135 |
$options['acting_settings']['jpayment']['webm_activate'] = 'off'; |
| 136 |
$options['acting_settings']['jpayment']['bitc_activate'] = 'off'; |
| 137 |
$options['acting_settings']['jpayment']['suica_activate'] = 'off'; |
| 138 |
$options['acting_settings']['jpayment']['bank_activate'] = 'off'; |
| 139 |
update_option( 'usces', $options ); |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* 決済有効判定 |
| 145 |
* 支払方法で使用している場合に true |
| 146 |
* |
| 147 |
* @param string $type Module type. |
| 148 |
* @return boolean |
| 149 |
*/ |
| 150 |
public function is_validity_acting( $type = '' ) { |
| 151 |
$acting_opts = $this->get_acting_settings(); |
| 152 |
if ( empty( $acting_opts ) ) { |
| 153 |
return false; |
| 154 |
} |
| 155 |
|
| 156 |
$payment_method = usces_get_system_option( 'usces_payment_method', 'sort' ); |
| 157 |
$method = false; |
| 158 |
|
| 159 |
switch ( $type ) { |
| 160 |
case 'card': |
| 161 |
foreach ( $payment_method as $payment ) { |
| 162 |
if ( 'acting_jpayment_card' == $payment['settlement'] && 'activate' == $payment['use'] ) { |
| 163 |
$method = true; |
| 164 |
break; |
| 165 |
} |
| 166 |
} |
| 167 |
if ( $method && $this->is_activate_card() ) { |
| 168 |
return true; |
| 169 |
} else { |
| 170 |
return false; |
| 171 |
} |
| 172 |
break; |
| 173 |
|
| 174 |
case 'conv': |
| 175 |
foreach ( $payment_method as $payment ) { |
| 176 |
if ( 'acting_jpayment_conv' == $payment['settlement'] && 'activate' == $payment['use'] ) { |
| 177 |
$method = true; |
| 178 |
break; |
| 179 |
} |
| 180 |
} |
| 181 |
if ( $method && $this->is_activate_conv() ) { |
| 182 |
return true; |
| 183 |
} else { |
| 184 |
return false; |
| 185 |
} |
| 186 |
break; |
| 187 |
|
| 188 |
case 'bank': |
| 189 |
foreach ( $payment_method as $payment ) { |
| 190 |
if ( 'acting_jpayment_bank' == $payment['settlement'] && 'activate' == $payment['use'] ) { |
| 191 |
$method = true; |
| 192 |
break; |
| 193 |
} |
| 194 |
} |
| 195 |
if ( $method && $this->is_activate_bank() ) { |
| 196 |
return true; |
| 197 |
} else { |
| 198 |
return false; |
| 199 |
} |
| 200 |
break; |
| 201 |
|
| 202 |
default: |
| 203 |
if ( 'on' == $acting_opts['activate'] ) { |
| 204 |
return true; |
| 205 |
} else { |
| 206 |
return false; |
| 207 |
} |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
/** |
| 212 |
* クレジットカード決済有効判定 |
| 213 |
* |
| 214 |
* @return boolean |
| 215 |
*/ |
| 216 |
public function is_activate_card() { |
| 217 |
$acting_opts = $this->get_acting_settings(); |
| 218 |
if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) && |
| 219 |
( isset( $acting_opts['card_activate'] ) && ( 'on' == $acting_opts['card_activate'] ) ) ) { |
| 220 |
$res = true; |
| 221 |
} else { |
| 222 |
$res = false; |
| 223 |
} |
| 224 |
return $res; |
| 225 |
} |
| 226 |
|
| 227 |
/** |
| 228 |
* コンビニ決済有効判定 |
| 229 |
* |
| 230 |
* @return boolean |
| 231 |
*/ |
| 232 |
public function is_activate_conv() { |
| 233 |
|
| 234 |
$acting_opts = $this->get_acting_settings(); |
| 235 |
if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) && |
| 236 |
( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) ) { |
| 237 |
$res = true; |
| 238 |
} else { |
| 239 |
$res = false; |
| 240 |
} |
| 241 |
return $res; |
| 242 |
} |
| 243 |
|
| 244 |
/** |
| 245 |
* バンクチェック決済有効判定 |
| 246 |
* |
| 247 |
* @return boolean |
| 248 |
*/ |
| 249 |
public function is_activate_bank() { |
| 250 |
|
| 251 |
$acting_opts = $this->get_acting_settings(); |
| 252 |
if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) && |
| 253 |
( isset( $acting_opts['bank_activate'] ) && 'on' == $acting_opts['bank_activate'] ) ) { |
| 254 |
$res = true; |
| 255 |
} else { |
| 256 |
$res = false; |
| 257 |
} |
| 258 |
return $res; |
| 259 |
} |
| 260 |
|
| 261 |
/** |
| 262 |
* 管理画面スクリプト |
| 263 |
* admin_print_footer_scripts |
| 264 |
*/ |
| 265 |
public function admin_scripts() { |
| 266 |
|
| 267 |
} |
| 268 |
|
| 269 |
/** |
| 270 |
* 決済オプション登録・更新 |
| 271 |
* usces_action_admin_settlement_update |
| 272 |
*/ |
| 273 |
public function settlement_update() { |
| 274 |
global $usces; |
| 275 |
|
| 276 |
if ( $this->paymod_id != wp_unslash( $_POST['acting'] ) ) { |
| 277 |
return; |
| 278 |
} |
| 279 |
|
| 280 |
$this->error_mes = ''; |
| 281 |
$options = get_option( 'usces', array() ); |
| 282 |
$payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' ); |
| 283 |
|
| 284 |
unset( $options['acting_settings']['jpayment'] ); |
| 285 |
$options['acting_settings']['jpayment']['aid'] = ( isset( $_POST['aid'] ) ) ? trim( wp_unslash( $_POST['aid'] ) ) : ''; |
| 286 |
$options['acting_settings']['jpayment']['card_activate'] = ( isset( $_POST['card_activate'] ) ) ? wp_unslash( $_POST['card_activate'] ) : ''; |
| 287 |
$options['acting_settings']['jpayment']['card_jb'] = ( isset( $_POST['card_jb'] ) ) ? wp_unslash( $_POST['card_jb'] ) : ''; |
| 288 |
$options['acting_settings']['jpayment']['conv_activate'] = ( isset( $_POST['conv_activate'] ) ) ? wp_unslash( $_POST['conv_activate'] ) : ''; |
| 289 |
$options['acting_settings']['jpayment']['conv_limit'] = ( isset( $_POST['conv_limit'] ) ) ? $_POST['conv_limit'] : '14'; |
| 290 |
$options['acting_settings']['jpayment']['bank_activate'] = ( isset( $_POST['bank_activate'] ) ) ? wp_unslash( $_POST['bank_activate'] ) : ''; |
| 291 |
|
| 292 |
if ( WCUtils::is_blank( $_POST['aid'] ) ) { |
| 293 |
$this->error_mes .= '※店舗IDコードを� |
| 294 |
�力してください<br />'; |
| 295 |
} |
| 296 |
if ( isset( $_POST['card_activate'] ) && 'on' == wp_unslash( $_POST['card_activate'] ) && empty( $_POST['card_jb'] ) ) { |
| 297 |
$this->error_mes .= '※ジョブタイプを指定してください<br />'; |
| 298 |
} |
| 299 |
|
| 300 |
if ( '' == $this->error_mes ) { |
| 301 |
$usces->action_status = 'success'; |
| 302 |
$usces->action_message = __( 'Options are updated.', 'usces' ); |
| 303 |
if ( 'on' == $options['acting_settings']['jpayment']['card_activate'] || 'on' == $options['acting_settings']['jpayment']['conv_activate'] || 'on' == $options['acting_settings']['jpayment']['bank_activate'] ) { |
| 304 |
$options['acting_settings']['jpayment']['activate'] = 'on'; |
| 305 |
$options['acting_settings']['jpayment']['send_url'] = 'https://credit.j-payment.co.jp/gateway/payform.aspx'; |
| 306 |
$toactive = array(); |
| 307 |
if ( 'on' == $options['acting_settings']['jpayment']['card_activate'] ) { |
| 308 |
$usces->payment_structure['acting_jpayment_card'] = 'カード決済(' . $this->acting_name . ')'; |
| 309 |
foreach ( $payment_method as $settlement => $payment ) { |
| 310 |
if ( 'acting_jpayment_card' == $settlement && 'deactivate' == $payment['use'] ) { |
| 311 |
$toactive[] = $payment['name']; |
| 312 |
} |
| 313 |
} |
| 314 |
} else { |
| 315 |
unset( $usces->payment_structure['acting_jpayment_card'] ); |
| 316 |
} |
| 317 |
if ( 'on' == $options['acting_settings']['jpayment']['conv_activate'] ) { |
| 318 |
$usces->payment_structure['acting_jpayment_conv'] = 'コンビニ決済(' . $this->acting_name . ')'; |
| 319 |
foreach ( $payment_method as $settlement => $payment ) { |
| 320 |
if ( 'acting_jpayment_conv' == $settlement && 'deactivate' == $payment['use'] ) { |
| 321 |
$toactive[] = $payment['name']; |
| 322 |
} |
| 323 |
} |
| 324 |
} else { |
| 325 |
unset( $usces->payment_structure['acting_jpayment_conv'] ); |
| 326 |
} |
| 327 |
if ( 'on' == $options['acting_settings']['jpayment']['bank_activate'] ) { |
| 328 |
$usces->payment_structure['acting_jpayment_bank'] = 'バンクチェック決済(' . $this->acting_name . ')'; |
| 329 |
foreach ( $payment_method as $settlement => $payment ) { |
| 330 |
if ( 'acting_jpayment_bank' == $settlement && 'deactivate' == $payment['use'] ) { |
| 331 |
$toactive[] = $payment['name']; |
| 332 |
} |
| 333 |
} |
| 334 |
} else { |
| 335 |
unset( $usces->payment_structure['acting_jpayment_bank'] ); |
| 336 |
} |
| 337 |
usces_admin_orderlist_show_wc_trans_id(); |
| 338 |
if ( 0 < count( $toactive ) ) { |
| 339 |
$usces->action_message .= __( 'Please update the payment method to "Activate". <a href="admin.php?page=usces_initial#payment_method_setting">General Setting > Payment Methods</a>', 'usces' ); |
| 340 |
} |
| 341 |
} else { |
| 342 |
$options['acting_settings']['jpayment']['activate'] = 'off'; |
| 343 |
unset( $usces->payment_structure['acting_jpayment_card'] ); |
| 344 |
unset( $usces->payment_structure['acting_jpayment_conv'] ); |
| 345 |
unset( $usces->payment_structure['acting_jpayment_bank'] ); |
| 346 |
} |
| 347 |
$deactivate = array(); |
| 348 |
foreach ( $payment_method as $settlement => $payment ) { |
| 349 |
if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) { |
| 350 |
if ( 'deactivate' != $payment['use'] ) { |
| 351 |
$payment['use'] = 'deactivate'; |
| 352 |
$deactivate[] = $payment['name']; |
| 353 |
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment ); |
| 354 |
} |
| 355 |
} |
| 356 |
} |
| 357 |
if ( 0 < count( $deactivate ) ) { |
| 358 |
$deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) ); |
| 359 |
$usces->action_message .= $deactivate_message; |
| 360 |
} |
| 361 |
} else { |
| 362 |
$usces->action_status = 'error'; |
| 363 |
$usces->action_message = __( 'Data have deficiency.', 'usces' ); |
| 364 |
$options['acting_settings']['jpayment']['activate'] = 'off'; |
| 365 |
unset( $usces->payment_structure['acting_jpayment_card'] ); |
| 366 |
unset( $usces->payment_structure['acting_jpayment_conv'] ); |
| 367 |
unset( $usces->payment_structure['acting_jpayment_bank'] ); |
| 368 |
$deactivate = array(); |
| 369 |
foreach ( $payment_method as $settlement => $payment ) { |
| 370 |
if ( in_array( $settlement, $this->pay_method ) ) { |
| 371 |
if ( 'deactivate' != $payment['use'] ) { |
| 372 |
$payment['use'] = 'deactivate'; |
| 373 |
$deactivate[] = $payment['name']; |
| 374 |
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment ); |
| 375 |
} |
| 376 |
} |
| 377 |
} |
| 378 |
if ( 0 < count( $deactivate ) ) { |
| 379 |
$deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) ); |
| 380 |
$usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' ); |
| 381 |
} |
| 382 |
} |
| 383 |
ksort( $usces->payment_structure ); |
| 384 |
update_option( 'usces', $options ); |
| 385 |
update_option( 'usces_payment_structure', $usces->payment_structure ); |
| 386 |
} |
| 387 |
|
| 388 |
/** |
| 389 |
* クレジット決済設定画面タブ |
| 390 |
* usces_action_settlement_tab_title |
| 391 |
*/ |
| 392 |
public function settlement_tab_title() { |
| 393 |
$settlement_selected = get_option( 'usces_settlement_selected' ); |
| 394 |
if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) { |
| 395 |
echo '<li><a href="#uscestabs_' . esc_html( $this->paymod_id ) . '">' . esc_html( $this->acting_name ) . '</a></li>'; |
| 396 |
} |
| 397 |
} |
| 398 |
|
| 399 |
/** |
| 400 |
* クレジット決済設定画面フォーム |
| 401 |
* usces_action_settlement_tab_body |
| 402 |
*/ |
| 403 |
public function settlement_tab_body() { |
| 404 |
global $usces; |
| 405 |
|
| 406 |
$settlement_selected = get_option( 'usces_settlement_selected' ); |
| 407 |
if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) : |
| 408 |
$acting_opts = $this->get_acting_settings(); |
| 409 |
$aid = ( isset( $acting_opts['aid'] ) ) ? $acting_opts['aid'] : ''; |
| 410 |
$card_activate = ( isset( $acting_opts['card_activate'] ) && 'on' == $acting_opts['card_activate'] ) ? 'on' : 'off'; |
| 411 |
$card_jb = ( isset( $acting_opts['card_jb'] ) ) ? $acting_opts['card_jb'] : ''; |
| 412 |
$conv_activate = ( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) ? 'on' : 'off'; |
| 413 |
$webm_activate = ( isset( $acting_opts['webm_activate'] ) && 'on' == $acting_opts['webm_activate'] ) ? 'on' : 'off'; |
| 414 |
$bitc_activate = ( isset( $acting_opts['bitc_activate'] ) && 'on' == $acting_opts['bitc_activate'] ) ? 'on' : 'off'; |
| 415 |
$suica_activate = ( isset( $acting_opts['suica_activate'] ) && 'on' == $acting_opts['suica_activate'] ) ? 'on' : 'off'; |
| 416 |
$bank_activate = ( isset( $acting_opts['bank_activate'] ) && 'on' == $acting_opts['bank_activate'] ) ? 'on' : 'off'; |
| 417 |
?> |
| 418 |
<div id="uscestabs_jpayment"> |
| 419 |
<div class="settlement_service"><span class="service_title"><?php echo esc_html( $this->acting_formal_name ); ?></span></div> |
| 420 |
<?php |
| 421 |
if ( isset( $_POST['acting'] ) && 'jpayment' == wp_unslash( $_POST['acting'] ) ) : |
| 422 |
if ( '' != $this->error_mes ) : |
| 423 |
?> |
| 424 |
<div class="error_message"><?php wel_esc_script_e( $this->error_mes ); ?></div> |
| 425 |
<?php elseif ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) : ?> |
| 426 |
<div class="message">十分にテストを行ってから運用してください。</div> |
| 427 |
<?php |
| 428 |
endif; |
| 429 |
endif; |
| 430 |
?> |
| 431 |
<form action="" method="post" name="jpayment_form" id="jpayment_form"> |
| 432 |
<table class="settle_table"> |
| 433 |
<tr> |
| 434 |
<th><a class="explanation-label" id="label_ex_aid_jpayment">店舗ID</a></th> |
| 435 |
<td><input name="aid" type="text" id="aid_jpayment" value="<?php echo esc_html( $aid ); ?>" class="regular-text" maxlength="6" /></td> |
| 436 |
</tr> |
| 437 |
<tr id="ex_aid_jpayment" class="explanation"><td colspan="2">契約時に <?php echo esc_html( $this->acting_name ); ?> から発行される店舗ID(半角数字)</td></tr> |
| 438 |
</table> |
| 439 |
<table class="settle_table"> |
| 440 |
<tr> |
| 441 |
<th><a class="explanation-label" id="label_ex_card_jpayment">クレジットカード決済</a></th> |
| 442 |
<td><label><input name="card_activate" type="radio" id="card_activate_jpayment_1" value="on"<?php checked( $card_activate, 'on' ); ?> /><span>利用する</span></label><br /> |
| 443 |
<label><input name="card_activate" type="radio" id="card_activate_jpayment_2" value="off"<?php checked( $card_activate, 'off' ); ?> /><span>利用しない</span></label> |
| 444 |
</td> |
| 445 |
</tr> |
| 446 |
<tr id="ex_card_jpayment" class="explanation"><td colspan="2">クレジットカード決済を利用するかどうか。<br />※自動継続課金には対応していません。</td></tr> |
| 447 |
<tr> |
| 448 |
<th><a class="explanation-label" id="label_ex_card_jb_jpayment">ジョブタイプ</a></th> |
| 449 |
<td><!--<label><input name="card_jb" type="radio" id="card_jb_jpayment_1" value="CHECK"<?php checked( $card_jb, 'CHECK' ); ?> /><span>有効性チェック</span></label><br />--> |
| 450 |
<label><input name="card_jb" type="radio" id="card_jb_jpayment_2" value="AUTH"<?php checked( $card_jb, 'AUTH' ); ?> /><span>仮売上処理</span></label><br /> |
| 451 |
<label><input name="card_jb" type="radio" id="card_jb_jpayment_3" value="CAPTURE"<?php checked( $card_jb, 'CAPTURE' ); ?> /><span>仮実同時売上処理</span></label> |
| 452 |
</td> |
| 453 |
</tr> |
| 454 |
<tr id="ex_card_jb_jpayment" class="explanation"><td colspan="2">決済の種類を指定します。</td></tr> |
| 455 |
</table> |
| 456 |
<table class="settle_table"> |
| 457 |
<tr> |
| 458 |
<th><a class="explanation-label" id="label_ex_conv_jpayment">コンビニ決済</a></th> |
| 459 |
<td><label><input name="conv_activate" type="radio" id="conv_activate_jpayment_1" value="on"<?php checked( $conv_activate, 'on' ); ?> /><span>利用する</span></label><br /> |
| 460 |
<label><input name="conv_activate" type="radio" id="conv_activate_jpayment_2" value="off"<?php checked( $conv_activate, 'off' ); ?> /><span>利用しない</span></label> |
| 461 |
</td> |
| 462 |
</tr> |
| 463 |
<tr id="ex_conv_jpayment" class="explanation"><td colspan="2">コンビニ(ペーパーレス)決済を利用するかどうか。</td></tr> |
| 464 |
<tr> |
| 465 |
<th><a class="explanation-label" id="label_ex_conv_limit_jpayment">支払期限</a></th> |
| 466 |
<td> |
| 467 |
<?php |
| 468 |
$selected = array_fill( 1, 30, '' ); |
| 469 |
if ( isset( $acting_opts['conv_limit'] ) ) { |
| 470 |
$selected[ $acting_opts['conv_limit'] ] = ' selected'; |
| 471 |
} else { |
| 472 |
$selected[14] = ' selected'; |
| 473 |
} |
| 474 |
?> |
| 475 |
<select name="conv_limit" id="conv_limit"> |
| 476 |
<?php for ( $i = 1; $i <= 30; $i++ ) : ?> |
| 477 |
<option value="<?php echo esc_html( $i ); ?>"<?php echo esc_html( $selected[ $i ] ); ?>><?php echo esc_html( $i ); ?></option> |
| 478 |
<?php endfor; ?> |
| 479 |
</select>日</td> |
| 480 |
</tr> |
| 481 |
<tr id="ex_conv_limit_jpayment" class="explanation"><td colspan="2">設定する場合は契約時の支払期限と合わせる� |
| 482 |
要があります。変更したい場合は <?php echo esc_html( $this->acting_name ); ?> にお申し込みください。ここでの設定はあくまで� |
| 483 |
容確認ページでの支払時期を表示するものとなります。</td></tr> |
| 484 |
</table> |
| 485 |
<!--<table class="settle_table"> |
| 486 |
<tr> |
| 487 |
<th><a class="explanation-label" id="label_ex_webm_jpayment">WebMoney決済</a></th> |
| 488 |
<td><label><input name="webm_activate" type="radio" id="webm_activate_jpayment_1" value="on"<?php checked( $webm_activate, 'on' ); ?> /><span>利用する</span></label><br /> |
| 489 |
<label><input name="webm_activate" type="radio" id="webm_activate_jpayment_2" value="off"<?php checked( $webm_activate, 'off' ); ?> /><span>利用しない</span></label> |
| 490 |
</td> |
| 491 |
</tr> |
| 492 |
<tr id="ex_webm_jpayment" class="explanation"><td colspan="2">電子マネー(WebMoney)決済を利用するかどうか。</td></tr> |
| 493 |
</table> |
| 494 |
<table class="settle_table"> |
| 495 |
<tr> |
| 496 |
<th><a class="explanation-label" id="label_ex_bitc_jpayment">BitCash決済</a></th> |
| 497 |
<td><label><input name="bitc_activate" type="radio" id="bitc_activate_jpayment_1" value="on"<?php checked( $bitc_activate, 'on' ); ?> /><span>利用する</span></label><br /> |
| 498 |
<label><input name="bitc_activate" type="radio" id="bitc_activate_jpayment_2" value="off"<?php checked( $bitc_activate, 'off' ); ?> /><span>利用しない</span></label> |
| 499 |
</td> |
| 500 |
</tr> |
| 501 |
<tr id="ex_bitc_jpayment" class="explanation"><td colspan="2">電子マネー(BitCash)決済を利用するかどうか。</td></tr> |
| 502 |
</table> |
| 503 |
<table class="settle_table"> |
| 504 |
<tr> |
| 505 |
<th><a class="explanation-label" id="label_ex_suica_jpayment">モバイルSuica決済</a></th> |
| 506 |
<td><label><input name="suica_activate" type="radio" id="suica_activate_jpayment_1" value="on"<?php checked( $suica_activate, 'on' ); ?> /><span>利用する</span></label><br /> |
| 507 |
<label><input name="suica_activate" type="radio" id="suica_activate_jpayment_2" value="off"<?php checked( $suica_activate, 'off' ); ?> /><span>利用しない</span></label> |
| 508 |
</td> |
| 509 |
</tr> |
| 510 |
<tr id="ex_suica_jpayment" class="explanation"><td colspan="2">電子マネー(モバイルSuica)決済を利用するかどうか。</td></tr> |
| 511 |
</table>--> |
| 512 |
<table class="settle_table"> |
| 513 |
<tr> |
| 514 |
<th><a class="explanation-label" id="label_ex_bank_jpayment">バンクチェック決済</a></th> |
| 515 |
<td><label><input name="bank_activate" type="radio" id="bank_activate_jpayment_1" value="on"<?php checked( $bank_activate, 'on' ); ?> /><span>利用する</span></label><br /> |
| 516 |
<label><input name="bank_activate" type="radio" id="bank_activate_jpayment_2" value="off"<?php checked( $bank_activate, 'off' ); ?> /><span>利用しない</span></label> |
| 517 |
</td> |
| 518 |
</tr> |
| 519 |
<tr id="ex_bank_jpayment" class="explanation"><td colspan="2">バンクチェック決済を利用するかどうか。</td></tr> |
| 520 |
</table> |
| 521 |
<input name="acting" type="hidden" value="jpayment" /> |
| 522 |
<input name="usces_option_update" type="submit" class="button button-primary" value="<?php echo esc_attr( $this->acting_name ); ?> の設定を更新する" /> |
| 523 |
<?php wp_nonce_field( 'admin_settlement', 'wc_nonce' ); ?> |
| 524 |
</form> |
| 525 |
<div class="settle_exp"> |
| 526 |
<p><strong><?php echo esc_html( $this->acting_formal_name ); ?></strong></p> |
| 527 |
<a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank"><?php echo esc_html( $this->acting_name ); ?> の詳細はこちら 》</a> |
| 528 |
<p> </p> |
| 529 |
<p>この決済は「外部リンク型」の決済システムです。</p> |
| 530 |
<p>「外部リンク型」とは、決済会社のページへ遷移してカード� |
| 531 |
報を� |
| 532 |
�力する決済システムです。</p> |
| 533 |
</div> |
| 534 |
</div><!--uscestabs_jpayment--> |
| 535 |
<?php |
| 536 |
endif; |
| 537 |
} |
| 538 |
|
| 539 |
/** |
| 540 |
* 受注データ登録 |
| 541 |
* Called by usces_reg_orderdata() and usces_new_orderdata(). |
| 542 |
* usces_action_reg_orderdata |
| 543 |
* |
| 544 |
* @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $results ). |
| 545 |
*/ |
| 546 |
public function register_orderdata( $args ) { |
| 547 |
global $usces; |
| 548 |
extract( $args ); |
| 549 |
|
| 550 |
$acting_flg = $payments['settlement']; |
| 551 |
if ( ! in_array( $acting_flg, $this->pay_method ) ) { |
| 552 |
return; |
| 553 |
} |
| 554 |
|
| 555 |
if ( ! $entry['order']['total_full_price'] ) { |
| 556 |
return; |
| 557 |
} |
| 558 |
|
| 559 |
if ( isset( $_REQUEST['acting'] ) && ( 'jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'] ) ) { |
| 560 |
$usces->set_order_meta_value( 'settlement_id', wp_unslash( $_GET['cod'] ), $order_id ); |
| 561 |
if ( ! empty( $_GET['gid'] ) ) { |
| 562 |
$usces->set_order_meta_value( 'wc_trans_id', wp_unslash( $_GET['gid'] ), $order_id ); |
| 563 |
} |
| 564 |
foreach ( $_GET as $key => $value ) { |
| 565 |
if ( 'purchase_jpayment' != $key ) { |
| 566 |
$data[ $key ] = wp_unslash( $value ); |
| 567 |
} |
| 568 |
} |
| 569 |
$usces->set_order_meta_value( 'acting_' . wp_unslash( $_REQUEST['acting'] ), serialize( $data ), $order_id ); |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
/** |
| 574 |
* 管理画面送信メール |
| 575 |
* usces_filter_order_confirm_mail_payment |
| 576 |
* |
| 577 |
* @param string $msg_payment Payment information message. |
| 578 |
* @param int $order_id Order number. |
| 579 |
* @param array $payment Payment data. |
| 580 |
* @param array $cart Cart data. |
| 581 |
* @param array $data Order data. |
| 582 |
* @return string |
| 583 |
*/ |
| 584 |
public function order_confirm_mail_payment( $msg_payment, $order_id, $payment, $cart, $data ) { |
| 585 |
global $usces; |
| 586 |
|
| 587 |
if ( 'acting_jpayment_conv' == $payment['settlement'] ) { |
| 588 |
$args = wel_safe_maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) ); |
| 589 |
$msg_payment .= '決済番号 : ' . $args['gid'] . "\r\n"; |
| 590 |
$msg_payment .= '決済金額 : ' . number_format( $args['ta'] ) . __( 'dollars', 'usces' ) . "\r\n"; |
| 591 |
$msg_payment .= 'お支払� |
| 592 |
� : ' . usces_get_conv_name( $args['cv'] ) . "\r\n"; |
| 593 |
$msg_payment .= 'コンビニ受付番号 : ' . $args['no'] . "\r\n"; |
| 594 |
if ( '030' != $args['cv'] ) { /* ファミリーマート以外 */ |
| 595 |
$msg_payment .= 'コンビニ受付番号� |
| 596 |
報URL : ' . $args['cu'] . "\r\n"; |
| 597 |
} |
| 598 |
$msg_payment .= "\r\n" . usces_mail_line( 2, $data['order_email'] ) . "\r\n"; |
| 599 |
|
| 600 |
} elseif ( 'acting_jpayment_bank' == $payment['settlement'] ) { |
| 601 |
$args = wel_safe_maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) ); |
| 602 |
$msg_payment .= '決済番号 : ' . $args['gid'] . "\r\n"; |
| 603 |
$msg_payment .= '決済金額 : ' . number_format( $args['ta'] ) . __( 'dollars', 'usces' ) . "\r\n"; |
| 604 |
$bank = explode( '.', $args['bank'] ); |
| 605 |
$msg_payment .= '銀行コード : ' . $bank[0] . "\r\n"; |
| 606 |
$msg_payment .= '銀行名 : ' . $bank[1] . "\r\n"; |
| 607 |
$msg_payment .= '支店コード : ' . $bank[2] . "\r\n"; |
| 608 |
$msg_payment .= '支店名 : ' . $bank[3] . "\r\n"; |
| 609 |
$msg_payment .= '口座種別 : ' . $bank[4] . "\r\n"; |
| 610 |
$msg_payment .= '口座番号 : ' . $bank[5] . "\r\n"; |
| 611 |
$msg_payment .= '口座名義 : ' . $bank[6] . "\r\n"; |
| 612 |
$msg_payment .= '支払期限 : ' . substr( $args['exp'], 0, 4 ) . '年' . substr( $args['exp'], 4, 2 ) . '月' . substr( $args['exp'], 6, 2 ) . "日\r\n"; |
| 613 |
$msg_payment .= "\r\n" . usces_mail_line( 2, $data['order_email'] ) . "\r\n"; |
| 614 |
} |
| 615 |
return $msg_payment; |
| 616 |
} |
| 617 |
|
| 618 |
/** |
| 619 |
* サンキューメール |
| 620 |
* usces_filter_send_order_mail_payment |
| 621 |
* |
| 622 |
* @param string $msg_payment Payment method message. |
| 623 |
* @param int $order_id Order number. |
| 624 |
* @param array $payment Payment data. |
| 625 |
* @param array $cart Cart data. |
| 626 |
* @param array $entry Entry data. |
| 627 |
* @param array $data Order data. |
| 628 |
* @return string |
| 629 |
*/ |
| 630 |
public function send_order_mail_payment( $msg_payment, $order_id, $payment, $cart, $entry, $data ) { |
| 631 |
global $usces; |
| 632 |
|
| 633 |
if ( 'acting_jpayment_conv' == $payment['settlement'] ) { |
| 634 |
$args = wel_safe_maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) ); |
| 635 |
$msg_payment .= '決済番号 : ' . $args['gid'] . "\r\n"; |
| 636 |
$msg_payment .= '決済金額 : ' . number_format( $args['ta'] ) . __( 'dollars', 'usces' ) . "\r\n"; |
| 637 |
$msg_payment .= 'お支払� |
| 638 |
� : ' . usces_get_conv_name( $args['cv'] ) . "\r\n"; |
| 639 |
$msg_payment .= 'コンビニ受付番号 : ' . $args['no'] . "\r\n"; |
| 640 |
if ( '030' != $args['cv'] ) { /* ファミリーマート以外 */ |
| 641 |
$msg_payment .= 'コンビニ受付番号� |
| 642 |
報URL : ' . $args['cu'] . "\r\n"; |
| 643 |
} |
| 644 |
$msg_payment .= "\r\n" . usces_mail_line( 2, $entry['customer']['mailaddress1'] ) . "\r\n"; |
| 645 |
|
| 646 |
} elseif ( 'acting_jpayment_bank' == $payment['settlement'] ) { |
| 647 |
$args = wel_safe_maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) ); |
| 648 |
$msg_payment .= '決済番号 : ' . $args['gid'] . "\r\n"; |
| 649 |
$msg_payment .= '決済金額 : ' . number_format( $args['ta'] ) . __( 'dollars', 'usces' ) . "\r\n"; |
| 650 |
$bank = explode( '.', $args['bank'] ); |
| 651 |
$msg_payment .= '銀行コード : ' . $bank[0] . "\r\n"; |
| 652 |
$msg_payment .= '銀行名 : ' . $bank[1] . "\r\n"; |
| 653 |
$msg_payment .= '支店コード : ' . $bank[2] . "\r\n"; |
| 654 |
$msg_payment .= '支店名 : ' . $bank[3] . "\r\n"; |
| 655 |
$msg_payment .= '口座種別 : ' . $bank[4] . "\r\n"; |
| 656 |
$msg_payment .= '口座番号 : ' . $bank[5] . "\r\n"; |
| 657 |
$msg_payment .= '口座名義 : ' . $bank[6] . "\r\n"; |
| 658 |
$msg_payment .= '支払期限 : ' . substr( $args['exp'], 0, 4 ) . '年' . substr( $args['exp'], 4, 2 ) . '月' . substr( $args['exp'], 6, 2 ) . "日\r\n"; |
| 659 |
$msg_payment .= "\r\n" . usces_mail_line( 2, $entry['customer']['mailaddress1'] ) . "\r\n"; |
| 660 |
} |
| 661 |
return $msg_payment; |
| 662 |
} |
| 663 |
|
| 664 |
/** |
| 665 |
* 支払方法説明 |
| 666 |
* usces_filter_payment_detail |
| 667 |
* |
| 668 |
* @param string $str Payment method description. |
| 669 |
* @param array $entry Entry data. |
| 670 |
* @return string |
| 671 |
*/ |
| 672 |
public function payment_detail( $str, $entry ) { |
| 673 |
$payment = usces_get_payments_by_name( $entry['order']['payment_name'] ); |
| 674 |
if ( isset( $payment['settlement'] ) && 'acting_jpayment_conv' == $payment['settlement'] ) { |
| 675 |
$acting_opts = $this->get_acting_settings(); |
| 676 |
if ( ! empty( $acting_opts['conv_limit'] ) ) { |
| 677 |
$payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['conv_limit'] ) . __( ')', 'usces' ); |
| 678 |
$str = apply_filters( 'usces_filter_jpayment_payment_limit_conv', $payment_detail, $acting_opts['conv_limit'] ); |
| 679 |
} |
| 680 |
} |
| 681 |
return $str; |
| 682 |
} |
| 683 |
|
| 684 |
/** |
| 685 |
* 購� |
| 686 |
�完了メッセージ |
| 687 |
* usces_filter_completion_settlement_message |
| 688 |
* |
| 689 |
* @param string $form Purchase complete message. |
| 690 |
* @param array $entry Entry data. |
| 691 |
* @return string |
| 692 |
*/ |
| 693 |
public function completion_settlement_message( $form, $entry ) { |
| 694 |
global $usces; |
| 695 |
|
| 696 |
if ( isset( $_REQUEST['acting'] ) && 'jpayment_conv' == $_REQUEST['acting'] ) { |
| 697 |
$form .= '<div id="status_table"><h5>' . esc_html( $this->acting_formal_name ) . ' コンビニペーパーレス決済</h5>'; |
| 698 |
$form .= '<table>'; |
| 699 |
$form .= '<tr><th>決済番号</th><td>' . esc_html( wp_unslash( $_GET['gid'] ) ) . '</td></tr>'; |
| 700 |
$form .= '<tr><th>決済金額</th><td>' . esc_html( wp_unslash( $_GET['ta'] ) ) . '</td></tr>'; |
| 701 |
$form .= '<tr><th>お支払� |
| 702 |
�</th><td>' . esc_html( usces_get_conv_name( wp_unslash( $_GET['cv'] ) ) ) . '</td></tr>'; |
| 703 |
$form .= '<tr><th>コンビニ受付番号</th><td>' . esc_html( wp_unslash( $_GET['no'] ) ) . '</td></tr>'; |
| 704 |
if ( '030' != wp_unslash( $_GET['cv'] ) ) { /* ファミリーマート以外 */ |
| 705 |
$form .= '<tr><th>コンビニ受付番号� |
| 706 |
報URL</th><td><a href="' . esc_html( wp_unslash( $_GET['cu'] ) ) . '" target="_blank">' . esc_html( wp_unslash( $_GET['cu'] ) ) . '</a></td></tr>'; |
| 707 |
} |
| 708 |
$form .= '</table>'; |
| 709 |
$form .= '<p>「お支払いのご案� |
| 710 |
」は、' . esc_html( $entry['customer']['mailaddress1'] ) . ' 宛にメールさせていただいております。</p>'; |
| 711 |
$form .= '</div>'; |
| 712 |
} |
| 713 |
return $form; |
| 714 |
} |
| 715 |
|
| 716 |
/** |
| 717 |
* 決済結果通知(キックバック)の送信� |
| 718 |
�IPを検証する |
| 719 |
* |
| 720 |
* 許可IP以外からのリクエストはエラーログを残して処理を終了する |
| 721 |
* � |
| 722 |
�金状� |
| 723 |
�を変更する通知(CPL / CVS_CAN / BAN_SAL)でのみ呼び出すこと |
| 724 |
* ブラウザ戻り(CPL_PRE / BANK)では呼び出さない |
| 725 |
* |
| 726 |
* @return void |
| 727 |
*/ |
| 728 |
public function acting_notice_ip_guard() { |
| 729 |
$remote_addr = ( isset( $_SERVER['REMOTE_ADDR'] ) ) ? wp_unslash( $_SERVER['REMOTE_ADDR'] ) : ''; |
| 730 |
if ( usces_acting_notice_ip_allowed( $remote_addr, self::ACTING_NOTICE_IPADDRS ) ) { |
| 731 |
return; |
| 732 |
} |
| 733 |
$log = array( |
| 734 |
'acting' => ( isset( $_REQUEST['acting'] ) ) ? wp_unslash( $_REQUEST['acting'] ) : 'jpayment', |
| 735 |
'key' => ( isset( $_GET['cod'] ) ) ? wp_unslash( $_GET['cod'] ) : '', |
| 736 |
'result' => 'IP ADDRESS NOT ALLOWED: ' . $remote_addr, |
| 737 |
'data' => wp_unslash( $_REQUEST ), |
| 738 |
); |
| 739 |
usces_save_order_acting_error( $log ); |
| 740 |
usces_log( 'jpayment notice denied ip : ' . $remote_addr, 'acting_transaction.log' ); |
| 741 |
die( 'error0' ); |
| 742 |
} |
| 743 |
|
| 744 |
/** |
| 745 |
* 決済オプション取得 |
| 746 |
* |
| 747 |
* @return array |
| 748 |
*/ |
| 749 |
protected function get_acting_settings() { |
| 750 |
global $usces; |
| 751 |
|
| 752 |
$acting_settings = ( isset( $usces->options['acting_settings'][ $this->paymod_id ] ) ) ? $usces->options['acting_settings'][ $this->paymod_id ] : array(); |
| 753 |
return $acting_settings; |
| 754 |
} |
| 755 |
} |
| 756 |
|