acting_name = 'WelcartPay'; $this->acting_formal_name = 'WelcartPay based on e-SCOTT'; $this->acting_card = 'welcart_card'; $this->acting_conv = 'welcart_conv'; $this->acting_atodene = 'welcart_atodene'; $this->acting_applepay = 'welcart_applepay'; $this->acting_unionpay = 'welcart_unionpay'; $this->acting_flg_card = 'acting_welcart_card'; $this->acting_flg_conv = 'acting_welcart_conv'; $this->acting_flg_atodene = 'acting_welcart_atodene'; $this->acting_flg_applepay = 'acting_welcart_applepay'; $this->acting_flg_unionpay = 'acting_welcart_unionpay'; $this->pay_method = array( 'acting_welcart_card', 'acting_welcart_conv', 'acting_welcart_applepay', 'acting_welcart_unionpay', ); $this->merchantfree3 = 'wc2collne'; $this->quick_key_pre = 'wcpay'; parent::__construct( 'welcart' ); if ( $this->is_activate_card() || $this->is_activate_conv() || $this->is_activate_applepay() || $this->is_activate_unionpay() ) { 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 ); } } if ( $this->is_validity_acting( 'card' ) ) { add_filter( 'usces_fiter_the_payment_method_explanation', array( $this, 'set_payment_method_explanation' ), 10, 3 ); add_filter( 'usces_filter_available_payment_method', array( $this, 'set_available_payment_method' ) ); add_filter( 'usces_filter_delivery_secure_form_howpay', array( $this, 'delivery_secure_form_howpay' ) ); 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_save_order_acting_data', array( $this, 'save_order_acting_data' ) ); /* WCEX DL Seller */ if ( defined( 'WCEX_DLSELLER' ) ) { if ( defined( 'WCEX_DLSELLER_VERSION' ) && version_compare( WCEX_DLSELLER_VERSION, '2.2-beta', '<=' ) ) { 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_limitofcard', array( $this, 'continue_member_list_limitofcard' ), 10, 4 ); 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_filter( 'dlseller_filter_card_update_mail', array( $this, 'continue_member_card_update_mail' ), 10, 3 ); 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 ); } /* WCEX Auto Delivery */ if ( defined( 'WCEX_AUTO_DELIVERY' ) ) { add_filter( 'wcad_filter_shippinglist_acting', array( $this, 'set_shippinglist_acting' ) ); add_filter( 'wcad_filter_available_regular_payment_method', array( $this, 'available_regular_payment_method' ) ); add_filter( 'wcad_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction' ), 10, 2 ); add_action( 'wcad_action_reg_auto_orderdata', array( $this, 'register_auto_orderdata' ) ); } } if ( $this->is_activate_atodene() ) { if ( is_admin() ) { add_action( 'usces_after_cart_instant', array( $this, 'atodene_upload' ), 9 ); add_action( 'usces_action_order_list_page', array( $this, 'output_atodene_csv' ) ); add_action( 'usces_action_order_list_searchbox_bottom', array( $this, 'action_atodene_button' ) ); add_action( 'usces_action_order_list_footer', array( $this, 'order_list_footer' ) ); add_filter( 'usces_filter_order_list_page_js', array( $this, 'order_list_page_js' ) ); add_filter( 'usces_order_list_action_status', array( $this, 'order_list_action_status' ) ); add_filter( 'usces_order_list_action_message', array( $this, 'order_list_action_message' ) ); add_filter( 'usces_filter_deli_comps', array( $this, 'delivery_company_name' ) ); $acting_opts = $this->get_acting_settings(); if ( isset( $acting_opts['atodene_byitem'] ) && 'on' === $acting_opts['atodene_byitem'] ) { add_filter( 'usces_item_master_second_section', array( $this, 'edit_item_atodene_byitem' ), 10, 2 ); add_action( 'usces_action_save_product', array( $this, 'save_item_atodene_byitem' ), 10, 2 ); } } } if ( $this->is_validity_acting( 'atodene' ) ) { add_filter( 'usces_filter_nonacting_settlements', array( $this, 'nonacting_settlements' ) ); /* WCEX Auto Delivery */ if ( defined( 'WCEX_AUTO_DELIVERY' ) ) { add_filter( 'wcad_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction_atodene' ), 11, 2 ); } } if ( $this->is_validity_acting( 'unionpay' ) ) { add_filter( 'usces_filter_save_order_acting_data', array( $this, 'save_order_acting_data' ) ); } $this->initialize_data(); } /** * 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']['welcart']['merchant_id'] = ( isset( $options['acting_settings']['welcart']['merchant_id'] ) ) ? $options['acting_settings']['welcart']['merchant_id'] : ''; $options['acting_settings']['welcart']['merchant_pass'] = ( isset( $options['acting_settings']['welcart']['merchant_pass'] ) ) ? $options['acting_settings']['welcart']['merchant_pass'] : ''; $options['acting_settings']['welcart']['tenant_id'] = ( isset( $options['acting_settings']['welcart']['tenant_id'] ) ) ? $options['acting_settings']['welcart']['tenant_id'] : '0001'; $options['acting_settings']['welcart']['auth_key'] = ( isset( $options['acting_settings']['welcart']['auth_key'] ) ) ? $options['acting_settings']['welcart']['auth_key'] : ''; $options['acting_settings']['welcart']['ope'] = ( isset( $options['acting_settings']['welcart']['ope'] ) ) ? $options['acting_settings']['welcart']['ope'] : 'test'; $options['acting_settings']['welcart']['card_activate'] = ( isset( $options['acting_settings']['welcart']['card_activate'] ) ) ? $options['acting_settings']['welcart']['card_activate'] : 'off'; $options['acting_settings']['welcart']['card_key_aes'] = ( isset( $options['acting_settings']['welcart']['card_key_aes'] ) ) ? $options['acting_settings']['welcart']['card_key_aes'] : ''; $options['acting_settings']['welcart']['card_key_iv'] = ( isset( $options['acting_settings']['welcart']['card_key_iv'] ) ) ? $options['acting_settings']['welcart']['card_key_iv'] : ''; $options['acting_settings']['welcart']['foreign_activate'] = ( isset( $options['acting_settings']['welcart']['foreign_activate'] ) ) ? $options['acting_settings']['welcart']['foreign_activate'] : 'off'; $options['acting_settings']['welcart']['seccd'] = ( isset( $options['acting_settings']['welcart']['seccd'] ) ) ? $options['acting_settings']['welcart']['seccd'] : 'on'; $options['acting_settings']['welcart']['sec3d_activate'] = ( isset( $options['acting_settings']['welcart']['sec3d_activate'] ) ) ? $options['acting_settings']['welcart']['sec3d_activate'] : 'off'; $options['acting_settings']['welcart']['token_code'] = ( isset( $options['acting_settings']['welcart']['token_code'] ) ) ? $options['acting_settings']['welcart']['token_code'] : ''; $options['acting_settings']['welcart']['quickpay'] = ( isset( $options['acting_settings']['welcart']['quickpay'] ) ) ? $options['acting_settings']['welcart']['quickpay'] : 'off'; $options['acting_settings']['welcart']['chooseable_quickpay'] = ( isset( $options['acting_settings']['welcart']['chooseable_quickpay'] ) ) ? $options['acting_settings']['welcart']['chooseable_quickpay'] : 'on'; $options['acting_settings']['welcart']['operateid'] = ( isset( $options['acting_settings']['welcart']['operateid'] ) ) ? $options['acting_settings']['welcart']['operateid'] : '1Gathering'; $options['acting_settings']['welcart']['operateid_dlseller'] = ( isset( $options['acting_settings']['welcart']['operateid_dlseller'] ) ) ? $options['acting_settings']['welcart']['operateid_dlseller'] : '1Gathering'; $options['acting_settings']['welcart']['auto_settlement_mail'] = ( isset( $options['acting_settings']['welcart']['auto_settlement_mail'] ) ) ? $options['acting_settings']['welcart']['auto_settlement_mail'] : 'off'; $options['acting_settings']['welcart']['howtopay'] = ( isset( $options['acting_settings']['welcart']['howtopay'] ) ) ? $options['acting_settings']['welcart']['howtopay'] : '1'; $options['acting_settings']['welcart']['conv_activate'] = ( isset( $options['acting_settings']['welcart']['conv_activate'] ) ) ? $options['acting_settings']['welcart']['conv_activate'] : 'off'; $options['acting_settings']['welcart']['conv_limit'] = ( ! empty( $options['acting_settings']['welcart']['conv_limit'] ) ) ? $options['acting_settings']['welcart']['conv_limit'] : '7'; $options['acting_settings']['welcart']['conv_fee_type'] = ( isset( $options['acting_settings']['welcart']['conv_fee_type'] ) ) ? $options['acting_settings']['welcart']['conv_fee_type'] : ''; $options['acting_settings']['welcart']['conv_fee'] = ( isset( $options['acting_settings']['welcart']['conv_fee'] ) ) ? $options['acting_settings']['welcart']['conv_fee'] : ''; $options['acting_settings']['welcart']['conv_fee_limit_amount'] = ( isset( $options['acting_settings']['welcart']['conv_fee_limit_amount'] ) ) ? $options['acting_settings']['welcart']['conv_fee_limit_amount'] : ''; $options['acting_settings']['welcart']['conv_fee_first_amount'] = ( isset( $options['acting_settings']['welcart']['conv_fee_first_amount'] ) ) ? $options['acting_settings']['welcart']['conv_fee_first_amount'] : ''; $options['acting_settings']['welcart']['conv_fee_first_fee'] = ( isset( $options['acting_settings']['welcart']['conv_fee_first_fee'] ) ) ? $options['acting_settings']['welcart']['conv_fee_first_fee'] : ''; $options['acting_settings']['welcart']['conv_fee_amounts'] = ( isset( $options['acting_settings']['welcart']['conv_fee_amounts'] ) ) ? $options['acting_settings']['welcart']['conv_fee_amounts'] : array(); $options['acting_settings']['welcart']['conv_fee_fees'] = ( isset( $options['acting_settings']['welcart']['conv_fee_fees'] ) ) ? $options['acting_settings']['welcart']['conv_fee_fees'] : array(); $options['acting_settings']['welcart']['conv_fee_end_fee'] = ( isset( $options['acting_settings']['welcart']['conv_fee_end_fee'] ) ) ? $options['acting_settings']['welcart']['conv_fee_end_fee'] : ''; $options['acting_settings']['welcart']['atodene_activate'] = ( isset( $options['acting_settings']['welcart']['atodene_activate'] ) ) ? $options['acting_settings']['welcart']['atodene_activate'] : 'off'; $options['acting_settings']['welcart']['atodene_byitem'] = ( isset( $options['acting_settings']['welcart']['atodene_byitem'] ) ) ? $options['acting_settings']['welcart']['atodene_byitem'] : 'off'; $options['acting_settings']['welcart']['atodene_billing_method'] = ( isset( $options['acting_settings']['welcart']['atodene_billing_method'] ) ) ? $options['acting_settings']['welcart']['atodene_billing_method'] : '2'; $options['acting_settings']['welcart']['atodene_fee_type'] = ( isset( $options['acting_settings']['welcart']['atodene_fee_type'] ) ) ? $options['acting_settings']['welcart']['atodene_fee_type'] : ''; $options['acting_settings']['welcart']['atodene_fee'] = ( isset( $options['acting_settings']['welcart']['atodene_fee'] ) ) ? $options['acting_settings']['welcart']['atodene_fee'] : ''; $options['acting_settings']['welcart']['atodene_fee_limit_amount'] = ( isset( $options['acting_settings']['welcart']['atodene_fee_limit_amount'] ) ) ? $options['acting_settings']['welcart']['atodene_fee_limit_amount'] : ''; $options['acting_settings']['welcart']['atodene_fee_first_amount'] = ( isset( $options['acting_settings']['welcart']['atodene_fee_first_amount'] ) ) ? $options['acting_settings']['welcart']['atodene_fee_first_amount'] : ''; $options['acting_settings']['welcart']['atodene_fee_first_fee'] = ( isset( $options['acting_settings']['welcart']['atodene_fee_first_fee'] ) ) ? $options['acting_settings']['welcart']['atodene_fee_first_fee'] : ''; $options['acting_settings']['welcart']['atodene_fee_amounts'] = ( isset( $options['acting_settings']['welcart']['atodene_fee_amounts'] ) ) ? $options['acting_settings']['welcart']['atodene_fee_amounts'] : array(); $options['acting_settings']['welcart']['atodene_fee_fees'] = ( isset( $options['acting_settings']['welcart']['atodene_fee_fees'] ) ) ? $options['acting_settings']['welcart']['atodene_fee_fees'] : array(); $options['acting_settings']['welcart']['atodene_fee_end_fee'] = ( isset( $options['acting_settings']['welcart']['atodene_fee_end_fee'] ) ) ? $options['acting_settings']['welcart']['atodene_fee_end_fee'] : ''; $options['acting_settings']['welcart']['applepay_activate'] = ( isset( $options['acting_settings']['welcart']['applepay_activate'] ) ) ? $options['acting_settings']['welcart']['applepay_activate'] : 'off'; $options['acting_settings']['welcart']['applepay_tenant_id'] = ( isset( $options['acting_settings']['welcart']['applepay_tenant_id'] ) ) ? $options['acting_settings']['welcart']['applepay_tenant_id'] : ''; $options['acting_settings']['welcart']['applepay_quickpay'] = ( isset( $options['acting_settings']['welcart']['applepay_quickpay'] ) ) ? $options['acting_settings']['welcart']['applepay_quickpay'] : 'off'; $options['acting_settings']['welcart']['applepay_operateid'] = ( isset( $options['acting_settings']['welcart']['applepay_operateid'] ) ) ? $options['acting_settings']['welcart']['applepay_operateid'] : '1Gathering'; $options['acting_settings']['welcart']['applepay_key_aes'] = ( isset( $options['acting_settings']['welcart']['applepay_key_aes'] ) ) ? $options['acting_settings']['welcart']['applepay_key_aes'] : ''; $options['acting_settings']['welcart']['applepay_key_iv'] = ( isset( $options['acting_settings']['welcart']['applepay_key_iv'] ) ) ? $options['acting_settings']['welcart']['applepay_key_iv'] : ''; $options['acting_settings']['welcart']['applepay_certificate_path'] = ( isset( $options['acting_settings']['welcart']['applepay_certificate_path'] ) ) ? $options['acting_settings']['welcart']['applepay_certificate_path'] : ''; $options['acting_settings']['welcart']['applepay_certificate_key_pass'] = ( isset( $options['acting_settings']['welcart']['applepay_certificate_key_pass'] ) ) ? $options['acting_settings']['welcart']['applepay_certificate_key_pass'] : ''; $options['acting_settings']['welcart']['applepay_merchantidentifier'] = ( isset( $options['acting_settings']['welcart']['applepay_merchantidentifier'] ) ) ? $options['acting_settings']['welcart']['applepay_merchantidentifier'] : ''; $options['acting_settings']['welcart']['unionpay_activate'] = ( isset( $options['acting_settings']['welcart']['unionpay_activate'] ) ) ? $options['acting_settings']['welcart']['unionpay_activate'] : 'off'; $options['acting_settings']['welcart']['unionpay_key_aes'] = ( isset( $options['acting_settings']['welcart']['unionpay_key_aes'] ) ) ? $options['acting_settings']['welcart']['unionpay_key_aes'] : ''; $options['acting_settings']['welcart']['unionpay_key_iv'] = ( isset( $options['acting_settings']['welcart']['unionpay_key_iv'] ) ) ? $options['acting_settings']['welcart']['unionpay_key_iv'] : ''; $options['acting_settings']['welcart']['unionpay_pagelanguage'] = ( isset( $options['acting_settings']['welcart']['unionpay_pagelanguage'] ) ) ? $options['acting_settings']['welcart']['unionpay_pagelanguage'] : ''; $options['acting_settings']['welcart']['activate'] = ( isset( $options['acting_settings']['welcart']['activate'] ) ) ? $options['acting_settings']['welcart']['activate'] : 'off'; update_option( 'usces', $options ); $welcartpay_keys = get_option( 'usces_welcartpay_keys', array() ); if ( empty( $welcartpay_keys ) ) { $welcartpay_keys = array( 'c0778c9aefe850d5ac8efed5d62ed281', 'd0771e4b42ef683223df03f9558c23fd', 'dfef8e46f7231e7e8271f906582a4e1d', 'ad6dbb5e26cc9db1fe5d876a75764559', '4fc1738fffa5aa33792ddf8e5c183f72', 'd255b1cb2c4d20959e3c80e457e5274c', '479ffcfe47db920e972a8c7932e581d9', '43c7f4782379b05cf69bbbfb547e3312', '524047b0e0ad64d4f7b42c14c77758e2', 'b848aed9c05cbf2c85d2889b274c18ec', ); update_option( 'usces_welcartpay_keys', $welcartpay_keys ); } $available_settlement = get_option( 'usces_available_settlement', array() ); if ( ! in_array( 'welcart', $available_settlement, true ) ) { $settlement = array( 'welcart' => $this->acting_name, ); $available_settlement = array_merge( $settlement, $available_settlement ); update_option( 'usces_available_settlement', $available_settlement ); } $noreceipt_status = get_option( 'usces_noreceipt_status', array() ); if ( ! in_array( 'acting_welcart_conv', $noreceipt_status, true ) || ! in_array( 'acting_welcart_atodene', $noreceipt_status, true ) ) { $noreceipt_status[] = 'acting_welcart_conv'; $noreceipt_status[] = 'acting_welcart_atodene'; update_option( 'usces_noreceipt_status', $noreceipt_status ); } $this->unavailable_method = array( 'acting_escott_card', 'acting_zeus_card', 'acting_zeus_conv', 'acting_sbps_card', ); } /** * Admin scripts. * admin_print_footer_scripts */ public function admin_scripts() { global $usces; $admin_page = filter_input( INPUT_GET, 'page', FILTER_DEFAULT ); switch ( $admin_page ) : case 'usces_settlement': $settlement_selected = get_option( 'usces_settlement_selected', array() ); if ( in_array( 'welcart', $settlement_selected, true ) ) : $acting_opts = $this->get_acting_settings(); ?> get_order_data( $order_id, 'direct' ); $payment = usces_get_payments_by_name( $order_data['order_payment_name'] ); if ( isset( $payment['settlement'] ) ) { $acting_flg = $payment['settlement']; } if ( isset( $payment['name'] ) ) { $dialog_title = $payment['name']; } } } $args = compact( 'order_id', 'acting_flg', 'admin_page', 'order_data' ); if ( in_array( $acting_flg, $this->pay_method, true ) ) : ?> 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']['welcart'] ); $options['acting_settings']['welcart']['merchant_id'] = ( isset( $post_data['merchant_id'] ) ) ? trim( $post_data['merchant_id'] ) : ''; $options['acting_settings']['welcart']['merchant_pass'] = ( isset( $post_data['merchant_pass'] ) ) ? trim( $post_data['merchant_pass'] ) : ''; $options['acting_settings']['welcart']['tenant_id'] = ( isset( $post_data['tenant_id'] ) ) ? trim( $post_data['tenant_id'] ) : '0001'; $options['acting_settings']['welcart']['auth_key'] = ( isset( $post_data['auth_key'] ) ) ? trim( $post_data['auth_key'] ) : ''; $options['acting_settings']['welcart']['ope'] = ( isset( $post_data['ope'] ) ) ? $post_data['ope'] : ''; $options['acting_settings']['welcart']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : 'off'; $options['acting_settings']['welcart']['card_key_aes'] = ( isset( $post_data['card_key_aes'] ) ) ? $post_data['card_key_aes'] : ''; $options['acting_settings']['welcart']['card_key_iv'] = ( isset( $post_data['card_key_iv'] ) ) ? $post_data['card_key_iv'] : ''; $options['acting_settings']['welcart']['foreign_activate'] = ( isset( $post_data['foreign_activate'] ) ) ? $post_data['foreign_activate'] : ''; $options['acting_settings']['welcart']['seccd'] = ( isset( $post_data['seccd'] ) ) ? $post_data['seccd'] : 'on'; $options['acting_settings']['welcart']['sec3d_activate'] = ( isset( $post_data['sec3d_activate'] ) ) ? $post_data['sec3d_activate'] : 'off'; $options['acting_settings']['welcart']['token_code'] = ( isset( $post_data['token_code'] ) ) ? trim( $post_data['token_code'] ) : ''; $options['acting_settings']['welcart']['quickpay'] = ( isset( $post_data['quickpay'] ) ) ? $post_data['quickpay'] : ''; $options['acting_settings']['welcart']['chooseable_quickpay'] = ( isset( $post_data['chooseable_quickpay'] ) ) ? $post_data['chooseable_quickpay'] : 'on'; $options['acting_settings']['welcart']['operateid'] = ( isset( $post_data['operateid'] ) ) ? $post_data['operateid'] : '1Gathering'; $options['acting_settings']['welcart']['operateid_dlseller'] = ( isset( $post_data['operateid_dlseller'] ) ) ? $post_data['operateid_dlseller'] : '1Gathering'; $options['acting_settings']['welcart']['auto_settlement_mail'] = ( isset( $post_data['auto_settlement_mail'] ) ) ? $post_data['auto_settlement_mail'] : 'off'; $options['acting_settings']['welcart']['howtopay'] = ( isset( $post_data['howtopay'] ) ) ? $post_data['howtopay'] : ''; $options['acting_settings']['welcart']['conv_activate'] = ( isset( $post_data['conv_activate'] ) ) ? $post_data['conv_activate'] : 'off'; $options['acting_settings']['welcart']['conv_limit'] = ( ! empty( $post_data['conv_limit'] ) ) ? $post_data['conv_limit'] : '7'; $options['acting_settings']['welcart']['conv_fee_type'] = ( isset( $post_data['conv_fee_type'] ) ) ? $post_data['conv_fee_type'] : ''; $options['acting_settings']['welcart']['conv_fee'] = ( isset( $post_data['conv_fee'] ) ) ? $post_data['conv_fee'] : ''; $options['acting_settings']['welcart']['conv_fee_limit_amount'] = ( isset( $post_data[ 'conv_fee_limit_amount_' . $options['acting_settings']['welcart']['conv_fee_type'] ] ) ) ? $post_data[ 'conv_fee_limit_amount_' . $options['acting_settings']['welcart']['conv_fee_type'] ] : ''; $options['acting_settings']['welcart']['conv_fee_first_amount'] = ( isset( $post_data['conv_fee_first_amount'] ) ) ? $post_data['conv_fee_first_amount'] : ''; $options['acting_settings']['welcart']['conv_fee_first_fee'] = ( isset( $post_data['conv_fee_first_fee'] ) ) ? $post_data['conv_fee_first_fee'] : ''; $options['acting_settings']['welcart']['conv_fee_amounts'] = ( isset( $post_data['conv_fee_amounts'] ) ) ? explode( '|', $post_data['conv_fee_amounts'] ) : array(); $options['acting_settings']['welcart']['conv_fee_fees'] = ( isset( $post_data['conv_fee_fees'] ) ) ? explode( '|', $post_data['conv_fee_fees'] ) : array(); $options['acting_settings']['welcart']['conv_fee_end_fee'] = ( isset( $post_data['conv_fee_end_fee'] ) ) ? $post_data['conv_fee_end_fee'] : ''; $options['acting_settings']['welcart']['atodene_activate'] = ( isset( $post_data['atodene_activate'] ) ) ? $post_data['atodene_activate'] : 'off'; $options['acting_settings']['welcart']['atodene_byitem'] = ( isset( $post_data['atodene_byitem'] ) ) ? $post_data['atodene_byitem'] : 'off'; $options['acting_settings']['welcart']['atodene_billing_method'] = ( isset( $post_data['atodene_billing_method'] ) ) ? $post_data['atodene_billing_method'] : '2'; $options['acting_settings']['welcart']['atodene_fee_type'] = ( isset( $post_data['atodene_fee_type'] ) ) ? $post_data['atodene_fee_type'] : ''; $options['acting_settings']['welcart']['atodene_fee'] = ( isset( $post_data['atodene_fee'] ) ) ? $post_data['atodene_fee'] : ''; $options['acting_settings']['welcart']['atodene_fee_limit_amount'] = ( isset( $post_data[ 'atodene_fee_limit_amount_' . $options['acting_settings']['welcart']['atodene_fee_type'] ] ) ) ? $post_data[ 'atodene_fee_limit_amount_' . $options['acting_settings']['welcart']['atodene_fee_type'] ] : ''; $options['acting_settings']['welcart']['atodene_fee_first_amount'] = ( isset( $post_data['atodene_fee_first_amount'] ) ) ? $post_data['atodene_fee_first_amount'] : ''; $options['acting_settings']['welcart']['atodene_fee_first_fee'] = ( isset( $post_data['atodene_fee_first_fee'] ) ) ? $post_data['atodene_fee_first_fee'] : ''; $options['acting_settings']['welcart']['atodene_fee_amounts'] = ( isset( $post_data['atodene_fee_amounts'] ) ) ? explode( '|', $post_data['atodene_fee_amounts'] ) : array(); $options['acting_settings']['welcart']['atodene_fee_fees'] = ( isset( $post_data['atodene_fee_fees'] ) ) ? explode( '|', $post_data['atodene_fee_fees'] ) : array(); $options['acting_settings']['welcart']['atodene_fee_end_fee'] = ( isset( $post_data['atodene_fee_end_fee'] ) ) ? $post_data['atodene_fee_end_fee'] : ''; $options['acting_settings']['welcart']['applepay_activate'] = ( isset( $post_data['applepay_activate'] ) ) ? $post_data['applepay_activate'] : 'off'; $options['acting_settings']['welcart']['applepay_tenant_id'] = ( isset( $post_data['applepay_tenant_id'] ) ) ? $post_data['applepay_tenant_id'] : ''; $options['acting_settings']['welcart']['applepay_quickpay'] = ( isset( $post_data['applepay_quickpay'] ) ) ? $post_data['applepay_quickpay'] : ''; $options['acting_settings']['welcart']['applepay_operateid'] = ( isset( $post_data['applepay_operateid'] ) ) ? $post_data['applepay_operateid'] : '1Gathering'; $options['acting_settings']['welcart']['applepay_key_aes'] = ( isset( $post_data['applepay_key_aes'] ) ) ? $post_data['applepay_key_aes'] : ''; $options['acting_settings']['welcart']['applepay_key_iv'] = ( isset( $post_data['applepay_key_iv'] ) ) ? $post_data['applepay_key_iv'] : ''; $options['acting_settings']['welcart']['applepay_certificate_path'] = ( isset( $post_data['applepay_certificate_path'] ) ) ? $post_data['applepay_certificate_path'] : ''; $options['acting_settings']['welcart']['applepay_certificate_key_pass'] = ( isset( $post_data['applepay_certificate_key_pass'] ) ) ? $post_data['applepay_certificate_key_pass'] : ''; $options['acting_settings']['welcart']['applepay_merchantidentifier'] = ( isset( $post_data['applepay_merchantidentifier'] ) ) ? $post_data['applepay_merchantidentifier'] : ''; $options['acting_settings']['welcart']['unionpay_activate'] = ( isset( $post_data['unionpay_activate'] ) ) ? $post_data['unionpay_activate'] : 'off'; $options['acting_settings']['welcart']['unionpay_key_aes'] = ( isset( $post_data['unionpay_key_aes'] ) ) ? $post_data['unionpay_key_aes'] : ''; $options['acting_settings']['welcart']['unionpay_key_iv'] = ( isset( $post_data['unionpay_key_iv'] ) ) ? $post_data['unionpay_key_iv'] : ''; $options['acting_settings']['welcart']['unionpay_pagelanguage'] = ( isset( $post_data['unionpay_pagelanguage'] ) ) ? $post_data['unionpay_pagelanguage'] : ''; if ( 'on' === $options['acting_settings']['welcart']['card_activate'] || 'on' === $options['acting_settings']['welcart']['conv_activate'] ) { $unavailable_activate = false; foreach ( $payment_method as $settlement => $payment ) { if ( in_array( $settlement, $this->unavailable_method, true ) && 'activate' === $payment['use'] ) { $unavailable_activate = true; break; } } if ( $unavailable_activate ) { $this->error_mes .= __( '* Settlement that can not be used together is activated.', 'usces' ) . '
'; } else { if ( WCUtils::is_blank( $post_data['merchant_id'] ) ) { $this->error_mes .= __( '* Please enter the Merchant ID.', 'usces' ) . '
'; } if ( WCUtils::is_blank( $post_data['merchant_pass'] ) ) { $this->error_mes .= __( '* Please enter the Merchant Password.', 'usces' ) . '
'; } if ( WCUtils::is_blank( $post_data['tenant_id'] ) ) { $this->error_mes .= __( '* Please enter the Tenant ID.', 'usces' ) . '
'; } if ( WCUtils::is_blank( $post_data['auth_key'] ) ) { $this->error_mes .= __( '* Please enter the Settlement auth key.', 'usces' ) . '
'; } else { $auth_key = md5( $post_data['auth_key'] ); $welcartpay_keys = get_option( 'usces_welcartpay_keys', array() ); if ( ! in_array( $auth_key, $welcartpay_keys, true ) ) { $this->error_mes .= __( '* The Settlement auth key is incorrect.', 'usces' ) . '
'; } } if ( WCUtils::is_blank( $post_data['ope'] ) ) { $this->error_mes .= __( '* Please select the operating environment.', 'usces' ) . '
'; } if ( WCUtils::is_blank( $post_data['operateid'] ) ) { $this->error_mes .= __( '* Please select the processing classification.', 'usces' ) . '
'; } if ( 'on' === $options['acting_settings']['welcart']['card_activate'] ) { if ( WCUtils::is_blank( $post_data['token_code'] ) ) { $this->error_mes .= __( '* Please enter the Token auth code.', 'usces' ) . '
'; } } } } if ( 'on' === $options['acting_settings']['welcart']['unionpay_activate'] ) { if ( WCUtils::is_blank( $post_data['unionpay_key_aes'] ) ) { $this->error_mes .= __( '* Please enter the UnionPay tripartite encryption key.', 'usces' ) . '
'; } if ( WCUtils::is_blank( $post_data['unionpay_key_iv'] ) ) { $this->error_mes .= __( '* Please enter the UnionPay tripartite initialization vector.', 'usces' ) . '
'; } } if ( '' === $this->error_mes ) { $usces->action_status = 'success'; $usces->action_message = __( 'Options are updated.', 'usces' ); if ( ( 'on' === $options['acting_settings']['welcart']['card_activate'] || 'link' === $options['acting_settings']['welcart']['card_activate'] || 'token' === $options['acting_settings']['welcart']['card_activate'] ) || 'on' === $options['acting_settings']['welcart']['conv_activate'] || 'on' === $options['acting_settings']['welcart']['atodene_activate'] || 'on' === $options['acting_settings']['welcart']['applepay_activate'] || 'on' === $options['acting_settings']['welcart']['unionpay_activate'] ) { $options['acting_settings']['welcart']['activate'] = 'on'; if ( 'public' === $options['acting_settings']['welcart']['ope'] ) { $options['acting_settings']['welcart']['send_url'] = 'https://www.e-scott.jp/online/aut/OAUT002.do'; $options['acting_settings']['welcart']['send_url_member'] = 'https://www.e-scott.jp/online/crp/OCRP005.do'; $options['acting_settings']['welcart']['send_url_conv'] = 'https://www.e-scott.jp/online/cnv/OCNV005.do'; $options['acting_settings']['welcart']['redirect_url_conv'] = 'https://link.kessai.info/JLP/JLPcon'; $options['acting_settings']['welcart']['send_url_link'] = 'https://www.e-scott.jp/euser/snp/SSNP005ReferStart.do'; $options['acting_settings']['welcart']['api_token'] = 'https://www.e-scott.jp/euser/stn/CdGetJavaScript.do'; $options['acting_settings']['welcart']['send_url_token'] = 'https://www.e-scott.jp/online/atn/OATN005.do'; $options['acting_settings']['welcart']['send_url_3dsecure'] = 'https://www.e-scott.jp/online/tds/OTDS010.do'; $options['acting_settings']['welcart']['send_url_applepay'] = 'https://www.e-scott.jp/online/aut/OAUT002.do'; $options['acting_settings']['welcart']['send_url_applepay_member'] = 'https://www.e-scott.jp/online/crp/OCRP005.do'; $options['acting_settings']['welcart']['send_url_unionpay'] = 'https://www.e-scott.jp/online/agc/OAGC010.do'; } else { $options['acting_settings']['welcart']['send_url'] = 'https://www.test.e-scott.jp/online/aut/OAUT002.do'; $options['acting_settings']['welcart']['send_url_member'] = 'https://www.test.e-scott.jp/online/crp/OCRP005.do'; $options['acting_settings']['welcart']['send_url_conv'] = 'https://www.test.e-scott.jp/online/cnv/OCNV005.do'; $options['acting_settings']['welcart']['redirect_url_conv'] = 'https://link.kessai.info/JLPCT/JLPcon'; $options['acting_settings']['welcart']['send_url_link'] = 'https://www.test.e-scott.jp/euser/snp/SSNP005ReferStart.do'; $options['acting_settings']['welcart']['api_token'] = 'https://www.test.e-scott.jp/euser/stn/CdGetJavaScript.do'; $options['acting_settings']['welcart']['send_url_token'] = 'https://www.test.e-scott.jp/online/atn/OATN005.do'; $options['acting_settings']['welcart']['send_url_3dsecure'] = 'https://www.test.e-scott.jp/online/tds/OTDS010.do'; $options['acting_settings']['welcart']['send_url_applepay'] = 'https://www.test.e-scott.jp/online/aut/OAUT002.do'; $options['acting_settings']['welcart']['send_url_applepay_member'] = 'https://www.test.e-scott.jp/online/crp/OCRP005.do'; $options['acting_settings']['welcart']['send_url_unionpay'] = 'https://www.test.e-scott.jp/online/agc/OAGC010.do'; $options['acting_settings']['welcart']['tenant_id'] = '0001'; } $toactive = array(); if ( 'on' === $options['acting_settings']['welcart']['card_activate'] ) { if ( ! empty( $options['acting_settings']['welcart']['token_code'] ) ) { $options['acting_settings']['welcart']['card_activate'] = 'token'; } } if ( 'on' === $options['acting_settings']['welcart']['card_activate'] || 'link' === $options['acting_settings']['welcart']['card_activate'] || 'token' === $options['acting_settings']['welcart']['card_activate'] ) { $usces->payment_structure['acting_welcart_card'] = __( 'Credit card transaction (WelcartPay)', 'usces' ); foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_welcart_card' === $settlement && 'deactivate' === $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_welcart_card'] ); } if ( 'on' === $options['acting_settings']['welcart']['conv_activate'] ) { $usces->payment_structure['acting_welcart_conv'] = __( 'Online storage agency (WelcartPay)', 'usces' ); foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_welcart_conv' === $settlement && 'deactivate' === $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_welcart_conv'] ); } if ( 'on' === $options['acting_settings']['welcart']['atodene_activate'] ) { $usces->payment_structure['acting_welcart_atodene'] = __( 'Postpay settlement (WelcartPay/ATODENE)', 'usces' ); foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_welcart_atodene' === $settlement && 'deactivate' === $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_welcart_atodene'] ); } if ( 'on' === $options['acting_settings']['welcart']['unionpay_activate'] ) { $usces->payment_structure['acting_welcart_unionpay'] = __( 'UnionPay (WelcartPay)', 'usces' ); foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_welcart_unionpay' === $settlement && 'deactivate' === $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_welcart_unionpay'] ); } 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']['welcart']['activate'] = 'off'; unset( $usces->payment_structure['acting_welcart_card'] ); unset( $usces->payment_structure['acting_welcart_conv'] ); unset( $usces->payment_structure['acting_welcart_atodene'] ); unset( $usces->payment_structure['acting_welcart_applepay'] ); unset( $usces->payment_structure['acting_welcart_unionpay'] ); } $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']['welcart']['activate'] = 'off'; unset( $usces->payment_structure['acting_welcart_card'] ); unset( $usces->payment_structure['acting_welcart_conv'] ); unset( $usces->payment_structure['acting_welcart_atodene'] ); unset( $usces->payment_structure['acting_welcart_applepay'] ); unset( $usces->payment_structure['acting_welcart_unionpay'] ); $deactivate = array(); foreach ( $payment_method as $settlement => $payment ) { if ( in_array( $settlement, $this->pay_method, true ) ) { 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_body */ public function settlement_tab_body() { $acting_opts = $this->get_acting_settings(); $settlement_selected = get_option( 'usces_settlement_selected', array() ); if ( in_array( 'welcart', $settlement_selected, true ) ) : $ope = ( isset( $acting_opts['ope'] ) && 'public' === $acting_opts['ope'] ) ? 'public' : 'test'; $card_activate = ( isset( $acting_opts['card_activate'] ) && ( 'on' === $acting_opts['card_activate'] || 'token' === $acting_opts['card_activate'] ) ) ? 'on' : $acting_opts['card_activate']; $sec3d_activate = ( isset( $acting_opts['sec3d_activate'] ) && 'on' === $acting_opts['sec3d_activate'] ) ? 'on' : 'off'; $seccd = ( isset( $acting_opts['seccd'] ) && 'on' === $acting_opts['seccd'] ) ? 'on' : 'off'; $quickpay = ( isset( $acting_opts['quickpay'] ) && 'on' === $acting_opts['quickpay'] ) ? 'on' : 'off'; $chooseable_quickpay = ( isset( $acting_opts['chooseable_quickpay'] ) && 'on' === $acting_opts['chooseable_quickpay'] ) ? 'on' : 'off'; $operateid = ( isset( $acting_opts['operateid'] ) ) ? $acting_opts['operateid'] : '1Gathering'; if ( defined( 'WCEX_DLSELLER' ) ) { $operateid_dlseller = ( isset( $acting_opts['operateid_dlseller'] ) ) ? $acting_opts['operateid_dlseller'] : '1Gathering'; $auto_settlement_mail = ( isset( $acting_opts['auto_settlement_mail'] ) && 'on' === $acting_opts['auto_settlement_mail'] ) ? 'on' : 'off'; } $howtopay = ( isset( $acting_opts['howtopay'] ) ) ? $acting_opts['howtopay'] : '1'; $conv_activate = ( isset( $acting_opts['conv_activate'] ) && 'on' === $acting_opts['conv_activate'] ) ? 'on' : 'off'; $atodene_activate = ( isset( $acting_opts['atodene_activate'] ) && 'on' === $acting_opts['atodene_activate'] ) ? 'on' : 'off'; $atodene_byitem = ( isset( $acting_opts['atodene_byitem'] ) && 'on' === $acting_opts['atodene_byitem'] ) ? 'on' : 'off'; $atodene_billing_method = ( isset( $acting_opts['atodene_billing_method'] ) ) ? $acting_opts['atodene_billing_method'] : '2'; $unionpay_activate = ( isset( $acting_opts['unionpay_activate'] ) && 'on' === $acting_opts['unionpay_activate'] ) ? 'on' : 'off'; ?>
error_mes ) : ?>
error_mes ); ?>
If you have only one shop to contract, enter 0001.', 'usces' ) ); ?>




