'佐川急便',
'12' => 'ヤマト運輸',
'15' => '郵便書留',
'16' => 'ゆうパック',
'27' => 'エコ配',
'18' => '福山通運',
'14' => '西濃運輸',
'13' => '日本通運',
'26' => 'JPロジスティクス',
'30' => 'セイノーエクスプレス',
'21' => '名鉄運輸',
'23' => '信州名鉄運輸',
'20' => '新潟運輸',
'29' => 'トナミ運輸',
'31' => '大川配送サービス',
'32' => 'プラスサービス',
'99' => 'その他',
);
/**
* 決済オプション
*
* @var array
*/
public $acting_opts;
/**
* Construct.
*/
public function __construct() {
$this->paymod_id = 'zeus';
$this->pay_method = array(
'acting_zeus_card',
'acting_zeus_bank',
'acting_zeus_conv',
'acting_zeus_bnpl',
);
$this->acting_name = 'ゼウス';
$this->acting_formal_name = 'ゼウス';
$this->acting_company_url = 'https://www.cardservice.co.jp/';
$this->initialize_data();
$this->acting_opts = $this->get_acting_settings();
if ( is_admin() ) {
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
add_action( 'usces_action_admin_settlement_update', array( $this, 'settlement_update' ) );
add_action( 'usces_action_settlement_tab_title', array( $this, 'settlement_tab_title' ) );
add_action( 'usces_action_settlement_tab_body', array( $this, 'settlement_tab_body' ) );
add_action( 'usces_filter_add_payment_method', array( $this, 'add_payment_method' ) );
}
if ( $this->is_validity_acting( 'card' ) || $this->is_validity_acting( 'bank' ) || $this->is_validity_acting( 'conv' ) || $this->is_validity_acting( 'bnpl' ) ) {
add_action( 'plugins_loaded', array( $this, 'acting_construct' ), 11 );
add_action( 'usces_after_cart_instant', array( $this, 'acting_transaction' ), 11 );
add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'order_confirm_mail_payment' ), 10, 5 );
add_filter( 'usces_filter_is_complete_settlement', array( $this, 'is_complete_settlement' ), 10, 3 );
add_action( 'usces_filter_completion_settlement_message', array( $this, 'completion_settlement_message' ), 10, 2 );
add_filter( 'usces_filter_get_link_key', array( $this, 'get_link_key' ), 10, 2 );
add_action( 'usces_action_revival_order_data', array( $this, 'revival_orderdata' ), 10, 3 );
if ( is_admin() ) {
add_action( 'usces_action_admin_ajax', array( $this, 'admin_ajax' ) );
add_filter( 'usces_filter_orderlist_detail_value', array( $this, 'orderlist_settlement_status' ), 10, 4 );
add_action( 'usces_action_order_edit_form_status_block_middle', array( $this, 'settlement_status' ), 10, 3 );
add_action( 'usces_action_order_edit_form_settle_info', array( $this, 'settlement_information' ), 10, 2 );
add_action( 'usces_action_endof_order_edit_form', array( $this, 'settlement_dialog' ), 10, 2 );
add_filter( 'usces_filter_settle_info_field_meta_keys', array( $this, 'settlement_info_field_meta_keys' ) );
add_filter( 'usces_filter_settle_info_field_keys', array( $this, 'settlement_info_field_keys' ), 10, 2 );
add_filter( 'usces_filter_settle_info_field_value', array( $this, 'settlement_info_field_value' ), 10, 3 );
add_filter( 'usces_filter_deli_comps', array( $this, 'bnpl_delivery_company' ), 10, 2 );
} else {
add_filter( 'usces_filter_payment_detail', array( $this, 'payment_detail' ), 10, 2 );
add_filter( 'usces_filter_payments_str', array( $this, 'payments_str' ), 10, 2 );
add_filter( 'usces_filter_payments_arr', array( $this, 'payments_arr' ), 10, 2 );
add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
add_filter( 'usces_filter_confirm_inform', array( $this, 'confirm_inform' ), 10, 5 );
add_action( 'usces_action_confirm_page_point_inform', array( $this, 'e_point_inform' ), 10, 5 );
add_filter( 'usces_filter_confirm_point_inform', array( $this, 'point_inform' ), 10, 5 );
add_filter( 'usces_filter_custom_field_info', array( $this, 'confirm_addition_bnpl' ), 20, 4 );
if ( defined( 'WCEX_COUPON' ) ) {
add_filter( 'wccp_filter_coupon_inform', array( $this, 'point_inform' ), 10, 5 );
}
add_action( 'usces_pre_purchase', array( $this, 'pre_purchase' ) );
add_action( 'usces_action_acting_processing', array( $this, 'acting_processing' ), 10, 2 );
add_action( 'usces_pre_acting_return', array( $this, 'pre_acting_return' ) );
add_filter( 'usces_filter_check_acting_return_results', array( $this, 'acting_return' ) );
add_filter( 'usces_filter_check_acting_return_duplicate', array( $this, 'check_acting_return_duplicate' ), 10, 2 );
add_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) );
add_action( 'usces_post_reg_orderdata', array( $this, 'post_register_orderdata' ), 10, 2 );
add_filter( 'usces_filter_get_error_settlement', array( $this, 'error_page_message' ) );
}
}
if ( $this->is_validity_acting( 'card' ) ) {
if ( $this->is_activate_card( 'api' ) && 1 === (int) $this->acting_opts['3dsecur'] ) {
add_action( 'wp_ajax_zeus_3dsecure_enrol', array( $this, 'zeus_3dsecure_enrol' ) );
add_action( 'wp_ajax_nopriv_zeus_3dsecure_enrol', array( $this, 'zeus_3dsecure_enrol' ) );
}
add_action( 'usces_action_admin_member_info', array( $this, 'admin_member_info' ), 10, 3 );
add_action( 'usces_action_post_update_memberdata', array( $this, 'admin_update_memberdata' ), 10, 2 );
add_filter( 'usces_filter_uscesL10n', array( $this, 'set_uscesL10n' ), 12, 2 );
add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ), 9 );
add_filter( 'usces_filter_available_payment_method', array( $this, 'set_available_payment_method' ) );
add_filter( 'usces_filter_template_redirect', array( $this, 'member_update_settlement' ), 1 );
add_action( 'usces_action_member_submenu_list', array( $this, 'e_update_settlement' ) );
add_filter( 'usces_filter_member_submenu_list', array( $this, 'update_settlement' ), 10, 2 );
add_filter( 'usces_filter_delete_member_check', array( $this, 'delete_member_check' ), 10, 2 );
add_filter( 'usces_filter_delete_member_check_front', array( $this, 'delete_member_check' ), 10, 2 );
/* WCEX DL Seller */
if ( defined( 'WCEX_DLSELLER' ) ) {
add_filter( 'usces_filter_the_continue_payment_method', array( $this, 'continuation_payment_method' ) );
add_filter( 'dlseller_filter_first_charging', array( $this, 'first_charging_date' ), 9, 5 );
add_filter( 'dlseller_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction' ), 10, 2 );
add_filter( 'dlseller_filter_continue_member_list_condition', array( $this, 'continue_member_list_condition' ), 10, 4 );
add_action( 'dlseller_action_continue_member_list_page', array( $this, 'continue_member_list_page' ) );
add_action( 'dlseller_action_do_continuation_charging', array( $this, 'auto_continuation_charging' ), 10, 4 );
add_action( 'dlseller_action_do_continuation', array( $this, 'do_auto_continuation' ), 10, 2 );
add_filter( 'dlseller_filter_reminder_mail_body', array( $this, 'reminder_mail_body' ), 10, 3 );
add_filter( 'dlseller_filter_contract_renewal_mail_body', array( $this, 'contract_renewal_mail_body' ), 10, 3 );
}
}
if ( $this->is_validity_acting( 'bnpl' ) ) {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_filter( 'usces_fiter_the_payment_method', array( $this, 'payment_method' ) );
add_filter( 'usces_filter_cod_label', array( $this, 'set_fee_label' ) );
add_filter( 'usces_filter_member_history_cod_label', array( $this, 'set_member_history_fee_label' ), 10, 2 );
add_filter( 'usces_filter_set_cart_fees_cod', array( $this, 'add_fee' ), 10, 7 );
add_filter( 'usces_filter_delivery_check', array( $this, 'check_fee_limit' ) );
add_filter( 'usces_filter_point_check_last', array( $this, 'check_fee_limit' ) );
}
}
/**
* Return an instance of this class.
*/
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Initialize.
*/
public function initialize_data() {
$options = get_option( 'usces', array() );
$options['acting_settings']['zeus']['ipaddrs'] = ( isset( $options['acting_settings']['zeus']['ipaddrs'] ) ) ? $options['acting_settings']['zeus']['ipaddrs'] : array();
$options['acting_settings']['zeus']['card_url'] = ( isset( $options['acting_settings']['zeus']['card_url'] ) ) ? $options['acting_settings']['zeus']['card_url'] : '';
$options['acting_settings']['zeus']['card_secureurl'] = ( isset( $options['acting_settings']['zeus']['card_secureurl'] ) ) ? $options['acting_settings']['zeus']['card_secureurl'] : '';
$options['acting_settings']['zeus']['card_tokenurl'] = ( isset( $options['acting_settings']['zeus']['card_tokenurl'] ) ) ? $options['acting_settings']['zeus']['card_tokenurl'] : '';
$options['acting_settings']['zeus']['bank_url'] = ( isset( $options['acting_settings']['zeus']['bank_url'] ) ) ? $options['acting_settings']['zeus']['bank_url'] : '';
$options['acting_settings']['zeus']['conv_url'] = ( isset( $options['acting_settings']['zeus']['conv_url'] ) ) ? $options['acting_settings']['zeus']['conv_url'] : '';
$options['acting_settings']['zeus']['card_activate'] = ( isset( $options['acting_settings']['zeus']['card_activate'] ) ) ? $options['acting_settings']['zeus']['card_activate'] : 'off';
$options['acting_settings']['zeus']['clientip'] = ( isset( $options['acting_settings']['zeus']['clientip'] ) ) ? $options['acting_settings']['zeus']['clientip'] : '';
$options['acting_settings']['zeus']['connection'] = ( isset( $options['acting_settings']['zeus']['connection'] ) ) ? $options['acting_settings']['zeus']['connection'] : 1;
$options['acting_settings']['zeus']['3dsecur'] = ( isset( $options['acting_settings']['zeus']['3dsecur'] ) ) ? $options['acting_settings']['zeus']['3dsecur'] : 2;
$options['acting_settings']['zeus']['3ds_pattern'] = ( isset( $options['acting_settings']['zeus']['3ds_pattern'] ) ) ? $options['acting_settings']['zeus']['3ds_pattern'] : '';
$options['acting_settings']['zeus']['security'] = ( isset( $options['acting_settings']['zeus']['security'] ) ) ? $options['acting_settings']['zeus']['security'] : 2;
$options['acting_settings']['zeus']['authkey'] = ( isset( $options['acting_settings']['zeus']['authkey'] ) ) ? $options['acting_settings']['zeus']['authkey'] : '';
$options['acting_settings']['zeus']['quickcharge'] = ( isset( $options['acting_settings']['zeus']['quickcharge'] ) ) ? $options['acting_settings']['zeus']['quickcharge'] : '';
$options['acting_settings']['zeus']['batch'] = ( isset( $options['acting_settings']['zeus']['batch'] ) ) ? $options['acting_settings']['zeus']['batch'] : '';
$options['acting_settings']['zeus']['auto_settlement_mail'] = ( isset( $options['acting_settings']['zeus']['auto_settlement_mail'] ) ) ? $options['acting_settings']['zeus']['auto_settlement_mail'] : 'off';
$options['acting_settings']['zeus']['howpay'] = ( isset( $options['acting_settings']['zeus']['howpay'] ) ) ? $options['acting_settings']['zeus']['howpay'] : '';
$options['acting_settings']['zeus']['howpay_B1'] = ( isset( $options['acting_settings']['zeus']['howpay_B1'] ) ) ? $options['acting_settings']['zeus']['howpay_B1'] : '';
$options['acting_settings']['zeus']['howpay_02'] = ( isset( $options['acting_settings']['zeus']['howpay_02'] ) ) ? $options['acting_settings']['zeus']['howpay_02'] : '';
$options['acting_settings']['zeus']['bank_activate'] = ( isset( $options['acting_settings']['zeus']['bank_activate'] ) ) ? $options['acting_settings']['zeus']['bank_activate'] : 'off';
$options['acting_settings']['zeus']['bank_ope'] = ( isset( $options['acting_settings']['zeus']['bank_ope'] ) ) ? $options['acting_settings']['zeus']['bank_ope'] : '';
$options['acting_settings']['zeus']['clientip_bank'] = ( isset( $options['acting_settings']['zeus']['clientip_bank'] ) ) ? $options['acting_settings']['zeus']['clientip_bank'] : '';
$options['acting_settings']['zeus']['testid_bank'] = ( isset( $options['acting_settings']['zeus']['testid_bank'] ) ) ? $options['acting_settings']['zeus']['testid_bank'] : '';
$options['acting_settings']['zeus']['bank_expired_date'] = ( isset( $options['acting_settings']['zeus']['bank_expired_date'] ) ) ? $options['acting_settings']['zeus']['bank_expired_date'] : '';
$options['acting_settings']['zeus']['conv_activate'] = ( isset( $options['acting_settings']['zeus']['conv_activate'] ) ) ? $options['acting_settings']['zeus']['conv_activate'] : 'off';
$options['acting_settings']['zeus']['conv_ope'] = ( isset( $options['acting_settings']['zeus']['conv_ope'] ) ) ? $options['acting_settings']['zeus']['conv_ope'] : '';
$options['acting_settings']['zeus']['clientip_conv'] = ( isset( $options['acting_settings']['zeus']['clientip_conv'] ) ) ? $options['acting_settings']['zeus']['clientip_conv'] : '';
$options['acting_settings']['zeus']['testid_conv'] = ( isset( $options['acting_settings']['zeus']['testid_conv'] ) ) ? $options['acting_settings']['zeus']['testid_conv'] : '';
$options['acting_settings']['zeus']['test_type_conv'] = ( isset( $options['acting_settings']['zeus']['test_type_conv'] ) ) ? $options['acting_settings']['zeus']['test_type_conv'] : '';
$options['acting_settings']['zeus']['pay_cvs'] = ( isset( $options['acting_settings']['zeus']['pay_cvs'] ) ) ? $options['acting_settings']['zeus']['pay_cvs'] : array();
$options['acting_settings']['zeus']['conv_span'] = ( isset( $options['acting_settings']['zeus']['conv_span'] ) ) ? $options['acting_settings']['zeus']['conv_span'] : '';
$options['acting_settings']['zeus']['bnpl_activate'] = ( isset( $options['acting_settings']['zeus']['bnpl_activate'] ) ) ? $options['acting_settings']['zeus']['bnpl_activate'] : 'off';
$options['acting_settings']['zeus']['bnpl_linkid'] = ( isset( $options['acting_settings']['zeus']['bnpl_linkid'] ) ) ? $options['acting_settings']['zeus']['bnpl_linkid'] : 'sbifstest1';
$options['acting_settings']['zeus']['clientip_bnpl'] = ( isset( $options['acting_settings']['zeus']['clientip_bnpl'] ) ) ? $options['acting_settings']['zeus']['clientip_bnpl'] : '';
$options['acting_settings']['zeus']['bnpl_linkpassword'] = ( isset( $options['acting_settings']['zeus']['bnpl_linkpassword'] ) ) ? $options['acting_settings']['zeus']['bnpl_linkpassword'] : '';
$options['acting_settings']['zeus']['bnpl_transaction_url'] = ( isset( $options['acting_settings']['zeus']['bnpl_transaction_url'] ) ) ? $options['acting_settings']['zeus']['bnpl_transaction_url'] : '';
$options['acting_settings']['zeus']['bnpl_shippingrequest_url'] = ( isset( $options['acting_settings']['zeus']['bnpl_shippingrequest_url'] ) ) ? $options['acting_settings']['zeus']['bnpl_shippingrequest_url'] : '';
$options['acting_settings']['zeus']['bnpl_modifytransaction_url'] = ( isset( $options['acting_settings']['zeus']['bnpl_modifytransaction_url'] ) ) ? $options['acting_settings']['zeus']['bnpl_modifytransaction_url'] : '';
$options['acting_settings']['zeus']['bnpl_fee_type'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_type'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_type'] : '';
$options['acting_settings']['zeus']['bnpl_fee'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee'] : '';
$options['acting_settings']['zeus']['bnpl_fee_limit_amount'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_limit_amount'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_limit_amount'] : '';
$options['acting_settings']['zeus']['bnpl_fee_first_amount'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_first_amount'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_first_amount'] : '';
$options['acting_settings']['zeus']['bnpl_fee_first_fee'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_first_fee'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_first_fee'] : '';
$options['acting_settings']['zeus']['bnpl_fee_amounts'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_amounts'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_amounts'] : array();
$options['acting_settings']['zeus']['bnpl_fee_fees'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_fees'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_fees'] : array();
$options['acting_settings']['zeus']['bnpl_fee_end_fee'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_end_fee'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_end_fee'] : '';
$options['acting_settings']['zeus']['activate'] = ( isset( $options['acting_settings']['zeus']['activate'] ) ) ? $options['acting_settings']['zeus']['activate'] : 'off';
if ( 'on' === $options['acting_settings']['zeus']['activate'] && 'on' === $options['acting_settings']['zeus']['card_activate'] ) {
if ( ! isset( $options['acting_settings']['zeus']['card_order_ref'] ) ) {
$options['acting_settings']['zeus']['card_order_ref'] = 'https://linkpt.cardservice.co.jp/cgi-bin/order_ref.cgi';
}
if ( ! isset( $options['acting_settings']['zeus']['card_price_change'] ) ) {
$options['acting_settings']['zeus']['card_price_change'] = 'https://linkpt.cardservice.co.jp/cgi-bin/credit/price_change/reflect/index.cgi';
}
}
update_option( 'usces', $options );
$this->unavailable_method = array( 'acting_welcart_card', 'acting_escott_card', 'acting_sbps_card', 'acting_paygent_card' );
}
/**
* 併用不可決済モジュール
* usces_filter_unavailable_payments
*
* @return array
*/
public function unavailable_payments() {
return $this->unavailable_method;
}
/**
* 決済有効判定
* 支払方法で使用している場合に true
*
* @param string $type Module type.
* @return bool
*/
public function is_validity_acting( $type = '' ) {
$acting_opts = $this->get_acting_settings();
if ( empty( $acting_opts ) ) {
return false;
}
$payment_method = usces_get_system_option( 'usces_payment_method', 'sort' );
$method = false;
switch ( $type ) {
case 'card':
foreach ( $payment_method as $payment ) {
if ( 'acting_zeus_card' === $payment['settlement'] && 'activate' === $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_card() ) {
return true;
} else {
return false;
}
break;
case 'bank':
foreach ( $payment_method as $payment ) {
if ( 'acting_zeus_bank' === $payment['settlement'] && 'activate' === $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_bank() ) {
return true;
} else {
return false;
}
break;
case 'conv':
foreach ( $payment_method as $payment ) {
if ( 'acting_zeus_conv' === $payment['settlement'] && 'activate' === $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_conv() ) {
return true;
} else {
return false;
}
break;
case 'bnpl':
foreach ( $payment_method as $payment ) {
if ( 'acting_zeus_bnpl' === $payment['settlement'] && 'activate' === $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_bnpl() ) {
return true;
} else {
return false;
}
break;
default:
if ( 'on' === $acting_opts['activate'] ) {
return true;
} else {
return false;
}
}
}
/**
* クレジットカード決済有効判定
*
* @param string $type 'link' Secure Link|'api' Secure API.
* @return boolean
*/
public function is_activate_card( $type = '' ) {
$acting_opts = $this->get_acting_settings();
if ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) {
if ( empty( $type ) ) {
if ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] ) {
$res = true;
} else {
$res = false;
}
} elseif ( 'link' === $type ) {
if ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] && isset( $acting_opts['connection'] ) && 1 === (int) $acting_opts['connection'] ) {
$res = true;
} else {
$res = false;
}
} elseif ( 'api' === $type ) {
if ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] && isset( $acting_opts['connection'] ) && 2 === (int) $acting_opts['connection'] ) {
$res = true;
} else {
$res = false;
}
} else {
$res = false;
}
} else {
$res = false;
}
return $res;
}
/**
* 銀行振込決済(入金おまかせサービス)有効判定
*
* @return bool
*/
public function is_activate_bank() {
$acting_opts = $this->get_acting_settings();
if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
( isset( $acting_opts['bank_activate'] ) && 'on' === $acting_opts['bank_activate'] ) ) {
$res = true;
} else {
$res = false;
}
return $res;
}
/**
* コンビニ決済有効判定
*
* @return bool
*/
public function is_activate_conv() {
$acting_opts = $this->get_acting_settings();
if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
( isset( $acting_opts['conv_activate'] ) && 'on' === $acting_opts['conv_activate'] ) ) {
$res = true;
} else {
$res = false;
}
return $res;
}
/**
* あと払い決済有効判定
*
* @return bool
*/
public function is_activate_bnpl() {
$acting_opts = $this->get_acting_settings();
if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
( isset( $acting_opts['bnpl_activate'] ) && 'on' === $acting_opts['bnpl_activate'] ) ) {
$res = true;
} else {
$res = false;
}
return $res;
}
/**
* 管理画面メッセージ表示
* admin_notices
*/
public function admin_notices() {
$acting_opts = $this->get_acting_settings();
if ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) {
if ( ! isset( $acting_opts['vercheck'] ) || '115' !== $acting_opts['vercheck'] ) {
echo '
';
}
}
}
/**
* 管理画面スクリプト
* admin_print_footer_scripts
*/
public function admin_scripts() {
$admin_page = filter_input( INPUT_GET, 'page' );
switch ( $admin_page ) :
/* クレジット決済設定画面 */
case 'usces_settlement':
$settlement_selected = get_option( 'usces_settlement_selected', array() );
if ( in_array( $this->paymod_id, (array) $settlement_selected, true ) ) :
$acting_opts = $this->get_acting_settings();
?>
get_order_payment_name( $order_id );
$acting_flg = $this->get_acting_flg( $payment_name );
$payment = usces_get_payments_by_name( $payment_name );
if ( isset( $payment['name'] ) ) {
$dialog_title = $payment['name'];
}
}
}
if ( 'acting_zeus_card' === $acting_flg || 'acting_zeus_bnpl' === $acting_flg ) :
?>
paymod_id ) {
return;
}
$this->error_mes = '';
$options = get_option( 'usces', array() );
$payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
$post_data = wp_unslash( $_POST );
unset( $options['acting_settings']['zeus'] );
$options['acting_settings']['zeus']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : '';
$options['acting_settings']['zeus']['clientip'] = ( isset( $post_data['clientip'] ) ) ? trim( $post_data['clientip'] ) : '';
$options['acting_settings']['zeus']['connection'] = ( isset( $post_data['connection'] ) ) ? $post_data['connection'] : 1;
$options['acting_settings']['zeus']['3dsecur'] = ( isset( $post_data['3dsecur'] ) ) ? $post_data['3dsecur'] : 2;
if ( isset( $post_data['3ds_pattern'] ) ) {
$options['acting_settings']['zeus']['3ds_pattern'] = $post_data['3ds_pattern'];
}
$options['acting_settings']['zeus']['security'] = ( isset( $post_data['security'] ) ) ? $post_data['security'] : 2;
if ( isset( $post_data['authkey'] ) ) {
$options['acting_settings']['zeus']['authkey'] = trim( $post_data['authkey'] );
}
$options['acting_settings']['zeus']['quickcharge'] = ( isset( $post_data['quickcharge'] ) ) ? $post_data['quickcharge'] : '';
$options['acting_settings']['zeus']['batch'] = ( isset( $post_data['batch'] ) ) ? $post_data['batch'] : '';
$options['acting_settings']['zeus']['auto_settlement_mail'] = ( isset( $post_data['auto_settlement_mail'] ) ) ? $post_data['auto_settlement_mail'] : 'off';
$options['acting_settings']['zeus']['howpay'] = ( isset( $post_data['howpay'] ) ) ? $post_data['howpay'] : '';
$options['acting_settings']['zeus']['howpay_B1'] = ( isset( $post_data['howpay_B1'] ) ) ? $post_data['howpay_B1'] : '';
$options['acting_settings']['zeus']['howpay_02'] = ( isset( $post_data['howpay_02'] ) ) ? $post_data['howpay_02'] : '';
$options['acting_settings']['zeus']['bank_activate'] = ( isset( $post_data['bank_activate'] ) ) ? $post_data['bank_activate'] : '';
$options['acting_settings']['zeus']['bank_ope'] = ( isset( $post_data['bank_ope'] ) ) ? $post_data['bank_ope'] : '';
$options['acting_settings']['zeus']['clientip_bank'] = ( isset( $post_data['clientip_bank'] ) ) ? trim( $post_data['clientip_bank'] ) : '';
$options['acting_settings']['zeus']['testid_bank'] = ( isset( $post_data['testid_bank'] ) ) ? trim( $post_data['testid_bank'] ) : '';
$options['acting_settings']['zeus']['bank_expired_date'] = ( isset( $post_data['bank_expired_date'] ) ) ? trim( $post_data['bank_expired_date'] ) : '';
$options['acting_settings']['zeus']['conv_activate'] = ( isset( $post_data['conv_activate'] ) ) ? $post_data['conv_activate'] : '';
$options['acting_settings']['zeus']['conv_ope'] = ( isset( $post_data['conv_ope'] ) ) ? $post_data['conv_ope'] : '';
$options['acting_settings']['zeus']['clientip_conv'] = ( isset( $post_data['clientip_conv'] ) ) ? trim( $post_data['clientip_conv'] ) : '';
$options['acting_settings']['zeus']['testid_conv'] = ( isset( $post_data['testid_conv'] ) ) ? trim( $post_data['testid_conv'] ) : '';
$options['acting_settings']['zeus']['test_type_conv'] = ( ( isset( $post_data['testid_conv'] ) && WCUtils::is_blank( $post_data['testid_conv'] ) ) || ( ! isset( $post_data['test_type'] ) ) ) ? 0 : $post_data['test_type'];
$options['acting_settings']['zeus']['pay_cvs'] = ( isset( $post_data['pay_cvs'] ) ) ? $post_data['pay_cvs'] : array();
$options['acting_settings']['zeus']['conv_span'] = ( isset( $post_data['conv_span'] ) ) ? trim( $post_data['conv_span'] ) : '';
$options['acting_settings']['zeus']['bnpl_activate'] = ( isset( $post_data['bnpl_activate'] ) ) ? $post_data['bnpl_activate'] : '';
$options['acting_settings']['zeus']['clientip_bnpl'] = ( isset( $post_data['clientip_bnpl'] ) ) ? trim( $post_data['clientip_bnpl'] ) : '';
$options['acting_settings']['zeus']['bnpl_linkpassword'] = ( isset( $post_data['bnpl_linkpassword'] ) ) ? trim( $post_data['bnpl_linkpassword'] ) : '';
$options['acting_settings']['zeus']['bnpl_fee_type'] = ( isset( $post_data['bnpl_fee_type'] ) ) ? $post_data['bnpl_fee_type'] : '';
$options['acting_settings']['zeus']['bnpl_fee'] = ( isset( $post_data['bnpl_fee'] ) ) ? $post_data['bnpl_fee'] : '';
$options['acting_settings']['zeus']['bnpl_fee_limit_amount'] = ( isset( $post_data[ 'bnpl_fee_limit_amount_' . $options['acting_settings']['zeus']['bnpl_fee_type'] ] ) ) ? $post_data[ 'bnpl_fee_limit_amount_' . $options['acting_settings']['zeus']['bnpl_fee_type'] ] : '';
$options['acting_settings']['zeus']['bnpl_fee_first_amount'] = ( isset( $post_data['bnpl_fee_first_amount'] ) ) ? $post_data['bnpl_fee_first_amount'] : '';
$options['acting_settings']['zeus']['bnpl_fee_first_fee'] = ( isset( $post_data['bnpl_fee_first_fee'] ) ) ? $post_data['bnpl_fee_first_fee'] : '';
$options['acting_settings']['zeus']['bnpl_fee_amounts'] = ( isset( $post_data['bnpl_fee_amounts'] ) ) ? explode( '|', $post_data['bnpl_fee_amounts'] ) : array();
$options['acting_settings']['zeus']['bnpl_fee_fees'] = ( isset( $post_data['bnpl_fee_fees'] ) ) ? explode( '|', $post_data['bnpl_fee_fees'] ) : array();
$options['acting_settings']['zeus']['bnpl_fee_end_fee'] = ( isset( $post_data['bnpl_fee_end_fee'] ) ) ? $post_data['bnpl_fee_end_fee'] : '';
if ( 'on' === $options['acting_settings']['zeus']['card_activate'] ) {
if ( WCUtils::is_blank( $post_data['clientip'] ) ) {
$this->error_mes .= '※カード決済IPコードを入力してください
';
}
if ( WCUtils::is_blank( $post_data['authkey'] ) && 2 === (int) $post_data['connection'] ) {
$this->error_mes .= '※認証キーを入力してください
';
}
if ( isset( $post_data['batch'] ) && 'on' === $post_data['batch'] ) {
if ( isset( $post_data['quickcharge'] ) && 'on' === $post_data['quickcharge'] ) {
} else {
$this->error_mes .= '※バッチ処理を利用する場合は、QuickCharge を「利用する」にしてください
';
$options['acting_settings']['zeus']['quickcharge'] = 'on';
}
}
}
if ( 'on' === $options['acting_settings']['zeus']['bank_activate'] ) {
if ( WCUtils::is_blank( $post_data['clientip_bank'] ) ) {
$this->error_mes .= '※銀行振込決済(入金おまかせサービス)IPコードを入力してください
';
}
if ( WCUtils::is_blank( $post_data['testid_bank'] ) && isset( $post_data['bank_ope'] ) && 'test' === $post_data['bank_ope'] ) {
$this->error_mes .= '※銀行振込決済(入金おまかせサービス)テストIDを入力してください
';
}
}
if ( 'on' === $options['acting_settings']['zeus']['conv_activate'] ) {
if ( WCUtils::is_blank( $post_data['clientip_conv'] ) ) {
$this->error_mes .= '※コンビニ決済IPコードを入力してください
';
}
if ( WCUtils::is_blank( $post_data['testid_conv'] ) && isset( $post_data['conv_ope'] ) && 'test' === $post_data['conv_ope'] ) {
$this->error_mes .= '※コンビニ決済テストIDを入力してください
';
}
if ( empty( $post_data['pay_cvs'] ) ) {
$this->error_mes .= '※コンビニ種類を選択してください
';
}
}
if ( 'on' === $options['acting_settings']['zeus']['bnpl_activate'] ) {
if ( WCUtils::is_blank( $post_data['clientip_bnpl'] ) ) {
$this->error_mes .= '※あと払い決済IPコードを入力してください
';
}
if ( WCUtils::is_blank( $post_data['bnpl_linkpassword'] ) ) {
$this->error_mes .= '※あと払い決済APIキーを入力してください
';
}
}
if ( 'on' === $options['acting_settings']['zeus']['card_activate'] || 'on' === $options['acting_settings']['zeus']['bank_activate'] || 'on' === $options['acting_settings']['zeus']['conv_activate'] || 'on' === $options['acting_settings']['zeus']['bnpl_activate'] ) {
$unavailable_activate = false;
foreach ( $payment_method as $settlement => $payment ) {
if ( in_array( $settlement, $this->unavailable_method ) && 'activate' === $payment['use'] ) {
$unavailable_activate = true;
break;
}
}
if ( $unavailable_activate ) {
$this->error_mes .= __( '* Settlement that can not be used together is activated.', 'usces' ) . '
';
}
}
if ( '' === $this->error_mes ) {
$usces->action_status = 'success';
$usces->action_message = __( 'Options are updated.', 'usces' );
if ( 'on' === $options['acting_settings']['zeus']['card_activate'] || 'on' === $options['acting_settings']['zeus']['bank_activate'] || 'on' === $options['acting_settings']['zeus']['conv_activate'] || 'on' === $options['acting_settings']['zeus']['bnpl_activate'] ) {
$options['acting_settings']['zeus']['activate'] = 'on';
$options['acting_settings']['zeus']['ipaddrs'] = self::ACTING_NOTICE_IPADDRS;
$toactive = array();
if ( 'on' === $options['acting_settings']['zeus']['card_activate'] ) {
$options['acting_settings']['zeus']['card_url'] = 'https://linkpt.cardservice.co.jp/cgi-bin/secure.cgi';
$options['acting_settings']['zeus']['card_secureurl'] = 'https://linkpt.cardservice.co.jp/cgi-bin/secure/api.cgi';
$options['acting_settings']['zeus']['card_tokenurl'] = 'https://linkpt.cardservice.co.jp/cgi-bin/token/token.cgi';
$options['acting_settings']['zeus']['card_order_ref'] = 'https://linkpt.cardservice.co.jp/cgi-bin/order_ref.cgi';
$options['acting_settings']['zeus']['card_price_change'] = 'https://linkpt.cardservice.co.jp/cgi-bin/credit/price_change/reflect/index.cgi';
$usces->payment_structure['acting_zeus_card'] = 'カード決済(ZEUS)';
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_zeus_card' === $settlement && 'activate' !== $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
} else {
unset( $usces->payment_structure['acting_zeus_card'] );
}
if ( 'on' === $options['acting_settings']['zeus']['bank_activate'] ) {
$options['acting_settings']['zeus']['bank_url'] = 'https://linkpt.cardservice.co.jp/cgi-bin/ebank.cgi';
$usces->payment_structure['acting_zeus_bank'] = '銀行振込決済(ZEUS)';
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_zeus_bank' === $settlement && 'activate' !== $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
} else {
unset( $usces->payment_structure['acting_zeus_bank'] );
}
if ( 'on' === $options['acting_settings']['zeus']['conv_activate'] ) {
$options['acting_settings']['zeus']['conv_url'] = 'https://linkpt.cardservice.co.jp/cgi-bin/cvs.cgi';
$usces->payment_structure['acting_zeus_conv'] = 'コンビニ決済(ZEUS)';
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_zeus_conv' === $settlement && 'activate' !== $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
} else {
unset( $usces->payment_structure['acting_zeus_conv'] );
}
if ( 'on' === $options['acting_settings']['zeus']['bnpl_activate'] ) {
$options['acting_settings']['zeus']['bnpl_linkid'] = 'sbifsprd01';
$options['acting_settings']['zeus']['bnpl_transaction_url'] = 'https://atobarai.sbi-finsol.co.jp/api/transaction.do';
$options['acting_settings']['zeus']['bnpl_shippingrequest_url'] = 'https://atobarai.sbi-finsol.co.jp/api/shippingrequest.do';
$options['acting_settings']['zeus']['bnpl_modifytransaction_url'] = 'https://atobarai.sbi-finsol.co.jp/api/modifytransaction.do';
$usces->payment_structure['acting_zeus_bnpl'] = 'あと払い決済(ZEUS)';
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_zeus_bnpl' === $settlement && 'activate' !== $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
} else {
unset( $usces->payment_structure['acting_zeus_bnpl'] );
}
$options['acting_settings']['zeus']['vercheck'] = '115';
usces_admin_orderlist_show_wc_trans_id();
if ( 0 < count( $toactive ) ) {
$usces->action_message .= __( 'Please update the payment method to "Activate". General Setting > Payment Methods', 'usces' );
}
} else {
$options['acting_settings']['zeus']['activate'] = 'off';
unset( $usces->payment_structure['acting_zeus_card'], $usces->payment_structure['acting_zeus_bank'], $usces->payment_structure['acting_zeus_conv'], $usces->payment_structure['acting_zeus_bnpl'] );
}
if ( 'on' !== $options['acting_settings']['zeus']['quickcharge'] || 'off' === $options['acting_settings']['zeus']['activate'] ) {
usces_clear_quickcharge( 'zeus_pcid' );
}
$deactivate = array();
foreach ( $payment_method as $settlement => $payment ) {
if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
if ( 'deactivate' !== $payment['use'] ) {
$payment['use'] = 'deactivate';
$deactivate[] = $payment['name'];
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
}
}
}
if ( 0 < count( $deactivate ) ) {
$deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
$usces->action_message .= $deactivate_message;
}
} else {
$usces->action_status = 'error';
$usces->action_message = __( 'Data have deficiency.', 'usces' );
$options['acting_settings']['zeus']['activate'] = 'off';
unset( $usces->payment_structure['acting_zeus_card'], $usces->payment_structure['acting_zeus_bank'], $usces->payment_structure['acting_zeus_conv'], $usces->payment_structure['acting_zeus_bnpl'] );
$deactivate = array();
foreach ( $payment_method as $settlement => $payment ) {
if ( in_array( $settlement, $this->pay_method ) ) {
if ( 'deactivate' !== $payment['use'] ) {
$payment['use'] = 'deactivate';
$deactivate[] = $payment['name'];
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
}
}
}
if ( 0 < count( $deactivate ) ) {
$deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
$usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
}
}
ksort( $usces->payment_structure );
update_option( 'usces', $options );
update_option( 'usces_payment_structure', $usces->payment_structure );
}
/**
* クレジット決済設定画面タブ
* usces_action_settlement_tab_title
*/
public function settlement_tab_title() {
$settlement_selected = get_option( 'usces_settlement_selected', array() );
if ( in_array( 'zeus', (array) $settlement_selected, true ) ) {
echo 'ゼウス';
}
}
/**
* クレジット決済設定画面フォーム
* usces_action_settlement_tab_body
*/
public function settlement_tab_body() {
global $usces;
$acting_opts = $this->get_acting_settings();
$settlement_selected = get_option( 'usces_settlement_selected', array() );
if ( in_array( 'zeus', (array) $settlement_selected, true ) ) :
$card_activate = ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] ) ? 'on' : 'off';
$client_ip = ( isset( $acting_opts['clientip'] ) ) ? $acting_opts['clientip'] : '';
$connection = ( isset( $acting_opts['connection'] ) ) ? (int) $acting_opts['connection'] : 0;
$authkey = ( isset( $acting_opts['authkey'] ) ) ? $acting_opts['authkey'] : '';
$threedsecure = ( 2 === $connection && isset( $acting_opts['3dsecur'] ) && 1 === (int) $acting_opts['3dsecur'] ) ? 1 : 2;
$pattern = ( 2 === $connection && isset( $acting_opts['3ds_pattern'] ) ) ? $acting_opts['3ds_pattern'] : '';
$security = ( isset( $acting_opts['security'] ) && 1 === (int) $acting_opts['security'] ) ? 1 : 2;
$quickcharge = ( isset( $acting_opts['quickcharge'] ) && 'on' === $acting_opts['quickcharge'] ) ? $acting_opts['quickcharge'] : 'off';
$batch = ( isset( $acting_opts['batch'] ) && 'on' === $acting_opts['batch'] ) ? $acting_opts['batch'] : 'off';
$howpay = ( isset( $acting_opts['howpay'] ) && 'on' === $acting_opts['howpay'] ) ? $acting_opts['howpay'] : 'off';
$howpay_b1 = ( isset( $acting_opts['howpay_B1'] ) && 'on' === $acting_opts['howpay_B1'] ) ? $acting_opts['howpay_B1'] : '';
$howpay_02 = ( isset( $acting_opts['howpay_02'] ) && 'on' === $acting_opts['howpay_02'] ) ? $acting_opts['howpay_02'] : '';
$wcex_name = '';
if ( defined( 'WCEX_DLSELLER' ) ) {
$wcex_name = '自動継続課金';
} elseif ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
$wcex_name = '定期購入';
}
$auto_settlement_mail = ( isset( $acting_opts['auto_settlement_mail'] ) && 'on' === $acting_opts['auto_settlement_mail'] ) ? 'on' : 'off';
$bank_activate = ( isset( $acting_opts['bank_activate'] ) && 'on' === $acting_opts['bank_activate'] ) ? 'on' : 'off';
$bank_ope = ( isset( $acting_opts['bank_ope'] ) && 'public' === $acting_opts['bank_ope'] ) ? 'public' : 'test';
$client_ip_bank = ( isset( $acting_opts['clientip_bank'] ) ) ? $acting_opts['clientip_bank'] : '';
$testid_bank = ( isset( $acting_opts['testid_bank'] ) ) ? $acting_opts['testid_bank'] : '';
$bank_expired_date = ( isset( $acting_opts['bank_expired_date'] ) ) ? $acting_opts['bank_expired_date'] : '';
$conv_activate = ( isset( $acting_opts['conv_activate'] ) && 'on' === $acting_opts['conv_activate'] ) ? 'on' : 'off';
$conv_ope = ( isset( $acting_opts['conv_ope'] ) && 'public' === $acting_opts['conv_ope'] ) ? 'public' : 'test';
$client_ip_conv = ( isset( $acting_opts['clientip_conv'] ) ) ? $acting_opts['clientip_conv'] : '';
$testid_conv = ( isset( $acting_opts['testid_conv'] ) ) ? $acting_opts['testid_conv'] : '';
$test_type_conv = ( isset( $acting_opts['test_type_conv'] ) ) ? (int) $acting_opts['test_type_conv'] : 0;
$pay_cvs = ( isset( $acting_opts['pay_cvs'] ) && is_array( $acting_opts['pay_cvs'] ) ) ? $acting_opts['pay_cvs'] : array();
$conv_span = ( isset( $acting_opts['conv_span'] ) ) ? $acting_opts['conv_span'] : '';
$bnpl_activate = ( isset( $acting_opts['bnpl_activate'] ) && 'on' === $acting_opts['bnpl_activate'] ) ? 'on' : 'off';
$client_ip_bnpl = ( isset( $acting_opts['clientip_bnpl'] ) ) ? $acting_opts['clientip_bnpl'] : '';
$bnpl_linkpassword = ( isset( $acting_opts['bnpl_linkpassword'] ) ) ? $acting_opts['bnpl_linkpassword'] : '';
if ( 'fix' === $acting_opts['bnpl_fee_type'] ) {
$bnpl_fee_type_field = ( ! empty( $acting_opts['bnpl_fee'] ) ) ? $this->get_fee_name( $acting_opts['bnpl_fee_type'] ) . ' ' : '';
} elseif ( 'change' === $acting_opts['bnpl_fee_type'] ) {
$bnpl_fee_type_field = ( ! empty( $acting_opts['bnpl_fee_first_fee'] ) ) ? $this->get_fee_name( $acting_opts['bnpl_fee_type'] ) . ' ' : '';
} else {
$bnpl_fee_type_field = '';
}
?>
acting_formal_name ); ?>
error_mes ) :
?>
error_mes ); ?>
十分にテストを行ってから運用してください。
ゼウス決済サービスの詳細はこちら 》
この決済は「非通過型・トークン方式」の決済システムです。
「非通過型」とは、決済会社のページへは遷移せず、Welcart のページのみで完結する決済システムです。
デザインの統一されたスタイリッシュな決済が可能です。但し、カード番号を扱いますので専用SSLが必須となります。
入力されたカード番号はトークンに置き換えてゼウスのシステムに送信されますので、Welcart に保存することはありません。
※ボーナス一括、2回払いは契約がある場合にのみご利用いただけます。
※ 3Dセキュアとセキュリティーコード
3Dセキュアとおよびセキュリティーコードの利用は、決済サービス契約時に決定します。契約内容に従って指定しないと正常に動作しませんのでご注意ください。
3Dセキュアを利用する場合はテストカードを使用してのテスト決済はできません。
詳しくは株式会社ゼウス(代表:03-3498-9030)にお問い合わせください。
テスト稼動について
銀行振込決済(入金おまかせサービス)およびコンビニ決済のテストを行う際は、「稼働環境」で「テスト環境」を選択し、「テストID」の項目にゼウスから発行されるテストIDを入力してください。
また、本稼働の際には、「本番環境」を選択して更新してください。
ご利用規約および下記の注意事項をご確認いただき、ご同意の上お申し込みください。
- ご利用限度額(未払い累計金額)は55,000円(税込)です。
- ご利用にあたり審査がございます。審査結果によっては、あと払い決済をご利用いただけないことがございますので、その場合は別のお支払方法をご利用ください。
- ご請求メールは、購入者さまのメールアドレス宛にSBI FinTech Solutions株式会社(atobarai@sbi-finsol.co.jp)よりお送りします。
- 商品をお受取り後、メールに記載のお支払い期日まで(発行日から14日以内)にコンビニエンスストアまたは銀行振込にてお支払いください。コンビニ払いの場合は、電子バーコードを提示してのお支払いになりますので、スマートフォンで受け取れるメールアドレスをご入力ください。
- 未成年の方は必ず親権者(法定代理人)の同意を得てご利用ください。
- 商品のお届け先住所が「運送業者の営業所留め」「郵便局留め」の場合や「学校」「病院」「ホテル」など一時滞在先の場合は、「あと払い決済」をご利用いただけません。また、商品の海外転送サービスもご利用いただけません。
- あと払い決済のサービス詳細・よくあるご質問は下記をご参照ください。
https://www.sbi-finsol.co.jp/atobarai/purchaser/
';
}
}
return $newvalue;
}
/**
* 結果通知前処理
* usces_construct
*/
public function acting_construct() {
$acting_opts = $this->get_acting_settings();
if ( ! empty( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], $acting_opts['ipaddrs'] ) ) {
$result_data = wp_unslash( $_REQUEST );
if ( isset( $result_data['sendpoint'] ) ) {
$sendpoint = $result_data['sendpoint'];
$acting_data = usces_get_order_acting_data( $sendpoint );
if ( empty( $acting_data['sesid'] ) ) {
if ( isset( $result_data['result'] ) && 'OK' === $result_data['result'] && isset( $result_data['money'] ) && 0 === (int) $result_data['money'] ) {
} else {
$log = array(
'acting' => 'zeus',
'key' => $sendpoint,
'result' => 'SESSION ERROR',
'data' => $result_data,
);
usces_save_order_acting_error( $log );
}
} else {
if ( isset( $result_data['acting'] ) && 'zeus_bank' === $result_data['acting'] ) {
usces_restore_order_acting_data( $sendpoint );
}
}
}
}
}
/**
* 決済結果通知(zeus_conv / zeus_bank)の送信元IPを検証する
*
* 許可IP以外からのリクエストはエラーログを残して処理を終了する
* 入金状態を変更するサーバー間通知でのみ呼び出すこと
* ブラウザ戻りを伴う zeus_card では呼び出さない
*
* @return void
*/
private function acting_notice_ip_guard() {
$remote_addr = ( isset( $_SERVER['REMOTE_ADDR'] ) ) ? wp_unslash( $_SERVER['REMOTE_ADDR'] ) : '';
if ( usces_acting_notice_ip_allowed( $remote_addr, self::ACTING_NOTICE_IPADDRS ) ) {
return;
}
$log = array(
'acting' => ( isset( $_REQUEST['acting'] ) ) ? wp_unslash( $_REQUEST['acting'] ) : 'zeus',
'key' => ( isset( $_REQUEST['sendpoint'] ) ) ? wp_unslash( $_REQUEST['sendpoint'] ) : '',
'result' => 'IP ADDRESS NOT ALLOWED: ' . $remote_addr,
'data' => wp_unslash( $_REQUEST ),
);
usces_save_order_acting_error( $log );
usces_log( 'zeus notice denied ip : ' . $remote_addr, 'acting_transaction.log' );
header( 'HTTP/1.0 200 OK' );
die( 'error0' );
}
/**
* 結果通知処理
* usces_after_cart_instant
*/
public function acting_transaction() {
global $usces;
/* zeus_card */
if ( isset( $_REQUEST['acting'] ) && 'zeus_card' === $_REQUEST['acting'] && isset( $_REQUEST['result'] ) && isset( $_REQUEST['ordd'] ) ) {
foreach ( $_REQUEST as $key => $value ) {
if ( 'uscesid' === $key ) {
continue;
}
$data[ $key ] = $value;
}
if ( empty( $data['sendpoint'] ) ) {
$log = array(
'acting' => $data['acting'],
'key' => '(empty key)',
'result' => $data['result'],
'data' => $data,
);
usces_save_order_acting_error( $log );
header( 'HTTP/1.0 200 OK' );
die( 'error1' );
}
if ( 'OK' === $data['result'] ) {
$order_data = usces_restore_order_acting_data( $data['sendpoint'] );
$order_id = $this->get_order_id( $data['sendpoint'] );
if ( empty( $order_id ) && ! empty( $order_data ) ) {
$res = $usces->order_processing( $data );
if ( 'ordercompletion' === $res ) {
$_nonce = ( isset( $order_data['_nonce'] ) ) ? $order_data['_nonce'] : wp_create_nonce( 'acting_zeus_card' );
wp_redirect(
add_query_arg(
array(
'acting' => $data['acting'],
'acting_return' => 1,
'result' => 1,
'_nonce' => $_nonce,
),
USCES_CART_URL
)
);
} else {
$log = array(
'acting' => $data['acting'],
'key' => $rand,
'result' => 'ORDER DATA REGISTERED ERROR',
'data' => $data,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => $data['acting'],
'acting_return' => 0,
'result' => 0,
),
USCES_CART_URL
)
);
}
} else {
$log = array(
'acting' => $data['acting'],
'key' => $data['sendpoint'],
'result' => 'ORDER DATA RESTORE ERROR',
'data' => $data,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => $data['acting'],
'acting_return' => 0,
'result' => 0,
),
USCES_CART_URL
)
);
}
header( 'HTTP/1.0 200 OK' );
die( 'zeus' );
} else {
$log = array(
'acting' => $data['acting'],
'key' => $data['sendpoint'],
'result' => $data['result'],
'data' => $data,
);
usces_save_order_acting_error( $log );
header( 'HTTP/1.0 200 OK' );
die( 'error3' );
}
/* zeus_bank */
} elseif ( isset( $_REQUEST['acting'] ) && 'zeus_bank' === $_REQUEST['acting'] && isset( $_REQUEST['order_no'] ) && isset( $_REQUEST['tracking_no'] ) ) {
$this->acting_notice_ip_guard();
foreach ( $_REQUEST as $key => $value ) {
if ( 'uscesid' === $key ) {
continue;
}
$data[ $key ] = $value;
}
if ( '04' === $data['status'] || '05' === $data['status'] ) {
$log = array(
'acting' => $data['acting'],
'key' => $data['sendpoint'],
'result' => $data['status'],
'data' => $data,
);
usces_save_order_acting_error( $log );
header( 'HTTP/1.0 200 OK' );
die( 'error0' );
}
$order_id = $this->get_order_id( $data['tracking_no'] );
if ( empty( $order_id ) ) {
$res = $usces->order_processing( $data );
if ( 'error' === $res ) {
$log = array(
'acting' => $data['acting'],
'key' => $data['sendpoint'],
'result' => 'ORDER DATA REGISTERED ERROR',
'data' => $data,
);
usces_save_order_acting_error( $log );
header( 'HTTP/1.0 200 OK' );
die( 'error1' );
} else {
$order_id = $usces->cart->get_order_entry( 'ID' );
if ( $order_id ) {
$usces->cart->clear_cart();
}
}
}
if ( ! empty( $order_id ) ) {
if ( '03' === $data['status'] ) {
$res = usces_change_order_receipt( $order_id, 'receipted' );
do_action( 'usces_action_zeus_bank_receipted', $order_id, $data );
} else {
$res = usces_change_order_receipt( $order_id, 'noreceipt' );
}
if ( false === $res ) {
$log = array(
'acting' => $data['acting'],
'key' => $data['sendpoint'],
'result' => 'ORDER DATA UPDATE ERROR',
'data' => $data,
);
usces_save_order_acting_error( $log );
header( 'HTTP/1.0 200 OK' );
die( 'error2' );
}
if ( '03' === $data['status'] ) {
usces_action_acting_getpoint( $order_id );
}
$res = $usces->set_order_meta_value( 'acting_' . $data['tracking_no'], usces_serialize( $data ), $order_id );
if ( false === $res ) {
$log = array(
'acting' => $data['acting'],
'key' => $data['sendpoint'],
'result' => 'ORDER META DATA UPDATE ERROR',
'data' => $data,
);
usces_save_order_acting_error( $log );
header( 'HTTP/1.0 200 OK' );
die( 'error3' );
}
}
header( 'HTTP/1.0 200 OK' );
die( 'zeus' );
/* zeus_conv */
} elseif ( isset( $_REQUEST['acting'] ) && 'zeus_conv' === $_REQUEST['acting'] && isset( $_REQUEST['status'] ) && isset( $_REQUEST['sendpoint'] ) && isset( $_REQUEST['clientip'] ) ) {
$this->acting_notice_ip_guard();
foreach ( $_REQUEST as $key => $value ) {
if ( 'uscesid' === $key ) {
continue;
}
if ( 'username' === $key ) {
$data[ $key ] = mb_convert_encoding( $value, 'UTF-8', 'SJIS' );
} else {
$data[ $key ] = $value;
}
}
$order_id = $this->get_order_id( $data['sendpoint'] );
if ( ! empty( $order_id ) ) {
if ( '05' !== $data['status'] ) {
if ( '04' === $data['status'] ) {
$res = usces_change_order_receipt( $order_id, 'receipted' );
do_action( 'usces_action_zeus_conv_receipted', $order_id, $data );
} else {
$res = usces_change_order_receipt( $order_id, 'noreceipt' );
}
if ( false === $res ) {
$log = array(
'acting' => $data['acting'],
'key' => $data['sendpoint'],
'result' => 'ORDER DATA UPDATE ERROR',
'data' => $data,
);
usces_save_order_acting_error( $log );
header( 'HTTP/1.0 200 OK' );
die( 'error2' );
}
if ( '04' === $data['status'] ) {
usces_action_acting_getpoint( $order_id );
}
$res = $usces->set_order_meta_value( 'acting_' . $data['sendpoint'], usces_serialize( $data ), $order_id );
if ( false === $res ) {
$log = array(
'acting' => $data['acting'],
'key' => $data['sendpoint'],
'result' => 'ORDER META DATA UPDATE ERROR',
'data' => $data,
);
usces_save_order_acting_error( $log );
header( 'HTTP/1.0 200 OK' );
die( 'error3' );
}
}
}
header( 'HTTP/1.0 200 OK' );
die( 'zeus' );
}
if ( isset( $_REQUEST['backfrom_zeus_bank'] ) && '1' === $_REQUEST['backfrom_zeus_bank'] ) {
$usces->cart->clear_cart();
}
}
/**
* 管理画面送信メール
* usces_filter_order_confirm_mail_payment
*
* @param string $msg_payment Default payment message.
* @param int $order_id Order number.
* @param array $payment Payment information.
* @param array $cart Cart data.
* @param array $data Order data.
* @return string
*/
public function order_confirm_mail_payment( $msg_payment, $order_id, $payment, $cart, $data ) {
global $usces;
switch ( $payment['settlement'] ) {
case 'acting_zeus_card':
$div_name = '';
$acting_opts = $this->get_acting_settings();
if ( 'on' === $acting_opts['howpay'] ) {
$acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_zeus_card', $order_id ) );
$howpay = ( isset( $acting_data['howpay'] ) ) ? $acting_data['howpay'] : '1';
$div = ( isset( $acting_data['div'] ) ) ? $acting_data['div'] : '01';
if ( '1' == $howpay ) {
$div_name = ' 一括払い';
} else {
switch ( $div ) {
case '01':
$div_name = ' 一括払い';
break;
case '02':
$div_name = ' 分割(2回)';
break;
case '03':
$div_name = ' 分割(3回)';
break;
case '05':
$div_name = ' 分割(5回)';
break;
case '06':
$div_name = ' 分割(6回)';
break;
case '10':
$div_name = ' 分割(10回)';
break;
case '12':
$div_name = ' 分割(12回)';
break;
case '15':
$div_name = ' 分割(15回)';
break;
case '18':
$div_name = ' 分割(18回)';
break;
case '20':
$div_name = ' 分割(20回)';
break;
case '24':
$div_name = ' 分割(24回)';
break;
case '99':
$div_name = ' 分割(リボ払い)';
break;
case 'B1':
$div_name = ' 分割(ボーナス一括払い)';
break;
}
}
}
if ( '' !== $div_name && isset( $payment['name'] ) ) {
if ( usces_is_html_mail() ) {
$msg_payment = '| ';
$msg_payment .= $payment['name'] . $div_name;
$msg_payment .= ' |
';
} else {
$msg_payment = __( '** Payment method **', 'usces' ) . "\r\n";
$msg_payment .= usces_mail_line( 1, $data['order_email'] ); // ********************
$msg_payment .= $payment['name'] . $div_name;
$msg_payment .= "\r\n\r\n";
}
}
break;
case 'acting_zeus_bank':
break;
case 'acting_zeus_conv':
$conv_name = '';
$acting_data = $this->get_order_meta_acting( $order_id );
if ( isset( $acting_data['pay_cvs'] ) ) {
$conv_name = usces_get_conv_name( $acting_data['pay_cvs'] );
}
if ( '' !== $conv_name && isset( $payment['name'] ) ) {
if ( usces_is_html_mail() ) {
$msg_payment = '| ';
$msg_payment .= $payment['name'] . ' (' . $conv_name . ')';
$msg_payment .= ' |
';
} else {
$msg_payment = __( '** Payment method **', 'usces' ) . "\r\n";
$msg_payment .= usces_mail_line( 1, $data['order_email'] ); // ********************
$msg_payment .= $payment['name'] . ' (' . $conv_name . ')';
$msg_payment .= "\r\n\r\n";
}
}
break;
case 'acting_zeus_bnpl':
break;
}
return $msg_payment;
}
/**
* ポイント即時付与
* usces_filter_is_complete_settlement
*
* @param bool $complete Complete the payment.
* @param string $payment_name Payment name.
* @param string $status Payment status.
* @return bool
*/
public function is_complete_settlement( $complete, $payment_name, $status ) {
$acting_flg = $this->get_acting_flg( $payment_name );
if ( 'acting_zeus_card' === $acting_flg ) {
$complete = true;
}
return $complete;
}
/**
* 購入完了メッセージ
* usces_filter_completion_settlement_message
*
* @param string $form Message form.
* @param array $entry Entry data.
* @return string
*/
public function completion_settlement_message( $form, $entry ) {
global $usces;
if ( isset( $_REQUEST['acting'] ) && 'zeus_conv' === wp_unslash( $_REQUEST['acting'] ) ) {
$form .= 'ゼウス・コンビニ決済
';
$form .= '
';
$form .= '| オーダー番号 | ' . esc_html( $usces->payment_results['order_no'] ) . ' |
';
$form .= '| お支払先 | ' . esc_html( usces_get_conv_name( $usces->payment_results['pay_cvs'] ) ) . ' |
';
switch ( $usces->payment_results['pay_cvs'] ) {
case 'D001': /* セブンイレブン */
$form .= '| 払込票番号 | ' . esc_html( $usces->payment_results['pay_no1'] ) . ' |
';
$form .= '| URL | ' . esc_html( $usces->payment_results['pay_url'] ) . ' |
';
break;
case 'D002': /* ローソン */
case 'D050': /* ミニストップ */
$form .= '| 受付番号 | ' . esc_html( $usces->payment_results['pay_no1'] ) . ' |
';
if ( isset( $usces->payment_results['pay_no2'] ) ) {
$form .= '| 確認番号 | ' . esc_html( $usces->payment_results['pay_no2'] ) . ' |
';
}
break;
case 'D040': /* サークルKサンクス */
case 'D015': /* セイコーマート */
$form .= '| お支払受付番号 | ' . esc_html( $usces->payment_results['pay_no1'] ) . ' |
';
break;
case 'D030': /* ファミリーマート */
$form .= '| 注文番号 | ' . esc_html( $usces->payment_results['pay_no1'] ) . ' |
';
$form .= '| 企業コード | ' . esc_html( $usces->payment_results['pay_no2'] ) . ' |
';
break;
case 'D060': /* デイリーヤマザキ */
$form .= '| オンライン決済番号 | ' . esc_html( $usces->payment_results['pay_no1'] ) . ' |
';
break;
}
$form .= '| お支払期限 | ' . esc_html( substr( $usces->payment_results['pay_limit'], 0, 4 ) . '年' . substr( $usces->payment_results['pay_limit'], 4, 2 ) . '月' . substr( $usces->payment_results['pay_limit'], 6, 2 ) . '日' ) . '(期限を過ぎますとお支払ができません) |
';
// $form .= '
get_member();
$subject = apply_filters( 'usces_filter_send_update_settlement_mail_subject', __( 'Confirmation of credit card update', 'usces' ), $member );
$mail_header = __( 'Your credit card information has been updated on the membership page.', 'usces' ) . "\r\n\r\n";
$mail_footer = get_option( 'blogname' ) . "\r\n";
$name = usces_localized_name( $member['name1'], $member['name2'], 'return' );
$to_name = sprintf( _x( '%s', 'honorific', 'usces' ), $name );
$message = '--------------------------------' . "\r\n";
$message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
$message .= __( 'Name', 'usces' ) . ' : ' . $to_name . "\r\n";
$message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
$message .= '--------------------------------' . "\r\n\r\n";
$message .= __( 'If you have not requested this email, sorry to trouble you, but please contact us.', 'usces' ) . "\r\n\r\n";
$message = apply_filters( 'usces_filter_send_update_settlement_mail_message', $message, $member );
$message = apply_filters( 'usces_filter_send_update_settlement_mail_message_head', $mail_header, $member ) . $message . apply_filters( 'usces_filter_send_update_settlement_mail_message_foot', $mail_footer, $member ) . "\r\n";
$message = sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n" . $message;
$send_para = array(
'to_name' => $to_name,
'to_address' => $member['mailaddress1'],
'from_name' => get_option( 'blogname' ),
'from_address' => $usces->options['sender_mail'],
'reply_name' => get_option( 'blogname' ),
'reply_to' => usces_get_first_order_mail(),
'return_path' => $usces->options['sender_mail'],
'subject' => $subject,
'message' => do_shortcode( $message ),
);
usces_send_mail( $send_para );
$admin_message = $mail_header;
$admin_message .= '--------------------------------' . "\r\n";
$admin_message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
$admin_message .= __( 'Name', 'usces' ) . ' : ' . $to_name . "\r\n";
$admin_message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
$admin_message .= '--------------------------------' . "\r\n\r\n";
if ( usces_have_member_continue_order( $member['ID'] ) ) {
$admin_message .= $this->message_continue_order( $member['ID'] );
}
if ( usces_have_member_regular_order( $member['ID'] ) ) {
$admin_message .= $this->message_regular_order( $member['ID'] );
}
$admin_message .=
"\r\n----------------------------------------------------\r\n" .
'REMOTE_ADDR : ' . $_SERVER['REMOTE_ADDR'] .
"\r\n----------------------------------------------------\r\n";
$admin_para = array(
'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
'to_address' => $usces->options['order_mail'],
'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
'from_address' => $usces->options['sender_mail'],
'reply_name' => get_option( 'blogname' ),
'reply_to' => usces_get_first_order_mail(),
'return_path' => $usces->options['sender_mail'],
'subject' => $subject . '( ' . $to_name . ' )',
'message' => do_shortcode( $admin_message ),
);
usces_send_mail( $admin_para );
}
/**
* 契約中の自動継続課金情報
*
* @param int $member_id Member ID.
*/
public function message_continue_order( $member_id ) {
global $usces, $wpdb;
$message = '';
$query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}usces_continuation WHERE `con_member_id` = %d AND `con_acting` = %s AND `con_status` = 'continuation'", $member_id, 'acting_paygent_card' );
$continue_order = $wpdb->get_results( $query, ARRAY_A );
if ( 0 < count( $continue_order ) ) {
$message .= '--------------------------------' . "\r\n";
$message .= __( 'Auto-continuation charging Information under Contract with a credit card', 'usces' ) . "\r\n";
foreach ( $continue_order as $continue_data ) {
$con_id = $continue_data['con_id'];
$con_order_id = $continue_data['con_order_id'];
$message .= __( 'Order number', 'usces' ) . ' : ' . $con_order_id;
$latest_log = $this->get_acting_latest_log( $con_order_id, 0, 'ALL' );
if ( ! empty( $latest_log ) ) {
$next_charging = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_charging( $con_order_id ) : $continue_data['con_next_contracting'];
$message .= ' ( ' . __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $next_charging ) );
if ( 0 < (int) $continue_data['con_interval'] ) {
$next_contracting = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_contracting( $con_order_id ) : $continue_data['con_next_contracting'];
$message .= ', ' . __( 'Renewal Date', 'dlseller' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $next_contracting ) );
}
$message .= ' )';
if ( isset( $latest_log['result'] ) && 'OK' !== $latest_log['result'] ) {
$message .= ' ' . __( 'Condition', 'dlseller' ) . ' : ' . __( 'Settlement error', 'usces' );
if ( ! empty( $latest_log['tracking_id'] ) ) {
$message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $latest_log['tracking_id'] . ' )';
}
}
}
$message .= "\r\n";
}
$message .= '--------------------------------' . "\r\n\r\n";
}
return $message;
}
/**
* 契約中の定期購入情報
*
* @param int $member_id Member ID.
*/
public function message_regular_order( $member_id ) {
global $usces, $wpdb;
$message = '';
$query_order = $wpdb->prepare(
"SELECT r.reg_id, r.reg_payment_name, d.regdet_schedule_date
FROM {$wpdb->prefix}usces_regular_detail AS `d`
RIGHT JOIN {$wpdb->prefix}usces_regular AS `r` ON r.reg_id = d.reg_id
WHERE r.reg_mem_id = %d AND d.regdet_condition = 'continuation'
GROUP BY r.reg_id",
$member_id
);
$regular_order = $wpdb->get_results( $query_order, ARRAY_A );
if ( 0 < count( $regular_order ) ) {
foreach ( $regular_order as $regular_data ) {
$acting_flg = $this->get_acting_flg( $regular_data['reg_payment_name'] );
if ( 'acting_zeus_card' !== $acting_flg ) {
continue;
}
$reg_id = $regular_data['reg_id'];
$query = $wpdb->prepare(
"SELECT o.ID AS `order_id`, meta.meta_value AS `deco_id`, DATE_FORMAT( o.order_date, %s ) AS `order_date`
FROM {$wpdb->prefix}usces_order AS `o`
LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta` ON o.ID = meta.order_id AND meta.meta_key = 'dec_order_id'
LEFT JOIN {$wpdb->prefix}usces_regular ON o.ID = `reg_order_id`
WHERE `reg_id` = %d
UNION ALL
SELECT o1.ID AS `order_id`, meta1.meta_value AS `deco_id`, DATE_FORMAT( o1.order_date, %s ) AS `order_date`
FROM {$wpdb->prefix}usces_order AS `o1`
LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta1` ON o1.ID = meta1.order_id AND meta1.meta_key = 'dec_order_id'
LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta2` ON o1.ID = meta2.order_id AND meta2.meta_key = 'regular_id'
WHERE meta2.meta_value = %d
ORDER BY `order_id` DESC, `order_date` DESC",
'%Y-%m-%d',
$reg_id,
'%Y-%m-%d',
$reg_id
);
$regular_order_data = $wpdb->get_results( $query, ARRAY_A );
if ( 0 < count( $regular_order_data ) ) {
$message .= __( 'Regular ID', 'autodelivery' ) . ' : ' . $reg_id;
$reg_order_id = $regular_order_data[0]['order_id'];
$latest_log = $this->get_acting_latest_log( $reg_order_id, 0, 'ALL' );
if ( isset( $latest_log['result'] ) && 'OK' !== $latest_log['result'] ) {
$message .= ' ' . __( 'Condition', 'autodelivery' ) . ' : ' . __( 'Settlement error', 'usces' );
$trans_id = $usces->get_order_meta_value( 'trans_id', $reg_order_id );
if ( $trans_id ) {
$message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $trans_id . ' )';
}
} else {
if ( $this->isdate( $regular_data['regdet_schedule_date'] ) ) {
$message .= ' ( ' . __( 'Scheduled order date', 'autodelivery' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $regular_data['regdet_schedule_date'] ) ) . ' )';
}
}
$message .= "\r\n";
}
}
if ( '' !== $message ) {
$message = '--------------------------------' . "\r\n"
. __( 'Subscription Information under Contract with a credit card', 'usces' ) . "\r\n"
. $message
. '--------------------------------' . "\r\n\r\n";
}
}
return $message;
}
/**
* 日付チェック
*
* @param object $date DateTime.
* @return boolean
*/
private function isdate( $date ) {
if ( empty( $date ) ) {
return false;
}
try {
new DateTime( $date );
list( $year, $month, $day ) = explode( '-', $date );
$res = checkdate( (int) $month, (int) $day, (int) $year );
return $res;
} catch ( Exception $e ) {
return false;
}
}
/**
* 会員データ削除チェック
* usces_filter_delete_member_check
*
* @param bool $del Deletable.
* @param int $member_id Member ID.
* @return bool
*/
public function delete_member_check( $del, $member_id ) {
if ( usces_have_member_continue_order( $member_id ) || usces_have_member_regular_order( $member_id ) ) {
$del = false;
}
return $del;
}
/**
* 利用可能な支払方法(継続課金・定期購入)
* dlseller_filter_the_payment_method_restriction
* wcad_filter_the_payment_method_restriction
*
* @param array $payments_restriction Payment method.
* @param string $value Input value.
* @return array
*/
public function payment_method_restriction( $payments_restriction, $value ) {
if ( ( usces_have_regular_order() || usces_have_continue_charge() ) && usces_is_login() ) {
$zeus_card = false;
foreach ( (array) $payments_restriction as $key => $payment ) {
if ( isset( $payment['settlement'] ) && 'acting_zeus_card' === $payment['settlement'] ) {
$zeus_card = true;
}
}
if ( ! $zeus_card ) {
$payments = usces_get_system_option( 'usces_payment_method', 'settlement' );
$payments_restriction[] = $payments['acting_zeus_card'];
}
$sort = array();
foreach ( (array) $payments_restriction as $key => $payment ) {
$sort[ $key ] = $payment['sort'];
}
array_multisort( $sort, SORT_ASC, $payments_restriction );
}
return $payments_restriction;
}
/**
* 利用可能な支払方法
* usces_filter_the_continue_payment_method
*
* @param array $payment_method Payment method.
* @return array
*/
public function continuation_payment_method( $payment_method ) {
if ( ! array_key_exists( 'acting_zeus_card', $payment_method ) ) {
$payment_method[] = 'acting_zeus_card';
}
return $payment_method;
}
/**
* 「初回引落し日」
* dlseller_filter_first_charging
*
* @param object $time Datetime.
* @param int $post_id Post ID.
* @param array $usces_item Item data.
* @param int $order_id Order number.
* @param array $continue_data Continuation data.
* @return object
*/
public function first_charging_date( $time, $post_id, $usces_item, $order_id, $continue_data ) {
if ( 99 === (int) $usces_item['item_chargingday'] ) {
if ( empty( $order_id ) ) {
$today = date_i18n( 'Y-m-d', current_time( 'timestamp' ) );
list( $year, $month, $day ) = explode( '-', $today );
$time = mktime( 0, 0, 0, (int) $month, (int) $day, (int) $year );
}
}
return $time;
}
/**
* 継続課金会員リスト「状態」
* dlseller_filter_continue_member_list_condition
*
* @param string $condition Continuation condition.
* @param int $member_id Member ID.
* @param int $order_id Order number.
* @param array $continue_data Continuation data.
* @return string
*/
public function continue_member_list_condition( $condition, $member_id, $order_id, $continue_data ) {
if ( isset( $continue_data['acting'] ) && 'acting_zeus_card' === $continue_data['acting'] ) {
$url = admin_url( 'admin.php?page=usces_continue&continue_action=settlement_zeus_card&member_id=' . esc_attr( $member_id ) . '&order_id=' . esc_attr( $order_id ) );
$condition = '' . __( 'Detail', 'usces' ) . '';
if ( 'continuation' === $continue_data['status'] ) {
$latest_log = $this->get_acting_latest_log( $order_id, 0, 'ALL' );
if ( isset( $latest_log['result'] ) && ! in_array( $latest_log['result'], $this->payment_normal_results, true ) ) {
$condition .= '' . __( 'Settlement error', 'usces' ) . '
';
}
}
}
return $condition;
}
/**
* 継続課金会員決済状況ページ表示
* dlseller_action_continue_member_list_page
*
* @param string $continue_action Continuation action.
*/
public function continue_member_list_page( $continue_action ) {
if ( 'settlement_zeus_card' === $continue_action ) {
$member_id = filter_input( INPUT_GET, 'member_id' );
$order_id = filter_input( INPUT_GET, 'order_id' );
if ( ! empty( $member_id ) && ! empty( $order_id ) ) {
$this->continue_member_settlement_info_page( $member_id, $order_id );
exit();
}
}
}
/**
* 継続課金会員決済詳細ページ
*
* @param int $member_id Member ID.
* @param int $order_id Order number.
*/
public function continue_member_settlement_info_page( $member_id, $order_id ) {
global $usces;
$order_data = $usces->get_order_data( $order_id, 'direct' );
if ( ! $order_data ) {
return;
}
$acting_flg = $this->get_acting_flg( $order_data['order_payment_name'] );
if ( 'acting_zeus_card' !== $acting_flg ) {
return;
}
$continue_data = $this->get_continuation_data( $member_id, $order_id );
if ( 'acting_zeus_card' !== $continue_data['acting'] ) {
return;
}
$con_id = $continue_data['con_id'];
$curent_url = $_SERVER['REQUEST_URI'];
$member_info = $usces->get_member_info( $member_id );
$name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
$contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
if ( ! empty( $contracted_date ) ) {
list( $contracted_year, $contracted_month, $contracted_day ) = explode( '-', $contracted_date );
} else {
$contracted_year = 0;
$contracted_month = 0;
$contracted_day = 0;
}
$charged_date = ( empty( $continue_data['chargedday'] ) ) ? dlseller_next_charging( $order_id ) : $continue_data['chargedday'];
if ( ! empty( $charged_date ) ) {
list( $charged_year, $charged_month, $charged_day ) = explode( '-', $charged_date );
} else {
$charged_year = 0;
$charged_month = 0;
$charged_day = 0;
}
$this_year = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 4 );
$log_data = $this->get_acting_log( $order_id, 0, 'ALL' );
$num = ( $log_data ) ? count( $log_data ) : 1;
?>
Welcart Management
Version
settlement_dialog( $order_data, $action_args );
include ABSPATH . 'wp-admin/admin-footer.php';
}
/**
* 自動継続課金処理
* dlseller_action_do_continuation_charging
*
* @param string $today Today.
* @param int $member_id Member ID.
* @param int $order_id Order number.
* @param array $continue_data Continuation data.
*/
public function auto_continuation_charging( $today, $member_id, $order_id, $continue_data ) {
global $usces;
if ( ! usces_is_membersystem_state() || 0 >= $continue_data['price'] || 'acting_zeus_card' !== $continue_data['acting'] ) {
return;
}
$order_data = $usces->get_order_data( $order_id, 'direct' );
if ( ! $order_data || $usces->is_status( 'cancel', $order_data['order_status'] ) ) {
return;
}
$acting_opts = $this->get_acting_settings();
if ( 'on' !== $acting_opts['quickcharge'] || 'on' !== $acting_opts['batch'] ) {
return;
}
$tracking_id = usces_acting_key();
$amount = usces_crform( $continue_data['price'], false, false, 'return', false );
$params = array();
$params['clientip'] = $acting_opts['clientip'];
$params['cardnumber'] = '9999999999999992';
$params['expyy'] = '00';
$params['expmm'] = '00';
$params['money'] = $amount;
$params['send'] = 'mall';
$params['telno'] = '0000000000';
$params['email'] = $this->get_email( $order_id );
$params['sendid'] = $member_id;
$params['sendpoint'] = $tracking_id;
$params['pubsec'] = 'yes';
$params['printord'] = 'yes';
$page = $this->secure_link_batch( $acting_opts['card_url'], $params );
if ( false !== strpos( $page, 'Success_order' ) ) {
$status = 'OK';
$data = array( 'result' => 'OK' );
$new_order_no = $this->get_order_number( $page );
if ( ! empty( $new_order_no ) ) {
$order_ref = wel_zeus_get_order_ref( $new_order_no );
if ( 'payment' === $order_ref['status'] || 'auth' === $order_ref['status'] ) {
$order_ref = apply_filters( 'usces_filter_zeus_card_auto_continuation_charging_log', $order_ref, $order_id, $tracking_id );
wel_zeus_save_acting_log( $order_ref, 'zeus_card', $order_ref['status'], $status, $order_id, $tracking_id );
$this->auto_settlement_mail( $member_id, $order_id, $data, $continue_data );
do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $order_ref );
} else {
if ( ! isset( $params['ordd'] ) ) {
$params['ordd'] = $new_order_no;
}
$params = apply_filters( 'usces_filter_zeus_card_auto_continuation_charging_log', $params, $order_id, $tracking_id );
wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
$this->auto_settlement_mail( $member_id, $order_id, $data, $continue_data );
$order_ref = wel_zeus_get_order_ref( $new_order_no );
do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $params );
}
} else {
$params = apply_filters( 'usces_filter_zeus_card_auto_continuation_charging_log', $params, $order_id, $tracking_id );
wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
$this->auto_settlement_mail( $member_id, $order_id, $data, $continue_data );
do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $params );
}
} else {
$status = $this->get_error_results( $page );
if ( empty( $status ) ) {
$status = 'ERROR';
}
$data = explode( "\r\n", $page );
$log = array(
'acting' => 'zeus_card',
'key' => $tracking_id,
'result' => $status,
'data' => $data,
);
usces_save_order_acting_error( $log );
wel_zeus_save_acting_log( $data, 'zeus_card', 'dlseller', $status, $order_id, $tracking_id );
$this->auto_settlement_error_mail( $member_id, $order_id, array( 'result' => $status ), $continue_data );
do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $data );
}
}
/**
* 自動継続課金処理メール(正常)
*
* @param int $member_id Member ID.
* @param int $order_id Order number.
* @param array $response_data Response data.
* @param array $continue_data Continuation data.
*/
public function auto_settlement_mail( $member_id, $order_id, $response_data, $continue_data ) {
global $usces;
$acting_opts = $this->get_acting_settings();
$order_data = $usces->get_order_data( $order_id, 'direct' );
$mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data, false );
if ( 'on' === $acting_opts['auto_settlement_mail'] ) {
$subject = apply_filters( 'usces_filter_zeus_auto_settlement_mail_subject', __( 'Announcement of automatic continuing charging process', 'usces' ), $member_id, $order_id, $order_data, $response_data, $continue_data );
$member_info = $usces->get_member_info( $member_id );
$name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
$mail_data = usces_mail_data();
$mail_header = '';
if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
$mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
}
$mail_header .= __( 'We will report automated accounting process was carried out as follows.', 'usces' ) . "\r\n\r\n";
$mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
$message = apply_filters( 'usces_filter_zeus_auto_settlement_mail_header', $mail_header, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
apply_filters( 'usces_filter_zeus_auto_settlement_mail_body', $mail_body, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
apply_filters( 'usces_filter_zeus_auto_settlement_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $response_data, $continue_data );
$headers = apply_filters( 'usces_filter_zeus_auto_settlement_mail_headers', '' );
$to_customer = array(
'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
'to_address' => $member_info['mem_email'],
'from_name' => get_option( 'blogname' ),
'from_address' => $usces->options['sender_mail'],
'reply_name' => get_option( 'blogname' ),
'reply_to' => usces_get_first_order_mail(),
'return_path' => $usces->options['sender_mail'],
'subject' => $subject,
'message' => do_shortcode( $message ),
'headers' => $headers,
);
usces_send_mail( $to_customer );
}
$ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
$this->continuation_charging_mail['OK'] = $ok + 1;
$this->continuation_charging_mail['mail'][] = $mail_body;
}
/**
* 自動継続課金処理メール(エラー)
*
* @param int $member_id Member ID.
* @param int $order_id Order number.
* @param array $response_data Response data.
* @param array $continue_data Continuation data.
*/
public function auto_settlement_error_mail( $member_id, $order_id, $response_data, $continue_data ) {
global $usces;
$acting_opts = $this->get_acting_settings();
$order_data = $usces->get_order_data( $order_id, 'direct' );
$mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data, false );
if ( 'on' === $acting_opts['auto_settlement_mail'] ) {
$subject = apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_subject', __( 'Announcement of automatic continuing charging process', 'usces' ), $member_id, $order_id, $order_data, $response_data, $continue_data );
$member_info = $usces->get_member_info( $member_id );
$name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
$mail_data = usces_mail_data();
$mail_header = '';
if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
$mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
}
$mail_header .= __( 'We will reported that an error occurred in automated accounting process.', 'usces' ) . "\r\n\r\n";
$mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
$message = apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_header', $mail_header, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_body', $mail_body, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $response_data, $continue_data );
$headers = apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_headers', '' );
$to_customer = array(
'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
'to_address' => $member_info['mem_email'],
'from_name' => get_option( 'blogname' ),
'from_address' => $usces->options['sender_mail'],
'reply_name' => get_option( 'blogname' ),
'reply_to' => usces_get_first_order_mail(),
'return_path' => $usces->options['sender_mail'],
'subject' => $subject,
'message' => do_shortcode( $message ),
'headers' => $headers,
);
usces_send_mail( $to_customer );
}
$error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
$this->continuation_charging_mail['NG'] = $error + 1;
$this->continuation_charging_mail['mail'][] = $mail_body;
}
/**
* 自動継続課金処理メール本文
*
* @param int $member_id Member ID.
* @param int $order_id Order number.
* @param array $order_data Order data.
* @param array $data Response data.
* @param array $continue_data Continuation data.
* @param boolean $html HTML mail.
* @return string
*/
public function auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data, $html = true ) {
global $usces;
$member_info = $usces->get_member_info( $member_id );
$name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
$contracted_date = ( isset( $continue_data['contractedday'] ) ) ? $continue_data['contractedday'] : '';
$charged_date = ( isset( $continue_data['chargedday'] ) ) ? $continue_data['chargedday'] : '';
$cart = usces_get_ordercartdata( $order_id );
if ( is_array( $cart ) && 0 < count( $cart ) ) {
$cart_row = current( $cart );
$item_name = $usces->getCartItemName_byOrder( $cart_row );
$options = ( isset( $cart_row['options'] ) ) ? $cart_row['options'] : array();
}
if ( usces_is_html_mail() && $html ) {
$message = '';
$message .= '| ';
$message .= __( 'Order ID', 'dlseller' );
$message .= ' | ';
$message .= $order_id;
$message .= ' |
';
$message .= '| ';
$message .= __( 'Application Date', 'dlseller' );
$message .= ' | ';
$message .= $order_data['order_date'];
$message .= ' |
';
$message .= '| ';
$message .= __( 'Member ID', 'dlseller' );
$message .= ' | ';
$message .= $member_id;
$message .= ' |
';
$message .= '| ';
$message .= __( 'Contractor name', 'dlseller' );
$message .= ' | ';
$message .= sprintf( _x( '%s', 'honorific', 'usces' ), $name );
$message .= ' |
';
$message .= '| ';
$message .= __( 'Items', 'usces' );
$message .= ' | ';
$message .= $item_name;
if ( is_array( $options ) && 0 < count( $options ) ) {
$optstr = '';
foreach ( $options as $key => $value ) {
if ( ! empty( $key ) ) {
$key = urldecode( $key );
$value = maybe_unserialize( $value );
if ( is_array( $value ) ) {
$c = '';
$optstr .= '( ' . $key . ' : ';
foreach ( $value as $v ) {
$optstr .= $c . rawurldecode( $v );
$c = ', ';
}
$optstr .= ' ) ';
} else {
$optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . ' ) ';
}
}
}
$message .= $optstr;
}
$message .= ' |
';
$message .= '| ';
$message .= __( 'Settlement amount', 'usces' );
$message .= ' | ';
$message .= usces_crform( $continue_data['price'], true, false, 'return' );
$message .= ' |
';
if ( isset( $data['reminder'] ) ) {
if ( ! empty( $charged_date ) ) {
$message .= '| ';
$message .= __( 'Next Withdrawal Date', 'dlseller' );
$message .= ' | ';
$message .= $charged_date;
$message .= ' |
';
}
if ( ! empty( $contracted_date ) ) {
$message .= '| ';
$message .= __( 'Renewal Date', 'dlseller' );
$message .= ' | ';
$message .= $contracted_date;
$message .= ' |
';
}
} else {
if ( ! empty( $charged_date ) ) {
$message .= '| ';
$message .= __( 'Next Withdrawal Date', 'dlseller' );
$message .= ' | ';
$message .= $charged_date;
$message .= ' |
';
}
if ( ! empty( $contracted_date ) ) {
$message .= '| ';
$message .= __( 'Renewal Date', 'dlseller' );
$message .= ' | ';
$message .= $contracted_date;
$message .= ' |
';
}
if ( isset( $data['result'] ) && in_array( $data['result'], $this->payment_normal_results, true ) ) {
$message .= '| ';
$message .= __( 'Result', 'usces' );
$message .= ' | ';
$message .= __( 'Normal done', 'usces' );
$message .= ' |
';
} else {
$message .= '| ';
$message .= __( 'Result', 'usces' );
$message .= ' | ';
$message .= __( 'Error', 'usces' );
$message .= ' |
';
}
}
$message .= '
';
} else {
$message = usces_mail_line( 2 ); // --------------------
$message .= __( 'Order ID', 'dlseller' ) . ' : ' . $order_id . "\r\n";
$message .= __( 'Application Date', 'dlseller' ) . ' : ' . $order_data['order_date'] . "\r\n";
$message .= __( 'Member ID', 'dlseller' ) . ' : ' . $member_id . "\r\n";
$message .= __( 'Contractor name', 'dlseller' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
$message .= __( 'Items', 'usces' ) . ' : ' . $item_name . "\r\n";
if ( is_array( $options ) && 0 < count( $options ) ) {
$optstr = '';
foreach ( $options as $key => $value ) {
if ( ! empty( $key ) ) {
$key = urldecode( $key );
$value = maybe_unserialize( $value );
if ( is_array( $value ) ) {
$c = '';
$optstr .= '( ' . $key . ' : ';
foreach ( $value as $v ) {
$optstr .= $c . rawurldecode( $v );
$c = ', ';
}
$optstr .= " )\r\n";
} else {
$optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . " )\r\n";
}
}
}
$message .= $optstr;
}
$message .= __( 'Settlement amount', 'usces' ) . ' : ' . usces_crform( $continue_data['price'], true, false, 'return' ) . "\r\n";
if ( ! empty( $charged_date ) ) {
$message .= __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . $charged_date . "\r\n";
}
if ( ! empty( $contracted_date ) ) {
$message .= __( 'Renewal Date', 'dlseller' ) . ' : ' . $contracted_date . "\r\n";
}
if ( isset( $data['reminder'] ) ) {
} else {
$message .= "\r\n";
if ( isset( $data['result'] ) && in_array( $data['result'], $this->payment_normal_results, true ) ) {
$message .= __( 'Result', 'usces' ) . ' : ' . __( 'Normal done', 'usces' ) . "\r\n";
} else {
$message .= __( 'Result', 'usces' ) . ' : ' . __( 'Error', 'usces' ) . "\r\n";
}
}
$message .= usces_mail_line( 2 ) . "\r\n"; // --------------------
}
return $message;
}
/**
* 自動継続課金処理
* dlseller_action_do_continuation
*
* @param string $today Today.
* @param array $todays_charging Charged data.
*/
public function do_auto_continuation( $today, $todays_charging ) {
global $usces;
if ( empty( $todays_charging ) ) {
return;
}
$ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
$error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
$admin_subject = apply_filters( 'usces_filter_zeus_autobilling_email_admin_subject', __( 'Automatic Continuing Charging Process Result', 'usces' ) . ' ' . $today, $today );
$admin_footer = apply_filters( 'usces_filter_zeus_autobilling_email_admin_mail_footer', __( 'For details, please check on the administration panel > Continuous charge member list > Continuous charge member information.', 'usces' ) );
$admin_message = __( 'Report that automated accounting process has been completed.', 'usces' ) . "\r\n\r\n"
. __( 'Processing date', 'usces' ) . ' : ' . wp_date( 'Y-m-d H:i:s' ) . "\r\n"
. __( 'Normal done', 'usces' ) . ' : ' . $ok . "\r\n"
. __( 'Abnormal done', 'usces' ) . ' : ' . $error . "\r\n\r\n";
foreach ( (array) $this->continuation_charging_mail['mail'] as $mail ) {
$admin_message .= $mail . "\r\n";
}
$admin_message .= $admin_footer . "\r\n";
$to_admin = array(
'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
'to_address' => $usces->options['order_mail'],
'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
'from_address' => $usces->options['sender_mail'],
'reply_name' => get_option( 'blogname' ),
'reply_to' => usces_get_first_order_mail(),
'return_path' => $usces->options['sender_mail'],
'subject' => $admin_subject,
'message' => do_shortcode( $admin_message ),
);
usces_send_mail( $to_admin );
unset( $this->continuation_charging_mail );
}
/**
* 課金日通知メール
* dlseller_filter_reminder_mail_body
*
* @param string $mail_body Message body.
* @param int $order_id Order number.
* @param array $continue_data Continuation data.
* @return string
*/
public function reminder_mail_body( $mail_body, $order_id, $continue_data ) {
global $usces;
$member_id = $continue_data['member_id'];
$order_id = $continue_data['order_id'];
$order_data = $usces->get_order_data( $order_id, 'direct' );
$data = array( 'reminder' => 'reminder' );
$mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data );
return $mail_body;
}
/**
* 契約更新日通知メール
* dlseller_filter_contract_renewal_mail_body
*
* @param string $mail_body Message body.
* @param int $order_id Order number.
* @param array $continue_data Continuation data.
* @return string
*/
public function contract_renewal_mail_body( $mail_body, $order_id, $continue_data ) {
global $usces;
$member_id = $continue_data['member_id'];
$order_data = $usces->get_order_data( $order_id, 'direct' );
$data = array( 'reminder' => 'contract_renewal' );
$mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data );
return $mail_body;
}
/**
* 継続課金会員データ取得
*
* @param int $member_id Member ID.
* @param int $order_id Order number.
* @return array
*/
private function get_continuation_data( $member_id, $order_id ) {
global $wpdb;
$query = $wpdb->prepare(
"SELECT
`con_id` AS `con_id`,
`con_acting` AS `acting`,
`con_order_price` AS `order_price`,
`con_price` AS `price`,
`con_next_charging` AS `chargedday`,
`con_next_contracting` AS `contractedday`,
`con_startdate` AS `startdate`,
`con_status` AS `status`
FROM {$wpdb->prefix}usces_continuation
WHERE `con_order_id` = %d AND `con_member_id` = %d",
$order_id,
$member_id
);
$data = $wpdb->get_row( $query, ARRAY_A );
return $data;
}
/**
* 継続課金会員データ更新
*
* @param int $member_id Member ID.
* @param int $order_id Order number.
* @param array $data Continuation data.
* @param boolean $stop Stop continuous billing.
* @return boolean
*/
private function update_continuation_data( $member_id, $order_id, $data, $stop = false ) {
global $wpdb;
if ( $stop ) {
$query = $wpdb->prepare(
"UPDATE {$wpdb->prefix}usces_continuation SET
`con_status` = 'cancellation'
WHERE `con_order_id` = %d AND `con_member_id` = %d",
$order_id,
$member_id
);
} else {
$query = $wpdb->prepare(
"UPDATE {$wpdb->prefix}usces_continuation SET
`con_price` = %f,
`con_next_charging` = %s,
`con_next_contracting` = %s,
`con_status` = %s
WHERE `con_order_id` = %d AND `con_member_id` = %d",
$data['price'],
$data['chargedday'],
$data['contractedday'],
$data['status'],
$order_id,
$member_id
);
}
$res = $wpdb->query( $query );
return $res;
}
/**
* 決済オプション取得
*
* @return array
*/
public function get_acting_settings() {
global $usces;
$acting_settings = ( isset( $usces->options['acting_settings'][ $this->paymod_id ] ) ) ? $usces->options['acting_settings'][ $this->paymod_id ] : array();
return apply_filters( 'usces_filter_get_acting_settings_zeus', $acting_settings );
}
/**
* Secure API
* 3D Secure Enrol.
*/
public function zeus_3dsecure_enrol() {
global $usces;
check_ajax_referer( 'acting_zeus_card', '_nonce' );
$entry = $usces->cart->get_entry();
if ( empty( $entry ) ) {
$result_data = array(
'action' => 'session',
'status' => 'error',
);
wp_send_json( $result_data );
}
$usces->error_message = $usces->zaiko_check();
if ( '' !== $usces->error_message || 0 === (int) $usces->cart->num_row() ) {
$result_data = array(
'action' => 'stock',
'status' => 'error',
);
wp_send_json( $result_data );
}
$acting_opts = $this->get_acting_settings();
$result_data = array();
if ( $this->is_activate_card( 'api' ) && 1 === (int) $acting_opts['3dsecur'] ) {
$sendid = ( 'on' === $acting_opts['quickcharge'] && isset( $_POST['sendid'] ) ) ? filter_input( INPUT_POST, 'sendid' ) : '';
$sendpoint = filter_input( INPUT_POST, 'sendpoint', FILTER_DEFAULT, array( 'options' => array( 'default' => '' ) ) );
$_nonce = filter_input( INPUT_POST, '_nonce', FILTER_DEFAULT, array( 'options' => array( 'default' => wp_create_nonce( 'acting_zeus_card' ) ) ) );
$uscesid = filter_input( INPUT_GET, 'uscesid', FILTER_DEFAULT, array( 'options' => array( 'default' => $usces->get_uscesid( false ) ) ) );
$data = array();
$data['authentication']['clientip'] = $acting_opts['clientip'];
$data['authentication']['key'] = $acting_opts['authkey'];
if ( 'on' === $acting_opts['quickcharge'] && isset( $_POST['card_option'] ) && 'prev' === filter_input( INPUT_POST, 'card_option' ) && ! empty( $sendid ) ) {
$data['card']['history']['key'] = 'sendid';
$data['card']['history']['action'] = 'send_email';
} elseif ( isset( $_POST['token_key'] ) ) {
$data['token_key'] = filter_input( INPUT_POST, 'token_key' );
}
$data['payment']['amount'] = apply_filters( 'zeus_secure_payreq_amount', usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ), $entry );
if ( isset( $entry['order']['cbrand'] ) && isset( $entry['order']['howpay'] ) && WCUtils::is_zero( $entry['order']['howpay'] ) ) {
$div_name = 'div_' . $entry['order']['cbrand'];
$data['payment']['count'] = $entry['order'][ $div_name ];
} else {
$data['payment']['count'] = '01';
}
$data['user']['telno'] = str_replace( '-', '', $entry['customer']['tel'] );
$data['user']['email'] = $entry['customer']['mailaddress1'];
$data['uniq_key']['sendid'] = $sendid;
$data['uniq_key']['sendpoint'] = $sendpoint;
$data['use_3ds2_flag'] = '1';
// リスクベース認証用追加パラメータ.
$data['cardHolderInfo']['cardholderName'] = filter_input( INPUT_POST, 'card_name' );
$data['cardHolderInfo']['email'] = $entry['customer']['mailaddress1'];
$enrol_req = '';
$enrol_req .= '';
$enrol_req .= $this->assoc2xml( $data );
$enrol_req .= '';
$xml = $this->get_xml( $acting_opts['card_secureurl'], $enrol_req );
if ( empty( $xml ) ) {
$log = array(
'acting' => 'zeus_card_API(3D Enrol)',
'key' => $sendpoint,
'result' => 'EnrolRes Error',
'data' => $enrol_req,
);
usces_save_order_acting_error( $log );
$result_data = array(
'action' => 'EnrolReq',
'status' => 'error',
);
} else {
$enrol_res = $this->xml2assoc( $xml );
if ( 'outside' === $enrol_res['response']['result']['status'] ) {
usces_ordered_acting_data( $sendpoint, 'propriety' );
$result_data = array(
'action' => 'EnrolReq',
'status' => $enrol_res['response']['result']['status'],
'xid' => $enrol_res['response']['xid'],
'code' => $enrol_res['response']['result']['code'],
);
} elseif ( 'success' === $enrol_res['response']['result']['status'] ) {
usces_ordered_acting_data( $sendpoint, 'propriety' );
$term_data = array(
'purchase' => '1',
'sendpoint' => $sendpoint,
'_nonce' => $_nonce,
'uscesid' => $uscesid,
);
$term_url = add_query_arg( $term_data, USCES_CART_URL );
$result_data = array(
'action' => 'EnrolReq',
'status' => $enrol_res['response']['result']['status'],
'MD' => $enrol_res['response']['xid'],
'PaReq' => $enrol_res['response']['redirection']['PaReq'],
'TermUrl' => $term_url,
'threeDSMehtod' => '2',
'iframeUrl' => $enrol_res['response']['iframeUrl'],
);
} else {
$log = array(
'acting' => 'zeus_card_API(3D Enrol)',
'key' => $sendpoint,
'result' => $enrol_res['response']['result']['status'] . ':' . $enrol_res['response']['result']['code'],
'data' => $enrol_res,
);
usces_save_order_acting_error( $log );
$result_data = array(
'action' => 'EnrolReq',
'status' => $enrol_res['response']['result']['status'],
'code' => $enrol_res['response']['result']['code'],
);
}
}
}
wp_send_json( $result_data );
}
/**
* Secure API
* 3D Secure Authentication.
* usces_zeus_3dsecure_auth
* ( call from acting_processing )
*/
public function zeus_3dsecure_auth() {
global $usces;
$acting_opts = $this->get_acting_settings();
$sendpoint = filter_input( INPUT_GET, 'sendpoint', FILTER_DEFAULT, array( 'options' => array( 'default' => '' ) ) );
$_nonce = filter_input( INPUT_GET, '_nonce', FILTER_DEFAULT, array( 'options' => array( 'default' => wp_create_nonce( 'acting_zeus_card' ) ) ) );
$request_body = file_get_contents( 'php://input' );
$body = json_decode( $request_body, true );
if ( ! empty( $body['MD'] ) && ! empty( $body['PaRes'] ) && ! empty( $body['status'] ) ) {
if ( 'failure' === $body['status'] || 'invalid' === $body['status'] || 'maintenance' === $body['status'] ) {
$log = array(
'acting' => 'zeus_card_API(3D Auth)',
'key' => $sendpoint,
'result' => 'PaRes Error',
'data' => $body,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => '0',
'status' => $body['status'],
),
USCES_CART_URL
)
);
exit();
}
$data = array();
$data['xid'] = $body['MD'];
$data['PaRes'] = $body['PaRes'];
$auth_req = '';
$auth_req .= '';
$auth_req .= $this->assoc2xml( $data );
$auth_req .= '';
$xml = $this->get_xml( $acting_opts['card_secureurl'], $auth_req );
if ( false !== strpos( $xml, 'Invalid' ) ) {
$log = array(
'acting' => 'zeus_card_API(3D Auth)',
'key' => $sendpoint,
'result' => 'AuthReq Error',
'data' => $auth_req,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => '0',
'status' => 'error',
),
USCES_CART_URL
)
);
exit();
}
$auth_res = $this->xml2assoc( $xml );
if ( 'success' !== $auth_res['response']['result']['status'] ) {
$log = array(
'acting' => 'zeus_card_API(3D Auth)',
'key' => $sendpoint,
'result' => $auth_res['response']['result']['status'] . ':' . $auth_res['response']['result']['code'],
'data' => $auth_res,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => '0',
'status' => $auth_res['response']['result']['status'],
'code' => $auth_res['response']['result']['code'],
),
USCES_CART_URL
)
);
exit();
}
$data = array();
$data['xid'] = $body['MD'];
$pay_req = '';
$pay_req .= '';
$pay_req .= $this->assoc2xml( $data );
$pay_req .= '';
$xml = $this->get_xml( $acting_opts['card_secureurl'], $pay_req );
if ( empty( $xml ) ) {
$log = array(
'acting' => 'zeus_card_API(3D Auth)',
'key' => $sendpoint,
'result' => 'PayReq Error',
'data' => $pay_req,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => '0',
'status' => 'error',
),
USCES_CART_URL
)
);
exit();
}
$pay_res = $this->xml2assoc( $xml );
if ( 'success' === $pay_res['response']['result']['status'] ) {
$result_data = array(
'acting' => 'zeus_card',
'acting_return' => '1',
'zeussuffix' => $pay_res['response']['card']['number']['suffix'],
'zeusordd' => $pay_res['response']['order_number'],
'wctid' => $sendpoint,
'auth_code' => $auth_res['response']['result']['code'],
);
$res = $usces->order_processing( $result_data );
if ( 'ordercompletion' === $res ) {
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => 1,
'result' => 1,
'_nonce' => $_nonce,
'uscesid' => $usces->get_uscesid( false ),
),
USCES_CART_URL
)
);
exit();
} else {
$log = array(
'acting' => 'zeus_card',
'key' => $sendpoint,
'result' => 'ORDER DATA REGISTERED ERROR',
'data' => $result_data,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => 0,
'result' => 0,
),
USCES_CART_URL
)
);
exit();
}
} else {
$log = array(
'acting' => 'zeus_card_API(3D Auth)',
'key' => $sendpoint,
'result' => $pay_res['response']['result']['status'] . ':' . $pay_res['response']['result']['code'],
'data' => $pay_res,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => '0',
'status' => $pay_res['response']['result']['status'],
'code' => $pay_res['response']['result']['code'],
),
USCES_CART_URL
)
);
exit();
}
}
exit();
}
/**
* Secure API
* Payment Request. (3D Secure Not used.)
* usces_zeus_secure_payreq
* ( call from acting_processing )
*/
protected function zeus_secure_payreq() {
global $usces;
$acting_opts = $this->get_acting_settings();
$sendid = ( 'on' == $acting_opts['quickcharge'] && isset( $_POST['sendid'] ) ) ? filter_input( INPUT_POST, 'sendid' ) : '';
$sendpoint = ( isset( $_POST['sendpoint'] ) ) ? filter_input( INPUT_POST, 'sendpoint' ) : '';
$outside = ( isset( $_POST['outside'] ) ) ? filter_input( INPUT_POST, 'outside' ) : '';
$data = array();
$data['authentication']['clientip'] = $acting_opts['clientip'];
$data['authentication']['key'] = $acting_opts['authkey'];
if ( 'on' === $acting_opts['quickcharge'] && isset( $_POST['card_option'] ) && 'prev' === filter_input( INPUT_POST, 'card_option' ) && ! empty( $sendid ) ) {
$data['card']['history']['key'] = 'sendid';
$data['card']['history']['action'] = 'send_email';
} elseif ( isset( $_POST['token_key'] ) ) {
$data['token_key'] = filter_input( INPUT_POST, 'token_key' );
}
$data['payment']['amount'] = apply_filters( 'zeus_secure_payreq_amount', filter_input( INPUT_POST, 'money' ), $entry );
if ( isset( $_POST['howpay'] ) && WCUtils::is_zero( filter_input( INPUT_POST, 'howpay' ) ) ) {
$data['payment']['count'] = filter_input( INPUT_POST, 'div' );
} else {
$data['payment']['count'] = '01';
}
$data['user']['telno'] = str_replace( '-', '', filter_input( INPUT_POST, 'telno' ) );
$data['user']['email'] = filter_input( INPUT_POST, 'email' );
$data['uniq_key']['sendid'] = $sendid;
$data['uniq_key']['sendpoint'] = $sendpoint;
$pay_req = '';
$pay_req .= '';
$pay_req .= $this->assoc2xml( $data );
$pay_req .= '';
$xml = $this->get_xml( $acting_opts['card_secureurl'], $pay_req );
if ( empty( $xml ) ) {
$log = array(
'acting' => 'zeus_card_API',
'key' => $sendpoint,
'result' => 'PayReq Error',
'data' => $pay_req,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => '0',
'status' => 'error',
),
USCES_CART_URL
)
);
exit();
}
usces_ordered_acting_data( $sendpoint, 'propriety' );
$pay_res = $this->xml2assoc( $xml );
if ( 'success' === $pay_res['response']['result']['status'] ) {
$result_data = array(
'acting' => 'zeus_card',
'zeussuffix' => $pay_res['response']['card']['number']['suffix'],
'zeusordd' => $pay_res['response']['order_number'],
'wctid' => $sendpoint,
);
if ( ! empty( $outside ) ) {
$result_data['auth_code'] = $outside;
}
$res = $usces->order_processing( $result_data );
if ( 'ordercompletion' === $res ) {
$_nonce = ( isset( $_POST['_nonce'] ) ) ? filter_input( INPUT_POST, '_nonce' ) : wp_create_nonce( 'acting_zeus_card' );
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => 1,
'result' => 1,
'_nonce' => $_nonce,
),
USCES_CART_URL
)
);
} else {
$log = array(
'acting' => 'zeus_card',
'key' => $sendpoint,
'result' => 'ORDER DATA REGISTERED ERROR',
'data' => $result_data,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => 0,
'result' => 0,
),
USCES_CART_URL
)
);
}
exit();
} else {
$log = array(
'acting' => 'zeus_card_API',
'key' => $sendpoint,
'result' => $pay_res['response']['result']['status'] . ':' . $pay_res['response']['result']['code'],
'data' => $pay_res,
);
usces_save_order_acting_error( $log );
wp_redirect(
add_query_arg(
array(
'acting' => 'zeus_card',
'acting_return' => '0',
'status' => $pay_res['response']['result']['status'],
'code' => $pay_res['response']['result']['code'],
),
USCES_CART_URL
)
);
exit();
}
}
/**
* XML to Association.
* usces_xml2assoc
*
* @param string $xml XML data.
* @return array
*/
public function xml2assoc( $xml ) {
$arr = array();
if ( ! preg_match_all( '|\<\s*?(\w+).*?\>(.*)\<\/\s*\\1.*?\>|s', $xml, $m ) ) {
return $xml;
}
if ( is_array( $m[1] ) ) {
for ( $i = 0; $i < sizeof( $m[1] ); $i++ ) {
$arr[ $m[1][ $i ] ] = $this->xml2assoc( $m[2][ $i ] );
}
} else {
$arr[ $m[1] ] = $this->xml2assoc( $m[2] );
}
return $arr;
}
/**
* Association to XML.
* usces_assoc2xml
*
* @param array $prm_array Parameters.
* @return string
*/
protected function assoc2xml( $prm_array ) {
$xml = '';
if ( is_array( $prm_array ) ) {
$i = 0;
foreach ( $prm_array as $index => $element ) {
if ( is_array( $element ) ) {
$acts = explode( '_', $index, 3 );
if ( is_array( $acts ) && 2 < count( $acts ) && 'history' === $acts[0] && 'action' === $acts[1] ) {
$xml .= '';
$xml .= $this->assoc2xml( $element );
$xml .= '';
} else {
$xml .= '<' . $index . '>';
$xml .= $this->assoc2xml( $element );
$xml .= '' . $index . '>';
}
} else {
$xml .= '<' . $index . '>' . $element . '' . $index . '>';
}
$i++;
if ( $i > 500 ) {
break;
}
}
}
return $xml;
}
/**
* Get XML Response.
* usces_get_xml
*
* @param string $url Connect url.
* @param string $params Sending parameters.
* @return string
*/
protected function get_xml( $url, $params ) {
$interface = $this->get_interface( $url );
$header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
$header .= 'Host: ' . $interface['host'] . "\r\n";
$header .= "User-Agent: PHP Script\r\n";
$header .= "Content-Type: text/xml\r\n";
$header .= 'Content-Length: ' . strlen( $params ) . "\r\n";
$header .= "Connection: close\r\n\r\n";
$header .= $params;
$fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
if ( ! $fp ) {
usces_log( 'zeus API : TLS(v1.2) Error', 'acting_transaction.log' );
}
$xml = '';
if ( $fp ) {
fwrite( $fp, $header );
while ( ! feof( $fp ) ) {
$xml .= fgets( $fp, 1024 );
}
fclose( $fp );
}
return $xml;
}
/**
* Get XML Response.
*
* @param string $url Connect url.
* @param string $params Sending parameters.
* @return string
*/
protected function get_xml_bnpl( $url, $params ) {
$args = array(
'method' => 'POST',
'headers' => array(
'Content-Type' => 'application/xml; charset=UTF-8',
'Accept' => 'application/xml; charset=UTF-8',
),
'body' => $params,
);
$xml = '';
$response = wp_remote_post( $url, $args );
if ( ! is_wp_error( $response ) ) {
$xml = wp_remote_retrieve_body( $response );
}
return $xml;
}
/**
* Secure Link Batch.
*
* @param string $url Connect url.
* @param array $params Sending parameters.
* @return string
*/
protected function secure_link_batch( $url, $params ) {
$page = '';
$interface = $this->get_interface( $url );
$vars = http_build_query( $params );
$header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
$header .= 'Host: ' . $interface['host'] . "\r\n";
$header .= "User-Agent: PHP Script\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
$header .= "Connection: close\r\n\r\n";
$header .= $vars;
$fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
if ( $fp ) {
fwrite( $fp, $header );
while ( ! feof( $fp ) ) {
$scr = fgets( $fp, 1024 );
$page .= $scr;
}
fclose( $fp );
}
return $page;
}
/**
* Get clientip.
*
* @param string $acting Acting type.
* @return string
*/
protected function get_clientip( $acting ) {
$client_ip = '';
$acting_opts = $this->get_acting_settings();
switch ( $acting ) {
case 'zeus_card':
$client_ip = $acting_opts['clientip'];
break;
case 'zeus_conv':
$client_ip = $acting_opts['clientip_conv'];
break;
case 'zeus_bank':
$client_ip = $acting_opts['clientip_bank'];
break;
}
return $client_ip;
}
/**
* Get order_number.
*
* @param string $page Post data.
* @return string
*/
protected function get_order_number( $page ) {
if ( empty( $page ) ) {
return '';
}
$log = explode( "\r\n", $page );
$ordd = '';
foreach ( (array) $log as $line ) {
if ( false !== strpos( $line, 'ordd' ) ) {
list( $status, $ordd ) = explode( '=', $line );
}
}
if ( empty( $ordd ) ) {
foreach ( (array) $log as $idx => $line ) {
if ( false !== strpos( $line, 'Success_order' ) ) {
list( $status, $ordd ) = explode( "\n", $line );
break;
}
}
}
return $ordd;
}
/**
* Get err_code.
*
* @param string $page Post data.
* @return string
*/
protected function get_err_code( $page ) {
if ( empty( $page ) ) {
return '';
}
$log = explode( "\r\n", $page );
$err_code = '';
foreach ( (array) $log as $line ) {
if ( false !== strpos( $line, 'err_code' ) ) {
list( $name, $err_code ) = explode( '=', $line );
}
}
return $err_code;
}
/**
* Get err_code.
*
* @param string $page Post data.
* @return string
*/
protected function get_error_results( $page ) {
$error_results = '';
if ( ! empty( $page ) ) {
$log = explode( "\r\n", $page );
foreach ( (array) $log as $line ) {
foreach ( $this->payment_error_results as $error ) {
if ( false !== strpos( $line, $error ) ) {
$error_results = $line;
break;
}
}
if ( ! empty( $error_results ) ) {
break;
}
}
}
return $error_results;
}
/**
* Get order_id by meta_data ( conv, bank )
*
* @param int $key Order number.
* @return string
*/
protected function get_order_id( $key ) {
global $wpdb;
$query = $wpdb->prepare( "SELECT `order_id` FROM {$wpdb->prefix}usces_order_meta WHERE `meta_key` = %s", 'acting_' . $key );
$order_id = $wpdb->get_var( $query );
return $order_id;
}
/**
* Get order_meta_data ( conv, bank )
*
* @param int $order_id Order number.
* @return array
*/
protected function get_order_meta_acting( $order_id ) {
global $wpdb;
$query = $wpdb->prepare( "SELECT `meta_value` FROM {$wpdb->prefix}usces_order_meta WHERE `order_id` = %d AND `meta_key` LIKE %s", $order_id, 'acting_%' );
$meta_value = $wpdb->get_var( $query );
$acting_data = usces_unserialize( $meta_value );
return $acting_data;
}
/**
* Tracking ID 取得
*
* @param int $order_id Order number.
* @return string
*/
protected function get_tracking_id( $order_id ) {
global $usces;
$tracking_id = $usces->get_order_meta_value( 'tracking_id', $order_id );
return $tracking_id;
}
/**
* 受注ステータス取得
*
* @param int $order_id Order number.
* @return string
*/
protected function get_order_status( $order_id ) {
global $wpdb;
$query = $wpdb->prepare( "SELECT LOCATE( 'receipted', `order_status` ) FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
$order_status = $wpdb->get_var( $query );
return $order_status;
}
/**
* 受注データ支払方法取得
*
* @param int $order_id Order number.
* @return string
*/
protected function get_order_payment_name( $order_id ) {
global $wpdb;
$query = $wpdb->prepare( "SELECT `order_payment_name` FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
$order_payment_name = $wpdb->get_var( $query );
return $order_payment_name;
}
/**
* 決済ログ取得
*
* @param int $order_id Order number.
* @param string $tracking_id Tracking ID.
* @param string $result Result.
* @return array
*/
public function get_acting_log( $order_id = 0, $tracking_id = 0, $result = 'OK' ) {
global $wpdb;
if ( empty( $order_id ) ) {
if ( 'OK' === $result ) {
$query = $wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `tracking_id` = %s AND `result` IN( %s ) ORDER BY `ID` DESC, `datetime` DESC",
$tracking_id,
implode( "','", $this->payment_normal_results )
);
$query = stripslashes( $query );
} else {
$query = $wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `tracking_id` = %s ORDER BY `ID` DESC, `datetime` DESC",
$tracking_id
);
}
} else {
if ( empty( $tracking_id ) ) {
if ( 'OK' === $result ) {
$query = $wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `datetime` IN( SELECT MAX( `datetime` ) FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d GROUP BY `tracking_id` ) AND `order_id` = %d AND `result` IN( %s ) ORDER BY `ID` DESC, `datetime` DESC",
$order_id,
$order_id,
implode( "','", $this->payment_normal_results )
);
$query = stripslashes( $query );
} else {
$query = $wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `datetime` IN( SELECT MAX( `datetime` ) FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d GROUP BY `tracking_id` ) AND `order_id` = %d ORDER BY `ID` DESC, `datetime` DESC",
$order_id,
$order_id
);
}
} else {
if ( 'OK' === $result ) {
$query = $wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d AND `tracking_id` = %s AND `result` IN( %s ) ORDER BY `ID` DESC, `datetime` DESC",
$order_id,
$tracking_id,
implode( "','", $this->payment_normal_results )
);
$query = stripslashes( $query );
} else {
$query = $wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d AND `tracking_id` = %s ORDER BY `ID` DESC, `datetime` DESC",
$order_id,
$tracking_id
);
}
}
}
$log_data = $wpdb->get_results( $query, ARRAY_A );
return $log_data;
}
/**
* 最新処理取得
*
* @param int $order_id Order number.
* @param string $tracking_id Tracking ID.
* @param string $result Result.
* @return array
*/
public function get_acting_latest_log( $order_id, $tracking_id, $result = 'OK' ) {
$latest_log = array();
$log_data = $this->get_acting_log( $order_id, $tracking_id, $result );
if ( $log_data ) {
$data = current( $log_data );
$log = usces_unserialize( $data['log'] );
$order_no = $this->get_order_no( $log );
$latest_log['acting'] = $data['acting'];
$latest_log['status'] = $data['status'];
$latest_log['result'] = $data['result'];
$latest_log['log'] = $log;
$latest_log['amount'] = (int) $data['amount'];
$latest_log['order_id'] = $data['order_id'];
$latest_log['order_no'] = $order_no;
$latest_log['tracking_id'] = $data['tracking_id'];
}
return $latest_log;
}
/**
* 決済処理取得
*
* @param int $order_id Order number.
* @param string $tracking_id Tracking ID.
* @param string $result Result.
* @return string
*/
private function get_acting_status( $order_id, $tracking_id, $result = 'OK' ) {
$acting_status = '';
$log_data = $this->get_acting_log( $order_id, $tracking_id, $result );
if ( $log_data ) {
foreach ( (array) $log_data as $data ) {
if ( 'change' === $data['status'] ) {
continue;
}
if ( 'TEST' === $data['status'] || 'test' === $data['status'] ) {
$acting_status = 'test';
} elseif ( 'cancel' === $data['status'] || 'sale' === $data['status'] || 'auth' === $data['status'] ) {
$acting_status = $data['status'];
} elseif ( 'autodelivery' === $data['status'] || 'dlseller' === $data['status'] ) {
$acting_status = 'error';
} elseif ( '仮売完了' === $data['result'] ) {
$acting_status = 'auth';
} elseif ( '決済完了' === $data['result'] || 'payment' === $data['status'] ) {
$acting_status = 'payment';
} elseif ( 'transaction' === $data['status'] || 'shippingrequest' === $data['status'] || 'canceltransaction' === $data['status'] ) {
$acting_status = $data['status'] . $data['result'];
}
if ( '' !== $acting_status ) {
break;
}
}
}
return $acting_status;
}
/**
* 処理区分名称取得
*
* @param string $payment_status Payment status code.
* @param string $payment_result Payment result.
* @return string
*/
private function get_status_name( $payment_status, $payment_result = '' ) {
$status_name = '';
switch ( $payment_status ) {
case 'TEST':
case 'test':
$status_name = 'テスト決済';
break;
case 'payment':
$status_name = '決済完了';
break;
case 'auth':
$status_name = '仮売完了';
break;
case 'sale':
$status_name = '決済完了';
break;
case 'cancel':
$status_name = '取り消し';
break;
case 'change':
$status_name = '金額変更';
break;
case 'error':
$status_name = 'エラー';
break;
case 'dlseller':
$status_name = '継続課金決済エラー';
break;
case 'autodelivery':
$status_name = '定期購入決済エラー';
break;
case 'transaction':
$status_name = '取引登録';
break;
case 'transactionOK':
$status_name = '取引登録完了';
break;
case 'transactionNG':
$status_name = '取引登録エラー';
break;
case 'shippingrequest':
$status_name = '出荷登録';
break;
case 'shippingrequestOK':
$status_name = '出荷登録完了';
break;
case 'shippingrequestNG':
$status_name = '出荷登録エラー';
break;
case 'canceltransaction':
$status_name = '取引キャンセル';
break;
case 'canceltransactionOK':
$status_name = '取引取消完了';
break;
case 'canceltransactionNG':
$status_name = '取引取消エラー';
break;
default:
if ( in_array( $payment_result, $this->payment_normal_results, true ) ) {
if ( 'OK' === $payment_result || 'Success_order' === $payment_result || 'SuccessOK' === $payment_result ) {
$status_name = '決済完了';
} else {
$status_name = $payment_result;
}
} else {
$status_name = ( ! empty( $payment_result ) ) ? $payment_result : '決済完了';
}
$status_name = $payment_status;
}
return $status_name;
}
/**
* オーダーNo 取得
*
* @param array $log Log data.
* @return string
*/
private function get_order_no( $log ) {
$order_no = ( isset( $log['ordd'] ) ) ? $log['ordd'] : '';
if ( empty( $order_no ) && isset( $log['zeusordd'] ) ) {
$order_no = $log['zeusordd'];
}
if ( empty( $order_no ) && isset( $log['ordd'] ) ) {
$order_no = $log['ordd'];
}
if ( empty( $order_no ) && isset( $log['order_no'] ) ) {
$order_no = $log['order_no'];
}
if ( empty( $order_no ) && isset( $log['ORDER_NO'] ) ) {
$order_no = $log['ORDER_NO'];
}
if ( empty( $order_no ) && isset( $log['result_order_number'] ) ) {
$order_no = $log['result_order_number'];
}
if ( empty( $order_no ) && isset( $log['response']['data']['ORDER_NO'] ) ) {
$order_no = $log['response']['data']['ORDER_NO'];
}
if ( empty( $order_no ) && isset( $log['response']['result']['result_order_number'] ) ) {
$order_no = $log['response']['result']['result_order_number'];
}
return $order_no;
}
/**
* Email 取得
*
* @param int $order_id Order number.
* @return string
*/
private function get_email( $order_id ) {
global $wpdb;
$query = $wpdb->prepare( "SELECT `order_email` FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
$email = $wpdb->get_var( $query );
return $email;
}
/**
* Get interface.
*
* @param string $url URL.
* @return array
*/
public function get_interface( $url ) {
$interface = parse_url( $url );
if ( defined( 'ZEUS_SSL_TEST' ) ) {
$interface['host'] = ZEUS_SSL_TEST . $interface['host'];
}
if ( defined( 'ZEUS_TLS_TEST' ) ) {
$interface['host'] = ZEUS_TLS_TEST;
}
return $interface;
}
/**
* Get acting flg.
*
* @param string $payment_name Payment name.
* @return string
*/
private function get_acting_flg( $payment_name ) {
$payment = usces_get_payments_by_name( $payment_name );
$acting_flg = ( isset( $payment['settlement'] ) && 'acting' === $payment['settlement'] ) ? $payment['module'] : $payment['settlement'];
return $acting_flg;
}
/**
* Get Header Information.
*
* @return string
*/
private function get_header_information() {
// ヘッダー情報を格納する配列.
$header_info = array();
// 1-14の指定されたヘッダーを取得.
$header_info[] = $_SERVER['HTTP_ACCEPT'] ?? '';
$header_info[] = $_SERVER['HTTP_ACCEPT_CHARSET'] ?? '';
$header_info[] = $_SERVER['HTTP_ACCEPT_ENCODING'] ?? '';
$header_info[] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '';
$header_info[] = $_SERVER['HTTP_CLIENT_IP'] ?? '';
$header_info[] = $_SERVER['HTTP_CONNECTION'] ?? '';
// 7) DNTヘッダーの処理(Mozilla系ブラウザの判定).
$user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
if ( strpos( $user_agent, 'Mozilla' ) !== false ) {
$header_info[] = $_SERVER['HTTP_DNT'] ?? '';
} else {
$header_info[] = $_SERVER['HTTP_X_DO_NOT_TRACK'] ?? '';
}
$header_info[] = $_SERVER['HTTP_HOST'] ?? '';
$header_info[] = $_SERVER['HTTP_REFERER'] ?? '';
$header_info[] = $user_agent;
$header_info[] = $_SERVER['HTTP_KEEP_ALIVE'] ?? '';
$header_info[] = $_SERVER['HTTP_UA_CPU'] ?? '';
$header_info[] = $_SERVER['HTTP_VIA'] ?? '';
$header_info[] = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? '';
// 15) その他のヘッダーの処理.
$other_headers = array();
$all_headers = getallheaders(); // 全ヘッダーを取得.
// 除外するヘッダー名のリスト(大文字小文字を区別しない比較のため小文字で保持).
$exclude_headers = array_map(
'strtolower', [
'Accept', 'Accept-Charset', 'Accept-Encoding', 'Accept-Language',
'Client-IP', 'Connection', 'DNT', 'X-Do-Not-Track', 'Host',
'Referer', 'User-Agent', 'Keep-Alive', 'UA-CPU', 'Via',
'X-Forwarded-For',
]
);
foreach ( $all_headers as $header => $value ) {
if ( ! in_array( strtolower( $header ), $exclude_headers ) ) {
$other_headers[] = $header . '--' . $value;
}
}
$header_info[] = implode( '::', $other_headers );
// 16) クライアントIPアドレスの取得.
$client_ip = '';
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
$client_ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$client_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$client_ip = $_SERVER['REMOTE_ADDR'] ?? '';
}
$header_info[] = $client_ip;
// 17) 携帯端末識別IDの取得.
$mobile_id = '';
if ( isset( $_SERVER['HTTP_X_DCMGUID'] ) ) { // DoCoMo.
$mobile_id = $_SERVER['HTTP_X_DCMGUID'];
} elseif ( isset( $_SERVER['HTTP_X_UP_SUBNO'] ) ) { // au.
$mobile_id = $_SERVER['HTTP_X_UP_SUBNO'];
} elseif ( isset( $_SERVER['HTTP_X_JPHONE_UID'] ) ) { // SoftBank.
$mobile_id = $_SERVER['HTTP_X_JPHONE_UID'];
}
$header_info[] = $mobile_id;
// 全ての値をセミコロンとコロンで連結.
return implode( ';:', array_map( function( $value ) {
return trim( $value );
}, $header_info ) );
}
/**
* 手数料名称
*
* @param string $fee_type Fee type.
* @return string
*/
protected function get_fee_name( $fee_type ) {
$fee_name = '';
if ( 'fix' === $fee_type ) {
$fee_name = __( 'Fixation', 'usces' );
} elseif ( 'change' === $fee_type ) {
$fee_name = __( 'Variable', 'usces' );
}
return $fee_name;
}
}
/**
* Get order_ref
*
* @param string $order_no Order No.
* @return array
*/
function wel_zeus_get_order_ref( $order_no ) {
$order_ref = array();
$zeus_settlement = ZEUS_SETTLEMENT::get_instance();
$acting_opts = $zeus_settlement->get_acting_settings();
$interface = $zeus_settlement->get_interface( $acting_opts['card_order_ref'] );
$params = array();
$params['clientip'] = $acting_opts['clientip'];
$params['zkey'] = $acting_opts['authkey'];
$params['order_no'] = $order_no;
$vars = http_build_query( $params );
$header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
$header .= 'Host: ' . $interface['host'] . "\r\n";
$header .= "User-Agent: PHP Script\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
$header .= "Connection: close\r\n\r\n";
$header .= $vars;
$fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
if ( $fp ) {
$xml = '';
fwrite( $fp, $header );
while ( ! feof( $fp ) ) {
$scr = fgets( $fp, 1024 );
if ( false !== strpos( $scr, '<' ) ) {
$xml .= mb_convert_encoding( $scr, 'UTF-8', 'sjis-win' );
}
}
fclose( $fp );
$assoc = $zeus_settlement->xml2assoc( $xml );
if ( isset( $assoc['message']['response']['data'] ) ) {
$order_ref = $assoc['message']['response']['data'];
if ( isset( $order_ref['RESULT'] ) ) {
if ( '決済完了' === $order_ref['RESULT'] ) {
$order_ref['status'] = 'payment';
} elseif ( '与信完了' === $order_ref['RESULT'] || '仮売完了' === $order_ref['RESULT'] ) {
$order_ref['status'] = 'auth';
} elseif ( '取り消し' === $order_ref['RESULT'] ) {
$order_ref['status'] = 'cancel';
} else {
$order_ref['status'] = $order_ref['RESULT'];
}
} else {
$order_ref['status'] = '';
}
} else {
$order_ref['status'] = '';
}
}
if ( empty( $order_ref['status'] ) && false !== strpos( $order_no, 'TEST' ) ) {
$order_ref['status'] = 'TEST';
}
return $order_ref;
}
/**
* 決済ログ出力
*
* @param string $log Log data.
* @param string $acting Acting type.
* @param string $status Status.
* @param string $result Result.
* @param int $order_id Order number.
* @param string $tracking_id Tracking ID.
* @return array
*/
function wel_zeus_save_acting_log( $log, $acting, $status, $result, $order_id, $tracking_id ) {
global $wpdb;
if ( isset( $log['money'] ) ) {
$amount = $log['money'];
} elseif ( isset( $log['amount'] ) ) {
$amount = $log['amount'];
} elseif ( isset( $log['king'] ) ) {
$amount = $log['king'];
} elseif ( isset( $log['KING'] ) ) {
$amount = $log['KING'];
} else {
$amount = 0;
}
$query = $wpdb->prepare(
"INSERT INTO {$wpdb->prefix}usces_acting_log ( `datetime`, `log`, `acting`, `status`, `result`, `amount`, `order_id`, `tracking_id` ) VALUES ( %s, %s, %s, %s, %s, %f, %d, %s )",
wp_date( 'Y-m-d H:i:s' ),
usces_serialize( $log ),
$acting,
$status,
$result,
$amount,
$order_id,
$tracking_id
);
$res = $wpdb->query( $query );
return $res;
}