| 1 |
<?php |
| 2 |
/** |
| 3 |
* Settlement Class. |
| 4 |
* Epsilon |
| 5 |
* |
| 6 |
* @package Welcart |
| 7 |
* @author Welcart Inc. |
| 8 |
*/ |
| 9 |
|
| 10 |
/** |
| 11 |
* Epsilon |
| 12 |
*/ |
| 13 |
class EPSILON_SETTLEMENT { |
| 14 |
|
| 15 |
/** |
| 16 |
* 決済結果通知の送信� |
| 17 |
�IP許可リスト(本番環境) |
| 18 |
* |
| 19 |
* @var array |
| 20 |
*/ |
| 21 |
const ACTING_NOTICE_IPADDRS_PUBLIC = array( '210.254.37.215' ); |
| 22 |
|
| 23 |
/** |
| 24 |
* 決済結果通知の送信� |
| 25 |
�IP許可リスト(テスト環境) |
| 26 |
* |
| 27 |
* @var array |
| 28 |
*/ |
| 29 |
const ACTING_NOTICE_IPADDRS_TEST = array( '210.254.37.214' ); |
| 30 |
|
| 31 |
/** |
| 32 |
* Instance of this class. |
| 33 |
* |
| 34 |
* @var object |
| 35 |
*/ |
| 36 |
protected static $instance = null; |
| 37 |
|
| 38 |
/** |
| 39 |
* 決済代行会社ID |
| 40 |
* |
| 41 |
* @var string |
| 42 |
*/ |
| 43 |
protected $paymod_id; |
| 44 |
|
| 45 |
/** |
| 46 |
* 決済種別 |
| 47 |
* |
| 48 |
* @var string |
| 49 |
*/ |
| 50 |
protected $pay_method; |
| 51 |
|
| 52 |
/** |
| 53 |
* 決済代行会社略称 |
| 54 |
* |
| 55 |
* @var string |
| 56 |
*/ |
| 57 |
protected $acting_name; |
| 58 |
|
| 59 |
/** |
| 60 |
* 決済代行会社正式名称 |
| 61 |
* |
| 62 |
* @var string |
| 63 |
*/ |
| 64 |
protected $acting_formal_name; |
| 65 |
|
| 66 |
/** |
| 67 |
* 決済代行会社URL |
| 68 |
* |
| 69 |
* @var string |
| 70 |
*/ |
| 71 |
protected $acting_company_url; |
| 72 |
|
| 73 |
/** |
| 74 |
* エラーメッセージ |
| 75 |
* |
| 76 |
* @var string |
| 77 |
*/ |
| 78 |
protected $error_mes; |
| 79 |
|
| 80 |
/** |
| 81 |
* Construct. |
| 82 |
*/ |
| 83 |
public function __construct() { |
| 84 |
$this->paymod_id = 'epsilon'; |
| 85 |
$this->pay_method = array( |
| 86 |
'acting_epsilon_card', |
| 87 |
'acting_epsilon_conv', |
| 88 |
'acting_epsilon_paypay', |
| 89 |
); |
| 90 |
$this->acting_name = 'イプシロン'; |
| 91 |
$this->acting_formal_name = 'イプシロン'; |
| 92 |
$this->acting_company_url = 'https://www.epsilon.jp/'; |
| 93 |
|
| 94 |
$this->initialize_data(); |
| 95 |
|
| 96 |
if ( is_admin() ) { |
| 97 |
add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) ); |
| 98 |
add_action( 'usces_action_admin_settlement_update', array( $this, 'settlement_update' ) ); |
| 99 |
add_action( 'usces_action_settlement_tab_title', array( $this, 'settlement_tab_title' ) ); |
| 100 |
add_action( 'usces_action_settlement_tab_body', array( $this, 'settlement_tab_body' ) ); |
| 101 |
} |
| 102 |
|
| 103 |
if ( $this->is_validity_acting() ) { |
| 104 |
add_action( 'usces_after_cart_instant', array( $this, 'acting_transaction' ) ); |
| 105 |
add_filter( 'usces_filter_is_complete_settlement', array( $this, 'is_complete_settlement' ), 10, 3 ); |
| 106 |
|
| 107 |
if ( $this->is_activate_card() || $this->is_activate_conv() || $this->is_activate_paypay() ) { |
| 108 |
add_action( 'usces_action_reg_orderdata', array( $this, 'register_order_data' ) ); |
| 109 |
if ( is_admin() ) { |
| 110 |
add_filter( 'usces_filter_settle_info_field_keys', array( $this, 'settlement_info_field_keys' ), 10, 2 ); |
| 111 |
add_filter( 'usces_filter_settle_info_field_value', array( $this, 'settlement_info_field_value' ), 10, 3 ); |
| 112 |
add_action( 'usces_action_revival_order_data', array( $this, 'revival_order_data' ), 10, 3 ); |
| 113 |
} else { |
| 114 |
add_filter( 'usces_filter_confirm_inform', array( $this, 'confirm_inform' ), 10, 5 ); |
| 115 |
add_action( 'usces_action_acting_processing', array( $this, 'acting_processing' ), 10, 2 ); |
| 116 |
add_filter( 'usces_filter_completion_settlement_message', array( $this, 'completion_settlement_message' ), 10, 2 ); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
if ( $this->is_validity_acting( 'card' ) ) { |
| 121 |
if ( is_admin() ) { |
| 122 |
add_action( 'usces_action_admin_member_info', array( $this, 'admin_member_info' ), 10, 3 ); |
| 123 |
add_action( 'usces_action_post_update_memberdata', array( $this, 'admin_update_memberdata' ), 10, 2 ); |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
if ( $this->is_validity_acting( 'conv' ) ) { |
| 128 |
add_filter( 'usces_filter_payment_detail', array( $this, 'payment_detail' ), 10, 2 ); |
| 129 |
add_filter( 'usces_filter_noreceipt_status', array( $this, 'noreceipt_status' ) ); |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
/** |
| 135 |
* Return an instance of this class. |
| 136 |
*/ |
| 137 |
public static function get_instance() { |
| 138 |
if ( is_null( self::$instance ) ) { |
| 139 |
self::$instance = new self(); |
| 140 |
} |
| 141 |
return self::$instance; |
| 142 |
} |
| 143 |
|
| 144 |
/** |
| 145 |
* Initialize. |
| 146 |
*/ |
| 147 |
public function initialize_data() { |
| 148 |
$options = get_option( 'usces', array() ); |
| 149 |
$options['acting_settings']['epsilon']['contract_code'] = ( isset( $options['acting_settings']['epsilon']['contract_code'] ) ) ? $options['acting_settings']['epsilon']['contract_code'] : ''; |
| 150 |
$options['acting_settings']['epsilon']['ope'] = ( isset( $options['acting_settings']['epsilon']['ope'] ) ) ? $options['acting_settings']['epsilon']['ope'] : ''; |
| 151 |
$options['acting_settings']['epsilon']['card_activate'] = ( isset( $options['acting_settings']['epsilon']['card_activate'] ) ) ? $options['acting_settings']['epsilon']['card_activate'] : ''; |
| 152 |
$options['acting_settings']['epsilon']['multi_currency'] = ( isset( $options['acting_settings']['epsilon']['multi_currency'] ) ) ? $options['acting_settings']['epsilon']['multi_currency'] : ''; |
| 153 |
$options['acting_settings']['epsilon']['3dsecure'] = ( isset( $options['acting_settings']['epsilon']['3dsecure'] ) ) ? $options['acting_settings']['epsilon']['3dsecure'] : ''; |
| 154 |
$options['acting_settings']['epsilon']['process_code'] = ( isset( $options['acting_settings']['epsilon']['process_code'] ) ) ? $options['acting_settings']['epsilon']['process_code'] : ''; |
| 155 |
$options['acting_settings']['epsilon']['conv_activate'] = ( isset( $options['acting_settings']['epsilon']['conv_activate'] ) ) ? $options['acting_settings']['epsilon']['conv_activate'] : ''; |
| 156 |
$options['acting_settings']['epsilon']['conv_limit'] = ( isset( $options['acting_settings']['epsilon']['conv_limit'] ) ) ? $options['acting_settings']['epsilon']['conv_limit'] : ''; |
| 157 |
$options['acting_settings']['epsilon']['paypay_activate'] = ( isset( $options['acting_settings']['epsilon']['paypay_activate'] ) ) ? $options['acting_settings']['epsilon']['paypay_activate'] : ''; |
| 158 |
update_option( 'usces', $options ); |
| 159 |
|
| 160 |
$available_settlement = get_option( 'usces_available_settlement', array() ); |
| 161 |
if ( ! in_array( 'epsilon', $available_settlement, true ) ) { |
| 162 |
$available_settlement['epsilon'] = $this->acting_name; |
| 163 |
update_option( 'usces_available_settlement', $available_settlement ); |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
/** |
| 168 |
* 決済有効判定 |
| 169 |
* 支払方法で使用している場合に true |
| 170 |
* |
| 171 |
* @param string $type Module type. |
| 172 |
* @return boolean |
| 173 |
*/ |
| 174 |
public function is_validity_acting( $type = '' ) { |
| 175 |
$acting_opts = $this->get_acting_settings(); |
| 176 |
if ( empty( $acting_opts ) ) { |
| 177 |
return false; |
| 178 |
} |
| 179 |
|
| 180 |
$payment_method = usces_get_system_option( 'usces_payment_method', 'sort' ); |
| 181 |
$method = false; |
| 182 |
|
| 183 |
switch ( $type ) { |
| 184 |
case 'card': |
| 185 |
foreach ( $payment_method as $payment ) { |
| 186 |
if ( 'acting_epsilon_card' === $payment['settlement'] && 'activate' === $payment['use'] ) { |
| 187 |
$method = true; |
| 188 |
break; |
| 189 |
} |
| 190 |
} |
| 191 |
if ( $method && $this->is_activate_card() ) { |
| 192 |
return true; |
| 193 |
} else { |
| 194 |
return false; |
| 195 |
} |
| 196 |
break; |
| 197 |
|
| 198 |
case 'conv': |
| 199 |
foreach ( $payment_method as $payment ) { |
| 200 |
if ( 'acting_epsilon_conv' === $payment['settlement'] && 'activate' === $payment['use'] ) { |
| 201 |
$method = true; |
| 202 |
break; |
| 203 |
} |
| 204 |
} |
| 205 |
if ( $method && $this->is_activate_conv() ) { |
| 206 |
return true; |
| 207 |
} else { |
| 208 |
return false; |
| 209 |
} |
| 210 |
break; |
| 211 |
|
| 212 |
case 'paypay': |
| 213 |
foreach ( $payment_method as $payment ) { |
| 214 |
if ( 'acting_epsilon_paypay' === $payment['settlement'] && 'activate' === $payment['use'] ) { |
| 215 |
$method = true; |
| 216 |
break; |
| 217 |
} |
| 218 |
} |
| 219 |
if ( $method && $this->is_activate_paypay() ) { |
| 220 |
return true; |
| 221 |
} else { |
| 222 |
return false; |
| 223 |
} |
| 224 |
break; |
| 225 |
|
| 226 |
default: |
| 227 |
if ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) { |
| 228 |
return true; |
| 229 |
} else { |
| 230 |
return false; |
| 231 |
} |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
/** |
| 236 |
* クレジットカード決済有効判定 |
| 237 |
* |
| 238 |
* @return boolean |
| 239 |
*/ |
| 240 |
public function is_activate_card() { |
| 241 |
$acting_opts = $this->get_acting_settings(); |
| 242 |
if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) && |
| 243 |
( isset( $acting_opts['card_activate'] ) && ( 'on' === $acting_opts['card_activate'] ) ) ) { |
| 244 |
$res = true; |
| 245 |
} else { |
| 246 |
$res = false; |
| 247 |
} |
| 248 |
return $res; |
| 249 |
} |
| 250 |
|
| 251 |
/** |
| 252 |
* コンビニ決済有効判定 |
| 253 |
* |
| 254 |
* @return boolean |
| 255 |
*/ |
| 256 |
public function is_activate_conv() { |
| 257 |
$acting_opts = $this->get_acting_settings(); |
| 258 |
if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) && |
| 259 |
( isset( $acting_opts['conv_activate'] ) && 'on' === $acting_opts['conv_activate'] ) ) { |
| 260 |
$res = true; |
| 261 |
} else { |
| 262 |
$res = false; |
| 263 |
} |
| 264 |
return $res; |
| 265 |
} |
| 266 |
|
| 267 |
/** |
| 268 |
* PayPay決済有効判定 |
| 269 |
* |
| 270 |
* @return boolean |
| 271 |
*/ |
| 272 |
public function is_activate_paypay() { |
| 273 |
$acting_opts = $this->get_acting_settings(); |
| 274 |
if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) && |
| 275 |
( isset( $acting_opts['paypay_activate'] ) && 'on' === $acting_opts['paypay_activate'] ) ) { |
| 276 |
$res = true; |
| 277 |
} else { |
| 278 |
$res = false; |
| 279 |
} |
| 280 |
return $res; |
| 281 |
} |
| 282 |
|
| 283 |
/** |
| 284 |
* 未� |
| 285 |
�金ステータス |
| 286 |
* usces_filter_noreceipt_status |
| 287 |
* |
| 288 |
* @param array $noreceipt_status Receive payment notification. |
| 289 |
* @return array |
| 290 |
*/ |
| 291 |
public function noreceipt_status( $noreceipt_status ) { |
| 292 |
if ( ! in_array( 'acting_epsilon_conv', $noreceipt_status, true ) ) { |
| 293 |
$noreceipt_status[] = 'acting_epsilon_conv'; |
| 294 |
update_option( 'usces_noreceipt_status', $noreceipt_status ); |
| 295 |
} |
| 296 |
return $noreceipt_status; |
| 297 |
} |
| 298 |
|
| 299 |
/** |
| 300 |
* 管理画面スクリプト |
| 301 |
* admin_print_footer_scripts |
| 302 |
*/ |
| 303 |
public function admin_scripts() { |
| 304 |
$admin_page = filter_input( INPUT_GET, 'page', FILTER_DEFAULT ); |
| 305 |
switch ( $admin_page ) : |
| 306 |
/* クレジット決済設定画面 */ |
| 307 |
case 'usces_settlement': |
| 308 |
$settlement_selected = get_option( 'usces_settlement_selected', array() ); |
| 309 |
if ( in_array( 'epsilon', $settlement_selected, true ) ) : |
| 310 |
?> |
| 311 |
<script type="text/javascript"> |
| 312 |
jQuery(document).ready( function($) { |
| 313 |
const form_epsilon = $('form#epsilon_form'); |
| 314 |
function card_activate_epsilon() { |
| 315 |
if( 'on' === form_epsilon.find("input[name='card_activate']:checked").val() ) { |
| 316 |
$('.card_form_epsilon').css('display',''); |
| 317 |
} else { |
| 318 |
$('.card_form_epsilon').css('display','none'); |
| 319 |
} |
| 320 |
} |
| 321 |
function conv_activate_epsilon() { |
| 322 |
if( 'on' === form_epsilon.find("input[name='conv_activate']:checked").val() ) { |
| 323 |
$(".conv_form_epsilon").css("display",""); |
| 324 |
} else { |
| 325 |
$(".conv_form_epsilon").css("display","none"); |
| 326 |
} |
| 327 |
} |
| 328 |
card_activate_epsilon(); |
| 329 |
$("input[id^='card_activate_epsilon_']").click( function() { |
| 330 |
card_activate_epsilon(); |
| 331 |
}); |
| 332 |
conv_activate_epsilon(); |
| 333 |
$("input[id^='conv_activate_epsilon_']").click( function() { |
| 334 |
conv_activate_epsilon(); |
| 335 |
}); |
| 336 |
}); |
| 337 |
</script> |
| 338 |
<?php |
| 339 |
endif; |
| 340 |
break; |
| 341 |
endswitch; |
| 342 |
} |
| 343 |
|
| 344 |
/** |
| 345 |
* 決済オプション登録・更新 |
| 346 |
* usces_action_admin_settlement_update |
| 347 |
*/ |
| 348 |
public function settlement_update() { |
| 349 |
global $usces; |
| 350 |
|
| 351 |
if ( 'epsilon' !== filter_input( INPUT_POST, 'acting', FILTER_DEFAULT ) ) { |
| 352 |
return; |
| 353 |
} |
| 354 |
|
| 355 |
$this->error_mes = ''; |
| 356 |
$options = get_option( 'usces', array() ); |
| 357 |
$payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' ); |
| 358 |
$post_data = wp_unslash( $_POST ); |
| 359 |
|
| 360 |
unset( $options['acting_settings']['epsilon'] ); |
| 361 |
$options['acting_settings']['epsilon']['contract_code'] = ( isset( $post_data['contract_code'] ) ) ? trim( $post_data['contract_code'] ) : ''; |
| 362 |
$options['acting_settings']['epsilon']['ope'] = ( isset( $post_data['ope'] ) ) ? $post_data['ope'] : ''; |
| 363 |
$options['acting_settings']['epsilon']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : ''; |
| 364 |
$options['acting_settings']['epsilon']['multi_currency'] = ( isset( $post_data['multi_currency'] ) ) ? $post_data['multi_currency'] : ''; |
| 365 |
$options['acting_settings']['epsilon']['3dsecure'] = ( isset( $post_data['3dsecure'] ) ) ? $post_data['3dsecure'] : ''; |
| 366 |
$options['acting_settings']['epsilon']['process_code'] = ( isset( $post_data['process_code'] ) ) ? $post_data['process_code'] : ''; |
| 367 |
$options['acting_settings']['epsilon']['conv_activate'] = ( isset( $post_data['conv_activate'] ) ) ? $post_data['conv_activate'] : ''; |
| 368 |
$options['acting_settings']['epsilon']['conv_limit'] = ( isset( $post_data['conv_limit'] ) ) ? wp_unslash( $post_data['conv_limit'] ) : ''; |
| 369 |
$options['acting_settings']['epsilon']['paypay_activate'] = ( isset( $post_data['paypay_activate'] ) ) ? $post_data['paypay_activate'] : ''; |
| 370 |
|
| 371 |
if ( 'on' === $options['acting_settings']['epsilon']['card_activate'] || 'on' === $options['acting_settings']['epsilon']['conv_activate'] || 'on' === $options['acting_settings']['epsilon']['paypay_activate'] ) { |
| 372 |
if ( '' === $options['acting_settings']['epsilon']['contract_code'] ) { |
| 373 |
$this->error_mes .= '※契約番号を� |
| 374 |
�力してください<br />'; |
| 375 |
} |
| 376 |
if ( '' === $options['acting_settings']['epsilon']['ope'] ) { |
| 377 |
$this->error_mes .= '※稼働環境を選択してください<br />'; |
| 378 |
} |
| 379 |
} |
| 380 |
|
| 381 |
if ( '' === $this->error_mes ) { |
| 382 |
$usces->action_status = 'success'; |
| 383 |
$usces->action_message = __( 'Options are updated.', 'usces' ); |
| 384 |
if ( 'on' === $options['acting_settings']['epsilon']['card_activate'] || 'on' === $options['acting_settings']['epsilon']['conv_activate'] || 'on' === $options['acting_settings']['epsilon']['paypay_activate'] ) { |
| 385 |
$options['acting_settings']['epsilon']['activate'] = 'on'; |
| 386 |
if ( 'public' === $options['acting_settings']['epsilon']['ope'] ) { |
| 387 |
$options['acting_settings']['epsilon']['send_url'] = 'https://secure.epsilon.jp/cgi-bin/order/receive_order3.cgi'; |
| 388 |
} elseif ( 'test' === $options['acting_settings']['epsilon']['ope'] ) { |
| 389 |
$options['acting_settings']['epsilon']['send_url'] = 'https://beta.epsilon.jp/cgi-bin/order/receive_order3.cgi'; |
| 390 |
} |
| 391 |
$toactive = array(); |
| 392 |
if ( 'on' === $options['acting_settings']['epsilon']['card_activate'] ) { |
| 393 |
$usces->payment_structure['acting_epsilon_card'] = 'カード決済(イプシロン)'; |
| 394 |
foreach ( $payment_method as $settlement => $payment ) { |
| 395 |
if ( 'acting_epsilon_card' === $settlement && 'activate' !== $payment['use'] ) { |
| 396 |
$toactive[] = $payment['name']; |
| 397 |
} |
| 398 |
} |
| 399 |
} else { |
| 400 |
unset( $usces->payment_structure['acting_epsilon_card'] ); |
| 401 |
} |
| 402 |
if ( 'on' === $options['acting_settings']['epsilon']['conv_activate'] ) { |
| 403 |
$usces->payment_structure['acting_epsilon_conv'] = 'コンビニ決済(イプシロン)'; |
| 404 |
foreach ( $payment_method as $settlement => $payment ) { |
| 405 |
if ( 'acting_epsilon_conv' === $settlement && 'activate' !== $payment['use'] ) { |
| 406 |
$toactive[] = $payment['name']; |
| 407 |
} |
| 408 |
} |
| 409 |
} else { |
| 410 |
unset( $usces->payment_structure['acting_epsilon_conv'] ); |
| 411 |
} |
| 412 |
if ( 'on' === $options['acting_settings']['epsilon']['paypay_activate'] ) { |
| 413 |
$usces->payment_structure['acting_epsilon_paypay'] = 'PayPay決済(イプシロン)'; |
| 414 |
foreach ( $payment_method as $settlement => $payment ) { |
| 415 |
if ( 'acting_epsilon_paypay' === $settlement && 'activate' !== $payment['use'] ) { |
| 416 |
$toactive[] = $payment['name']; |
| 417 |
} |
| 418 |
} |
| 419 |
} else { |
| 420 |
unset( $usces->payment_structure['acting_epsilon_paypay'] ); |
| 421 |
} |
| 422 |
usces_admin_orderlist_show_wc_trans_id(); |
| 423 |
if ( 0 < count( $toactive ) ) { |
| 424 |
$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' ); |
| 425 |
} |
| 426 |
} else { |
| 427 |
$options['acting_settings']['epsilon']['activate'] = 'off'; |
| 428 |
unset( $usces->payment_structure['acting_epsilon_card'] ); |
| 429 |
unset( $usces->payment_structure['acting_epsilon_conv'] ); |
| 430 |
unset( $usces->payment_structure['acting_epsilon_paypay'] ); |
| 431 |
} |
| 432 |
$deactivate = array(); |
| 433 |
foreach ( $payment_method as $settlement => $payment ) { |
| 434 |
if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) { |
| 435 |
if ( 'deactivate' !== $payment['use'] ) { |
| 436 |
$payment['use'] = 'deactivate'; |
| 437 |
$deactivate[] = $payment['name']; |
| 438 |
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment ); |
| 439 |
} |
| 440 |
} |
| 441 |
} |
| 442 |
if ( 0 < count( $deactivate ) ) { |
| 443 |
$deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) ); |
| 444 |
$usces->action_message .= $deactivate_message; |
| 445 |
} |
| 446 |
} else { |
| 447 |
$usces->action_status = 'error'; |
| 448 |
$usces->action_message = __( 'Data have deficiency.', 'usces' ); |
| 449 |
$options['acting_settings']['epsilon']['activate'] = 'off'; |
| 450 |
unset( $usces->payment_structure['acting_epsilon_card'] ); |
| 451 |
unset( $usces->payment_structure['acting_epsilon_conv'] ); |
| 452 |
unset( $usces->payment_structure['acting_epsilon_paypay'] ); |
| 453 |
$deactivate = array(); |
| 454 |
foreach ( $payment_method as $settlement => $payment ) { |
| 455 |
if ( in_array( $settlement, $this->pay_method, true ) ) { |
| 456 |
if ( 'deactivate' !== $payment['use'] ) { |
| 457 |
$payment['use'] = 'deactivate'; |
| 458 |
$deactivate[] = $payment['name']; |
| 459 |
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment ); |
| 460 |
} |
| 461 |
} |
| 462 |
} |
| 463 |
if ( 0 < count( $deactivate ) ) { |
| 464 |
$deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) ); |
| 465 |
$usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' ); |
| 466 |
} |
| 467 |
} |
| 468 |
ksort( $usces->payment_structure ); |
| 469 |
update_option( 'usces', $options ); |
| 470 |
update_option( 'usces_payment_structure', $usces->payment_structure ); |
| 471 |
} |
| 472 |
|
| 473 |
/** |
| 474 |
* クレジット決済設定画面タブ |
| 475 |
* usces_action_settlement_tab_title |
| 476 |
*/ |
| 477 |
public function settlement_tab_title() { |
| 478 |
$settlement_selected = get_option( 'usces_settlement_selected', array() ); |
| 479 |
if ( in_array( $this->paymod_id, $settlement_selected, true ) ) { |
| 480 |
echo '<li><a href="#uscestabs_' . esc_html( $this->paymod_id ) . '">' . esc_html( $this->acting_name ) . '</a></li>'; |
| 481 |
} |
| 482 |
} |
| 483 |
|
| 484 |
/** |
| 485 |
* クレジット決済設定画面フォーム |
| 486 |
* usces_action_settlement_tab_body |
| 487 |
*/ |
| 488 |
public function settlement_tab_body() { |
| 489 |
$settlement_selected = get_option( 'usces_settlement_selected', array() ); |
| 490 |
if ( in_array( $this->paymod_id, $settlement_selected, true ) ) : |
| 491 |
$acting_opts = $this->get_acting_settings(); |
| 492 |
$contract_code = ( isset( $acting_opts['contract_code'] ) ) ? $acting_opts['contract_code'] : ''; |
| 493 |
$ope = ( isset( $acting_opts['ope'] ) && 'public' === $acting_opts['ope'] ) ? 'public' : 'test'; |
| 494 |
$card_activate = ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] ) ? 'on' : 'off'; |
| 495 |
$multi_currency = ( isset( $acting_opts['multi_currency'] ) && 'on' === $acting_opts['multi_currency'] ) ? 'on' : 'off'; |
| 496 |
$threedsecure = ( isset( $acting_opts['3dsecure'] ) && 'on' === $acting_opts['3dsecure'] ) ? 'on' : 'off'; |
| 497 |
$process_code = ( isset( $acting_opts['process_code'] ) && 'on' === $acting_opts['process_code'] ) ? 'on' : 'off'; |
| 498 |
$conv_activate = ( isset( $acting_opts['conv_activate'] ) && 'on' === $acting_opts['conv_activate'] ) ? 'on' : 'off'; |
| 499 |
$conv_limit = ( isset( $acting_opts['conv_limit'] ) ) ? $acting_opts['conv_limit'] : ''; |
| 500 |
$paypay_activate = ( isset( $acting_opts['paypay_activate'] ) && 'on' === $acting_opts['paypay_activate'] ) ? 'on' : 'off'; |
| 501 |
?> |
| 502 |
<div id="uscestabs_epsilon"> |
| 503 |
<div class="settlement_service"><span class="service_title"><?php echo esc_html( $this->acting_formal_name ); ?></span></div> |
| 504 |
<?php |
| 505 |
if ( 'epsilon' === filter_input( INPUT_POST, 'acting', FILTER_DEFAULT ) ) : |
| 506 |
if ( '' !== $this->error_mes ) : |
| 507 |
?> |
| 508 |
<div class="error_message"><?php wel_esc_script_e( $this->error_mes ); ?></div> |
| 509 |
<?php |
| 510 |
elseif ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) : |
| 511 |
?> |
| 512 |
<div class="message"><?php esc_html_e( 'Test thoroughly before use.', 'usces' ); ?></div> |
| 513 |
<?php |
| 514 |
endif; |
| 515 |
endif; |
| 516 |
?> |
| 517 |
<form action="" method="post" name="epsilon_form" id="epsilon_form"> |
| 518 |
<table class="settle_table"> |
| 519 |
<tr> |
| 520 |
<th><a class="explanation-label" id="label_ex_contract_code_epsilon">契約番号</a></th> |
| 521 |
<td><input name="contract_code" type="text" id="contract_code_epsilon" value="<?php echo esc_attr( $contract_code ); ?>" class="regular-text" maxlength="8" /></td> |
| 522 |
</tr> |
| 523 |
<tr id="ex_contract_code_epsilon" class="explanation"><td colspan="2">契約時にイプシロンから発行される契約番号(半角数字8桁)</td></tr> |
| 524 |
<tr> |
| 525 |
<th><a class="explanation-label" id="label_ex_ope_epsilon"><?php esc_html_e( 'Operation Environment', 'usces' ); ?></a></th> |
| 526 |
<td><label><input name="ope" type="radio" id="ope_epsilon_test" value="test"<?php checked( $ope, 'test' ); ?> /><span>テスト環境</span></label><br /> |
| 527 |
<label><input name="ope" type="radio" id="ope_epsilon_public" value="public"<?php checked( $ope, 'public' ); ?> /><span>本番環境</span></label> |
| 528 |
</td> |
| 529 |
</tr> |
| 530 |
<tr id="ex_ope_epsilon" class="explanation"><td colspan="2">動作環境を切り替えます。</td></tr> |
| 531 |
</table> |
| 532 |
<table class="settle_table"> |
| 533 |
<tr> |
| 534 |
<th>クレジットカード決済</th> |
| 535 |
<td><label><input name="card_activate" type="radio" id="card_activate_epsilon_on" value="on"<?php checked( $card_activate, 'on' ); ?> /><span>利用する</span></label><br /> |
| 536 |
<label><input name="card_activate" type="radio" id="card_activate_epsilon_off" value="off"<?php checked( $card_activate, 'off' ); ?> /><span>利用しない</span></label> |
| 537 |
</td> |
| 538 |
</tr> |
| 539 |
<tr class="card_form_epsilon"> |
| 540 |
<th><a class="explanation-label" id="label_ex_multi_currency_epsilon">多通貨決済</a></th> |
| 541 |
<td><label><input name="multi_currency" type="radio" class="multi_currency_epsilon" id="multi_currency_epsilon_on" value="on"<?php checked( $multi_currency, 'on' ); ?> /><span>利用する</span></label><br /> |
| 542 |
<label><input name="multi_currency" type="radio" class="multi_currency_epsilon" id="multi_currency_epsilon_off" value="off"<?php checked( $multi_currency, 'off' ); ?> /><span>利用しない</span></label> |
| 543 |
</td> |
| 544 |
</tr> |
| 545 |
<tr id="ex_multi_currency_epsilon" class="explanation card_form_epsilon"><td colspan="2">イプシロンとの契約時にクレジットカード決済(多通貨)の契約をした場合、「利用する」にしてください。</td></tr> |
| 546 |
<tr class="card_form_epsilon"> |
| 547 |
<th><a class="explanation-label" id="label_ex_3dsecure_epsilon">3Dセキュア</a></th> |
| 548 |
<td><label><input name="3dsecure" type="radio" class="3dsecure_epsilon" id="3dsecure_epsilon_on" value="on"<?php checked( $threedsecure, 'on' ); ?> /><span>利用する</span></label><br /> |
| 549 |
<label><input name="3dsecure" type="radio" class="3dsecure_epsilon" id="3dsecure_epsilon_off" value="off"<?php checked( $threedsecure, 'off' ); ?> /><span>利用しない</span></label> |
| 550 |
</td> |
| 551 |
</tr> |
| 552 |
<tr id="ex_3dsecure_epsilon" class="explanation card_form_epsilon"><td colspan="2">イプシロンとの契約時に3Dセキュアの契約をした場合、「利用する」にしてください。<br />「多通貨決済」では� |
| 553 |
須です。</td></tr> |
| 554 |
<tr class="card_form_epsilon"> |
| 555 |
<th><a class="explanation-label" id="label_ex_process_code_epsilon">登録済み課金</th> |
| 556 |
<td><label><input name="process_code" type="radio" class="process_code_epsilon" id="process_code_epsilon_on" value="on"<?php checked( $process_code, 'on' ); ?> /><span>利用する</span></label><br /> |
| 557 |
<label><input name="process_code" type="radio" class="process_code_epsilon" id="process_code_epsilon_off" value="off"<?php checked( $process_code, 'off' ); ?> /><span>利用しない</span></label> |
| 558 |
</td> |
| 559 |
</tr> |
| 560 |
<tr id="ex_process_code_epsilon" class="explanation card_form_epsilon"><td colspan="2">Welcart の会員システムを利用している場合、1度クレジットカード決済を実施すると会員番号で紐付けてクレジットカード番号をイプシロンで保持し、2回目以降のクレジット決済において、クレジットカード番号の� |
| 561 |
�力を不要にします。</td></tr> |
| 562 |
</table> |
| 563 |
<table class="settle_table"> |
| 564 |
<tr> |
| 565 |
<th>コンビニ決済</th> |
| 566 |
<td><label><input name="conv_activate" type="radio" id="conv_activate_epsilon_on" value="on"<?php checked( $conv_activate, 'on' ); ?> /><span>利用する</span></label><br /> |
| 567 |
<label><input name="conv_activate" type="radio" id="conv_activate_epsilon_off" value="off"<?php checked( $conv_activate, 'off' ); ?> /><span>利用しない</span></label> |
| 568 |
</td> |
| 569 |
</tr> |
| 570 |
<tr class="conv_form_epsilon"> |
| 571 |
<th><a class="explanation-label" id="label_ex_conv_limit"><?php esc_html_e( 'Payment due days', 'usces' ); ?></a></th> |
| 572 |
<td><select name="conv_limit"> |
| 573 |
<option value=""></option> |
| 574 |
<?php for ( $d = 10; $d >= 3; $d-- ) : ?> |
| 575 |
<option value="<?php echo esc_attr( $d ); ?>"<?php selected( $conv_limit, $d ); ?>><?php echo esc_html( $d ); ?>日間</option> |
| 576 |
<?php endfor; ?> |
| 577 |
</select> |
| 578 |
</td> |
| 579 |
</tr> |
| 580 |
<tr id="ex_conv_limit" class="explanation conv_form_epsilon"><td colspan="2">設定する場合はイプシロン管理画面の「コンビニ支払期限」と合わせる� |
| 581 |
要があります。ここでの設定はあくまで� |
| 582 |
容確認ページでの支払時期を表示するものとなります。</td></tr> |
| 583 |
</table> |
| 584 |
<table class="settle_table"> |
| 585 |
<tr> |
| 586 |
<th>PayPay決済</th> |
| 587 |
<td><label><input name="paypay_activate" type="radio" id="paypay_activate_epsilon_on" value="on"<?php checked( $paypay_activate, 'on' ); ?> /><span>利用する</span></label><br /> |
| 588 |
<label><input name="paypay_activate" type="radio" id="paypay_activate_epsilon_off" value="off"<?php checked( $paypay_activate, 'off' ); ?> /><span>利用しない</span></label> |
| 589 |
</td> |
| 590 |
</tr> |
| 591 |
</table> |
| 592 |
<input name="acting" type="hidden" value="epsilon" /> |
| 593 |
<input name="usces_option_update" type="submit" class="button button-primary" value="<?php echo esc_attr( $this->acting_name ); ?>の設定を更新する" /> |
| 594 |
<?php wp_nonce_field( 'admin_settlement', 'wc_nonce' ); ?> |
| 595 |
</form> |
| 596 |
<div class="settle_exp"> |
| 597 |
<p><strong><?php echo esc_html( $this->acting_formal_name ); ?></strong></p> |
| 598 |
<a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank"><?php echo esc_html( $this->acting_name ); ?>の詳細はこちら 》</a> |
| 599 |
<p> </p> |
| 600 |
<p>この決済は「外部リンク型」の決済システムです。</p> |
| 601 |
<p>「外部リンク型」とは、決済会社のページへ遷移してカード� |
| 602 |
報を� |
| 603 |
�力する決済システムです。</p> |
| 604 |
</div> |
| 605 |
</div><!--uscestabs_epsilon--> |
| 606 |
<?php |
| 607 |
endif; |
| 608 |
} |
| 609 |
|
| 610 |
/** |
| 611 |
* 決済結果通知の送信� |
| 612 |
�IPを検証する |
| 613 |
* |
| 614 |
* 許可IP以外からのリクエストはエラーログを残して処理を終了する |
| 615 |
* � |
| 616 |
�金状� |
| 617 |
�を変更するサーバー間通知でのみ呼び出すこと |
| 618 |
* ブラウザ戻りを伴う結果戻りでは呼び出さない |
| 619 |
* |
| 620 |
* @param array $data Notification data. |
| 621 |
* @return void |
| 622 |
*/ |
| 623 |
private function acting_notice_ip_guard( $data ) { |
| 624 |
$acting_opts = $this->get_acting_settings(); |
| 625 |
$allowed_ips = ( isset( $acting_opts['ope'] ) && 'public' === $acting_opts['ope'] ) ? self::ACTING_NOTICE_IPADDRS_PUBLIC : self::ACTING_NOTICE_IPADDRS_TEST; |
| 626 |
$remote_addr = ( isset( $_SERVER['REMOTE_ADDR'] ) ) ? wp_unslash( $_SERVER['REMOTE_ADDR'] ) : ''; |
| 627 |
if ( usces_acting_notice_ip_allowed( $remote_addr, $allowed_ips ) ) { |
| 628 |
return; |
| 629 |
} |
| 630 |
$log = array( |
| 631 |
'acting' => 'epsilon_conv', |
| 632 |
'key' => ( isset( $data['order_number'] ) ) ? $data['order_number'] : '', |
| 633 |
'result' => 'IP ADDRESS NOT ALLOWED: ' . $remote_addr, |
| 634 |
'data' => $data, |
| 635 |
); |
| 636 |
usces_save_order_acting_error( $log ); |
| 637 |
usces_log( 'epsilon notice denied ip : ' . $remote_addr, 'acting_transaction.log' ); |
| 638 |
exit( '0 999 ERROR0' ); |
| 639 |
} |
| 640 |
|
| 641 |
/** |
| 642 |
* 結果通知処理 |
| 643 |
* usces_after_cart_instant |
| 644 |
*/ |
| 645 |
public function acting_transaction() { |
| 646 |
global $wpdb; |
| 647 |
|
| 648 |
if ( ! isset( $_GET['acting_return'] ) && isset( $_GET['trans_code'] ) && isset( $_GET['user_id'] ) && isset( $_GET['result'] ) && isset( $_GET['order_number'] ) ) { |
| 649 |
wp_redirect( |
| 650 |
add_query_arg( |
| 651 |
array( |
| 652 |
'acting' => 'epsilon', |
| 653 |
'acting_return' => '1', |
| 654 |
'trans_code' => filter_input( INPUT_GET, 'trans_code', FILTER_DEFAULT ), |
| 655 |
'user_id' => filter_input( INPUT_GET, 'user_id', FILTER_DEFAULT ), |
| 656 |
'result' => filter_input( INPUT_GET, 'result', FILTER_DEFAULT ), |
| 657 |
'order_number' => filter_input( INPUT_GET, 'order_number', FILTER_DEFAULT ), |
| 658 |
), |
| 659 |
USCES_CART_URL |
| 660 |
) |
| 661 |
); |
| 662 |
exit; |
| 663 |
|
| 664 |
} elseif ( isset( $_POST['trans_code'] ) && isset( $_POST['user_id'] ) && isset( $_POST['order_number'] ) ) { |
| 665 |
$post_data = array(); |
| 666 |
foreach ( $_POST as $key => $value ) { |
| 667 |
$post_data[ $key ] = mb_convert_encoding( wp_unslash( $value ), 'UTF-8', 'SJIS' ); |
| 668 |
} |
| 669 |
$this->acting_notice_ip_guard( $post_data ); |
| 670 |
|
| 671 |
if ( '1' === $post_data['paid'] ) { |
| 672 |
$order_id = $this->get_order_id( $post_data['order_number'] ); |
| 673 |
if ( ! $order_id ) { |
| 674 |
$log = array( |
| 675 |
'acting' => 'epsilon_conv', |
| 676 |
'key' => $post_data['order_number'], |
| 677 |
'result' => 'ORDER DATA UPDATE ERROR1', |
| 678 |
'data' => $post_data, |
| 679 |
); |
| 680 |
usces_save_order_acting_error( $log ); |
| 681 |
// usces_log( 'Epsilon conv error1 : ' . print_r( $post_data, true ), 'acting_transaction.log' ); |
| 682 |
exit( '0 999 ERROR1' ); |
| 683 |
} |
| 684 |
|
| 685 |
$res = usces_change_order_receipt( $order_id, 'receipted' ); |
| 686 |
if ( false === $res ) { |
| 687 |
$log = array( |
| 688 |
'acting' => 'epsilon_conv', |
| 689 |
'key' => $post_data['order_number'], |
| 690 |
'result' => 'ORDER DATA UPDATE ERROR2', |
| 691 |
'data' => $post_data, |
| 692 |
); |
| 693 |
usces_save_order_acting_error( $log ); |
| 694 |
// usces_log( 'Epsilon conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' ); |
| 695 |
exit( '0 999 ERROR2' ); |
| 696 |
} |
| 697 |
|
| 698 |
$mquery = $wpdb->prepare( "UPDATE {$wpdb->prefix}usces_order_meta SET `meta_value` = %s WHERE `meta_key` = %s AND `order_id` = %d", serialize( $post_data ), 'acting_epsilon_conv', $order_id ); |
| 699 |
$res = $wpdb->query( $mquery ); |
| 700 |
if ( ! $res ) { |
| 701 |
$log = array( |
| 702 |
'acting' => 'epsilon_conv', |
| 703 |
'key' => $post_data['order_number'], |
| 704 |
'result' => 'ORDER DATA UPDATE ERROR3', |
| 705 |
'data' => $post_data, |
| 706 |
); |
| 707 |
usces_save_order_acting_error( $log ); |
| 708 |
// usces_log( 'Epsilon conv error3 : ' . print_r( $post_data, true ), 'acting_transaction.log' ); |
| 709 |
exit( '0 999 ERROR3' ); |
| 710 |
} |
| 711 |
|
| 712 |
usces_action_acting_getpoint( $order_id ); |
| 713 |
|
| 714 |
// usces_log( 'Epsilon conv transaction : ' . $post_data['settlement_id'], 'acting_transaction.log' ); |
| 715 |
exit( '1' ); |
| 716 |
} |
| 717 |
} |
| 718 |
} |
| 719 |
|
| 720 |
/** |
| 721 |
* 受注ID 取得 |
| 722 |
* |
| 723 |
* @param string $order_number Order number. |
| 724 |
* @return int |
| 725 |
*/ |
| 726 |
protected function get_order_id( $order_number ) { |
| 727 |
global $wpdb; |
| 728 |
|
| 729 |
$query = $wpdb->prepare( "SELECT `order_id` FROM {$wpdb->prefix}usces_order_meta WHERE `meta_key` = %s AND `meta_value` = %s", 'settlement_id', $order_number ); |
| 730 |
$order_id = $wpdb->get_var( $query ); |
| 731 |
return $order_id; |
| 732 |
} |
| 733 |
|
| 734 |
/** |
| 735 |
* ポイント即時付与 |
| 736 |
* usces_filter_is_complete_settlement |
| 737 |
* |
| 738 |
* @param boolean $complete Complete the payment. |
| 739 |
* @param string $payment_name Payment name. |
| 740 |
* @param string $status Payment status. |
| 741 |
* @return boolean |
| 742 |
*/ |
| 743 |
public function is_complete_settlement( $complete, $payment_name, $status ) { |
| 744 |
$payments = usces_get_system_option( 'usces_payment_method', 'name' ); |
| 745 |
if ( isset( $payments[ $payment_name ]['settlement'] ) && ( 'acting_epsilon_card' === $payments[ $payment_name ]['settlement'] || 'acting_epsilon_paypay' === $payments[ $payment_name ]['settlement'] ) ) { |
| 746 |
$complete = true; |
| 747 |
} |
| 748 |
return $complete; |
| 749 |
} |
| 750 |
|
| 751 |
/** |
| 752 |
* 受注データ登録 |
| 753 |
* Called by usces_reg_orderdata() and usces_new_orderdata(). |
| 754 |
* usces_action_reg_orderdata |
| 755 |
* |
| 756 |
* @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $results ). |
| 757 |
*/ |
| 758 |
public function register_order_data( $args ) { |
| 759 |
global $usces; |
| 760 |
extract( $args ); // phpcs:ignore |
| 761 |
|
| 762 |
if ( ! $entry['order']['total_full_price'] ) { |
| 763 |
return; |
| 764 |
} |
| 765 |
|
| 766 |
if ( isset( $_GET['acting'] ) && isset( $_GET['acting_return'] ) && isset( $_GET['trans_code'] ) && 'epsilon' === filter_input( INPUT_GET, 'acting', FILTER_DEFAULT ) ) { |
| 767 |
$acting_flg = ( isset( $payments['settlement'] ) ) ? $payments['settlement'] : ''; |
| 768 |
$order_number = filter_input( INPUT_GET, 'order_number', FILTER_DEFAULT ); |
| 769 |
$usces->set_order_meta_value( 'settlement_id', $order_number, $order_id ); |
| 770 |
$usces->set_order_meta_value( 'wc_trans_id', $order_number, $order_id ); |
| 771 |
if ( isset( $results['reg_order'] ) ) { |
| 772 |
unset( $results['0'] ); |
| 773 |
unset( $results['reg_order'] ); |
| 774 |
} |
| 775 |
$results['trans_code'] = filter_input( INPUT_GET, 'trans_code', FILTER_DEFAULT ); |
| 776 |
if ( 'acting_epsilon_card' === $acting_flg ) { |
| 777 |
$user_id = filter_input( INPUT_GET, 'user_id', FILTER_DEFAULT, FILTER_NULL_ON_FAILURE ); |
| 778 |
$acting_opts = $this->get_acting_settings(); |
| 779 |
if ( 'on' === $acting_opts['process_code'] && $user_id ) { |
| 780 |
$usces->del_member_meta( 'epsilon_process_code_release', $user_id ); |
| 781 |
$results['user_id'] = $user_id; |
| 782 |
} |
| 783 |
} |
| 784 |
$usces->set_order_meta_value( $acting_flg, usces_serialize( $results ), $order_id ); |
| 785 |
} |
| 786 |
} |
| 787 |
|
| 788 |
/** |
| 789 |
* 受注編集画面に表示する決済� |
| 790 |
報のキー |
| 791 |
* usces_filter_settle_info_field_keys |
| 792 |
* |
| 793 |
* @param array $keys Settlement information keys. |
| 794 |
* @param array $fields Settlement information fields. |
| 795 |
* @return array |
| 796 |
*/ |
| 797 |
public function settlement_info_field_keys( $keys, $fields ) { |
| 798 |
array_push( $keys, 'trans_code', 'conveni_name', 'conveni_date' ); |
| 799 |
return $keys; |
| 800 |
} |
| 801 |
|
| 802 |
/** |
| 803 |
* 受注編集画面に表示する決済� |
| 804 |
報の値整形 |
| 805 |
* usces_filter_settle_info_field_value |
| 806 |
* |
| 807 |
* @param string $value Settlement information value. |
| 808 |
* @param string $key Settlement information key. |
| 809 |
* @param string $acting Acting type. |
| 810 |
* @return string |
| 811 |
*/ |
| 812 |
public function settlement_info_field_value( $value, $key, $acting ) { |
| 813 |
return $value; |
| 814 |
} |
| 815 |
|
| 816 |
/** |
| 817 |
* 受注データ復旧処理 |
| 818 |
* usces_action_revival_order_data |
| 819 |
* |
| 820 |
* @param int $order_id Order number. |
| 821 |
* @param string $log_key Link key. |
| 822 |
* @param string $acting_flg Payment type. |
| 823 |
*/ |
| 824 |
public function revival_order_data( $order_id, $log_key, $acting_flg ) { |
| 825 |
global $usces; |
| 826 |
if ( in_array( $acting_flg, $this->pay_method, true ) ) { |
| 827 |
$usces->set_order_meta_value( 'settlement_id', $log_key, $order_id ); |
| 828 |
} |
| 829 |
} |
| 830 |
|
| 831 |
/** |
| 832 |
* 支払方法説明 |
| 833 |
* usces_filter_payment_detail |
| 834 |
* |
| 835 |
* @param string $str Payment method description. |
| 836 |
* @param array $entry Entry data. |
| 837 |
* @return string |
| 838 |
*/ |
| 839 |
public function payment_detail( $str, $entry ) { |
| 840 |
$payment = usces_get_payments_by_name( $entry['order']['payment_name'] ); |
| 841 |
if ( isset( $payment['settlement'] ) && 'acting_epsilon_conv' === $payment['settlement'] ) { |
| 842 |
$acting_opts = $this->get_acting_settings(); |
| 843 |
if ( ! empty( $acting_opts['conv_limit'] ) ) { |
| 844 |
$payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['conv_limit'] ) . __( ')', 'usces' ); |
| 845 |
$str = apply_filters( 'usces_filter_epsilon_payment_limit_conv', $payment_detail, $acting_opts['conv_limit'] ); |
| 846 |
} |
| 847 |
} |
| 848 |
return $str; |
| 849 |
} |
| 850 |
|
| 851 |
/** |
| 852 |
* � |
| 853 |
容確認ページ [注文する] ボタン |
| 854 |
* usces_filter_confirm_inform |
| 855 |
* |
| 856 |
* @param string $form Purchase post form. |
| 857 |
* @param array $payments Payment data. |
| 858 |
* @param string $acting_flg Payment type. |
| 859 |
* @param string $rand Welcart transaction key. |
| 860 |
* @param string $purchase_disabled Disable purchase button. |
| 861 |
* @return string |
| 862 |
*/ |
| 863 |
public function confirm_inform( $form, $payments, $acting_flg, $rand, $purchase_disabled ) { |
| 864 |
if ( in_array( $acting_flg, $this->pay_method, true ) ) { |
| 865 |
$form = '<form id="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}"> |
| 866 |
<div class="send"> |
| 867 |
' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . ' |
| 868 |
<input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' /> |
| 869 |
<input name="purchase" type="submit" id="purchase_button" class="checkout_button" value="' . apply_filters( 'usces_filter_confirm_checkout_button_value', __( 'Checkout', 'usces' ) ) . '"' . $purchase_disabled . ' /></div> |
| 870 |
<input type="hidden" name="rand" value="' . esc_attr( $rand ) . '"> |
| 871 |
<input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">'; |
| 872 |
} |
| 873 |
return $form; |
| 874 |
} |
| 875 |
|
| 876 |
/** |
| 877 |
* 決済処理 |
| 878 |
* usces_action_acting_processing |
| 879 |
* |
| 880 |
* @param string $acting_flg Payment type. |
| 881 |
* @param array $post_query Post data. |
| 882 |
*/ |
| 883 |
public function acting_processing( $acting_flg, $post_query ) { |
| 884 |
if ( ! in_array( $acting_flg, $this->pay_method, true ) ) { |
| 885 |
return; |
| 886 |
} |
| 887 |
|
| 888 |
if ( ! wp_verify_nonce( $_REQUEST['_nonce'], $acting_flg ) ) { |
| 889 |
wp_redirect( USCES_CART_URL ); |
| 890 |
} |
| 891 |
|
| 892 |
global $usces; |
| 893 |
$entry = $usces->cart->get_entry(); |
| 894 |
$cart = $usces->cart->get_cart(); |
| 895 |
if ( ! $entry || ! $cart ) { |
| 896 |
wp_redirect( USCES_CART_URL ); |
| 897 |
} |
| 898 |
|
| 899 |
$delim = apply_filters( 'usces_filter_delim', $usces->delim ); |
| 900 |
$acting = substr( $acting_flg, 7 ); |
| 901 |
$acting_opts = $this->get_acting_settings(); |
| 902 |
$rand = wp_unslash( $_REQUEST['rand'] ); |
| 903 |
usces_save_order_acting_data( $rand ); |
| 904 |
$user_name = mb_strimwidth( $entry['customer']['name1'] . $entry['customer']['name2'], 0, 64, '', 'UTF-8' ); |
| 905 |
$item_code = mb_convert_kana( $usces->getItemCode( $cart[0]['post_id'] ), 'a', 'UTF-8' ); |
| 906 |
$item_name = $usces->getItemName( $cart[0]['post_id'] ); |
| 907 |
if ( 1 < count( $cart ) ) { |
| 908 |
$item_name .= ' ' . __( 'Others', 'usces' ); |
| 909 |
} |
| 910 |
if ( 32 < mb_strlen( $item_name, 'UTF-8' ) ) { |
| 911 |
$item_name = mb_strimwidth( $item_name, 0, 28, '...', 'UTF-8' ); |
| 912 |
} |
| 913 |
|
| 914 |
switch ( $acting_flg ) { |
| 915 |
case 'acting_epsilon_card': /* クレジットカード決済 */ |
| 916 |
if ( 'on' === $acting_opts['multi_currency'] ) { |
| 917 |
$st_code = '10000-0000-00000-00001-00000-00000-00000'; |
| 918 |
$currency_id = $usces->get_currency_code(); |
| 919 |
$user_id = '-'; |
| 920 |
$process_code = '1'; |
| 921 |
} else { |
| 922 |
$st_code = '10000-0000-00000-00000-00000-00000-00000'; |
| 923 |
$currency_id = ''; |
| 924 |
if ( 'on' === $acting_opts['process_code'] ) { |
| 925 |
$member = $usces->get_member(); |
| 926 |
if ( ! empty( $member['ID'] ) ) { |
| 927 |
$release = $usces->get_member_meta_value( 'epsilon_process_code_release', $member['ID'] ); |
| 928 |
$user_id = $member['ID']; |
| 929 |
$process_code = ( empty( $release ) ) ? '2' : '4'; |
| 930 |
} else { |
| 931 |
$user_id = '-'; |
| 932 |
$process_code = '1'; |
| 933 |
} |
| 934 |
} else { |
| 935 |
$user_id = '-'; |
| 936 |
$process_code = '1'; |
| 937 |
} |
| 938 |
} |
| 939 |
$threedsecure = ( 'on' === $acting_opts['3dsecure'] ) ? '21' : ''; |
| 940 |
break; |
| 941 |
case 'acting_epsilon_conv': /* コンビニ決済 */ |
| 942 |
$st_code = '00100-0000-00000-00000-00000-00000-00000'; |
| 943 |
$user_id = '-'; |
| 944 |
$currency_id = ''; |
| 945 |
$process_code = '1'; |
| 946 |
break; |
| 947 |
case 'acting_epsilon_paypay': /* PayPay決済 */ |
| 948 |
$st_code = '00000-0000-00000-00000-00000-10000-00000'; |
| 949 |
$user_id = '-'; |
| 950 |
$currency_id = ''; |
| 951 |
$process_code = '1'; |
| 952 |
break; |
| 953 |
} |
| 954 |
|
| 955 |
$send_data = array( |
| 956 |
'version' => '2', |
| 957 |
'contract_code' => $acting_opts['contract_code'], |
| 958 |
'user_id' => $user_id, |
| 959 |
'user_name' => $user_name, |
| 960 |
'user_mail_add' => $entry['customer']['mailaddress1'], |
| 961 |
'item_code' => $item_code, |
| 962 |
'item_name' => $item_name, |
| 963 |
'order_number' => $rand, |
| 964 |
'st_code' => $st_code, |
| 965 |
'mission_code' => '1', |
| 966 |
'item_price' => $entry['order']['total_full_price'], |
| 967 |
'process_code' => $process_code, |
| 968 |
'memo1' => '', |
| 969 |
'memo2' => 'wc1collne', |
| 970 |
'xml' => '1', |
| 971 |
'character_code' => 'UTF8', |
| 972 |
'currency_id' => $currency_id, |
| 973 |
); |
| 974 |
if ( 'acting_epsilon_conv' === $acting_flg ) { |
| 975 |
$send_data['user_tel'] = str_replace( '-', '', mb_convert_kana( $entry['customer']['tel'], 'a', 'UTF-8' ) ); |
| 976 |
$send_data['user_name_kana'] = $entry['customer']['name3'] . $entry['customer']['name4']; |
| 977 |
} |
| 978 |
if ( ! empty( $threedsecure ) ) { |
| 979 |
$send_data['tds_flag'] = $threedsecure; |
| 980 |
} |
| 981 |
$vars = http_build_query( $send_data ); |
| 982 |
$host = parse_url( USCES_CART_URL ); |
| 983 |
$interface = parse_url( $acting_opts['send_url'] ); |
| 984 |
|
| 985 |
$request = 'POST ' . $acting_opts['send_url'] . " HTTP/1.1\r\n"; |
| 986 |
$request .= 'Host: ' . $host['host'] . "\r\n"; |
| 987 |
$request .= "User-Agent: PHP Script\r\n"; |
| 988 |
$request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
| 989 |
$request .= 'Content-Length: ' . strlen( $vars ) . "\r\n"; |
| 990 |
$request .= "Connection: close\r\n\r\n"; |
| 991 |
$request .= $vars; |
| 992 |
|
| 993 |
$fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 ); |
| 994 |
if ( ! $fp ) { |
| 995 |
// usces_log( 'Epsilon : TLS(v1.2) Socket Error', 'acting_transaction.log' ); |
| 996 |
$log = array( |
| 997 |
'acting' => $acting, |
| 998 |
'key' => $rand, |
| 999 |
'result' => 'SSL/TLS ERROR (' . $errno . ')', |
| 1000 |
'data' => array( $errstr ), |
| 1001 |
); |
| 1002 |
usces_save_order_acting_error( $log ); |
| 1003 |
wp_redirect( |
| 1004 |
add_query_arg( |
| 1005 |
array( |
| 1006 |
'acting' => 'epsilon', |
| 1007 |
'acting_return' => '0', |
| 1008 |
), |
| 1009 |
USCES_CART_URL |
| 1010 |
) |
| 1011 |
); |
| 1012 |
exit; |
| 1013 |
} |
| 1014 |
|
| 1015 |
fwrite( $fp, $request ); |
| 1016 |
while ( ! feof( $fp ) ) { |
| 1017 |
$scr = fgets( $fp, 1024 ); |
| 1018 |
preg_match_all( '/<result\s(.*)\s\/>/', $scr, $match, PREG_SET_ORDER ); |
| 1019 |
if ( ! empty( $match[0][1] ) ) { |
| 1020 |
list( $key, $value ) = explode( '=', $match[0][1] ); |
| 1021 |
$datas[ $key ] = urldecode( trim( $value, '"' ) ); |
| 1022 |
} |
| 1023 |
} |
| 1024 |
fclose( $fp ); |
| 1025 |
if ( 1 === (int) $datas['result'] ) { |
| 1026 |
wp_redirect( $datas['redirect'] ); |
| 1027 |
} else { |
| 1028 |
// usces_log( 'Epsilon : Certification Error' . print_r( $datas, true ), 'acting_transaction.log' ); |
| 1029 |
$err_code = ( isset( $datas['err_code'] ) ) ? urlencode( $datas['err_code'] ) : ''; |
| 1030 |
$err_detail = ( isset( $datas['err_detail'] ) ) ? urlencode( $datas['err_detail'] ) : ''; |
| 1031 |
$log = array( |
| 1032 |
'acting' => $acting, |
| 1033 |
'key' => $rand, |
| 1034 |
'result' => $err_code, |
| 1035 |
'data' => $datas, |
| 1036 |
); |
| 1037 |
usces_save_order_acting_error( $log ); |
| 1038 |
wp_redirect( |
| 1039 |
add_query_arg( |
| 1040 |
array( |
| 1041 |
'acting' => 'epsilon', |
| 1042 |
'acting_return' => '0', |
| 1043 |
), |
| 1044 |
USCES_CART_URL |
| 1045 |
) |
| 1046 |
); |
| 1047 |
} |
| 1048 |
exit; |
| 1049 |
} |
| 1050 |
|
| 1051 |
/** |
| 1052 |
* 購� |
| 1053 |
�完了メッセージ |
| 1054 |
* usces_filter_completion_settlement_message |
| 1055 |
* |
| 1056 |
* @param string $form Purchase complete message. |
| 1057 |
* @param array $entry Entry data. |
| 1058 |
* @return string |
| 1059 |
*/ |
| 1060 |
public function completion_settlement_message( $form, $entry ) { |
| 1061 |
if ( isset( $_GET['acting'] ) && 'epsilon' === filter_input( INPUT_GET, 'acting', FILTER_DEFAULT ) ) { |
| 1062 |
$payments = usces_get_payments_by_name( $entry['order']['payment_name'] ); |
| 1063 |
if ( isset( $payments['settlement'] ) && 'acting_epsilon_conv' === $payments['settlement'] ) { |
| 1064 |
$form .= '<div id="status_table"><h5>イプシロン・コンビニ決済</h5> |
| 1065 |
<p>「お支払いのご案� |
| 1066 |
」は、' . esc_html( $entry['customer']['mailaddress1'] ) . ' 宛にメールさせていただいております。</p> |
| 1067 |
</div>' . "\n"; |
| 1068 |
} |
| 1069 |
} |
| 1070 |
return $form; |
| 1071 |
} |
| 1072 |
|
| 1073 |
/** |
| 1074 |
* 会員データ編集画面 カード� |
| 1075 |
報登録� |
| 1076 |
報 |
| 1077 |
* usces_action_admin_member_info |
| 1078 |
* |
| 1079 |
* @param array $member Member data. |
| 1080 |
* @param array $member_metas Member meta data. |
| 1081 |
* @param array $member_history Member's history order data. |
| 1082 |
*/ |
| 1083 |
public function admin_member_info( $member, $member_metas, $member_history ) { |
| 1084 |
if ( ! $this->is_activate_card() ) { |
| 1085 |
return; |
| 1086 |
} |
| 1087 |
|
| 1088 |
$acting_opts = $this->get_acting_settings(); |
| 1089 |
if ( 'on' !== $acting_opts['process_code'] ) { |
| 1090 |
return; |
| 1091 |
} |
| 1092 |
|
| 1093 |
global $usces; |
| 1094 |
|
| 1095 |
$epsilon_card = false; |
| 1096 |
foreach ( $member_history as $history ) { |
| 1097 |
$payments = usces_get_payments_by_name( $history['payment_name'] ); |
| 1098 |
$settlement = ( 'acting' === $payments['settlement'] ) ? $payments['module'] : $payments['settlement']; |
| 1099 |
if ( 'acting_epsilon_card' === $settlement ) { |
| 1100 |
$epsilon_card = true; |
| 1101 |
break; |
| 1102 |
} |
| 1103 |
} |
| 1104 |
|
| 1105 |
if ( 0 < count( $member_history ) && $epsilon_card ) : |
| 1106 |
?> |
| 1107 |
<tr> |
| 1108 |
<td class="label"><input type="checkbox" name="epsilon_process_code_release" id="epsilon_process_code_release" value="release"></td> |
| 1109 |
<td><label for="epsilon_process_code_release">登録済み課金を解除する</label></td> |
| 1110 |
</tr> |
| 1111 |
<?php |
| 1112 |
endif; |
| 1113 |
} |
| 1114 |
|
| 1115 |
/** |
| 1116 |
* 会員データ編集画面 カード� |
| 1117 |
報登録解除 |
| 1118 |
* usces_action_post_update_memberdata |
| 1119 |
* |
| 1120 |
* @param int $member_id Member ID. |
| 1121 |
* @param boolean $res Result. |
| 1122 |
*/ |
| 1123 |
public function admin_update_memberdata( $member_id, $res ) { |
| 1124 |
if ( ! $this->is_activate_card() || false === $res ) { |
| 1125 |
return; |
| 1126 |
} |
| 1127 |
|
| 1128 |
global $usces; |
| 1129 |
|
| 1130 |
$acting_opts = $this->get_acting_settings(); |
| 1131 |
if ( 'on' === $acting_opts['process_code'] ) { |
| 1132 |
if ( filter_input( INPUT_POST, 'epsilon_process_code_release', FILTER_DEFAULT, FILTER_NULL_ON_FAILURE ) ) { |
| 1133 |
$usces->set_member_meta_value( 'epsilon_process_code_release', 'release', $member_id ); |
| 1134 |
} else { |
| 1135 |
$usces->del_member_meta( 'epsilon_process_code_release', $member_id ); |
| 1136 |
} |
| 1137 |
} |
| 1138 |
} |
| 1139 |
|
| 1140 |
/** |
| 1141 |
* 決済オプション取得 |
| 1142 |
* |
| 1143 |
* @return array |
| 1144 |
*/ |
| 1145 |
protected function get_acting_settings() { |
| 1146 |
global $usces; |
| 1147 |
|
| 1148 |
$acting_settings = ( isset( $usces->options['acting_settings'][ $this->paymod_id ] ) ) ? $usces->options['acting_settings'][ $this->paymod_id ] : array(); |
| 1149 |
return $acting_settings; |
| 1150 |
} |
| 1151 |
} |
| 1152 |
|