(authentication assist)', 'usces' ) ); /* セキュリティコード */ ?>








get_fee_name( $acting_opts['conv_fee_type'] ) ); ?>


If enabled, a selection field will be added to determine whether postpay settlement is possible on the product registration screen. If there is a product in the cart that can not be postpaid settlement, we exclude postpaid settlement from the payment method options.
In addition, availability data is added to the product CSV as a custom field (welcartpay_atodene).', 'usces' ) ); ?>

get_fee_name( $acting_opts['atodene_fee_type'] ) ); ?>

WelcartPay based on e-SCOTT
>', 'usces' ); ?>















() ()
0
get_acting_settings(); if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) && ( isset( $acting_opts['card_activate'] ) && ( 'on' === $acting_opts['card_activate'] || 'link' === $acting_opts['card_activate'] || 'token' === $acting_opts['card_activate'] ) ) && ( isset( $acting_opts['quickpay'] ) && 'on' === $acting_opts['quickpay'] ) ) { $msg = ''; } else { $zeus_opts = $usces->options['acting_settings']['zeus']; $p_flag = ( ( isset( $zeus_opts['activate'] ) && 'on' === $zeus_opts['activate'] ) && ( isset( $zeus_opts['card_activate'] ) && 'on' === $zeus_opts['card_activate'] ) ) ? true : false; $batch = ( isset( $zeus_opts['batch'] ) ) ? $zeus_opts['batch'] : 'off'; if ( ! $p_flag || 'off' === $batch ) { $msg .= '

' . __( "In 'credit settlement Settings', please set to 'use' the quickpay of WelcartPay.", 'usces' ) . '

'; } } return $msg; } /** * 入金通知処理および、三者間決済画面からのリダイレクト * usces_after_cart_instant */ public function acting_transaction() { global $usces; /* 入金通知 */ if ( isset( $_REQUEST['MerchantFree1'] ) && isset( $_REQUEST['MerchantId'] ) && isset( $_REQUEST['TransactionId'] ) && isset( $_REQUEST['RecvNum'] ) && isset( $_REQUEST['NyukinDate'] ) && ( isset( $_REQUEST['MerchantFree2'] ) && 'acting_welcart_conv' === wp_unslash( $_REQUEST['MerchantFree2'] ) ) ) { $this->acting_notice_ip_guard( wp_unslash( $_REQUEST ) ); $acting_opts = $this->get_acting_settings(); if ( $acting_opts['merchant_id'] === wp_unslash( $_REQUEST['MerchantId'] ) ) { $response_data = wp_unslash( $_REQUEST ); $order_id = usces_get_order_id_by_trans_id( $response_data['MerchantFree1'] ); if ( ! empty( $order_id ) ) { /* オーダーステータス変更 */ usces_change_order_receipt( $order_id, 'receipted' ); /* ポイント付与 */ usces_action_acting_getpoint( $order_id ); $response_data['OperateId'] = 'receipted'; $order_meta = usces_unserialize( $usces->get_order_meta_value( $response_data['MerchantFree2'], $order_id ) ); $meta_value = array_merge( $order_meta, $response_data ); $usces->set_order_meta_value( $response_data['MerchantFree2'], usces_serialize( $meta_value ), $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $response_data['MerchantFree1'] ); usces_log( '[WelcartPay] conv receipted : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } else { usces_log( '[WelcartPay] conv receipted order_id error : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } } header( 'HTTP/1.0 200 OK' ); die(); } elseif ( isset( $_REQUEST['EncryptValue'] ) ) { $acting_opts = $this->get_acting_settings(); /* 銀聯決済 */ if ( isset( $_REQUEST['acting'] ) && $this->acting_unionpay === wp_unslash( $_REQUEST['acting'] ) && $this->is_validity_acting( 'unionpay' ) ) { $encryptvalue = openssl_decrypt( $_REQUEST['EncryptValue'], 'aes-128-cbc', $acting_opts['unionpay_key_aes'], false, $acting_opts['unionpay_key_iv'] ); if ( $encryptvalue ) { parse_str( $encryptvalue, $response_data ); if ( isset( $response_data['OperateId'] ) && isset( $response_data['ResponseCd'] ) && isset( $response_data['MerchantFree1'] ) && ( isset( $response_data['MerchantFree2'] ) && 'acting_welcart_unionpay' === $response_data['MerchantFree2'] ) ) { if ( 'OK' === $response_data['ResponseCd'] ) { $order_data = usces_restore_order_acting_data( $response_data['MerchantFree1'] ); if ( ! empty( $order_data ) ) { $response_data['acting'] = $this->acting_unionpay; $res = $usces->order_processing( $response_data ); if ( 'ordercompletion' === $res ) { $_nonce = ( isset( $order_data['_nonce'] ) ) ? $order_data['_nonce'] : wp_create_nonce( $this->acting_flg_unionpay ); wp_redirect( add_query_arg( array( 'acting' => $this->acting_unionpay, 'acting_return' => 1, 'result' => 1, '_nonce' => $_nonce, ), USCES_CART_URL ) ); } else { $logdata = array_merge( $usces_entries['order'], $response_data ); $log = array( 'acting' => $this->acting_unionpay, 'key' => $response_data['MerchantFree1'], 'result' => 'ORDER DATA REGISTERED ERROR', 'data' => $logdata, ); usces_save_order_acting_error( $log ); wp_redirect( add_query_arg( array( 'acting' => $this->acting_unionpay, 'acting_return' => 0, 'result' => 0, ), USCES_CART_URL ) ); } } else { $log = array( 'acting' => $this->acting_unionpay, 'key' => $response_data['MerchantFree1'], 'result' => 'ORDER DATA RESTORE ERROR', 'data' => $response_data, ); usces_save_order_acting_error( $log ); wp_redirect( add_query_arg( array( 'acting' => $this->acting_unionpay, 'acting_return' => 0, 'result' => 0, ), USCES_CART_URL ) ); } } elseif ( 'KI0' === $response_data['ResponseCd'] ) { /* Return to Merchant */ wp_redirect( add_query_arg( array( 'confirm' => 1, ), USCES_CART_URL ) ); } else { $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $response_data[ $cd ] = $this->response_message( $cd ); } $log = array( 'acting' => $this->acting_unionpay, 'key' => $response_data['MerchantFree1'], 'result' => $response_data['ResponseCd'], 'data' => $response_data, ); usces_save_order_acting_error( $log ); wp_redirect( add_query_arg( array( 'acting' => $this->acting_unionpay, 'acting_return' => 0, 'result' => 0, ), USCES_CART_URL ) ); } } exit(); } /* 外部リンク(三者間画面)決済 */ } else { $encryptvalue = openssl_decrypt( $_REQUEST['EncryptValue'], 'aes-128-cbc', $acting_opts['key_aes'], false, $acting_opts['key_iv'] ); if ( $encryptvalue ) { parse_str( $encryptvalue, $response_data ); if ( isset( $response_data['OperateId'] ) && isset( $response_data['ResponseCd'] ) && ( isset( $response_data['MerchantId'] ) && $acting_opts['merchant_id'] === $response_data['MerchantId'] ) ) { $cancel = array( 'P51', 'P52', 'P55', 'P56', 'P62', 'P63', 'P64', 'P65', 'P69', 'P70' ); if ( isset( $response_data['MerchantFree1'] ) && ( isset( $response_data['MerchantFree2'] ) && 'acting_welcart_card' === $response_data['MerchantFree2'] ) ) { if ( 'OK' === $response_data['ResponseCd'] ) { /* 会員登録・会員変更 */ if ( '4MemAdd' === $response_data['OperateId'] || '4MemChg' === $response_data['OperateId'] ) { $member = $usces->get_member(); $usces->set_member_meta_value( 'wcpay_member_id', $response_data['KaiinId'], $member['ID'] ); $usces->set_member_meta_value( 'wcpay_member_passwd', $response_data['KaiinPass'], $member['ID'] ); $usces_entries = $usces->cart->get_entry(); $cart = $usces->cart->get_cart(); if ( usces_have_continue_charge() ) { $chargingday = $usces->getItemChargingDay( $cart[0]['post_id'] ); if ( 99 === (int) $chargingday ) { /* 受注日課金 */ $operateid = $acting_opts['operateid']; } else { $operateid = '1Auth'; } } else { $operateid = $acting_opts['operateid']; } $operateid = apply_filters( 'usces_filter_escott_operateid', $operateid, $cart, $usces_entries['order']['total_full_price'] ); $home_url = str_replace( 'http://', 'https://', home_url( '/' ) ); $redirecturl = $home_url . '?page_id=' . USCES_CART_NUMBER; $data_list = array(); $data_list['OperateId'] = $operateid; $data_list['MerchantPass'] = $acting_opts['merchant_pass']; $data_list['TransactionDate'] = $response_data['TransactionDate']; $data_list['MerchantFree1'] = $response_data['MerchantFree1']; $data_list['MerchantFree2'] = $response_data['MerchantFree2']; $data_list['MerchantFree3'] = $this->merchantfree3; $data_list['TenantId'] = $acting_opts['tenant_id']; $data_list['KaiinId'] = $response_data['KaiinId']; $data_list['KaiinPass'] = $response_data['KaiinPass']; $data_list['PayType'] = '01'; $data_list['Amount'] = $usces_entries['order']['total_full_price']; $data_list['ProcNo'] = '0000000'; if ( isset( $response_data['EncodeXId3D'] ) ) { $data_list['EncodeXId3D'] = $response_data['EncodeXId3D']; } if ( isset( $response_data['TransactionId3D'] ) ) { $data_list['TransactionId3D'] = $response_data['TransactionId3D']; } if ( isset( $response_data['MessageVersionNo3D'] ) ) { $data_list['MessageVersionNo3D'] = $response_data['MessageVersionNo3D']; } if ( isset( $response_data['TransactionStatus3D'] ) ) { $data_list['TransactionStatus3D'] = $response_data['TransactionStatus3D']; } if ( isset( $response_data['CAVVAlgorithm3D'] ) ) { $data_list['CAVVAlgorithm3D'] = $response_data['CAVVAlgorithm3D']; } if ( isset( $response_data['ECI3D'] ) ) { $data_list['ECI3D'] = $response_data['ECI3D']; } if ( isset( $response_data['CAVV3D'] ) ) { $data_list['CAVV3D'] = $response_data['CAVV3D']; } if ( isset( $response_data['SecureResultCode'] ) ) { $data_list['SecureResultCode'] = $response_data['SecureResultCode']; } if ( isset( $response_data['DSTransactionId'] ) ) { $data_list['DSTransactionId'] = $response_data['DSTransactionId']; } if ( isset( $response_data['ThreeDSServerTransactionId'] ) ) { $data_list['ThreeDSServerTransactionId'] = $response_data['ThreeDSServerTransactionId']; } $data_list['RedirectUrl'] = $redirecturl; $data_query = http_build_query( $data_list ); $encryptvalue = openssl_encrypt( $data_query, 'aes-128-cbc', $acting_opts['key_aes'], false, $acting_opts['key_iv'] ); wp_redirect( add_query_arg( array( 'MerchantId' => $acting_opts['merchant_id'], 'EncryptValue' => urlencode( $encryptvalue ), ), $acting_opts['send_url_link'] ) ); exit(); /* 決済 */ } else { $order_data = usces_restore_order_acting_data( $response_data['MerchantFree1'] ); if ( ! empty( $order_data ) ) { $res = $usces->order_processing( $response_data ); if ( 'ordercompletion' === $res ) { $_nonce = ( isset( $order_data['_nonce'] ) ) ? $order_data['_nonce'] : wp_create_nonce( $this->acting_flg_card ); wp_redirect( add_query_arg( array( 'acting' => $this->acting_card, 'acting_return' => 1, 'result' => 1, '_nonce' => $_nonce, ), USCES_CART_URL ) ); } else { $log = array( 'acting' => $this->acting_card, 'key' => $response_data['MerchantFree1'], 'result' => 'ORDER DATA REGISTERED ERROR', 'data' => $response_data, ); usces_save_order_acting_error( $log ); wp_redirect( add_query_arg( array( 'acting' => $this->acting_card, 'acting_return' => 0, 'result' => 0, ), USCES_CART_URL ) ); } } else { $log = array( 'acting' => $this->acting_card, 'key' => $response_data['MerchantFree1'], 'result' => 'ORDER DATA RESTORE ERROR', 'data' => $response_data, ); usces_save_order_acting_error( $log ); wp_redirect( add_query_arg( array( 'acting' => $this->acting_card, 'acting_return' => 0, 'result' => 0, ), USCES_CART_URL ) ); } } } elseif ( in_array( $response_data['ResponseCd'], $cancel, true ) ) { wp_redirect( add_query_arg( array( 'acting' => $this->acting_card, 'confirm' => 1, ), USCES_CART_URL ) ); } else { $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $response_data[ $cd ] = $this->response_message( $cd ); } $log = array( 'acting' => $this->acting_card, 'key' => $response_data['MerchantFree1'], 'result' => $response_data['ResponseCd'], 'data' => $response_data, ); usces_save_order_acting_error( $log ); wp_redirect( add_query_arg( array( 'acting' => $this->acting_card, 'acting_return' => 0, 'result' => 0, ), USCES_CART_URL ) ); } } else { /* マイページからの会員登録・会員変更 */ if ( '4MemAdd' === $response_data['OperateId'] || '4MemChg' === $response_data['OperateId'] ) { if ( 'OK' === $response_data['ResponseCd'] ) { $member = $usces->get_member(); $usces->set_member_meta_value( 'wcpay_member_id', $response_data['KaiinId'], $member['ID'] ); $usces->set_member_meta_value( 'wcpay_member_passwd', $response_data['KaiinPass'], $member['ID'] ); } elseif ( in_array( $response_data['ResponseCd'], $cancel ) ) { // phpcs:ignore } else { usces_log( '[WelcartPay] 4MemChg NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } wp_redirect( USCES_MEMBER_URL ); } } exit(); } } } } } /** * 管理画面決済処理 * usces_action_admin_ajax */ public function admin_ajax() { global $usces; $mode = filter_input( INPUT_POST, 'mode', FILTER_DEFAULT ); $data = array(); switch ( $mode ) { /* 取引参照 */ case 'get_welcartpay_card': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $order_num = filter_input( INPUT_POST, 'order_num' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) { $data['status'] = 'NG'; $data['result'] = ''; wp_send_json( $data ); break; } $res = ''; $log_data = array(); if ( '9999999999' === $trans_id ) { $member_id = filter_input( INPUT_POST, 'member_id' ); $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員照会 */ if ( 'OK' === $response_member['ResponseCd'] ) { $order_data = $usces->get_order_data( $order_id, 'direct' ); $total_full_price = $order_data['order_item_total_price'] - $order_data['order_usedpoint'] + $order_data['order_discount'] + $order_data['order_shipping_charge'] + $order_data['order_cod_fee'] + $order_data['order_tax']; $res .= '
' . __( 'New', 'usces' ) . '
'; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= '
' . __( 'Spending amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
'; $res .= '
'; $res .= ''; /* 与信 */ $res .= ''; /* 与信売上計上 */ $res .= '
'; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; $res .= '
'; $res .= '
' . __( 'Credit card information not registered', 'usces' ) . '
'; /* カード情報未登録 */ $res .= '
'; } $data['status'] = 'OK'; $data['result'] = $res; } else { if ( 1 === (int) $order_num ) { $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) ); } else { $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id ); $acting_data = usces_unserialize( $log_data[0]['log'] ); } $operateid = $this->get_acting_operateid( $order_id . '_' . $trans_id ); $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_card'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $params['send_url'] = $acting_opts['send_url']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '1Search', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], ) ); $response_data = $this->connection( $params ); if ( 'OK' === $response_data['ResponseCd'] ) { $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id ); if ( isset( $latest_log['OperateId'] ) ) { $class = ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 1 ) ); $status_name = $this->get_operate_name( $latest_log['OperateId'] ); $res .= '
' . $status_name . '
'; $res .= ''; if ( isset( $response_data['Amount'] ) ) { $res .= ''; $res .= ''; $res .= ''; } if ( isset( $response_data['SalesDate'] ) ) { $res .= ''; } $res .= '
' . __( 'Spending amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
' . __( 'Recorded sales date', 'usces' ) . '' . $response_data['SalesDate'] . '
'; $res .= '
'; if ( '1Delete' === $latest_log['OperateId'] ) { $res .= ''; /* 再オーソリ */ } else { if ( '1Auth' === $operateid && '1Capture' !== $latest_log['OperateId'] && '1Gathering' !== $latest_log['OperateId'] ) { $res .= ''; /* 再オーソリ */ $res .= ''; /* 売上計上 */ } if ( '1Delete' !== $latest_log['OperateId'] ) { $res .= ''; /* 取消 */ } if ( '1Change' !== $latest_log['OperateId'] ) { $res .= ''; /* 利用額変更 */ } } $res .= '
'; } } else { if ( 'K12' === $response_data['ResponseCd'] ) { $res .= '
' . __( 'Expired', 'usces' ) . '
'; $res .= '
'; $res .= '
K12 : ' . __( 'Handling expired.', 'usces' ) . '
'; $res .= '
'; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 1Search connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } } $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['result'] = $res; } wp_send_json( $data ); break; /* 売上計上 */ case 'capture_welcartpay_card': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $order_num = filter_input( INPUT_POST, 'order_num' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); $amount = filter_input( INPUT_POST, 'amount' ); if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $acting_status = ''; $log_data = array(); if ( 1 === (int) $order_num ) { $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) ); } else { $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id ); $acting_data = usces_unserialize( $log_data[0]['log'] ); } $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_card'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $member_id = filter_input( INPUT_POST, 'member_id' ); $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員照会 */ if ( 'OK' === $response_member['ResponseCd'] ) { $param_list['KaiinId'] = $response_member['KaiinId']; $param_list['KaiinPass'] = $response_member['KaiinPass']; } $params['send_url'] = $acting_opts['send_url']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '1Capture', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], 'SalesDate' => $transaction_date, ) ); $response_data = $this->connection( $params ); if ( 'K81' === $response_data['ResponseCd'] ) { $param_list['KaiinId'] = ''; $param_list['KaiinPass'] = ''; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '1Capture', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], 'SalesDate' => $transaction_date, ) ); $response_data = $this->connection( $params ); } if ( 'OK' === $response_data['ResponseCd'] ) { $class = ' card-' . mb_strtolower( substr( $response_data['OperateId'], 1 ) ); $status_name = $this->get_operate_name( $response_data['OperateId'] ); $res .= '
' . $status_name . '
'; $res .= ''; $res .= ''; $res .= ''; $res .= ''; if ( isset( $response_data['SalesDate'] ) ) { $res .= ''; } $res .= '
' . __( 'Spending amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
' . __( 'Recorded sales date', 'usces' ) . '' . $response_data['SalesDate'] . '
'; $res .= '
'; $res .= ''; /* 取消 */ $res .= ''; /* 利用額変更 */ $res .= '
'; $acting_status = '' . $status_name . ''; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 1Capture connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = $amount; } $response_data = apply_filters( 'usces_filter_escott_capture_history_log', $response_data, $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id ); $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['acting_status'] = $acting_status; $data['result'] = $res; $this->save_admin_log( $order_id, $order_id . '_' . $trans_id ); wp_send_json( $data ); break; /* 取消/返品 */ case 'delete_welcartpay_card': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $order_num = filter_input( INPUT_POST, 'order_num' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); $amount = filter_input( INPUT_POST, 'amount' ); if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $acting_status = ''; $log_data = array(); if ( 1 === (int) $order_num ) { $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) ); } else { $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id ); $acting_data = usces_unserialize( $log_data[0]['log'] ); } $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_card'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $member_id = filter_input( INPUT_POST, 'member_id' ); $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員照会 */ if ( 'OK' === $response_member['ResponseCd'] ) { $param_list['KaiinId'] = $response_member['KaiinId']; $param_list['KaiinPass'] = $response_member['KaiinPass']; } $params['send_url'] = $acting_opts['send_url']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '1Delete', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], ) ); $response_data = $this->connection( $params ); if ( 'K81' === $response_data['ResponseCd'] ) { $param_list['KaiinId'] = ''; $param_list['KaiinPass'] = ''; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '1Delete', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], ) ); $response_data = $this->connection( $params ); } if ( 'OK' === $response_data['ResponseCd'] ) { $class = ' card-' . mb_strtolower( substr( $response_data['OperateId'], 1 ) ); $status_name = $this->get_operate_name( $response_data['OperateId'] ); $res .= '
' . $status_name . '
'; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= '
' . __( 'Spending amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
'; $res .= '
'; $res .= ''; /* 再オーソリ */ $res .= '
'; $acting_status = '' . $status_name . ''; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 1Delete connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = $amount; } $response_data = apply_filters( 'usces_filter_escott_delete_history_log', $response_data, $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id ); $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['acting_status'] = $acting_status; $data['result'] = $res; $this->save_admin_log( $order_id, $order_id . '_' . $trans_id ); wp_send_json( $data ); break; /* 利用額変更 */ case 'change_welcartpay_card': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $order_num = filter_input( INPUT_POST, 'order_num' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); $amount = filter_input( INPUT_POST, 'amount' ); if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) || is_null( $amount ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $log_data = array(); if ( 1 === (int) $order_num ) { $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) ); } else { $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id ); $acting_data = usces_unserialize( $log_data[0]['log'] ); } $operateid = $this->get_acting_operateid( $order_id . '_' . $trans_id ); $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_card'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $member_id = filter_input( INPUT_POST, 'member_id' ); $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員照会 */ if ( 'OK' === $response_member['ResponseCd'] ) { $param_list['KaiinId'] = $response_member['KaiinId']; $param_list['KaiinPass'] = $response_member['KaiinPass']; } $params['send_url'] = $acting_opts['send_url']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '1Change', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], 'Amount' => $amount, ) ); $response_data = $this->connection( $params ); if ( 'K81' === $response_data['ResponseCd'] ) { $param_list['KaiinId'] = ''; $param_list['KaiinPass'] = ''; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '1Change', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], 'Amount' => $amount, ) ); $response_data = $this->connection( $params ); } if ( 'OK' === $response_data['ResponseCd'] ) { $class = ' card-' . mb_strtolower( substr( $operateid, 1 ) ); $status_name = $this->get_operate_name( $operateid ); $res .= '
' . $status_name . '
'; $res .= ''; $res .= ''; $res .= ''; $res .= ''; if ( isset( $response_data['SalesDate'] ) ) { $res .= ''; } $res .= '
' . __( 'Spending amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
' . __( 'Recorded sales date', 'usces' ) . '' . $response_data['SalesDate'] . '
'; $res .= '
'; if ( '1Capture' !== $operateid && '1Gathering' !== $operateid ) { $res .= ''; /* 売上計上 */ } $res .= ''; /* 取消 */ $res .= ''; /* 利用額変更 */ $res .= '
'; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; /* エラー */ $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 1Change connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = $amount; } $response_data = apply_filters( 'usces_filter_escott_change_history_log', $response_data, $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id ); $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['result'] = $res; $this->save_admin_log( $order_id, $order_id . '_' . $trans_id ); wp_send_json( $data ); break; /* 与信 */ case 'auth_welcartpay_card': /* 与信売上計上 */ case 'gathering_welcartpay_card': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $order_num = filter_input( INPUT_POST, 'order_num' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); $amount = filter_input( INPUT_POST, 'amount' ); if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) || is_null( $amount ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $acting_status = ''; $log_data = array(); if ( '9999999999' === $trans_id ) { $trans_id = usces_acting_key(); } else { if ( 1 === (int) $order_num ) { $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) ); } else { $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id ); $acting_data = usces_unserialize( $log_data[0]['log'] ); } } $operateid = ( 'auth_welcartpay_card' === $mode ) ? '1Auth' : '1Gathering'; $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_card'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $member_id = filter_input( INPUT_POST, 'member_id' ); $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員照会 */ if ( 'OK' === $response_member['ResponseCd'] ) { $params['send_url'] = $acting_opts['send_url']; $params['param_list'] = array_merge( $param_list, array( 'KaiinId' => $response_member['KaiinId'], 'KaiinPass' => $response_member['KaiinPass'], 'OperateId' => $operateid, 'PayType' => '01', 'Amount' => $amount, ) ); $response_data = $this->connection( $params ); if ( 'OK' === $response_data['ResponseCd'] ) { if ( 1 === (int) $order_num ) { $cardlast4 = substr( $response_member['CardNo'], -4 ); $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 ); $expmm = substr( $response_member['CardExp'], 2, 2 ); $response_data['acting'] = $this->acting_card; $response_data['CardNo'] = $cardlast4; $response_data['CardExp'] = $expyy . '/' . $expmm; $usces->set_order_meta_value( 'acting_welcart_card', usces_serialize( $response_data ), $order_id ); $usces->set_order_meta_value( 'trans_id', $trans_id, $order_id ); $usces->set_order_meta_value( 'wc_trans_id', $trans_id, $order_id ); } else { if ( $log_data ) { $this->update_acting_log( $response_data, $order_id . '_' . $trans_id ); } } $class = ' card-' . mb_strtolower( substr( $operateid, 1 ) ); $status_name = $this->get_operate_name( $operateid ); $res .= '
' . $status_name . '
'; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= '
' . __( 'Spending amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
'; $res .= '
'; if ( '1Capture' !== $operateid && '1Gathering' !== $operateid ) { $res .= ''; /* 売上計上 */ } $res .= ''; /* 取消 */ $res .= ''; /* 利用額変更 */ $res .= '
'; $acting_status = '' . $status_name . ''; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; /* エラー */ $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] ' . $operateid . ' connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = $amount; } $response_data = apply_filters( 'usces_filter_escott_' . mb_strtolower( substr( $operateid, 1 ) ) . '_history_log', $response_data, $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id ); $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['acting_status'] = $acting_status; $data['result'] = $res; $data['trans_id'] = $trans_id; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; /* エラー */ $res .= '
'; $responsecd = explode( '|', $response_member['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 4MemRefM connection NG : ' . print_r( $response_member, true ), 'acting_transaction.log' ); $data['status'] = $response_member['ResponseCd']; $data['result'] = $res; } wp_send_json( $data ); break; /* 再オーソリ */ case 'reauth_welcartpay_card': check_admin_referer( 'order_edit', 'wc_nonce' ); $res = ''; $order_id = filter_input( INPUT_POST, 'order_id' ); $order_num = filter_input( INPUT_POST, 'order_num' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); $amount = filter_input( INPUT_POST, 'amount' ); if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) || is_null( $amount ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $acting_status = ''; if ( 1 === (int) $order_num ) { $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) ); } else { $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id ); $acting_data = usces_unserialize( $log_data[0]['log'] ); } $operateid = $this->get_acting_operateid( $order_id . '_' . $trans_id ); $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_card'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $member_id = filter_input( INPUT_POST, 'member_id' ); $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員照会 */ if ( 'OK' === $response_member['ResponseCd'] ) { $param_list['KaiinId'] = $response_member['KaiinId']; $param_list['KaiinPass'] = $response_member['KaiinPass']; } // if ( '1Gathering' === $operateid ) { $param_list['SalesDate'] = $transaction_date; // } $params['send_url'] = $acting_opts['send_url']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '1ReAuth', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], 'Amount' => $amount, ) ); $response_data = $this->connection( $params ); if ( 'K81' === $response_data['ResponseCd'] ) { $param_list['KaiinId'] = ''; $param_list['KaiinPass'] = ''; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '1ReAuth', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], 'Amount' => $amount, ) ); $response_data = $this->connection( $params ); } if ( 'OK' === $response_data['ResponseCd'] ) { $acting_data['TransactionId'] = $response_data['TransactionId']; $acting_data['TransactionDate'] = $response_data['TransactionDate']; $acting_data['ProcessId'] = $response_data['ProcessId']; $acting_data['ProcessPass'] = $response_data['ProcessPass']; $usces->set_order_meta_value( 'acting_welcart_card', usces_serialize( $acting_data ), $order_id ); $class = ' card-' . mb_strtolower( substr( $operateid, 1 ) ); $status_name = $this->get_operate_name( $operateid ); $res .= '
' . $status_name . '
'; $res .= ''; $res .= ''; $res .= ''; $res .= ''; if ( isset( $response_data['SalesDate'] ) ) { $res .= ''; } $res .= '
' . __( 'Spending amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
' . __( 'Recorded sales date', 'usces' ) . '' . $response_data['SalesDate'] . '
'; $res .= '
'; if ( '1Capture' !== $operateid && '1Gathering' !== $operateid ) { $res .= ''; /* 売上計上 */ } $res .= ''; /* 取消 */ $res .= ''; /* 利用額変更 */ $res .= '
'; $acting_status = '' . $status_name . ''; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; /* エラー */ $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 1ReAuth connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = $amount; } $response_data = apply_filters( 'usces_filter_escott_reauth_history_log', $response_data, $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id ); $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['acting_status'] = $acting_status; $data['result'] = $res; $this->save_admin_log( $order_id, $order_id . '_' . $trans_id ); wp_send_json( $data ); break; /* 決済エラー */ case 'error_welcartpay_card': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $order_num = filter_input( INPUT_POST, 'order_num' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) { $data['status'] = 'NG'; $data['result'] = ''; wp_send_json( $data ); break; } $res = ''; $member_id = filter_input( INPUT_POST, 'member_id' ); $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員照会 */ if ( 'OK' === $response_member['ResponseCd'] ) { $order_data = $usces->get_order_data( $order_id, 'direct' ); $total_full_price = $order_data['order_item_total_price'] - $order_data['order_usedpoint'] + $order_data['order_discount'] + $order_data['order_shipping_charge'] + $order_data['order_cod_fee'] + $order_data['order_tax']; $res .= '
' . __( 'Repayment', 'usces' ) . '
'; /* 再決済 */ $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= '
' . __( 'Spending amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
'; $res .= '
'; $res .= ''; /* 与信 */ $res .= ''; /* 与信売上計上 */ $res .= '
'; $res .= $this->settlement_history( $order_id . '_' . $trans_id ); } else { $res .= '
' . __( 'Settlement error', 'usces' ) . '
'; /* エラー */ $res .= '
'; $res .= '
' . __( 'Credit card information not registered', 'usces' ) . '
'; /* カード情報未登録 */ $res .= '
'; } $data['status'] = 'OK'; $data['result'] = $res; wp_send_json( $data ); break; /* 継続課金情報更新 */ case 'continuation_update': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $member_id = filter_input( INPUT_POST, 'member_id' ); $contracted_year = filter_input( INPUT_POST, 'contracted_year' ); $contracted_month = filter_input( INPUT_POST, 'contracted_month' ); $contracted_day = filter_input( INPUT_POST, 'contracted_day' ); $charged_year = filter_input( INPUT_POST, 'charged_year' ); $charged_month = filter_input( INPUT_POST, 'charged_month' ); $charged_day = filter_input( INPUT_POST, 'charged_day' ); $price = filter_input( INPUT_POST, 'price' ); if ( is_null( $price ) ) { $price = 0; } $status = filter_input( INPUT_POST, 'status' ); if ( version_compare( WCEX_DLSELLER_VERSION, '3.0-beta', '<=' ) ) { $continue_data = usces_unserialize( $usces->get_member_meta_value( 'continuepay_' . $order_id, $member_id ) ); } else { $continue_data = $this->get_continuation_data( $order_id, $member_id ); } if ( ! $continue_data ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } /* 継続中→停止 */ if ( 'continuation' === $continue_data['status'] && 'cancellation' === $status ) { if ( version_compare( WCEX_DLSELLER_VERSION, '3.0-beta', '<=' ) ) { $continue_data['status'] = 'cancellation'; $usces->set_member_meta_value( 'continuepay_' . $order_id, usces_serialize( $continue_data ), $member_id ); } else { $this->update_continuation_data( $order_id, $member_id, $continue_data, true ); } } else { if ( ! empty( $contracted_year ) && ! empty( $contracted_month ) && ! empty( $contracted_day ) ) { $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday']; if ( $contracted_date ) { $new_contracted_date = $contracted_year . '-' . $contracted_month . '-' . $contracted_day; if ( ! $this->isdate( $new_contracted_date ) ) { $data['status'] = 'NG'; $data['message'] = __( 'Next contract renewal date is incorrect.', 'dlseller' ); wp_send_json( $data ); } } } else { $new_contracted_date = ''; } $new_charged_date = $charged_year . '-' . $charged_month . '-' . $charged_day; if ( ! $this->isdate( $new_charged_date ) ) { $data['status'] = 'NG'; $data['message'] = __( 'Next settlement date is incorrect.', 'dlseller' ); wp_send_json( $data ); } $tomorrow = date_i18n( 'Y-m-d', strtotime( '+1 day' ) ); if ( $new_charged_date < $tomorrow ) { $data['status'] = 'NG'; $data['message'] = sprintf( __( 'The next settlement date must be after %s.', 'dlseller' ), $tomorrow ); wp_send_json( $data ); } $continue_data['contractedday'] = $new_contracted_date; $continue_data['chargedday'] = $new_charged_date; $continue_data['price'] = usces_crform( $price, false, false, 'return', false ); $continue_data['status'] = $status; if ( version_compare( WCEX_DLSELLER_VERSION, '3.0-beta', '<=' ) ) { $usces->set_member_meta_value( 'continuepay_' . $order_id, usces_serialize( $continue_data ), $member_id ); } else { $this->update_continuation_data( $order_id, $member_id, $continue_data ); } } $data['status'] = 'OK'; wp_send_json( $data ); break; /* オンライン収納代行データ登録 */ case 'add_welcartpay_conv': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); $paylimit = filter_input( INPUT_POST, 'paylimit' ); $amount = filter_input( INPUT_POST, 'amount' ); if ( is_null( $order_id ) || is_null( $trans_id ) || is_null( $paylimit ) || is_null( $amount ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $acting_status = ''; $order_data = $usces->get_order_data( $order_id, 'direct' ); $namekanji = $order_data['order_name1'] . $order_data['order_name2']; $namekana = ( ! empty( $order_data['order_name3'] ) ) ? $order_data['order_name3'] . $order_data['order_name4'] : $namekanji; $telno = $order_data['order_tel']; $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_conv'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $params['send_url'] = $acting_opts['send_url_conv']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '2Add', 'PayLimit' => $paylimit . '2359', 'Amount' => $amount, 'NameKanji' => $namekanji, 'NameKana' => $namekana, 'TelNo' => $telno, 'ReturnURL' => home_url( '/' ), ) ); $response_data = $this->connection( $params ); if ( 'OK' === $response_data['ResponseCd'] ) { $response_data['acting'] = $this->acting_conv; $response_data['PayLimit'] = $params['param_list']['PayLimit']; $response_data['Amount'] = $params['param_list']['Amount']; $usces->set_order_meta_value( 'acting_welcart_conv', usces_serialize( $response_data ), $order_id ); $freearea = trim( $response_data['FreeArea'] ); $url = add_query_arg( array( 'code' => $freearea, 'rkbn' => 2, ), $acting_opts['redirect_url_conv'] ); $usces->set_order_meta_value( 'welcart_conv_url', $url, $order_id ); $res .= '
' . __( 'Unpaid', 'usces' ) . '
'; /* 未入金 */ $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= '
' . __( 'Payment due', 'usces' ) . '
' . __( 'Payment amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
'; $res .= '
'; $res .= ''; /* 取消 */ $res .= ''; /* 変更 */ $res .= '
'; $acting_status = '' . __( 'Unpaid', 'usces' ) . ''; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; /* エラー */ $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 2Add connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = $amount; } $response_data = apply_filters( 'usces_filter_escott_add_conv_history_log', $response_data, $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id ); $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['acting_status'] = $acting_status; $data['result'] = $res; wp_send_json( $data ); break; /* オンライン収納代行データ変更 */ case 'change_welcartpay_conv': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); $paylimit = filter_input( INPUT_POST, 'paylimit' ); $amount = filter_input( INPUT_POST, 'amount' ); if ( is_null( $order_id ) || is_null( $trans_id ) || is_null( $paylimit ) || is_null( $amount ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_conv', $order_id ) ); $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_conv'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $params['send_url'] = $acting_opts['send_url_conv']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '2Chg', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], 'PayLimit' => $paylimit . '2359', 'Amount' => $amount, ) ); $response_data = $this->connection( $params ); if ( 'OK' === $response_data['ResponseCd'] ) { $acting_data['PayLimit'] = $params['param_list']['PayLimit']; $acting_data['Amount'] = $params['param_list']['Amount']; $usces->set_order_meta_value( 'acting_welcart_conv', usces_serialize( $acting_data ), $order_id ); $freearea = trim( $response_data['FreeArea'] ); $url = add_query_arg( array( 'code' => $freearea, 'rkbn' => 2, ), $acting_opts['redirect_url_conv'] ); $usces->set_order_meta_value( 'welcart_conv_url', $url, $order_id ); $res .= '
' . __( 'Unpaid', 'usces' ) . '
'; /* 未入金 */ $res .= ''; if ( isset( $acting_data['PayLimit'] ) ) { $res .= ''; } if ( isset( $acting_data['Amount'] ) ) { $res .= ''; } $res .= '
' . __( 'Payment due', 'usces' ) . '' . $acting_data['PayLimit'] . '
' . __( 'Payment amount', 'usces' ) . '' . $acting_data['Amount'] . '
'; $res .= '
'; $res .= ''; /* 取消 */ $res .= '
'; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; /* エラー */ $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 2Chg connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = $amount; } $response_data = apply_filters( 'usces_filter_escott_change_conv_history_log', $response_data, $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id ); $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['result'] = $res; wp_send_json( $data ); break; /* オンライン収納代行データ削除 */ case 'delete_welcartpay_conv': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); $amount = filter_input( INPUT_POST, 'amount' ); if ( is_null( $order_id ) || is_null( $trans_id ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $acting_status = ''; $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_conv', $order_id ) ); $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_conv'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $params['send_url'] = $acting_opts['send_url_conv']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '2Del', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], ) ); $response_data = $this->connection( $params ); if ( 'OK' === $response_data['ResponseCd'] ) { $res .= '
' . __( 'Canceled', 'usces' ) . '
'; /* 取消済み */ $res .= ''; if ( isset( $acting_data['PayLimit'] ) ) { $paylimit = substr( $acting_data['PayLimit'], 0, 8 ); $res .= ''; } if ( isset( $acting_data['Amount'] ) ) { $res .= ''; } $res .= '
' . __( 'Payment due', 'usces' ) . '' . $paylimit . '
' . __( 'Payment amount', 'usces' ) . '' . $acting_data['Amount'] . '
'; $acting_status = '' . __( 'Canceled', 'usces' ) . ''; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; /* エラー */ $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 2Del connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = ( isset( $acting_data['Amount'] ) ) ? $acting_data['Amount'] : $amount; } $response_data = apply_filters( 'usces_filter_escott_delete_conv_history_log', $response_data, $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id ); $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['acting_status'] = $acting_status; $data['result'] = $res; wp_send_json( $data ); break; /* オンライン収納代行データ入金結果参照 */ case 'get_welcartpay_conv': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); if ( is_null( $order_id ) || is_null( $trans_id ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_conv', $order_id ) ); $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_conv'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $params['send_url'] = $acting_opts['send_url_conv']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '2Ref', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], ) ); $response_data = $this->connection( $params ); if ( 'OK' === $response_data['ResponseCd'] ) { if ( isset( $response_data['NyukinDate'] ) ) { $res .= '
' . __( 'Paid', 'usces' ) . '
'; /* 入金済 */ $res .= ''; if ( isset( $response_data['RecvNum'] ) ) { $res .= ''; /* 受付番号 */ } if ( isset( $response_data['NyukinDate'] ) ) { $res .= ''; /* 入金日時 */ } if ( isset( $response_data['CvsCd'] ) ) { $cvs_name = $this->get_cvs_name( $response_data['CvsCd'] ); $res .= ''; /* 収納機関コード */ } if ( isset( $response_data['TenantCd'] ) ) { $res .= ''; /* 店舗コード */ } if ( isset( $response_data['Amount'] ) ) { $res .= ''; } $res .= '
' . __( 'Receipt number', 'usces' ) . '' . $response_data['RecvNum'] . '
' . __( 'Deposit date', 'usces' ) . '' . $response_data['NyukinDate'] . '
' . __( 'Convenience store code', 'usces' ) . '' . $cvs_name . '
' . __( 'Tenant code', 'usces' ) . '' . $response_data['TenantCd'] . '
' . __( 'Payment amount', 'usces' ) . '' . $response_data['Amount'] . __( usces_crcode( 'return' ), 'usces' ) . '
'; } else { $paylimit = substr( $acting_data['PayLimit'], 0, 8 ); $expiration = $this->check_paylimit( $order_id, $trans_id ); $res .= '
' . __( 'Unpaid', 'usces' ); /* 未入金 */ if ( $expiration ) { $res .= __( '(Expired)', 'usces' ); /* (期限切れ) */ } $res .= '
'; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= '
' . __( 'Payment due', 'usces' ) . '
' . __( 'Payment amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
'; $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id ); if ( isset( $latest_log['OperateId'] ) ) { $res .= '
'; if ( '2Del' !== $latest_log['OperateId'] ) { $res .= ''; /* 取消 */ } if ( '2Chg' !== $latest_log['OperateId'] ) { $res .= ''; /* 変更 */ } $res .= '
'; } } } else { $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id ); if ( isset( $latest_log['OperateId'] ) && '2Del' === $latest_log['OperateId'] && 'K12' === $response_data['ResponseCd'] ) { $paylimit = substr( $acting_data['PayLimit'], 0, 8 ); $res .= '
' . __( 'Canceled', 'usces' ) . '
'; /* 取消済み */ $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= '
' . __( 'Payment due', 'usces' ) . '
' . __( 'Payment amount', 'usces' ) . '' . __( usces_crcode( 'return' ), 'usces' ) . '
'; $res .= '
'; $res .= ''; /* 登録 */ $res .= '
'; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; /* エラー */ $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 2Ref connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } } $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['result'] = $res; wp_send_json( $data ); break; /* 銀聯取引参照 */ case 'get_welcartpay_unionpay': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $order_num = filter_input( INPUT_POST, 'order_num' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $log_data = array(); $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_unionpay', $order_id ) ); $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_unionpay'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $params['send_url'] = $acting_opts['send_url_unionpay']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '11Search', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], ) ); $response_data = $this->connection( $params ); if ( 'OK' === $response_data['ResponseCd'] ) { $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id ); if ( isset( $latest_log['OperateId'] ) ) { $class = ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 2 ) ); $status_name = $this->get_operate_name( $latest_log['OperateId'] ); $res .= '
' . $status_name . '
'; $res .= ''; if ( isset( $latest_log['Amount'] ) ) { $res .= ''; } if ( isset( $latest_log['Status'] ) ) { $res .= ''; } $res .= '
' . __( 'Spending amount', 'usces' ) . '' . usces_crform( $latest_log['Amount'], false, true, 'return', true ) . '
' . __( 'Transaction status', 'usces' ) . '' . $this->get_unionpay_status_name( $latest_log['Status'] ) . '
'; $res .= '
'; if ( '11Delete' !== $latest_log['OperateId'] ) { $res .= ''; /* 取消 */ } $res .= '
'; } } else { if ( 'K12' === $response_data['ResponseCd'] ) { $res .= '
' . __( 'Expired', 'usces' ) . '
'; $res .= '
'; $res .= '
K12 : ' . __( 'Handling expired.', 'usces' ) . '
'; $res .= '
'; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 11Search connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } } $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['result'] = $res; wp_send_json( $data ); break; /* 銀聯取消 */ case 'delete_welcartpay_unionpay': check_admin_referer( 'order_edit', 'wc_nonce' ); $order_id = filter_input( INPUT_POST, 'order_id' ); $order_num = filter_input( INPUT_POST, 'order_num' ); $trans_id = filter_input( INPUT_POST, 'trans_id' ); $amount = filter_input( INPUT_POST, 'amount' ); if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) { $data['status'] = 'NG'; wp_send_json( $data ); break; } $res = ''; $acting_status = ''; $log_data = array(); $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_unionpay', $order_id ) ); $acting_opts = $this->get_acting_settings(); $transaction_date = $this->get_transaction_date(); $param_list = array(); $params = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $trans_id; $param_list['MerchantFree2'] = 'acting_welcart_unionpay'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $params['send_url'] = $acting_opts['send_url_unionpay']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => '11Delete', 'ProcessId' => $acting_data['ProcessId'], 'ProcessPass' => $acting_data['ProcessPass'], ) ); $response_data = $this->connection( $params ); if ( 'OK' === $response_data['ResponseCd'] ) { $class = ' card-' . mb_strtolower( substr( $response_data['OperateId'], 2 ) ); $status_name = $this->get_operate_name( $response_data['OperateId'] ); $res .= '
' . $status_name . '
'; $res .= ''; $res .= ''; $res .= '
' . __( 'Spending amount', 'usces' ) . '' . usces_crform( $amount, false, true, 'return', true ) . '
'; $acting_status = '' . $status_name . ''; } else { $res .= '
' . __( 'Error', 'usces' ) . '
'; $res .= '
'; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $res .= '
' . $cd . ' : ' . $this->response_message( $cd ) . '
'; } $res .= '
'; usces_log( '[WelcartPay] 11Delete connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' ); } do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = $amount; } $response_data = apply_filters( 'usces_filter_escott_delete_unionpay_history_log', $response_data, $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id ); $res .= $this->settlement_history( $order_id . '_' . $trans_id ); $data['status'] = $response_data['ResponseCd']; $data['acting_status'] = $acting_status; $data['result'] = $res; wp_send_json( $data ); break; } } /** * 決済状況 * usces_filter_orderlist_detail_value * * @param string $detail HTML. * @param string $value Settlement info key. * @param string $key Settlement info value. * @param int $order_id Order number. * @return array */ public function orderlist_settlement_status( $detail, $value, $key, $order_id ) { global $usces; if ( 'wc_trans_id' !== $key || empty( $value ) ) { return $detail; } $order_data = $usces->get_order_data( $order_id, 'direct' ); $payment = usces_get_payments_by_name( $order_data['order_payment_name'] ); $acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : ''; if ( 'acting_welcart_card' === $acting_flg ) { $trans_id = $usces->get_order_meta_value( 'trans_id', $order_id ); $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id ); if ( isset( $latest_log['OperateId'] ) ) { $class = ( ctype_digit( substr( $latest_log['OperateId'], 0, 1 ) ) ) ? ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 1 ) ) : ' card-' . $latest_log['OperateId']; $detail = '' . $value . '' . $this->get_operate_name( $latest_log['OperateId'] ) . ''; } elseif ( defined( 'WCEX_AUTO_DELIVERY' ) ) { $regular_id = $usces->get_order_meta_value( 'regular_id', $order_id ); if ( ! empty( $regular_id ) && empty( $trans_id ) ) { $detail = '' . $value . '' . __( 'Card unregistered', 'usces' ) . ''; } } } elseif ( 'acting_welcart_conv' === $acting_flg ) { $trans_id = $usces->get_order_meta_value( 'trans_id', $order_id ); $expiration = $this->check_paylimit( $order_id, $trans_id ); if ( $expiration ) { if ( ! $usces->is_status( 'receipted', $order_data['order_status'] ) ) { $detail = '' . $value . '' . __( 'Expired', 'usces' ) . ''; } } else { $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id ); if ( isset( $latest_log['OperateId'] ) && '2Del' === $latest_log['OperateId'] ) { $detail = '' . $value . '' . __( 'Canceled', 'usces' ) . ''; } else { $management_status = apply_filters( 'usces_filter_management_status', get_option( 'usces_management_status' ) ); if ( $usces->is_status( 'noreceipt', $value ) ) { $detail = '' . $value . '' . esc_html( $management_status['noreceipt'] ) . ''; } elseif ( $usces->is_status( 'receipted', $value ) ) { $detail = '' . $value . '' . esc_html( $management_status['receipted'] ) . ''; } else { $detail = '' . $value . ''; } } } } elseif ( 'acting_welcart_unionpay' === $acting_flg ) { $trans_id = $usces->get_order_meta_value( 'trans_id', $order_id ); $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id ); if ( isset( $latest_log['OperateId'] ) ) { $class = ( ctype_digit( substr( $latest_log['OperateId'], 0, 2 ) ) ) ? ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 2 ) ) : ' card-' . $latest_log['OperateId']; $detail = '' . $value . '' . $this->get_operate_name( $latest_log['OperateId'] ) . ''; } } return $detail; } /** * 受注編集画面に表示する決済情報の値整形 * usces_filter_settle_info_field_value * * @param string $value Settlement information value. * @param string $key Settlement information key. * @param string $acting Acting type. * @return string */ public function settlement_info_field_value( $value, $key, $acting ) { if ( 'welcart_card' !== $acting && 'welcart_conv' !== $acting && 'welcart_atodene' !== $acting && 'welcart_applepay' !== $acting && 'welcart_unionpay' !== $acting ) { return $value; } switch ( $key ) { case 'acting': switch ( $value ) { case 'welcart_card': $value = __( 'WelcartPay - Credit card transaction', 'usces' ); break; case 'welcart_conv': $value = __( 'WelcartPay - Online storage agency', 'usces' ); break; case 'welcart_atodene': $value = __( 'WelcartPay - Postpay settlement', 'usces' ); break; case 'welcart_applepay': $value = __( 'WelcartPay - Apple Pay', 'usces' ); break; case 'welcart_unionpay': $value = __( 'WelcartPay - UnionPay', 'usces' ); break; } break; } $value = parent::settlement_info_field_value( $value, $key, $acting ); return $value; } /** * 受注編集画面【ステータス】 * usces_action_order_edit_form_status_block_middle * * @param array $data Order data. * @param array $cscs_meta Custom field data. * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ). */ public function settlement_status( $data, $cscs_meta, $action_args ) { global $usces; extract( $action_args ); // phpcs:ignore if ( 'new' !== $order_action && ! empty( $order_id ) ) { $payment = usces_get_payments_by_name( $data['order_payment_name'] ); if ( in_array( $payment['settlement'], $this->pay_method ) ) { $acting_data = usces_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) ); $merchantfree1 = ( isset( $acting_data['MerchantFree1'] ) ) ? $acting_data['MerchantFree1'] : ''; if ( ! empty( $merchantfree1 ) ) { $status_name = ''; $class = ''; $latest_log = $this->get_acting_latest_log( $order_id . '_' . $merchantfree1 ); if ( isset( $latest_log['OperateId'] ) ) { switch ( $payment['settlement'] ) { case 'acting_welcart_conv': $expiration = $this->check_paylimit( $order_id, $merchantfree1 ); if ( $expiration ) { if ( ! $usces->is_status( 'receipted', $data['order_status'] ) ) { $class = ' conv-expiration'; $status_name = __( 'Expired', 'usces' ); } } else { if ( '2Del' === $latest_log['OperateId'] ) { $class = ' conv-del'; $status_name = __( 'Canceled', 'usces' ); } } break; case 'acting_welcart_card': $class = ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 1 ) ); $status_name = $this->get_operate_name( $latest_log['OperateId'] ); break; case 'acting_welcart_unionpay': $class = ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 2 ) ); $status_name = $this->get_operate_name( $latest_log['OperateId'] ); break; } if ( ! empty( $status_name ) ) { echo ' ' . esc_html__( 'Settlement status', 'usces' ) . ' ' . esc_html( $status_name ) . ' '; } } } elseif ( defined( 'WCEX_AUTO_DELIVERY' ) ) { $regular_id = $usces->get_order_meta_value( 'regular_id', $order_id ); if ( ! empty( $regular_id ) ) { echo ' ' . esc_html__( 'Settlement status', 'usces' ) . ' ' . esc_html__( 'Card unregistered', 'usces' ) . ' '; } } } } } /** * 受注編集画面【支払情報】 * usces_action_order_edit_form_settle_info * * @param array $data Order data. * @param array $action_args Compact array( $order_action, $order_id, $cart ). */ public function settlement_information( $data, $action_args ) { global $usces; extract( $action_args ); // phpcs:ignore if ( 'new' !== $order_action && ! empty( $order_id ) ) { $payment = usces_get_payments_by_name( $data['order_payment_name'] ); if ( in_array( $payment['settlement'], $this->pay_method, true ) ) { $acting_data = usces_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) ); $merchantfree1 = ( isset( $acting_data['MerchantFree1'] ) && isset( $acting_data['ProcessId'] ) && isset( $acting_data['ProcessPass'] ) ) ? $acting_data['MerchantFree1'] : '9999999999'; echo ''; } } } /** * 決済情報ダイアログ * usces_action_endof_order_edit_form * * @param array $data Order data. * @param array $action_args Compact array( $order_action, $order_id, $cart ). */ public function settlement_dialog( $data, $action_args ) { global $usces; extract( $action_args ); // phpcs:ignore if ( 'new' !== $order_action && ! empty( $order_id ) ) : $payment = usces_get_payments_by_name( $data['order_payment_name'] ); if ( in_array( $payment['settlement'], $this->pay_method, true ) ) : ?>
get_acting_settings(); /* 外部リンク(三者間画面) */ if ( 'acting_welcart_card' === $acting_flg && 'link' === $acting_opts['card_activate'] ) { $usces_entries = $usces->cart->get_entry(); $cart = $usces->cart->get_cart(); if ( ! $usces_entries || ! $cart ) { wp_redirect( USCES_CART_URL ); exit(); } if ( ! wp_verify_nonce( $_REQUEST['_nonce'], $acting_flg ) ) { wp_redirect( USCES_CART_URL ); exit(); } parse_str( $post_query, $post_data ); $transaction_date = $this->get_transaction_date(); $rand = $post_data['rand']; $member = $usces->get_member(); usces_save_order_acting_data( $rand ); $param_list = array(); $params = array(); $quick_member = ( isset( $post_data['quick_member'] ) ) ? $post_data['quick_member'] : ''; if ( 'add' !== $quick_member ) { if ( ! empty( $member['ID'] ) && 'on' === $acting_opts['quickpay'] ) { $kaiin_id = $this->get_quick_kaiin_id( $member['ID'] ); $kaiin_pass = $this->get_quick_pass( $member['ID'] ); } else { $kaiin_id = ''; $kaiin_pass = ''; } if ( empty( $kaiin_id ) || empty( $kaiin_pass ) ) { $quick_member = 'no'; } } $home_url = str_replace( 'http://', 'https://', home_url( '/' ) ); $redirecturl = $home_url . '?page_id=' . USCES_CART_NUMBER; if ( ! empty( $member['ID'] ) && 'on' === $acting_opts['quickpay'] && ( 'add' === $quick_member || 'update' === $quick_member ) ) { $data_list = array(); $data_list['MerchantPass'] = $acting_opts['merchant_pass']; $data_list['TransactionDate'] = $transaction_date; $data_list['MerchantFree1'] = $rand; $data_list['MerchantFree2'] = $acting_flg; $data_list['MerchantFree3'] = $this->merchantfree3; $data_list['TenantId'] = $acting_opts['tenant_id']; if ( 'add' === $quick_member ) { $data_list['OperateId'] = '4MemAdd'; $data_list['KaiinId'] = $this->make_kaiin_id( $member['ID'] ); $data_list['KaiinPass'] = $this->make_kaiin_pass(); } elseif ( 'update' === $quick_member ) { $data_list['OperateId'] = '4MemChg'; $data_list['KaiinId'] = $kaiin_id; $data_list['KaiinPass'] = $kaiin_pass; } $data_list['ProcNo'] = '0000000'; $data_list['RedirectUrl'] = $redirecturl; $data_query = http_build_query( $data_list ); $encryptvalue = openssl_encrypt( $data_query, 'aes-128-cbc', $acting_opts['key_aes'], false, $acting_opts['key_iv'] ); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['EncryptValue'] = urlencode( $encryptvalue ); wp_redirect( add_query_arg( $param_list, $acting_opts['send_url_link'] ) ); } else { if ( usces_have_continue_charge() ) { $chargingday = $usces->getItemChargingDay( $cart[0]['post_id'] ); if ( 99 === (int) $chargingday ) { /* 受注日課金 */ $operateid = $acting_opts['operateid']; } else { $operateid = '1Auth'; } } else { $operateid = $acting_opts['operateid']; } $operateid = apply_filters( 'usces_filter_escott_operateid', $operateid, $cart, $usces_entries['order']['total_full_price'] ); $data_list = array(); $data_list['OperateId'] = $operateid; $data_list['MerchantPass'] = $acting_opts['merchant_pass']; $data_list['TransactionDate'] = $transaction_date; $data_list['MerchantFree1'] = $rand; $data_list['MerchantFree2'] = $acting_flg; $data_list['MerchantFree3'] = $this->merchantfree3; $data_list['TenantId'] = $acting_opts['tenant_id']; if ( 'on' === $acting_opts['quickpay'] && ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) { $data_list['KaiinId'] = $kaiin_id; $data_list['KaiinPass'] = $kaiin_pass; } $data_list['PayType'] = '01'; $data_list['Amount'] = $usces_entries['order']['total_full_price']; $data_list['ProcNo'] = '0000000'; $data_list['RedirectUrl'] = $redirecturl; $data_query = http_build_query( $data_list ); $encryptvalue = openssl_encrypt( $data_query, 'aes-128-cbc', $acting_opts['key_aes'], false, $acting_opts['key_iv'] ); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['EncryptValue'] = urlencode( $encryptvalue ); wp_redirect( add_query_arg( $param_list, $acting_opts['send_url_link'] ) ); } exit(); /* 銀聯 */ } elseif ( 'acting_welcart_unionpay' === $acting_flg ) { $home_url = str_replace( 'http://', 'https://', home_url( '/' ) ); $usces_entries = $usces->cart->get_entry(); $cart = $usces->cart->get_cart(); if ( ! $usces_entries || ! $cart ) { wp_redirect( USCES_CART_URL ); exit(); } if ( ! wp_verify_nonce( $_REQUEST['_nonce'], $acting_flg ) ) { wp_redirect( USCES_CART_URL ); exit(); } parse_str( $post_query, $post_data ); $transaction_date = $this->get_transaction_date(); $rand = $post_data['rand']; usces_save_order_acting_data( $rand ); $data_list = array(); $data_list['MerchantPass'] = $acting_opts['merchant_pass']; $data_list['TransactionDate'] = $transaction_date; $data_list['MerchantFree1'] = $rand; $data_list['MerchantFree2'] = $acting_flg; $data_list['MerchantFree3'] = $this->merchantfree3; $data_list['TenantId'] = $acting_opts['tenant_id']; $data_list['Amount'] = $usces_entries['order']['total_full_price']; $data_list['CurrencyId'] = '392'; /* JPY */ if ( ! empty( $acting_opts['unionpay_pagelanguage'] ) ) { $data_list['PageLanguage'] = $acting_opts['unionpay_pagelanguage']; } // $data_list['PayCardType'] = '00'; $data_list['ProcNo'] = sprintf( '%020d', $rand ); $data_list['SuccessURL'] = USCES_CART_URL . $usces->delim . 'acting=' . $this->acting_unionpay . '&acting_return=1'; $data_list['ErrorURL'] = USCES_CART_URL . $usces->delim . 'acting=' . $this->acting_unionpay . '&acting_return=0'; $data_list['StatusNoticeURL'] = $home_url; $data_list['EndNoticeURL'] = $home_url; $data_query = http_build_query( $data_list ); $encryptvalue = openssl_encrypt( $data_query, 'aes-128-cbc', $acting_opts['unionpay_key_aes'], false, $acting_opts['unionpay_key_iv'] ); $param_list = array(); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['OperateId'] = '11Gathering'; $param_list['EncryptValue'] = $encryptvalue; $gc = new SLNConnection(); $gc->send_request_unionpay( $acting_opts['send_url_unionpay'], $param_list ); exit(); } } /** * 受注データ登録 * Called by usces_reg_orderdata() and usces_new_orderdata(). * usces_action_reg_orderdata * * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $results ). */ public function register_orderdata( $args ) { extract( $args ); // phpcs:ignore if ( ! isset( $results['MerchantFree1'] ) ) { return; } $acting_flg = $payments['settlement']; if ( ! in_array( $acting_flg, $this->pay_method ) ) { return; } if ( ! $entry['order']['total_full_price'] ) { return; } parent::register_orderdata( $args ); if ( ! isset( $results['Amount'] ) ) { $results['Amount'] = $entry['order']['total_full_price']; } $results = apply_filters( 'usces_filter_escott_register_orderdata_history_log', $results, $args ); $this->save_acting_history_log( $results, $order_id . '_' . $results['MerchantFree1'] ); } /** * Front scripts. * wp_print_footer_scripts */ public function footer_scripts() { global $usces; if ( ! $this->is_validity_acting( 'card' ) ) { return; } parent::footer_scripts(); /* 発送・支払方法ページ */ if ( 'delivery' === $usces->page ) { $acting_opts = $this->get_acting_settings(); /* リンク型 */ if ( isset( $acting_opts['card_activate'] ) && 'link' === $acting_opts['card_activate'] ) { wp_enqueue_style( 'jquery-ui-style' ); wp_enqueue_script( 'jquery-ui-dialog' ); wp_enqueue_style( 'jquery-ui-dialog-min-css', includes_url() . 'css/jquery-ui-dialog.min.css' ); wp_register_script( 'usces_cart_escott_link', USCES_FRONT_PLUGIN_URL . '/js/cart_escott_link.js', array( 'jquery' ), USCES_VERSION, true ); $escott_params = array(); $escott_params['card_activate'] = $acting_opts['card_activate']; $escott_params['message']['agreement'] = $this->consent_message(); $escott_params['message']['agree'] = __( 'Agree', 'usces' ); $escott_params['message']['disagree'] = __( 'Disagree', 'usces' ); wp_localize_script( 'usces_cart_escott_link', 'escott_params', $escott_params ); wp_enqueue_script( 'usces_cart_escott_link' ); } } if ( ! usces_is_membersystem_state() || ! usces_is_login() ) { return; } /* クレジットカード情報更新ページ */ if ( isset( $_GET['usces_page'] ) && ( 'member_register_settlement' === filter_input( INPUT_GET, 'usces_page', FILTER_DEFAULT ) || 'member_update_settlement' === filter_input( INPUT_GET, 'usces_page', FILTER_DEFAULT ) ) ) { // wp_enqueue_script( 'usces_escott_member', USCES_FRONT_PLUGIN_URL . '/js/member_escott.js', array( 'jquery' ), USCES_VERSION, true ); print_google_recaptcha_response( filter_input( INPUT_GET, 'usces_page', FILTER_DEFAULT ), 'member-card-info', 'member_update_settlement' ); } /* マイページ */ if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) { $acting_opts = $this->get_acting_settings(); if ( 'on' === $acting_opts['quickpay'] ) { wp_enqueue_style( 'jquery-ui-style' ); wp_enqueue_script( 'jquery-ui-dialog' ); wp_enqueue_style( 'jquery-ui-dialog-min-css', includes_url() . 'css/jquery-ui-dialog.min.css' ); wp_register_script( 'usces_member_escott', USCES_FRONT_PLUGIN_URL . '/js/member_escott.js', array( 'jquery' ), USCES_VERSION, true ); $escott_params = array(); $escott_params['sec3d_activate'] = $acting_opts['sec3d_activate']; $escott_params['message']['agreement'] = $this->consent_message(); $escott_params['message']['agree'] = __( 'Agree', 'usces' ); $escott_params['message']['disagree'] = __( 'Disagree', 'usces' ); $escott_params['update_settlement_url'] = urlencode( add_query_arg( array( 'usces_page' => 'member_update_settlement', 're-enter' => 1, ), USCES_MEMBER_URL ) ); $escott_params['register_settlement_url'] = urlencode( add_query_arg( array( 'usces_page' => 'member_register_settlement', 're-enter' => 1, ), USCES_MEMBER_URL ) ); $member = $usces->get_member(); $escott_params['edit_auth'] = ( isset( $member['edit_auth'] ) ) ? $member['edit_auth'] : ''; $escott_params['edit_flag'] = USCES_VERIFY_MEMBERS_EMAIL::$opts['edit_flag']; wp_localize_script( 'usces_member_escott', 'escott_params', $escott_params ); wp_enqueue_script( 'usces_member_escott' ); } } } /** * 支払方法説明 * usces_fiter_the_payment_method_explanation * * @param string $explanation Explanation of Payment Method. * @param array $payment Payment data. * @param string $value Input value. * @return string */ public function set_payment_method_explanation( $explanation, $payment, $value ) { global $usces; $quickpay = ''; if ( $this->acting_flg_card === $payment['settlement'] ) { $acting_opts = $this->get_acting_settings(); if ( 'link' === $acting_opts['card_activate'] ) { if ( usces_is_login() && 'on' === $acting_opts['quickpay'] ) { $member = $usces->get_member(); $kaiin_id = $this->get_quick_kaiin_id( $member['ID'] ); $kaiin_pass = $this->get_quick_pass( $member['ID'] ); if ( ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) { $quickpay = '

'; } else { if ( usces_have_regular_order() || usces_have_continue_charge() ) { $quickpay = ''; } elseif ( 'on' !== $acting_opts['chooseable_quickpay'] ) { $quickpay = ''; } else { $quickpay = '

'; } } } else { $quickpay = ''; } } } return $quickpay . $explanation; } /** * 利用可能な決済モジュール * usces_filter_available_payment_method * * @param array $payments Payment data. * @return array */ public function set_available_payment_method( $payments ) { global $usces; if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) { $payment_method = array(); foreach ( (array) $payments as $id => $payment ) { if ( $this->acting_flg_card === $payment['settlement'] ) { $payment_method[ $id ] = $payments[ $id ]; break; } } if ( ! empty( $payment_method ) ) { $payments = $payment_method; } } return $payments; } /** * 支払回数 * usces_filter_delivery_secure_form_howpay * * @param string $html HTML. * @return string */ public function delivery_secure_form_howpay( $html ) { if ( isset( $_GET['usces_page'] ) && ( 'member_update_settlement' === filter_input( INPUT_GET, 'usces_page', FILTER_DEFAULT ) || 'member_register_settlement' === filter_input( INPUT_GET, 'usces_page', FILTER_DEFAULT ) ) ) { $html = ''; } return $html; } /** * 内容確認ページ [注文する] ボタン * usces_filter_confirm_inform * * @param string $html Purchase post form. * @param array $payments Payment data. * @param string $acting_flg Payment type. * @param string $rand Welcart transaction key. * @param string $purchase_disabled Disable purchase button. * @return string */ public function confirm_inform( $html, $payments, $acting_flg, $rand, $purchase_disabled ) { global $usces; $html = parent::confirm_inform( $html, $payments, $acting_flg, $rand, $purchase_disabled ); $usces_entries = $usces->cart->get_entry(); if ( ! $usces_entries['order']['total_full_price'] ) { return $html; } if ( $this->acting_flg_unionpay === $acting_flg ) { $html = '
' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
'; } return $html; } /** * Front styles. * wp_print_styles */ public function print_styles() { global $usces; parent::print_styles(); /* マイページ */ if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) : $acting_opts = $this->get_acting_settings(); if ( isset( $acting_opts['card_activate'] ) && 'token' === $acting_opts['card_activate'] || 'link' === $acting_opts['card_activate'] ) : ?> is_validity_acting( 'card' ) ) : if ( ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'delivery' === $usces->page ) || ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) && ( 'member_register_settlement' === filter_input( INPUT_GET, 'usces_page', FILTER_DEFAULT ) || 'member_update_settlement' === filter_input( INPUT_GET, 'usces_page', FILTER_DEFAULT ) ) ) ) : $acting_opts = $this->get_acting_settings(); if ( isset( $acting_opts['card_activate'] ) && 'token' === $acting_opts['card_activate'] ) : ?> is_cart_page( $_SERVER['REQUEST_URI'] ) && 'delivery' === $usces->page ) { $acting_opts = $this->get_acting_settings(); if ( isset( $acting_opts['card_activate'] ) && 'link' === $acting_opts['card_activate'] ) { $front_ajaxurl = trailingslashit( USCES_SSL_URL ) . 'index.php'; $l10n .= "'front_ajaxurl': '" . $front_ajaxurl . "',\n"; $payment_method = usces_get_system_option( 'usces_payment_method', 'sort' ); $payment_method = apply_filters( 'usces_fiter_the_payment_method', $payment_method, '' ); foreach ( (array) $payment_method as $id => $payment ) { if ( $payment['settlement'] === $this->acting_flg_card ) { $l10n .= "'escott_link_payment_id': '" . $id . "',\n"; break; } } } } elseif ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) && ( isset( $_GET['usces_page'] ) && ( 'member_register_settlement' === filter_input( INPUT_GET, 'usces_page', FILTER_DEFAULT ) || 'member_update_settlement' === filter_input( INPUT_GET, 'usces_page', FILTER_DEFAULT ) ) ) ) { $acting_opts = $this->get_acting_settings(); if ( isset( $acting_opts['card_activate'] ) && 'token' === $acting_opts['card_activate'] ) { $front_ajaxurl = trailingslashit( USCES_SSL_URL ) . 'index.php'; $l10n .= "'front_ajaxurl': '" . $front_ajaxurl . "',\n"; $l10n .= "'escott_token_error_message': '" . __( 'Credit card information is not appropriate.', 'usces' ) . "',\n"; } } return $l10n; } /** * クレジットカード登録・変更ページ表示 * usces_filter_template_redirect */ public function member_update_settlement() { global $usces; if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) { if ( ! usces_is_membersystem_state() || ! usces_is_login() ) { return; } $acting_opts = $this->get_acting_settings(); if ( 'on' !== $acting_opts['quickpay'] ) { return; } if ( isset( $_REQUEST['usces_page'] ) && 'member_update_settlement' === wp_unslash( $_REQUEST['usces_page'] ) ) { add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) ); $usces->page = 'member_update_settlement'; $this->member_update_settlement_form(); exit(); } elseif ( isset( $_REQUEST['usces_page'] ) && 'member_register_settlement' === wp_unslash( $_REQUEST['usces_page'] ) ) { add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) ); $usces->page = 'member_register_settlement'; $this->member_update_settlement_form(); exit(); } } return false; } /** * クレジットカード登録・変更ページ表示 * usces_filter_states_form_js * * @param string $js Scripts. * @return string */ public function states_form_js( $js ) { return ''; } /** * 会員データ削除チェック * usces_filter_delete_member_check * * @param boolean $del Deletable. * @param int $member_id Member ID. * @return boolean */ public function delete_member_check( $del, $member_id ) { $kaiin_id = $this->get_quick_kaiin_id( $member_id ); if ( ! empty( $kaiin_id ) ) { $del = false; } return $del; } /** * クレジットカード登録・変更ページリンク * usces_action_member_submenu_list */ public function e_update_settlement() { global $usces; $member = $usces->get_member(); $html = $this->update_settlement( '', $member ); echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * クレジットカード登録・変更ページリンク * usces_filter_member_submenu_list * * @param string $html Submenu area of the member page. * @param array $member Member information. * @return string */ public function update_settlement( $html, $member ) { $acting_opts = $this->get_acting_settings(); if ( 'on' === $acting_opts['quickpay'] ) { /* e-SCOTT 会員照会 */ $response_member = $this->escott_member_reference( $member['ID'] ); if ( 'OK' === $response_member['ResponseCd'] ) { if ( 'on' === $acting_opts['sec3d_activate'] ) { $html .= '
  • ' . __( 'Change the credit card is here >>', 'usces' ) . '
  • '; } else { $update_settlement_url = add_query_arg( array( 'usces_page' => 'member_update_settlement', 're-enter' => 1, ), USCES_MEMBER_URL ); $html .= '
  • ' . __( 'Change the credit card is here >>', 'usces' ) . '
  • '; } } else { if ( 'on' === $acting_opts['sec3d_activate'] ) { $html .= '
  • ' . __( 'Credit card registration is here >>', 'usces' ) . '
  • '; } else { $register_settlement_url = add_query_arg( array( 'usces_page' => 'member_register_settlement', 're-enter' => 1, ), USCES_MEMBER_URL ); $html .= '
  • ' . __( 'Credit card registration is here >>', 'usces' ) . '
  • '; } } } return $html; } /** * クレジットカード登録・変更ページ */ public function member_update_settlement_form() { global $usces; $member = $usces->get_member(); $acting_opts = $this->get_acting_settings(); /* 外部リンク(三者間画面) */ if ( 'link' === $acting_opts['card_activate'] ) { $transaction_date = $this->get_transaction_date(); $home_url = str_replace( 'http://', 'https://', home_url( '/' ) ); $redirecturl = $home_url . '?page_id=' . USCES_MEMBER_NUMBER; $data_list = array(); $data_list['MerchantPass'] = $acting_opts['merchant_pass']; $data_list['TransactionDate'] = $transaction_date; $data_list['MerchantFree3'] = $this->merchantfree3; $data_list['TenantId'] = $acting_opts['tenant_id']; if ( 'member_register_settlement' === $usces->page ) { $data_list['OperateId'] = '4MemAdd'; $data_list['KaiinId'] = $this->make_kaiin_id( $member['ID'] ); $data_list['KaiinPass'] = $this->make_kaiin_pass(); } else { $data_list['OperateId'] = '4MemChg'; $data_list['KaiinId'] = $this->get_quick_kaiin_id( $member['ID'] ); $data_list['KaiinPass'] = $this->get_quick_pass( $member['ID'] ); } $data_list['ProcNo'] = '0000000'; $data_list['RedirectUrl'] = $redirecturl; $data_query = http_build_query( $data_list ); $encryptvalue = openssl_encrypt( $data_query, 'aes-128-cbc', $acting_opts['key_aes'], false, $acting_opts['key_iv'] ); $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['EncryptValue'] = urlencode( $encryptvalue ); wp_redirect( add_query_arg( $param_list, $acting_opts['send_url_link'] ) ); exit(); /* マイページ */ } else { $script = ''; $done_message = ''; $html = ''; $register = ( 'member_register_settlement' === $usces->page ) ? true : false; $deleted = false; $cardno = ''; $seccd = ''; $expyy = ''; $expmm = ''; $cardname = ''; if ( 'on' === $acting_opts['quickpay'] ) { if ( isset( $_POST['update'] ) ) { check_admin_referer( 'member_update_settlement', 'wc_nonce' ); $verify_action = wel_verify_update_settlement( $member['ID'] ); if ( ! $verify_action ) { $usces->error_message .= '

    ' . __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '

    '; } else { $response_member = $this->escott_member_update( $member['ID'] ); if ( 'OK' === $response_member['ResponseCd'] ) { $this->send_update_settlement_mail(); $done_message = __( 'Successfully updated.', 'usces' ); } else { $usces->error_message .= '

    ' . __( 'Credit card information is not appropriate.', 'usces' ) . '

    '; $cardno = filter_input( INPUT_POST, 'cardno', FILTER_DEFAULT ); $seccd = filter_input( INPUT_POST, 'seccd', FILTER_DEFAULT ); $expyy = filter_input( INPUT_POST, 'expyy', FILTER_DEFAULT ); $expmm = filter_input( INPUT_POST, 'expmm', FILTER_DEFAULT ); $cardname = filter_input( INPUT_POST, 'cardname', FILTER_DEFAULT ); } } } elseif ( isset( $_POST['register'] ) ) { check_admin_referer( 'member_update_settlement', 'wc_nonce' ); $verify_action = wel_verify_update_settlement( $member['ID'] ); if ( ! $verify_action ) { $usces->error_message .= '

    ' . __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '

    '; } else { $response_member = $this->escott_member_register( $member['ID'] ); if ( 'OK' === $response_member['ResponseCd'] ) { $done_message = __( 'Successfully registered.', 'usces' ); $register = false; } else { $usces->error_message .= '

    ' . __( 'Credit card information is not appropriate.', 'usces' ) . '

    '; $cardno = filter_input( INPUT_POST, 'cardno', FILTER_DEFAULT ); $seccd = filter_input( INPUT_POST, 'seccd', FILTER_DEFAULT ); $expyy = filter_input( INPUT_POST, 'expyy', FILTER_DEFAULT ); $expmm = filter_input( INPUT_POST, 'expmm', FILTER_DEFAULT ); $cardname = filter_input( INPUT_POST, 'cardname', FILTER_DEFAULT ); } } } if ( ! $deleted ) { /* e-SCOTT 会員照会 */ $response_member = $this->escott_member_reference( $member['ID'] ); if ( 'OK' === $response_member['ResponseCd'] ) { $cardlast4 = substr( $response_member['CardNo'], -4 ); $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 ); $expmm = substr( $response_member['CardExp'], 2, 2 ); } else { $cardlast4 = ''; } $html .= ' '; if ( ! empty( $cardlast4 ) ) { $html .= ' '; } $cardno_attention = apply_filters( 'usces_filter_cardno_attention', __( '(Single-byte numbers only)', 'usces' ) . '
    ' . __( '* Please do not enter symbols or letters other than numbers such as space (blank), hyphen (-) between numbers.', 'usces' ) . '
    ' ); $html .= ' '; if ( 'on' === $acting_opts['seccd'] ) { $seccd_attention = apply_filters( 'usces_filter_seccd_attention', __( '(Single-byte numbers only)', 'usces' ) ); $html .= ' '; } $html .= ' '; $cardname_attention = apply_filters( 'usces_filter_cardname_attention', __( '(Alphabetic characters only)', 'usces' ) . '
    ' . __( '* Use a space to separate the first and last name, and enter all characters in uppercase.', 'usces' ) . '
    ' ); $html .= '
    ' . __( 'The last four digits of your card number', 'usces' ) . '

    ' . $cardlast4 . '

    ' . __( 'card number', 'usces' ) . ' ' . $cardno_attention . '
    ' . __( 'security code', 'usces' ) . ' ' . $seccd_attention . '
    ' . __( 'Card expiration', 'usces' ) . ' ' . __( 'month', 'usces' ) . '  ' . __( 'year', 'usces' ) . '
    ' . __( 'Card name', 'usces' ) . ' ' . $cardname_attention . '
    '; } if ( empty( $usces->error_message ) && isset( $_GET['re-enter'] ) && isset( $_GET['ResponseCd'] ) ) { if ( 'NG' === wp_unslash( $_GET['ResponseCd'] ) ) { $usces->error_message = __( 'Credit card information is not appropriate.', 'usces' ); } } } $update_settlement_url = add_query_arg( array( 'usces_page' => $usces->page, 'settlement' => 1, 're-enter' => 1, ), USCES_MEMBER_URL ); if ( '' !== $done_message ) { $script .= ' '; } $error_message = apply_filters( 'usces_filter_member_update_settlement_error_message', $usces->error_message ); ob_start(); get_header(); if ( '' !== $script ) { echo $script; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } ?>

    get_member(); // $mail_data = $usces->options['mail_data']; $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 = $mail_data['footer']['thankyou']; $mail_footer = get_option( 'blogname' ) . "\r\n"; $name = usces_localized_name( $member['name1'], $member['name2'], 'return' ); $message = '--------------------------------' . "\r\n"; $message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n"; $message .= __( 'Name', 'usces' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $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' => sprintf( _x( '%s', 'honorific', 'usces' ), $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' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $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 . '( ' . sprintf( _x( '%s', 'honorific', 'usces' ), $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_welcart_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; $status = $this->get_latest_status( $member_id, $con_order_id ); if ( ! empty( $status ) ) { $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 ( 'OK' !== $status ) { $message .= ' ' . __( 'Condition', 'dlseller' ) . ' : ' . __( 'Settlement error', 'usces' ); $log_data = $this->get_acting_log( $con_order_id ); if ( $log_data && 0 < count( $log_data ) ) { $acting_data = usces_unserialize( $log_data[0]['log'] ); $trans_id = ( isset( $acting_data['MerchantFree1'] ) ) ? $acting_data['MerchantFree1'] : ''; } else { $trans_id = $usces->get_order_meta_value( 'trans_id', $con_order_id ); } if ( $trans_id ) { $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $trans_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 = ''; $regular_table_name = $wpdb->prefix . 'usces_regular'; $regular_detail_table_name = $wpdb->prefix . 'usces_regular_detail'; $order_table_name = $wpdb->prefix . 'usces_order'; $order_meta_table_name = $wpdb->prefix . 'usces_order_meta'; $query = $wpdb->prepare( "SELECT r.reg_id, r.reg_payment_name, d.regdet_schedule_date FROM {$regular_detail_table_name} AS `d` RIGHT JOIN {$regular_table_name} 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, ARRAY_A ); if ( 0 < count( $regular_order ) ) { foreach ( $regular_order as $regular_data ) { $payment = $usces->getPayments( $regular_data['reg_payment_name'] ); if ( 'acting_welcart_card' !== $payment['settlement'] ) { continue; } $reg_id = $regular_data['reg_id']; $message .= __( 'Regular ID', 'autodelivery' ) . ' : ' . $reg_id; $query = $wpdb->prepare( "SELECT o.ID AS `order_id`, meta.meta_value AS `deco_id`, DATE_FORMAT( order_date, %s ) AS `date` FROM {$order_table_name} AS `o` LEFT JOIN {$order_meta_table_name} AS `meta` ON o.ID = meta.order_id AND meta.meta_key = 'dec_order_id' LEFT JOIN {$regular_table_name} 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( order_date, %s ) AS `date` FROM {$order_table_name} AS `o1` LEFT JOIN {$order_meta_table_name} AS `meta1` ON o1.ID = meta1.order_id AND meta1.meta_key = 'dec_order_id' LEFT JOIN {$order_meta_table_name} AS `meta2` ON o1.ID = meta2.order_id AND meta2.meta_key = 'regular_id' WHERE meta2.meta_value = %d ORDER BY order_id DESC, 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 ) ) { $reg_order_id = $regular_order_data[0]['order_id']; $status = $this->get_latest_status( $member_id, $reg_order_id ); if ( ! empty( $status ) && 'OK' === $status ) { if ( $this->isdate( $regular_data['regdet_schedule_date'] ) ) { $message .= ' ( ' . __( 'Scheduled order date', 'autodelivery' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $regular_data['regdet_schedule_date'] ) ) . ' )'; } } else { $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 . ' )'; } } $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; } /** * 利用可能な支払方法 * usces_filter_the_continue_payment_method * * @param array $payment_method Payment method. * @return array */ public function continuation_payment_method( $payment_method ) { $acting_opts = $this->get_acting_settings(); if ( 'on' === $acting_opts['quickpay'] ) { $payment_method[] = 'acting_welcart_card'; } return $payment_method; } /** * 利用可能な支払方法 * dlseller_filter_the_payment_method_restriction * wcad_filter_the_payment_method_restriction * * @param array $payments_restriction Payment method. * @param string $payments_value Input value. * @return array */ public function payment_method_restriction( $payments_restriction, $payments_value ) { $acting_opts = $this->get_acting_settings(); if ( ( usces_have_regular_order() || usces_have_continue_charge() ) && usces_is_login() && 'on' === $acting_opts['quickpay'] ) { $payments = usces_get_system_option( 'usces_payment_method', 'settlement' ); $payments_restriction[] = $payments['acting_welcart_card']; foreach ( (array) $payments_restriction as $key => $value ) { $sort[ $key ] = $value['sort']; } array_multisort( $sort, SORT_ASC, $payments_restriction ); } return $payments_restriction; } /** * 「初回引落し日」 * 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_limitofcard * * @param string $limitofcard Card expiration date. * @param int $member_id Member ID. * @param int $order_id Order number. * @param array $meta_data Continuation data. * @return string */ public function continue_member_list_limitofcard( $limitofcard, $member_id, $order_id, $meta_data ) { if ( isset( $meta_data['acting'] ) ) { if ( version_compare( WCEX_DLSELLER_VERSION, '3.0-beta', '<=' ) ) { $payment = usces_get_payments_by_name( $meta_data['acting'] ); $acting = $payment['settlement']; } else { $acting = $meta_data['acting']; } if ( 'acting_welcart_card' !== $acting ) { return $limitofcard; } $acting_opts = $this->get_acting_settings(); if ( 'on' !== $acting_opts['quickpay'] ) { return $limitofcard; } $kaiin_id = $this->get_quick_kaiin_id( $member_id ); $kaiin_pass = $this->get_quick_pass( $member_id ); if ( ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) { /* e-SCOTT 会員照会 */ $response_member = $this->escott_member_reference( $member_id, $kaiin_id, $kaiin_pass ); if ( 'OK' === $response_member['ResponseCd'] ) { $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 ); $expmm = substr( $response_member['CardExp'], 2, 2 ); $limit = $expyy . $expmm; $now = date_i18n( 'Ym', current_time( 'timestamp', 0 ) ); $limitofcard = $expmm . '/' . substr( $response_member['CardExp'], 0, 2 ); if ( $limit <= $now ) { $limitofcard .= '
    ' . __( 'Update Request Email', 'dlseller' ) . ''; } } } else { $limitofcard = ''; } } return $limitofcard; } /** * 継続課金会員リスト「契約」 * dlseller_filter_continue_member_list_continue_status * * @param string $status Continuation status. * @param int $member_id Member ID. * @param int $order_id Order number. * @param array $meta_data Continuation data. * @return string */ public function continue_member_list_continue_status( $status, $member_id, $order_id, $meta_data ) { return $status; } /** * 継続課金会員リスト「状態」 * 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 $meta_data Continuation data. * @return string */ public function continue_member_list_condition( $condition, $member_id, $order_id, $meta_data ) { global $usces; $order_data = $usces->get_order_data( $order_id, 'direct' ); $payment = $usces->getPayments( $order_data['order_payment_name'] ); if ( isset( $payment['settlement'] ) && 'acting_welcart_card' === $payment['settlement'] ) { $url = admin_url( 'admin.php?page=usces_continue&continue_action=settlement&member_id=' . $member_id . '&order_id=' . $order_id ); $condition = '' . __( 'Detail', 'usces' ) . ''; if ( 'continuation' === $meta_data['status'] ) { $status = $this->get_latest_status( $member_id, $order_id ); if ( ! empty( $status ) && 'OK' !== $status ) { $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' === $continue_action ) { $member_id = filter_input( INPUT_GET, 'member_id' ); $order_id = filter_input( INPUT_GET, 'order_id' ); if ( ! is_null( $member_id ) && ! is_null( $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; if ( version_compare( WCEX_DLSELLER_VERSION, '3.0-beta', '<=' ) ) { $continue_data = usces_unserialize( $usces->get_member_meta_value( 'continuepay_' . $order_id, $member_id ) ); } else { $continue_data = $this->get_continuation_data( $order_id, $member_id ); } $curent_url = $_SERVER['REQUEST_URI']; $navibutton = '' . __( 'Back to the continue members list', 'dlseller' ) . ''; $order_data = $usces->get_order_data( $order_id, 'direct' ); if ( ! $order_data ) { return; } $member_info = $usces->get_member_info( $member_id ); $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' ); $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) ); $payment = $usces->getPayments( $order_data['order_payment_name'] ); if ( 'acting_welcart_card' !== $payment['settlement'] ) { 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; } $year = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 4 ); $total_full_price = $order_data['order_item_total_price'] - $order_data['order_usedpoint'] + $order_data['order_discount'] + $order_data['order_shipping_charge'] + $order_data['order_cod_fee'] + $order_data['order_tax']; $log_data = $this->get_acting_log( $order_id ); $num = ( $log_data ) ? count( $log_data ) + 1 : 1; $kaiin_id = $this->get_quick_kaiin_id( $member_id ); $card = ( empty( $kaiin_id ) ) ? ' ' . __( 'Card unregistered', 'usces' ) . '' : ''; ?>

    Welcart Management

    Version

    get_acting_latest_log( $log_row['log_key'], 'ALL' ); if ( isset( $log['OperateId'] ) && isset( $log['ResponseCd'] ) && 'OK' === $log['ResponseCd'] ) { $class = ' card-' . mb_strtolower( substr( $log['OperateId'], 1 ) ); $status_name = $this->get_operate_name( $log['OperateId'] ); $merchantfree1 = $log['MerchantFree1']; $responsecd = ''; $amount = ( isset( $log['Amount'] ) ) ? usces_crform( $log['Amount'], false, true, 'return', true ) : ''; } else { $class = ' card-error'; $status_name = __( 'Settlement error', 'usces' ); if ( isset( $log_row['log'] ) ) { $log = usces_unserialize( $log_row['log'] ); if ( isset( $log['MerchantFree1'] ) ) { $merchantfree1 = $log['MerchantFree1']; } else { $log_key = explode( '_', $log_row['log_key'] ); $merchantfree1 = ( isset( $log_key[1] ) ) ? $log_key[1] : '9999999999'; } $responsecd = $log['ResponseCd']; $amount = ( isset( $log['Amount'] ) ) ? usces_crform( $log['Amount'], false, true, 'return', true ) : ''; } else { $log_key = explode( '_', $log_row['log_key'] ); $merchantfree1 = ( isset( $log_key[1] ) ) ? $log_key[1] : '9999999999'; $responsecd = 'NG'; $amount = ''; } } ?> get_order_meta_value( 'trans_id', $order_id ); $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id, 'ALL' ); if ( $latest_log ) : $class = ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 1 ) ); $status_name = $this->get_operate_name( $latest_log['OperateId'] ); if ( isset( $latest_log['Amount'] ) ) { $amount = usces_crform( $latest_log['Amount'], false, true, 'return', true ); } elseif ( isset( $continue_data['order_price'] ) ) { $amount = usces_crform( $continue_data['order_price'], false, true, 'return', true ); } else { $amount = ''; } ?>
       
      
    1   
    settlement_dialog( $order_data, $action_args ); include ABSPATH . 'wp-admin/admin-footer.php'; } /** * 継続課金会員クレジットカード変更依頼メール * dlseller_filter_card_update_mail * * @param string $message Message. * @param int $member_id Member ID. * @param int $order_id Order number. * @return string */ public function continue_member_card_update_mail( $message, $member_id, $order_id ) { global $usces; $acting_opts = $this->get_acting_settings(); if ( ! usces_is_membersystem_state() || 'on' !== $acting_opts['quickpay'] ) { return $message; } $kaiin_id = $this->get_quick_kaiin_id( $member_id ); $kaiin_pass = $this->get_quick_pass( $member_id ); if ( ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) { /* e-SCOTT 会員照会 */ $response_member = $this->escott_member_reference( $member_id, $kaiin_id, $kaiin_pass ); if ( 'OK' === $response_member['ResponseCd'] ) { $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 ); $expmm = substr( $response_member['CardExp'], 2, 2 ); $now = date_i18n( 'Ym', current_time( 'timestamp', 0 ) ); $member_info = $usces->get_member_info( $member_id ); $mail_data = usces_mail_data(); $nonsessionurl = usces_url( 'cartnonsession', 'return' ); $parts = parse_url( $nonsessionurl ); if ( isset( $parts['query'] ) ) { parse_str( $parts['query'], $query ); } if ( false !== strpos( $nonsessionurl, '/usces-cart' ) ) { $nonsessionurl = str_replace( '/usces-cart', '/usces-member', $nonsessionurl ); } elseif ( isset( $query['page_id'] ) && USCES_CART_NUMBER === $query['page_id'] ) { $nonsessionurl = str_replace( 'page_id=' . USCES_CART_NUMBER, 'page_id=' . USCES_MEMBER_NUMBER, $nonsessionurl ); } $delim = ( false === strpos( $nonsessionurl, '?' ) ) ? '?' : '&'; $regd = $expyy . $expmm; if ( $regd === $now ) { $flag = 'NOW'; } elseif ( $regd < $now ) { $flag = 'PASSED'; } else { return $message; } $exp = mktime( 0, 0, 0, $expmm, 1, $expyy ); $limit = date_i18n( __( 'F, Y' ), $exp ); $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' ); $message = __( 'Member ID', 'dlseller' ) . ' : ' . $member_id . "\n"; $message .= __( 'Contractor name', 'dlseller' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\n\n\n"; $message .= __( 'Thank you very much for using our service.', 'dlseller' ) . "\r\n\r\n"; $message .= __( 'Please be sure to check this notification because it is an important contact for continued use of the service under contract.', 'dlseller' ) . "\r\n\r\n"; $message .= __( '---------------------------------------------------------', 'dlseller' ) . "\r\n"; $message .= sprintf( __( 'Currently registered credit card expiration date is %s, ', 'dlseller' ), $limit ) . "\r\n"; if ( 'NOW' === $flag ) { $message .= __( 'So you keep on this you will not be able to pay next month.', 'dlseller' ) . "\r\n"; } else { $message .= __( 'So your payment of this month is outstanding payment.', 'dlseller' ) . "\r\n"; } $message .= __( '---------------------------------------------------------', 'dlseller' ) . "\r\n\r\n"; $message .= __( 'If you have received a new credit card, ', 'dlseller' ) . "\r\n"; $message .= __( 'Please click the URL below and update the card information during this month.', 'dlseller' ) . "\r\n"; $message .= __( 'Sorry for troubling you, please process it.', 'dlseller' ) . "\r\n\r\n\r\n"; $message .= $nonsessionurl . $delim . 'dlseller_card_update=login&dlseller_up_mode=1&dlseller_order_id=' . $order_id . "\r\n"; $message .= __( 'If the card information update procedure failed, please contact us at the following email address.', 'dlseller' ) . "\r\n\r\n"; $message .= __( 'Thank you.', 'dlseller' ) . "\r\n\r\n\r\n"; $message .= $mail_data['footer']['ordermail']; $message = apply_filters( 'usces_filter_continue_member_card_update_mail', $message, $member_id, $member_info ); if ( function_exists( 'usces_is_html_mail' ) && usces_is_html_mail() ) { $message = do_shortcode( wpautop( $message ) ); } } } return $message; } /** * 自動継続課金処理 * 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; $acting_opts = $this->get_acting_settings(); if ( ! usces_is_membersystem_state() || 'on' !== $acting_opts['quickpay'] ) { return; } if ( 0 >= $continue_data['price'] ) { return; } $order_data = $usces->get_order_data( $order_id, 'direct' ); if ( ! $order_data || $usces->is_status( 'cancel', $order_data['order_status'] ) ) { return; } $payment = $usces->getPayments( $order_data['order_payment_name'] ); if ( 'acting_welcart_card' !== $payment['settlement'] ) { return; } $kaiin_id = $this->get_quick_kaiin_id( $member_id ); $kaiin_pass = $this->get_quick_pass( $member_id ); $rand = usces_acting_key(); if ( ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) { $transaction_date = $this->get_transaction_date(); $param_list = array(); $params_member = array(); $params = array(); /* 共通部 */ $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $rand; $param_list['MerchantFree2'] = $payment['settlement']; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $params_member['send_url'] = $acting_opts['send_url_member']; $params_member['param_list'] = array_merge( $param_list, array( 'OperateId' => '4MemRefM', 'KaiinId' => $kaiin_id, 'KaiinPass' => $kaiin_pass, ) ); /* e-SCOTT 会員照会 */ $response_member = $this->connection( $params_member ); if ( 'OK' === $response_member['ResponseCd'] ) { $params['send_url'] = $acting_opts['send_url']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => $acting_opts['operateid_dlseller'], 'Amount' => usces_crform( $continue_data['price'], false, false, 'return', false ), 'PayType' => '01', 'KaiinId' => $kaiin_id, 'KaiinPass' => $kaiin_pass, ) ); /* e-SCOTT 決済 */ $response_data = $this->connection( $params ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = $continue_data['price']; } $response_data = apply_filters( 'usces_filter_escott_auto_continuation_charging_history_log', $response_data, $member_id, $order_id, $continue_data ); $this->save_acting_history_log( $response_data, $order_id . '_' . $rand ); if ( 'OK' === $response_data['ResponseCd'] ) { $cardlast4 = substr( $response_member['CardNo'], -4 ); $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 ); $expmm = substr( $response_member['CardExp'], 2, 2 ); $response_data['acting'] = $this->acting_card; $response_data['PayType'] = '01'; $response_data['CardNo'] = $cardlast4; $response_data['CardExp'] = $expyy . '/' . $expmm; $this->save_acting_log( $response_data, $order_id . '_' . $rand ); $this->auto_settlement_mail( $member_id, $order_id, $response_data, $continue_data ); } else { $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $response_data[ $cd ] = $this->response_message( $cd ); } $log = array( 'acting' => $this->acting_card, 'key' => $rand, 'result' => $response_data['ResponseCd'], 'data' => $response_data, ); usces_save_order_acting_error( $log ); $this->save_acting_log( $response_data, $order_id . '_' . $rand ); $this->auto_settlement_error_mail( $member_id, $order_id, $response_data, $continue_data ); } do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $response_data ); } else { if ( ! isset( $response_member['Amount'] ) ) { $response_member['Amount'] = $continue_data['price']; } $response_member = apply_filters( 'usces_filter_escott_auto_continuation_charging_history_log', $response_member, $member_id, $order_id, $continue_data ); $this->save_acting_history_log( $response_member, $order_id . '_' . $rand ); $responsecd = explode( '|', $response_member['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $response_member[ $cd ] = $this->response_message( $cd ); } $log = array( 'acting' => $this->acting_card . '(member_process)', 'key' => $member_id, 'result' => $response_member['ResponseCd'], 'data' => $response_member, ); usces_save_order_acting_error( $log ); $this->save_acting_log( $response_member, $order_id . '_' . $rand ); $this->auto_settlement_error_mail( $member_id, $order_id, $response_member, $continue_data ); do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $response_member ); } } else { $logdata = array( 'KaiinId' => $kaiin_id, 'KaiinPass' => $kaiin_pass, ); $log = array( 'acting' => $this->acting_card . '(member_process)', 'key' => $member_id, 'result' => 'MEMBER ERROR', 'data' => $logdata, ); usces_save_order_acting_error( $log ); $log['ResponseCd'] = 'NG'; $log['MerchantFree1'] = $rand; $this->save_acting_log( $log, $order_id . '_' . $rand ); $this->auto_settlement_error_mail( $member_id, $order_id, $logdata, $continue_data ); do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $log ); } } /** * 自動継続課金処理メール(正常) * * @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_escott_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_escott_auto_settlement_mail_header', $mail_header, $member_id, $order_id, $order_data, $response_data, $continue_data ) . apply_filters( 'usces_filter_escott_auto_settlement_mail_body', $mail_body, $member_id, $order_id, $order_data, $response_data, $continue_data ) . apply_filters( 'usces_filter_escott_auto_settlement_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $response_data, $continue_data ); $headers = apply_filters( 'usces_filter_escott_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_escott_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_escott_auto_settlement_error_mail_header', $mail_header, $member_id, $order_id, $order_data, $response_data, $continue_data ) . apply_filters( 'usces_filter_escott_auto_settlement_error_mail_body', $mail_body, $member_id, $order_id, $order_data, $response_data, $continue_data ) . apply_filters( 'usces_filter_escott_auto_settlement_error_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $response_data, $continue_data ); $headers = apply_filters( 'usces_filter_escott_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 $response_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, $response_data, $continue_data, $html = true ) { global $usces; if ( usces_is_html_mail() && $html ) { $message = $this->auto_settlement_message_htmlbody( $member_id, $order_id, $order_data, $response_data, $continue_data ); } else { $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'] : ''; $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"; $cart = usces_get_ordercartdata( $order_id ); $cart_row = current( $cart ); $item_name = $usces->getCartItemName_byOrder( $cart_row ); $options = ( empty( $cart_row['options'] ) ) ? array() : $cart_row['options']; $message .= __( 'Items', 'usces' ) . ' : ' . $item_name . "\r\n"; if ( is_array( $options ) && count( $options ) > 0 ) { $optstr = ''; foreach ( $options as $key => $value ) { if ( ! empty( $key ) ) { $key = urldecode( $key ); $value = wel_safe_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 ( isset( $response_data['reminder'] ) ) { 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"; } } else { if ( isset( $response_data['MerchantFree1'] ) ) { $message .= __( 'Transaction ID', 'usces' ) . ' : ' . $response_data['MerchantFree1'] . "\r\n"; } if ( isset( $response_data['TransactionId'] ) ) { $message .= __( 'Sequence number', 'usces' ) . ' : ' . $response_data['TransactionId'] . "\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"; } $message .= "\r\n"; if ( isset( $response_data['ResponseCd'] ) ) { if ( 'OK' === $response_data['ResponseCd'] ) { $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Normal done', 'usces' ) . "\r\n"; } else { $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Error', 'usces' ) . "\r\n"; $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $message .= $cd . ' : ' . $this->response_message( $cd ) . "\r\n"; } } } else { $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Error', 'usces' ) . "\r\n"; $message .= __( 'Credit card is not registered.', 'usces' ) . "\r\n"; } } $message .= usces_mail_line( 2 ) . "\r\n"; } return $message; } /** * Automatic renewal billing process email body html * * @param int $member_id Member ID. * @param int $order_id Order number. * @param array $order_data Order data. * @param array $response_data Response data. * @param array $continue_data Continuation data. * @return string */ public function auto_settlement_message_htmlbody( $member_id, $order_id, $order_data, $response_data, $continue_data ) { 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'] : ''; $message = ''; $message .= ''; $message .= ''; $message .= ''; $message .= ''; $cart = usces_get_ordercartdata( $order_id ); $cart_row = current( $cart ); $item_name = $usces->getCartItemName_byOrder( $cart_row ); $options = ( empty( $cart_row['options'] ) ) ? array() : $cart_row['options']; $message .= ''; $message .= ''; if ( isset( $response_data['reminder'] ) ) { if ( ! empty( $charged_date ) ) { $message .= ''; } if ( ! empty( $contracted_date ) ) { $message .= ''; } } else { if ( isset( $response_data['MerchantFree1'] ) ) { $message .= ''; } if ( isset( $response_data['TransactionId'] ) ) { $message .= ''; } if ( ! empty( $charged_date ) ) { $message .= ''; } if ( ! empty( $contracted_date ) ) { $message .= ''; } if ( isset( $response_data['ResponseCd'] ) ) { if ( 'OK' === $response_data['ResponseCd'] ) { $message .= ''; } else { $message .= ''; } } else { $message .= ''; } } $message .= '
    '; $message .= __( 'Order ID', 'dlseller' ); $message .= ''; $message .= $order_id; $message .= '
    '; $message .= __( 'Application Date', 'dlseller' ); $message .= ''; $message .= $order_data['order_date']; $message .= '
    '; $message .= __( 'Member ID', 'dlseller' ); $message .= ''; $message .= $member_id; $message .= '
    '; $message .= __( 'Contractor name', 'dlseller' ); $message .= ''; $message .= sprintf( _x( '%s', 'honorific', 'usces' ), $name ); $message .= '
    '; $message .= __( 'Items', 'usces' ); $message .= ''; $message .= $item_name; if ( is_array( $options ) && count( $options ) > 0 ) { $optstr = ''; foreach ( $options as $key => $value ) { if ( ! empty( $key ) ) { $key = urldecode( $key ); $value = wel_safe_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 .= __( 'Settlement amount', 'usces' ); $message .= ''; $message .= usces_crform( $continue_data['price'], true, false, 'return' ); $message .= '
    '; $message .= __( 'Next Withdrawal Date', 'dlseller' ); $message .= ''; $message .= $charged_date; $message .= '
    '; $message .= __( 'Renewal Date', 'dlseller' ); $message .= ''; $message .= $contracted_date; $message .= '
    '; $message .= __( 'Transaction ID', 'usces' ); $message .= ''; $message .= $response_data['MerchantFree1']; $message .= '
    '; $message .= __( 'Sequence number', 'usces' ); $message .= ''; $message .= $response_data['TransactionId']; $message .= '
    '; $message .= __( 'Next Withdrawal Date', 'dlseller' ); $message .= ''; $message .= $charged_date; $message .= '
    '; $message .= __( 'Renewal Date', 'dlseller' ); $message .= ''; $message .= $contracted_date; $message .= '
    '; $message .= __( 'Result', 'usces' ); $message .= ''; $message .= __( 'Normal done', 'usces' ); $message .= '
    '; $message .= __( 'Result', 'usces' ); $message .= ''; $message .= __( 'Error', 'usces' ); $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $message .= $cd . ' : ' . $this->response_message( $cd ) . '
    '; } $message .= '
    '; $message .= __( 'Result', 'usces' ); $message .= ''; $message .= __( 'Error', 'usces' ) . '
    '; $message .= __( 'Credit card is not registered.', 'usces' ); $message .= '
    '; 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_escott_auto_settlement_mail_admin_subject', __( 'Automatic Continuing Charging Process Result', 'usces' ) . ' ' . $today, $today ); $admin_footer = apply_filters( 'usces_filter_escott_auto_settlement_mail_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' ) . ' : ' . date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "\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. */ 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' ); $response_data = array( 'reminder' => 'reminder' ); $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_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. */ 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' ); $response_data = array( 'reminder' => 'contract_renewal' ); $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data ); return $mail_body; } /** * 利用可能な支払方法 * wcad_filter_available_regular_payment_method * * @param array $payment_method Payment method. * @return array */ public function available_regular_payment_method( $payment_method ) { $acting_opts = $this->get_acting_settings(); if ( isset( $acting_opts['quickpay'] ) && 'on' === $acting_opts['quickpay'] ) { $payment_method[] = 'acting_welcart_card'; } return $payment_method; } /** * 発送先リスト利用可能決済 * wcad_filter_shippinglist_acting * * @param string $acting Payment method. * @return string */ public function set_shippinglist_acting( $acting ) { $acting = 'acting_welcart_card'; return $acting; } /** * 定期購入決済処理 * wcad_action_reg_auto_orderdata * * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $total_amount, $reg_id, $order_date ). */ public function register_auto_orderdata( $args ) { global $usces; extract( $args ); // phpcs:ignore $acting_opts = $this->get_acting_settings(); if ( ! usces_is_membersystem_state() || 'on' !== $acting_opts['quickpay'] ) { return; } if ( 0 >= $total_amount ) { return; } $acting_flg = $payments['settlement']; if ( 'acting_welcart_card' !== $payments['settlement'] ) { return; } $settltment_errmsg = ''; $kaiin_id = $this->get_quick_kaiin_id( $member_id ); $kaiin_pass = $this->get_quick_pass( $member_id ); $rand = usces_acting_key(); if ( ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) { $transaction_date = $this->get_transaction_date(); $param_list = array(); $params_member = array(); $params = array(); /* 共通部 */ $param_list['MerchantId'] = $acting_opts['merchant_id']; $param_list['MerchantPass'] = $acting_opts['merchant_pass']; $param_list['TransactionDate'] = $transaction_date; $param_list['MerchantFree1'] = $rand; $param_list['MerchantFree2'] = 'acting_welcart_card'; $param_list['MerchantFree3'] = $this->merchantfree3; $param_list['TenantId'] = $acting_opts['tenant_id']; $params_member['send_url'] = $acting_opts['send_url_member']; $params_member['param_list'] = array_merge( $param_list, array( 'OperateId' => '4MemRefM', 'KaiinId' => $kaiin_id, 'KaiinPass' => $kaiin_pass, ) ); /* e-SCOTT 会員照会 */ $response_member = $this->connection( $params_member ); if ( 'OK' === $response_member['ResponseCd'] ) { $params['send_url'] = $acting_opts['send_url']; $params['param_list'] = array_merge( $param_list, array( 'OperateId' => $acting_opts['operateid'], 'Amount' => $total_amount, 'PayType' => '01', 'KaiinId' => $kaiin_id, 'KaiinPass' => $kaiin_pass, ) ); /* e-SCOTT 決済 */ $response_data = $this->connection( $params ); if ( ! isset( $response_data['Amount'] ) ) { $response_data['Amount'] = $total_amount; } $response_data = apply_filters( 'usces_filter_escott_auto_register_orderdata_history_log', $response_data, $member_id, $order_id ); $this->save_acting_history_log( $response_data, $order_id . '_' . $rand ); if ( 'OK' === $response_data['ResponseCd'] ) { $usces->set_order_meta_value( 'trans_id', $rand, $order_id ); $usces->set_order_meta_value( 'wc_trans_id', $rand, $order_id ); $cardlast4 = substr( $response_member['CardNo'], -4 ); $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 ); $expmm = substr( $response_member['CardExp'], 2, 2 ); $response_data['acting'] = $this->acting_card; $response_data['PayType'] = '01'; $response_data['CardNo'] = $cardlast4; $response_data['CardExp'] = $expyy . '/' . $expmm; $usces->set_order_meta_value( $acting_flg, usces_serialize( $response_data ), $order_id ); } else { $settltment_errmsg = __( '[Regular purchase] Settlement was not completed.', 'autodelivery' ); $responsecd = explode( '|', $response_data['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $response_data[ $cd ] = $this->response_message( $cd ); } $log = array( 'acting' => $this->acting_card, 'key' => $rand, 'result' => $response_data['ResponseCd'], 'data' => $response_data, ); usces_save_order_acting_error( $log ); } do_action( 'usces_action_register_auto_orderdata', $args, $response_data ); } else { if ( ! isset( $response_member['Amount'] ) ) { $response_member['Amount'] = $total_amount; } $response_member = apply_filters( 'usces_filter_escott_auto_register_orderdata_history_log', $response_member, $member_id, $order_id ); $this->save_acting_history_log( $response_member, $order_id . '_' . $rand ); $settltment_errmsg = __( '[Regular purchase] Member information acquisition error.', 'autodelivery' ); $responsecd = explode( '|', $response_member['ResponseCd'] ); foreach ( (array) $responsecd as $cd ) { $response_member[ $cd ] = $this->response_message( $cd ); } $log = array( 'acting' => $this->acting_card . '(member_process)', 'key' => $member_id, 'result' => $response_member['ResponseCd'], 'data' => $response_member, ); usces_save_order_acting_error( $log ); do_action( 'usces_action_register_auto_orderdata', $args, $response_member ); } } else { $settltment_errmsg = __( '[Regular purchase] Member information acquisition error.', 'autodelivery' ); $logdata = array( 'KaiinId' => $kaiin_id, 'KaiinPass' => $kaiin_pass, ); $log = array( 'acting' => $this->acting_card . '(member_process)', 'key' => $member_id, 'result' => 'MEMBER ERROR', 'data' => $logdata, ); usces_save_order_acting_error( $log ); do_action( 'usces_action_register_auto_orderdata', $args, $log ); } if ( '' !== $settltment_errmsg ) { $settlement = array( 'settltment_status' => __( 'Failure', 'autodelivery' ), 'settltment_errmsg' => $settltment_errmsg, ); $usces->set_order_meta_value( $acting_flg, usces_serialize( $settlement ), $order_id ); wcad_settlement_error_mail( $order_id, $settltment_errmsg ); } } /** * 決済ログ出力 * * @param array $log Log data. * @param string $log_key [order_id]_[trans_id]. * @return boolean */ private function save_acting_log( $log, $log_key ) { global $wpdb; $datetime = current_time( 'mysql' ); $query = $wpdb->prepare( "INSERT INTO {$wpdb->prefix}usces_log ( `datetime`, `log`, `log_type`, `log_key` ) VALUES ( %s, %s, %s, %s )", $datetime, usces_serialize( $log ), 'acting_welcart', $log_key ); $res = $wpdb->query( $query ); // phpcs:ignore return $res; } /** * 決済ログ取得 * * @param int $order_id Order number. * @param string $log_key [order_id]_[trans_id]. * @return array */ public function get_acting_log( $order_id, $log_key = '' ) { global $wpdb; if ( ! empty( $log_key ) ) { $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}usces_log WHERE `log_type` = 'acting_welcart' AND `log_key` = %s ORDER BY datetime DESC", $log_key ); } else { $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}usces_log WHERE `log_type` = 'acting_welcart' AND `log_key` LIKE %s ORDER BY datetime DESC", $wpdb->esc_like( $order_id . '_' ) . '%' ); } $log_data = $wpdb->get_results( $query, ARRAY_A ); // phpcs:ignore return $log_data; } /** * 決済ログ更新 * * @param array $log Log data. * @param string $log_key [order_id]_[trans_id]. * @return boolean */ private function update_acting_log( $log, $log_key ) { global $wpdb; $datetime = current_time( 'mysql' ); $query = $wpdb->prepare( "UPDATE {$wpdb->prefix}usces_log SET `datetime` = %s, `log` = %s WHERE `log_type` = %s AND `log_key` = %s", $datetime, usces_serialize( $log ), 'acting_welcart', $log_key ); $res = $wpdb->query( $query ); // phpcs:ignore return $res; } /** * 決済履歴ログ出力 * * @param array $log Log data. * @param string $log_key [order_id]_[trans_id]. * @return boolean */ private function save_acting_history_log( $log, $log_key ) { global $wpdb; $datetime = current_time( 'mysql' ); $query = $wpdb->prepare( "INSERT INTO {$wpdb->prefix}usces_log ( `datetime`, `log`, `log_type`, `log_key` ) VALUES ( %s, %s, %s, %s )", $datetime, usces_serialize( $log ), 'acting_welcart_history', $log_key ); $res = $wpdb->query( $query ); // phpcs:ignore return $res; } /** * 決済履歴ログ取得 * * @param string $log_key [order_id]_[trans_id]. * @return array */ public function get_acting_history_log( $log_key ) { global $wpdb; $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}usces_log WHERE `log_type` = 'acting_welcart_history' AND `log_key` = %s ORDER BY datetime DESC", $log_key ); $log_data = $wpdb->get_results( $query, ARRAY_A ); // phpcs:ignore return $log_data; } /** * 決済処理取得 * * @param string $log_key [order_id]_[trans_id]. * @return string */ private function get_acting_operateid( $log_key ) { $operateid = ''; $latest_log = $this->get_acting_latest_log( $log_key, 'OK' ); if ( isset( $latest_log['OperateId'] ) ) { $operateid = $latest_log['OperateId']; } return $operateid; } /** * 初回決済処理取得 * * @param string $log_key [order_id]_[trans_id]. * @return string */ private function get_acting_first_operateid( $log_key ) { global $wpdb; $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}usces_log WHERE `log_type` = 'acting_welcart_history' AND `log_key` = %s ORDER BY datetime ASC", $log_key ); $log_data = $wpdb->get_results( $query, ARRAY_A ); // phpcs:ignore if ( $log_data ) { $log = usces_unserialize( $log_data[0]['log'] ); $operateid = ( isset( $log['OperateId'] ) ) ? $log['OperateId'] : ''; } else { $operateid = ''; } return $operateid; } /** * 決済履歴 * * @param string $log_key [order_id]_[trans_id]. * @return string */ private function settlement_history( $log_key ) { $html = ''; $log_data = $this->get_acting_history_log( $log_key ); if ( $log_data ) { $num = count( $log_data ); $html = ''; foreach ( (array) $log_data as $data ) { $log = usces_unserialize( $data['log'] ); $class = ( 'OK' !== $log['ResponseCd'] ) ? ' error' : ''; $operate_name = ( isset( $log['OperateId'] ) ) ? $this->get_operate_name( $log['OperateId'] ) : ''; $amount = ( isset( $log['Amount'] ) ) ? usces_crform( $log['Amount'], false, true, 'return', true ) : ''; $html .= ''; $num--; } $html .= '
    ' . __( 'Processing date', 'usces' ) . '' . __( 'Sequence number', 'usces' ) . '' . __( 'Processing classification', 'usces' ) . '' . __( 'Amount', 'usces' ) . '' . __( 'Result', 'usces' ) . '
    ' . $num . ' ' . $data['datetime'] . ' ' . $log['TransactionId'] . ' ' . $operate_name . ' ' . $amount . ' ' . $log['ResponseCd'] . '
    '; } return $html; } /** * 最新処理取得 * * @param string $log_key [order_id]_[trans_id]. * @param string $responsecd ResponseCd. * @return array */ public function get_acting_latest_log( $log_key, $responsecd = 'OK' ) { $latest_log = array(); $log_data = $this->get_acting_history_log( $log_key ); if ( $log_data ) { if ( 'OK' === $responsecd ) { $reauth = false; foreach ( (array) $log_data as $data ) { $log = usces_unserialize( $data['log'] ); if ( isset( $log['ResponseCd'] ) ) { if ( 'OK' === $log['ResponseCd'] && in_array( $log['OperateId'], $this->reauth_status ) ) { $reauth = true; } else { if ( $reauth ) { if ( 'OK' === $log['ResponseCd'] && in_array( $log['OperateId'], $this->primarily_status ) ) { $latest_log = $log; break; } } else { if ( 'OK' === $log['ResponseCd'] && in_array( $log['OperateId'], $this->latest_status ) ) { $latest_log = $log; break; } } } } } } else { $latest_log = usces_unserialize( $log_data[0]['log'] ); } } return $latest_log; } /** * 最新処理ステータス取得 * * @param int $member_id Member ID. * @param int $order_id Order number. * @return string */ public function get_latest_status( $member_id, $order_id ) { global $usces; $status = ''; $log_data = $this->get_acting_log( $order_id ); if ( $log_data && 0 < count( $log_data ) ) { $acting_data = usces_unserialize( $log_data[0]['log'] ); $trans_id = ( isset( $acting_data['MerchantFree1'] ) ) ? $acting_data['MerchantFree1'] : ''; } else { $trans_id = $usces->get_order_meta_value( 'trans_id', $order_id ); } if ( $trans_id ) { $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id, 'ALL' ); $status = ( isset( $latest_log['ResponseCd'] ) ) ? $latest_log['ResponseCd'] : 'NG'; } return $status; } /** * 処理区分名称取得 * * @param string $log_key [order_id]_[trans_id]. * @return string */ private function get_acting_status_name( $log_key ) { $status_name = ''; $log_data = $this->get_acting_history_log( $log_key ); if ( $log_data ) { $log = usces_unserialize( $log_data[0]['log'] ); if ( isset( $log['OperateId'] ) ) { $status_name = $this->get_operate_name( $log['OperateId'] ); } } return $status_name; } /** * 銀聯取引ステータス取得 * * @param string $status Status. * @return string */ protected function get_unionpay_status_name( $status ) { $status_name = ''; switch ( trim( $status ) ) { case 1: /* 売上確定済 */ $status_name = __( 'Sales confirmed', 'usces' ); break; case 2: /* 取消済 */ $status_name = __( 'Canceled', 'usces' ); break; case 3: /* 返品済 */ $status_name = __( 'Returned', 'usces' ); break; case 4: /* 参照処理済 */ $status_name = __( 'Reference processed', 'usces' ); break; case 97: /* NG(詳細不明) */ $status_name = __( 'NG (details unknown)', 'usces' ); break; case 98: /* レスポンス不明 */ $status_name = __( 'Unknown response', 'usces' ); break; case 99: $status_name = 'NG'; break; } return $status_name; } /** * 期限切れチェック * * @param int $order_id Order number. * @param string $trans_id Transaction ID. * @return boolean */ private function check_paylimit( $order_id, $trans_id ) { global $usces; $expiration = false; $receipted = false; $log_data = $this->get_acting_history_log( $order_id . '_' . $trans_id ); if ( $log_data ) { foreach ( (array) $log_data as $data ) { $log = usces_unserialize( $data['log'] ); if ( isset( $log['OperateId'] ) && 'receipted' === $log['OperateId'] ) { $receipted = true; break; } } } if ( $receipted ) { return false; } $today = date_i18n( 'YmdHi', current_time( 'timestamp' ) ); $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_conv', $order_id ) ); if ( ! empty( $acting_data['PayLimit'] ) && $today > $acting_data['PayLimit'] ) { $expiration = true; } return $expiration; } /** * 削除済みチェック * * @param string $log_key [order_id]_[trans_id]. * @return boolean */ private function check_deleted( $log_key ) { $deleted = false; $log_data = $this->get_acting_history_log( $log_key ); if ( $log_data ) { foreach ( (array) $log_data as $data ) { $log = usces_unserialize( $data['log'] ); if ( isset( $log['OperateId'] ) && '2Del' === $log['OperateId'] ) { $deleted = true; break; } } } return $deleted; } /** * 継続課金会員データ取得 * * @param int $order_id Order number. * @param int $member_id Member ID. * @return array */ private function get_continuation_data( $order_id, $member_id ) { global $wpdb; $query = $wpdb->prepare( "SELECT `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 ); // phpcs:ignore return $data; } /** * 継続課金会員データ更新 * * @param int $order_id Order number. * @param int $member_id Member ID. * @param array $data Continuation data. * @param boolean $stop Stop continuous billing. * @return boolean */ private function update_continuation_data( $order_id, $member_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 ); // phpcs:ignore return $res; } /** * 日付チェック * * @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_fiter_the_payment_method * * @param array $payments Payment data. * @return array */ public function payment_method( $payments ) { global $usces; $conv_exclusion = false; $atodene_exclusion = false; if ( usces_have_regular_order() ) { $conv_exclusion = true; } elseif ( usces_have_continue_charge() ) { $conv_exclusion = true; $atodene_exclusion = true; } else { $acting_opts = $this->get_acting_settings(); if ( 'on' === $acting_opts['atodene_byitem'] ) { /* 商品ごとの可否が有効 */ $cart = $usces->cart->get_cart(); foreach ( $cart as $cart_row ) { $product = wel_get_product( $cart_row['post_id'] ); $atodene_propriety = $product['atodene_propriety']; if ( 1 === (int) $atodene_propriety ) { $atodene_exclusion = true; break; } } } } if ( $conv_exclusion ) { foreach ( $payments as $key => $payment ) { if ( $this->acting_flg_conv === $payment['settlement'] ) { unset( $payments[ $key ] ); } } } if ( $atodene_exclusion ) { foreach ( $payments as $key => $payment ) { if ( $this->acting_flg_atodene === $payment['settlement'] ) { unset( $payments[ $key ] ); } } } return $payments; } /** * ATODENE CSVアップロード * usces_after_cart_instant */ public function atodene_upload() { if ( isset( $_POST['page'] ) && 'atodene_results_csv' === wp_unslash( $_POST['page'] ) && isset( $_POST['action'] ) && 'atodene_upload' === wp_unslash( $_POST['action'] ) ) { $path = WP_CONTENT_DIR . '/uploads/'; $workfile = $_FILES['atodene_upcsv']['tmp_name']; if ( ! is_uploaded_file( $workfile ) ) { $message = __( 'The file was not uploaded.', 'usces' ); wp_redirect( add_query_arg( array( 'page' => 'usces_orderlist', 'usces_status' => 'error', 'usces_message' => urlencode( $message ), 'order_action' => 'atodene_upload', ), USCES_ADMIN_URL ) ); exit(); } list( $fname, $fext ) = explode( '.', $_FILES['atodene_upcsv']['name'], 2 ); if ( 'csv' !== $fext ) { $message = __( 'The file is not supported.', 'usces' ) . $fname . '.' . $fext; wp_redirect( add_query_arg( array( 'page' => 'usces_orderlist', 'usces_status' => 'error', 'usces_message' => urlencode( $message ), 'order_action' => 'atodene_upload', ), USCES_ADMIN_URL ) ); exit(); } $new_filename = base64_encode( $fname . '_' . time() . '.' . $fext ); if ( ! move_uploaded_file( $_FILES['atodene_upcsv']['tmp_name'], $path . $new_filename ) ) { $message = __( 'The file was not stored.', 'usces' ) . $_FILES['atodene_upcsv']['name']; wp_redirect( add_query_arg( array( 'page' => 'usces_orderlist', 'usces_status' => 'error', 'usces_message' => urlencode( $message ), 'order_action' => 'atodene_upload', ), USCES_ADMIN_URL ) ); exit(); } wp_redirect( add_query_arg( array( 'page' => 'usces_orderlist', 'usces_status' => 'none', 'usces_message' => '', 'order_action' => 'upload_atodene_results', 'atodene_upfile' => urlencode( $new_filename ), 'wc_nonce' => wp_create_nonce( 'order_list' ), ), USCES_ADMIN_URL ) ); exit(); } } /** * ATODENE CSV出力・CSVアップロード * usces_action_order_list_page * * @param string $order_action Order action. */ public function output_atodene_csv( $order_action ) { switch ( $order_action ) { case 'download_atodene_register': $this->download_atodene_register(); break; case 'download_atodene_update': $this->download_atodene_update(); break; case 'download_atodene_report': $this->download_atodene_report(); break; case 'upload_atodene_results': if ( isset( $_GET['atodene_upfile'] ) && ! WCUtils::is_blank( wp_unslash( $_GET['atodene_upfile'] ) ) ) { $res = $this->upload_atodene_results(); $_GET['usces_status'] = ( isset( $res['status'] ) ) ? $res['status'] : ''; $_GET['usces_message'] = ( isset( $res['message'] ) ) ? $res['message'] : ''; } break; } } /** * ATODENE アクションボタン * usces_action_order_list_searchbox_bottom */ public function action_atodene_button() { ?> getItemDivision( $post_id ); $charging_type = $usces->getItemChargingType( $post_id ); $acting_opts = $this->get_acting_settings(); if ( 'shipped' === $division && 'continue' !== $charging_type && 'on' === $acting_opts['atodene_byitem'] ) { /* 商品ごとの可否が有効 */ $product = wel_get_product( $post_id ); $atodene_propriety = $product['atodene_propriety']; $checked = ( 1 === (int) $atodene_propriety ) ? array( '', ' checked="checked"' ) : array( ' checked="checked"', '' ); $second_section .= ' ' . __( 'Atobarai Propriety', 'usces' ) . ' '; } return $second_section; } /** * 後払い決済の可否更新 * usces_action_save_product * * @param int $post_id Post ID. * @param array $post Post data. */ public function save_item_atodene_byitem( $post_id, $post ) { /* This process has moved to item_post.php 1567. */ // if ( isset( $_POST['atodene_propriety'] ) ) { // update_post_meta( $post_id, 'atodene_propriety', $_POST['atodene_propriety'] ); // } } /** * 接続しない決済モジュール * usces_filter_nonacting_settlements * * @param array $nonacting_settlements Non-working settlement module.. * @return array */ public function nonacting_settlements( $nonacting_settlements ) { if ( ! in_array( 'acting_welcart_atodene', $nonacting_settlements ) ) { $nonacting_settlements[] = 'acting_welcart_atodene'; } return $nonacting_settlements; } /** * 利用可能な支払方法 * wcad_filter_the_payment_method_restriction * * @param array $payments_restriction Payment method. * @param string $payments_value Input value. * @return array */ public function payment_method_restriction_atodene( $payments_restriction, $payments_value ) { global $usces; $acting_opts = $this->get_acting_settings(); if ( usces_have_regular_order() ) { $atodene_exclusion = false; if ( 'on' === $acting_opts['atodene_byitem'] ) { /* 商品ごとの可否が有効 */ $cart = $usces->cart->get_cart(); foreach ( $cart as $cart_row ) { $product = wel_get_product( $cart_row['post_id'] ); $atodene_propriety = $product['atodene_propriety']; if ( 1 === (int) $atodene_propriety ) { $atodene_exclusion = true; break; } } } if ( ! $atodene_exclusion ) { $payments = usces_get_system_option( 'usces_payment_method', 'settlement' ); $payments_restriction[] = $payments['acting_welcart_atodene']; foreach ( (array) $payments_restriction as $key => $value ) { $sort[ $key ] = $value['sort']; } array_multisort( $sort, SORT_ASC, $payments_restriction ); } } return $payments_restriction; } /** * ATODENE 取引登録CSV出力 */ public function download_atodene_register() { global $usces; $acting_opts = $this->get_acting_settings(); $filename = mb_convert_encoding( __( 'ATODENE_transaction_', 'usces' ), 'SJIS', 'UTF-8' ) . date_i18n( 'YmdHis', current_time( 'timestamp' ) ) . '.csv'; $line = '"ご購入店受注番号","購入者注文日","会社名","部署名","氏名","氏名(フリガナ)","郵便番号","住所","電話番号","メールアドレス","配送先会社名","配送先部署名","配送先氏名","配送先氏名(フリガナ)","配送先郵便番号","配送先住所","配送先電話番号","請求書送付方法","予備領域1","予備領域2","予備領域3","顧客請求総額(税込)","明細名(商品名)","単価(税込)","数量"' . "\r\n"; $ids = $_GET['listcheck']; foreach ( (array) $ids as $order_id ) { $order_data = $usces->get_order_data( $order_id, 'direct' ); $payment = $usces->getPayments( $order_data['order_payment_name'] ); if ( 'acting_welcart_atodene' !== $payment['settlement'] ) { continue; } $delivery = usces_unserialize( $order_data['order_delivery'] ); $cart = usces_get_ordercartdata( $order_id ); $order_date = substr( $order_data['order_date'], 0, 10 ); $date = str_replace( '-', '/', $order_date ); $company = $usces->get_order_meta_value( 'cscs_company', $order_id ); $order_name = $order_data['order_name1'] . $order_data['order_name2']; $order_kana = mb_convert_kana( $order_data['order_name3'], 'ak', 'UTF-8' ) . mb_convert_kana( $order_data['order_name4'], 'ak', 'UTF-8' ); $order_zip = str_replace( 'ー', '', mb_convert_kana( $order_data['order_zip'], 'a', 'UTF-8' ) ); $order_post = str_replace( '-', '', $order_zip ); $order_address = $order_data['order_pref'] . $order_data['order_address1']; if ( ! empty( $order_data['order_address2'] ) ) { $order_address .= mb_convert_kana( $order_data['order_address2'], 'ak', 'UTF-8' ); } if ( ! empty( $order_data['order_address3'] ) ) { $order_address .= mb_convert_kana( $order_data['order_address3'], 'ak', 'UTF-8' ); } $order_tel = $order_data['order_tel']; $email = $order_data['order_email']; $shipto_company = $usces->get_order_meta_value( 'csde_company', $order_id ); $shipto_name = $delivery['name1'] . $delivery['name2']; $shipto_kana = mb_convert_kana( $delivery['name3'], 'ak', 'UTF-8' ) . mb_convert_kana( $delivery['name4'], 'ak', 'UTF-8' ); $shipto_zip = str_replace( 'ー', '', mb_convert_kana( $delivery['zipcode'], 'a', 'UTF-8' ) ); $shipto_post = str_replace( '-', '', $delivery['zipcode'] ); $shipto_address = $delivery['pref'] . $delivery['address1']; if ( ! empty( $delivery['address2'] ) ) { $shipto_address .= mb_convert_kana( $delivery['address2'], 'ak', 'UTF-8' ); } if ( ! empty( $delivery['address3'] ) ) { $shipto_address .= mb_convert_kana( $delivery['address3'], 'ak', 'UTF-8' ); } $shipto_tel = $delivery['tel']; $amount = $order_data['order_item_total_price'] - $order_data['order_usedpoint'] + $order_data['order_discount'] + $order_data['order_shipping_charge'] + $order_data['order_cod_fee'] + $order_data['order_tax']; $line .= '"' . $order_id . '",' . '"' . $date . '",' . '"' . $company . '","",' . '"' . $order_name . '",' . '"' . $order_kana . '",' . '"' . $order_post . '",' . '"' . $order_address . '",' . '"' . $order_tel . '",' . '"' . $email . '",' . '"' . $shipto_company . '","",' . '"' . $shipto_name . '",' . '"' . $shipto_kana . '",' . '"' . $shipto_post . '",' . '"' . $shipto_address . '",' . '"' . $shipto_tel . '",' . '"' . $acting_opts['atodene_billing_method'] . '","","","",' . '"' . $amount . '",'; $row = 1; foreach ( $cart as $cart_row ) { if ( 1 < $row ) { $line .= '"","","","","","","","","","","","","","","","","","","","","","",'; } $line .= '"' . $cart_row['item_name'] . '",'; $line .= '"' . usces_crform( $cart_row['price'], false, false, 'return', false ) . '",'; $line .= '"' . $cart_row['quantity'] . '"' . "\r\n"; $row++; } if ( 0 !== (int) $order_data['order_discount'] ) { $line .= '"","","","","","","","","","","","","","","","","","","","","","",'; $line .= '"' . apply_filters( 'usces_confirm_discount_label', __( 'Discount', 'usces' ), $order_id ) . '",'; $line .= '"' . usces_crform( $cart_row['order_discount'], false, false, 'return', false ) . '","1"' . "\r\n"; } if ( usces_is_tax_display() && 'products' === usces_get_tax_target() && 'exclude' === usces_get_tax_mode() ) { $line .= '"","","","","","","","","","","","","","","","","","","","","","",'; $line .= '"' . usces_tax_label( $order_data, 'return' ) . '",'; $line .= '"' . usces_crform( $order_data['order_tax'], false, false, 'return', false ) . '","1"' . "\r\n"; } if ( usces_is_member_system() && usces_is_member_system_point() && 0 === (int) usces_point_coverage() && 0 !== (int) $order_data['order_usedpoint'] ) { $line .= '"","","","","","","","","","","","","","","","","","","","","","",'; $line .= '"' . __( 'use of points', 'usces' ) . '",'; $line .= '"' . usces_crform( $order_data['order_usedpoint'], false, false, 'return', false ) . '","1"' . "\r\n"; } if ( 0 < $order_data['order_shipping_charge'] ) { $line .= '"","","","","","","","","","","","","","","","","","","","","","",'; $line .= '"' . __( 'Shipping', 'usces' ) . '",'; $line .= '"' . usces_crform( $order_data['order_shipping_charge'], false, false, 'return', false ) . '","1"' . "\r\n"; } if ( 0 < $order_data['order_cod_fee'] ) { $line .= '"","","","","","","","","","","","","","","","","","","","","","",'; $line .= '"' . apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ) ) . '",'; $line .= '"' . usces_crform( $order_data['order_cod_fee'], false, false, 'return', false ) . '","1"' . "\r\n"; } if ( usces_is_tax_display() && 'all' === usces_get_tax_target() && 'exclude' === usces_get_tax_mode() ) { $line .= '"","","","","","","","","","","","","","","","","","","","","","",'; $line .= '"' . usces_tax_label( $order_data, 'return' ) . '",'; $line .= '"' . usces_crform( $order_data['order_tax'], false, false, 'return', false ) . '","1"' . "\r\n"; } if ( usces_is_member_system() && usces_is_member_system_point() && 1 === (int) usces_point_coverage() && 0 !== (int) $order_data['order_usedpoint'] ) { $line .= '"","","","","","","","","","","","","","","","","","","","","","",'; $line .= '"' . __( 'use of points', 'usces' ) . '",'; $line .= '"' . usces_crform( $order_data['order_usedpoint'], false, false, 'return', false ) . '","1"' . "\r\n"; } } header( 'Content-Type: application/octet-stream' ); header( "Content-disposition: attachment; filename=$filename" ); mb_http_output( 'pass' ); print( mb_convert_encoding( $line, 'SJIS-win', 'UTF-8' ) ); // phpcs:ignore exit(); } /** * ATODENE 取引一括変更・キャンセルCSV出力 */ public function download_atodene_update() { exit(); } /** * ATODENE 出荷報告登録CSV出力 */ public function download_atodene_report() { global $usces; $acting_opts = $this->get_acting_settings(); $filename = mb_convert_encoding( __( 'ATODENE_shippingreport_', 'usces' ), 'SJIS', 'UTF-8' ) . date_i18n( 'YmdHis', current_time( 'timestamp' ) ) . '.csv'; $line = '"運送会社名","配送伝票番号","購入者注文日","お問合せ番号","ご購入店受注番号","氏名","予備項目","配送先氏名","配送先住所","顧客請求金額(税込)","請求書送付方法","審査結果"' . "\r\n"; $ids = $_GET['listcheck']; foreach ( (array) $ids as $order_id ) { $order_data = $usces->get_order_data( $order_id, 'direct' ); $payment = $usces->getPayments( $order_data['order_payment_name'] ); if ( 'acting_welcart_atodene' !== $payment['settlement'] ) { continue; } $delivery_company = $usces->get_order_meta_value( 'delivery_company', $order_id ); $tracking_number = $usces->get_order_meta_value( apply_filters( 'usces_filter_tracking_meta_key', 'tracking_number' ), $order_id ); $atodene_number = $usces->get_order_meta_value( 'atodene_number', $order_id ); if ( ! empty( $delivery_company ) && ! empty( $tracking_number ) && ! empty( $atodene_number ) ) { $line .= '"' . $delivery_company . '",' . '"' . $tracking_number . '","",' . '"' . $atodene_number . '",' . '"' . $order_id . '","","","","","","",""' . "\r\n"; } } header( 'Content-Type: application/octet-stream' ); header( "Content-disposition: attachment; filename=$filename" ); mb_http_output( 'pass' ); print( mb_convert_encoding( $line, 'SJIS-win', 'UTF-8' ) ); // phpcs:ignore exit(); } /** * ATODENE 与信審査結果CSV取込 * * @return array */ public function upload_atodene_results() { global $usces, $wpdb; $res = array(); $path = WP_CONTENT_DIR . '/uploads/'; if ( isset( $_GET['atodene_upfile'] ) && ! WCUtils::is_blank( filter_input( INPUT_GET, 'atodene_upfile', FILTER_DEFAULT ) ) && isset( $_GET['order_action'] ) && 'upload_atodene_results' === filter_input( INPUT_GET, 'order_action', FILTER_DEFAULT ) ) { $file_name = urldecode( filter_input( INPUT_GET, 'atodene_upfile' ) ); $decode_filename = base64_decode( $file_name ); if ( ! file_exists( $path . $file_name ) ) { $res['status'] = 'error'; $res['message'] = __( 'CSV file does not exist.', 'usces' ) . esc_html( $decode_filename ); return( $res ); } } $wpdb->query( 'SET SQL_BIG_SELECTS=1' ); set_time_limit( 3600 ); define( 'COL_ORDER_ID', 0 ); /* ご購入店受注番号 */ define( 'COL_ATODINE_NUMBER', 1 ); /* お問合せ番号 */ define( 'COL_NAME', 2 ); /* 氏名 */ define( 'COL_AMOUNT', 3 ); /* 顧客請求金額(税込) */ define( 'COL_BILLING_METHOD', 4 ); /* 請求書送付方法(別送/同梱) */ define( 'COL_RESULTS', 5 ); /* 与信審査結果(OK/NG/保留/審査中) */ if ( ! ( $fpo = fopen( $path . $file_name, 'r' ) ) ) { $res['status'] = 'error'; $res['message'] = __( 'A file does not open.', 'usces' ) . esc_html( $decode_filename ); return $res; } $orglines = array(); $sp = ','; $fname_parts = explode( '.', $decode_filename ); if ( 'csv' !== end( $fname_parts ) ) { $res['status'] = 'error'; $res['message'] = __( 'This file is not in the CSV file.', 'usces' ) . esc_html( $decode_filename ); return $res; } $buf = ''; while ( ! feof( $fpo ) ) { $temp = fgets( $fpo, 10240 ); if ( 0 === strlen( $temp ) ) { continue; } $orglines[] = str_replace( '"', '', $temp ); } fclose( $fpo ); foreach ( $orglines as $sjisline ) { $line = mb_convert_encoding( $sjisline, 'UTF-8', 'SJIS' ); list( $order_id, $atodene_number, $name, $amount, $billing_method, $atodene_results ) = explode( $sp, $line ); if ( ! is_numeric( $order_id ) ) { continue; } $order_data = $usces->get_order_data( $order_id, 'direct' ); if ( $order_data ) { $atodene_results = mb_convert_kana( $atodene_results, 'r', 'UTF-8' ); if ( 'OK' === trim( $atodene_results ) ) { $res = usces_change_order_receipt( (int) $order_id, 'receipted' ); usces_action_acting_getpoint( (int) $order_id ); } if ( ! empty( $atodene_number ) ) { $usces->set_order_meta_value( 'atodene_number', trim( $atodene_number ), (int) $order_id ); } if ( ! empty( $atodene_results ) ) { $usces->set_order_meta_value( 'atodene_results', trim( $atodene_results ), (int) $order_id ); } } } unlink( $path . $file_name ); return $res; } /** * Temporary storage of session data. * usces_filter_save_order_acting_data * * @param array $data Session data. * @return array */ public function save_order_acting_data( $data ) { if ( isset( $_POST['_nonce'] ) ) { $data['_nonce'] = filter_input( INPUT_POST, '_nonce' ); } return $data; } /** * Save admin log. * * @since 2.7.2 * @see admin_ajax() * @param integer $order_id The order id. * @param string $log_key The log key. * @return void */ private function save_admin_log( $order_id, $log_key ) { $latest_log = array(); $log_data = $this->get_acting_history_log( $log_key ); if ( ! empty( $log_data ) ) { $latest_log = current( $log_data ); } Logger::log( $order_id, 'orderedit', 'update', array( 'acting_welcart_card' => $latest_log ) ); } }