PluginProbe
Welcart e-Commerce / 2.11.33
Welcart e-Commerce v2.11.33
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / classes / paymentWelcart.class.php

paymentWelcart.class.php in Welcart e-Commerce 2.11.33, at classes/paymentWelcart.class.php

7,349 lines 346.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Settlement Class.
4 * WelcartPay based on e-SCOTT
5 *
6 * @package Welcart
7 * @author Collne Inc.
8 * @version 1.2.0
9 * @since 1.4.14
10 */
11 class WELCARTPAY_SETTLEMENT extends ESCOTT_MAIN {
12 /**
13 * Instance of this class.
14 *
15 * @var object
16 */
17 protected static $instance = null;
18
19 /**
20 * 継続課金結果通知メール
21 *
22 * @var string
23 */
24 protected $continuation_charging_mail;
25
26 /**
27 * 処理ステータス
28 *
29 * @var array
30 */
31 protected $latest_status = array(
32 '1Auth',
33 '1Capture',
34 '1Gathering',
35 '1Delete',
36 '2Add',
37 '2Chg',
38 '2Del',
39 '5Auth',
40 '5Gathering',
41 '5Capture',
42 '5Delete',
43 'receipted',
44 '11Gathering',
45 '11Delete',
46 );
47
48 /**
49 * 処理ステータス(取消以外)
50 *
51 * @var array
52 */
53 protected $primarily_status = array(
54 '1Auth',
55 '1Gathering',
56 '2Add',
57 '5Auth',
58 '5Gathering',
59 '5Capture',
60 'receipted',
61 );
62
63 /**
64 * 処理ステータス(再オーソリ)
65 *
66 * @var array
67 */
68 protected $reauth_status = array(
69 '1ReAuth',
70 );
71
72 /**
73 * Construct.
74 */
75 public function __construct() {
76 $this->acting_name = 'WelcartPay';
77 $this->acting_formal_name = 'WelcartPay based on e-SCOTT';
78
79 $this->acting_card = 'welcart_card';
80 $this->acting_conv = 'welcart_conv';
81 $this->acting_atodene = 'welcart_atodene';
82 $this->acting_applepay = 'welcart_applepay';
83 $this->acting_unionpay = 'welcart_unionpay';
84
85 $this->acting_flg_card = 'acting_welcart_card';
86 $this->acting_flg_conv = 'acting_welcart_conv';
87 $this->acting_flg_atodene = 'acting_welcart_atodene';
88 $this->acting_flg_applepay = 'acting_welcart_applepay';
89 $this->acting_flg_unionpay = 'acting_welcart_unionpay';
90
91 $this->pay_method = array(
92 'acting_welcart_card',
93 'acting_welcart_conv',
94 'acting_welcart_applepay',
95 'acting_welcart_unionpay',
96 );
97 $this->merchantfree3 = 'wc2collne';
98 $this->quick_key_pre = 'wcpay';
99
100 parent::__construct( 'welcart' );
101
102 if ( $this->is_activate_card() || $this->is_activate_conv() || $this->is_activate_applepay() || $this->is_activate_unionpay() ) {
103 if ( is_admin() ) {
104 add_action( 'usces_action_admin_ajax', array( $this, 'admin_ajax' ) );
105 add_filter( 'usces_filter_orderlist_detail_value', array( $this, 'orderlist_settlement_status' ), 10, 4 );
106 add_action( 'usces_action_order_edit_form_status_block_middle', array( $this, 'settlement_status' ), 10, 3 );
107 add_action( 'usces_action_order_edit_form_settle_info', array( $this, 'settlement_information' ), 10, 2 );
108 add_action( 'usces_action_endof_order_edit_form', array( $this, 'settlement_dialog' ), 10, 2 );
109 }
110 }
111
112 if ( $this->is_validity_acting( 'card' ) ) {
113 add_filter( 'usces_fiter_the_payment_method_explanation', array( $this, 'set_payment_method_explanation' ), 10, 3 );
114 add_filter( 'usces_filter_available_payment_method', array( $this, 'set_available_payment_method' ) );
115 add_filter( 'usces_filter_delivery_secure_form_howpay', array( $this, 'delivery_secure_form_howpay' ) );
116 add_filter( 'usces_filter_template_redirect', array( $this, 'member_update_settlement' ), 1 );
117 add_action( 'usces_action_member_submenu_list', array( $this, 'e_update_settlement' ) );
118 add_filter( 'usces_filter_member_submenu_list', array( $this, 'update_settlement' ), 10, 2 );
119 add_filter( 'usces_filter_save_order_acting_data', array( $this, 'save_order_acting_data' ) );
120
121 /* WCEX DL Seller */
122 if ( defined( 'WCEX_DLSELLER' ) ) {
123 if ( defined( 'WCEX_DLSELLER_VERSION' ) && version_compare( WCEX_DLSELLER_VERSION, '2.2-beta', '<=' ) ) {
124 add_filter( 'usces_filter_the_continue_payment_method', array( $this, 'continuation_payment_method' ) );
125 }
126 add_filter( 'dlseller_filter_first_charging', array( $this, 'first_charging_date' ), 9, 5 );
127 add_filter( 'dlseller_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction' ), 10, 2 );
128 add_filter( 'dlseller_filter_continue_member_list_limitofcard', array( $this, 'continue_member_list_limitofcard' ), 10, 4 );
129 add_filter( 'dlseller_filter_continue_member_list_condition', array( $this, 'continue_member_list_condition' ), 10, 4 );
130 add_action( 'dlseller_action_continue_member_list_page', array( $this, 'continue_member_list_page' ) );
131 add_filter( 'dlseller_filter_card_update_mail', array( $this, 'continue_member_card_update_mail' ), 10, 3 );
132 add_action( 'dlseller_action_do_continuation_charging', array( $this, 'auto_continuation_charging' ), 10, 4 );
133 add_action( 'dlseller_action_do_continuation', array( $this, 'do_auto_continuation' ), 10, 2 );
134 add_filter( 'dlseller_filter_reminder_mail_body', array( $this, 'reminder_mail_body' ), 10, 3 );
135 add_filter( 'dlseller_filter_contract_renewal_mail_body', array( $this, 'contract_renewal_mail_body' ), 10, 3 );
136 }
137
138 /* WCEX Auto Delivery */
139 if ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
140 add_filter( 'wcad_filter_shippinglist_acting', array( $this, 'set_shippinglist_acting' ) );
141 add_filter( 'wcad_filter_available_regular_payment_method', array( $this, 'available_regular_payment_method' ) );
142 add_filter( 'wcad_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction' ), 10, 2 );
143 add_action( 'wcad_action_reg_auto_orderdata', array( $this, 'register_auto_orderdata' ) );
144 }
145 }
146
147 if ( $this->is_activate_atodene() ) {
148 if ( is_admin() ) {
149 add_action( 'usces_after_cart_instant', array( $this, 'atodene_upload' ), 9 );
150 add_action( 'usces_action_order_list_page', array( $this, 'output_atodene_csv' ) );
151 add_action( 'usces_action_order_list_searchbox_bottom', array( $this, 'action_atodene_button' ) );
152 add_action( 'usces_action_order_list_footer', array( $this, 'order_list_footer' ) );
153 add_filter( 'usces_filter_order_list_page_js', array( $this, 'order_list_page_js' ) );
154 add_filter( 'usces_order_list_action_status', array( $this, 'order_list_action_status' ) );
155 add_filter( 'usces_order_list_action_message', array( $this, 'order_list_action_message' ) );
156 add_filter( 'usces_filter_deli_comps', array( $this, 'delivery_company_name' ) );
157
158 $acting_opts = $this->get_acting_settings();
159 if ( isset( $acting_opts['atodene_byitem'] ) && 'on' === $acting_opts['atodene_byitem'] ) {
160 add_filter( 'usces_item_master_second_section', array( $this, 'edit_item_atodene_byitem' ), 10, 2 );
161 add_action( 'usces_action_save_product', array( $this, 'save_item_atodene_byitem' ), 10, 2 );
162 }
163 }
164 }
165
166 if ( $this->is_validity_acting( 'atodene' ) ) {
167 add_filter( 'usces_filter_nonacting_settlements', array( $this, 'nonacting_settlements' ) );
168
169 /* WCEX Auto Delivery */
170 if ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
171 add_filter( 'wcad_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction_atodene' ), 11, 2 );
172 }
173 }
174
175 if ( $this->is_validity_acting( 'unionpay' ) ) {
176 add_filter( 'usces_filter_save_order_acting_data', array( $this, 'save_order_acting_data' ) );
177 }
178
179 $this->initialize_data();
180 }
181
182 /**
183 * Return an instance of this class.
184 */
185 public static function get_instance() {
186 if ( is_null( self::$instance ) ) {
187 self::$instance = new self();
188 }
189 return self::$instance;
190 }
191
192 /**
193 * Initialize.
194 */
195 public function initialize_data() {
196 $options = get_option( 'usces', array() );
197
198 $options['acting_settings']['welcart']['merchant_id'] = ( isset( $options['acting_settings']['welcart']['merchant_id'] ) ) ? $options['acting_settings']['welcart']['merchant_id'] : '';
199 $options['acting_settings']['welcart']['merchant_pass'] = ( isset( $options['acting_settings']['welcart']['merchant_pass'] ) ) ? $options['acting_settings']['welcart']['merchant_pass'] : '';
200 $options['acting_settings']['welcart']['tenant_id'] = ( isset( $options['acting_settings']['welcart']['tenant_id'] ) ) ? $options['acting_settings']['welcart']['tenant_id'] : '0001';
201 $options['acting_settings']['welcart']['auth_key'] = ( isset( $options['acting_settings']['welcart']['auth_key'] ) ) ? $options['acting_settings']['welcart']['auth_key'] : '';
202 $options['acting_settings']['welcart']['ope'] = ( isset( $options['acting_settings']['welcart']['ope'] ) ) ? $options['acting_settings']['welcart']['ope'] : 'test';
203 $options['acting_settings']['welcart']['card_activate'] = ( isset( $options['acting_settings']['welcart']['card_activate'] ) ) ? $options['acting_settings']['welcart']['card_activate'] : 'off';
204 $options['acting_settings']['welcart']['card_key_aes'] = ( isset( $options['acting_settings']['welcart']['card_key_aes'] ) ) ? $options['acting_settings']['welcart']['card_key_aes'] : '';
205 $options['acting_settings']['welcart']['card_key_iv'] = ( isset( $options['acting_settings']['welcart']['card_key_iv'] ) ) ? $options['acting_settings']['welcart']['card_key_iv'] : '';
206 $options['acting_settings']['welcart']['foreign_activate'] = ( isset( $options['acting_settings']['welcart']['foreign_activate'] ) ) ? $options['acting_settings']['welcart']['foreign_activate'] : 'off';
207 $options['acting_settings']['welcart']['seccd'] = ( isset( $options['acting_settings']['welcart']['seccd'] ) ) ? $options['acting_settings']['welcart']['seccd'] : 'on';
208 $options['acting_settings']['welcart']['sec3d_activate'] = ( isset( $options['acting_settings']['welcart']['sec3d_activate'] ) ) ? $options['acting_settings']['welcart']['sec3d_activate'] : 'off';
209 $options['acting_settings']['welcart']['token_code'] = ( isset( $options['acting_settings']['welcart']['token_code'] ) ) ? $options['acting_settings']['welcart']['token_code'] : '';
210 $options['acting_settings']['welcart']['quickpay'] = ( isset( $options['acting_settings']['welcart']['quickpay'] ) ) ? $options['acting_settings']['welcart']['quickpay'] : 'off';
211 $options['acting_settings']['welcart']['chooseable_quickpay'] = ( isset( $options['acting_settings']['welcart']['chooseable_quickpay'] ) ) ? $options['acting_settings']['welcart']['chooseable_quickpay'] : 'on';
212 $options['acting_settings']['welcart']['operateid'] = ( isset( $options['acting_settings']['welcart']['operateid'] ) ) ? $options['acting_settings']['welcart']['operateid'] : '1Gathering';
213 $options['acting_settings']['welcart']['operateid_dlseller'] = ( isset( $options['acting_settings']['welcart']['operateid_dlseller'] ) ) ? $options['acting_settings']['welcart']['operateid_dlseller'] : '1Gathering';
214 $options['acting_settings']['welcart']['auto_settlement_mail'] = ( isset( $options['acting_settings']['welcart']['auto_settlement_mail'] ) ) ? $options['acting_settings']['welcart']['auto_settlement_mail'] : 'off';
215 $options['acting_settings']['welcart']['howtopay'] = ( isset( $options['acting_settings']['welcart']['howtopay'] ) ) ? $options['acting_settings']['welcart']['howtopay'] : '1';
216 $options['acting_settings']['welcart']['conv_activate'] = ( isset( $options['acting_settings']['welcart']['conv_activate'] ) ) ? $options['acting_settings']['welcart']['conv_activate'] : 'off';
217 $options['acting_settings']['welcart']['conv_limit'] = ( ! empty( $options['acting_settings']['welcart']['conv_limit'] ) ) ? $options['acting_settings']['welcart']['conv_limit'] : '7';
218 $options['acting_settings']['welcart']['conv_fee_type'] = ( isset( $options['acting_settings']['welcart']['conv_fee_type'] ) ) ? $options['acting_settings']['welcart']['conv_fee_type'] : '';
219 $options['acting_settings']['welcart']['conv_fee'] = ( isset( $options['acting_settings']['welcart']['conv_fee'] ) ) ? $options['acting_settings']['welcart']['conv_fee'] : '';
220 $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'] : '';
221 $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'] : '';
222 $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'] : '';
223 $options['acting_settings']['welcart']['conv_fee_amounts'] = ( isset( $options['acting_settings']['welcart']['conv_fee_amounts'] ) ) ? $options['acting_settings']['welcart']['conv_fee_amounts'] : array();
224 $options['acting_settings']['welcart']['conv_fee_fees'] = ( isset( $options['acting_settings']['welcart']['conv_fee_fees'] ) ) ? $options['acting_settings']['welcart']['conv_fee_fees'] : array();
225 $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'] : '';
226 $options['acting_settings']['welcart']['atodene_activate'] = ( isset( $options['acting_settings']['welcart']['atodene_activate'] ) ) ? $options['acting_settings']['welcart']['atodene_activate'] : 'off';
227 $options['acting_settings']['welcart']['atodene_byitem'] = ( isset( $options['acting_settings']['welcart']['atodene_byitem'] ) ) ? $options['acting_settings']['welcart']['atodene_byitem'] : 'off';
228 $options['acting_settings']['welcart']['atodene_billing_method'] = ( isset( $options['acting_settings']['welcart']['atodene_billing_method'] ) ) ? $options['acting_settings']['welcart']['atodene_billing_method'] : '2';
229 $options['acting_settings']['welcart']['atodene_fee_type'] = ( isset( $options['acting_settings']['welcart']['atodene_fee_type'] ) ) ? $options['acting_settings']['welcart']['atodene_fee_type'] : '';
230 $options['acting_settings']['welcart']['atodene_fee'] = ( isset( $options['acting_settings']['welcart']['atodene_fee'] ) ) ? $options['acting_settings']['welcart']['atodene_fee'] : '';
231 $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'] : '';
232 $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'] : '';
233 $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'] : '';
234 $options['acting_settings']['welcart']['atodene_fee_amounts'] = ( isset( $options['acting_settings']['welcart']['atodene_fee_amounts'] ) ) ? $options['acting_settings']['welcart']['atodene_fee_amounts'] : array();
235 $options['acting_settings']['welcart']['atodene_fee_fees'] = ( isset( $options['acting_settings']['welcart']['atodene_fee_fees'] ) ) ? $options['acting_settings']['welcart']['atodene_fee_fees'] : array();
236 $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'] : '';
237 $options['acting_settings']['welcart']['applepay_activate'] = ( isset( $options['acting_settings']['welcart']['applepay_activate'] ) ) ? $options['acting_settings']['welcart']['applepay_activate'] : 'off';
238 $options['acting_settings']['welcart']['applepay_tenant_id'] = ( isset( $options['acting_settings']['welcart']['applepay_tenant_id'] ) ) ? $options['acting_settings']['welcart']['applepay_tenant_id'] : '';
239 $options['acting_settings']['welcart']['applepay_quickpay'] = ( isset( $options['acting_settings']['welcart']['applepay_quickpay'] ) ) ? $options['acting_settings']['welcart']['applepay_quickpay'] : 'off';
240 $options['acting_settings']['welcart']['applepay_operateid'] = ( isset( $options['acting_settings']['welcart']['applepay_operateid'] ) ) ? $options['acting_settings']['welcart']['applepay_operateid'] : '1Gathering';
241 $options['acting_settings']['welcart']['applepay_key_aes'] = ( isset( $options['acting_settings']['welcart']['applepay_key_aes'] ) ) ? $options['acting_settings']['welcart']['applepay_key_aes'] : '';
242 $options['acting_settings']['welcart']['applepay_key_iv'] = ( isset( $options['acting_settings']['welcart']['applepay_key_iv'] ) ) ? $options['acting_settings']['welcart']['applepay_key_iv'] : '';
243 $options['acting_settings']['welcart']['applepay_certificate_path'] = ( isset( $options['acting_settings']['welcart']['applepay_certificate_path'] ) ) ? $options['acting_settings']['welcart']['applepay_certificate_path'] : '';
244 $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'] : '';
245 $options['acting_settings']['welcart']['applepay_merchantidentifier'] = ( isset( $options['acting_settings']['welcart']['applepay_merchantidentifier'] ) ) ? $options['acting_settings']['welcart']['applepay_merchantidentifier'] : '';
246 $options['acting_settings']['welcart']['unionpay_activate'] = ( isset( $options['acting_settings']['welcart']['unionpay_activate'] ) ) ? $options['acting_settings']['welcart']['unionpay_activate'] : 'off';
247 $options['acting_settings']['welcart']['unionpay_key_aes'] = ( isset( $options['acting_settings']['welcart']['unionpay_key_aes'] ) ) ? $options['acting_settings']['welcart']['unionpay_key_aes'] : '';
248 $options['acting_settings']['welcart']['unionpay_key_iv'] = ( isset( $options['acting_settings']['welcart']['unionpay_key_iv'] ) ) ? $options['acting_settings']['welcart']['unionpay_key_iv'] : '';
249 $options['acting_settings']['welcart']['unionpay_pagelanguage'] = ( isset( $options['acting_settings']['welcart']['unionpay_pagelanguage'] ) ) ? $options['acting_settings']['welcart']['unionpay_pagelanguage'] : '';
250 $options['acting_settings']['welcart']['activate'] = ( isset( $options['acting_settings']['welcart']['activate'] ) ) ? $options['acting_settings']['welcart']['activate'] : 'off';
251 update_option( 'usces', $options );
252
253 $welcartpay_keys = get_option( 'usces_welcartpay_keys', array() );
254 if ( empty( $welcartpay_keys ) ) {
255 $welcartpay_keys = array(
256 'c0778c9aefe850d5ac8efed5d62ed281',
257 'd0771e4b42ef683223df03f9558c23fd',
258 'dfef8e46f7231e7e8271f906582a4e1d',
259 'ad6dbb5e26cc9db1fe5d876a75764559',
260 '4fc1738fffa5aa33792ddf8e5c183f72',
261 'd255b1cb2c4d20959e3c80e457e5274c',
262 '479ffcfe47db920e972a8c7932e581d9',
263 '43c7f4782379b05cf69bbbfb547e3312',
264 '524047b0e0ad64d4f7b42c14c77758e2',
265 'b848aed9c05cbf2c85d2889b274c18ec',
266 );
267 update_option( 'usces_welcartpay_keys', $welcartpay_keys );
268 }
269
270 $available_settlement = get_option( 'usces_available_settlement', array() );
271 if ( ! in_array( 'welcart', $available_settlement, true ) ) {
272 $settlement = array(
273 'welcart' => $this->acting_name,
274 );
275 $available_settlement = array_merge( $settlement, $available_settlement );
276 update_option( 'usces_available_settlement', $available_settlement );
277 }
278
279 $noreceipt_status = get_option( 'usces_noreceipt_status', array() );
280 if ( ! in_array( 'acting_welcart_conv', $noreceipt_status, true ) || ! in_array( 'acting_welcart_atodene', $noreceipt_status, true ) ) {
281 $noreceipt_status[] = 'acting_welcart_conv';
282 $noreceipt_status[] = 'acting_welcart_atodene';
283 update_option( 'usces_noreceipt_status', $noreceipt_status );
284 }
285
286 $this->unavailable_method = array(
287 'acting_escott_card',
288 'acting_zeus_card',
289 'acting_zeus_conv',
290 'acting_sbps_card',
291 );
292 }
293
294 /**
295 * Admin scripts.
296 * admin_print_footer_scripts
297 */
298 public function admin_scripts() {
299 global $usces;
300
301 $admin_page = filter_input( INPUT_GET, 'page', FILTER_DEFAULT );
302 switch ( $admin_page ) :
303 case 'usces_settlement':
304 $settlement_selected = get_option( 'usces_settlement_selected', array() );
305 if ( in_array( 'welcart', $settlement_selected, true ) ) :
306 $acting_opts = $this->get_acting_settings();
307 ?>
308 <script type="text/javascript">
309 jQuery(document).ready( function($) {
310 var card_activate = "<?php echo esc_attr( $acting_opts['card_activate'] ); ?>";
311 var conv_activate = "<?php echo esc_attr( $acting_opts['conv_activate'] ); ?>";
312 var atodene_activate = "<?php echo esc_attr( $acting_opts['atodene_activate'] ); ?>";
313 var applepay_activate = "<?php echo esc_attr( $acting_opts['applepay_activate'] ); ?>";
314 var unionpay_activate = "<?php echo esc_attr( $acting_opts['unionpay_activate'] ); ?>";
315
316 if( "on" == card_activate || "token" == card_activate ) {
317 $(".card_welcart").css("display","");
318 $(".card_token_code_welcart").css("display","");
319 $(".card_howtopay_welcart").css("display","");
320 $(".card_sec3d_welcart").css("display","");
321 var sec3d_activate = "<?php echo esc_attr( $acting_opts['sec3d_activate'] ); ?>";
322 if( "on" == sec3d_activate ) {
323 $(".card_key_welcart").css("display","");
324 } else {
325 $(".card_key_welcart").css("display","none");
326 }
327 var quickpay_welcart = "<?php echo esc_attr( $acting_opts['quickpay'] ); ?>";
328 if( "on" == quickpay_welcart ) {
329 $(".card_chooseable_quickpay_welcart").css("display","");
330 } else {
331 $(".card_chooseable_quickpay_welcart").css("display","none");
332 }
333 } else if( "link" == card_activate ) {
334 $(".card_welcart").css("display","");
335 $(".card_key_welcart").css("display","");
336 $(".card_token_code_welcart").css("display","none");
337 $(".card_howtopay_welcart").css("display","none");
338 $(".card_sec3d_welcart").css("display","none");
339 var quickpay_welcart = "<?php echo esc_attr( $acting_opts['quickpay'] ); ?>";
340 if( "on" == quickpay_welcart ) {
341 $(".card_chooseable_quickpay_welcart").css("display","");
342 } else {
343 $(".card_chooseable_quickpay_welcart").css("display","none");
344 }
345 } else {
346 $(".card_welcart").css("display","none");
347 $(".card_key_welcart").css("display","none");
348 $(".card_token_code_welcart").css("display","none");
349 $(".card_howtopay_welcart").css("display","none");
350 $(".card_sec3d_welcart").css("display","none");
351 $(".card_chooseable_quickpay_welcart").css("display","none");
352 }
353
354 if( "on" == conv_activate ) {
355 $(".conv_welcart").css("display","");
356 } else {
357 $(".conv_welcart").css("display","none");
358 }
359
360 if( "on" == atodene_activate ) {
361 $(".atodene_welcart").css("display","");
362 } else {
363 $(".atodene_welcart").css("display","none");
364 }
365
366 if( "on" == applepay_activate ) {
367 $(".applepay_welcart").css( "display","");
368 } else {
369 $(".applepay_welcart").css("display","none");
370 }
371
372 if( "on" == unionpay_activate ) {
373 $(".unionpay_welcart").css("display","");
374 } else {
375 $(".unionpay_welcart").css("display","none");
376 }
377
378 $(document).on( "change", ".card_activate_welcart", function() {
379 if( "on" == $(this).val() || "token" == $(this).val() ) {
380 $(".card_welcart").css("display","");
381 $(".card_token_code_welcart").css("display","");
382 $(".card_howtopay_welcart").css("display","");
383 $(".card_sec3d_welcart").css("display","");
384 if( "on" == $("input[name='sec3d_activate']:checked").val() ) {
385 $(".card_key_welcart").css("display","");
386 } else {
387 $(".card_key_welcart").css("display","none");
388 }
389 if( "on" == $("input[name='quickpay']:checked").val() ) {
390 $(".card_chooseable_quickpay_welcart").css("display","");
391 } else {
392 $(".card_chooseable_quickpay_welcart").css("display","none");
393 }
394 } else if( "link" == $(this).val() ) {
395 $(".card_welcart").css("display","");
396 $(".card_key_welcart").css("display","");
397 $(".card_token_code_welcart").css("display","none");
398 $(".card_howtopay_welcart").css("display","none");
399 $(".card_sec3d_welcart").css("display","none");
400 if( "on" == $("input[name='quickpay']:checked").val() ) {
401 $(".card_chooseable_quickpay_welcart").css("display","");
402 } else {
403 $(".card_chooseable_quickpay_welcart").css("display","none");
404 }
405 } else {
406 $(".card_welcart").css("display","none");
407 $(".card_key_welcart").css("display","none");
408 $(".card_token_code_welcart").css("display","none");
409 $(".card_howtopay_welcart").css("display","none");
410 $(".card_sec3d_welcart").css("display","none");
411 $(".card_chooseable_quickpay_welcart").css("display","none");
412 }
413 });
414
415 $(document).on( "change", ".sec3d_activate_welcart", function() {
416 if( "on" == $(this).val() ) {
417 $(".card_key_welcart").css("display","");
418 } else {
419 $(".card_key_welcart").css("display","none");
420 }
421 });
422
423 $(document).on( "change", ".quickpay_welcart", function() {
424 if( "on" == $(this).val() ) {
425 $(".card_chooseable_quickpay_welcart").css("display","");
426 } else {
427 $(".card_chooseable_quickpay_welcart").css("display","none");
428 }
429 });
430
431 $(document).on( "change", ".conv_activate_welcart", function() {
432 if( "on" == $(this).val() ) {
433 $(".conv_welcart").css("display","");
434 } else {
435 $(".conv_welcart").css("display","none");
436 }
437 });
438
439 $(document).on( "change", ".atodene_activate_welcart", function() {
440 if( "on" == $(this).val() ) {
441 $(".atodene_welcart").css("display","");
442 } else {
443 $(".atodene_welcart").css("display","none");
444 }
445 });
446
447 $(document).on( "change", ".applepay_activate_welcart", function() {
448 if( "on" == $(this).val() ) {
449 $(".applepay_welcart").css("display","");
450 } else {
451 $(".applepay_welcart").css("display","none");
452 }
453 });
454
455 $(document).on( "change", ".unionpay_activate_welcart", function() {
456 if( "on" == $(this).val() ) {
457 $(".unionpay_welcart").css("display","");
458 } else {
459 $(".unionpay_welcart").css("display","none");
460 }
461 });
462
463 adminSettlementWelcartPay = {
464 openFee : function(mode) {
465 $("#fee_change_field").html("");
466 $("#fee_fix").val($("#"+mode+"_fee").val());
467 $("#fee_limit_amount_fix").val($("#"+mode+"_fee_limit_amount_fix").val());
468 $("#fee_first_amount").val($("#"+mode+"_fee_first_amount").val());
469 $("#fee_first_fee").val($("#"+mode+"_fee_first_fee").val());
470 $("#fee_limit_amount_change").val($("#"+mode+"_fee_limit_amount_change").val());
471 var fee_amounts = new Array();
472 var fee_fees = new Array();
473 if( 0 < $("#"+mode+"_fee_amounts").val().length ) {
474 fee_amounts = $("#"+mode+"_fee_amounts").val().split("|");
475 }
476 if( 0 < $("#"+mode+"_fee_fees").val().length ) {
477 fee_fees = $("#"+mode+"_fee_fees").val().split("|");
478 }
479 if( 0 < fee_amounts.length ) {
480 var amount = parseInt($("#fee_first_amount").val()) + 1;
481 for( var i = 0; i < fee_amounts.length; i++ ) {
482 html = '<tr id="row_'+i+'"><td class="cod_f"><span id="amount_'+i+'">'+amount+'</span></td><td class="cod_m"><?php esc_html_e( ' - ', 'usces' ); ?></td><td class="cod_e"><input name="fee_amounts['+i+']" type="text" class="short_str num" value="'+fee_amounts[i]+'" /></td><td class="cod_cod"><input name="fee_fees['+i+']" type="text" class="short_str num" value="'+fee_fees[i]+'" /></td></tr>';
483 $("#fee_change_field").append(html);
484 amount = parseInt(fee_amounts[i]) + 1;
485 }
486 $("#end_amount").html(amount);
487 } else {
488 $("#end_amount").html(parseInt($("#"+mode+"_fee_first_amount").val()) + 1);
489 }
490 $("#fee_end_fee").val($("#"+mode+"_fee_end_fee").val());
491
492 var fee_type = $("#"+mode+"_fee_type").val();
493 if( "change" == fee_type ) {
494 $("#fee_type_change").prop("checked",true);
495 $("#welcartpay_fee_fix_table").css("display","none");
496 $("#welcartpay_fee_change_table").css("display","");
497 } else {
498 $("#fee_type_fix").prop("checked",true);
499 $("#welcartpay_fee_fix_table").css("display","");
500 $("#welcartpay_fee_change_table").css("display","none");
501 }
502 },
503
504 updateFee : function(mode) {
505 var fee_type = $("input[name='fee_type']:checked").val();
506 $("#"+mode+"_fee_type").val(fee_type);
507 $("#"+mode+"_fee").val($("#fee_fix").val());
508 $("#"+mode+"_fee_limit_amount_"+fee_type).val($("#fee_limit_amount_"+fee_type).val());
509 $("#"+mode+"_fee_first_amount").val($("#fee_first_amount").val());
510 $("#"+mode+"_fee_first_fee").val($("#fee_first_fee").val());
511 var fee_amounts = "";
512 var fee_fees = "";
513 var sp = "";
514 var fee_amounts_length = $("input[name^='fee_amounts']").length;
515 for( var i = 0; i < fee_amounts_length; i++ ) {
516 fee_amounts += sp + $("input[name='fee_amounts\["+i+"\]']").val();
517 fee_fees += sp + $("input[name='fee_fees\["+i+"\]']").val();
518 sp = "|";
519 }
520 $("#"+mode+"_fee_amounts").val(fee_amounts);
521 $("#"+mode+"_fee_fees").val(fee_fees);
522 $("#"+mode+"_fee_end_fee").val($("#fee_end_fee").val());
523 },
524
525 setFeeType : function( mode, closed ) {
526 var fee_type = $("input[name='fee_type']:checked").val();
527 if( "change" == fee_type ) {
528 $("#"+mode+"_fee_type_field").html("<?php esc_attr_e( 'Variable', 'usces' ); ?>");
529 if( !closed ) {
530 $("#welcartpay_fee_fix_table").css("display","none");
531 $("#welcartpay_fee_change_table").css("display","");
532 }
533 } else if( "fix" == fee_type ) {
534 $("#"+mode+"_fee_type_field").html("<?php esc_attr_e( 'Fixation', 'usces' ); ?>");
535 if( !closed ) {
536 $("#welcartpay_fee_fix_table").css("display","");
537 $("#welcartpay_fee_change_table").css("display","none");
538 }
539 }
540 }
541 };
542
543 $("#welcartpay_fee_dialog").dialog({
544 autoOpen: false,
545 height: 500,
546 width: 450,
547 modal: true,
548 open: function() {
549 adminSettlementWelcartPay.openFee($("#welcartpay_fee_mode").val());
550 },
551 buttons: {
552 "<?php esc_attr_e( 'Settings' ); ?>": function() {
553 adminSettlementWelcartPay.updateFee($("#welcartpay_fee_mode").val());
554 },
555 "<?php esc_attr_e( 'Close' ); ?>": function() {
556 $(this).dialog('close');
557 }
558 },
559 close: function() {
560 adminSettlementWelcartPay.setFeeType($("#welcartpay_fee_mode").val(),true);
561 }
562 });
563
564 $(document).on( "click", "#conv_fee_setting", function() {
565 $("#welcartpay_fee_mode").val("conv");
566 $("#welcartpay_fee_dialog").dialog("option","title","<?php esc_attr_e( 'Online storage agency settlement fee setting', 'usces' ); ?>");
567 $("#welcartpay_fee_dialog").dialog("open");
568 });
569
570 $(document).on( "click", "#atodene_fee_setting", function() {
571 $("#welcartpay_fee_mode").val("atodene");
572 $("#welcartpay_fee_dialog").dialog("option","title","<?php esc_attr_e( 'Postpay settlement fee setting', 'usces' ); ?>");
573 $("#welcartpay_fee_dialog").dialog("open");
574 });
575
576 $(document).on( "click", ".fee_type", function() {
577 if( "change" == $(this).val() ) {
578 $("#welcartpay_fee_fix_table").css("display","none");
579 $("#welcartpay_fee_change_table").css("display","");
580 } else {
581 $("#welcartpay_fee_fix_table").css("display","");
582 $("#welcartpay_fee_change_table").css("display","none");
583 }
584 });
585
586 $(document).on( "change", "input[name='fee_first_amount']", function() {
587 var rows = $("input[name^='fee_amounts']");
588 var first_amount = $("input[name='fee_first_amount']");
589 if( 0 == rows.length && $(first_amount).val() != '' ) {
590 $("#end_amount").html(parseInt($(first_amount).val()) + 1);
591 } else if( 0 < rows.length && $(first_amount).val() != '' ) {
592 $('#amount_0').html(parseInt($(first_amount).val()) + 1);
593 }
594 });
595
596 $(document).on( "change", "#fee_limit_amount_change", function() {
597 if( "change" == $("input[name='fee_type']:checked").val() ) {
598 var amount = parseInt($("#end_amount").html());
599 var limit = parseInt($("#fee_limit_amount_change").val());
600 if( amount >= limit ) {
601 alert("<?php esc_attr_e( 'A value of the amount of upper limit is incorrect.', 'usces' ); ?>"+amount+' : '+limit);
602 }
603 }
604 });
605
606 $(document).on( "change", "input[name^='fee_amounts']", function() {
607 var rows = $("input[name^='fee_amounts']");
608 var cnt = $(rows).length;
609 var end_amount = $("#end_amount");
610 var id = $(rows).index(this);
611 if( id >= cnt-1 ) {
612 $( end_amount ).html(parseInt($(rows).eq(id).val()) + 1);
613 } else if( id < cnt - 1 ) {
614 $("#amount_"+(id + 1)).html(parseInt($(rows).eq(id).val()) + 1);
615 }
616 });
617
618 $(document).on( "click", "#fee_add_row", function() {
619 var rows = $("input[name^='fee_amounts']");
620 $(rows).unbind("change");
621 var first_amount = $("input[name='fee_first_amount']");
622 var first_fee = $("input[name='fee_first_fee']");
623 var end_amount = $("#end_amount");
624 var enf_fee = $("input[name='fee_end_fee']");
625 if( 0 == rows.length ) {
626 amount = ( $(first_amount).val() == '' ) ? '' : parseInt($(first_amount).val()) + 1;
627 } else if( 0 < rows.length ) {
628 amount = ( $(rows).eq(rows.length-1).val() == '' ) ? '' : parseInt($(rows).eq(rows.length-1).val()) + 1;
629 }
630 html = '<tr id="row_'+rows.length+'"><td class="cod_f"><span id="amount_'+rows.length+'">'+amount+'</span></td><td class="cod_m"><?php esc_html_e( ' - ', 'usces' ); ?></td><td class="cod_e"><input name="fee_amounts['+rows.length+']" type="text" class="short_str num" /></td><td class="cod_cod"><input name="fee_fees['+rows.length+']" type="text" class="short_str num" /></td></tr>';
631 $("#fee_change_field").append(html);
632 rows = $("input[name^='fee_amounts']");
633 $(rows).bind( "change", function() {
634 var cnt = $(rows).length - 1;
635 var id = $(rows).index(this);
636 if( id >= cnt ) {
637 $(end_amount).html(parseInt($(rows).eq(id).val()) + 1);
638 } else if( id < cnt ) {
639 $("#amount_"+(id + 1)).html(parseInt($(rows).eq(id).val()) + 1);
640 }
641 });
642 });
643
644 $(document).on( "click", "#fee_del_row", function() {
645 var rows = $("input[name^='fee_amounts']");
646 var first_amount = $("input[name='fee_first_amount']");
647 var end_amount = $("#end_amount");
648 var del_id = rows.length - 1;
649 if( 0 < rows.length ) {
650 $("#row_"+del_id).remove();
651 }
652 rows = $("input[name^='fee_amounts']");
653 if( 0 == rows.length && $(first_amount).val() != "" ) {
654 $(end_amount).html(parseInt($(first_amount).val()) + 1);
655 } else if( 0 < rows.length && $(rows).eq(rows.length - 1).val() != "" ) {
656 $(end_amount).html(parseInt($(rows).eq(rows.length - 1).val()) + 1);
657 }
658 });
659
660 adminSettlementWelcartPay.setFeeType("conv",false);
661 adminSettlementWelcartPay.setFeeType("atodene",false);
662 });
663 </script>
664 <?php
665 endif;
666 break;
667
668 case 'usces_orderlist':
669 case 'usces_continue':
670 $acting_flg = '';
671 $dialog_title = '';
672 $order_id = '';
673 $order_data = array();
674
675 $order_action = filter_input( INPUT_GET, 'order_action', FILTER_DEFAULT );
676 $continue_action = filter_input( INPUT_GET, 'continue_action', FILTER_DEFAULT );
677
678 /* 受注編集画面・継続課金会員詳細画面 */
679 if ( ( 'usces_orderlist' === $admin_page && ( 'edit' === $order_action || 'editpost' === $order_action || 'newpost' === $order_action ) ) ||
680 ( 'usces_continue' === $admin_page && 'settlement' === $continue_action ) ) {
681 $order_id = filter_input( INPUT_GET, 'order_id', FILTER_DEFAULT, FILTER_NULL_ON_FAILURE );
682 if ( ! $order_id && isset( $_POST['order_id'] ) ) {
683 $order_id = filter_input( INPUT_POST, 'order_id', FILTER_DEFAULT, FILTER_NULL_ON_FAILURE );
684 }
685 if ( $order_id ) {
686 $order_data = $usces->get_order_data( $order_id, 'direct' );
687 $payment = usces_get_payments_by_name( $order_data['order_payment_name'] );
688 if ( isset( $payment['settlement'] ) ) {
689 $acting_flg = $payment['settlement'];
690 }
691 if ( isset( $payment['name'] ) ) {
692 $dialog_title = $payment['name'];
693 }
694 }
695 }
696 $args = compact( 'order_id', 'acting_flg', 'admin_page', 'order_data' );
697
698 if ( in_array( $acting_flg, $this->pay_method, true ) ) :
699 ?>
700 <script type="text/javascript">
701 jQuery(document).ready( function( $ ) {
702 adminOrderEdit = {
703 <?php
704 if ( 'acting_welcart_card' === $acting_flg ) :
705 ?>
706 getSettlementInfoCard : function() {
707 $("#settlement-response").html("");
708 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
709 var mode = ( "" != $("#error").val() ) ? "error_welcartpay_card" : "get_welcartpay_card";
710 $.ajax({
711 url: ajaxurl,
712 type: "POST",
713 cache: false,
714 dataType: 'json',
715 data: {
716 action: "usces_admin_ajax",
717 mode: mode,
718 order_id: $("#order_id").val(),
719 order_num: $("#order_num").val(),
720 trans_id: $("#trans_id").val(),
721 member_id: $("#member_id").val(),
722 wc_nonce: $("#wc_nonce").val()
723 }
724 }).done( function(retVal,dataType) {
725 $("#settlement-response").html(retVal.result);
726 $("#settlement-response-loading").html("");
727 }).fail( function(retVal) {
728 $("#settlement-response-loading").html("");
729 });
730 return false;
731 },
732 captureSettlementCard : function(amount) {
733 $("#settlement-response").html("");
734 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
735 $.ajax({
736 url: ajaxurl,
737 type: "POST",
738 cache: false,
739 dataType: 'json',
740 data: {
741 action: "usces_admin_ajax",
742 mode: "capture_welcartpay_card",
743 order_id: $("#order_id").val(),
744 order_num: $("#order_num").val(),
745 trans_id: $("#trans_id").val(),
746 member_id: $("#member_id").val(),
747 amount: amount,
748 wc_nonce: $("#wc_nonce").val()
749 }
750 }).done( function(retVal,dataType) {
751 $("#settlement-response").html(retVal.result);
752 if( retVal.status == "OK" ) {
753 $("#settlement-status").html(retVal.acting_status);
754 $("#responsecd-"+$("#trans_id").val()+"-"+$("#order_num").val()).val("");
755 } else {
756 $("#responsecd-"+$("#trans_id").val()+"-"+$("#order_num").val()).val(retVal.status);
757 }
758 $("#settlement-response-loading").html("");
759 }).fail( function( retVal ) {
760 $("#settlement-response-loading").html("");
761 });
762 return false;
763 },
764 changeSettlementCard : function(amount) {
765 $("#settlement-response").html("");
766 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
767 $.ajax({
768 url: ajaxurl,
769 type: "POST",
770 cache: false,
771 dataType: 'json',
772 data: {
773 action: "usces_admin_ajax",
774 mode: "change_welcartpay_card",
775 order_id: $("#order_id").val(),
776 order_num: $("#order_num").val(),
777 trans_id: $("#trans_id").val(),
778 member_id: $("#member_id").val(),
779 amount: amount,
780 wc_nonce: $("#wc_nonce").val()
781 }
782 }).done( function(retVal,dataType) {
783 $("#settlement-response").html(retVal.result);
784 $("#settlement-response-loading").html("");
785 }).fail( function(retVal) {
786 $("#settlement-response-loading").html("");
787 });
788 return false;
789 },
790 deleteSettlementCard : function(amount) {
791 $("#settlement-response").html("");
792 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
793 $.ajax({
794 url: ajaxurl,
795 type: "POST",
796 cache: false,
797 dataType: 'json',
798 data: {
799 action: "usces_admin_ajax",
800 mode: "delete_welcartpay_card",
801 order_id: $("#order_id").val(),
802 order_num: $("#order_num").val(),
803 trans_id: $("#trans_id").val(),
804 member_id: $("#member_id").val(),
805 amount: amount,
806 wc_nonce: $("#wc_nonce").val()
807 }
808 }).done( function(retVal,dataType) {
809 $("#settlement-response").html(retVal.result);
810 if( retVal.status == "OK" ) {
811 $("#settlement-status").html(retVal.acting_status);
812 $("#responsecd-"+$("#trans_id").val()+"-"+$("#order_num").val()).val("");
813 } else {
814 $("#responsecd-"+$("#trans_id").val()+"-"+$("#order_num").val()).val(retVal.status);
815 }
816 $("#settlement-response-loading").html("");
817 }).fail( function(retVal) {
818 $("#settlement-response-loading").html("");
819 });
820 return false;
821 },
822 authSettlementCard : function(mode,amount) {
823 $("#settlement-response").html("");
824 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
825 $.ajax({
826 url: ajaxurl,
827 type: "POST",
828 cache: false,
829 dataType: 'json',
830 data: {
831 action: "usces_admin_ajax",
832 mode: mode+"_welcartpay_card",
833 order_id: $("#order_id").val(),
834 order_num: $("#order_num").val(),
835 trans_id: $("#trans_id").val(),
836 member_id: $("#member_id").val(),
837 amount: amount,
838 wc_nonce: $("#wc_nonce").val()
839 }
840 }).done( function(retVal,dataType) {
841 $("#settlement-response").html(retVal.result);
842 if( retVal.status == "OK" ) {
843 $("#settlement-status").html(retVal.acting_status);
844 $("#responsecd-"+$("#trans_id").val()+"-"+$("#order_num").val()).val("");
845 if( retVal.trans_id && $("#settlement-information-9999999999-1").length ) {
846 $("[id=settlement-information-9999999999-1]").attr("id","settlement-information-"+retVal.trans_id+"-1");
847 $("#trans_id").val(retVal.trans_id);
848 }
849 } else {
850 $("#responsecd-"+$("#trans_id").val()+"-"+$("#order_num").val()).val(retVal.status);
851 }
852 $("#settlement-response-loading").html("");
853 }).fail( function(retVal) {
854 $("#settlement-response-loading").html("");
855 });
856 return false;
857 }
858 <?php
859 elseif ( 'acting_welcart_conv' === $acting_flg ) :
860 ?>
861 getSettlementInfoConv : function() {
862 $("#settlement-response").html("");
863 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
864 $.ajax({
865 url: ajaxurl,
866 type: "POST",
867 cache: false,
868 dataType: 'json',
869 data: {
870 action: "usces_admin_ajax",
871 mode: "get_welcartpay_conv",
872 order_id: $("#order_id").val(),
873 trans_id: $("#trans_id").val(),
874 wc_nonce: $("#wc_nonce").val()
875 }
876 }).done( function(retVal,dataType) {
877 $("#settlement-response").html(retVal.result);
878 $("#settlement-response-loading").html("");
879 }).fail( function(retVal) {
880 $("#settlement-response-loading").html("");
881 });
882 return false;
883 },
884 changeSettlementConv : function(paylimit,amount) {
885 $("#settlement-response").html("");
886 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
887
888 $.ajax({
889 url: ajaxurl,
890 type: "POST",
891 cache: false,
892 dataType: 'json',
893 data: {
894 action: "usces_admin_ajax",
895 mode: "change_welcartpay_conv",
896 order_id: $("#order_id").val(),
897 trans_id: $("#trans_id").val(),
898 paylimit: paylimit,
899 amount: amount,
900 wc_nonce: $("#wc_nonce").val()
901 }
902 }).done( function(retVal,dataType) {
903 $("#settlement-response").html(retVal.result);
904 $("#settlement-response-loading").html("");
905 }).fail( function(retVal) {
906 $("#settlement-response-loading").html("");
907 });
908 return false;
909 },
910 deleteSettlementConv : function(amount) {
911 $("#settlement-response").html("");
912 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
913 $.ajax({
914 url: ajaxurl,
915 type: "POST",
916 cache: false,
917 dataType: 'json',
918 data: {
919 action: "usces_admin_ajax",
920 mode: "delete_welcartpay_conv",
921 order_id: $("#order_id").val(),
922 trans_id: $("#trans_id").val(),
923 amount: amount,
924 wc_nonce: $("#wc_nonce").val()
925 }
926 }).done( function(retVal,dataType) {
927 $("#settlement-response").html(retVal.result);
928 if( retVal.status == "OK" ) {
929 $("#settlement-status").html(retVal.acting_status);
930 }
931 $("#settlement-response-loading").html("");
932 }).fail( function(retVal) {
933 $("#settlement-response-loading").html("");
934 });
935 return false;
936 },
937 addSettlementConv : function(paylimit,amount) {
938 $("#settlement-response").html("");
939 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
940 $.ajax({
941 url: ajaxurl,
942 type: "POST",
943 cache: false,
944 dataType: 'json',
945 data: {
946 action: "usces_admin_ajax",
947 mode: "add_welcartpay_conv",
948 order_id: $("#order_id").val(),
949 trans_id: $("#trans_id").val(),
950 paylimit: paylimit,
951 amount: amount,
952 wc_nonce: $("#wc_nonce").val()
953 }
954 }).done( function(retVal,dataType) {
955 $("#settlement-response").html(retVal.result);
956 if( retVal.status == "OK" ) {
957 $("#settlement-status").html(retVal.acting_status);
958 }
959 $("#settlement-response-loading").html("");
960 }).fail( function(retVal) {
961 $("#settlement-response-loading").html("");
962 });
963 return false;
964 }
965 <?php
966 elseif ( 'acting_welcart_unionpay' === $acting_flg ) :
967 ?>
968 getSettlementInfoUnionPay : function() {
969 $("#settlement-response").html("");
970 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
971 var mode = ( "" != $("#error").val() ) ? "error_welcartpay_unionpay" : "get_welcartpay_unionpay";
972 $.ajax({
973 url: ajaxurl,
974 type: "POST",
975 cache: false,
976 dataType: 'json',
977 data: {
978 action: "usces_admin_ajax",
979 mode: mode,
980 order_id: $("#order_id").val(),
981 order_num: $("#order_num").val(),
982 trans_id: $("#trans_id").val(),
983 member_id: $("#member_id").val(),
984 wc_nonce: $("#wc_nonce").val()
985 }
986 }).done( function(retVal,dataType) {
987 $("#settlement-response").html(retVal.result);
988 $("#settlement-response-loading").html("");
989 }).fail( function(retVal) {
990 $("#settlement-response-loading").html("");
991 });
992 return false;
993 },
994 deleteSettlementUnionPay : function() {
995 $("#settlement-response").html("");
996 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
997 $.ajax({
998 url: ajaxurl,
999 type: "POST",
1000 cache: false,
1001 dataType: 'json',
1002 data: {
1003 action: "usces_admin_ajax",
1004 mode: "delete_welcartpay_unionpay",
1005 order_id: $("#order_id").val(),
1006 order_num: $("#order_num").val(),
1007 trans_id: $("#trans_id").val(),
1008 member_id: $("#member_id").val(),
1009 wc_nonce: $("#wc_nonce").val()
1010 }
1011 }).done( function(retVal,dataType) {
1012 $("#settlement-response").html(retVal.result);
1013 if( retVal.status == "OK" ) {
1014 $("#settlement-status").html(retVal.acting_status);
1015 $("#responsecd-"+$("#trans_id").val()+"-"+$("#order_num").val()).val("");
1016 } else {
1017 $("#responsecd-"+$("#trans_id").val()+"-"+$("#order_num").val()).val(retVal.status);
1018 }
1019 $("#settlement-response-loading").html("");
1020 }).fail( function(retVal) {
1021 $("#settlement-response-loading").html("");
1022 });
1023 return false;
1024 }
1025 <?php
1026 endif;
1027 ?>
1028 };
1029
1030 $("#settlement_dialog").dialog({
1031 bgiframe: true,
1032 autoOpen: false,
1033 height: "auto",
1034 width: 800,
1035 resizable: true,
1036 modal: true,
1037 buttons: {
1038 "<?php esc_attr_e( 'Close' ); ?>": function() {
1039 $(this).dialog("close");
1040 }
1041 },
1042 open: function() {
1043 <?php
1044 if ( 'acting_welcart_card' === $acting_flg ) :
1045 ?>
1046 adminOrderEdit.getSettlementInfoCard();
1047 <?php
1048 elseif ( 'acting_welcart_conv' === $acting_flg ) :
1049 ?>
1050 adminOrderEdit.getSettlementInfoConv();
1051 <?php
1052 elseif ( 'acting_welcart_unionpay' === $acting_flg ) :
1053 ?>
1054 adminOrderEdit.getSettlementInfoUnionPay();
1055 <?php
1056 endif;
1057 ?>
1058 },
1059 close: function() {
1060 <?php do_action( 'usces_action_welcartpay_settlement_dialog_close', $args ); ?>
1061 }
1062 });
1063
1064 $(document).on( "click", ".settlement-information", function() {
1065 var idname = $(this).attr("id");
1066 var ids = idname.split("-");
1067 $("#trans_id").val(ids[2]);
1068 $("#order_num").val(ids[3]);
1069 if( undefined != $("#responsecd-"+ids[2]+"-"+ids[3]) ) {
1070 $("#error").val($("#responsecd-"+ids[2]+"-"+ids[3]).val());
1071 } else {
1072 $("#error").val("");
1073 }
1074 $("#settlement_dialog").dialog("option","title","<?php echo esc_attr( $dialog_title ); ?>");
1075 $("#settlement_dialog").dialog("open");
1076 });
1077
1078 <?php
1079 if ( 'acting_welcart_card' === $acting_flg ) :
1080 ?>
1081 $(document).on( "click", "#capture-settlement", function() {
1082 if( !confirm("<?php esc_attr_e( 'Are you sure you want to execute sales accounting processing?', 'usces' ); ?>") ) {
1083 return;
1084 }
1085 adminOrderEdit.captureSettlementCard($("#amount_change").val());
1086 });
1087
1088 $(document).on( "click", "#delete-settlement", function() {
1089 if( !confirm("<?php esc_attr_e( 'Are you sure you want to cancellation processing?', 'usces' ); ?>") ) {
1090 return;
1091 }
1092 adminOrderEdit.deleteSettlementCard($("#amount_change").val());
1093 });
1094
1095 $(document).on( "click", "#change-settlement", function() {
1096 if( $("#amount_change").val() == $("#amount").val() ) {
1097 return;
1098 }
1099 var amount = $("#amount_change").val();
1100 if( amount == "" || parseInt(amount) === 0 || !checkNum(amount) ) {
1101 alert("<?php esc_attr_e( 'The spending amount format is incorrect. Please enter with numeric value.', 'usces' ); ?>");
1102 return;
1103 }
1104 if( !confirm("<?php esc_attr_e( 'Are you sure you want to change the spending amount?', 'usces' ); ?>") ) {
1105 return;
1106 }
1107 adminOrderEdit.changeSettlementCard($("#amount_change").val());
1108 });
1109
1110 $(document).on( "click", "#auth-settlement", function() {
1111 var amount = $("#amount_change").val();
1112 if( amount == "" || parseInt(amount) === 0 || !checkNum(amount) ) {
1113 alert("<?php esc_attr_e( 'The spending amount format is incorrect. Please enter with numeric value.', 'usces' ); ?>");
1114 return;
1115 }
1116 if( !confirm("<?php esc_attr_e( 'Are you sure you want to execute credit processing?', 'usces' ); ?>") ) {
1117 return;
1118 }
1119 adminOrderEdit.authSettlementCard("auth",$("#amount_change").val());
1120 });
1121
1122 $(document).on( "click", "#gathering-settlement", function() {
1123 var amount = $("#amount_change").val();
1124 if( amount == "" || parseInt(amount) === 0 || !checkNum(amount) ) {
1125 alert("<?php esc_attr_e( 'The spending amount format is incorrect. Please enter with numeric value.', 'usces' ); ?>");
1126 return;
1127 }
1128 if( !confirm("<?php esc_attr_e( 'Are you sure you want to execute credit sales processing?', 'usces' ); ?>") ) {
1129 return;
1130 }
1131 adminOrderEdit.authSettlementCard("gathering",$("#amount_change").val());
1132 });
1133
1134 $(document).on( "click", "#reauth-settlement", function() {
1135 var amount = $("#amount_change").val();
1136 if( amount == "" || parseInt(amount) === 0 || !checkNum(amount) ) {
1137 alert("<?php esc_attr_e( 'The spending amount format is incorrect. Please enter with numeric value.', 'usces' ); ?>");
1138 return;
1139 }
1140 if( !confirm("<?php esc_attr_e( 'Are you sure you want to re-authorization?', 'usces' ); ?>") ) {
1141 return;
1142 }
1143 adminOrderEdit.authSettlementCard("reauth",$("#amount_change").val());
1144 });
1145
1146 <?php
1147 elseif ( 'acting_welcart_conv' === $acting_flg ) :
1148 ?>
1149 $(document).on( "click", "#delete-settlement", function() {
1150 if( !confirm("<?php esc_attr_e( 'Are you sure you want to cancellation processing?', 'usces' ); ?>") ) {
1151 return;
1152 }
1153 adminOrderEdit.deleteSettlementConv($("#amount_change").val());
1154 });
1155
1156 $(document).on( "click", "#change-settlement", function() {
1157 if( ( $("#paylimit_change").val() == $("#paylimit").val() ) &&
1158 ( $("#amount_change").val() == $("#amount").val() ) ) {
1159 return;
1160 }
1161 var paylimit = $("#paylimit_change").val();
1162 var amount = $("#amount_change").val();
1163 var today = "<?php echo esc_attr( $this->get_transaction_date() ); ?>";
1164 if( paylimit.length != 8 || !checkNum(paylimit) ) {
1165 alert("<?php esc_attr_e( 'The payment due format is incorrect. Please enter with 8 digit number.', 'usces' ); ?>");
1166 return;
1167 }
1168 if( today > paylimit ) {
1169 alert("<?php esc_attr_e( 'The payment due is incorrect. Date before today cannot be specified.', 'usces' ); ?>");
1170 return;
1171 }
1172 if( amount == "" || parseInt( amount ) === 0 || !checkNum( amount ) ) {
1173 alert("<?php esc_attr_e( 'The payment amount format is incorrect. Please enter with numeric value.', 'usces' ); ?>");
1174 return;
1175 }
1176 if( !confirm("<?php esc_attr_e( 'Are you sure you want to change payment due and payment amount?', 'usces' ); ?>") ) {
1177 return;
1178 }
1179 adminOrderEdit.changeSettlementConv($("#paylimit_change").val(),$("#amount_change").val());
1180 });
1181
1182 $(document).on( "click", "#add-settlement", function() {
1183 var paylimit = $("#paylimit_change").val();
1184 var amount = $("#amount_change").val();
1185 var today = "<?php echo esc_attr( $this->get_transaction_date() ); ?>";
1186 if( paylimit.length != 8 || !checkNum(paylimit) ) {
1187 alert("<?php esc_attr_e( 'The payment due format is incorrect. Please enter with 8 digit number.', 'usces' ); ?>");
1188 return;
1189 }
1190 if( today > paylimit ) {
1191 alert("<?php esc_attr_e( 'The payment due is incorrect. Date before today cannot be specified.', 'usces' ); ?>");
1192 return;
1193 }
1194 if( amount == "" || parseInt(amount) === 0 || !checkNum(amount) ) {
1195 alert("<?php esc_attr_e( 'The payment amount format is incorrect. Please enter with numeric value.', 'usces' ); ?>");
1196 return;
1197 }
1198 if( !confirm("<?php esc_attr_e( 'Are you sure you want to execute the registration processing?', 'usces' ); ?>") ) {
1199 return;
1200 }
1201 adminOrderEdit.addSettlementConv($("#paylimit_change").val(),$("#amount_change").val());
1202 });
1203
1204 <?php
1205 elseif ( 'acting_welcart_unionpay' === $acting_flg ) :
1206 ?>
1207 $(document).on( "click", "#delete-settlement", function() {
1208 if( !confirm("<?php esc_attr_e( 'Are you sure you want to cancellation processing?', 'usces' ); ?>") ) {
1209 return;
1210 }
1211 adminOrderEdit.deleteSettlementUnionPay();
1212 });
1213
1214 <?php
1215 endif;
1216 if ( 'usces_continue' === $admin_page ) :
1217 ?>
1218 adminContinuation = {
1219 update : function() {
1220 $.ajax({
1221 url: ajaxurl,
1222 type: "POST",
1223 cache: false,
1224 dataType: 'json',
1225 data: {
1226 action: "usces_admin_ajax",
1227 mode: "continuation_update",
1228 member_id: $("#member_id").val(),
1229 order_id: $("#order_id").val(),
1230 contracted_year: $("#contracted-year option:selected").val(),
1231 contracted_month: $("#contracted-month option:selected").val(),
1232 contracted_day: $("#contracted-day option:selected").val(),
1233 charged_year: $("#charged-year option:selected").val(),
1234 charged_month: $("#charged-month option:selected").val(),
1235 charged_day: $("#charged-day option:selected").val(),
1236 price: $("#price").val(),
1237 status: $("#dlseller-status").val(),
1238 wc_nonce: $("#wc_nonce").val()
1239 }
1240 }).done( function(retVal,dataType) {
1241 if( retVal.status == "OK" ) {
1242 adminOperation.setActionStatus("success","<?php esc_attr_e( 'The update was completed.', 'usces' ); ?>");
1243 } else {
1244 mes = ( retVal.message != "" ) ? retVal.message : "<?php esc_attr_e( 'failure in update', 'usces' ); ?>";
1245 adminOperation.setActionStatus("error",mes);
1246 }
1247 }).fail( function(retVal) {
1248 adminOperation.setActionStatus("error","<?php esc_attr_e( 'failure in update', 'usces' ); ?>");
1249 });
1250 return false;
1251 }
1252 };
1253
1254 $("#price").bind( "change", function() {
1255 usces_check_money($(this));
1256 });
1257
1258 $(document).on( "click", "#continuation-update", function() {
1259 var status = $("#dlseller-status option:selected").val();
1260 if( status == "continuation" ) {
1261 var year = $("#charged-year option:selected").val();
1262 var month = $("#charged-month option:selected").val();
1263 var day = $("#charged-day option:selected").val();
1264 if( year == 0 || month == 0 || day == 0 ) {
1265 alert("<?php esc_attr_e( 'Data have deficiency.', 'usces' ); ?>");
1266 $("#charged-year").focus();
1267 return;
1268 }
1269 if( $("#price").val() == "" || parseInt($("#price").val()) == 0 ) {
1270 alert("<?php printf( __( 'Input the %s', 'usces' ), esc_attr__( 'Amount', 'dlseller' ) ); ?>");
1271 $("#price").focus();
1272 return;
1273 }
1274 }
1275 if( !confirm("<?php esc_attr_e( 'Are you sure you want to update the settings?', 'usces' ); ?>") ) {
1276 return;
1277 }
1278 adminContinuation.update();
1279 });
1280 <?php
1281 endif;
1282 ?>
1283 });
1284 </script>
1285 <?php
1286 endif;
1287 break;
1288 endswitch;
1289 }
1290
1291 /**
1292 * 決済オプション登録・更新
1293 * usces_action_admin_settlement_update
1294 */
1295 public function settlement_update() {
1296 global $usces;
1297
1298 if ( 'welcart' !== filter_input( INPUT_POST, 'acting', FILTER_DEFAULT ) ) {
1299 return;
1300 }
1301
1302 $this->error_mes = '';
1303 $options = get_option( 'usces', array() );
1304 $payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
1305 $post_data = wp_unslash( $_POST );
1306
1307 unset( $options['acting_settings']['welcart'] );
1308 $options['acting_settings']['welcart']['merchant_id'] = ( isset( $post_data['merchant_id'] ) ) ? trim( $post_data['merchant_id'] ) : '';
1309 $options['acting_settings']['welcart']['merchant_pass'] = ( isset( $post_data['merchant_pass'] ) ) ? trim( $post_data['merchant_pass'] ) : '';
1310 $options['acting_settings']['welcart']['tenant_id'] = ( isset( $post_data['tenant_id'] ) ) ? trim( $post_data['tenant_id'] ) : '0001';
1311 $options['acting_settings']['welcart']['auth_key'] = ( isset( $post_data['auth_key'] ) ) ? trim( $post_data['auth_key'] ) : '';
1312 $options['acting_settings']['welcart']['ope'] = ( isset( $post_data['ope'] ) ) ? $post_data['ope'] : '';
1313 $options['acting_settings']['welcart']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : 'off';
1314 $options['acting_settings']['welcart']['card_key_aes'] = ( isset( $post_data['card_key_aes'] ) ) ? $post_data['card_key_aes'] : '';
1315 $options['acting_settings']['welcart']['card_key_iv'] = ( isset( $post_data['card_key_iv'] ) ) ? $post_data['card_key_iv'] : '';
1316 $options['acting_settings']['welcart']['foreign_activate'] = ( isset( $post_data['foreign_activate'] ) ) ? $post_data['foreign_activate'] : '';
1317 $options['acting_settings']['welcart']['seccd'] = ( isset( $post_data['seccd'] ) ) ? $post_data['seccd'] : 'on';
1318 $options['acting_settings']['welcart']['sec3d_activate'] = ( isset( $post_data['sec3d_activate'] ) ) ? $post_data['sec3d_activate'] : 'off';
1319 $options['acting_settings']['welcart']['token_code'] = ( isset( $post_data['token_code'] ) ) ? trim( $post_data['token_code'] ) : '';
1320 $options['acting_settings']['welcart']['quickpay'] = ( isset( $post_data['quickpay'] ) ) ? $post_data['quickpay'] : '';
1321 $options['acting_settings']['welcart']['chooseable_quickpay'] = ( isset( $post_data['chooseable_quickpay'] ) ) ? $post_data['chooseable_quickpay'] : 'on';
1322 $options['acting_settings']['welcart']['operateid'] = ( isset( $post_data['operateid'] ) ) ? $post_data['operateid'] : '1Gathering';
1323 $options['acting_settings']['welcart']['operateid_dlseller'] = ( isset( $post_data['operateid_dlseller'] ) ) ? $post_data['operateid_dlseller'] : '1Gathering';
1324 $options['acting_settings']['welcart']['auto_settlement_mail'] = ( isset( $post_data['auto_settlement_mail'] ) ) ? $post_data['auto_settlement_mail'] : 'off';
1325 $options['acting_settings']['welcart']['howtopay'] = ( isset( $post_data['howtopay'] ) ) ? $post_data['howtopay'] : '';
1326 $options['acting_settings']['welcart']['conv_activate'] = ( isset( $post_data['conv_activate'] ) ) ? $post_data['conv_activate'] : 'off';
1327 $options['acting_settings']['welcart']['conv_limit'] = ( ! empty( $post_data['conv_limit'] ) ) ? $post_data['conv_limit'] : '7';
1328 $options['acting_settings']['welcart']['conv_fee_type'] = ( isset( $post_data['conv_fee_type'] ) ) ? $post_data['conv_fee_type'] : '';
1329 $options['acting_settings']['welcart']['conv_fee'] = ( isset( $post_data['conv_fee'] ) ) ? $post_data['conv_fee'] : '';
1330 $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'] ] : '';
1331 $options['acting_settings']['welcart']['conv_fee_first_amount'] = ( isset( $post_data['conv_fee_first_amount'] ) ) ? $post_data['conv_fee_first_amount'] : '';
1332 $options['acting_settings']['welcart']['conv_fee_first_fee'] = ( isset( $post_data['conv_fee_first_fee'] ) ) ? $post_data['conv_fee_first_fee'] : '';
1333 $options['acting_settings']['welcart']['conv_fee_amounts'] = ( isset( $post_data['conv_fee_amounts'] ) ) ? explode( '|', $post_data['conv_fee_amounts'] ) : array();
1334 $options['acting_settings']['welcart']['conv_fee_fees'] = ( isset( $post_data['conv_fee_fees'] ) ) ? explode( '|', $post_data['conv_fee_fees'] ) : array();
1335 $options['acting_settings']['welcart']['conv_fee_end_fee'] = ( isset( $post_data['conv_fee_end_fee'] ) ) ? $post_data['conv_fee_end_fee'] : '';
1336 $options['acting_settings']['welcart']['atodene_activate'] = ( isset( $post_data['atodene_activate'] ) ) ? $post_data['atodene_activate'] : 'off';
1337 $options['acting_settings']['welcart']['atodene_byitem'] = ( isset( $post_data['atodene_byitem'] ) ) ? $post_data['atodene_byitem'] : 'off';
1338 $options['acting_settings']['welcart']['atodene_billing_method'] = ( isset( $post_data['atodene_billing_method'] ) ) ? $post_data['atodene_billing_method'] : '2';
1339 $options['acting_settings']['welcart']['atodene_fee_type'] = ( isset( $post_data['atodene_fee_type'] ) ) ? $post_data['atodene_fee_type'] : '';
1340 $options['acting_settings']['welcart']['atodene_fee'] = ( isset( $post_data['atodene_fee'] ) ) ? $post_data['atodene_fee'] : '';
1341 $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'] ] : '';
1342 $options['acting_settings']['welcart']['atodene_fee_first_amount'] = ( isset( $post_data['atodene_fee_first_amount'] ) ) ? $post_data['atodene_fee_first_amount'] : '';
1343 $options['acting_settings']['welcart']['atodene_fee_first_fee'] = ( isset( $post_data['atodene_fee_first_fee'] ) ) ? $post_data['atodene_fee_first_fee'] : '';
1344 $options['acting_settings']['welcart']['atodene_fee_amounts'] = ( isset( $post_data['atodene_fee_amounts'] ) ) ? explode( '|', $post_data['atodene_fee_amounts'] ) : array();
1345 $options['acting_settings']['welcart']['atodene_fee_fees'] = ( isset( $post_data['atodene_fee_fees'] ) ) ? explode( '|', $post_data['atodene_fee_fees'] ) : array();
1346 $options['acting_settings']['welcart']['atodene_fee_end_fee'] = ( isset( $post_data['atodene_fee_end_fee'] ) ) ? $post_data['atodene_fee_end_fee'] : '';
1347 $options['acting_settings']['welcart']['applepay_activate'] = ( isset( $post_data['applepay_activate'] ) ) ? $post_data['applepay_activate'] : 'off';
1348 $options['acting_settings']['welcart']['applepay_tenant_id'] = ( isset( $post_data['applepay_tenant_id'] ) ) ? $post_data['applepay_tenant_id'] : '';
1349 $options['acting_settings']['welcart']['applepay_quickpay'] = ( isset( $post_data['applepay_quickpay'] ) ) ? $post_data['applepay_quickpay'] : '';
1350 $options['acting_settings']['welcart']['applepay_operateid'] = ( isset( $post_data['applepay_operateid'] ) ) ? $post_data['applepay_operateid'] : '1Gathering';
1351 $options['acting_settings']['welcart']['applepay_key_aes'] = ( isset( $post_data['applepay_key_aes'] ) ) ? $post_data['applepay_key_aes'] : '';
1352 $options['acting_settings']['welcart']['applepay_key_iv'] = ( isset( $post_data['applepay_key_iv'] ) ) ? $post_data['applepay_key_iv'] : '';
1353 $options['acting_settings']['welcart']['applepay_certificate_path'] = ( isset( $post_data['applepay_certificate_path'] ) ) ? $post_data['applepay_certificate_path'] : '';
1354 $options['acting_settings']['welcart']['applepay_certificate_key_pass'] = ( isset( $post_data['applepay_certificate_key_pass'] ) ) ? $post_data['applepay_certificate_key_pass'] : '';
1355 $options['acting_settings']['welcart']['applepay_merchantidentifier'] = ( isset( $post_data['applepay_merchantidentifier'] ) ) ? $post_data['applepay_merchantidentifier'] : '';
1356 $options['acting_settings']['welcart']['unionpay_activate'] = ( isset( $post_data['unionpay_activate'] ) ) ? $post_data['unionpay_activate'] : 'off';
1357 $options['acting_settings']['welcart']['unionpay_key_aes'] = ( isset( $post_data['unionpay_key_aes'] ) ) ? $post_data['unionpay_key_aes'] : '';
1358 $options['acting_settings']['welcart']['unionpay_key_iv'] = ( isset( $post_data['unionpay_key_iv'] ) ) ? $post_data['unionpay_key_iv'] : '';
1359 $options['acting_settings']['welcart']['unionpay_pagelanguage'] = ( isset( $post_data['unionpay_pagelanguage'] ) ) ? $post_data['unionpay_pagelanguage'] : '';
1360
1361 if ( 'on' === $options['acting_settings']['welcart']['card_activate'] || 'on' === $options['acting_settings']['welcart']['conv_activate'] ) {
1362 $unavailable_activate = false;
1363 foreach ( $payment_method as $settlement => $payment ) {
1364 if ( in_array( $settlement, $this->unavailable_method, true ) && 'activate' === $payment['use'] ) {
1365 $unavailable_activate = true;
1366 break;
1367 }
1368 }
1369 if ( $unavailable_activate ) {
1370 $this->error_mes .= __( '* Settlement that can not be used together is activated.', 'usces' ) . '<br />';
1371 } else {
1372 if ( WCUtils::is_blank( $post_data['merchant_id'] ) ) {
1373 $this->error_mes .= __( '* Please enter the Merchant ID.', 'usces' ) . '<br />';
1374 }
1375 if ( WCUtils::is_blank( $post_data['merchant_pass'] ) ) {
1376 $this->error_mes .= __( '* Please enter the Merchant Password.', 'usces' ) . '<br />';
1377 }
1378 if ( WCUtils::is_blank( $post_data['tenant_id'] ) ) {
1379 $this->error_mes .= __( '* Please enter the Tenant ID.', 'usces' ) . '<br />';
1380 }
1381 if ( WCUtils::is_blank( $post_data['auth_key'] ) ) {
1382 $this->error_mes .= __( '* Please enter the Settlement auth key.', 'usces' ) . '<br />';
1383 } else {
1384 $auth_key = md5( $post_data['auth_key'] );
1385 $welcartpay_keys = get_option( 'usces_welcartpay_keys', array() );
1386 if ( ! in_array( $auth_key, $welcartpay_keys, true ) ) {
1387 $this->error_mes .= __( '* The Settlement auth key is incorrect.', 'usces' ) . '<br />';
1388 }
1389 }
1390 if ( WCUtils::is_blank( $post_data['ope'] ) ) {
1391 $this->error_mes .= __( '* Please select the operating environment.', 'usces' ) . '<br />';
1392 }
1393 if ( WCUtils::is_blank( $post_data['operateid'] ) ) {
1394 $this->error_mes .= __( '* Please select the processing classification.', 'usces' ) . '<br />';
1395 }
1396 if ( 'on' === $options['acting_settings']['welcart']['card_activate'] ) {
1397 if ( WCUtils::is_blank( $post_data['token_code'] ) ) {
1398 $this->error_mes .= __( '* Please enter the Token auth code.', 'usces' ) . '<br />';
1399 }
1400 }
1401 }
1402 }
1403 if ( 'on' === $options['acting_settings']['welcart']['unionpay_activate'] ) {
1404 if ( WCUtils::is_blank( $post_data['unionpay_key_aes'] ) ) {
1405 $this->error_mes .= __( '* Please enter the UnionPay tripartite encryption key.', 'usces' ) . '<br />';
1406 }
1407 if ( WCUtils::is_blank( $post_data['unionpay_key_iv'] ) ) {
1408 $this->error_mes .= __( '* Please enter the UnionPay tripartite initialization vector.', 'usces' ) . '<br />';
1409 }
1410 }
1411
1412 if ( '' === $this->error_mes ) {
1413 $usces->action_status = 'success';
1414 $usces->action_message = __( 'Options are updated.', 'usces' );
1415 if ( ( 'on' === $options['acting_settings']['welcart']['card_activate'] || 'link' === $options['acting_settings']['welcart']['card_activate'] || 'token' === $options['acting_settings']['welcart']['card_activate'] ) ||
1416 'on' === $options['acting_settings']['welcart']['conv_activate'] ||
1417 'on' === $options['acting_settings']['welcart']['atodene_activate'] ||
1418 'on' === $options['acting_settings']['welcart']['applepay_activate'] ||
1419 'on' === $options['acting_settings']['welcart']['unionpay_activate'] ) {
1420 $options['acting_settings']['welcart']['activate'] = 'on';
1421 if ( 'public' === $options['acting_settings']['welcart']['ope'] ) {
1422 $options['acting_settings']['welcart']['send_url'] = 'https://www.e-scott.jp/online/aut/OAUT002.do';
1423 $options['acting_settings']['welcart']['send_url_member'] = 'https://www.e-scott.jp/online/crp/OCRP005.do';
1424 $options['acting_settings']['welcart']['send_url_conv'] = 'https://www.e-scott.jp/online/cnv/OCNV005.do';
1425 $options['acting_settings']['welcart']['redirect_url_conv'] = 'https://link.kessai.info/JLP/JLPcon';
1426 $options['acting_settings']['welcart']['send_url_link'] = 'https://www.e-scott.jp/euser/snp/SSNP005ReferStart.do';
1427 $options['acting_settings']['welcart']['api_token'] = 'https://www.e-scott.jp/euser/stn/CdGetJavaScript.do';
1428 $options['acting_settings']['welcart']['send_url_token'] = 'https://www.e-scott.jp/online/atn/OATN005.do';
1429 $options['acting_settings']['welcart']['send_url_3dsecure'] = 'https://www.e-scott.jp/online/tds/OTDS010.do';
1430 $options['acting_settings']['welcart']['send_url_applepay'] = 'https://www.e-scott.jp/online/aut/OAUT002.do';
1431 $options['acting_settings']['welcart']['send_url_applepay_member'] = 'https://www.e-scott.jp/online/crp/OCRP005.do';
1432 $options['acting_settings']['welcart']['send_url_unionpay'] = 'https://www.e-scott.jp/online/agc/OAGC010.do';
1433 } else {
1434 $options['acting_settings']['welcart']['send_url'] = 'https://www.test.e-scott.jp/online/aut/OAUT002.do';
1435 $options['acting_settings']['welcart']['send_url_member'] = 'https://www.test.e-scott.jp/online/crp/OCRP005.do';
1436 $options['acting_settings']['welcart']['send_url_conv'] = 'https://www.test.e-scott.jp/online/cnv/OCNV005.do';
1437 $options['acting_settings']['welcart']['redirect_url_conv'] = 'https://link.kessai.info/JLPCT/JLPcon';
1438 $options['acting_settings']['welcart']['send_url_link'] = 'https://www.test.e-scott.jp/euser/snp/SSNP005ReferStart.do';
1439 $options['acting_settings']['welcart']['api_token'] = 'https://www.test.e-scott.jp/euser/stn/CdGetJavaScript.do';
1440 $options['acting_settings']['welcart']['send_url_token'] = 'https://www.test.e-scott.jp/online/atn/OATN005.do';
1441 $options['acting_settings']['welcart']['send_url_3dsecure'] = 'https://www.test.e-scott.jp/online/tds/OTDS010.do';
1442 $options['acting_settings']['welcart']['send_url_applepay'] = 'https://www.test.e-scott.jp/online/aut/OAUT002.do';
1443 $options['acting_settings']['welcart']['send_url_applepay_member'] = 'https://www.test.e-scott.jp/online/crp/OCRP005.do';
1444 $options['acting_settings']['welcart']['send_url_unionpay'] = 'https://www.test.e-scott.jp/online/agc/OAGC010.do';
1445 $options['acting_settings']['welcart']['tenant_id'] = '0001';
1446 }
1447 $toactive = array();
1448 if ( 'on' === $options['acting_settings']['welcart']['card_activate'] ) {
1449 if ( ! empty( $options['acting_settings']['welcart']['token_code'] ) ) {
1450 $options['acting_settings']['welcart']['card_activate'] = 'token';
1451 }
1452 }
1453 if ( 'on' === $options['acting_settings']['welcart']['card_activate'] || 'link' === $options['acting_settings']['welcart']['card_activate'] || 'token' === $options['acting_settings']['welcart']['card_activate'] ) {
1454 $usces->payment_structure['acting_welcart_card'] = __( 'Credit card transaction (WelcartPay)', 'usces' );
1455 foreach ( $payment_method as $settlement => $payment ) {
1456 if ( 'acting_welcart_card' === $settlement && 'deactivate' === $payment['use'] ) {
1457 $toactive[] = $payment['name'];
1458 }
1459 }
1460 } else {
1461 unset( $usces->payment_structure['acting_welcart_card'] );
1462 }
1463 if ( 'on' === $options['acting_settings']['welcart']['conv_activate'] ) {
1464 $usces->payment_structure['acting_welcart_conv'] = __( 'Online storage agency (WelcartPay)', 'usces' );
1465 foreach ( $payment_method as $settlement => $payment ) {
1466 if ( 'acting_welcart_conv' === $settlement && 'deactivate' === $payment['use'] ) {
1467 $toactive[] = $payment['name'];
1468 }
1469 }
1470 } else {
1471 unset( $usces->payment_structure['acting_welcart_conv'] );
1472 }
1473 if ( 'on' === $options['acting_settings']['welcart']['atodene_activate'] ) {
1474 $usces->payment_structure['acting_welcart_atodene'] = __( 'Postpay settlement (WelcartPay/ATODENE)', 'usces' );
1475 foreach ( $payment_method as $settlement => $payment ) {
1476 if ( 'acting_welcart_atodene' === $settlement && 'deactivate' === $payment['use'] ) {
1477 $toactive[] = $payment['name'];
1478 }
1479 }
1480 } else {
1481 unset( $usces->payment_structure['acting_welcart_atodene'] );
1482 }
1483 if ( 'on' === $options['acting_settings']['welcart']['unionpay_activate'] ) {
1484 $usces->payment_structure['acting_welcart_unionpay'] = __( 'UnionPay (WelcartPay)', 'usces' );
1485 foreach ( $payment_method as $settlement => $payment ) {
1486 if ( 'acting_welcart_unionpay' === $settlement && 'deactivate' === $payment['use'] ) {
1487 $toactive[] = $payment['name'];
1488 }
1489 }
1490 } else {
1491 unset( $usces->payment_structure['acting_welcart_unionpay'] );
1492 }
1493 usces_admin_orderlist_show_wc_trans_id();
1494 if ( 0 < count( $toactive ) ) {
1495 $usces->action_message .= __( 'Please update the payment method to "Activate". <a href="admin.php?page=usces_initial#payment_method_setting">General Setting > Payment Methods</a>', 'usces' );
1496 }
1497 } else {
1498 $options['acting_settings']['welcart']['activate'] = 'off';
1499 unset( $usces->payment_structure['acting_welcart_card'] );
1500 unset( $usces->payment_structure['acting_welcart_conv'] );
1501 unset( $usces->payment_structure['acting_welcart_atodene'] );
1502 unset( $usces->payment_structure['acting_welcart_applepay'] );
1503 unset( $usces->payment_structure['acting_welcart_unionpay'] );
1504 }
1505 $deactivate = array();
1506 foreach ( $payment_method as $settlement => $payment ) {
1507 if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
1508 if ( 'deactivate' !== $payment['use'] ) {
1509 $payment['use'] = 'deactivate';
1510 $deactivate[] = $payment['name'];
1511 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
1512 }
1513 }
1514 }
1515 if ( 0 < count( $deactivate ) ) {
1516 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
1517 $usces->action_message .= $deactivate_message;
1518 }
1519 } else {
1520 $usces->action_status = 'error';
1521 $usces->action_message = __( 'Data have deficiency.', 'usces' );
1522 $options['acting_settings']['welcart']['activate'] = 'off';
1523 unset( $usces->payment_structure['acting_welcart_card'] );
1524 unset( $usces->payment_structure['acting_welcart_conv'] );
1525 unset( $usces->payment_structure['acting_welcart_atodene'] );
1526 unset( $usces->payment_structure['acting_welcart_applepay'] );
1527 unset( $usces->payment_structure['acting_welcart_unionpay'] );
1528 $deactivate = array();
1529 foreach ( $payment_method as $settlement => $payment ) {
1530 if ( in_array( $settlement, $this->pay_method, true ) ) {
1531 if ( 'deactivate' !== $payment['use'] ) {
1532 $payment['use'] = 'deactivate';
1533 $deactivate[] = $payment['name'];
1534 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
1535 }
1536 }
1537 }
1538 if ( 0 < count( $deactivate ) ) {
1539 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
1540 $usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
1541 }
1542 }
1543 ksort( $usces->payment_structure );
1544 update_option( 'usces', $options );
1545 update_option( 'usces_payment_structure', $usces->payment_structure );
1546 }
1547
1548 /**
1549 * クレジット決済設定画面フォーム
1550 * usces_action_settlement_tab_body
1551 */
1552 public function settlement_tab_body() {
1553 $acting_opts = $this->get_acting_settings();
1554 $settlement_selected = get_option( 'usces_settlement_selected', array() );
1555 if ( in_array( 'welcart', $settlement_selected, true ) ) :
1556 $ope = ( isset( $acting_opts['ope'] ) && 'public' === $acting_opts['ope'] ) ? 'public' : 'test';
1557 $card_activate = ( isset( $acting_opts['card_activate'] ) && ( 'on' === $acting_opts['card_activate'] || 'token' === $acting_opts['card_activate'] ) ) ? 'on' : $acting_opts['card_activate'];
1558 $sec3d_activate = ( isset( $acting_opts['sec3d_activate'] ) && 'on' === $acting_opts['sec3d_activate'] ) ? 'on' : 'off';
1559 $seccd = ( isset( $acting_opts['seccd'] ) && 'on' === $acting_opts['seccd'] ) ? 'on' : 'off';
1560 $quickpay = ( isset( $acting_opts['quickpay'] ) && 'on' === $acting_opts['quickpay'] ) ? 'on' : 'off';
1561 $chooseable_quickpay = ( isset( $acting_opts['chooseable_quickpay'] ) && 'on' === $acting_opts['chooseable_quickpay'] ) ? 'on' : 'off';
1562 $operateid = ( isset( $acting_opts['operateid'] ) ) ? $acting_opts['operateid'] : '1Gathering';
1563 if ( defined( 'WCEX_DLSELLER' ) ) {
1564 $operateid_dlseller = ( isset( $acting_opts['operateid_dlseller'] ) ) ? $acting_opts['operateid_dlseller'] : '1Gathering';
1565 $auto_settlement_mail = ( isset( $acting_opts['auto_settlement_mail'] ) && 'on' === $acting_opts['auto_settlement_mail'] ) ? 'on' : 'off';
1566 }
1567 $howtopay = ( isset( $acting_opts['howtopay'] ) ) ? $acting_opts['howtopay'] : '1';
1568 $conv_activate = ( isset( $acting_opts['conv_activate'] ) && 'on' === $acting_opts['conv_activate'] ) ? 'on' : 'off';
1569 $atodene_activate = ( isset( $acting_opts['atodene_activate'] ) && 'on' === $acting_opts['atodene_activate'] ) ? 'on' : 'off';
1570 $atodene_byitem = ( isset( $acting_opts['atodene_byitem'] ) && 'on' === $acting_opts['atodene_byitem'] ) ? 'on' : 'off';
1571 $atodene_billing_method = ( isset( $acting_opts['atodene_billing_method'] ) ) ? $acting_opts['atodene_billing_method'] : '2';
1572 $unionpay_activate = ( isset( $acting_opts['unionpay_activate'] ) && 'on' === $acting_opts['unionpay_activate'] ) ? 'on' : 'off';
1573 ?>
1574 <div id="uscestabs_welcart">
1575 <div class="settlement_service"><span class="service_title"><?php esc_html_e( 'WelcartPay', 'usces' ); ?></span></div>
1576 <?php
1577 if ( 'welcart' === filter_input( INPUT_POST, 'acting', FILTER_DEFAULT ) ) :
1578 if ( '' !== $this->error_mes ) :
1579 ?>
1580 <div class="error_message"><?php echo wp_kses_post( $this->error_mes ); ?></div>
1581 <?php
1582 elseif ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) :
1583 ?>
1584 <div class="message"><?php esc_html_e( 'Test thoroughly before use.', 'usces' ); ?></div>
1585 <?php
1586 endif;
1587 endif;
1588 ?>
1589 <form action="" method="post" name="welcart_form" id="welcart_form">
1590 <table class="settle_table">
1591 <tr>
1592 <th><a class="explanation-label" id="label_ex_merchant_id_welcart"><?php esc_html_e( 'Merchant ID', 'usces' ); /* マーチャントID */ ?></a></th>
1593 <td><input name="merchant_id" type="text" id="merchant_id_welcart" value="<?php echo esc_attr( $acting_opts['merchant_id'] ); ?>" class="regular-text" /></td>
1594 </tr>
1595 <tr id="ex_merchant_id_welcart" class="explanation"><td colspan="2"><?php esc_html_e( 'Merchant ID (single-byte numbers only) issued from e-SCOTT.', 'usces' ); ?></td></tr>
1596 <tr>
1597 <th><a class="explanation-label" id="label_ex_merchant_pass_welcart"><?php esc_html_e( 'Merchant Password', 'usces' ); /* マーチャントパスワード */ ?></a></th>
1598 <td><input name="merchant_pass" type="text" id="merchant_pass_welcart" value="<?php echo esc_attr( $acting_opts['merchant_pass'] ); ?>" class="regular-text" /></td>
1599 </tr>
1600 <tr id="ex_merchant_pass_welcart" class="explanation"><td colspan="2"><?php esc_html_e( 'Merchant Password (single-byte alphanumeric characters only) issued from e-SCOTT.', 'usces' ); ?></td></tr>
1601 <tr>
1602 <th><a class="explanation-label" id="label_ex_tenant_id_welcart"><?php esc_html_e( 'Tenant ID', 'usces' ); /* 店舗コード */ ?></a></th>
1603 <td><input name="tenant_id" type="text" id="tenant_id_welcart" value="<?php echo esc_attr( $acting_opts['tenant_id'] ); ?>" class="regular-text" /></td>
1604 </tr>
1605 <tr id="ex_tenant_id_welcart" class="explanation"><td colspan="2"><?php echo wp_kses_post( __( 'Tenant ID issued from e-SCOTT.<br />If you have only one shop to contract, enter 0001.', 'usces' ) ); ?></td></tr>
1606 <tr>
1607 <th><a class="explanation-label" id="label_ex_auth_key_welcart"><?php esc_html_e( 'Settlement auth key', 'usces' ); /* 決済認証キー */ ?></a></th>
1608 <td><input name="auth_key" type="text" id="auth_key_welcart" value="<?php echo esc_attr( $acting_opts['auth_key'] ); ?>" class="regular-text" /></td>
1609 </tr>
1610 <tr id="ex_auth_key_welcart" class="explanation"><td colspan="2"><?php esc_html_e( 'Settlement auth key (single-byte numbers only) issued from e-SCOTT.', 'usces' ); ?></td></tr>
1611 <tr>
1612 <th><a class="explanation-label" id="label_ex_ope_welcart"><?php esc_html_e( 'Operation Environment', 'usces' ); /* 動作環境 */ ?></a></th>
1613 <td><label><input name="ope" type="radio" id="ope_welcart_1" value="test"<?php checked( $ope, 'test' ); ?> /><span><?php esc_html_e( 'Testing environment', 'usces' ); ?></span></label><br />
1614 <label><input name="ope" type="radio" id="ope_welcart_2" value="public"<?php checked( $ope, 'public' ); ?> /><span><?php esc_html_e( 'Production environment', 'usces' ); ?></span></label>
1615 </td>
1616 </tr>
1617 <tr id="ex_ope_welcart" class="explanation"><td colspan="2"><?php esc_html_e( 'Switch the operating environment.', 'usces' ); ?></td></tr>
1618 </table>
1619 <table class="settle_table">
1620 <tr>
1621 <th><?php esc_html_e( 'Credit card settlement', 'usces' ); /* クレジットカード決済 */ ?></th>
1622 <td><label><input name="card_activate" type="radio" class="card_activate_welcart" id="card_activate_welcart_1" value="on"<?php checked( $card_activate, 'on' ); ?> /><span><?php esc_html_e( 'Use with non-passage type', 'usces' ); ?></span></label><br />
1623 <label><input name="card_activate" type="radio" class="card_activate_welcart" id="card_activate_welcart_2" value="link"<?php checked( $card_activate, 'link' ); ?> /><span><?php esc_html_e( 'Use with external link type', 'usces' ); ?></span></label><br />
1624 <label><input name="card_activate" type="radio" class="card_activate_welcart" id="card_activate_welcart_0" value="off"<?php checked( $card_activate, 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
1625 </td>
1626 </tr>
1627 <tr class="card_sec3d_welcart">
1628 <th><a class="explanation-label" id="label_ex_sec3d_activate"><?php esc_html_e( '3D Secure', 'usces' ); /* 3Dセキュア */ ?></a></th>
1629 <td><label><input name="sec3d_activate" type="radio" class="sec3d_activate_welcart" id="sec3d_activate_1" value="on"<?php checked( $sec3d_activate, 'on' ); ?> /><span><?php esc_html_e( 'Use', 'usces' ); ?></span></label><br />
1630 <label><input name="sec3d_activate" type="radio" class="sec3d_activate_welcart" id="sec3d_activate_0" value="off"<?php checked( $sec3d_activate, 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
1631 </td>
1632 </tr>
1633 <tr id="ex_sec3d_activate" class="explanation card_welcart card_sec3d_welcart"><td colspan="2"><?php esc_html_e( '3D secure authentication at the time of payment. If you want to use it, you need to apply to SP.LINKS Inc.', 'usces' ); ?></td></tr>
1634 <tr class="card_welcart card_key_welcart">
1635 <th><a class="explanation-label" id="label_ex_card_key_aes_welcart"><?php esc_html_e( 'Encryption Key', 'usces' ); /* 暗号化キー */ ?></a></th>
1636 <td><input name="card_key_aes" type="text" id="card_key_aes_welcart" value="<?php echo esc_attr( $acting_opts['card_key_aes'] ); ?>" class="regular-text" /></td>
1637 </tr>
1638 <tr id="ex_card_key_aes_welcart" class="explanation card_welcart card_key_welcart"><td colspan="2"><?php esc_html_e( 'Encryption key (single-byte alphanumeric characters only) issued by e-SCOTT.', 'usces' ); ?><?php esc_html_e( 'If you want to use 3D Secure Authentication or External Link Type Payment, please apply to SP.LINKS Inc.', 'usces' ); ?></td></tr>
1639 <tr class="card_welcart card_key_welcart">
1640 <th><a class="explanation-label" id="label_ex_card_key_iv_welcart"><?php esc_html_e( 'Initialization Vector', 'usces' ); /* 初期化ベクトル */ ?></a></th>
1641 <td><input name="card_key_iv" type="text" id="card_key_iv_welcart" value="<?php echo esc_attr( $acting_opts['card_key_iv'] ); ?>" class="regular-text" /></td>
1642 </tr>
1643 <tr id="ex_card_key_iv_welcart" class="explanation card_welcart card_key_welcart"><td colspan="2"><?php esc_html_e( 'Initialization vector (single-byte alphanumeric characters only) issued by e-SCOTT.', 'usces' ); ?><?php esc_html_e( 'If you want to use 3D Secure Authentication or External Link Type Payment, please apply to SP.LINKS Inc.', 'usces' ); ?></td></tr>
1644 <tr class="card_token_code_welcart">
1645 <th><a class="explanation-label" id="label_ex_token_code_welcart"><?php esc_html_e( 'Token auth code', 'usces' ); /* トークン決済認証コード */ ?></a></th>
1646 <td><input name="token_code" type="text" id="token_code_welcart" value="<?php echo esc_attr( $acting_opts['token_code'] ); ?>" class="regular-text" maxlength="32" /></td>
1647 </tr>
1648 <tr id="ex_token_code_welcart" class="explanation card_token_code_welcart"><td colspan="2"><?php esc_html_e( 'Token auth code (single-byte alphanumeric characters only) issued from e-SCOTT.', 'usces' ); ?></td></tr>
1649 <tr class="card_welcart">
1650 <th><a class="explanation-label" id="label_ex_seccd_welcart"><?php echo wp_kses_post( __( 'Security code <br /> (authentication assist)', 'usces' ) ); /* セキュリティコード */ ?></a></th>
1651 <td><label><input name="seccd" type="radio" id="seccd_welcart_1" value="on"<?php checked( $seccd, 'on' ); ?> /><span><?php esc_html_e( 'Use', 'usces' ); ?></span></label><br />
1652 <label><input name="seccd" type="radio" id="seccd_welcart_0" value="off"<?php checked( $seccd, 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
1653 </td>
1654 </tr>
1655 <tr id="ex_seccd_welcart" class="explanation card_welcart"><td colspan="2"><?php esc_html_e( "Use 'Security code' of authentication assist matching. If you decide not to use, please also set 'Do not verify matching' on the e-SCOTT management screen.", 'usces' ); ?></td></tr>
1656 <tr class="card_welcart">
1657 <th><a class="explanation-label" id="label_ex_quickpay_welcart"><?php esc_html_e( 'Quick payment', 'usces' ); /* クイック決済 */ ?></a></th>
1658 <td><label><input name="quickpay" type="radio" class="quickpay_welcart" id="quickpay_welcart_1" value="on"<?php checked( $quickpay, 'on' ); ?> /><span><?php esc_html_e( 'Use', 'usces' ); ?></span></label><br />
1659 <label><input name="quickpay" type="radio" class="quickpay_welcart" id="quickpay_welcart_0" value="off"<?php checked( $quickpay, 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
1660 </td>
1661 </tr>
1662 <tr id="ex_quickpay_welcart" class="explanation card_welcart"><td colspan="2"><?php esc_html_e( 'Members can pay with saved card. Card number will be registered in e-SCOTT Smart system.', 'usces' ); ?><?php esc_html_e( "When using automatic continuing charging (required WCEX DLSeller) or subscription (required WCEX Auto Delivery), please make 'Quick payment' of 'Use'.", 'usces' ); ?></td></tr>
1663 <tr class="card_chooseable_quickpay_welcart">
1664 <th><a class="explanation-label" id="label_ex_chooseable_quickpay_welcart"><?php esc_html_e( 'Register credit card', 'usces' ); /* クレジットカードの登録 */ ?></a></th>
1665 <td><label><input name="chooseable_quickpay" type="radio" class="chooseable_quickpay_welcart" id="chooseable_quickpay_welcart_1" value="on"<?php checked( $chooseable_quickpay, 'on' ); ?> /><span><?php esc_html_e( 'Member chooses', 'usces' ); ?></span></label><br />
1666 <label><input name="chooseable_quickpay" type="radio" class="chooseable_quickpay_welcart" id="chooseable_quickpay_welcart_0" value="off"<?php checked( $chooseable_quickpay, 'off' ); ?> /><span><?php esc_html_e( 'Always register', 'usces' ); ?></span></label>
1667 </td>
1668 </tr>
1669 <tr id="ex_chooseable_quickpay_welcart" class="explanation card_chooseable_quickpay_welcart"><td colspan="2"><?php esc_html_e( "In case of 'Always register', 'Register and purchase credit card' will not be displayed when purchasing with credit card.", 'usces' ); ?></td></tr>
1670 <tr class="card_welcart">
1671 <th><a class="explanation-label" id="label_ex_operateid_welcart"><?php esc_html_e( 'Processing classification', 'usces' ); /* 処理区分 */ ?></a></th>
1672 <td><label><input name="operateid" type="radio" id="operateid_welcart_1" value="1Auth"<?php checked( $operateid, '1Auth' ); ?> /><span><?php esc_html_e( 'Credit', 'usces' ); /* 与信 */ ?></span></label><br />
1673 <label><input name="operateid" type="radio" id="operateid_welcart_2" value="1Gathering"<?php checked( $operateid, '1Gathering' ); ?> /><span><?php esc_html_e( 'Credit sales', 'usces' ); /* 与信売上計上 */ ?></span></label>
1674 </td>
1675 </tr>
1676 <tr id="ex_operateid_welcart" class="explanation card_welcart"><td colspan="2"><?php esc_html_e( "In case of 'Credit' setting, it need to change to 'Sales recorded' manually in later. In case of 'Credit sales recorded' setting, sales will be recorded at the time of purchase.", 'usces' ); ?></td></tr>
1677 <?php if ( defined( 'WCEX_DLSELLER' ) ) : ?>
1678 <tr class="card_welcart">
1679 <th><a class="explanation-label" id="label_ex_operateid_dlseller_welcart"><?php esc_html_e( 'Automatic Continuing Charging Processing Classification', 'usces' ); /* 自動継続課金処理区分 */ ?></a></th>
1680 <td><label><input name="operateid_dlseller" type="radio" id="operateid_dlseller_welcart_1" value="1Auth"<?php checked( $operateid_dlseller, '1Auth' ); ?> /><span><?php esc_html_e( 'Credit', 'usces' ); /* 与信 */ ?></span></label><br />
1681 <label><input name="operateid_dlseller" type="radio" id="operateid_dlseller_welcart_2" value="1Gathering"<?php checked( $operateid_dlseller, '1Gathering' ); ?> /><span><?php esc_html_e( 'Credit sales', 'usces' ); /* 与信売上計上 */ ?></span></label>
1682 </td>
1683 </tr>
1684 <tr id="ex_operateid_dlseller_welcart" class="explanation card_welcart"><td colspan="2"><?php esc_html_e( 'Processing classification when automatic continuing charging (required WCEX DLSeller).', 'usces' ); ?></td></tr>
1685 <tr class="card_welcart">
1686 <th><a class="explanation-label" id="label_ex_auto_settlement_mail_welcart"><?php esc_html_e( 'Automatic Continuing Charging Completion Mail', 'usces' ); /* 自動継続課金完了メール */ ?></a></th>
1687 <td><label><input name="auto_settlement_mail" type="radio" id="auto_settlement_mail_welcart_1" value="on"<?php checked( $auto_settlement_mail, 'on' ); ?> /><span><?php esc_html_e( 'Send', 'usces' ); ?></span></label><br />
1688 <label><input name="auto_settlement_mail" type="radio" id="auto_settlement_mail_welcart_0" value="off"<?php checked( $auto_settlement_mail, 'off' ); ?> /><span><?php esc_html_e( "Don't send", 'usces' ); ?></span></label>
1689 </td>
1690 </tr>
1691 <tr id="ex_auto_settlement_mail_welcart" class="explanation card_welcart"><td colspan="2"><?php esc_html_e( 'Send billing completion mail to the member on which automatic continuing charging processing (required WCEX DLSeller) is executed.', 'usces' ); ?></td></tr>
1692 <?php endif; ?>
1693 <tr class="card_howtopay_welcart">
1694 <th><a class="explanation-label" id="label_ex_howtopay_welcart"><?php esc_html_e( 'Number of payments', 'usces' ); /* 支払回数 */ ?></a></th>
1695 <td><label><input name="howtopay" type="radio" id="howtopay_welcart_1" value="1"<?php checked( $howtopay, '1' ); ?> /><span><?php esc_html_e( 'Lump-sum payment only', 'usces' ); /* 一括払いのみ */ ?></span></label><br />
1696 <label><input name="howtopay" type="radio" id="howtopay_welcart_2" value="2"<?php checked( $howtopay, '2' ); ?> /><span><?php esc_html_e( 'Activate installment payment', 'usces' ); /* 分割払いを有効にする */ ?></span></label><br />
1697 <label><input name="howtopay" type="radio" id="howtopay_welcart_3" value="3"<?php checked( $howtopay, '3' ); ?> /><span><?php esc_html_e( 'Activate installment payments and bonus payments', 'usces' ); /* 分割払いとボーナス払いを有効にする */ ?></span></label>
1698 </td>
1699 </tr>
1700 <tr id="ex_howtopay_welcart" class="explanation card_howtopay_welcart"><td colspan="2"><?php esc_html_e( 'It can be selected when using in non-passage type.', 'usces' ); ?></td></tr>
1701 </table>
1702 <table class="settle_table">
1703 <tr>
1704 <th><?php esc_html_e( 'Online storage agency', 'usces' ); /* オンライン収納代行 */ ?></th>
1705 <td><label><input name="conv_activate" type="radio" class="conv_activate_welcart" id="conv_activate_welcart_1" value="on"<?php checked( $conv_activate, 'on' ); ?> /><span><?php esc_html_e( 'Use', 'usces' ); ?></span></label><br />
1706 <label><input name="conv_activate" type="radio" class="conv_activate_welcart" id="conv_activate_welcart_0" value="off"<?php checked( $conv_activate, 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
1707 </td>
1708 </tr>
1709 <tr class="conv_welcart">
1710 <th><?php esc_html_e( 'Payment due days', 'usces' ); /* 支払期限日数 */ ?></th>
1711 <td><input name="conv_limit" type="text" id="conv_limit" value="<?php echo esc_attr( $acting_opts['conv_limit'] ); ?>" class="small-text" /><?php esc_html_e( 'days', 'usces' ); ?></td>
1712 </tr>
1713 <tr class="conv_welcart">
1714 <th><a class="explanation-label" id="label_ex_conv_fee_welcart"><?php esc_html_e( 'Fee', 'usces' ); /* 手数料 */ ?></a></th>
1715 <td><span id="conv_fee_type_field" class="fee_type_field"><?php echo esc_html( $this->get_fee_name( $acting_opts['conv_fee_type'] ) ); ?></span><input type="button" class="button" value="<?php esc_attr_e( 'Detailed setting', 'usces' ); ?>" id="conv_fee_setting" /></td>
1716 </tr>
1717 <tr id="ex_conv_fee_welcart" class="explanation conv_welcart"><td colspan="2"><?php esc_html_e( 'Set the online storage agency commission and settlement upper limit. Leave it blank if you do not need it.', 'usces' ); ?></td></tr>
1718 </table>
1719 <table class="settle_table">
1720 <tr>
1721 <th><?php esc_html_e( 'Postpay settlement (ATODENE)', 'usces' ); /* 後払い決済 */ ?></th>
1722 <td><label><input name="atodene_activate" type="radio" class="atodene_activate_welcart" id="atodene_activate_welcart_1" value="on"<?php checked( $atodene_activate, 'on' ); ?> /><span><?php esc_html_e( 'Use', 'usces' ); ?></span></label><br />
1723 <label><input name="atodene_activate" type="radio" class="atodene_activate_welcart" id="atodene_activate_welcart_0" value="off"<?php checked( $atodene_activate, 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
1724 </td>
1725 </tr>
1726 <tr class="atodene_welcart">
1727 <th><a class="explanation-label" id="label_ex_atodene_byitem_welcart"><?php esc_html_e( 'Possibility of each items', 'usces' ); /* 商品ごとの可否 */ ?></a></th>
1728 <td><label><input name="atodene_byitem" type="radio" id="atodene_byitem_welcart_1" value="on"<?php checked( $atodene_byitem, 'on' ); ?> /><span><?php esc_html_e( 'Enabled', 'usces' ); ?></span></label><br />
1729 <label><input name="atodene_byitem" type="radio" id="atodene_byitem_welcart_0" value="off"<?php checked( $atodene_byitem, 'off' ); ?> /><span><?php esc_html_e( 'Disabled', 'usces' ); ?></span></label>
1730 </td>
1731 </tr>
1732 <tr id="ex_atodene_byitem_welcart" class="explanation atodene_welcart"><td colspan="2"><?php echo wp_kses_post( __( 'It is effective when setting possibility of each items. Invalid when not distinguished in particular.<br />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.<br />In addition, availability data is added to the product CSV as a custom field (welcartpay_atodene).', 'usces' ) ); ?></td></tr>
1733 <tr class="atodene_welcart">
1734 <th><a class="explanation-label" id="label_ex_atodene_billing_method_welcart"><?php esc_html_e( 'Invoice delivery method', 'usces' ); /* 請求書送付方法 */ ?></a></th>
1735 <td><label><input name="atodene_billing_method" type="radio" id="atodene_billing_method_welcart_2" value="2"<?php checked( $atodene_billing_method, '2' ); ?> /><span><?php esc_html_e( 'Separate shipment', 'usces' ); /* 別送 */ ?></span></label><br />
1736 <label><input name="atodene_billing_method" type="radio" id="atodene_billing_method_welcart_3" value="3"<?php checked( $atodene_billing_method, '3' ); ?> /><span><?php esc_html_e( 'Include shipment', 'usces' ); /* 同梱 */ ?></span></label>
1737 </td>
1738 </tr>
1739 <tr id="ex_atodene_billing_method_welcart" class="explanation atodene_welcart"><td colspan="2"><?php esc_html_e( 'How to send invoices from ATODENE.', 'usces' ); ?></td></tr>
1740 <tr class="atodene_welcart">
1741 <th><a class="explanation-label" id="label_ex_atodene_fee_welcart"><?php esc_html_e( 'Fee', 'usces' ); ?></a></th>
1742 <td><span id="atodene_fee_type_field" class="fee_type_field"><?php echo esc_html( $this->get_fee_name( $acting_opts['atodene_fee_type'] ) ); ?></span><input type="button" class="button" value="<?php esc_attr_e( 'Detailed setting', 'usces' ); ?>" id="atodene_fee_setting" /></td>
1743 </tr>
1744 <tr id="ex_atodene_fee_welcart" class="explanation atodene_welcart"><td colspan="2"><?php esc_html_e( 'Set up postpaid settlement fee and maximum settlement amount. Leave it blank if you do not need it.', 'usces' ); ?></td></tr>
1745 </table>
1746 <table class="settle_table">
1747 <tr>
1748 <th><?php esc_html_e( 'UnionPay', 'usces' ); /* 銀聯 */ ?></th>
1749 <td><label><input name="unionpay_activate" type="radio" class="unionpay_activate_welcart" id="unionpay_activate_welcart_1" value="on"<?php checked( $unionpay_activate, 'on' ); ?> /><span><?php esc_html_e( 'Use', 'usces' ); ?></span></label><br />
1750 <label><input name="unionpay_activate" type="radio" class="unionpay_activate_welcart" id="unionpay_activate_welcart_0" value="off"<?php checked( $unionpay_activate, 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
1751 </td>
1752 </tr>
1753 <tr class="unionpay_welcart">
1754 <th><a class="explanation-label" id="label_ex_unionpay_key_aes_welcart"><?php esc_html_e( 'Encryption Key', 'usces' ); /* 銀聯暗号化キー */ ?></a></th>
1755 <td><input name="unionpay_key_aes" type="text" id="unionpay_key_aes_welcart" value="<?php echo esc_attr( $acting_opts['unionpay_key_aes'] ); ?>" class="regular-text" /></td>
1756 </tr>
1757 <tr id="ex_unionpay_key_aes_welcart" class="explanation unionpay_welcart"><td colspan="2"><?php esc_html_e( 'UnionPay encryption key (single-byte alphanumeric characters only) issued by e-SCOTT.', 'usces' ); ?></td></tr>
1758 <tr class="unionpay_welcart">
1759 <th><a class="explanation-label" id="label_ex_unionpay_key_iv_welcart"><?php esc_html_e( 'Initialization Vector', 'usces' ); /* 銀聯初期化ベクトル */ ?></a></th>
1760 <td><input name="unionpay_key_iv" type="text" id="unionpay_key_iv_welcart" value="<?php echo esc_attr( $acting_opts['unionpay_key_iv'] ); ?>" class="regular-text" /></td>
1761 </tr>
1762 <tr id="ex_unionpay_key_iv_welcart" class="explanation unionpay_welcart"><td colspan="2"><?php esc_html_e( 'UnionPay initialization vector (single-byte alphanumeric characters only) issued by e-SCOTT.', 'usces' ); ?></td></tr>
1763 <tr class="unionpay_welcart">
1764 <th><a class="explanation-label" id="label_ex_unionpay_pagelanguage_welcart"><?php esc_html_e( 'Page Language', 'usces' ); /* 三�
1765 間ページ言語 */ ?></a></th>
1766 <td><select name="unionpay_pagelanguage" id="unionpay_pagelanguage_welcart">
1767 <option value=""><?php esc_html_e( 'Not set', 'usces' ); ?></option>
1768 <option value="zh_CN"<?php selected( $acting_opts['unionpay_pagelanguage'], 'zh_CN' ); ?>><?php esc_html_e( 'Chinese (Simplified)', 'usces' ); ?></option>
1769 <option value="zh_TW"<?php selected( $acting_opts['unionpay_pagelanguage'], 'zh_TW' ); ?>><?php esc_html_e( 'Chinese (Traditional)', 'usces' ); ?></option>
1770 <option value="en_US"<?php selected( $acting_opts['unionpay_pagelanguage'], 'en_US' ); ?>><?php esc_html_e( 'English', 'usces' ); ?></option>
1771 <option value="ja_JP"<?php selected( $acting_opts['unionpay_pagelanguage'], 'ja_JP' ); ?>><?php esc_html_e( 'Japanese', 'usces' ); ?></option>
1772 <option value="ko_KR"<?php selected( $acting_opts['unionpay_pagelanguage'], 'ko_KR' ); ?>><?php esc_html_e( 'Korean', 'usces' ); ?></option>
1773 </select>
1774 </td>
1775 </tr>
1776 <tr id="ex_unionpay_pagelanguage_welcart" class="explanation unionpay_welcart"><td colspan="2"><?php esc_html_e( 'Specifies the language of the SecurePay payment page. If not set, the page is displayed according to the language of the end user\'s browser. For mobile devices, only Chinese and English are displayed.', 'usces' ); ?></td></tr>
1777 </table>
1778 <input type="hidden" name="acting" value="welcart" />
1779 <input type="hidden" name="conv_fee_type" id="conv_fee_type" value="<?php echo esc_attr( $acting_opts['conv_fee_type'] ); ?>" />
1780 <input type="hidden" name="conv_fee" id="conv_fee" value="<?php echo esc_attr( $acting_opts['conv_fee'] ); ?>" />
1781 <input type="hidden" name="conv_fee_limit_amount_fix" id="conv_fee_limit_amount_fix" value="<?php echo esc_attr( $acting_opts['conv_fee_limit_amount'] ); ?>" />
1782 <input type="hidden" name="conv_fee_first_amount" id="conv_fee_first_amount" value="<?php echo esc_attr( $acting_opts['conv_fee_first_amount'] ); ?>" />
1783 <input type="hidden" name="conv_fee_first_fee" id="conv_fee_first_fee" value="<?php echo esc_attr( $acting_opts['conv_fee_first_fee'] ); ?>" />
1784 <input type="hidden" name="conv_fee_limit_amount_change" id="conv_fee_limit_amount_change" value="<?php echo esc_attr( $acting_opts['conv_fee_limit_amount'] ); ?>" />
1785 <input type="hidden" name="conv_fee_amounts" id="conv_fee_amounts" value="<?php echo esc_attr( implode( '|', $acting_opts['conv_fee_amounts'] ) ); ?>" />
1786 <input type="hidden" name="conv_fee_fees" id="conv_fee_fees" value="<?php echo esc_attr( implode( '|', $acting_opts['conv_fee_fees'] ) ); ?>" />
1787 <input type="hidden" name="conv_fee_end_fee" id="conv_fee_end_fee" value="<?php echo esc_attr( $acting_opts['conv_fee_end_fee'] ); ?>" />
1788 <input type="hidden" name="atodene_fee_type" id="atodene_fee_type" value="<?php echo esc_attr( $acting_opts['atodene_fee_type'] ); ?>" />
1789 <input type="hidden" name="atodene_fee" id="atodene_fee" value="<?php echo esc_attr( $acting_opts['atodene_fee'] ); ?>" />
1790 <input type="hidden" name="atodene_fee_limit_amount_fix" id="atodene_fee_limit_amount_fix" value="<?php echo esc_attr( $acting_opts['atodene_fee_limit_amount'] ); ?>" />
1791 <input type="hidden" name="atodene_fee_first_amount" id="atodene_fee_first_amount" value="<?php echo esc_attr( $acting_opts['atodene_fee_first_amount'] ); ?>" />
1792 <input type="hidden" name="atodene_fee_first_fee" id="atodene_fee_first_fee" value="<?php echo esc_attr( $acting_opts['atodene_fee_first_fee'] ); ?>" />
1793 <input type="hidden" name="atodene_fee_limit_amount_change" id="atodene_fee_limit_amount_change" value="<?php echo esc_attr( $acting_opts['atodene_fee_limit_amount'] ); ?>" />
1794 <input type="hidden" name="atodene_fee_amounts" id="atodene_fee_amounts" value="<?php echo esc_attr( implode( '|', $acting_opts['atodene_fee_amounts'] ) ); ?>" />
1795 <input type="hidden" name="atodene_fee_fees" id="atodene_fee_fees" value="<?php echo esc_attr( implode( '|', $acting_opts['atodene_fee_fees'] ) ); ?>" />
1796 <input type="hidden" name="atodene_fee_end_fee" id="atodene_fee_end_fee" value="<?php echo esc_attr( $acting_opts['atodene_fee_end_fee'] ); ?>" />
1797 <input name="usces_option_update" type="submit" class="button button-primary" value="<?php esc_attr_e( 'Update WelcartPay settings', 'usces' ); ?>" />
1798 <?php wp_nonce_field( 'admin_settlement', 'wc_nonce' ); ?>
1799 </form>
1800 <div class="settle_exp">
1801 <p><strong>WelcartPay based on e-SCOTT</strong><br />
1802 <a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank"><?php esc_html_e( 'Details of e-SCOTT Smart is here >>', 'usces' ); ?></a></p>
1803 <p><?php esc_html_e( "'Non-passage type' is a settlement system that completes with shop site only, without transitioning to the page of the settlement company.", 'usces' ); ?><br />
1804 <?php esc_html_e( 'Stylish with unified design is possible. However, because we will handle the card number, dedicated SSL is required.', 'usces' ); ?><br />
1805 <?php esc_html_e( "'External link type' is a settlement system that moves to the page of the settlement company and inputs card information.", 'usces' ); ?><br />
1806 <?php esc_html_e( 'In both types, the entered card number will be sent to the e-SCOTT Smart system, so it will not be saved in Welcart.', 'usces' ); ?></p>
1807 <p><?php esc_html_e( "'WCEX DL Seller' is necessary when using 'automatic continuing charging'.", 'usces' ); ?><br />
1808 <?php esc_html_e( "'WCEX Auto Delivery' is necessary when using 'subscription'.", 'usces' ); ?></p>
1809 <p><?php esc_html_e( 'In addition, in the production environment, it is SSL communication with only an authorized SSL certificate, so it is necessary to be careful.', 'usces' ); ?></p>
1810 <p><?php esc_html_e( 'The Welcart member account used in the test environment may not be available in the production environment.', 'usces' ); ?><br />
1811 <?php esc_html_e( 'Please make another member registration in the test environment and production environment, or delete the member used in the test environment once and register again in the production environment.', 'usces' ); ?></p>
1812 <p><strong><?php esc_html_e( '[About 3D Secure]', 'usces' ); ?></strong><br />
1813 <?php esc_html_e( 'If you do not use 3D Secure (do not check the "Use" box), the merchant is responsible for payment due to fraudulent use of the credit card.', 'usces' ); ?><br />
1814 <?php esc_html_e( 'Even if we have already paid the merchant an amount equivalent to the sales proceeds, the merchant must return the amount to us upon request for a chargeback (return of sales proceeds) from the credit card company.', 'usces' ); ?><br />
1815 <?php esc_html_e( 'Please note that chargebacks may occur even if you select "Use". Please understand this in advance.', 'usces' ); ?><br />
1816 <?php esc_html_e( 'If you have applied for the EMV 3D Secure service, please be sure to select "Use".', 'usces' ); ?></p>
1817 <p><strong><?php esc_html_e( '[Note on chargebacks]', 'usces' ); ?></strong><br />
1818 <?php esc_html_e( '* Even if sales approval has been obtained (when the authorization result is OK), chargebacks will still be incurred.', 'usces' ); ?><br />
1819 <?php esc_html_e( '* If chargebacks occur, there is no compensation or reimbursement by us or the credit card companies. The merchant is responsible for all charges.', 'usces' ); ?><br />
1820 <?php esc_html_e( "* Chargebacks will be incurred regardless of whether the merchant's intentional or negligent conduct is involved.", 'usces' ); ?><br />
1821 <?php esc_html_e( 'Please be sure to confirm the following before starting to use the service.', 'usces' ); ?><br />
1822 <a href="https://www.splinks.co.jp/yougo/chargeback.html" target="_blank"><?php esc_html_e( 'About chargebacks', 'usces' ); ?></a></p>
1823 </div>
1824 </div><!--uscestabs_welcart-->
1825
1826 <div id="welcartpay_fee_dialog" class="cod_dialog">
1827 <fieldset>
1828 <table id="welcartpay_fee_type_table" class="cod_type_table">
1829 <tr>
1830 <th><?php esc_html_e( 'Type of the fee', 'usces' ); ?></th>
1831 <td class="radio"><input name="fee_type" type="radio" id="fee_type_fix" class="fee_type" value="fix" /></td><td><label for="fee_type_fix"><?php esc_html_e( 'Fixation', 'usces' ); ?></label></td>
1832 <td class="radio"><input name="fee_type" type="radio" id="fee_type_change" class="fee_type" value="change" /></td><td><label for="fee_type_change"><?php esc_html_e( 'Variable', 'usces' ); ?></label></td>
1833 </tr>
1834 </table>
1835 <table id="welcartpay_fee_fix_table" class="cod_fix_table">
1836 <tr>
1837 <th><?php esc_html_e( 'Fee', 'usces' ); ?></th>
1838 <td><input name="fee" type="text" id="fee_fix" class="short_str num" /><?php usces_crcode(); ?></td>
1839 </tr>
1840 <tr>
1841 <th><?php esc_html_e( 'Upper limit', 'usces' ); ?></th>
1842 <td><input name="fee_limit_amount_fix" type="text" id="fee_limit_amount_fix" class="short_str num" /><?php usces_crcode(); ?></td>
1843 </tr>
1844 </table>
1845 <div id="welcartpay_fee_change_table" class="cod_change_table">
1846 <input type="button" class="button" id="fee_add_row" value="<?php esc_attr_e( 'Add row', 'usces' ); ?>" />
1847 <input type="button" class="button" id="fee_del_row" value="<?php esc_attr_e( 'Delete row', 'usces' ); ?>" />
1848 <table>
1849 <thead>
1850 <tr>
1851 <th colspan="3"><?php esc_html_e( 'A purchase amount', 'usces' ); ?>(<?php usces_crcode(); ?>)</th>
1852 <th><?php esc_html_e( 'Fee', 'usces' ); ?>(<?php usces_crcode(); ?>)</th>
1853 </tr>
1854 <tr>
1855 <td class="cod_f">0</td>
1856 <td class="cod_m"><?php esc_html_e( ' - ', 'usces' ); ?></td>
1857 <td class="cod_e"><input name="fee_first_amount" id="fee_first_amount" type="text" class="short_str num" /></td>
1858 <td class="cod_cod"><input name="fee_first_fee" id="fee_first_fee" type="text" class="short_str num" /></td>
1859 </tr>
1860 </thead>
1861 <tbody id="fee_change_field"></tbody>
1862 <tfoot>
1863 <tr>
1864 <td class="cod_f"><span id="end_amount"></span></td>
1865 <td class="cod_m"><?php esc_html_e( ' - ', 'usces' ); ?></td>
1866 <td class="cod_e"><input name="fee_limit_amount_change" type="text" id="fee_limit_amount_change" class="short_str num" /></td>
1867 <td class="cod_cod"><input name="fee_end_fee" type="text" id="fee_end_fee" class="short_str num" /></td>
1868 </tr>
1869 </tfoot>
1870 </table>
1871 </div>
1872 </fieldset>
1873 <input type="hidden" id="welcartpay_fee_mode">
1874 </div><!--welcartpay_fee_dialog-->
1875 <?php
1876 endif;
1877 }
1878
1879 /**
1880 * ゼウス定期購�
1881 �メッセージ
1882 * wcad_filter_admin_notices
1883 *
1884 * @param string $msg Admin message.
1885 * @return string
1886 */
1887 public function admin_notices_autodelivery( $msg ) {
1888 global $usces;
1889
1890 $acting_opts = $this->get_acting_settings();
1891 if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
1892 ( isset( $acting_opts['card_activate'] ) && ( 'on' === $acting_opts['card_activate'] || 'link' === $acting_opts['card_activate'] || 'token' === $acting_opts['card_activate'] ) ) &&
1893 ( isset( $acting_opts['quickpay'] ) && 'on' === $acting_opts['quickpay'] ) ) {
1894 $msg = '';
1895 } else {
1896 $zeus_opts = $usces->options['acting_settings']['zeus'];
1897 $p_flag = ( ( isset( $zeus_opts['activate'] ) && 'on' === $zeus_opts['activate'] ) && ( isset( $zeus_opts['card_activate'] ) && 'on' === $zeus_opts['card_activate'] ) ) ? true : false;
1898 $batch = ( isset( $zeus_opts['batch'] ) ) ? $zeus_opts['batch'] : 'off';
1899 if ( ! $p_flag || 'off' === $batch ) {
1900 $msg .= '
1901 <div class="error">
1902 <p>' . __( "In 'credit settlement Settings', please set to 'use' the quickpay of WelcartPay.", 'usces' ) . '</p>
1903 </div>';
1904 }
1905 }
1906 return $msg;
1907 }
1908
1909 /**
1910 * �
1911 �金通知処理および、三�
1912 間決済画面からのリダイレクト
1913 * usces_after_cart_instant
1914 */
1915 public function acting_transaction() {
1916 global $usces;
1917
1918 /* �
1919 �金通知 */
1920 if ( isset( $_REQUEST['MerchantFree1'] ) && isset( $_REQUEST['MerchantId'] ) && isset( $_REQUEST['TransactionId'] ) && isset( $_REQUEST['RecvNum'] ) && isset( $_REQUEST['NyukinDate'] ) &&
1921 ( isset( $_REQUEST['MerchantFree2'] ) && 'acting_welcart_conv' === wp_unslash( $_REQUEST['MerchantFree2'] ) ) ) {
1922 $this->acting_notice_ip_guard( wp_unslash( $_REQUEST ) );
1923 $acting_opts = $this->get_acting_settings();
1924 if ( $acting_opts['merchant_id'] === wp_unslash( $_REQUEST['MerchantId'] ) ) {
1925 $response_data = wp_unslash( $_REQUEST );
1926 $order_id = usces_get_order_id_by_trans_id( $response_data['MerchantFree1'] );
1927 if ( ! empty( $order_id ) ) {
1928
1929 /* オーダーステータス変更 */
1930 usces_change_order_receipt( $order_id, 'receipted' );
1931 /* ポイント付与 */
1932 usces_action_acting_getpoint( $order_id );
1933
1934 $response_data['OperateId'] = 'receipted';
1935 $order_meta = usces_unserialize( $usces->get_order_meta_value( $response_data['MerchantFree2'], $order_id ) );
1936 $meta_value = array_merge( $order_meta, $response_data );
1937 $usces->set_order_meta_value( $response_data['MerchantFree2'], usces_serialize( $meta_value ), $order_id );
1938 $this->save_acting_history_log( $response_data, $order_id . '_' . $response_data['MerchantFree1'] );
1939 usces_log( '[WelcartPay] conv receipted : ' . print_r( $response_data, true ), 'acting_transaction.log' );
1940 } else {
1941 usces_log( '[WelcartPay] conv receipted order_id error : ' . print_r( $response_data, true ), 'acting_transaction.log' );
1942 }
1943 }
1944 header( 'HTTP/1.0 200 OK' );
1945 die();
1946
1947 } elseif ( isset( $_REQUEST['EncryptValue'] ) ) {
1948 $acting_opts = $this->get_acting_settings();
1949
1950 /* 銀聯決済 */
1951 if ( isset( $_REQUEST['acting'] ) && $this->acting_unionpay === wp_unslash( $_REQUEST['acting'] ) && $this->is_validity_acting( 'unionpay' ) ) {
1952 $encryptvalue = openssl_decrypt( $_REQUEST['EncryptValue'], 'aes-128-cbc', $acting_opts['unionpay_key_aes'], false, $acting_opts['unionpay_key_iv'] );
1953 if ( $encryptvalue ) {
1954 parse_str( $encryptvalue, $response_data );
1955 if ( isset( $response_data['OperateId'] ) && isset( $response_data['ResponseCd'] ) && isset( $response_data['MerchantFree1'] ) &&
1956 ( isset( $response_data['MerchantFree2'] ) && 'acting_welcart_unionpay' === $response_data['MerchantFree2'] ) ) {
1957 if ( 'OK' === $response_data['ResponseCd'] ) {
1958 $order_data = usces_restore_order_acting_data( $response_data['MerchantFree1'] );
1959 if ( ! empty( $order_data ) ) {
1960 $response_data['acting'] = $this->acting_unionpay;
1961 $res = $usces->order_processing( $response_data );
1962 if ( 'ordercompletion' === $res ) {
1963 $_nonce = ( isset( $order_data['_nonce'] ) ) ? $order_data['_nonce'] : wp_create_nonce( $this->acting_flg_unionpay );
1964 wp_redirect(
1965 add_query_arg(
1966 array(
1967 'acting' => $this->acting_unionpay,
1968 'acting_return' => 1,
1969 'result' => 1,
1970 '_nonce' => $_nonce,
1971 ),
1972 USCES_CART_URL
1973 )
1974 );
1975 } else {
1976 $logdata = array_merge( $usces_entries['order'], $response_data );
1977 $log = array(
1978 'acting' => $this->acting_unionpay,
1979 'key' => $response_data['MerchantFree1'],
1980 'result' => 'ORDER DATA REGISTERED ERROR',
1981 'data' => $logdata,
1982 );
1983 usces_save_order_acting_error( $log );
1984 wp_redirect(
1985 add_query_arg(
1986 array(
1987 'acting' => $this->acting_unionpay,
1988 'acting_return' => 0,
1989 'result' => 0,
1990 ),
1991 USCES_CART_URL
1992 )
1993 );
1994 }
1995 } else {
1996 $log = array(
1997 'acting' => $this->acting_unionpay,
1998 'key' => $response_data['MerchantFree1'],
1999 'result' => 'ORDER DATA RESTORE ERROR',
2000 'data' => $response_data,
2001 );
2002 usces_save_order_acting_error( $log );
2003 wp_redirect(
2004 add_query_arg(
2005 array(
2006 'acting' => $this->acting_unionpay,
2007 'acting_return' => 0,
2008 'result' => 0,
2009 ),
2010 USCES_CART_URL
2011 )
2012 );
2013 }
2014 } elseif ( 'KI0' === $response_data['ResponseCd'] ) {
2015 /* Return to Merchant */
2016 wp_redirect(
2017 add_query_arg(
2018 array(
2019 'confirm' => 1,
2020 ),
2021 USCES_CART_URL
2022 )
2023 );
2024 } else {
2025 $responsecd = explode( '|', $response_data['ResponseCd'] );
2026 foreach ( (array) $responsecd as $cd ) {
2027 $response_data[ $cd ] = $this->response_message( $cd );
2028 }
2029 $log = array(
2030 'acting' => $this->acting_unionpay,
2031 'key' => $response_data['MerchantFree1'],
2032 'result' => $response_data['ResponseCd'],
2033 'data' => $response_data,
2034 );
2035 usces_save_order_acting_error( $log );
2036 wp_redirect(
2037 add_query_arg(
2038 array(
2039 'acting' => $this->acting_unionpay,
2040 'acting_return' => 0,
2041 'result' => 0,
2042 ),
2043 USCES_CART_URL
2044 )
2045 );
2046 }
2047 }
2048 exit();
2049 }
2050
2051 /* 外部リンク(三�
2052 間画面)決済 */
2053 } else {
2054 $encryptvalue = openssl_decrypt( $_REQUEST['EncryptValue'], 'aes-128-cbc', $acting_opts['key_aes'], false, $acting_opts['key_iv'] );
2055 if ( $encryptvalue ) {
2056 parse_str( $encryptvalue, $response_data );
2057 if ( isset( $response_data['OperateId'] ) && isset( $response_data['ResponseCd'] ) && ( isset( $response_data['MerchantId'] ) && $acting_opts['merchant_id'] === $response_data['MerchantId'] ) ) {
2058 $cancel = array( 'P51', 'P52', 'P55', 'P56', 'P62', 'P63', 'P64', 'P65', 'P69', 'P70' );
2059 if ( isset( $response_data['MerchantFree1'] ) && ( isset( $response_data['MerchantFree2'] ) && 'acting_welcart_card' === $response_data['MerchantFree2'] ) ) {
2060 if ( 'OK' === $response_data['ResponseCd'] ) {
2061 /* 会員登録・会員変更 */
2062 if ( '4MemAdd' === $response_data['OperateId'] || '4MemChg' === $response_data['OperateId'] ) {
2063 $member = $usces->get_member();
2064 $usces->set_member_meta_value( 'wcpay_member_id', $response_data['KaiinId'], $member['ID'] );
2065 $usces->set_member_meta_value( 'wcpay_member_passwd', $response_data['KaiinPass'], $member['ID'] );
2066
2067 $usces_entries = $usces->cart->get_entry();
2068 $cart = $usces->cart->get_cart();
2069
2070 if ( usces_have_continue_charge() ) {
2071 $chargingday = $usces->getItemChargingDay( $cart[0]['post_id'] );
2072 if ( 99 === (int) $chargingday ) { /* 受注日課金 */
2073 $operateid = $acting_opts['operateid'];
2074 } else {
2075 $operateid = '1Auth';
2076 }
2077 } else {
2078 $operateid = $acting_opts['operateid'];
2079 }
2080 $operateid = apply_filters( 'usces_filter_escott_operateid', $operateid, $cart, $usces_entries['order']['total_full_price'] );
2081
2082 $home_url = str_replace( 'http://', 'https://', home_url( '/' ) );
2083 $redirecturl = $home_url . '?page_id=' . USCES_CART_NUMBER;
2084
2085 $data_list = array();
2086 $data_list['OperateId'] = $operateid;
2087 $data_list['MerchantPass'] = $acting_opts['merchant_pass'];
2088 $data_list['TransactionDate'] = $response_data['TransactionDate'];
2089 $data_list['MerchantFree1'] = $response_data['MerchantFree1'];
2090 $data_list['MerchantFree2'] = $response_data['MerchantFree2'];
2091 $data_list['MerchantFree3'] = $this->merchantfree3;
2092 $data_list['TenantId'] = $acting_opts['tenant_id'];
2093 $data_list['KaiinId'] = $response_data['KaiinId'];
2094 $data_list['KaiinPass'] = $response_data['KaiinPass'];
2095 $data_list['PayType'] = '01';
2096 $data_list['Amount'] = $usces_entries['order']['total_full_price'];
2097 $data_list['ProcNo'] = '0000000';
2098 if ( isset( $response_data['EncodeXId3D'] ) ) {
2099 $data_list['EncodeXId3D'] = $response_data['EncodeXId3D'];
2100 }
2101 if ( isset( $response_data['TransactionId3D'] ) ) {
2102 $data_list['TransactionId3D'] = $response_data['TransactionId3D'];
2103 }
2104 if ( isset( $response_data['MessageVersionNo3D'] ) ) {
2105 $data_list['MessageVersionNo3D'] = $response_data['MessageVersionNo3D'];
2106 }
2107 if ( isset( $response_data['TransactionStatus3D'] ) ) {
2108 $data_list['TransactionStatus3D'] = $response_data['TransactionStatus3D'];
2109 }
2110 if ( isset( $response_data['CAVVAlgorithm3D'] ) ) {
2111 $data_list['CAVVAlgorithm3D'] = $response_data['CAVVAlgorithm3D'];
2112 }
2113 if ( isset( $response_data['ECI3D'] ) ) {
2114 $data_list['ECI3D'] = $response_data['ECI3D'];
2115 }
2116 if ( isset( $response_data['CAVV3D'] ) ) {
2117 $data_list['CAVV3D'] = $response_data['CAVV3D'];
2118 }
2119 if ( isset( $response_data['SecureResultCode'] ) ) {
2120 $data_list['SecureResultCode'] = $response_data['SecureResultCode'];
2121 }
2122 if ( isset( $response_data['DSTransactionId'] ) ) {
2123 $data_list['DSTransactionId'] = $response_data['DSTransactionId'];
2124 }
2125 if ( isset( $response_data['ThreeDSServerTransactionId'] ) ) {
2126 $data_list['ThreeDSServerTransactionId'] = $response_data['ThreeDSServerTransactionId'];
2127 }
2128 $data_list['RedirectUrl'] = $redirecturl;
2129 $data_query = http_build_query( $data_list );
2130 $encryptvalue = openssl_encrypt( $data_query, 'aes-128-cbc', $acting_opts['key_aes'], false, $acting_opts['key_iv'] );
2131 wp_redirect(
2132 add_query_arg(
2133 array(
2134 'MerchantId' => $acting_opts['merchant_id'],
2135 'EncryptValue' => urlencode( $encryptvalue ),
2136 ),
2137 $acting_opts['send_url_link']
2138 )
2139 );
2140 exit();
2141
2142 /* 決済 */
2143 } else {
2144 $order_data = usces_restore_order_acting_data( $response_data['MerchantFree1'] );
2145 if ( ! empty( $order_data ) ) {
2146 $res = $usces->order_processing( $response_data );
2147 if ( 'ordercompletion' === $res ) {
2148 $_nonce = ( isset( $order_data['_nonce'] ) ) ? $order_data['_nonce'] : wp_create_nonce( $this->acting_flg_card );
2149 wp_redirect(
2150 add_query_arg(
2151 array(
2152 'acting' => $this->acting_card,
2153 'acting_return' => 1,
2154 'result' => 1,
2155 '_nonce' => $_nonce,
2156 ),
2157 USCES_CART_URL
2158 )
2159 );
2160 } else {
2161 $log = array(
2162 'acting' => $this->acting_card,
2163 'key' => $response_data['MerchantFree1'],
2164 'result' => 'ORDER DATA REGISTERED ERROR',
2165 'data' => $response_data,
2166 );
2167 usces_save_order_acting_error( $log );
2168 wp_redirect(
2169 add_query_arg(
2170 array(
2171 'acting' => $this->acting_card,
2172 'acting_return' => 0,
2173 'result' => 0,
2174 ),
2175 USCES_CART_URL
2176 )
2177 );
2178 }
2179 } else {
2180 $log = array(
2181 'acting' => $this->acting_card,
2182 'key' => $response_data['MerchantFree1'],
2183 'result' => 'ORDER DATA RESTORE ERROR',
2184 'data' => $response_data,
2185 );
2186 usces_save_order_acting_error( $log );
2187 wp_redirect(
2188 add_query_arg(
2189 array(
2190 'acting' => $this->acting_card,
2191 'acting_return' => 0,
2192 'result' => 0,
2193 ),
2194 USCES_CART_URL
2195 )
2196 );
2197 }
2198 }
2199 } elseif ( in_array( $response_data['ResponseCd'], $cancel, true ) ) {
2200 wp_redirect(
2201 add_query_arg(
2202 array(
2203 'acting' => $this->acting_card,
2204 'confirm' => 1,
2205 ),
2206 USCES_CART_URL
2207 )
2208 );
2209 } else {
2210 $responsecd = explode( '|', $response_data['ResponseCd'] );
2211 foreach ( (array) $responsecd as $cd ) {
2212 $response_data[ $cd ] = $this->response_message( $cd );
2213 }
2214 $log = array(
2215 'acting' => $this->acting_card,
2216 'key' => $response_data['MerchantFree1'],
2217 'result' => $response_data['ResponseCd'],
2218 'data' => $response_data,
2219 );
2220 usces_save_order_acting_error( $log );
2221 wp_redirect(
2222 add_query_arg(
2223 array(
2224 'acting' => $this->acting_card,
2225 'acting_return' => 0,
2226 'result' => 0,
2227 ),
2228 USCES_CART_URL
2229 )
2230 );
2231 }
2232 } else {
2233 /* マイページからの会員登録・会員変更 */
2234 if ( '4MemAdd' === $response_data['OperateId'] || '4MemChg' === $response_data['OperateId'] ) {
2235 if ( 'OK' === $response_data['ResponseCd'] ) {
2236 $member = $usces->get_member();
2237 $usces->set_member_meta_value( 'wcpay_member_id', $response_data['KaiinId'], $member['ID'] );
2238 $usces->set_member_meta_value( 'wcpay_member_passwd', $response_data['KaiinPass'], $member['ID'] );
2239
2240 } elseif ( in_array( $response_data['ResponseCd'], $cancel ) ) { // phpcs:ignore
2241
2242 } else {
2243 usces_log( '[WelcartPay] 4MemChg NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
2244 }
2245 wp_redirect( USCES_MEMBER_URL );
2246 }
2247 }
2248 exit();
2249 }
2250 }
2251 }
2252 }
2253 }
2254
2255 /**
2256 * 管理画面決済処理
2257 * usces_action_admin_ajax
2258 */
2259 public function admin_ajax() {
2260 global $usces;
2261
2262 $mode = filter_input( INPUT_POST, 'mode', FILTER_DEFAULT );
2263 $data = array();
2264
2265 switch ( $mode ) {
2266 /* 取引参�
2267 � */
2268 case 'get_welcartpay_card':
2269 check_admin_referer( 'order_edit', 'wc_nonce' );
2270 $order_id = filter_input( INPUT_POST, 'order_id' );
2271 $order_num = filter_input( INPUT_POST, 'order_num' );
2272 $trans_id = filter_input( INPUT_POST, 'trans_id' );
2273 if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) {
2274 $data['status'] = 'NG';
2275 $data['result'] = '';
2276 wp_send_json( $data );
2277 break;
2278 }
2279 $res = '';
2280 $log_data = array();
2281 if ( '9999999999' === $trans_id ) {
2282 $member_id = filter_input( INPUT_POST, 'member_id' );
2283 $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員�
2284 �会 */
2285 if ( 'OK' === $response_member['ResponseCd'] ) {
2286 $order_data = $usces->get_order_data( $order_id, 'direct' );
2287 $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'];
2288
2289 $res .= '<div class="welcart-settlement-admin card-new">' . __( 'New', 'usces' ) . '</div>';
2290 $res .= '<table class="welcart-settlement-admin-table">';
2291 $res .= '<tr><th>' . __( 'Spending amount', 'usces' ) . '</th>';
2292 $res .= '<td><input type="text" id="amount_change" value="' . $total_full_price . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $total_full_price . '" /></td>';
2293 $res .= '</tr>';
2294 $res .= '</table>';
2295 $res .= '<div class="welcart-settlement-admin-button">';
2296 $res .= '<input id="auth-settlement" type="button" class="button" value="' . __( 'Credit', 'usces' ) . '" />'; /* 与信 */
2297 $res .= '<input id="gathering-settlement" type="button" class="button" value="' . __( 'Credit sales', 'usces' ) . '" />'; /* 与信売上計上 */
2298 $res .= '</div>';
2299 } else {
2300 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Error', 'usces' ) . '</div>';
2301 $res .= '<div class="welcart-settlement-admin-error">';
2302 $res .= '<div><span class="message">' . __( 'Credit card information not registered', 'usces' ) . '</span></div>'; /* カード�
2303 報未登録 */
2304 $res .= '</div>';
2305 }
2306 $data['status'] = 'OK';
2307 $data['result'] = $res;
2308 } else {
2309 if ( 1 === (int) $order_num ) {
2310 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) );
2311 } else {
2312 $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id );
2313 $acting_data = usces_unserialize( $log_data[0]['log'] );
2314 }
2315 $operateid = $this->get_acting_operateid( $order_id . '_' . $trans_id );
2316 $acting_opts = $this->get_acting_settings();
2317 $transaction_date = $this->get_transaction_date();
2318 $param_list = array();
2319 $params = array();
2320 $param_list['MerchantId'] = $acting_opts['merchant_id'];
2321 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
2322 $param_list['TransactionDate'] = $transaction_date;
2323 $param_list['MerchantFree1'] = $trans_id;
2324 $param_list['MerchantFree2'] = 'acting_welcart_card';
2325 $param_list['MerchantFree3'] = $this->merchantfree3;
2326 $param_list['TenantId'] = $acting_opts['tenant_id'];
2327 $params['send_url'] = $acting_opts['send_url'];
2328 $params['param_list'] = array_merge(
2329 $param_list,
2330 array(
2331 'OperateId' => '1Search',
2332 'ProcessId' => $acting_data['ProcessId'],
2333 'ProcessPass' => $acting_data['ProcessPass'],
2334 )
2335 );
2336 $response_data = $this->connection( $params );
2337 if ( 'OK' === $response_data['ResponseCd'] ) {
2338 $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id );
2339 if ( isset( $latest_log['OperateId'] ) ) {
2340 $class = ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 1 ) );
2341 $status_name = $this->get_operate_name( $latest_log['OperateId'] );
2342 $res .= '<div class="welcart-settlement-admin' . $class . '">' . $status_name . '</div>';
2343 $res .= '<table class="welcart-settlement-admin-table">';
2344 if ( isset( $response_data['Amount'] ) ) {
2345 $res .= '<tr><th>' . __( 'Spending amount', 'usces' ) . '</th>';
2346 $res .= '<td><input type="text" id="amount_change" value="' . $response_data['Amount'] . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $response_data['Amount'] . '" /></td>';
2347 $res .= '</tr>';
2348 }
2349 if ( isset( $response_data['SalesDate'] ) ) {
2350 $res .= '<tr><th>' . __( 'Recorded sales date', 'usces' ) . '</th><td>' . $response_data['SalesDate'] . '</td></tr>';
2351 }
2352 $res .= '</table>';
2353 $res .= '<div class="welcart-settlement-admin-button">';
2354 if ( '1Delete' === $latest_log['OperateId'] ) {
2355 $res .= '<input id="reauth-settlement" type="button" class="button" value="' . __( 'Re-authorization', 'usces' ) . '" />'; /* 再オーソリ */
2356 } else {
2357 if ( '1Auth' === $operateid && '1Capture' !== $latest_log['OperateId'] && '1Gathering' !== $latest_log['OperateId'] ) {
2358 $res .= '<input id="reauth-settlement" type="button" class="button" value="' . __( 'Re-authorization', 'usces' ) . '" />'; /* 再オーソリ */
2359 $res .= '<input id="capture-settlement" type="button" class="button" value="' . __( 'Sales recorded', 'usces' ) . '" />'; /* 売上計上 */
2360 }
2361 if ( '1Delete' !== $latest_log['OperateId'] ) {
2362 $res .= '<input id="delete-settlement" type="button" class="button" value="' . __( 'Unregister', 'usces' ) . '" />'; /* 取消 */
2363 }
2364 if ( '1Change' !== $latest_log['OperateId'] ) {
2365 $res .= '<input id="change-settlement" type="button" class="button" value="' . __( 'Change spending amount', 'usces' ) . '" />'; /* 利用額変更 */
2366 }
2367 }
2368 $res .= '</div>';
2369 }
2370 } else {
2371 if ( 'K12' === $response_data['ResponseCd'] ) {
2372 $res .= '<div class="welcart-settlement-admin card-delete">' . __( 'Expired', 'usces' ) . '</div>';
2373 $res .= '<div class="welcart-settlement-admin-expired">';
2374 $res .= '<div><span class="code">K12</span> : <span class="message">' . __( 'Handling expired.', 'usces' ) . '</span></div>';
2375 $res .= '</div>';
2376 } else {
2377 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Error', 'usces' ) . '</div>';
2378 $res .= '<div class="welcart-settlement-admin-error">';
2379 $responsecd = explode( '|', $response_data['ResponseCd'] );
2380 foreach ( (array) $responsecd as $cd ) {
2381 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
2382 }
2383 $res .= '</div>';
2384 usces_log( '[WelcartPay] 1Search connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
2385 }
2386 }
2387 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
2388 $data['status'] = $response_data['ResponseCd'];
2389 $data['result'] = $res;
2390 }
2391 wp_send_json( $data );
2392 break;
2393
2394 /* 売上計上 */
2395 case 'capture_welcartpay_card':
2396 check_admin_referer( 'order_edit', 'wc_nonce' );
2397 $order_id = filter_input( INPUT_POST, 'order_id' );
2398 $order_num = filter_input( INPUT_POST, 'order_num' );
2399 $trans_id = filter_input( INPUT_POST, 'trans_id' );
2400 $amount = filter_input( INPUT_POST, 'amount' );
2401 if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) {
2402 $data['status'] = 'NG';
2403 wp_send_json( $data );
2404 break;
2405 }
2406 $res = '';
2407 $acting_status = '';
2408 $log_data = array();
2409 if ( 1 === (int) $order_num ) {
2410 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) );
2411 } else {
2412 $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id );
2413 $acting_data = usces_unserialize( $log_data[0]['log'] );
2414 }
2415 $acting_opts = $this->get_acting_settings();
2416 $transaction_date = $this->get_transaction_date();
2417 $param_list = array();
2418 $params = array();
2419 $param_list['MerchantId'] = $acting_opts['merchant_id'];
2420 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
2421 $param_list['TransactionDate'] = $transaction_date;
2422 $param_list['MerchantFree1'] = $trans_id;
2423 $param_list['MerchantFree2'] = 'acting_welcart_card';
2424 $param_list['MerchantFree3'] = $this->merchantfree3;
2425 $param_list['TenantId'] = $acting_opts['tenant_id'];
2426 $member_id = filter_input( INPUT_POST, 'member_id' );
2427 $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員�
2428 �会 */
2429 if ( 'OK' === $response_member['ResponseCd'] ) {
2430 $param_list['KaiinId'] = $response_member['KaiinId'];
2431 $param_list['KaiinPass'] = $response_member['KaiinPass'];
2432 }
2433 $params['send_url'] = $acting_opts['send_url'];
2434 $params['param_list'] = array_merge(
2435 $param_list,
2436 array(
2437 'OperateId' => '1Capture',
2438 'ProcessId' => $acting_data['ProcessId'],
2439 'ProcessPass' => $acting_data['ProcessPass'],
2440 'SalesDate' => $transaction_date,
2441 )
2442 );
2443 $response_data = $this->connection( $params );
2444 if ( 'K81' === $response_data['ResponseCd'] ) {
2445 $param_list['KaiinId'] = '';
2446 $param_list['KaiinPass'] = '';
2447 $params['param_list'] = array_merge(
2448 $param_list,
2449 array(
2450 'OperateId' => '1Capture',
2451 'ProcessId' => $acting_data['ProcessId'],
2452 'ProcessPass' => $acting_data['ProcessPass'],
2453 'SalesDate' => $transaction_date,
2454 )
2455 );
2456 $response_data = $this->connection( $params );
2457 }
2458 if ( 'OK' === $response_data['ResponseCd'] ) {
2459 $class = ' card-' . mb_strtolower( substr( $response_data['OperateId'], 1 ) );
2460 $status_name = $this->get_operate_name( $response_data['OperateId'] );
2461 $res .= '<div class="welcart-settlement-admin' . $class . '">' . $status_name . '</div>';
2462 $res .= '<table class="welcart-settlement-admin-table">';
2463 $res .= '<tr><th>' . __( 'Spending amount', 'usces' ) . '</th>';
2464 $res .= '<td><input type="text" id="amount_change" value="' . $amount . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $amount . '" /></td>';
2465 $res .= '</tr>';
2466 if ( isset( $response_data['SalesDate'] ) ) {
2467 $res .= '<tr><th>' . __( 'Recorded sales date', 'usces' ) . '</th><td>' . $response_data['SalesDate'] . '</td></tr>';
2468 }
2469 $res .= '</table>';
2470 $res .= '<div class="welcart-settlement-admin-button">';
2471 $res .= '<input id="delete-settlement" type="button" class="button" value="' . __( 'Unregister', 'usces' ) . '" />'; /* 取消 */
2472 $res .= '<input id="change-settlement" type="button" class="button" value="' . __( 'Change spending amount', 'usces' ) . '" />'; /* 利用額変更 */
2473 $res .= '</div>';
2474 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
2475 } else {
2476 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Error', 'usces' ) . '</div>';
2477 $res .= '<div class="welcart-settlement-admin-error">';
2478 $responsecd = explode( '|', $response_data['ResponseCd'] );
2479 foreach ( (array) $responsecd as $cd ) {
2480 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
2481 }
2482 $res .= '</div>';
2483 usces_log( '[WelcartPay] 1Capture connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
2484 }
2485 do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id );
2486 if ( ! isset( $response_data['Amount'] ) ) {
2487 $response_data['Amount'] = $amount;
2488 }
2489 $response_data = apply_filters( 'usces_filter_escott_capture_history_log', $response_data, $order_id );
2490 $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id );
2491 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
2492 $data['status'] = $response_data['ResponseCd'];
2493 $data['acting_status'] = $acting_status;
2494 $data['result'] = $res;
2495 $this->save_admin_log( $order_id, $order_id . '_' . $trans_id );
2496 wp_send_json( $data );
2497 break;
2498
2499 /* 取消/返品 */
2500 case 'delete_welcartpay_card':
2501 check_admin_referer( 'order_edit', 'wc_nonce' );
2502 $order_id = filter_input( INPUT_POST, 'order_id' );
2503 $order_num = filter_input( INPUT_POST, 'order_num' );
2504 $trans_id = filter_input( INPUT_POST, 'trans_id' );
2505 $amount = filter_input( INPUT_POST, 'amount' );
2506 if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) {
2507 $data['status'] = 'NG';
2508 wp_send_json( $data );
2509 break;
2510 }
2511 $res = '';
2512 $acting_status = '';
2513 $log_data = array();
2514 if ( 1 === (int) $order_num ) {
2515 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) );
2516 } else {
2517 $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id );
2518 $acting_data = usces_unserialize( $log_data[0]['log'] );
2519 }
2520 $acting_opts = $this->get_acting_settings();
2521 $transaction_date = $this->get_transaction_date();
2522 $param_list = array();
2523 $params = array();
2524 $param_list['MerchantId'] = $acting_opts['merchant_id'];
2525 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
2526 $param_list['TransactionDate'] = $transaction_date;
2527 $param_list['MerchantFree1'] = $trans_id;
2528 $param_list['MerchantFree2'] = 'acting_welcart_card';
2529 $param_list['MerchantFree3'] = $this->merchantfree3;
2530 $param_list['TenantId'] = $acting_opts['tenant_id'];
2531 $member_id = filter_input( INPUT_POST, 'member_id' );
2532 $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員�
2533 �会 */
2534 if ( 'OK' === $response_member['ResponseCd'] ) {
2535 $param_list['KaiinId'] = $response_member['KaiinId'];
2536 $param_list['KaiinPass'] = $response_member['KaiinPass'];
2537 }
2538 $params['send_url'] = $acting_opts['send_url'];
2539 $params['param_list'] = array_merge(
2540 $param_list,
2541 array(
2542 'OperateId' => '1Delete',
2543 'ProcessId' => $acting_data['ProcessId'],
2544 'ProcessPass' => $acting_data['ProcessPass'],
2545 )
2546 );
2547 $response_data = $this->connection( $params );
2548 if ( 'K81' === $response_data['ResponseCd'] ) {
2549 $param_list['KaiinId'] = '';
2550 $param_list['KaiinPass'] = '';
2551 $params['param_list'] = array_merge(
2552 $param_list,
2553 array(
2554 'OperateId' => '1Delete',
2555 'ProcessId' => $acting_data['ProcessId'],
2556 'ProcessPass' => $acting_data['ProcessPass'],
2557 )
2558 );
2559 $response_data = $this->connection( $params );
2560 }
2561 if ( 'OK' === $response_data['ResponseCd'] ) {
2562 $class = ' card-' . mb_strtolower( substr( $response_data['OperateId'], 1 ) );
2563 $status_name = $this->get_operate_name( $response_data['OperateId'] );
2564 $res .= '<div class="welcart-settlement-admin' . $class . '">' . $status_name . '</div>';
2565 $res .= '<table class="welcart-settlement-admin-table">';
2566 $res .= '<tr><th>' . __( 'Spending amount', 'usces' ) . '</th>';
2567 $res .= '<td><input type="text" id="amount_change" value="' . $amount . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $amount . '" /></td>';
2568 $res .= '</tr>';
2569 $res .= '</table>';
2570 $res .= '<div class="welcart-settlement-admin-button">';
2571 $res .= '<input id="reauth-settlement" type="button" class="button" value="' . __( 'Re-authorization', 'usces' ) . '" />'; /* 再オーソリ */
2572 $res .= '</div>';
2573 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
2574 } else {
2575 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Error', 'usces' ) . '</div>';
2576 $res .= '<div class="welcart-settlement-admin-error">';
2577 $responsecd = explode( '|', $response_data['ResponseCd'] );
2578 foreach ( (array) $responsecd as $cd ) {
2579 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
2580 }
2581 $res .= '</div>';
2582 usces_log( '[WelcartPay] 1Delete connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
2583 }
2584 do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id );
2585 if ( ! isset( $response_data['Amount'] ) ) {
2586 $response_data['Amount'] = $amount;
2587 }
2588 $response_data = apply_filters( 'usces_filter_escott_delete_history_log', $response_data, $order_id );
2589 $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id );
2590 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
2591 $data['status'] = $response_data['ResponseCd'];
2592 $data['acting_status'] = $acting_status;
2593 $data['result'] = $res;
2594 $this->save_admin_log( $order_id, $order_id . '_' . $trans_id );
2595 wp_send_json( $data );
2596 break;
2597
2598 /* 利用額変更 */
2599 case 'change_welcartpay_card':
2600 check_admin_referer( 'order_edit', 'wc_nonce' );
2601 $order_id = filter_input( INPUT_POST, 'order_id' );
2602 $order_num = filter_input( INPUT_POST, 'order_num' );
2603 $trans_id = filter_input( INPUT_POST, 'trans_id' );
2604 $amount = filter_input( INPUT_POST, 'amount' );
2605 if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) || is_null( $amount ) ) {
2606 $data['status'] = 'NG';
2607 wp_send_json( $data );
2608 break;
2609 }
2610 $res = '';
2611 $log_data = array();
2612 if ( 1 === (int) $order_num ) {
2613 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) );
2614 } else {
2615 $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id );
2616 $acting_data = usces_unserialize( $log_data[0]['log'] );
2617 }
2618 $operateid = $this->get_acting_operateid( $order_id . '_' . $trans_id );
2619 $acting_opts = $this->get_acting_settings();
2620 $transaction_date = $this->get_transaction_date();
2621 $param_list = array();
2622 $params = array();
2623 $param_list['MerchantId'] = $acting_opts['merchant_id'];
2624 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
2625 $param_list['TransactionDate'] = $transaction_date;
2626 $param_list['MerchantFree1'] = $trans_id;
2627 $param_list['MerchantFree2'] = 'acting_welcart_card';
2628 $param_list['MerchantFree3'] = $this->merchantfree3;
2629 $param_list['TenantId'] = $acting_opts['tenant_id'];
2630 $member_id = filter_input( INPUT_POST, 'member_id' );
2631 $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員�
2632 �会 */
2633 if ( 'OK' === $response_member['ResponseCd'] ) {
2634 $param_list['KaiinId'] = $response_member['KaiinId'];
2635 $param_list['KaiinPass'] = $response_member['KaiinPass'];
2636 }
2637 $params['send_url'] = $acting_opts['send_url'];
2638 $params['param_list'] = array_merge(
2639 $param_list,
2640 array(
2641 'OperateId' => '1Change',
2642 'ProcessId' => $acting_data['ProcessId'],
2643 'ProcessPass' => $acting_data['ProcessPass'],
2644 'Amount' => $amount,
2645 )
2646 );
2647 $response_data = $this->connection( $params );
2648 if ( 'K81' === $response_data['ResponseCd'] ) {
2649 $param_list['KaiinId'] = '';
2650 $param_list['KaiinPass'] = '';
2651 $params['param_list'] = array_merge(
2652 $param_list,
2653 array(
2654 'OperateId' => '1Change',
2655 'ProcessId' => $acting_data['ProcessId'],
2656 'ProcessPass' => $acting_data['ProcessPass'],
2657 'Amount' => $amount,
2658 )
2659 );
2660 $response_data = $this->connection( $params );
2661 }
2662 if ( 'OK' === $response_data['ResponseCd'] ) {
2663 $class = ' card-' . mb_strtolower( substr( $operateid, 1 ) );
2664 $status_name = $this->get_operate_name( $operateid );
2665 $res .= '<div class="welcart-settlement-admin' . $class . '">' . $status_name . '</div>';
2666 $res .= '<table class="welcart-settlement-admin-table">';
2667 $res .= '<tr><th>' . __( 'Spending amount', 'usces' ) . '</th>';
2668 $res .= '<td><input type="text" id="amount_change" value="' . $amount . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $amount . '" /></td>';
2669 $res .= '</tr>';
2670 if ( isset( $response_data['SalesDate'] ) ) {
2671 $res .= '<tr><th>' . __( 'Recorded sales date', 'usces' ) . '</th><td>' . $response_data['SalesDate'] . '</td></tr>';
2672 }
2673 $res .= '</table>';
2674 $res .= '<div class="welcart-settlement-admin-button">';
2675 if ( '1Capture' !== $operateid && '1Gathering' !== $operateid ) {
2676 $res .= '<input id="capture-settlement" type="button" class="button" value="' . __( 'Sales recorded', 'usces' ) . '" />'; /* 売上計上 */
2677 }
2678 $res .= '<input id="delete-settlement" type="button" class="button" value="' . __( 'Unregister', 'usces' ) . '" />'; /* 取消 */
2679 $res .= '<input id="change-settlement" type="button" class="button" value="' . __( 'Change spending amount', 'usces' ) . '" />'; /* 利用額変更 */
2680 $res .= '</div>';
2681 } else {
2682 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Error', 'usces' ) . '</div>'; /* エラー */
2683 $res .= '<div class="welcart-settlement-admin-error">';
2684 $responsecd = explode( '|', $response_data['ResponseCd'] );
2685 foreach ( (array) $responsecd as $cd ) {
2686 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
2687 }
2688 $res .= '</div>';
2689 usces_log( '[WelcartPay] 1Change connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
2690 }
2691 do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id );
2692 if ( ! isset( $response_data['Amount'] ) ) {
2693 $response_data['Amount'] = $amount;
2694 }
2695 $response_data = apply_filters( 'usces_filter_escott_change_history_log', $response_data, $order_id );
2696 $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id );
2697 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
2698 $data['status'] = $response_data['ResponseCd'];
2699 $data['result'] = $res;
2700 $this->save_admin_log( $order_id, $order_id . '_' . $trans_id );
2701 wp_send_json( $data );
2702 break;
2703
2704 /* 与信 */
2705 case 'auth_welcartpay_card':
2706 /* 与信売上計上 */
2707 case 'gathering_welcartpay_card':
2708 check_admin_referer( 'order_edit', 'wc_nonce' );
2709 $order_id = filter_input( INPUT_POST, 'order_id' );
2710 $order_num = filter_input( INPUT_POST, 'order_num' );
2711 $trans_id = filter_input( INPUT_POST, 'trans_id' );
2712 $amount = filter_input( INPUT_POST, 'amount' );
2713 if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) || is_null( $amount ) ) {
2714 $data['status'] = 'NG';
2715 wp_send_json( $data );
2716 break;
2717 }
2718 $res = '';
2719 $acting_status = '';
2720 $log_data = array();
2721 if ( '9999999999' === $trans_id ) {
2722 $trans_id = usces_acting_key();
2723 } else {
2724 if ( 1 === (int) $order_num ) {
2725 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) );
2726 } else {
2727 $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id );
2728 $acting_data = usces_unserialize( $log_data[0]['log'] );
2729 }
2730 }
2731 $operateid = ( 'auth_welcartpay_card' === $mode ) ? '1Auth' : '1Gathering';
2732 $acting_opts = $this->get_acting_settings();
2733 $transaction_date = $this->get_transaction_date();
2734 $param_list = array();
2735 $params = array();
2736 $param_list['MerchantId'] = $acting_opts['merchant_id'];
2737 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
2738 $param_list['TransactionDate'] = $transaction_date;
2739 $param_list['MerchantFree1'] = $trans_id;
2740 $param_list['MerchantFree2'] = 'acting_welcart_card';
2741 $param_list['MerchantFree3'] = $this->merchantfree3;
2742 $param_list['TenantId'] = $acting_opts['tenant_id'];
2743 $member_id = filter_input( INPUT_POST, 'member_id' );
2744 $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員�
2745 �会 */
2746 if ( 'OK' === $response_member['ResponseCd'] ) {
2747 $params['send_url'] = $acting_opts['send_url'];
2748 $params['param_list'] = array_merge(
2749 $param_list,
2750 array(
2751 'KaiinId' => $response_member['KaiinId'],
2752 'KaiinPass' => $response_member['KaiinPass'],
2753 'OperateId' => $operateid,
2754 'PayType' => '01',
2755 'Amount' => $amount,
2756 )
2757 );
2758 $response_data = $this->connection( $params );
2759 if ( 'OK' === $response_data['ResponseCd'] ) {
2760 if ( 1 === (int) $order_num ) {
2761 $cardlast4 = substr( $response_member['CardNo'], -4 );
2762 $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 );
2763 $expmm = substr( $response_member['CardExp'], 2, 2 );
2764 $response_data['acting'] = $this->acting_card;
2765 $response_data['CardNo'] = $cardlast4;
2766 $response_data['CardExp'] = $expyy . '/' . $expmm;
2767 $usces->set_order_meta_value( 'acting_welcart_card', usces_serialize( $response_data ), $order_id );
2768 $usces->set_order_meta_value( 'trans_id', $trans_id, $order_id );
2769 $usces->set_order_meta_value( 'wc_trans_id', $trans_id, $order_id );
2770 } else {
2771 if ( $log_data ) {
2772 $this->update_acting_log( $response_data, $order_id . '_' . $trans_id );
2773 }
2774 }
2775
2776 $class = ' card-' . mb_strtolower( substr( $operateid, 1 ) );
2777 $status_name = $this->get_operate_name( $operateid );
2778 $res .= '<div class="welcart-settlement-admin' . $class . '">' . $status_name . '</div>';
2779 $res .= '<table class="welcart-settlement-admin-table">';
2780 $res .= '<tr><th>' . __( 'Spending amount', 'usces' ) . '</th>';
2781 $res .= '<td><input type="text" id="amount_change" value="' . $amount . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $amount . '" /></td>';
2782 $res .= '</tr>';
2783 $res .= '</table>';
2784 $res .= '<div class="welcart-settlement-admin-button">';
2785 if ( '1Capture' !== $operateid && '1Gathering' !== $operateid ) {
2786 $res .= '<input id="capture-settlement" type="button" class="button" value="' . __( 'Sales recorded', 'usces' ) . '" />'; /* 売上計上 */
2787 }
2788 $res .= '<input id="delete-settlement" type="button" class="button" value="' . __( 'Unregister', 'usces' ) . '" />'; /* 取消 */
2789 $res .= '<input id="change-settlement" type="button" class="button" value="' . __( 'Change spending amount', 'usces' ) . '" />'; /* 利用額変更 */
2790 $res .= '</div>';
2791 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
2792 } else {
2793 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Error', 'usces' ) . '</div>'; /* エラー */
2794 $res .= '<div class="welcart-settlement-admin-error">';
2795 $responsecd = explode( '|', $response_data['ResponseCd'] );
2796 foreach ( (array) $responsecd as $cd ) {
2797 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
2798 }
2799 $res .= '</div>';
2800 usces_log( '[WelcartPay] ' . $operateid . ' connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
2801 }
2802 do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id );
2803 if ( ! isset( $response_data['Amount'] ) ) {
2804 $response_data['Amount'] = $amount;
2805 }
2806 $response_data = apply_filters( 'usces_filter_escott_' . mb_strtolower( substr( $operateid, 1 ) ) . '_history_log', $response_data, $order_id );
2807 $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id );
2808 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
2809 $data['status'] = $response_data['ResponseCd'];
2810 $data['acting_status'] = $acting_status;
2811 $data['result'] = $res;
2812 $data['trans_id'] = $trans_id;
2813 } else {
2814 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Error', 'usces' ) . '</div>'; /* エラー */
2815 $res .= '<div class="welcart-settlement-admin-error">';
2816 $responsecd = explode( '|', $response_member['ResponseCd'] );
2817 foreach ( (array) $responsecd as $cd ) {
2818 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
2819 }
2820 $res .= '</div>';
2821 usces_log( '[WelcartPay] 4MemRefM connection NG : ' . print_r( $response_member, true ), 'acting_transaction.log' );
2822 $data['status'] = $response_member['ResponseCd'];
2823 $data['result'] = $res;
2824 }
2825 wp_send_json( $data );
2826 break;
2827
2828 /* 再オーソリ */
2829 case 'reauth_welcartpay_card':
2830 check_admin_referer( 'order_edit', 'wc_nonce' );
2831 $res = '';
2832 $order_id = filter_input( INPUT_POST, 'order_id' );
2833 $order_num = filter_input( INPUT_POST, 'order_num' );
2834 $trans_id = filter_input( INPUT_POST, 'trans_id' );
2835 $amount = filter_input( INPUT_POST, 'amount' );
2836 if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) || is_null( $amount ) ) {
2837 $data['status'] = 'NG';
2838 wp_send_json( $data );
2839 break;
2840 }
2841 $res = '';
2842 $acting_status = '';
2843 if ( 1 === (int) $order_num ) {
2844 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) );
2845 } else {
2846 $log_data = $this->get_acting_log( $order_id, $order_id . '_' . $trans_id );
2847 $acting_data = usces_unserialize( $log_data[0]['log'] );
2848 }
2849 $operateid = $this->get_acting_operateid( $order_id . '_' . $trans_id );
2850 $acting_opts = $this->get_acting_settings();
2851 $transaction_date = $this->get_transaction_date();
2852 $param_list = array();
2853 $params = array();
2854 $param_list['MerchantId'] = $acting_opts['merchant_id'];
2855 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
2856 $param_list['TransactionDate'] = $transaction_date;
2857 $param_list['MerchantFree1'] = $trans_id;
2858 $param_list['MerchantFree2'] = 'acting_welcart_card';
2859 $param_list['MerchantFree3'] = $this->merchantfree3;
2860 $param_list['TenantId'] = $acting_opts['tenant_id'];
2861 $member_id = filter_input( INPUT_POST, 'member_id' );
2862 $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員�
2863 �会 */
2864 if ( 'OK' === $response_member['ResponseCd'] ) {
2865 $param_list['KaiinId'] = $response_member['KaiinId'];
2866 $param_list['KaiinPass'] = $response_member['KaiinPass'];
2867 }
2868 // if ( '1Gathering' === $operateid ) {
2869 $param_list['SalesDate'] = $transaction_date;
2870 // }
2871 $params['send_url'] = $acting_opts['send_url'];
2872 $params['param_list'] = array_merge(
2873 $param_list,
2874 array(
2875 'OperateId' => '1ReAuth',
2876 'ProcessId' => $acting_data['ProcessId'],
2877 'ProcessPass' => $acting_data['ProcessPass'],
2878 'Amount' => $amount,
2879 )
2880 );
2881 $response_data = $this->connection( $params );
2882 if ( 'K81' === $response_data['ResponseCd'] ) {
2883 $param_list['KaiinId'] = '';
2884 $param_list['KaiinPass'] = '';
2885 $params['param_list'] = array_merge(
2886 $param_list,
2887 array(
2888 'OperateId' => '1ReAuth',
2889 'ProcessId' => $acting_data['ProcessId'],
2890 'ProcessPass' => $acting_data['ProcessPass'],
2891 'Amount' => $amount,
2892 )
2893 );
2894 $response_data = $this->connection( $params );
2895 }
2896 if ( 'OK' === $response_data['ResponseCd'] ) {
2897 $acting_data['TransactionId'] = $response_data['TransactionId'];
2898 $acting_data['TransactionDate'] = $response_data['TransactionDate'];
2899 $acting_data['ProcessId'] = $response_data['ProcessId'];
2900 $acting_data['ProcessPass'] = $response_data['ProcessPass'];
2901 $usces->set_order_meta_value( 'acting_welcart_card', usces_serialize( $acting_data ), $order_id );
2902
2903 $class = ' card-' . mb_strtolower( substr( $operateid, 1 ) );
2904 $status_name = $this->get_operate_name( $operateid );
2905 $res .= '<div class="welcart-settlement-admin' . $class . '">' . $status_name . '</div>';
2906 $res .= '<table class="welcart-settlement-admin-table">';
2907 $res .= '<tr><th>' . __( 'Spending amount', 'usces' ) . '</th>';
2908 $res .= '<td><input type="text" id="amount_change" value="' . $amount . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $amount . '" /></td>';
2909 $res .= '</tr>';
2910 if ( isset( $response_data['SalesDate'] ) ) {
2911 $res .= '<tr><th>' . __( 'Recorded sales date', 'usces' ) . '</th><td>' . $response_data['SalesDate'] . '</td></tr>';
2912 }
2913 $res .= '</table>';
2914 $res .= '<div class="welcart-settlement-admin-button">';
2915 if ( '1Capture' !== $operateid && '1Gathering' !== $operateid ) {
2916 $res .= '<input id="capture-settlement" type="button" class="button" value="' . __( 'Sales recorded', 'usces' ) . '" />'; /* 売上計上 */
2917 }
2918 $res .= '<input id="delete-settlement" type="button" class="button" value="' . __( 'Unregister', 'usces' ) . '" />'; /* 取消 */
2919 $res .= '<input id="change-settlement" type="button" class="button" value="' . __( 'Change spending amount', 'usces' ) . '" />'; /* 利用額変更 */
2920 $res .= '</div>';
2921 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
2922 } else {
2923 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Error', 'usces' ) . '</div>'; /* エラー */
2924 $res .= '<div class="welcart-settlement-admin-error">';
2925 $responsecd = explode( '|', $response_data['ResponseCd'] );
2926 foreach ( (array) $responsecd as $cd ) {
2927 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
2928 }
2929 $res .= '</div>';
2930 usces_log( '[WelcartPay] 1ReAuth connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
2931 }
2932 do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id );
2933 if ( ! isset( $response_data['Amount'] ) ) {
2934 $response_data['Amount'] = $amount;
2935 }
2936 $response_data = apply_filters( 'usces_filter_escott_reauth_history_log', $response_data, $order_id );
2937 $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id );
2938 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
2939 $data['status'] = $response_data['ResponseCd'];
2940 $data['acting_status'] = $acting_status;
2941 $data['result'] = $res;
2942 $this->save_admin_log( $order_id, $order_id . '_' . $trans_id );
2943 wp_send_json( $data );
2944 break;
2945
2946 /* 決済エラー */
2947 case 'error_welcartpay_card':
2948 check_admin_referer( 'order_edit', 'wc_nonce' );
2949 $order_id = filter_input( INPUT_POST, 'order_id' );
2950 $order_num = filter_input( INPUT_POST, 'order_num' );
2951 $trans_id = filter_input( INPUT_POST, 'trans_id' );
2952 if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) {
2953 $data['status'] = 'NG';
2954 $data['result'] = '';
2955 wp_send_json( $data );
2956 break;
2957 }
2958 $res = '';
2959 $member_id = filter_input( INPUT_POST, 'member_id' );
2960 $response_member = $this->escott_member_reference( $member_id ); /* e-SCOTT 会員�
2961 �会 */
2962 if ( 'OK' === $response_member['ResponseCd'] ) {
2963 $order_data = $usces->get_order_data( $order_id, 'direct' );
2964 $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'];
2965
2966 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Repayment', 'usces' ) . '</div>'; /* 再決済 */
2967 $res .= '<table class="welcart-settlement-admin-table">';
2968 $res .= '<tr><th>' . __( 'Spending amount', 'usces' ) . '</th>';
2969 $res .= '<td><input type="text" id="amount_change" value="' . $total_full_price . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $total_full_price . '" /></td>';
2970 $res .= '</tr>';
2971 $res .= '</table>';
2972 $res .= '<div class="welcart-settlement-admin-button">';
2973 $res .= '<input id="auth-settlement" type="button" class="button" value="' . __( 'Credit', 'usces' ) . '" />'; /* 与信 */
2974 $res .= '<input id="gathering-settlement" type="button" class="button" value="' . __( 'Credit sales', 'usces' ) . '" />'; /* 与信売上計上 */
2975 $res .= '</div>';
2976 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
2977 } else {
2978 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Settlement error', 'usces' ) . '</div>'; /* エラー */
2979 $res .= '<div class="welcart-settlement-admin-error">';
2980 $res .= '<div><span class="message">' . __( 'Credit card information not registered', 'usces' ) . '</span></div>'; /* カード�
2981 報未登録 */
2982 $res .= '</div>';
2983 }
2984 $data['status'] = 'OK';
2985 $data['result'] = $res;
2986 wp_send_json( $data );
2987 break;
2988
2989 /* 継続課金�
2990 報更新 */
2991 case 'continuation_update':
2992 check_admin_referer( 'order_edit', 'wc_nonce' );
2993 $order_id = filter_input( INPUT_POST, 'order_id' );
2994 $member_id = filter_input( INPUT_POST, 'member_id' );
2995 $contracted_year = filter_input( INPUT_POST, 'contracted_year' );
2996 $contracted_month = filter_input( INPUT_POST, 'contracted_month' );
2997 $contracted_day = filter_input( INPUT_POST, 'contracted_day' );
2998 $charged_year = filter_input( INPUT_POST, 'charged_year' );
2999 $charged_month = filter_input( INPUT_POST, 'charged_month' );
3000 $charged_day = filter_input( INPUT_POST, 'charged_day' );
3001 $price = filter_input( INPUT_POST, 'price' );
3002 if ( is_null( $price ) ) {
3003 $price = 0;
3004 }
3005 $status = filter_input( INPUT_POST, 'status' );
3006
3007 if ( version_compare( WCEX_DLSELLER_VERSION, '3.0-beta', '<=' ) ) {
3008 $continue_data = usces_unserialize( $usces->get_member_meta_value( 'continuepay_' . $order_id, $member_id ) );
3009 } else {
3010 $continue_data = $this->get_continuation_data( $order_id, $member_id );
3011 }
3012 if ( ! $continue_data ) {
3013 $data['status'] = 'NG';
3014 wp_send_json( $data );
3015 break;
3016 }
3017
3018 /* 継続中→停止 */
3019 if ( 'continuation' === $continue_data['status'] && 'cancellation' === $status ) {
3020 if ( version_compare( WCEX_DLSELLER_VERSION, '3.0-beta', '<=' ) ) {
3021 $continue_data['status'] = 'cancellation';
3022 $usces->set_member_meta_value( 'continuepay_' . $order_id, usces_serialize( $continue_data ), $member_id );
3023 } else {
3024 $this->update_continuation_data( $order_id, $member_id, $continue_data, true );
3025 }
3026 } else {
3027 if ( ! empty( $contracted_year ) && ! empty( $contracted_month ) && ! empty( $contracted_day ) ) {
3028 $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
3029 if ( $contracted_date ) {
3030 $new_contracted_date = $contracted_year . '-' . $contracted_month . '-' . $contracted_day;
3031 if ( ! $this->isdate( $new_contracted_date ) ) {
3032 $data['status'] = 'NG';
3033 $data['message'] = __( 'Next contract renewal date is incorrect.', 'dlseller' );
3034 wp_send_json( $data );
3035 }
3036 }
3037 } else {
3038 $new_contracted_date = '';
3039 }
3040 $new_charged_date = $charged_year . '-' . $charged_month . '-' . $charged_day;
3041 if ( ! $this->isdate( $new_charged_date ) ) {
3042 $data['status'] = 'NG';
3043 $data['message'] = __( 'Next settlement date is incorrect.', 'dlseller' );
3044 wp_send_json( $data );
3045 }
3046 $tomorrow = date_i18n( 'Y-m-d', strtotime( '+1 day' ) );
3047 if ( $new_charged_date < $tomorrow ) {
3048 $data['status'] = 'NG';
3049 $data['message'] = sprintf( __( 'The next settlement date must be after %s.', 'dlseller' ), $tomorrow );
3050 wp_send_json( $data );
3051 }
3052 $continue_data['contractedday'] = $new_contracted_date;
3053 $continue_data['chargedday'] = $new_charged_date;
3054 $continue_data['price'] = usces_crform( $price, false, false, 'return', false );
3055 $continue_data['status'] = $status;
3056 if ( version_compare( WCEX_DLSELLER_VERSION, '3.0-beta', '<=' ) ) {
3057 $usces->set_member_meta_value( 'continuepay_' . $order_id, usces_serialize( $continue_data ), $member_id );
3058 } else {
3059 $this->update_continuation_data( $order_id, $member_id, $continue_data );
3060 }
3061 }
3062 $data['status'] = 'OK';
3063 wp_send_json( $data );
3064 break;
3065
3066 /* オンライン収納代行データ登録 */
3067 case 'add_welcartpay_conv':
3068 check_admin_referer( 'order_edit', 'wc_nonce' );
3069 $order_id = filter_input( INPUT_POST, 'order_id' );
3070 $trans_id = filter_input( INPUT_POST, 'trans_id' );
3071 $paylimit = filter_input( INPUT_POST, 'paylimit' );
3072 $amount = filter_input( INPUT_POST, 'amount' );
3073 if ( is_null( $order_id ) || is_null( $trans_id ) || is_null( $paylimit ) || is_null( $amount ) ) {
3074 $data['status'] = 'NG';
3075 wp_send_json( $data );
3076 break;
3077 }
3078 $res = '';
3079 $acting_status = '';
3080 $order_data = $usces->get_order_data( $order_id, 'direct' );
3081 $namekanji = $order_data['order_name1'] . $order_data['order_name2'];
3082 $namekana = ( ! empty( $order_data['order_name3'] ) ) ? $order_data['order_name3'] . $order_data['order_name4'] : $namekanji;
3083 $telno = $order_data['order_tel'];
3084 $acting_opts = $this->get_acting_settings();
3085 $transaction_date = $this->get_transaction_date();
3086 $param_list = array();
3087 $params = array();
3088 $param_list['MerchantId'] = $acting_opts['merchant_id'];
3089 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
3090 $param_list['TransactionDate'] = $transaction_date;
3091 $param_list['MerchantFree1'] = $trans_id;
3092 $param_list['MerchantFree2'] = 'acting_welcart_conv';
3093 $param_list['MerchantFree3'] = $this->merchantfree3;
3094 $param_list['TenantId'] = $acting_opts['tenant_id'];
3095 $params['send_url'] = $acting_opts['send_url_conv'];
3096 $params['param_list'] = array_merge(
3097 $param_list,
3098 array(
3099 'OperateId' => '2Add',
3100 'PayLimit' => $paylimit . '2359',
3101 'Amount' => $amount,
3102 'NameKanji' => $namekanji,
3103 'NameKana' => $namekana,
3104 'TelNo' => $telno,
3105 'ReturnURL' => home_url( '/' ),
3106 )
3107 );
3108 $response_data = $this->connection( $params );
3109 if ( 'OK' === $response_data['ResponseCd'] ) {
3110 $response_data['acting'] = $this->acting_conv;
3111 $response_data['PayLimit'] = $params['param_list']['PayLimit'];
3112 $response_data['Amount'] = $params['param_list']['Amount'];
3113 $usces->set_order_meta_value( 'acting_welcart_conv', usces_serialize( $response_data ), $order_id );
3114 $freearea = trim( $response_data['FreeArea'] );
3115 $url = add_query_arg(
3116 array(
3117 'code' => $freearea,
3118 'rkbn' => 2,
3119 ),
3120 $acting_opts['redirect_url_conv']
3121 );
3122 $usces->set_order_meta_value( 'welcart_conv_url', $url, $order_id );
3123
3124 $res .= '<div class="welcart-settlement-admin conv-noreceipt">' . __( 'Unpaid', 'usces' ) . '</div>'; /* 未�
3125 �金 */
3126 $res .= '<table class="welcart-settlement-admin-table">';
3127 $res .= '<tr><th>' . __( 'Payment due', 'usces' ) . '</th>';
3128 $res .= '<td><input type="text" id="paylimit_change" value="' . $paylimit . '" style="ime-mode:disabled" size="10" /><input type="hidden" id="paylimit" value="' . $paylimit . '" /></td>';
3129 $res .= '</tr>';
3130 $res .= '<tr><th>' . __( 'Payment amount', 'usces' ) . '</th>';
3131 $res .= '<td><input type="text" id="amount_change" value="' . $amount . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $amount . '" /></td>';
3132 $res .= '</tr>';
3133 $res .= '</table>';
3134 $res .= '<div class="welcart-settlement-admin-button">';
3135 $res .= '<input id="delete-settlement" type="button" class="button" value="' . __( 'Unregister', 'usces' ) . '" />'; /* 取消 */
3136 $res .= '<input id="change-settlement" type="button" class="button" value="' . __( 'Change' ) . '" />'; /* 変更 */
3137 $res .= '</div>';
3138 $acting_status = '<span class="acting-status conv-noreceipt">' . __( 'Unpaid', 'usces' ) . '</span>';
3139 } else {
3140 $res .= '<div class="welcart-settlement-admin conv-error">' . __( 'Error', 'usces' ) . '</div>'; /* エラー */
3141 $res .= '<div class="welcart-settlement-admin-error">';
3142 $responsecd = explode( '|', $response_data['ResponseCd'] );
3143 foreach ( (array) $responsecd as $cd ) {
3144 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
3145 }
3146 $res .= '</div>';
3147 usces_log( '[WelcartPay] 2Add connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
3148 }
3149 do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id );
3150 if ( ! isset( $response_data['Amount'] ) ) {
3151 $response_data['Amount'] = $amount;
3152 }
3153 $response_data = apply_filters( 'usces_filter_escott_add_conv_history_log', $response_data, $order_id );
3154 $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id );
3155 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
3156 $data['status'] = $response_data['ResponseCd'];
3157 $data['acting_status'] = $acting_status;
3158 $data['result'] = $res;
3159 wp_send_json( $data );
3160 break;
3161
3162 /* オンライン収納代行データ変更 */
3163 case 'change_welcartpay_conv':
3164 check_admin_referer( 'order_edit', 'wc_nonce' );
3165 $order_id = filter_input( INPUT_POST, 'order_id' );
3166 $trans_id = filter_input( INPUT_POST, 'trans_id' );
3167 $paylimit = filter_input( INPUT_POST, 'paylimit' );
3168 $amount = filter_input( INPUT_POST, 'amount' );
3169 if ( is_null( $order_id ) || is_null( $trans_id ) || is_null( $paylimit ) || is_null( $amount ) ) {
3170 $data['status'] = 'NG';
3171 wp_send_json( $data );
3172 break;
3173 }
3174 $res = '';
3175 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_conv', $order_id ) );
3176 $acting_opts = $this->get_acting_settings();
3177 $transaction_date = $this->get_transaction_date();
3178 $param_list = array();
3179 $params = array();
3180 $param_list['MerchantId'] = $acting_opts['merchant_id'];
3181 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
3182 $param_list['TransactionDate'] = $transaction_date;
3183 $param_list['MerchantFree1'] = $trans_id;
3184 $param_list['MerchantFree2'] = 'acting_welcart_conv';
3185 $param_list['MerchantFree3'] = $this->merchantfree3;
3186 $param_list['TenantId'] = $acting_opts['tenant_id'];
3187 $params['send_url'] = $acting_opts['send_url_conv'];
3188 $params['param_list'] = array_merge(
3189 $param_list,
3190 array(
3191 'OperateId' => '2Chg',
3192 'ProcessId' => $acting_data['ProcessId'],
3193 'ProcessPass' => $acting_data['ProcessPass'],
3194 'PayLimit' => $paylimit . '2359',
3195 'Amount' => $amount,
3196 )
3197 );
3198 $response_data = $this->connection( $params );
3199 if ( 'OK' === $response_data['ResponseCd'] ) {
3200 $acting_data['PayLimit'] = $params['param_list']['PayLimit'];
3201 $acting_data['Amount'] = $params['param_list']['Amount'];
3202 $usces->set_order_meta_value( 'acting_welcart_conv', usces_serialize( $acting_data ), $order_id );
3203 $freearea = trim( $response_data['FreeArea'] );
3204 $url = add_query_arg(
3205 array(
3206 'code' => $freearea,
3207 'rkbn' => 2,
3208 ),
3209 $acting_opts['redirect_url_conv']
3210 );
3211 $usces->set_order_meta_value( 'welcart_conv_url', $url, $order_id );
3212
3213 $res .= '<div class="welcart-settlement-admin conv-noreceipt">' . __( 'Unpaid', 'usces' ) . '</div>'; /* 未�
3214 �金 */
3215 $res .= '<table class="welcart-settlement-admin-table">';
3216 if ( isset( $acting_data['PayLimit'] ) ) {
3217 $res .= '<tr><th>' . __( 'Payment due', 'usces' ) . '</th><td>' . $acting_data['PayLimit'] . '</td></tr>';
3218 }
3219 if ( isset( $acting_data['Amount'] ) ) {
3220 $res .= '<tr><th>' . __( 'Payment amount', 'usces' ) . '</th><td>' . $acting_data['Amount'] . '</td></tr>';
3221 }
3222 $res .= '</table>';
3223 $res .= '<div class="welcart-settlement-admin-button">';
3224 $res .= '<input id="delete-settlement" type="button" class="button" value="' . __( 'Unregister', 'usces' ) . '" />'; /* 取消 */
3225 $res .= '</div>';
3226 } else {
3227 $res .= '<div class="welcart-settlement-admin conv-error">' . __( 'Error', 'usces' ) . '</div>'; /* エラー */
3228 $res .= '<div class="welcart-settlement-admin-error">';
3229 $responsecd = explode( '|', $response_data['ResponseCd'] );
3230 foreach ( (array) $responsecd as $cd ) {
3231 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
3232 }
3233 $res .= '</div>';
3234 usces_log( '[WelcartPay] 2Chg connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
3235 }
3236 do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id );
3237 if ( ! isset( $response_data['Amount'] ) ) {
3238 $response_data['Amount'] = $amount;
3239 }
3240 $response_data = apply_filters( 'usces_filter_escott_change_conv_history_log', $response_data, $order_id );
3241 $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id );
3242 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
3243 $data['status'] = $response_data['ResponseCd'];
3244 $data['result'] = $res;
3245 wp_send_json( $data );
3246 break;
3247
3248 /* オンライン収納代行データ削除 */
3249 case 'delete_welcartpay_conv':
3250 check_admin_referer( 'order_edit', 'wc_nonce' );
3251 $order_id = filter_input( INPUT_POST, 'order_id' );
3252 $trans_id = filter_input( INPUT_POST, 'trans_id' );
3253 $amount = filter_input( INPUT_POST, 'amount' );
3254 if ( is_null( $order_id ) || is_null( $trans_id ) ) {
3255 $data['status'] = 'NG';
3256 wp_send_json( $data );
3257 break;
3258 }
3259 $res = '';
3260 $acting_status = '';
3261 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_conv', $order_id ) );
3262 $acting_opts = $this->get_acting_settings();
3263 $transaction_date = $this->get_transaction_date();
3264 $param_list = array();
3265 $params = array();
3266 $param_list['MerchantId'] = $acting_opts['merchant_id'];
3267 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
3268 $param_list['TransactionDate'] = $transaction_date;
3269 $param_list['MerchantFree1'] = $trans_id;
3270 $param_list['MerchantFree2'] = 'acting_welcart_conv';
3271 $param_list['MerchantFree3'] = $this->merchantfree3;
3272 $param_list['TenantId'] = $acting_opts['tenant_id'];
3273 $params['send_url'] = $acting_opts['send_url_conv'];
3274 $params['param_list'] = array_merge(
3275 $param_list,
3276 array(
3277 'OperateId' => '2Del',
3278 'ProcessId' => $acting_data['ProcessId'],
3279 'ProcessPass' => $acting_data['ProcessPass'],
3280 )
3281 );
3282 $response_data = $this->connection( $params );
3283 if ( 'OK' === $response_data['ResponseCd'] ) {
3284 $res .= '<div class="welcart-settlement-admin conv-del">' . __( 'Canceled', 'usces' ) . '</div>'; /* 取消済み */
3285 $res .= '<table class="welcart-settlement-admin-table">';
3286 if ( isset( $acting_data['PayLimit'] ) ) {
3287 $paylimit = substr( $acting_data['PayLimit'], 0, 8 );
3288 $res .= '<tr><th>' . __( 'Payment due', 'usces' ) . '</th><td>' . $paylimit . '</td></tr>';
3289 }
3290 if ( isset( $acting_data['Amount'] ) ) {
3291 $res .= '<tr><th>' . __( 'Payment amount', 'usces' ) . '</th><td>' . $acting_data['Amount'] . '</td></tr>';
3292 }
3293 $res .= '</table>';
3294 $acting_status = '<span class="acting-status conv-del">' . __( 'Canceled', 'usces' ) . '</span>';
3295 } else {
3296 $res .= '<div class="welcart-settlement-admin conv-error">' . __( 'Error', 'usces' ) . '</div>'; /* エラー */
3297 $res .= '<div class="welcart-settlement-admin-error">';
3298 $responsecd = explode( '|', $response_data['ResponseCd'] );
3299 foreach ( (array) $responsecd as $cd ) {
3300 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
3301 }
3302 $res .= '</div>';
3303 usces_log( '[WelcartPay] 2Del connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
3304 }
3305 do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id );
3306 if ( ! isset( $response_data['Amount'] ) ) {
3307 $response_data['Amount'] = ( isset( $acting_data['Amount'] ) ) ? $acting_data['Amount'] : $amount;
3308 }
3309 $response_data = apply_filters( 'usces_filter_escott_delete_conv_history_log', $response_data, $order_id );
3310 $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id );
3311 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
3312 $data['status'] = $response_data['ResponseCd'];
3313 $data['acting_status'] = $acting_status;
3314 $data['result'] = $res;
3315 wp_send_json( $data );
3316 break;
3317
3318 /* オンライン収納代行データ�
3319 �金結果参�
3320 � */
3321 case 'get_welcartpay_conv':
3322 check_admin_referer( 'order_edit', 'wc_nonce' );
3323 $order_id = filter_input( INPUT_POST, 'order_id' );
3324 $trans_id = filter_input( INPUT_POST, 'trans_id' );
3325 if ( is_null( $order_id ) || is_null( $trans_id ) ) {
3326 $data['status'] = 'NG';
3327 wp_send_json( $data );
3328 break;
3329 }
3330 $res = '';
3331 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_conv', $order_id ) );
3332 $acting_opts = $this->get_acting_settings();
3333 $transaction_date = $this->get_transaction_date();
3334 $param_list = array();
3335 $params = array();
3336 $param_list['MerchantId'] = $acting_opts['merchant_id'];
3337 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
3338 $param_list['TransactionDate'] = $transaction_date;
3339 $param_list['MerchantFree1'] = $trans_id;
3340 $param_list['MerchantFree2'] = 'acting_welcart_conv';
3341 $param_list['MerchantFree3'] = $this->merchantfree3;
3342 $param_list['TenantId'] = $acting_opts['tenant_id'];
3343 $params['send_url'] = $acting_opts['send_url_conv'];
3344 $params['param_list'] = array_merge(
3345 $param_list,
3346 array(
3347 'OperateId' => '2Ref',
3348 'ProcessId' => $acting_data['ProcessId'],
3349 'ProcessPass' => $acting_data['ProcessPass'],
3350 )
3351 );
3352 $response_data = $this->connection( $params );
3353 if ( 'OK' === $response_data['ResponseCd'] ) {
3354 if ( isset( $response_data['NyukinDate'] ) ) {
3355 $res .= '<div class="welcart-settlement-admin conv-receipted">' . __( 'Paid', 'usces' ) . '</div>'; /* �
3356 �金済 */
3357 $res .= '<table class="welcart-settlement-admin-table">';
3358 if ( isset( $response_data['RecvNum'] ) ) {
3359 $res .= '<tr><th>' . __( 'Receipt number', 'usces' ) . '</th><td>' . $response_data['RecvNum'] . '</td></tr>'; /* 受付番号 */
3360 }
3361 if ( isset( $response_data['NyukinDate'] ) ) {
3362 $res .= '<tr><th>' . __( 'Deposit date', 'usces' ) . '</th><td>' . $response_data['NyukinDate'] . '</td></tr>'; /* �
3363 �金日時 */
3364 }
3365 if ( isset( $response_data['CvsCd'] ) ) {
3366 $cvs_name = $this->get_cvs_name( $response_data['CvsCd'] );
3367 $res .= '<tr><th>' . __( 'Convenience store code', 'usces' ) . '</th><td>' . $cvs_name . '</td></tr>'; /* 収納機関コード */
3368 }
3369 if ( isset( $response_data['TenantCd'] ) ) {
3370 $res .= '<tr><th>' . __( 'Tenant code', 'usces' ) . '</th><td>' . $response_data['TenantCd'] . '</td></tr>'; /* 店舗コード */
3371 }
3372 if ( isset( $response_data['Amount'] ) ) {
3373 $res .= '<tr><th>' . __( 'Payment amount', 'usces' ) . '</th><td>' . $response_data['Amount'] . __( usces_crcode( 'return' ), 'usces' ) . '</td></tr>';
3374 }
3375 $res .= '</table>';
3376 } else {
3377 $paylimit = substr( $acting_data['PayLimit'], 0, 8 );
3378 $expiration = $this->check_paylimit( $order_id, $trans_id );
3379 $res .= '<div class="welcart-settlement-admin conv-noreceipt">' . __( 'Unpaid', 'usces' ); /* 未�
3380 �金 */
3381 if ( $expiration ) {
3382 $res .= __( '(Expired)', 'usces' ); /* (期限切れ) */
3383 }
3384 $res .= '</div>';
3385 $res .= '<table class="welcart-settlement-admin-table">';
3386 $res .= '<tr><th>' . __( 'Payment due', 'usces' ) . '</th>';
3387 $res .= '<td><input type="text" id="paylimit_change" value="' . $paylimit . '" style="ime-mode:disabled" size="10" /><input type="hidden" id="paylimit" value="' . $paylimit . '" /></td>';
3388 $res .= '</tr>';
3389 $res .= '<tr><th>' . __( 'Payment amount', 'usces' ) . '</th>';
3390 $res .= '<td><input type="text" id="amount_change" value="' . $acting_data['Amount'] . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $acting_data['Amount'] . '" /></td>';
3391 $res .= '</tr>';
3392 $res .= '</table>';
3393 $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id );
3394 if ( isset( $latest_log['OperateId'] ) ) {
3395 $res .= '<div class="welcart-settlement-admin-button">';
3396 if ( '2Del' !== $latest_log['OperateId'] ) {
3397 $res .= '<input id="delete-settlement" type="button" class="button" value="' . __( 'Unregister', 'usces' ) . '" />'; /* 取消 */
3398 }
3399 if ( '2Chg' !== $latest_log['OperateId'] ) {
3400 $res .= '<input id="change-settlement" type="button" class="button" value="' . __( 'Change' ) . '" />'; /* 変更 */
3401 }
3402 $res .= '</div>';
3403 }
3404 }
3405 } else {
3406 $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id );
3407 if ( isset( $latest_log['OperateId'] ) && '2Del' === $latest_log['OperateId'] && 'K12' === $response_data['ResponseCd'] ) {
3408 $paylimit = substr( $acting_data['PayLimit'], 0, 8 );
3409 $res .= '<div class="welcart-settlement-admin conv-del">' . __( 'Canceled', 'usces' ) . '</div>'; /* 取消済み */
3410 $res .= '<table class="welcart-settlement-admin-table">';
3411 $res .= '<tr><th>' . __( 'Payment due', 'usces' ) . '</th>';
3412 $res .= '<td><input type="text" id="paylimit_change" value="' . $paylimit . '" style="ime-mode:disabled" size="10" /><input type="hidden" id="paylimit" value="' . $paylimit . '" /></td>';
3413 $res .= '</tr>';
3414 $res .= '<tr><th>' . __( 'Payment amount', 'usces' ) . '</th>';
3415 $res .= '<td><input type="text" id="amount_change" value="' . $acting_data['Amount'] . '" style="text-align:right;ime-mode:disabled" size="10" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount" value="' . $acting_data['Amount'] . '" /></td>';
3416 $res .= '</tr>';
3417 $res .= '</table>';
3418 $res .= '<div class="welcart-settlement-admin-button">';
3419 $res .= '<input id="add-settlement" type="button" class="button" value="' . __( 'Register' ) . '" />'; /* 登録 */
3420 $res .= '</div>';
3421 } else {
3422 $res .= '<div class="welcart-settlement-admin conv-error">' . __( 'Error', 'usces' ) . '</div>'; /* エラー */
3423 $res .= '<div class="welcart-settlement-admin-error">';
3424 $responsecd = explode( '|', $response_data['ResponseCd'] );
3425 foreach ( (array) $responsecd as $cd ) {
3426 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
3427 }
3428 $res .= '</div>';
3429 usces_log( '[WelcartPay] 2Ref connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
3430 }
3431 }
3432 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
3433 $data['status'] = $response_data['ResponseCd'];
3434 $data['result'] = $res;
3435 wp_send_json( $data );
3436 break;
3437
3438 /* 銀聯取引参�
3439 � */
3440 case 'get_welcartpay_unionpay':
3441 check_admin_referer( 'order_edit', 'wc_nonce' );
3442 $order_id = filter_input( INPUT_POST, 'order_id' );
3443 $order_num = filter_input( INPUT_POST, 'order_num' );
3444 $trans_id = filter_input( INPUT_POST, 'trans_id' );
3445 if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) {
3446 $data['status'] = 'NG';
3447 wp_send_json( $data );
3448 break;
3449 }
3450 $res = '';
3451 $log_data = array();
3452 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_unionpay', $order_id ) );
3453 $acting_opts = $this->get_acting_settings();
3454 $transaction_date = $this->get_transaction_date();
3455 $param_list = array();
3456 $params = array();
3457 $param_list['MerchantId'] = $acting_opts['merchant_id'];
3458 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
3459 $param_list['TransactionDate'] = $transaction_date;
3460 $param_list['MerchantFree1'] = $trans_id;
3461 $param_list['MerchantFree2'] = 'acting_welcart_unionpay';
3462 $param_list['MerchantFree3'] = $this->merchantfree3;
3463 $param_list['TenantId'] = $acting_opts['tenant_id'];
3464 $params['send_url'] = $acting_opts['send_url_unionpay'];
3465 $params['param_list'] = array_merge(
3466 $param_list,
3467 array(
3468 'OperateId' => '11Search',
3469 'ProcessId' => $acting_data['ProcessId'],
3470 'ProcessPass' => $acting_data['ProcessPass'],
3471 )
3472 );
3473 $response_data = $this->connection( $params );
3474 if ( 'OK' === $response_data['ResponseCd'] ) {
3475 $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id );
3476 if ( isset( $latest_log['OperateId'] ) ) {
3477 $class = ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 2 ) );
3478 $status_name = $this->get_operate_name( $latest_log['OperateId'] );
3479 $res .= '<div class="welcart-settlement-admin' . $class . '">' . $status_name . '</div>';
3480 $res .= '<table class="welcart-settlement-admin-table">';
3481 if ( isset( $latest_log['Amount'] ) ) {
3482 $res .= '<tr><th>' . __( 'Spending amount', 'usces' ) . '</th><td>' . usces_crform( $latest_log['Amount'], false, true, 'return', true ) . '</td></tr>';
3483 }
3484 if ( isset( $latest_log['Status'] ) ) {
3485 $res .= '<tr><th>' . __( 'Transaction status', 'usces' ) . '</th><td>' . $this->get_unionpay_status_name( $latest_log['Status'] ) . '</td></tr>';
3486 }
3487 $res .= '</table>';
3488 $res .= '<div class="welcart-settlement-admin-button">';
3489 if ( '11Delete' !== $latest_log['OperateId'] ) {
3490 $res .= '<input id="delete-settlement" type="button" class="button" value="' . __( 'Unregister', 'usces' ) . '" />'; /* 取消 */
3491 }
3492 $res .= '</div>';
3493 }
3494 } else {
3495 if ( 'K12' === $response_data['ResponseCd'] ) {
3496 $res .= '<div class="welcart-settlement-admin card-delete">' . __( 'Expired', 'usces' ) . '</div>';
3497 $res .= '<div class="welcart-settlement-admin-expired">';
3498 $res .= '<div><span class="code">K12</span> : <span class="message">' . __( 'Handling expired.', 'usces' ) . '</span></div>';
3499 $res .= '</div>';
3500 } else {
3501 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Error', 'usces' ) . '</div>';
3502 $res .= '<div class="welcart-settlement-admin-error">';
3503 $responsecd = explode( '|', $response_data['ResponseCd'] );
3504 foreach ( $responsecd as $cd ) {
3505 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
3506 }
3507 $res .= '</div>';
3508 usces_log( '[WelcartPay] 11Search connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
3509 }
3510 }
3511 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
3512 $data['status'] = $response_data['ResponseCd'];
3513 $data['result'] = $res;
3514 wp_send_json( $data );
3515 break;
3516
3517 /* 銀聯取消 */
3518 case 'delete_welcartpay_unionpay':
3519 check_admin_referer( 'order_edit', 'wc_nonce' );
3520 $order_id = filter_input( INPUT_POST, 'order_id' );
3521 $order_num = filter_input( INPUT_POST, 'order_num' );
3522 $trans_id = filter_input( INPUT_POST, 'trans_id' );
3523 $amount = filter_input( INPUT_POST, 'amount' );
3524 if ( is_null( $order_id ) || is_null( $order_num ) || is_null( $trans_id ) ) {
3525 $data['status'] = 'NG';
3526 wp_send_json( $data );
3527 break;
3528 }
3529 $res = '';
3530 $acting_status = '';
3531 $log_data = array();
3532 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_unionpay', $order_id ) );
3533 $acting_opts = $this->get_acting_settings();
3534 $transaction_date = $this->get_transaction_date();
3535 $param_list = array();
3536 $params = array();
3537 $param_list['MerchantId'] = $acting_opts['merchant_id'];
3538 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
3539 $param_list['TransactionDate'] = $transaction_date;
3540 $param_list['MerchantFree1'] = $trans_id;
3541 $param_list['MerchantFree2'] = 'acting_welcart_unionpay';
3542 $param_list['MerchantFree3'] = $this->merchantfree3;
3543 $param_list['TenantId'] = $acting_opts['tenant_id'];
3544 $params['send_url'] = $acting_opts['send_url_unionpay'];
3545 $params['param_list'] = array_merge(
3546 $param_list,
3547 array(
3548 'OperateId' => '11Delete',
3549 'ProcessId' => $acting_data['ProcessId'],
3550 'ProcessPass' => $acting_data['ProcessPass'],
3551 )
3552 );
3553 $response_data = $this->connection( $params );
3554 if ( 'OK' === $response_data['ResponseCd'] ) {
3555 $class = ' card-' . mb_strtolower( substr( $response_data['OperateId'], 2 ) );
3556 $status_name = $this->get_operate_name( $response_data['OperateId'] );
3557 $res .= '<div class="welcart-settlement-admin' . $class . '">' . $status_name . '</div>';
3558 $res .= '<table class="welcart-settlement-admin-table">';
3559 $res .= '<tr><th>' . __( 'Spending amount', 'usces' ) . '</th><td>' . usces_crform( $amount, false, true, 'return', true ) . '</td></tr>';
3560 $res .= '</table>';
3561 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
3562 } else {
3563 $res .= '<div class="welcart-settlement-admin card-error">' . __( 'Error', 'usces' ) . '</div>';
3564 $res .= '<div class="welcart-settlement-admin-error">';
3565 $responsecd = explode( '|', $response_data['ResponseCd'] );
3566 foreach ( (array) $responsecd as $cd ) {
3567 $res .= '<div><span class="code">' . $cd . '</span> : <span class="message">' . $this->response_message( $cd ) . '</span></div>';
3568 }
3569 $res .= '</div>';
3570 usces_log( '[WelcartPay] 11Delete connection NG : ' . print_r( $response_data, true ), 'acting_transaction.log' );
3571 }
3572 do_action( 'usces_action_admin_' . $mode, $response_data, $order_id, $trans_id );
3573 if ( ! isset( $response_data['Amount'] ) ) {
3574 $response_data['Amount'] = $amount;
3575 }
3576 $response_data = apply_filters( 'usces_filter_escott_delete_unionpay_history_log', $response_data, $order_id );
3577 $this->save_acting_history_log( $response_data, $order_id . '_' . $trans_id );
3578 $res .= $this->settlement_history( $order_id . '_' . $trans_id );
3579 $data['status'] = $response_data['ResponseCd'];
3580 $data['acting_status'] = $acting_status;
3581 $data['result'] = $res;
3582 wp_send_json( $data );
3583 break;
3584 }
3585 }
3586
3587 /**
3588 * 決済状況
3589 * usces_filter_orderlist_detail_value
3590 *
3591 * @param string $detail HTML.
3592 * @param string $value Settlement info key.
3593 * @param string $key Settlement info value.
3594 * @param int $order_id Order number.
3595 * @return array
3596 */
3597 public function orderlist_settlement_status( $detail, $value, $key, $order_id ) {
3598 global $usces;
3599
3600 if ( 'wc_trans_id' !== $key || empty( $value ) ) {
3601 return $detail;
3602 }
3603
3604 $order_data = $usces->get_order_data( $order_id, 'direct' );
3605 $payment = usces_get_payments_by_name( $order_data['order_payment_name'] );
3606 $acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
3607
3608 if ( 'acting_welcart_card' === $acting_flg ) {
3609 $trans_id = $usces->get_order_meta_value( 'trans_id', $order_id );
3610 $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id );
3611 if ( isset( $latest_log['OperateId'] ) ) {
3612 $class = ( ctype_digit( substr( $latest_log['OperateId'], 0, 1 ) ) ) ? ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 1 ) ) : ' card-' . $latest_log['OperateId'];
3613 $detail = '<td>' . $value . '<span class="acting-status' . $class . '">' . $this->get_operate_name( $latest_log['OperateId'] ) . '</span></td>';
3614 } elseif ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
3615 $regular_id = $usces->get_order_meta_value( 'regular_id', $order_id );
3616 if ( ! empty( $regular_id ) && empty( $trans_id ) ) {
3617 $detail = '<td>' . $value . '<span class="acting-status card-error">' . __( 'Card unregistered', 'usces' ) . '</span></td>';
3618 }
3619 }
3620 } elseif ( 'acting_welcart_conv' === $acting_flg ) {
3621 $trans_id = $usces->get_order_meta_value( 'trans_id', $order_id );
3622 $expiration = $this->check_paylimit( $order_id, $trans_id );
3623 if ( $expiration ) {
3624 if ( ! $usces->is_status( 'receipted', $order_data['order_status'] ) ) {
3625 $detail = '<td>' . $value . '<span class="acting-status conv-expiration">' . __( 'Expired', 'usces' ) . '</span></td>';
3626 }
3627 } else {
3628 $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id );
3629 if ( isset( $latest_log['OperateId'] ) && '2Del' === $latest_log['OperateId'] ) {
3630 $detail = '<td>' . $value . '<span class="acting-status conv-del">' . __( 'Canceled', 'usces' ) . '</span></td>';
3631 } else {
3632 $management_status = apply_filters( 'usces_filter_management_status', get_option( 'usces_management_status' ) );
3633 if ( $usces->is_status( 'noreceipt', $value ) ) {
3634 $detail = '<td>' . $value . '<span class="acting-status conv-noreceipt">' . esc_html( $management_status['noreceipt'] ) . '</span></td>';
3635 } elseif ( $usces->is_status( 'receipted', $value ) ) {
3636 $detail = '<td>' . $value . '<span class="acting-status conv-receipted">' . esc_html( $management_status['receipted'] ) . '</span></td>';
3637 } else {
3638 $detail = '<td>' . $value . '</td>';
3639 }
3640 }
3641 }
3642 } elseif ( 'acting_welcart_unionpay' === $acting_flg ) {
3643 $trans_id = $usces->get_order_meta_value( 'trans_id', $order_id );
3644 $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id );
3645 if ( isset( $latest_log['OperateId'] ) ) {
3646 $class = ( ctype_digit( substr( $latest_log['OperateId'], 0, 2 ) ) ) ? ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 2 ) ) : ' card-' . $latest_log['OperateId'];
3647 $detail = '<td>' . $value . '<span class="acting-status' . $class . '">' . $this->get_operate_name( $latest_log['OperateId'] ) . '</span></td>';
3648 }
3649 }
3650 return $detail;
3651 }
3652
3653 /**
3654 * 受注編集画面に表示する決済�
3655 報の値整形
3656 * usces_filter_settle_info_field_value
3657 *
3658 * @param string $value Settlement information value.
3659 * @param string $key Settlement information key.
3660 * @param string $acting Acting type.
3661 * @return string
3662 */
3663 public function settlement_info_field_value( $value, $key, $acting ) {
3664 if ( 'welcart_card' !== $acting && 'welcart_conv' !== $acting && 'welcart_atodene' !== $acting && 'welcart_applepay' !== $acting && 'welcart_unionpay' !== $acting ) {
3665 return $value;
3666 }
3667
3668 switch ( $key ) {
3669 case 'acting':
3670 switch ( $value ) {
3671 case 'welcart_card':
3672 $value = __( 'WelcartPay - Credit card transaction', 'usces' );
3673 break;
3674 case 'welcart_conv':
3675 $value = __( 'WelcartPay - Online storage agency', 'usces' );
3676 break;
3677 case 'welcart_atodene':
3678 $value = __( 'WelcartPay - Postpay settlement', 'usces' );
3679 break;
3680 case 'welcart_applepay':
3681 $value = __( 'WelcartPay - Apple Pay', 'usces' );
3682 break;
3683 case 'welcart_unionpay':
3684 $value = __( 'WelcartPay - UnionPay', 'usces' );
3685 break;
3686 }
3687 break;
3688 }
3689
3690 $value = parent::settlement_info_field_value( $value, $key, $acting );
3691
3692 return $value;
3693 }
3694
3695 /**
3696 * 受注編集画面【ステータス】
3697 * usces_action_order_edit_form_status_block_middle
3698 *
3699 * @param array $data Order data.
3700 * @param array $cscs_meta Custom field data.
3701 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3702 */
3703 public function settlement_status( $data, $cscs_meta, $action_args ) {
3704 global $usces;
3705 extract( $action_args ); // phpcs:ignore
3706
3707 if ( 'new' !== $order_action && ! empty( $order_id ) ) {
3708 $payment = usces_get_payments_by_name( $data['order_payment_name'] );
3709 if ( in_array( $payment['settlement'], $this->pay_method ) ) {
3710 $acting_data = usces_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
3711 $merchantfree1 = ( isset( $acting_data['MerchantFree1'] ) ) ? $acting_data['MerchantFree1'] : '';
3712 if ( ! empty( $merchantfree1 ) ) {
3713 $status_name = '';
3714 $class = '';
3715 $latest_log = $this->get_acting_latest_log( $order_id . '_' . $merchantfree1 );
3716 if ( isset( $latest_log['OperateId'] ) ) {
3717 switch ( $payment['settlement'] ) {
3718 case 'acting_welcart_conv':
3719 $expiration = $this->check_paylimit( $order_id, $merchantfree1 );
3720 if ( $expiration ) {
3721 if ( ! $usces->is_status( 'receipted', $data['order_status'] ) ) {
3722 $class = ' conv-expiration';
3723 $status_name = __( 'Expired', 'usces' );
3724 }
3725 } else {
3726 if ( '2Del' === $latest_log['OperateId'] ) {
3727 $class = ' conv-del';
3728 $status_name = __( 'Canceled', 'usces' );
3729 }
3730 }
3731 break;
3732 case 'acting_welcart_card':
3733 $class = ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 1 ) );
3734 $status_name = $this->get_operate_name( $latest_log['OperateId'] );
3735 break;
3736 case 'acting_welcart_unionpay':
3737 $class = ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 2 ) );
3738 $status_name = $this->get_operate_name( $latest_log['OperateId'] );
3739 break;
3740 }
3741 if ( ! empty( $status_name ) ) {
3742 echo '
3743 <tr>
3744 <td class="label status">' . esc_html__( 'Settlement status', 'usces' ) . '</td>
3745 <td class="col1 status"><span id="settlement-status"><span class="acting-status' . esc_attr( $class ) . '">' . esc_html( $status_name ) . '</span></span></td>
3746 </tr>';
3747 }
3748 }
3749 } elseif ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
3750 $regular_id = $usces->get_order_meta_value( 'regular_id', $order_id );
3751 if ( ! empty( $regular_id ) ) {
3752 echo '
3753 <tr>
3754 <td class="label status">' . esc_html__( 'Settlement status', 'usces' ) . '</td>
3755 <td class="col1 status"><span id="settlement-status"><span class="acting-status card-error">' . esc_html__( 'Card unregistered', 'usces' ) . '</span></span></td>
3756 </tr>';
3757 }
3758 }
3759 }
3760 }
3761 }
3762
3763 /**
3764 * 受注編集画面【支払�
3765 報】
3766 * usces_action_order_edit_form_settle_info
3767 *
3768 * @param array $data Order data.
3769 * @param array $action_args Compact array( $order_action, $order_id, $cart ).
3770 */
3771 public function settlement_information( $data, $action_args ) {
3772 global $usces;
3773 extract( $action_args ); // phpcs:ignore
3774
3775 if ( 'new' !== $order_action && ! empty( $order_id ) ) {
3776 $payment = usces_get_payments_by_name( $data['order_payment_name'] );
3777 if ( in_array( $payment['settlement'], $this->pay_method, true ) ) {
3778 $acting_data = usces_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
3779 $merchantfree1 = ( isset( $acting_data['MerchantFree1'] ) && isset( $acting_data['ProcessId'] ) && isset( $acting_data['ProcessPass'] ) ) ? $acting_data['MerchantFree1'] : '9999999999';
3780 echo '<input type="button" id="settlement-information-' . esc_attr( $merchantfree1 ) . '-1" class="button settlement-information" value="' . esc_attr__( 'Settlement info', 'usces' ) . '">';
3781 }
3782 }
3783 }
3784
3785 /**
3786 * 決済�
3787 報ダイアログ
3788 * usces_action_endof_order_edit_form
3789 *
3790 * @param array $data Order data.
3791 * @param array $action_args Compact array( $order_action, $order_id, $cart ).
3792 */
3793 public function settlement_dialog( $data, $action_args ) {
3794 global $usces;
3795 extract( $action_args ); // phpcs:ignore
3796
3797 if ( 'new' !== $order_action && ! empty( $order_id ) ) :
3798 $payment = usces_get_payments_by_name( $data['order_payment_name'] );
3799 if ( in_array( $payment['settlement'], $this->pay_method, true ) ) :
3800 ?>
3801 <div id="settlement_dialog" title="">
3802 <div id="settlement-response-loading"></div>
3803 <fieldset>
3804 <div id="settlement-response"></div>
3805 <input type="hidden" id="order_num">
3806 <input type="hidden" id="trans_id">
3807 <input type="hidden" id="acting" value="<?php echo esc_attr( $payment['settlement'] ); ?>">
3808 <input type="hidden" id="error">
3809 </fieldset>
3810 </div>
3811 <?php
3812 endif;
3813 endif;
3814 }
3815
3816 /**
3817 * 決済処理
3818 * usces_action_acting_processing
3819 *
3820 * @param string $acting_flg Payment type.
3821 * @param array $post_query Post data.
3822 */
3823 public function acting_processing( $acting_flg, $post_query ) {
3824 global $usces;
3825
3826 parent::acting_processing( $acting_flg, $post_query );
3827
3828 $acting_opts = $this->get_acting_settings();
3829
3830 /* 外部リンク(三�
3831 間画面) */
3832 if ( 'acting_welcart_card' === $acting_flg && 'link' === $acting_opts['card_activate'] ) {
3833
3834 $usces_entries = $usces->cart->get_entry();
3835 $cart = $usces->cart->get_cart();
3836
3837 if ( ! $usces_entries || ! $cart ) {
3838 wp_redirect( USCES_CART_URL );
3839 exit();
3840 }
3841
3842 if ( ! wp_verify_nonce( $_REQUEST['_nonce'], $acting_flg ) ) {
3843 wp_redirect( USCES_CART_URL );
3844 exit();
3845 }
3846
3847 parse_str( $post_query, $post_data );
3848 $transaction_date = $this->get_transaction_date();
3849 $rand = $post_data['rand'];
3850 $member = $usces->get_member();
3851
3852 usces_save_order_acting_data( $rand );
3853
3854 $param_list = array();
3855 $params = array();
3856
3857 $quick_member = ( isset( $post_data['quick_member'] ) ) ? $post_data['quick_member'] : '';
3858 if ( 'add' !== $quick_member ) {
3859 if ( ! empty( $member['ID'] ) && 'on' === $acting_opts['quickpay'] ) {
3860 $kaiin_id = $this->get_quick_kaiin_id( $member['ID'] );
3861 $kaiin_pass = $this->get_quick_pass( $member['ID'] );
3862 } else {
3863 $kaiin_id = '';
3864 $kaiin_pass = '';
3865 }
3866 if ( empty( $kaiin_id ) || empty( $kaiin_pass ) ) {
3867 $quick_member = 'no';
3868 }
3869 }
3870
3871 $home_url = str_replace( 'http://', 'https://', home_url( '/' ) );
3872 $redirecturl = $home_url . '?page_id=' . USCES_CART_NUMBER;
3873
3874 if ( ! empty( $member['ID'] ) && 'on' === $acting_opts['quickpay'] && ( 'add' === $quick_member || 'update' === $quick_member ) ) {
3875 $data_list = array();
3876 $data_list['MerchantPass'] = $acting_opts['merchant_pass'];
3877 $data_list['TransactionDate'] = $transaction_date;
3878 $data_list['MerchantFree1'] = $rand;
3879 $data_list['MerchantFree2'] = $acting_flg;
3880 $data_list['MerchantFree3'] = $this->merchantfree3;
3881 $data_list['TenantId'] = $acting_opts['tenant_id'];
3882 if ( 'add' === $quick_member ) {
3883 $data_list['OperateId'] = '4MemAdd';
3884 $data_list['KaiinId'] = $this->make_kaiin_id( $member['ID'] );
3885 $data_list['KaiinPass'] = $this->make_kaiin_pass();
3886 } elseif ( 'update' === $quick_member ) {
3887 $data_list['OperateId'] = '4MemChg';
3888 $data_list['KaiinId'] = $kaiin_id;
3889 $data_list['KaiinPass'] = $kaiin_pass;
3890 }
3891 $data_list['ProcNo'] = '0000000';
3892 $data_list['RedirectUrl'] = $redirecturl;
3893 $data_query = http_build_query( $data_list );
3894 $encryptvalue = openssl_encrypt( $data_query, 'aes-128-cbc', $acting_opts['key_aes'], false, $acting_opts['key_iv'] );
3895
3896 $param_list['MerchantId'] = $acting_opts['merchant_id'];
3897 $param_list['EncryptValue'] = urlencode( $encryptvalue );
3898 wp_redirect( add_query_arg( $param_list, $acting_opts['send_url_link'] ) );
3899 } else {
3900 if ( usces_have_continue_charge() ) {
3901 $chargingday = $usces->getItemChargingDay( $cart[0]['post_id'] );
3902 if ( 99 === (int) $chargingday ) { /* 受注日課金 */
3903 $operateid = $acting_opts['operateid'];
3904 } else {
3905 $operateid = '1Auth';
3906 }
3907 } else {
3908 $operateid = $acting_opts['operateid'];
3909 }
3910 $operateid = apply_filters( 'usces_filter_escott_operateid', $operateid, $cart, $usces_entries['order']['total_full_price'] );
3911
3912 $data_list = array();
3913 $data_list['OperateId'] = $operateid;
3914 $data_list['MerchantPass'] = $acting_opts['merchant_pass'];
3915 $data_list['TransactionDate'] = $transaction_date;
3916 $data_list['MerchantFree1'] = $rand;
3917 $data_list['MerchantFree2'] = $acting_flg;
3918 $data_list['MerchantFree3'] = $this->merchantfree3;
3919 $data_list['TenantId'] = $acting_opts['tenant_id'];
3920 if ( 'on' === $acting_opts['quickpay'] && ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) {
3921 $data_list['KaiinId'] = $kaiin_id;
3922 $data_list['KaiinPass'] = $kaiin_pass;
3923 }
3924 $data_list['PayType'] = '01';
3925 $data_list['Amount'] = $usces_entries['order']['total_full_price'];
3926 $data_list['ProcNo'] = '0000000';
3927 $data_list['RedirectUrl'] = $redirecturl;
3928 $data_query = http_build_query( $data_list );
3929 $encryptvalue = openssl_encrypt( $data_query, 'aes-128-cbc', $acting_opts['key_aes'], false, $acting_opts['key_iv'] );
3930
3931 $param_list['MerchantId'] = $acting_opts['merchant_id'];
3932 $param_list['EncryptValue'] = urlencode( $encryptvalue );
3933 wp_redirect( add_query_arg( $param_list, $acting_opts['send_url_link'] ) );
3934 }
3935 exit();
3936
3937 /* 銀聯 */
3938 } elseif ( 'acting_welcart_unionpay' === $acting_flg ) {
3939 $home_url = str_replace( 'http://', 'https://', home_url( '/' ) );
3940
3941 $usces_entries = $usces->cart->get_entry();
3942 $cart = $usces->cart->get_cart();
3943
3944 if ( ! $usces_entries || ! $cart ) {
3945 wp_redirect( USCES_CART_URL );
3946 exit();
3947 }
3948
3949 if ( ! wp_verify_nonce( $_REQUEST['_nonce'], $acting_flg ) ) {
3950 wp_redirect( USCES_CART_URL );
3951 exit();
3952 }
3953
3954 parse_str( $post_query, $post_data );
3955 $transaction_date = $this->get_transaction_date();
3956 $rand = $post_data['rand'];
3957
3958 usces_save_order_acting_data( $rand );
3959
3960 $data_list = array();
3961 $data_list['MerchantPass'] = $acting_opts['merchant_pass'];
3962 $data_list['TransactionDate'] = $transaction_date;
3963 $data_list['MerchantFree1'] = $rand;
3964 $data_list['MerchantFree2'] = $acting_flg;
3965 $data_list['MerchantFree3'] = $this->merchantfree3;
3966 $data_list['TenantId'] = $acting_opts['tenant_id'];
3967 $data_list['Amount'] = $usces_entries['order']['total_full_price'];
3968 $data_list['CurrencyId'] = '392'; /* JPY */
3969 if ( ! empty( $acting_opts['unionpay_pagelanguage'] ) ) {
3970 $data_list['PageLanguage'] = $acting_opts['unionpay_pagelanguage'];
3971 }
3972 // $data_list['PayCardType'] = '00';
3973 $data_list['ProcNo'] = sprintf( '%020d', $rand );
3974 $data_list['SuccessURL'] = USCES_CART_URL . $usces->delim . 'acting=' . $this->acting_unionpay . '&acting_return=1';
3975 $data_list['ErrorURL'] = USCES_CART_URL . $usces->delim . 'acting=' . $this->acting_unionpay . '&acting_return=0';
3976 $data_list['StatusNoticeURL'] = $home_url;
3977 $data_list['EndNoticeURL'] = $home_url;
3978 $data_query = http_build_query( $data_list );
3979 $encryptvalue = openssl_encrypt( $data_query, 'aes-128-cbc', $acting_opts['unionpay_key_aes'], false, $acting_opts['unionpay_key_iv'] );
3980
3981 $param_list = array();
3982 $param_list['MerchantId'] = $acting_opts['merchant_id'];
3983 $param_list['OperateId'] = '11Gathering';
3984 $param_list['EncryptValue'] = $encryptvalue;
3985
3986 $gc = new SLNConnection();
3987 $gc->send_request_unionpay( $acting_opts['send_url_unionpay'], $param_list );
3988 exit();
3989 }
3990 }
3991
3992 /**
3993 * 受注データ登録
3994 * Called by usces_reg_orderdata() and usces_new_orderdata().
3995 * usces_action_reg_orderdata
3996 *
3997 * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $results ).
3998 */
3999 public function register_orderdata( $args ) {
4000 extract( $args ); // phpcs:ignore
4001
4002 if ( ! isset( $results['MerchantFree1'] ) ) {
4003 return;
4004 }
4005
4006 $acting_flg = $payments['settlement'];
4007 if ( ! in_array( $acting_flg, $this->pay_method ) ) {
4008 return;
4009 }
4010
4011 if ( ! $entry['order']['total_full_price'] ) {
4012 return;
4013 }
4014
4015 parent::register_orderdata( $args );
4016
4017 if ( ! isset( $results['Amount'] ) ) {
4018 $results['Amount'] = $entry['order']['total_full_price'];
4019 }
4020 $results = apply_filters( 'usces_filter_escott_register_orderdata_history_log', $results, $args );
4021 $this->save_acting_history_log( $results, $order_id . '_' . $results['MerchantFree1'] );
4022 }
4023
4024 /**
4025 * Front scripts.
4026 * wp_print_footer_scripts
4027 */
4028 public function footer_scripts() {
4029 global $usces;
4030
4031 if ( ! $this->is_validity_acting( 'card' ) ) {
4032 return;
4033 }
4034
4035 parent::footer_scripts();
4036
4037 /* 発送・支払方法ページ */
4038 if ( 'delivery' === $usces->page ) {
4039 $acting_opts = $this->get_acting_settings();
4040 /* リンク型 */
4041 if ( isset( $acting_opts['card_activate'] ) && 'link' === $acting_opts['card_activate'] ) {
4042 wp_enqueue_style( 'jquery-ui-style' );
4043 wp_enqueue_script( 'jquery-ui-dialog' );
4044 wp_enqueue_style( 'jquery-ui-dialog-min-css', includes_url() . 'css/jquery-ui-dialog.min.css' );
4045 wp_register_script( 'usces_cart_escott_link', USCES_FRONT_PLUGIN_URL . '/js/cart_escott_link.js', array( 'jquery' ), USCES_VERSION, true );
4046 $escott_params = array();
4047 $escott_params['card_activate'] = $acting_opts['card_activate'];
4048 $escott_params['message']['agreement'] = $this->consent_message();
4049 $escott_params['message']['agree'] = __( 'Agree', 'usces' );
4050 $escott_params['message']['disagree'] = __( 'Disagree', 'usces' );
4051 wp_localize_script( 'usces_cart_escott_link', 'escott_params', $escott_params );
4052 wp_enqueue_script( 'usces_cart_escott_link' );
4053 }
4054 }
4055
4056 if ( ! usces_is_membersystem_state() || ! usces_is_login() ) {
4057 return;
4058 }
4059
4060 /* クレジットカード�
4061 報更新ページ */
4062 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 ) ) ) {
4063 // wp_enqueue_script( 'usces_escott_member', USCES_FRONT_PLUGIN_URL . '/js/member_escott.js', array( 'jquery' ), USCES_VERSION, true );
4064 print_google_recaptcha_response( filter_input( INPUT_GET, 'usces_page', FILTER_DEFAULT ), 'member-card-info', 'member_update_settlement' );
4065 }
4066
4067 /* マイページ */
4068 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
4069 $acting_opts = $this->get_acting_settings();
4070 if ( 'on' === $acting_opts['quickpay'] ) {
4071 wp_enqueue_style( 'jquery-ui-style' );
4072 wp_enqueue_script( 'jquery-ui-dialog' );
4073 wp_enqueue_style( 'jquery-ui-dialog-min-css', includes_url() . 'css/jquery-ui-dialog.min.css' );
4074 wp_register_script( 'usces_member_escott', USCES_FRONT_PLUGIN_URL . '/js/member_escott.js', array( 'jquery' ), USCES_VERSION, true );
4075 $escott_params = array();
4076 $escott_params['sec3d_activate'] = $acting_opts['sec3d_activate'];
4077 $escott_params['message']['agreement'] = $this->consent_message();
4078 $escott_params['message']['agree'] = __( 'Agree', 'usces' );
4079 $escott_params['message']['disagree'] = __( 'Disagree', 'usces' );
4080 $escott_params['update_settlement_url'] = urlencode(
4081 add_query_arg(
4082 array(
4083 'usces_page' => 'member_update_settlement',
4084 're-enter' => 1,
4085 ),
4086 USCES_MEMBER_URL
4087 )
4088 );
4089 $escott_params['register_settlement_url'] = urlencode(
4090 add_query_arg(
4091 array(
4092 'usces_page' => 'member_register_settlement',
4093 're-enter' => 1,
4094 ),
4095 USCES_MEMBER_URL
4096 )
4097 );
4098 $member = $usces->get_member();
4099 $escott_params['edit_auth'] = ( isset( $member['edit_auth'] ) ) ? $member['edit_auth'] : '';
4100 $escott_params['edit_flag'] = USCES_VERIFY_MEMBERS_EMAIL::$opts['edit_flag'];
4101 wp_localize_script( 'usces_member_escott', 'escott_params', $escott_params );
4102 wp_enqueue_script( 'usces_member_escott' );
4103 }
4104 }
4105 }
4106
4107 /**
4108 * 支払方法説明
4109 * usces_fiter_the_payment_method_explanation
4110 *
4111 * @param string $explanation Explanation of Payment Method.
4112 * @param array $payment Payment data.
4113 * @param string $value Input value.
4114 * @return string
4115 */
4116 public function set_payment_method_explanation( $explanation, $payment, $value ) {
4117 global $usces;
4118
4119 $quickpay = '';
4120 if ( $this->acting_flg_card === $payment['settlement'] ) {
4121 $acting_opts = $this->get_acting_settings();
4122 if ( 'link' === $acting_opts['card_activate'] ) {
4123 if ( usces_is_login() && 'on' === $acting_opts['quickpay'] ) {
4124 $member = $usces->get_member();
4125 $kaiin_id = $this->get_quick_kaiin_id( $member['ID'] );
4126 $kaiin_pass = $this->get_quick_pass( $member['ID'] );
4127 if ( ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) {
4128 $quickpay = '<p class="' . $this->paymod_id . '_quick_member"><label type="update"><input type="checkbox" name="quick_member" value="update"><span>' . __( 'Change and register purchased credit card', 'usces' ) . '</span></label></p>';
4129 } else {
4130 if ( usces_have_regular_order() || usces_have_continue_charge() ) {
4131 $quickpay = '<input type="hidden" name="quick_member" value="add">';
4132 } elseif ( 'on' !== $acting_opts['chooseable_quickpay'] ) {
4133 $quickpay = '<input type="hidden" name="quick_member" value="add">';
4134 } else {
4135 $quickpay = '<p class="' . $this->paymod_id . '_quick_member"><label type="add"><input type="checkbox" name="quick_member" value="add"><span>' . __( 'Register and purchase a credit card', 'usces' ) . '</span></label></p>';
4136 }
4137 }
4138 } else {
4139 $quickpay = '<input type="hidden" name="quick_member" value="no">';
4140 }
4141 }
4142 }
4143 return $quickpay . $explanation;
4144 }
4145
4146 /**
4147 * 利用可能な決済モジュール
4148 * usces_filter_available_payment_method
4149 *
4150 * @param array $payments Payment data.
4151 * @return array
4152 */
4153 public function set_available_payment_method( $payments ) {
4154 global $usces;
4155
4156 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
4157 $payment_method = array();
4158 foreach ( (array) $payments as $id => $payment ) {
4159 if ( $this->acting_flg_card === $payment['settlement'] ) {
4160 $payment_method[ $id ] = $payments[ $id ];
4161 break;
4162 }
4163 }
4164 if ( ! empty( $payment_method ) ) {
4165 $payments = $payment_method;
4166 }
4167 }
4168 return $payments;
4169 }
4170
4171 /**
4172 * 支払回数
4173 * usces_filter_delivery_secure_form_howpay
4174 *
4175 * @param string $html HTML.
4176 * @return string
4177 */
4178 public function delivery_secure_form_howpay( $html ) {
4179 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 ) ) ) {
4180 $html = '';
4181 }
4182 return $html;
4183 }
4184
4185 /**
4186 * �
4187 容確認ページ [注文する] ボタン
4188 * usces_filter_confirm_inform
4189 *
4190 * @param string $html Purchase post form.
4191 * @param array $payments Payment data.
4192 * @param string $acting_flg Payment type.
4193 * @param string $rand Welcart transaction key.
4194 * @param string $purchase_disabled Disable purchase button.
4195 * @return string
4196 */
4197 public function confirm_inform( $html, $payments, $acting_flg, $rand, $purchase_disabled ) {
4198 global $usces;
4199
4200 $html = parent::confirm_inform( $html, $payments, $acting_flg, $rand, $purchase_disabled );
4201
4202 $usces_entries = $usces->cart->get_entry();
4203 if ( ! $usces_entries['order']['total_full_price'] ) {
4204 return $html;
4205 }
4206
4207 if ( $this->acting_flg_unionpay === $acting_flg ) {
4208 $html = '<form id="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4209 <input type="hidden" name="rand" value="' . $rand . '">
4210 <div class="send">
4211 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4212 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4213 <input name="purchase" type="submit" id="purchase_button" class="checkout_button" value="' . apply_filters( 'usces_filter_confirm_checkout_button_value', __( 'Checkout', 'usces' ) ) . '"' . apply_filters( 'usces_filter_confirm_nextbutton', null ) . $purchase_disabled . ' />
4214 </div>
4215 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4216 }
4217 return $html;
4218 }
4219
4220 /**
4221 * Front styles.
4222 * wp_print_styles
4223 */
4224 public function print_styles() {
4225 global $usces;
4226
4227 parent::print_styles();
4228
4229 /* マイページ */
4230 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) :
4231 $acting_opts = $this->get_acting_settings();
4232 if ( isset( $acting_opts['card_activate'] ) && 'token' === $acting_opts['card_activate'] || 'link' === $acting_opts['card_activate'] ) :
4233 ?>
4234 <style type="text/css">
4235 #escott-dialog {
4236 left: 50% !important;
4237 transform: translateY(-50%) translateX(-50%);
4238 -webkit- transform: translateY(-50%) translateX(-50%);
4239 width: 90% !important;
4240 max-width: 700px;
4241 }
4242 #escott-agree-dialog {
4243 height: auto !important;
4244 }
4245 .escott_agreement_message {
4246 width: 100%;
4247 height: 200px;
4248 }
4249 </style>
4250 <?php
4251 endif;
4252 endif;
4253 }
4254
4255 /**
4256 * Front scripts.
4257 * wp_enqueue_scripts
4258 */
4259 public function enqueue_scripts() {
4260 global $usces;
4261
4262 /* 発送・支払方法ページ、クレジットカード�
4263 報更新ページ */
4264 if ( ! is_admin() && $this->is_validity_acting( 'card' ) ) :
4265 if ( ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'delivery' === $usces->page ) ||
4266 ( $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 ) ) ) ) :
4267 $acting_opts = $this->get_acting_settings();
4268 if ( isset( $acting_opts['card_activate'] ) && 'token' === $acting_opts['card_activate'] ) :
4269 ?>
4270 <script type="text/javascript" src="<?php echo esc_attr( $acting_opts['api_token'] ); ?>?k_TokenNinsyoCode=<?php echo esc_attr( $acting_opts['token_code'] ); ?>" callBackFunc="setToken" class="spsvToken"></script>
4271 <?php
4272 endif;
4273 endif;
4274 endif;
4275 }
4276
4277 /**
4278 * Set uscesL10n.
4279 * usces_filter_uscesL10n
4280 *
4281 * @param string $l10n uscesL10n.
4282 * @param int $post_id Post ID.
4283 * @return string
4284 */
4285 public function set_uscesL10n( $l10n, $post_id ) {
4286 global $usces;
4287
4288 $l10n = parent::set_uscesL10n( $l10n, $post_id );
4289
4290 if ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'delivery' === $usces->page ) {
4291 $acting_opts = $this->get_acting_settings();
4292 if ( isset( $acting_opts['card_activate'] ) && 'link' === $acting_opts['card_activate'] ) {
4293 $front_ajaxurl = trailingslashit( USCES_SSL_URL ) . 'index.php';
4294 $l10n .= "'front_ajaxurl': '" . $front_ajaxurl . "',\n";
4295 $payment_method = usces_get_system_option( 'usces_payment_method', 'sort' );
4296 $payment_method = apply_filters( 'usces_fiter_the_payment_method', $payment_method, '' );
4297 foreach ( (array) $payment_method as $id => $payment ) {
4298 if ( $payment['settlement'] === $this->acting_flg_card ) {
4299 $l10n .= "'escott_link_payment_id': '" . $id . "',\n";
4300 break;
4301 }
4302 }
4303 }
4304 } 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 ) ) ) ) {
4305 $acting_opts = $this->get_acting_settings();
4306 if ( isset( $acting_opts['card_activate'] ) && 'token' === $acting_opts['card_activate'] ) {
4307 $front_ajaxurl = trailingslashit( USCES_SSL_URL ) . 'index.php';
4308 $l10n .= "'front_ajaxurl': '" . $front_ajaxurl . "',\n";
4309 $l10n .= "'escott_token_error_message': '" . __( 'Credit card information is not appropriate.', 'usces' ) . "',\n";
4310 }
4311 }
4312 return $l10n;
4313 }
4314
4315 /**
4316 * クレジットカード登録・変更ページ表示
4317 * usces_filter_template_redirect
4318 */
4319 public function member_update_settlement() {
4320 global $usces;
4321
4322 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
4323 if ( ! usces_is_membersystem_state() || ! usces_is_login() ) {
4324 return;
4325 }
4326
4327 $acting_opts = $this->get_acting_settings();
4328 if ( 'on' !== $acting_opts['quickpay'] ) {
4329 return;
4330 }
4331
4332 if ( isset( $_REQUEST['usces_page'] ) && 'member_update_settlement' === wp_unslash( $_REQUEST['usces_page'] ) ) {
4333 add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) );
4334 $usces->page = 'member_update_settlement';
4335 $this->member_update_settlement_form();
4336 exit();
4337
4338 } elseif ( isset( $_REQUEST['usces_page'] ) && 'member_register_settlement' === wp_unslash( $_REQUEST['usces_page'] ) ) {
4339 add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) );
4340 $usces->page = 'member_register_settlement';
4341 $this->member_update_settlement_form();
4342 exit();
4343 }
4344 }
4345 return false;
4346 }
4347
4348 /**
4349 * クレジットカード登録・変更ページ表示
4350 * usces_filter_states_form_js
4351 *
4352 * @param string $js Scripts.
4353 * @return string
4354 */
4355 public function states_form_js( $js ) {
4356 return '';
4357 }
4358
4359 /**
4360 * 会員データ削除チェック
4361 * usces_filter_delete_member_check
4362 *
4363 * @param boolean $del Deletable.
4364 * @param int $member_id Member ID.
4365 * @return boolean
4366 */
4367 public function delete_member_check( $del, $member_id ) {
4368 $kaiin_id = $this->get_quick_kaiin_id( $member_id );
4369 if ( ! empty( $kaiin_id ) ) {
4370 $del = false;
4371 }
4372 return $del;
4373 }
4374
4375 /**
4376 * クレジットカード登録・変更ページリンク
4377 * usces_action_member_submenu_list
4378 */
4379 public function e_update_settlement() {
4380 global $usces;
4381
4382 $member = $usces->get_member();
4383 $html = $this->update_settlement( '', $member );
4384 echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4385 }
4386
4387 /**
4388 * クレジットカード登録・変更ページリンク
4389 * usces_filter_member_submenu_list
4390 *
4391 * @param string $html Submenu area of the member page.
4392 * @param array $member Member information.
4393 * @return string
4394 */
4395 public function update_settlement( $html, $member ) {
4396 $acting_opts = $this->get_acting_settings();
4397 if ( 'on' === $acting_opts['quickpay'] ) {
4398 /* e-SCOTT 会員�
4399 �会 */
4400 $response_member = $this->escott_member_reference( $member['ID'] );
4401 if ( 'OK' === $response_member['ResponseCd'] ) {
4402 if ( 'on' === $acting_opts['sec3d_activate'] ) {
4403 $html .= '<li class="settlement-update gotoedit"><a href="javascript:void(0);" class="escott_agreement" data-mode="update">' . __( 'Change the credit card is here >>', 'usces' ) . '</a></li>';
4404 } else {
4405 $update_settlement_url = add_query_arg(
4406 array(
4407 'usces_page' => 'member_update_settlement',
4408 're-enter' => 1,
4409 ),
4410 USCES_MEMBER_URL
4411 );
4412 $html .= '<li class="settlement-update gotoedit"><a href="' . $update_settlement_url . '">' . __( 'Change the credit card is here >>', 'usces' ) . '</a></li>';
4413 }
4414 } else {
4415 if ( 'on' === $acting_opts['sec3d_activate'] ) {
4416 $html .= '<li class="settlement-register gotoedit"><a href="javascript:void(0);" class="escott_agreement" data-mode="register">' . __( 'Credit card registration is here >>', 'usces' ) . '</a></li>';
4417 } else {
4418 $register_settlement_url = add_query_arg(
4419 array(
4420 'usces_page' => 'member_register_settlement',
4421 're-enter' => 1,
4422 ),
4423 USCES_MEMBER_URL
4424 );
4425 $html .= '<li class="settlement-register gotoedit"><a href="' . $register_settlement_url . '">' . __( 'Credit card registration is here >>', 'usces' ) . '</a></li>';
4426 }
4427 }
4428 }
4429 return $html;
4430 }
4431
4432 /**
4433 * クレジットカード登録・変更ページ
4434 */
4435 public function member_update_settlement_form() {
4436 global $usces;
4437
4438 $member = $usces->get_member();
4439 $acting_opts = $this->get_acting_settings();
4440
4441 /* 外部リンク(三�
4442 間画面) */
4443 if ( 'link' === $acting_opts['card_activate'] ) {
4444 $transaction_date = $this->get_transaction_date();
4445 $home_url = str_replace( 'http://', 'https://', home_url( '/' ) );
4446 $redirecturl = $home_url . '?page_id=' . USCES_MEMBER_NUMBER;
4447
4448 $data_list = array();
4449 $data_list['MerchantPass'] = $acting_opts['merchant_pass'];
4450 $data_list['TransactionDate'] = $transaction_date;
4451 $data_list['MerchantFree3'] = $this->merchantfree3;
4452 $data_list['TenantId'] = $acting_opts['tenant_id'];
4453 if ( 'member_register_settlement' === $usces->page ) {
4454 $data_list['OperateId'] = '4MemAdd';
4455 $data_list['KaiinId'] = $this->make_kaiin_id( $member['ID'] );
4456 $data_list['KaiinPass'] = $this->make_kaiin_pass();
4457 } else {
4458 $data_list['OperateId'] = '4MemChg';
4459 $data_list['KaiinId'] = $this->get_quick_kaiin_id( $member['ID'] );
4460 $data_list['KaiinPass'] = $this->get_quick_pass( $member['ID'] );
4461 }
4462 $data_list['ProcNo'] = '0000000';
4463 $data_list['RedirectUrl'] = $redirecturl;
4464 $data_query = http_build_query( $data_list );
4465 $encryptvalue = openssl_encrypt( $data_query, 'aes-128-cbc', $acting_opts['key_aes'], false, $acting_opts['key_iv'] );
4466
4467 $param_list['MerchantId'] = $acting_opts['merchant_id'];
4468 $param_list['EncryptValue'] = urlencode( $encryptvalue );
4469 wp_redirect( add_query_arg( $param_list, $acting_opts['send_url_link'] ) );
4470 exit();
4471
4472 /* マイページ */
4473 } else {
4474 $script = '';
4475 $done_message = '';
4476 $html = '';
4477 $register = ( 'member_register_settlement' === $usces->page ) ? true : false;
4478 $deleted = false;
4479
4480 $cardno = '';
4481 $seccd = '';
4482 $expyy = '';
4483 $expmm = '';
4484 $cardname = '';
4485
4486 if ( 'on' === $acting_opts['quickpay'] ) {
4487 if ( isset( $_POST['update'] ) ) {
4488 check_admin_referer( 'member_update_settlement', 'wc_nonce' );
4489 $verify_action = wel_verify_update_settlement( $member['ID'] );
4490 if ( ! $verify_action ) {
4491 $usces->error_message .= '<p>' . __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '</p>';
4492 } else {
4493 $response_member = $this->escott_member_update( $member['ID'] );
4494 if ( 'OK' === $response_member['ResponseCd'] ) {
4495 $this->send_update_settlement_mail();
4496 $done_message = __( 'Successfully updated.', 'usces' );
4497 } else {
4498 $usces->error_message .= '<p>' . __( 'Credit card information is not appropriate.', 'usces' ) . '</p>';
4499 $cardno = filter_input( INPUT_POST, 'cardno', FILTER_DEFAULT );
4500 $seccd = filter_input( INPUT_POST, 'seccd', FILTER_DEFAULT );
4501 $expyy = filter_input( INPUT_POST, 'expyy', FILTER_DEFAULT );
4502 $expmm = filter_input( INPUT_POST, 'expmm', FILTER_DEFAULT );
4503 $cardname = filter_input( INPUT_POST, 'cardname', FILTER_DEFAULT );
4504 }
4505 }
4506 } elseif ( isset( $_POST['register'] ) ) {
4507 check_admin_referer( 'member_update_settlement', 'wc_nonce' );
4508 $verify_action = wel_verify_update_settlement( $member['ID'] );
4509 if ( ! $verify_action ) {
4510 $usces->error_message .= '<p>' . __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '</p>';
4511 } else {
4512 $response_member = $this->escott_member_register( $member['ID'] );
4513 if ( 'OK' === $response_member['ResponseCd'] ) {
4514 $done_message = __( 'Successfully registered.', 'usces' );
4515 $register = false;
4516 } else {
4517 $usces->error_message .= '<p>' . __( 'Credit card information is not appropriate.', 'usces' ) . '</p>';
4518 $cardno = filter_input( INPUT_POST, 'cardno', FILTER_DEFAULT );
4519 $seccd = filter_input( INPUT_POST, 'seccd', FILTER_DEFAULT );
4520 $expyy = filter_input( INPUT_POST, 'expyy', FILTER_DEFAULT );
4521 $expmm = filter_input( INPUT_POST, 'expmm', FILTER_DEFAULT );
4522 $cardname = filter_input( INPUT_POST, 'cardname', FILTER_DEFAULT );
4523 }
4524 }
4525 }
4526
4527 if ( ! $deleted ) {
4528 /* e-SCOTT 会員�
4529 �会 */
4530 $response_member = $this->escott_member_reference( $member['ID'] );
4531 if ( 'OK' === $response_member['ResponseCd'] ) {
4532 $cardlast4 = substr( $response_member['CardNo'], -4 );
4533 $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 );
4534 $expmm = substr( $response_member['CardExp'], 2, 2 );
4535 } else {
4536 $cardlast4 = '';
4537 }
4538 $html .= '<input name="acting" type="hidden" value="' . $this->paymod_id . '" />
4539 <table class="customer_form" id="' . $this->paymod_id . '">';
4540 if ( ! empty( $cardlast4 ) ) {
4541 $html .= '
4542 <tr>
4543 <th scope="row">' . __( 'The last four digits of your card number', 'usces' ) . '</th>
4544 <td colspan="2"><p>' . $cardlast4 . '</p></td>
4545 </tr>';
4546 }
4547 $cardno_attention = apply_filters( 'usces_filter_cardno_attention', __( '(Single-byte numbers only)', 'usces' ) . '<div class="attention">' . __( '* Please do not enter symbols or letters other than numbers such as space (blank), hyphen (-) between numbers.', 'usces' ) . '</div>' );
4548 $html .= '
4549 <tr>
4550 <th scope="row">' . __( 'card number', 'usces' ) . '</th>
4551 <td colspan="2"><input name="cardno" id="cardno" type="tel" value="' . $cardno . '" />' . $cardno_attention . '</td>
4552 </tr>';
4553 if ( 'on' === $acting_opts['seccd'] ) {
4554 $seccd_attention = apply_filters( 'usces_filter_seccd_attention', __( '(Single-byte numbers only)', 'usces' ) );
4555 $html .= '
4556 <tr>
4557 <th scope="row">' . __( 'security code', 'usces' ) . '</th>
4558 <td colspan="2"><input name="seccd" id="seccd" type="tel" value="' . $seccd . '" />' . $seccd_attention . '</td>
4559 </tr>';
4560 }
4561 $html .= '
4562 <tr>
4563 <th scope="row">' . __( 'Card expiration', 'usces' ) . '</th>
4564 <td colspan="2">
4565 <select id="expmm">
4566 <option value=""' . selected( empty( $expmm ), true, false ) . '>--</option>';
4567 for ( $i = 1; $i <= 12; $i++ ) {
4568 $html .= '
4569 <option value="' . sprintf( '%02d', $i ) . '"' . selected( (int) $expmm, $i, false ) . '>' . sprintf( '%2d', $i ) . '</option>';
4570 }
4571 $html .= '
4572 </select>' . __( 'month', 'usces' ) . '&nbsp;
4573 <select id="expyy">
4574 <option value=""' . selected( empty( $expyy ), true, false ) . '>----</option>';
4575 for ( $i = 0; $i < 15; $i++ ) {
4576 $year = date_i18n( 'Y' ) + $i;
4577 $html .= '
4578 <option value="' . $year . '"' . selected( (int) $expyy, (int) $year, false ) . '>' . $year . '</option>';
4579 }
4580 $html .= '
4581 </select>' . __( 'year', 'usces' ) . '
4582 </td>
4583 </tr>';
4584
4585 $cardname_attention = apply_filters( 'usces_filter_cardname_attention', __( '(Alphabetic characters only)', 'usces' ) . '<div class="attention">' . __( '* Use a space to separate the first and last name, and enter all characters in uppercase.', 'usces' ) . '</div>' );
4586 $html .= '
4587 <tr>
4588 <th scope="row">' . __( 'Card name', 'usces' ) . '</th>
4589 <td colspan="2"><input name="cardname" id="cardname" type="text" value="" />' . $cardname_attention . '</td>
4590 </tr>
4591 </table>';
4592 }
4593
4594 if ( empty( $usces->error_message ) && isset( $_GET['re-enter'] ) && isset( $_GET['ResponseCd'] ) ) {
4595 if ( 'NG' === wp_unslash( $_GET['ResponseCd'] ) ) {
4596 $usces->error_message = __( 'Credit card information is not appropriate.', 'usces' );
4597 }
4598 }
4599 }
4600
4601 $update_settlement_url = add_query_arg(
4602 array(
4603 'usces_page' => $usces->page,
4604 'settlement' => 1,
4605 're-enter' => 1,
4606 ),
4607 USCES_MEMBER_URL
4608 );
4609 if ( '' !== $done_message ) {
4610 $script .= '
4611 <script type="text/javascript">
4612 jQuery.event.add( window, "load", function() {
4613 alert("' . $done_message . '");
4614 });
4615 </script>';
4616 }
4617 $error_message = apply_filters( 'usces_filter_member_update_settlement_error_message', $usces->error_message );
4618
4619 ob_start();
4620 get_header();
4621 if ( '' !== $script ) {
4622 echo $script; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4623 }
4624 ?>
4625 <div id="content" class="two-column">
4626 <div class="catbox">
4627 <?php
4628 if ( have_posts() ) :
4629 usces_remove_filter();
4630 ?>
4631 <div class="post" id="wc_member_update_settlement">
4632 <?php
4633 if ( $register ) :
4634 ?>
4635 <h1 class="member_page_title"><?php esc_html_e( 'Credit card registration', 'usces' ); ?></h1>
4636 <?php
4637 else :
4638 ?>
4639 <h1 class="member_page_title"><?php esc_html_e( 'Credit card update', 'usces' ); ?></h1>
4640 <?php
4641 endif;
4642 ?>
4643 <div class="entry">
4644 <div id="memberpages">
4645 <div class="whitebox">
4646 <div id="memberinfo">
4647 <div class="header_explanation"></div>
4648 <?php
4649 if ( ! $deleted && ! $register ) :
4650 ?>
4651 <p><?php esc_html_e( 'If you want to change the expiration date only, please the card number to the blank.', 'usces' ); ?></p>
4652 <?php
4653 endif;
4654 ?>
4655 <div class="error_message"><?php echo wp_kses_post( $error_message ); ?></div>
4656 <?php
4657 if ( 'token' === $acting_opts['card_activate'] ) :
4658 echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4659 endif;
4660 ?>
4661 <form id="member-card-info" name="member_update_settlement" action="<?php echo esc_url( $update_settlement_url ); ?>" method="post" onKeyDown="if(event.keyCode == 13) {return false;}">
4662 <?php
4663 if ( 'on' === $acting_opts['card_activate'] ) :
4664 echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4665 endif;
4666 ?>
4667 <div class="send">
4668 <input type="hidden" name="expmm" value="<?php echo esc_attr( $expmm ); ?>" />
4669 <input type="hidden" name="expyy" value="<?php echo esc_attr( $expyy ); ?>" />
4670 <?php
4671 if ( 'token' === $acting_opts['card_activate'] ) :
4672 ?>
4673 <input type="hidden" name="token" id="token" value="" />
4674 <input type="hidden" name="billingname" id="billingname" value="" />
4675 <?php
4676 endif;
4677 if ( 'on' === $acting_opts['sec3d_activate'] ) :
4678 ?>
4679 <input type="hidden" name="billingemail" id="billingemail" value="<?php echo esc_attr( $member['mailaddress1'] ); ?>" />
4680 <input type="hidden" name="rand" id="rand" value="<?php echo esc_attr( usces_acting_key() ); ?>" />
4681 <?php
4682 endif;
4683 if ( $register ) :
4684 ?>
4685 <input type="hidden" name="register" value="register" />
4686 <input type="button" id="card-register" class="card-register" value="<?php esc_attr_e( 'Register' ); ?>" />
4687 <?php
4688 else :
4689 if ( ! $deleted ) :
4690 ?>
4691 <input type="hidden" name="update" value="update" />
4692 <input type="button" id="card-update" class="card-update" value="<?php esc_attr_e( 'Update' ); ?>" />
4693 <?php
4694 endif;
4695 endif;
4696 ?>
4697 <input type="button" name="back" value="<?php esc_attr_e( 'Back to the member page.', 'usces' ); ?>" onclick="location.href='<?php echo esc_url( USCES_MEMBER_URL ); ?>'" />
4698 <input type="button" name="top" value="<?php esc_attr_e( 'Back to the top page.', 'usces' ); ?>" onclick="location.href='<?php echo esc_url( home_url() ); ?>'" />
4699 </div>
4700 <?php wp_nonce_field( 'member_update_settlement', 'wc_nonce' ); ?>
4701 </form>
4702 <div class="footer_explanation"></div>
4703 </div><!-- end of memberinfo -->
4704 </div><!-- end of whitebox -->
4705 </div><!-- end of memberpages -->
4706 </div><!-- end of entry -->
4707 </div><!-- end of post -->
4708 <?php
4709 else :
4710 ?>
4711 <p><?php esc_html_e( 'Sorry, no posts matched your criteria.', 'usces' ); ?></p>
4712 <?php
4713 endif;
4714 ?>
4715 </div><!-- end of catbox -->
4716 </div><!-- end of content -->
4717 <?php
4718 $sidebar = apply_filters( 'usces_filter_member_update_settlement_page_sidebar', 'cartmember' );
4719 if ( ! empty( $sidebar ) ) {
4720 get_sidebar( $sidebar );
4721 }
4722 get_footer();
4723 $contents = ob_get_contents();
4724 ob_end_clean();
4725
4726 echo $contents; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4727 }
4728 }
4729
4730 /**
4731 * クレジットカード変更確認メール
4732 */
4733 public function send_update_settlement_mail() {
4734 global $usces;
4735
4736 $member = $usces->get_member();
4737 // $mail_data = $usces->options['mail_data'];
4738
4739 $subject = apply_filters( 'usces_filter_send_update_settlement_mail_subject', __( 'Confirmation of credit card update', 'usces' ), $member );
4740 $mail_header = __( 'Your credit card information has been updated on the membership page.', 'usces' ) . "\r\n\r\n";
4741 // $mail_footer = $mail_data['footer']['thankyou'];
4742 $mail_footer = get_option( 'blogname' ) . "\r\n";
4743 $name = usces_localized_name( $member['name1'], $member['name2'], 'return' );
4744
4745 $message = '--------------------------------' . "\r\n";
4746 $message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
4747 $message .= __( 'Name', 'usces' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
4748 $message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
4749 $message .= '--------------------------------' . "\r\n\r\n";
4750 $message .= __( 'If you have not requested this email, sorry to trouble you, but please contact us.', 'usces' ) . "\r\n\r\n";
4751 $message = apply_filters( 'usces_filter_send_update_settlement_mail_message', $message, $member );
4752 $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";
4753 $message = sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n" . $message;
4754
4755 $send_para = array(
4756 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
4757 'to_address' => $member['mailaddress1'],
4758 'from_name' => get_option( 'blogname' ),
4759 'from_address' => $usces->options['sender_mail'],
4760 'reply_name' => get_option( 'blogname' ),
4761 'reply_to' => usces_get_first_order_mail(),
4762 'return_path' => $usces->options['sender_mail'],
4763 'subject' => $subject,
4764 'message' => do_shortcode( $message ),
4765 );
4766 usces_send_mail( $send_para );
4767
4768 $admin_message = $mail_header;
4769 $admin_message .= '--------------------------------' . "\r\n";
4770 $admin_message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
4771 $admin_message .= __( 'Name', 'usces' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
4772 $admin_message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
4773 $admin_message .= '--------------------------------' . "\r\n\r\n";
4774 if ( usces_have_member_continue_order( $member['ID'] ) ) {
4775 $admin_message .= $this->message_continue_order( $member['ID'] );
4776 }
4777 if ( usces_have_member_regular_order( $member['ID'] ) ) {
4778 $admin_message .= $this->message_regular_order( $member['ID'] );
4779 }
4780 $admin_message .=
4781 "\r\n----------------------------------------------------\r\n" .
4782 'REMOTE_ADDR : ' . $_SERVER['REMOTE_ADDR'] .
4783 "\r\n----------------------------------------------------\r\n";
4784
4785 $admin_para = array(
4786 'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
4787 'to_address' => $usces->options['order_mail'],
4788 'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
4789 'from_address' => $usces->options['sender_mail'],
4790 'reply_name' => get_option( 'blogname' ),
4791 'reply_to' => usces_get_first_order_mail(),
4792 'return_path' => $usces->options['sender_mail'],
4793 'subject' => $subject . '( ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . ' )',
4794 'message' => do_shortcode( $admin_message ),
4795 );
4796 usces_send_mail( $admin_para );
4797 }
4798
4799 /**
4800 * 契約中の自動継続課金�
4801
4802 *
4803 * @param int $member_id Member ID.
4804 */
4805 public function message_continue_order( $member_id ) {
4806 global $usces, $wpdb;
4807
4808 $message = '';
4809 $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' );
4810 $continue_order = $wpdb->get_results( $query, ARRAY_A );
4811 if ( 0 < count( $continue_order ) ) {
4812 $message .= '--------------------------------' . "\r\n";
4813 $message .= __( 'Auto-continuation charging Information under Contract with a credit card', 'usces' ) . "\r\n";
4814 foreach ( $continue_order as $continue_data ) {
4815 $con_id = $continue_data['con_id'];
4816 $con_order_id = $continue_data['con_order_id'];
4817 $message .= __( 'Order number', 'usces' ) . ' : ' . $con_order_id;
4818 $status = $this->get_latest_status( $member_id, $con_order_id );
4819 if ( ! empty( $status ) ) {
4820 $next_charging = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_charging( $con_order_id ) : $continue_data['con_next_contracting'];
4821 $message .= ' ( ' . __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $next_charging ) );
4822 if ( 0 < (int) $continue_data['con_interval'] ) {
4823 $next_contracting = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_contracting( $con_order_id ) : $continue_data['con_next_contracting'];
4824 $message .= ', ' . __( 'Renewal Date', 'dlseller' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $next_contracting ) );
4825 }
4826 $message .= ' )';
4827 if ( 'OK' !== $status ) {
4828 $message .= ' ' . __( 'Condition', 'dlseller' ) . ' : ' . __( 'Settlement error', 'usces' );
4829 $log_data = $this->get_acting_log( $con_order_id );
4830 if ( $log_data && 0 < count( $log_data ) ) {
4831 $acting_data = usces_unserialize( $log_data[0]['log'] );
4832 $trans_id = ( isset( $acting_data['MerchantFree1'] ) ) ? $acting_data['MerchantFree1'] : '';
4833 } else {
4834 $trans_id = $usces->get_order_meta_value( 'trans_id', $con_order_id );
4835 }
4836 if ( $trans_id ) {
4837 $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $trans_id . ' )';
4838 }
4839 }
4840 }
4841 $message .= "\r\n";
4842 }
4843 $message .= '--------------------------------' . "\r\n\r\n";
4844 }
4845 return $message;
4846 }
4847
4848 /**
4849 * 契約中の定期購�
4850 ��
4851
4852 *
4853 * @param int $member_id Member ID.
4854 */
4855 public function message_regular_order( $member_id ) {
4856 global $usces, $wpdb;
4857
4858 $message = '';
4859 $regular_table_name = $wpdb->prefix . 'usces_regular';
4860 $regular_detail_table_name = $wpdb->prefix . 'usces_regular_detail';
4861 $order_table_name = $wpdb->prefix . 'usces_order';
4862 $order_meta_table_name = $wpdb->prefix . 'usces_order_meta';
4863
4864 $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 );
4865 $regular_order = $wpdb->get_results( $query, ARRAY_A );
4866 if ( 0 < count( $regular_order ) ) {
4867 foreach ( $regular_order as $regular_data ) {
4868 $payment = $usces->getPayments( $regular_data['reg_payment_name'] );
4869 if ( 'acting_welcart_card' !== $payment['settlement'] ) {
4870 continue;
4871 }
4872 $reg_id = $regular_data['reg_id'];
4873 $message .= __( 'Regular ID', 'autodelivery' ) . ' : ' . $reg_id;
4874 $query = $wpdb->prepare(
4875 "SELECT o.ID AS `order_id`, meta.meta_value AS `deco_id`, DATE_FORMAT( order_date, %s ) AS `date`
4876 FROM {$order_table_name} AS `o`
4877 LEFT JOIN {$order_meta_table_name} AS `meta` ON o.ID = meta.order_id AND meta.meta_key = 'dec_order_id'
4878 LEFT JOIN {$regular_table_name} ON o.ID = reg_order_id
4879 WHERE reg_id = %d
4880 UNION ALL
4881 SELECT o1.ID AS `order_id`, meta1.meta_value AS `deco_id`, DATE_FORMAT( order_date, %s ) AS `date`
4882 FROM {$order_table_name} AS `o1`
4883 LEFT JOIN {$order_meta_table_name} AS `meta1` ON o1.ID = meta1.order_id AND meta1.meta_key = 'dec_order_id'
4884 LEFT JOIN {$order_meta_table_name} AS `meta2` ON o1.ID = meta2.order_id AND meta2.meta_key = 'regular_id'
4885 WHERE meta2.meta_value = %d
4886 ORDER BY order_id DESC, date DESC",
4887 '%Y-%m-%d',
4888 $reg_id,
4889 '%Y-%m-%d',
4890 $reg_id
4891 );
4892 $regular_order_data = $wpdb->get_results( $query, ARRAY_A );
4893 if ( 0 < count( $regular_order_data ) ) {
4894 $reg_order_id = $regular_order_data[0]['order_id'];
4895 $status = $this->get_latest_status( $member_id, $reg_order_id );
4896 if ( ! empty( $status ) && 'OK' === $status ) {
4897 if ( $this->isdate( $regular_data['regdet_schedule_date'] ) ) {
4898 $message .= ' ( ' . __( 'Scheduled order date', 'autodelivery' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $regular_data['regdet_schedule_date'] ) ) . ' )';
4899 }
4900 } else {
4901 $message .= ' ' . __( 'Condition', 'autodelivery' ) . ' : ' . __( 'Settlement error', 'usces' );
4902 $trans_id = $usces->get_order_meta_value( 'trans_id', $reg_order_id );
4903 if ( $trans_id ) {
4904 $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $trans_id . ' )';
4905 }
4906 }
4907 $message .= "\r\n";
4908 }
4909 }
4910 if ( '' !== $message ) {
4911 $message = '--------------------------------' . "\r\n"
4912 . __( 'Subscription Information under Contract with a credit card', 'usces' ) . "\r\n"
4913 . $message
4914 . '--------------------------------' . "\r\n\r\n";
4915 }
4916 }
4917
4918 return $message;
4919 }
4920
4921 /**
4922 * 利用可能な支払方法
4923 * usces_filter_the_continue_payment_method
4924 *
4925 * @param array $payment_method Payment method.
4926 * @return array
4927 */
4928 public function continuation_payment_method( $payment_method ) {
4929 $acting_opts = $this->get_acting_settings();
4930 if ( 'on' === $acting_opts['quickpay'] ) {
4931 $payment_method[] = 'acting_welcart_card';
4932 }
4933 return $payment_method;
4934 }
4935
4936 /**
4937 * 利用可能な支払方法
4938 * dlseller_filter_the_payment_method_restriction
4939 * wcad_filter_the_payment_method_restriction
4940 *
4941 * @param array $payments_restriction Payment method.
4942 * @param string $payments_value Input value.
4943 * @return array
4944 */
4945 public function payment_method_restriction( $payments_restriction, $payments_value ) {
4946 $acting_opts = $this->get_acting_settings();
4947 if ( ( usces_have_regular_order() || usces_have_continue_charge() ) && usces_is_login() && 'on' === $acting_opts['quickpay'] ) {
4948 $payments = usces_get_system_option( 'usces_payment_method', 'settlement' );
4949 $payments_restriction[] = $payments['acting_welcart_card'];
4950 foreach ( (array) $payments_restriction as $key => $value ) {
4951 $sort[ $key ] = $value['sort'];
4952 }
4953 array_multisort( $sort, SORT_ASC, $payments_restriction );
4954 }
4955 return $payments_restriction;
4956 }
4957
4958 /**
4959 * 「初回引落し日」
4960 * dlseller_filter_first_charging
4961 *
4962 * @param object $time Datetime.
4963 * @param int $post_id Post ID.
4964 * @param array $usces_item Item data.
4965 * @param int $order_id Order number.
4966 * @param array $continue_data Continuation data.
4967 * @return object
4968 */
4969 public function first_charging_date( $time, $post_id, $usces_item, $order_id, $continue_data ) {
4970 if ( 99 === (int) $usces_item['item_chargingday'] ) {
4971 if ( empty( $order_id ) ) {
4972 $today = date_i18n( 'Y-m-d', current_time( 'timestamp' ) );
4973 list( $year, $month, $day ) = explode( '-', $today );
4974 $time = mktime( 0, 0, 0, (int) $month, (int) $day, (int) $year );
4975 }
4976 }
4977 return $time;
4978 }
4979
4980 /**
4981 * 継続課金会員リスト「有効期限」
4982 * dlseller_filter_continue_member_list_limitofcard
4983 *
4984 * @param string $limitofcard Card expiration date.
4985 * @param int $member_id Member ID.
4986 * @param int $order_id Order number.
4987 * @param array $meta_data Continuation data.
4988 * @return string
4989 */
4990 public function continue_member_list_limitofcard( $limitofcard, $member_id, $order_id, $meta_data ) {
4991 if ( isset( $meta_data['acting'] ) ) {
4992 if ( version_compare( WCEX_DLSELLER_VERSION, '3.0-beta', '<=' ) ) {
4993 $payment = usces_get_payments_by_name( $meta_data['acting'] );
4994 $acting = $payment['settlement'];
4995 } else {
4996 $acting = $meta_data['acting'];
4997 }
4998 if ( 'acting_welcart_card' !== $acting ) {
4999 return $limitofcard;
5000 }
5001
5002 $acting_opts = $this->get_acting_settings();
5003 if ( 'on' !== $acting_opts['quickpay'] ) {
5004 return $limitofcard;
5005 }
5006
5007 $kaiin_id = $this->get_quick_kaiin_id( $member_id );
5008 $kaiin_pass = $this->get_quick_pass( $member_id );
5009
5010 if ( ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) {
5011 /* e-SCOTT 会員�
5012 �会 */
5013 $response_member = $this->escott_member_reference( $member_id, $kaiin_id, $kaiin_pass );
5014 if ( 'OK' === $response_member['ResponseCd'] ) {
5015 $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 );
5016 $expmm = substr( $response_member['CardExp'], 2, 2 );
5017 $limit = $expyy . $expmm;
5018 $now = date_i18n( 'Ym', current_time( 'timestamp', 0 ) );
5019 $limitofcard = $expmm . '/' . substr( $response_member['CardExp'], 0, 2 );
5020 if ( $limit <= $now ) {
5021 $limitofcard .= '<br /><a href="javascript:void(0)" onClick="uscesMail.getMailData( \'' . $member_id . '\', \'' . $order_id . '\' )">' . __( 'Update Request Email', 'dlseller' ) . '</a>';
5022 }
5023 }
5024 } else {
5025 $limitofcard = '';
5026 }
5027 }
5028 return $limitofcard;
5029 }
5030
5031 /**
5032 * 継続課金会員リスト「契約」
5033 * dlseller_filter_continue_member_list_continue_status
5034 *
5035 * @param string $status Continuation status.
5036 * @param int $member_id Member ID.
5037 * @param int $order_id Order number.
5038 * @param array $meta_data Continuation data.
5039 * @return string
5040 */
5041 public function continue_member_list_continue_status( $status, $member_id, $order_id, $meta_data ) {
5042 return $status;
5043 }
5044
5045 /**
5046 * 継続課金会員リスト「状�
5047 �」
5048 * dlseller_filter_continue_member_list_condition
5049 *
5050 * @param string $condition Continuation condition.
5051 * @param int $member_id Member ID.
5052 * @param int $order_id Order number.
5053 * @param array $meta_data Continuation data.
5054 * @return string
5055 */
5056 public function continue_member_list_condition( $condition, $member_id, $order_id, $meta_data ) {
5057 global $usces;
5058
5059 $order_data = $usces->get_order_data( $order_id, 'direct' );
5060 $payment = $usces->getPayments( $order_data['order_payment_name'] );
5061 if ( isset( $payment['settlement'] ) && 'acting_welcart_card' === $payment['settlement'] ) {
5062 $url = admin_url( 'admin.php?page=usces_continue&continue_action=settlement&member_id=' . $member_id . '&order_id=' . $order_id );
5063 $condition = '<a href="' . $url . '">' . __( 'Detail', 'usces' ) . '</a>';
5064
5065 if ( 'continuation' === $meta_data['status'] ) {
5066 $status = $this->get_latest_status( $member_id, $order_id );
5067 if ( ! empty( $status ) && 'OK' !== $status ) {
5068 $condition .= '<div class="acting-status card-error">' . __( 'Settlement error', 'usces' ) . '</div>';
5069 }
5070 }
5071 }
5072 return $condition;
5073 }
5074
5075 /**
5076 * 継続課金会員決済状況ページ表示
5077 * dlseller_action_continue_member_list_page
5078 *
5079 * @param string $continue_action Continuation action.
5080 */
5081 public function continue_member_list_page( $continue_action ) {
5082 if ( 'settlement' === $continue_action ) {
5083 $member_id = filter_input( INPUT_GET, 'member_id' );
5084 $order_id = filter_input( INPUT_GET, 'order_id' );
5085 if ( ! is_null( $member_id ) && ! is_null( $order_id ) ) {
5086 $this->continue_member_settlement_info_page( $member_id, $order_id );
5087 exit();
5088 }
5089 }
5090 }
5091
5092 /**
5093 * 継続課金会員決済状況ページ
5094 *
5095 * @param int $member_id Member ID.
5096 * @param int $order_id Order number.
5097 */
5098 public function continue_member_settlement_info_page( $member_id, $order_id ) {
5099 global $usces;
5100
5101 if ( version_compare( WCEX_DLSELLER_VERSION, '3.0-beta', '<=' ) ) {
5102 $continue_data = usces_unserialize( $usces->get_member_meta_value( 'continuepay_' . $order_id, $member_id ) );
5103 } else {
5104 $continue_data = $this->get_continuation_data( $order_id, $member_id );
5105 }
5106 $curent_url = $_SERVER['REQUEST_URI'];
5107 $navibutton = '<a href="' . esc_url( $_SERVER['HTTP_REFERER'] ) . '" class="back-list"><span class="dashicons dashicons-list-view"></span>' . __( 'Back to the continue members list', 'dlseller' ) . '</a>';
5108
5109 $order_data = $usces->get_order_data( $order_id, 'direct' );
5110 if ( ! $order_data ) {
5111 return;
5112 }
5113
5114 $member_info = $usces->get_member_info( $member_id );
5115 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
5116 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_card', $order_id ) );
5117
5118 $payment = $usces->getPayments( $order_data['order_payment_name'] );
5119 if ( 'acting_welcart_card' !== $payment['settlement'] ) {
5120 return;
5121 }
5122
5123 $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
5124 if ( ! empty( $contracted_date ) ) {
5125 list( $contracted_year, $contracted_month, $contracted_day ) = explode( '-', $contracted_date );
5126 } else {
5127 $contracted_year = 0;
5128 $contracted_month = 0;
5129 $contracted_day = 0;
5130 }
5131 $charged_date = ( empty( $continue_data['chargedday'] ) ) ? dlseller_next_charging( $order_id ) : $continue_data['chargedday'];
5132 if ( ! empty( $charged_date ) ) {
5133 list( $charged_year, $charged_month, $charged_day ) = explode( '-', $charged_date );
5134 } else {
5135 $charged_year = 0;
5136 $charged_month = 0;
5137 $charged_day = 0;
5138 }
5139 $year = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 4 );
5140 $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'];
5141
5142 $log_data = $this->get_acting_log( $order_id );
5143 $num = ( $log_data ) ? count( $log_data ) + 1 : 1;
5144
5145 $kaiin_id = $this->get_quick_kaiin_id( $member_id );
5146 $card = ( empty( $kaiin_id ) ) ? '&nbsp;<span id="settlement-status"><span class="acting-status card-error">' . __( 'Card unregistered', 'usces' ) . '</span></span>' : '';
5147 ?>
5148 <div class="wrap">
5149 <div class="usces_admin">
5150 <h1>Welcart Management <?php esc_html_e( 'Continuation charging member information', 'dlseller' ); ?></h1>
5151 <p class="version_info">Version <?php echo esc_html( WCEX_DLSELLER_VERSION ); ?></p>
5152 <?php usces_admin_action_status(); ?>
5153 <div class="edit_pagenav"><?php echo wp_kses_post( $navibutton ); ?></div>
5154 <div id="datatable">
5155 <div id="tablesearch" class="usces_tablesearch">
5156 <div id="searchBox" style="display:block">
5157 <table class="search_table">
5158 <tr>
5159 <td class="label"><?php esc_html_e( 'Continuation charging information', 'dlseller' ); ?></td>
5160 <td>
5161 <table class="order_info">
5162 <tr>
5163 <th><?php esc_html_e( 'Member ID', 'dlseller' ); ?></th>
5164 <td><?php echo esc_html( $member_id ); ?><?php echo wp_kses_post( $card ); ?></td>
5165 <th><?php esc_html_e( 'Contractor name', 'dlseller' ); ?></th>
5166 <td><?php echo esc_html( $name ); ?></td>
5167 </tr>
5168 <tr>
5169 <th><?php esc_html_e( 'Order ID', 'dlseller' ); ?></th>
5170 <td><?php echo esc_html( $order_id ); ?></td>
5171 <th><?php esc_html_e( 'Application Date', 'dlseller' ); ?></th>
5172 <td><?php echo esc_html( $order_data['order_date'] ); ?></td>
5173 </tr>
5174 <tr>
5175 <th><?php esc_html_e( 'Renewal Date', 'dlseller' ); ?></th>
5176 <td>
5177 <select id="contracted-year">
5178 <option value="0"<?php selected( (int) $contracted_year, 0 ); ?>></option>
5179 <?php for ( $i = 0; $i <= 10; $i++ ) : ?>
5180 <option value="<?php echo esc_attr( $year + $i ); ?>"<?php selected( (int) $contracted_year, ( (int) $year + $i ) ); ?>><?php echo esc_html( (int) $year + $i ); ?></option>
5181 <?php endfor; ?>
5182 </select>-<select id="contracted-month">
5183 <option value="0"<?php selected( (int) $contracted_month, 0 ); ?>></option>
5184 <?php for ( $i = 1; $i <= 12; $i++ ) : ?>
5185 <option value="<?php printf( '%02d', $i ); ?>"<?php selected( (int) $contracted_month, $i ); ?>><?php printf( '%2d', $i ); ?></option>
5186 <?php endfor; ?>
5187 </select>-<select id="contracted-day">
5188 <option value="0"<?php selected( $contracted_day, 0 ); ?>></option>
5189 <?php for ( $i = 1; $i <= 31; $i++ ) : ?>
5190 <option value="<?php printf( '%02d', $i ); ?>"<?php selected( (int) $contracted_day, $i ); ?>><?php printf( '%2d', $i ); ?></option>
5191 <?php endfor; ?>
5192 </select>
5193 </td>
5194 <th><?php esc_html_e( 'Next Withdrawal Date', 'dlseller' ); ?></th>
5195 <td>
5196 <select id="charged-year">
5197 <option value="0"<?php selected( (int) $charged_year, 0 ); ?>></option>
5198 <option value="<?php echo esc_attr( $year ); ?>"<?php selected( (int) $charged_year, (int) $year ); ?>><?php echo esc_html( $year ); ?></option>
5199 <option value="<?php echo esc_attr( $year + 1 ); ?>"<?php selected( (int) $charged_year, ( (int) $year + 1 ) ); ?>><?php echo esc_html( (int) $year + 1 ); ?></option>
5200 </select>-<select id="charged-month">
5201 <option value="0"<?php selected( (int) $charged_month, 0 ); ?>></option>
5202 <?php for ( $i = 1; $i <= 12; $i++ ) : ?>
5203 <option value="<?php printf( '%02d', $i ); ?>"<?php selected( (int) $charged_month, $i ); ?>><?php printf( '%2d', $i ); ?></option>
5204 <?php endfor; ?>
5205 </select>-<select id="charged-day">
5206 <option value="0"<?php selected( $charged_day, 0 ); ?>></option>
5207 <?php for ( $i = 1; $i <= 31; $i++ ) : ?>
5208 <option value="<?php printf( '%02d', $i ); ?>"<?php selected( (int) $charged_day, $i ); ?>><?php printf( '%2d', $i ); ?></option>
5209 <?php endfor; ?>
5210 </select>
5211 </td>
5212 </tr>
5213 <tr>
5214 <th><?php esc_html_e( 'Amount on order', 'usces' ); ?></th>
5215 <td><?php usces_crform( $continue_data['order_price'], false ); ?></td>
5216 <th><?php esc_html_e( 'Settlement amount', 'usces' ); ?></th>
5217 <td><input type="text" id="price" style="text-align: right;" value="<?php usces_crform( $continue_data['price'], false, false, '', false ); ?>"><?php usces_crcode(); ?></td>
5218 </tr>
5219 <tr>
5220 <th><?php esc_html_e( 'Status', 'dlseller' ); ?></th>
5221 <td><select id="dlseller-status">
5222 <?php
5223 ob_start();
5224 if ( 'continuation' === $continue_data['status'] ) :
5225 ?>
5226 <option value="continuation" selected="selected"><?php esc_html_e( 'Continuation', 'dlseller' ); ?></option>
5227 <option value="cancellation"><?php esc_html_e( 'Stop', 'dlseller' ); ?></option>
5228 <?php
5229 else :
5230 ?>
5231 <option value="cancellation" selected="selected"><?php esc_html_e( 'Cancellation', 'dlseller' ); ?></option>
5232 <option value="continuation"><?php esc_html_e( 'Resumption', 'dlseller' ); ?></option>
5233 <?php
5234 endif;
5235 $dlseller_status_options = ob_get_contents();
5236 ob_end_clean();
5237 $dlseller_status_options = apply_filters( 'usces_filter_continuation_charging_status_options', $dlseller_status_options, $continue_data );
5238 wel_esc_script_e( $dlseller_status_options );
5239 ?>
5240 </select></td>
5241 <td colspan="2"><input id="continuation-update" type="button" class="button button-primary" value="<?php esc_attr_e( 'Update' ); ?>" /></td>
5242 </tr>
5243 </table>
5244 <?php do_action( 'usces_action_continuation_charging_information', $continue_data, $member_id, $order_id ); ?>
5245 </td>
5246 </tr>
5247 </table>
5248 </div><!-- searchBox -->
5249 </div><!-- tablesearch -->
5250 <table id="mainDataTable" class="new-table order-new-table">
5251 <thead>
5252 <tr>
5253 <th scope="col">&nbsp;</th>
5254 <th scope="col"><?php esc_html_e( 'Processing date', 'usces' ); ?></th>
5255 <th scope="col"><?php esc_html_e( 'Transaction ID', 'usces' ); ?></th>
5256 <th scope="col"><?php esc_html_e( 'Settlement amount', 'usces' ); ?></th>
5257 <th scope="col"><?php esc_html_e( 'Processing classification', 'usces' ); ?></th>
5258 <th scope="col">&nbsp;</th>
5259 </tr>
5260 </thead>
5261 <?php
5262 foreach ( (array) $log_data as $log_row ) :
5263 $log = $this->get_acting_latest_log( $log_row['log_key'], 'ALL' );
5264 if ( isset( $log['OperateId'] ) && isset( $log['ResponseCd'] ) && 'OK' === $log['ResponseCd'] ) {
5265 $class = ' card-' . mb_strtolower( substr( $log['OperateId'], 1 ) );
5266 $status_name = $this->get_operate_name( $log['OperateId'] );
5267 $merchantfree1 = $log['MerchantFree1'];
5268 $responsecd = '';
5269 $amount = ( isset( $log['Amount'] ) ) ? usces_crform( $log['Amount'], false, true, 'return', true ) : '';
5270 } else {
5271 $class = ' card-error';
5272 $status_name = __( 'Settlement error', 'usces' );
5273 if ( isset( $log_row['log'] ) ) {
5274 $log = usces_unserialize( $log_row['log'] );
5275 if ( isset( $log['MerchantFree1'] ) ) {
5276 $merchantfree1 = $log['MerchantFree1'];
5277 } else {
5278 $log_key = explode( '_', $log_row['log_key'] );
5279 $merchantfree1 = ( isset( $log_key[1] ) ) ? $log_key[1] : '9999999999';
5280 }
5281 $responsecd = $log['ResponseCd'];
5282 $amount = ( isset( $log['Amount'] ) ) ? usces_crform( $log['Amount'], false, true, 'return', true ) : '';
5283 } else {
5284 $log_key = explode( '_', $log_row['log_key'] );
5285 $merchantfree1 = ( isset( $log_key[1] ) ) ? $log_key[1] : '9999999999';
5286 $responsecd = 'NG';
5287 $amount = '';
5288 }
5289 }
5290 ?>
5291 <tbody>
5292 <tr>
5293 <td><?php echo esc_html( $num ); ?></td>
5294 <td><?php echo esc_html( $log_row['datetime'] ); ?></td>
5295 <td><?php echo esc_html( $merchantfree1 ); ?></td>
5296 <td class="amount"><?php echo esc_html( $amount ); ?></td>
5297 <?php
5298 if ( ! empty( $status_name ) ) :
5299 ?>
5300 <td><span id="settlement-status-<?php echo esc_attr( $num ); ?>"><span class="acting-status<?php echo esc_attr( $class ); ?>"><?php echo esc_html( $status_name ); ?></span></span></td>
5301 <td>
5302 <input type="button" id="settlement-information-<?php echo esc_attr( $merchantfree1 ); ?>-<?php echo esc_attr( $num ); ?>" class="button settlement-information" value="<?php esc_attr_e( 'Settlement info', 'usces' ); ?>">
5303 <input type="hidden" id="responsecd-<?php echo esc_attr( $merchantfree1 ); ?>-<?php echo esc_attr( $num ); ?>" value="<?php echo esc_attr( $responsecd ); ?>">
5304 </td>
5305 <?php
5306 else :
5307 ?>
5308 <td>&nbsp;</td><td>&nbsp;</td>
5309 <?php
5310 endif;
5311 ?>
5312 </tr>
5313 </tbody>
5314 <?php
5315 $num--;
5316 endforeach;
5317 $trans_id = $usces->get_order_meta_value( 'trans_id', $order_id );
5318 $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id, 'ALL' );
5319 if ( $latest_log ) :
5320 $class = ' card-' . mb_strtolower( substr( $latest_log['OperateId'], 1 ) );
5321 $status_name = $this->get_operate_name( $latest_log['OperateId'] );
5322 if ( isset( $latest_log['Amount'] ) ) {
5323 $amount = usces_crform( $latest_log['Amount'], false, true, 'return', true );
5324 } elseif ( isset( $continue_data['order_price'] ) ) {
5325 $amount = usces_crform( $continue_data['order_price'], false, true, 'return', true );
5326 } else {
5327 $amount = '';
5328 }
5329 ?>
5330 <tbody>
5331 <tr>
5332 <td>1</td>
5333 <td><?php echo esc_html( $order_data['order_date'] ); ?></td>
5334 <td><?php echo esc_html( $trans_id ); ?></td>
5335 <td class="amount"><?php echo esc_html( $amount ); ?></td>
5336 <?php
5337 if ( ! empty( $status_name ) ) :
5338 ?>
5339 <td><span id="settlement-status-1"><span class="acting-status<?php echo esc_attr( $class ); ?>"><?php echo esc_html( $status_name ); ?></span></span></td>
5340 <td><input type="button" id="settlement-information-<?php echo esc_attr( $trans_id ); ?>-1" class="button settlement-information" value="<?php esc_attr_e( 'Settlement info', 'usces' ); ?>"></td>
5341 <?php
5342 else :
5343 ?>
5344 <td>&nbsp;</td><td>&nbsp;</td>
5345 <?php
5346 endif;
5347 ?>
5348 </tr>
5349 </tbody>
5350 <?php
5351 endif;
5352 ?>
5353 </table>
5354 </div><!--datatable-->
5355 <input name="member_id" type="hidden" id="member_id" value="<?php echo esc_attr( $member_id ); ?>" />
5356 <input name="order_id" type="hidden" id="order_id" value="<?php echo esc_attr( $order_id ); ?>" />
5357 <input name="usces_referer" type="hidden" id="usces_referer" value="<?php echo esc_url( $curent_url ); ?>" />
5358 <?php wp_nonce_field( 'order_edit', 'wc_nonce' ); ?>
5359 </div><!--usces_admin-->
5360 </div><!--wrap-->
5361 <?php
5362 $order_action = 'edit';
5363 $cart = array();
5364 $action_args = compact( 'order_action', 'order_id', 'cart' );
5365 $this->settlement_dialog( $order_data, $action_args );
5366 include ABSPATH . 'wp-admin/admin-footer.php';
5367 }
5368
5369 /**
5370 * 継続課金会員クレジットカード変更依頼メール
5371 * dlseller_filter_card_update_mail
5372 *
5373 * @param string $message Message.
5374 * @param int $member_id Member ID.
5375 * @param int $order_id Order number.
5376 * @return string
5377 */
5378 public function continue_member_card_update_mail( $message, $member_id, $order_id ) {
5379 global $usces;
5380
5381 $acting_opts = $this->get_acting_settings();
5382 if ( ! usces_is_membersystem_state() || 'on' !== $acting_opts['quickpay'] ) {
5383 return $message;
5384 }
5385
5386 $kaiin_id = $this->get_quick_kaiin_id( $member_id );
5387 $kaiin_pass = $this->get_quick_pass( $member_id );
5388
5389 if ( ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) {
5390 /* e-SCOTT 会員�
5391 �会 */
5392 $response_member = $this->escott_member_reference( $member_id, $kaiin_id, $kaiin_pass );
5393 if ( 'OK' === $response_member['ResponseCd'] ) {
5394 $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 );
5395 $expmm = substr( $response_member['CardExp'], 2, 2 );
5396
5397 $now = date_i18n( 'Ym', current_time( 'timestamp', 0 ) );
5398 $member_info = $usces->get_member_info( $member_id );
5399 $mail_data = usces_mail_data();
5400
5401 $nonsessionurl = usces_url( 'cartnonsession', 'return' );
5402 $parts = parse_url( $nonsessionurl );
5403 if ( isset( $parts['query'] ) ) {
5404 parse_str( $parts['query'], $query );
5405 }
5406 if ( false !== strpos( $nonsessionurl, '/usces-cart' ) ) {
5407 $nonsessionurl = str_replace( '/usces-cart', '/usces-member', $nonsessionurl );
5408 } elseif ( isset( $query['page_id'] ) && USCES_CART_NUMBER === $query['page_id'] ) {
5409 $nonsessionurl = str_replace( 'page_id=' . USCES_CART_NUMBER, 'page_id=' . USCES_MEMBER_NUMBER, $nonsessionurl );
5410 }
5411 $delim = ( false === strpos( $nonsessionurl, '?' ) ) ? '?' : '&';
5412
5413 $regd = $expyy . $expmm;
5414 if ( $regd === $now ) {
5415 $flag = 'NOW';
5416 } elseif ( $regd < $now ) {
5417 $flag = 'PASSED';
5418 } else {
5419 return $message;
5420 }
5421
5422 $exp = mktime( 0, 0, 0, $expmm, 1, $expyy );
5423 $limit = date_i18n( __( 'F, Y' ), $exp );
5424 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
5425
5426 $message = __( 'Member ID', 'dlseller' ) . ' : ' . $member_id . "\n";
5427 $message .= __( 'Contractor name', 'dlseller' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\n\n\n";
5428 $message .= __( 'Thank you very much for using our service.', 'dlseller' ) . "\r\n\r\n";
5429 $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";
5430 $message .= __( '---------------------------------------------------------', 'dlseller' ) . "\r\n";
5431 $message .= sprintf( __( 'Currently registered credit card expiration date is %s, ', 'dlseller' ), $limit ) . "\r\n";
5432 if ( 'NOW' === $flag ) {
5433 $message .= __( 'So you keep on this you will not be able to pay next month.', 'dlseller' ) . "\r\n";
5434 } else {
5435 $message .= __( 'So your payment of this month is outstanding payment.', 'dlseller' ) . "\r\n";
5436 }
5437 $message .= __( '---------------------------------------------------------', 'dlseller' ) . "\r\n\r\n";
5438 $message .= __( 'If you have received a new credit card, ', 'dlseller' ) . "\r\n";
5439 $message .= __( 'Please click the URL below and update the card information during this month.', 'dlseller' ) . "\r\n";
5440 $message .= __( 'Sorry for troubling you, please process it.', 'dlseller' ) . "\r\n\r\n\r\n";
5441 $message .= $nonsessionurl . $delim . 'dlseller_card_update=login&dlseller_up_mode=1&dlseller_order_id=' . $order_id . "\r\n";
5442 $message .= __( 'If the card information update procedure failed, please contact us at the following email address.', 'dlseller' ) . "\r\n\r\n";
5443 $message .= __( 'Thank you.', 'dlseller' ) . "\r\n\r\n\r\n";
5444 $message .= $mail_data['footer']['ordermail'];
5445 $message = apply_filters( 'usces_filter_continue_member_card_update_mail', $message, $member_id, $member_info );
5446 if ( function_exists( 'usces_is_html_mail' ) && usces_is_html_mail() ) {
5447 $message = do_shortcode( wpautop( $message ) );
5448 }
5449 }
5450 }
5451 return $message;
5452 }
5453
5454 /**
5455 * 自動継続課金処理
5456 * dlseller_action_do_continuation_charging
5457 *
5458 * @param string $today Today.
5459 * @param int $member_id Member ID.
5460 * @param int $order_id Order number.
5461 * @param array $continue_data Continuation data.
5462 */
5463 public function auto_continuation_charging( $today, $member_id, $order_id, $continue_data ) {
5464 global $usces;
5465
5466 $acting_opts = $this->get_acting_settings();
5467 if ( ! usces_is_membersystem_state() || 'on' !== $acting_opts['quickpay'] ) {
5468 return;
5469 }
5470
5471 if ( 0 >= $continue_data['price'] ) {
5472 return;
5473 }
5474
5475 $order_data = $usces->get_order_data( $order_id, 'direct' );
5476 if ( ! $order_data || $usces->is_status( 'cancel', $order_data['order_status'] ) ) {
5477 return;
5478 }
5479
5480 $payment = $usces->getPayments( $order_data['order_payment_name'] );
5481 if ( 'acting_welcart_card' !== $payment['settlement'] ) {
5482 return;
5483 }
5484
5485 $kaiin_id = $this->get_quick_kaiin_id( $member_id );
5486 $kaiin_pass = $this->get_quick_pass( $member_id );
5487 $rand = usces_acting_key();
5488
5489 if ( ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) {
5490 $transaction_date = $this->get_transaction_date();
5491 $param_list = array();
5492 $params_member = array();
5493 $params = array();
5494
5495 /* �
5496 �通部 */
5497 $param_list['MerchantId'] = $acting_opts['merchant_id'];
5498 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
5499 $param_list['TransactionDate'] = $transaction_date;
5500 $param_list['MerchantFree1'] = $rand;
5501 $param_list['MerchantFree2'] = $payment['settlement'];
5502 $param_list['MerchantFree3'] = $this->merchantfree3;
5503 $param_list['TenantId'] = $acting_opts['tenant_id'];
5504 $params_member['send_url'] = $acting_opts['send_url_member'];
5505 $params_member['param_list'] = array_merge(
5506 $param_list,
5507 array(
5508 'OperateId' => '4MemRefM',
5509 'KaiinId' => $kaiin_id,
5510 'KaiinPass' => $kaiin_pass,
5511 )
5512 );
5513 /* e-SCOTT 会員�
5514 �会 */
5515 $response_member = $this->connection( $params_member );
5516 if ( 'OK' === $response_member['ResponseCd'] ) {
5517 $params['send_url'] = $acting_opts['send_url'];
5518 $params['param_list'] = array_merge(
5519 $param_list,
5520 array(
5521 'OperateId' => $acting_opts['operateid_dlseller'],
5522 'Amount' => usces_crform( $continue_data['price'], false, false, 'return', false ),
5523 'PayType' => '01',
5524 'KaiinId' => $kaiin_id,
5525 'KaiinPass' => $kaiin_pass,
5526 )
5527 );
5528 /* e-SCOTT 決済 */
5529 $response_data = $this->connection( $params );
5530 if ( ! isset( $response_data['Amount'] ) ) {
5531 $response_data['Amount'] = $continue_data['price'];
5532 }
5533 $response_data = apply_filters( 'usces_filter_escott_auto_continuation_charging_history_log', $response_data, $member_id, $order_id, $continue_data );
5534 $this->save_acting_history_log( $response_data, $order_id . '_' . $rand );
5535 if ( 'OK' === $response_data['ResponseCd'] ) {
5536 $cardlast4 = substr( $response_member['CardNo'], -4 );
5537 $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 );
5538 $expmm = substr( $response_member['CardExp'], 2, 2 );
5539 $response_data['acting'] = $this->acting_card;
5540 $response_data['PayType'] = '01';
5541 $response_data['CardNo'] = $cardlast4;
5542 $response_data['CardExp'] = $expyy . '/' . $expmm;
5543 $this->save_acting_log( $response_data, $order_id . '_' . $rand );
5544 $this->auto_settlement_mail( $member_id, $order_id, $response_data, $continue_data );
5545 } else {
5546 $responsecd = explode( '|', $response_data['ResponseCd'] );
5547 foreach ( (array) $responsecd as $cd ) {
5548 $response_data[ $cd ] = $this->response_message( $cd );
5549 }
5550 $log = array(
5551 'acting' => $this->acting_card,
5552 'key' => $rand,
5553 'result' => $response_data['ResponseCd'],
5554 'data' => $response_data,
5555 );
5556 usces_save_order_acting_error( $log );
5557 $this->save_acting_log( $response_data, $order_id . '_' . $rand );
5558 $this->auto_settlement_error_mail( $member_id, $order_id, $response_data, $continue_data );
5559 }
5560 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $response_data );
5561 } else {
5562 if ( ! isset( $response_member['Amount'] ) ) {
5563 $response_member['Amount'] = $continue_data['price'];
5564 }
5565 $response_member = apply_filters( 'usces_filter_escott_auto_continuation_charging_history_log', $response_member, $member_id, $order_id, $continue_data );
5566 $this->save_acting_history_log( $response_member, $order_id . '_' . $rand );
5567 $responsecd = explode( '|', $response_member['ResponseCd'] );
5568 foreach ( (array) $responsecd as $cd ) {
5569 $response_member[ $cd ] = $this->response_message( $cd );
5570 }
5571 $log = array(
5572 'acting' => $this->acting_card . '(member_process)',
5573 'key' => $member_id,
5574 'result' => $response_member['ResponseCd'],
5575 'data' => $response_member,
5576 );
5577 usces_save_order_acting_error( $log );
5578 $this->save_acting_log( $response_member, $order_id . '_' . $rand );
5579 $this->auto_settlement_error_mail( $member_id, $order_id, $response_member, $continue_data );
5580 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $response_member );
5581 }
5582 } else {
5583 $logdata = array(
5584 'KaiinId' => $kaiin_id,
5585 'KaiinPass' => $kaiin_pass,
5586 );
5587 $log = array(
5588 'acting' => $this->acting_card . '(member_process)',
5589 'key' => $member_id,
5590 'result' => 'MEMBER ERROR',
5591 'data' => $logdata,
5592 );
5593 usces_save_order_acting_error( $log );
5594 $log['ResponseCd'] = 'NG';
5595 $log['MerchantFree1'] = $rand;
5596 $this->save_acting_log( $log, $order_id . '_' . $rand );
5597 $this->auto_settlement_error_mail( $member_id, $order_id, $logdata, $continue_data );
5598 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $log );
5599 }
5600 }
5601
5602 /**
5603 * 自動継続課金処理メール(正常)
5604 *
5605 * @param int $member_id Member ID.
5606 * @param int $order_id Order number.
5607 * @param array $response_data Response data.
5608 * @param array $continue_data Continuation data.
5609 */
5610 public function auto_settlement_mail( $member_id, $order_id, $response_data, $continue_data ) {
5611 global $usces;
5612
5613 $acting_opts = $this->get_acting_settings();
5614 $order_data = $usces->get_order_data( $order_id, 'direct' );
5615 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data, false );
5616
5617 if ( 'on' === $acting_opts['auto_settlement_mail'] ) {
5618 $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 );
5619 $member_info = $usces->get_member_info( $member_id );
5620 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
5621 $mail_data = usces_mail_data();
5622 $mail_header = '';
5623 if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
5624 $mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
5625 }
5626 $mail_header .= __( 'We will report automated accounting process was carried out as follows.', 'usces' ) . "\r\n\r\n";
5627 $mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
5628 $message = apply_filters( 'usces_filter_escott_auto_settlement_mail_header', $mail_header, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
5629 apply_filters( 'usces_filter_escott_auto_settlement_mail_body', $mail_body, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
5630 apply_filters( 'usces_filter_escott_auto_settlement_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $response_data, $continue_data );
5631 $headers = apply_filters( 'usces_filter_escott_auto_settlement_mail_headers', '' );
5632 $to_customer = array(
5633 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
5634 'to_address' => $member_info['mem_email'],
5635 'from_name' => get_option( 'blogname' ),
5636 'from_address' => $usces->options['sender_mail'],
5637 'reply_name' => get_option( 'blogname' ),
5638 'reply_to' => usces_get_first_order_mail(),
5639 'return_path' => $usces->options['sender_mail'],
5640 'subject' => $subject,
5641 'message' => do_shortcode( $message ),
5642 'headers' => $headers,
5643 );
5644 usces_send_mail( $to_customer );
5645 }
5646
5647 $ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
5648 $this->continuation_charging_mail['OK'] = $ok + 1;
5649 $this->continuation_charging_mail['mail'][] = $mail_body;
5650 }
5651
5652 /**
5653 * 自動継続課金処理メール(エラー)
5654 *
5655 * @param int $member_id Member ID.
5656 * @param int $order_id Order number.
5657 * @param array $response_data Response data.
5658 * @param array $continue_data Continuation data.
5659 */
5660 public function auto_settlement_error_mail( $member_id, $order_id, $response_data, $continue_data ) {
5661 global $usces;
5662
5663 $acting_opts = $this->get_acting_settings();
5664 $order_data = $usces->get_order_data( $order_id, 'direct' );
5665 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data, false );
5666
5667 if ( 'on' === $acting_opts['auto_settlement_mail'] ) {
5668 $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 );
5669 $member_info = $usces->get_member_info( $member_id );
5670 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
5671 $mail_data = usces_mail_data();
5672 $mail_header = '';
5673 if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
5674 $mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
5675 }
5676 $mail_header .= __( 'We will reported that an error occurred in automated accounting process.', 'usces' ) . "\r\n\r\n";
5677 $mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
5678 $message = apply_filters( 'usces_filter_escott_auto_settlement_error_mail_header', $mail_header, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
5679 apply_filters( 'usces_filter_escott_auto_settlement_error_mail_body', $mail_body, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
5680 apply_filters( 'usces_filter_escott_auto_settlement_error_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $response_data, $continue_data );
5681 $headers = apply_filters( 'usces_filter_escott_auto_settlement_error_mail_headers', '' );
5682 $to_customer = array(
5683 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
5684 'to_address' => $member_info['mem_email'],
5685 'from_name' => get_option( 'blogname' ),
5686 'from_address' => $usces->options['sender_mail'],
5687 'reply_name' => get_option( 'blogname' ),
5688 'reply_to' => usces_get_first_order_mail(),
5689 'return_path' => $usces->options['sender_mail'],
5690 'subject' => $subject,
5691 'message' => do_shortcode( $message ),
5692 'headers' => $headers,
5693 );
5694 usces_send_mail( $to_customer );
5695 }
5696
5697 $error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
5698 $this->continuation_charging_mail['NG'] = $error + 1;
5699 $this->continuation_charging_mail['mail'][] = $mail_body;
5700 }
5701
5702 /**
5703 * 自動継続課金処理メール本文
5704 *
5705 * @param int $member_id Member ID.
5706 * @param int $order_id Order number.
5707 * @param array $order_data Order data.
5708 * @param array $response_data Response data.
5709 * @param array $continue_data Continuation data.
5710 * @param boolean $html HTML Mail.
5711 * @return string
5712 */
5713 public function auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data, $html = true ) {
5714 global $usces;
5715
5716 if ( usces_is_html_mail() && $html ) {
5717 $message = $this->auto_settlement_message_htmlbody( $member_id, $order_id, $order_data, $response_data, $continue_data );
5718 } else {
5719 $member_info = $usces->get_member_info( $member_id );
5720 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
5721 $contracted_date = ( isset( $continue_data['contractedday'] ) ) ? $continue_data['contractedday'] : '';
5722 $charged_date = ( isset( $continue_data['chargedday'] ) ) ? $continue_data['chargedday'] : '';
5723
5724 $message = usces_mail_line( 2 );
5725 $message .= __( 'Order ID', 'dlseller' ) . ' : ' . $order_id . "\r\n";
5726 $message .= __( 'Application Date', 'dlseller' ) . ' : ' . $order_data['order_date'] . "\r\n";
5727 $message .= __( 'Member ID', 'dlseller' ) . ' : ' . $member_id . "\r\n";
5728 $message .= __( 'Contractor name', 'dlseller' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
5729
5730 $cart = usces_get_ordercartdata( $order_id );
5731 $cart_row = current( $cart );
5732 $item_name = $usces->getCartItemName_byOrder( $cart_row );
5733 $options = ( empty( $cart_row['options'] ) ) ? array() : $cart_row['options'];
5734 $message .= __( 'Items', 'usces' ) . ' : ' . $item_name . "\r\n";
5735 if ( is_array( $options ) && count( $options ) > 0 ) {
5736 $optstr = '';
5737 foreach ( $options as $key => $value ) {
5738 if ( ! empty( $key ) ) {
5739 $key = urldecode( $key );
5740 $value = maybe_unserialize( $value );
5741 if ( is_array( $value ) ) {
5742 $c = '';
5743 $optstr .= '( ' . $key . ' : ';
5744 foreach ( $value as $v ) {
5745 $optstr .= $c . rawurldecode( $v );
5746 $c = ', ';
5747 }
5748 $optstr .= " )\r\n";
5749 } else {
5750 $optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . " )\r\n";
5751 }
5752 }
5753 }
5754 $message .= $optstr;
5755 }
5756
5757 $message .= __( 'Settlement amount', 'usces' ) . ' : ' . usces_crform( $continue_data['price'], true, false, 'return' ) . "\r\n";
5758 if ( isset( $response_data['reminder'] ) ) {
5759 if ( ! empty( $charged_date ) ) {
5760 $message .= __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . $charged_date . "\r\n";
5761 }
5762 if ( ! empty( $contracted_date ) ) {
5763 $message .= __( 'Renewal Date', 'dlseller' ) . ' : ' . $contracted_date . "\r\n";
5764 }
5765 } else {
5766 if ( isset( $response_data['MerchantFree1'] ) ) {
5767 $message .= __( 'Transaction ID', 'usces' ) . ' : ' . $response_data['MerchantFree1'] . "\r\n";
5768 }
5769 if ( isset( $response_data['TransactionId'] ) ) {
5770 $message .= __( 'Sequence number', 'usces' ) . ' : ' . $response_data['TransactionId'] . "\r\n";
5771 }
5772 if ( ! empty( $charged_date ) ) {
5773 $message .= __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . $charged_date . "\r\n";
5774 }
5775 if ( ! empty( $contracted_date ) ) {
5776 $message .= __( 'Renewal Date', 'dlseller' ) . ' : ' . $contracted_date . "\r\n";
5777 }
5778 $message .= "\r\n";
5779 if ( isset( $response_data['ResponseCd'] ) ) {
5780 if ( 'OK' === $response_data['ResponseCd'] ) {
5781 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Normal done', 'usces' ) . "\r\n";
5782 } else {
5783 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Error', 'usces' ) . "\r\n";
5784 $responsecd = explode( '|', $response_data['ResponseCd'] );
5785 foreach ( (array) $responsecd as $cd ) {
5786 $message .= $cd . ' : ' . $this->response_message( $cd ) . "\r\n";
5787 }
5788 }
5789 } else {
5790 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Error', 'usces' ) . "\r\n";
5791 $message .= __( 'Credit card is not registered.', 'usces' ) . "\r\n";
5792 }
5793 }
5794 $message .= usces_mail_line( 2 ) . "\r\n";
5795 }
5796 return $message;
5797 }
5798
5799 /**
5800 * Automatic renewal billing process email body html
5801 *
5802 * @param int $member_id Member ID.
5803 * @param int $order_id Order number.
5804 * @param array $order_data Order data.
5805 * @param array $response_data Response data.
5806 * @param array $continue_data Continuation data.
5807 * @return string
5808 */
5809 public function auto_settlement_message_htmlbody( $member_id, $order_id, $order_data, $response_data, $continue_data ) {
5810 global $usces;
5811
5812 $member_info = $usces->get_member_info( $member_id );
5813 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
5814 $contracted_date = ( isset( $continue_data['contractedday'] ) ) ? $continue_data['contractedday'] : '';
5815 $charged_date = ( isset( $continue_data['chargedday'] ) ) ? $continue_data['chargedday'] : '';
5816
5817 $message = '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;"><tbody>';
5818 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5819 $message .= __( 'Order ID', 'dlseller' );
5820 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5821 $message .= $order_id;
5822 $message .= '</td></tr>';
5823
5824 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5825 $message .= __( 'Application Date', 'dlseller' );
5826 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5827 $message .= $order_data['order_date'];
5828 $message .= '</td></tr>';
5829
5830 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5831 $message .= __( 'Member ID', 'dlseller' );
5832 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5833 $message .= $member_id;
5834 $message .= '</td></tr>';
5835
5836 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5837 $message .= __( 'Contractor name', 'dlseller' );
5838 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5839 $message .= sprintf( _x( '%s', 'honorific', 'usces' ), $name );
5840 $message .= '</td></tr>';
5841
5842 $cart = usces_get_ordercartdata( $order_id );
5843 $cart_row = current( $cart );
5844 $item_name = $usces->getCartItemName_byOrder( $cart_row );
5845 $options = ( empty( $cart_row['options'] ) ) ? array() : $cart_row['options'];
5846 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5847 $message .= __( 'Items', 'usces' );
5848 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5849 $message .= $item_name;
5850 if ( is_array( $options ) && count( $options ) > 0 ) {
5851 $optstr = '';
5852 foreach ( $options as $key => $value ) {
5853 if ( ! empty( $key ) ) {
5854 $key = urldecode( $key );
5855 $value = maybe_unserialize( $value );
5856 if ( is_array( $value ) ) {
5857 $c = '';
5858 $optstr .= '( ' . $key . ' : ';
5859 foreach ( $value as $v ) {
5860 $optstr .= $c . rawurldecode( $v );
5861 $c = ', ';
5862 }
5863 $optstr .= ' )<br>';
5864 } else {
5865 $optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . ' )<br>';
5866 }
5867 }
5868 }
5869 $message .= $optstr;
5870 }
5871 $message .= '</td></tr>';
5872
5873 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5874 $message .= __( 'Settlement amount', 'usces' );
5875 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5876 $message .= usces_crform( $continue_data['price'], true, false, 'return' );
5877 $message .= '</td></tr>';
5878 if ( isset( $response_data['reminder'] ) ) {
5879 if ( ! empty( $charged_date ) ) {
5880 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5881 $message .= __( 'Next Withdrawal Date', 'dlseller' );
5882 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5883 $message .= $charged_date;
5884 $message .= '</td></tr>';
5885 }
5886 if ( ! empty( $contracted_date ) ) {
5887 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5888 $message .= __( 'Renewal Date', 'dlseller' );
5889 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5890 $message .= $contracted_date;
5891 $message .= '</td></tr>';
5892 }
5893 } else {
5894 if ( isset( $response_data['MerchantFree1'] ) ) {
5895 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5896 $message .= __( 'Transaction ID', 'usces' );
5897 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5898 $message .= $response_data['MerchantFree1'];
5899 $message .= '</td></tr>';
5900 }
5901 if ( isset( $response_data['TransactionId'] ) ) {
5902 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5903 $message .= __( 'Sequence number', 'usces' );
5904 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5905 $message .= $response_data['TransactionId'];
5906 $message .= '</td></tr>';
5907 }
5908 if ( ! empty( $charged_date ) ) {
5909 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5910 $message .= __( 'Next Withdrawal Date', 'dlseller' );
5911 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5912 $message .= $charged_date;
5913 $message .= '</td></tr>';
5914 }
5915 if ( ! empty( $contracted_date ) ) {
5916 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5917 $message .= __( 'Renewal Date', 'dlseller' );
5918 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5919 $message .= $contracted_date;
5920 $message .= '</td></tr>';
5921 }
5922 if ( isset( $response_data['ResponseCd'] ) ) {
5923 if ( 'OK' === $response_data['ResponseCd'] ) {
5924 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5925 $message .= __( 'Result', 'usces' );
5926 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5927 $message .= __( 'Normal done', 'usces' );
5928 $message .= '</td></tr>';
5929 } else {
5930 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5931 $message .= __( 'Result', 'usces' );
5932 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5933 $message .= __( 'Error', 'usces' );
5934 $responsecd = explode( '|', $response_data['ResponseCd'] );
5935 foreach ( (array) $responsecd as $cd ) {
5936 $message .= $cd . ' : ' . $this->response_message( $cd ) . '<br>';
5937 }
5938 $message .= '</td></tr>';
5939 }
5940 } else {
5941 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
5942 $message .= __( 'Result', 'usces' );
5943 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
5944 $message .= __( 'Error', 'usces' ) . '<br>';
5945 $message .= __( 'Credit card is not registered.', 'usces' );
5946 $message .= '</td></tr>';
5947 }
5948 }
5949 $message .= '</tbody></table>';
5950 return $message;
5951 }
5952
5953 /**
5954 * 自動継続課金処理
5955 * dlseller_action_do_continuation
5956 *
5957 * @param string $today Today.
5958 * @param array $todays_charging Charged data.
5959 */
5960 public function do_auto_continuation( $today, $todays_charging ) {
5961 global $usces;
5962
5963 if ( empty( $todays_charging ) ) {
5964 return;
5965 }
5966
5967 $ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
5968 $error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
5969 $admin_subject = apply_filters( 'usces_filter_escott_auto_settlement_mail_admin_subject', __( 'Automatic Continuing Charging Process Result', 'usces' ) . ' ' . $today, $today );
5970 $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' ) );
5971 $admin_message = __( 'Report that automated accounting process has been completed.', 'usces' ) . "\r\n\r\n"
5972 . __( 'Processing date', 'usces' ) . ' : ' . date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "\r\n"
5973 . __( 'Normal done', 'usces' ) . ' : ' . $ok . "\r\n"
5974 . __( 'Abnormal done', 'usces' ) . ' : ' . $error . "\r\n\r\n";
5975 foreach ( (array) $this->continuation_charging_mail['mail'] as $mail ) {
5976 $admin_message .= $mail . "\r\n";
5977 }
5978 $admin_message .= $admin_footer . "\r\n";
5979
5980 $to_admin = array(
5981 'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
5982 'to_address' => $usces->options['order_mail'],
5983 'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
5984 'from_address' => $usces->options['sender_mail'],
5985 'reply_name' => get_option( 'blogname' ),
5986 'reply_to' => usces_get_first_order_mail(),
5987 'return_path' => $usces->options['sender_mail'],
5988 'subject' => $admin_subject,
5989 'message' => do_shortcode( $admin_message ),
5990 );
5991 usces_send_mail( $to_admin );
5992 unset( $this->continuation_charging_mail );
5993 }
5994
5995 /**
5996 * 課金日通知メール
5997 * dlseller_filter_reminder_mail_body
5998 *
5999 * @param string $mail_body Message body.
6000 * @param int $order_id Order number.
6001 * @param array $continue_data Continuation data.
6002 */
6003 public function reminder_mail_body( $mail_body, $order_id, $continue_data ) {
6004 global $usces;
6005
6006 $member_id = $continue_data['member_id'];
6007 $order_id = $continue_data['order_id'];
6008 $order_data = $usces->get_order_data( $order_id, 'direct' );
6009 $response_data = array( 'reminder' => 'reminder' );
6010 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data );
6011 return $mail_body;
6012 }
6013
6014 /**
6015 * 契約更新日通知メール
6016 * dlseller_filter_contract_renewal_mail_body
6017 *
6018 * @param string $mail_body Message body.
6019 * @param int $order_id Order number.
6020 * @param array $continue_data Continuation data.
6021 */
6022 public function contract_renewal_mail_body( $mail_body, $order_id, $continue_data ) {
6023 global $usces;
6024
6025 $member_id = $continue_data['member_id'];
6026 $order_data = $usces->get_order_data( $order_id, 'direct' );
6027 $response_data = array( 'reminder' => 'contract_renewal' );
6028 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data );
6029 return $mail_body;
6030 }
6031
6032 /**
6033 * 利用可能な支払方法
6034 * wcad_filter_available_regular_payment_method
6035 *
6036 * @param array $payment_method Payment method.
6037 * @return array
6038 */
6039 public function available_regular_payment_method( $payment_method ) {
6040 $acting_opts = $this->get_acting_settings();
6041 if ( isset( $acting_opts['quickpay'] ) && 'on' === $acting_opts['quickpay'] ) {
6042 $payment_method[] = 'acting_welcart_card';
6043 }
6044 return $payment_method;
6045 }
6046
6047 /**
6048 * 発送�
6049 �リスト利用可能決済
6050 * wcad_filter_shippinglist_acting
6051 *
6052 * @param string $acting Payment method.
6053 * @return string
6054 */
6055 public function set_shippinglist_acting( $acting ) {
6056 $acting = 'acting_welcart_card';
6057 return $acting;
6058 }
6059
6060 /**
6061 * 定期購�
6062 �決済処理
6063 * wcad_action_reg_auto_orderdata
6064 *
6065 * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $total_amount, $reg_id, $order_date ).
6066 */
6067 public function register_auto_orderdata( $args ) {
6068 global $usces;
6069 extract( $args ); // phpcs:ignore
6070
6071 $acting_opts = $this->get_acting_settings();
6072 if ( ! usces_is_membersystem_state() || 'on' !== $acting_opts['quickpay'] ) {
6073 return;
6074 }
6075
6076 if ( 0 >= $total_amount ) {
6077 return;
6078 }
6079
6080 $acting_flg = $payments['settlement'];
6081 if ( 'acting_welcart_card' !== $payments['settlement'] ) {
6082 return;
6083 }
6084
6085 $settltment_errmsg = '';
6086 $kaiin_id = $this->get_quick_kaiin_id( $member_id );
6087 $kaiin_pass = $this->get_quick_pass( $member_id );
6088 $rand = usces_acting_key();
6089
6090 if ( ! empty( $kaiin_id ) && ! empty( $kaiin_pass ) ) {
6091 $transaction_date = $this->get_transaction_date();
6092 $param_list = array();
6093 $params_member = array();
6094 $params = array();
6095
6096 /* �
6097 �通部 */
6098 $param_list['MerchantId'] = $acting_opts['merchant_id'];
6099 $param_list['MerchantPass'] = $acting_opts['merchant_pass'];
6100 $param_list['TransactionDate'] = $transaction_date;
6101 $param_list['MerchantFree1'] = $rand;
6102 $param_list['MerchantFree2'] = 'acting_welcart_card';
6103 $param_list['MerchantFree3'] = $this->merchantfree3;
6104 $param_list['TenantId'] = $acting_opts['tenant_id'];
6105 $params_member['send_url'] = $acting_opts['send_url_member'];
6106 $params_member['param_list'] = array_merge(
6107 $param_list,
6108 array(
6109 'OperateId' => '4MemRefM',
6110 'KaiinId' => $kaiin_id,
6111 'KaiinPass' => $kaiin_pass,
6112 )
6113 );
6114 /* e-SCOTT 会員�
6115 �会 */
6116 $response_member = $this->connection( $params_member );
6117 if ( 'OK' === $response_member['ResponseCd'] ) {
6118 $params['send_url'] = $acting_opts['send_url'];
6119 $params['param_list'] = array_merge(
6120 $param_list,
6121 array(
6122 'OperateId' => $acting_opts['operateid'],
6123 'Amount' => $total_amount,
6124 'PayType' => '01',
6125 'KaiinId' => $kaiin_id,
6126 'KaiinPass' => $kaiin_pass,
6127 )
6128 );
6129 /* e-SCOTT 決済 */
6130 $response_data = $this->connection( $params );
6131 if ( ! isset( $response_data['Amount'] ) ) {
6132 $response_data['Amount'] = $total_amount;
6133 }
6134 $response_data = apply_filters( 'usces_filter_escott_auto_register_orderdata_history_log', $response_data, $member_id, $order_id );
6135 $this->save_acting_history_log( $response_data, $order_id . '_' . $rand );
6136 if ( 'OK' === $response_data['ResponseCd'] ) {
6137 $usces->set_order_meta_value( 'trans_id', $rand, $order_id );
6138 $usces->set_order_meta_value( 'wc_trans_id', $rand, $order_id );
6139 $cardlast4 = substr( $response_member['CardNo'], -4 );
6140 $expyy = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 2 ) . substr( $response_member['CardExp'], 0, 2 );
6141 $expmm = substr( $response_member['CardExp'], 2, 2 );
6142 $response_data['acting'] = $this->acting_card;
6143 $response_data['PayType'] = '01';
6144 $response_data['CardNo'] = $cardlast4;
6145 $response_data['CardExp'] = $expyy . '/' . $expmm;
6146 $usces->set_order_meta_value( $acting_flg, usces_serialize( $response_data ), $order_id );
6147 } else {
6148 $settltment_errmsg = __( '[Regular purchase] Settlement was not completed.', 'autodelivery' );
6149 $responsecd = explode( '|', $response_data['ResponseCd'] );
6150 foreach ( (array) $responsecd as $cd ) {
6151 $response_data[ $cd ] = $this->response_message( $cd );
6152 }
6153 $log = array(
6154 'acting' => $this->acting_card,
6155 'key' => $rand,
6156 'result' => $response_data['ResponseCd'],
6157 'data' => $response_data,
6158 );
6159 usces_save_order_acting_error( $log );
6160 }
6161 do_action( 'usces_action_register_auto_orderdata', $args, $response_data );
6162 } else {
6163 if ( ! isset( $response_member['Amount'] ) ) {
6164 $response_member['Amount'] = $total_amount;
6165 }
6166 $response_member = apply_filters( 'usces_filter_escott_auto_register_orderdata_history_log', $response_member, $member_id, $order_id );
6167 $this->save_acting_history_log( $response_member, $order_id . '_' . $rand );
6168 $settltment_errmsg = __( '[Regular purchase] Member information acquisition error.', 'autodelivery' );
6169 $responsecd = explode( '|', $response_member['ResponseCd'] );
6170 foreach ( (array) $responsecd as $cd ) {
6171 $response_member[ $cd ] = $this->response_message( $cd );
6172 }
6173 $log = array(
6174 'acting' => $this->acting_card . '(member_process)',
6175 'key' => $member_id,
6176 'result' => $response_member['ResponseCd'],
6177 'data' => $response_member,
6178 );
6179 usces_save_order_acting_error( $log );
6180 do_action( 'usces_action_register_auto_orderdata', $args, $response_member );
6181 }
6182 } else {
6183 $settltment_errmsg = __( '[Regular purchase] Member information acquisition error.', 'autodelivery' );
6184 $logdata = array(
6185 'KaiinId' => $kaiin_id,
6186 'KaiinPass' => $kaiin_pass,
6187 );
6188 $log = array(
6189 'acting' => $this->acting_card . '(member_process)',
6190 'key' => $member_id,
6191 'result' => 'MEMBER ERROR',
6192 'data' => $logdata,
6193 );
6194 usces_save_order_acting_error( $log );
6195 do_action( 'usces_action_register_auto_orderdata', $args, $log );
6196 }
6197 if ( '' !== $settltment_errmsg ) {
6198 $settlement = array(
6199 'settltment_status' => __( 'Failure', 'autodelivery' ),
6200 'settltment_errmsg' => $settltment_errmsg,
6201 );
6202 $usces->set_order_meta_value( $acting_flg, usces_serialize( $settlement ), $order_id );
6203 wcad_settlement_error_mail( $order_id, $settltment_errmsg );
6204 }
6205 }
6206
6207 /**
6208 * 決済ログ出力
6209 *
6210 * @param array $log Log data.
6211 * @param string $log_key [order_id]_[trans_id].
6212 * @return boolean
6213 */
6214 private function save_acting_log( $log, $log_key ) {
6215 global $wpdb;
6216
6217 $datetime = current_time( 'mysql' );
6218 $query = $wpdb->prepare( "INSERT INTO {$wpdb->prefix}usces_log ( `datetime`, `log`, `log_type`, `log_key` ) VALUES ( %s, %s, %s, %s )",
6219 $datetime,
6220 usces_serialize( $log ),
6221 'acting_welcart',
6222 $log_key
6223 );
6224 $res = $wpdb->query( $query ); // phpcs:ignore
6225 return $res;
6226 }
6227
6228 /**
6229 * 決済ログ取得
6230 *
6231 * @param int $order_id Order number.
6232 * @param string $log_key [order_id]_[trans_id].
6233 * @return array
6234 */
6235 public function get_acting_log( $order_id, $log_key = '' ) {
6236 global $wpdb;
6237
6238 if ( ! empty( $log_key ) ) {
6239 $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}usces_log WHERE `log_type` = 'acting_welcart' AND `log_key` = %s ORDER BY datetime DESC", $log_key );
6240 } else {
6241 $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 . '_' ) . '%' );
6242 }
6243 $log_data = $wpdb->get_results( $query, ARRAY_A ); // phpcs:ignore
6244 return $log_data;
6245 }
6246
6247 /**
6248 * 決済ログ更新
6249 *
6250 * @param array $log Log data.
6251 * @param string $log_key [order_id]_[trans_id].
6252 * @return boolean
6253 */
6254 private function update_acting_log( $log, $log_key ) {
6255 global $wpdb;
6256
6257 $datetime = current_time( 'mysql' );
6258 $query = $wpdb->prepare( "UPDATE {$wpdb->prefix}usces_log SET `datetime` = %s, `log` = %s WHERE `log_type` = %s AND `log_key` = %s",
6259 $datetime,
6260 usces_serialize( $log ),
6261 'acting_welcart',
6262 $log_key
6263 );
6264 $res = $wpdb->query( $query ); // phpcs:ignore
6265 return $res;
6266 }
6267
6268 /**
6269 * 決済履歴ログ出力
6270 *
6271 * @param array $log Log data.
6272 * @param string $log_key [order_id]_[trans_id].
6273 * @return boolean
6274 */
6275 private function save_acting_history_log( $log, $log_key ) {
6276 global $wpdb;
6277
6278 $datetime = current_time( 'mysql' );
6279 $query = $wpdb->prepare( "INSERT INTO {$wpdb->prefix}usces_log ( `datetime`, `log`, `log_type`, `log_key` ) VALUES ( %s, %s, %s, %s )",
6280 $datetime,
6281 usces_serialize( $log ),
6282 'acting_welcart_history',
6283 $log_key
6284 );
6285 $res = $wpdb->query( $query ); // phpcs:ignore
6286 return $res;
6287 }
6288
6289 /**
6290 * 決済履歴ログ取得
6291 *
6292 * @param string $log_key [order_id]_[trans_id].
6293 * @return array
6294 */
6295 public function get_acting_history_log( $log_key ) {
6296 global $wpdb;
6297
6298 $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 );
6299 $log_data = $wpdb->get_results( $query, ARRAY_A ); // phpcs:ignore
6300 return $log_data;
6301 }
6302
6303 /**
6304 * 決済処理取得
6305 *
6306 * @param string $log_key [order_id]_[trans_id].
6307 * @return string
6308 */
6309 private function get_acting_operateid( $log_key ) {
6310 $operateid = '';
6311 $latest_log = $this->get_acting_latest_log( $log_key, 'OK' );
6312 if ( isset( $latest_log['OperateId'] ) ) {
6313 $operateid = $latest_log['OperateId'];
6314 }
6315 return $operateid;
6316 }
6317
6318 /**
6319 * 初回決済処理取得
6320 *
6321 * @param string $log_key [order_id]_[trans_id].
6322 * @return string
6323 */
6324 private function get_acting_first_operateid( $log_key ) {
6325 global $wpdb;
6326
6327 $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 );
6328 $log_data = $wpdb->get_results( $query, ARRAY_A ); // phpcs:ignore
6329 if ( $log_data ) {
6330 $log = usces_unserialize( $log_data[0]['log'] );
6331 $operateid = ( isset( $log['OperateId'] ) ) ? $log['OperateId'] : '';
6332 } else {
6333 $operateid = '';
6334 }
6335 return $operateid;
6336 }
6337
6338 /**
6339 * 決済履歴
6340 *
6341 * @param string $log_key [order_id]_[trans_id].
6342 * @return string
6343 */
6344 private function settlement_history( $log_key ) {
6345 $html = '';
6346 $log_data = $this->get_acting_history_log( $log_key );
6347 if ( $log_data ) {
6348 $num = count( $log_data );
6349 $html = '<table class="settlement-history">
6350 <thead class="settlement-history-head">
6351 <tr><th></th><th>' . __( 'Processing date', 'usces' ) . '</th><th>' . __( 'Sequence number', 'usces' ) . '</th><th>' . __( 'Processing classification', 'usces' ) . '</th><th>' . __( 'Amount', 'usces' ) . '</th><th>' . __( 'Result', 'usces' ) . '</th></tr>
6352 </thead>
6353 <tbody class="settlement-history-body">';
6354 foreach ( (array) $log_data as $data ) {
6355 $log = usces_unserialize( $data['log'] );
6356 $class = ( 'OK' !== $log['ResponseCd'] ) ? ' error' : '';
6357 $operate_name = ( isset( $log['OperateId'] ) ) ? $this->get_operate_name( $log['OperateId'] ) : '';
6358 $amount = ( isset( $log['Amount'] ) ) ? usces_crform( $log['Amount'], false, true, 'return', true ) : '';
6359 $html .= '<tr>
6360 <td class="num">' . $num . '</td>
6361 <td class="datetime">' . $data['datetime'] . '</td>
6362 <td class="transactionid">' . $log['TransactionId'] . '</td>
6363 <td class="operateid">' . $operate_name . '</td>
6364 <td class="amount">' . $amount . '</td>
6365 <td class="responsecd' . $class . '">' . $log['ResponseCd'] . '</td>
6366 </tr>';
6367 $num--;
6368 }
6369 $html .= '</tbody>
6370 </table>';
6371 }
6372 return $html;
6373 }
6374
6375 /**
6376 * 最新処理取得
6377 *
6378 * @param string $log_key [order_id]_[trans_id].
6379 * @param string $responsecd ResponseCd.
6380 * @return array
6381 */
6382 public function get_acting_latest_log( $log_key, $responsecd = 'OK' ) {
6383 $latest_log = array();
6384 $log_data = $this->get_acting_history_log( $log_key );
6385 if ( $log_data ) {
6386 if ( 'OK' === $responsecd ) {
6387 $reauth = false;
6388 foreach ( (array) $log_data as $data ) {
6389 $log = usces_unserialize( $data['log'] );
6390 if ( isset( $log['ResponseCd'] ) ) {
6391 if ( 'OK' === $log['ResponseCd'] && in_array( $log['OperateId'], $this->reauth_status ) ) {
6392 $reauth = true;
6393 } else {
6394 if ( $reauth ) {
6395 if ( 'OK' === $log['ResponseCd'] && in_array( $log['OperateId'], $this->primarily_status ) ) {
6396 $latest_log = $log;
6397 break;
6398 }
6399 } else {
6400 if ( 'OK' === $log['ResponseCd'] && in_array( $log['OperateId'], $this->latest_status ) ) {
6401 $latest_log = $log;
6402 break;
6403 }
6404 }
6405 }
6406 }
6407 }
6408 } else {
6409 $latest_log = usces_unserialize( $log_data[0]['log'] );
6410 }
6411 }
6412 return $latest_log;
6413 }
6414
6415 /**
6416 * 最新処理ステータス取得
6417 *
6418 * @param int $member_id Member ID.
6419 * @param int $order_id Order number.
6420 * @return string
6421 */
6422 public function get_latest_status( $member_id, $order_id ) {
6423 global $usces;
6424
6425 $status = '';
6426 $log_data = $this->get_acting_log( $order_id );
6427 if ( $log_data && 0 < count( $log_data ) ) {
6428 $acting_data = usces_unserialize( $log_data[0]['log'] );
6429 $trans_id = ( isset( $acting_data['MerchantFree1'] ) ) ? $acting_data['MerchantFree1'] : '';
6430 } else {
6431 $trans_id = $usces->get_order_meta_value( 'trans_id', $order_id );
6432 }
6433 if ( $trans_id ) {
6434 $latest_log = $this->get_acting_latest_log( $order_id . '_' . $trans_id, 'ALL' );
6435 $status = ( isset( $latest_log['ResponseCd'] ) ) ? $latest_log['ResponseCd'] : 'NG';
6436 }
6437 return $status;
6438 }
6439
6440 /**
6441 * 処理区分名称取得
6442 *
6443 * @param string $log_key [order_id]_[trans_id].
6444 * @return string
6445 */
6446 private function get_acting_status_name( $log_key ) {
6447 $status_name = '';
6448 $log_data = $this->get_acting_history_log( $log_key );
6449 if ( $log_data ) {
6450 $log = usces_unserialize( $log_data[0]['log'] );
6451 if ( isset( $log['OperateId'] ) ) {
6452 $status_name = $this->get_operate_name( $log['OperateId'] );
6453 }
6454 }
6455 return $status_name;
6456 }
6457
6458 /**
6459 * 銀聯取引ステータス取得
6460 *
6461 * @param string $status Status.
6462 * @return string
6463 */
6464 protected function get_unionpay_status_name( $status ) {
6465 $status_name = '';
6466 switch ( trim( $status ) ) {
6467 case 1: /* 売上確定済 */
6468 $status_name = __( 'Sales confirmed', 'usces' );
6469 break;
6470 case 2: /* 取消済 */
6471 $status_name = __( 'Canceled', 'usces' );
6472 break;
6473 case 3: /* 返品済 */
6474 $status_name = __( 'Returned', 'usces' );
6475 break;
6476 case 4: /* 参�
6477 �処理済 */
6478 $status_name = __( 'Reference processed', 'usces' );
6479 break;
6480 case 97: /* NG(詳細不明) */
6481 $status_name = __( 'NG (details unknown)', 'usces' );
6482 break;
6483 case 98: /* レスポンス不明 */
6484 $status_name = __( 'Unknown response', 'usces' );
6485 break;
6486 case 99:
6487 $status_name = 'NG';
6488 break;
6489 }
6490 return $status_name;
6491 }
6492
6493 /**
6494 * 期限切れチェック
6495 *
6496 * @param int $order_id Order number.
6497 * @param string $trans_id Transaction ID.
6498 * @return boolean
6499 */
6500 private function check_paylimit( $order_id, $trans_id ) {
6501 global $usces;
6502
6503 $expiration = false;
6504 $receipted = false;
6505 $log_data = $this->get_acting_history_log( $order_id . '_' . $trans_id );
6506 if ( $log_data ) {
6507 foreach ( (array) $log_data as $data ) {
6508 $log = usces_unserialize( $data['log'] );
6509 if ( isset( $log['OperateId'] ) && 'receipted' === $log['OperateId'] ) {
6510 $receipted = true;
6511 break;
6512 }
6513 }
6514 }
6515 if ( $receipted ) {
6516 return false;
6517 }
6518 $today = date_i18n( 'YmdHi', current_time( 'timestamp' ) );
6519 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_welcart_conv', $order_id ) );
6520 if ( ! empty( $acting_data['PayLimit'] ) && $today > $acting_data['PayLimit'] ) {
6521 $expiration = true;
6522 }
6523 return $expiration;
6524 }
6525
6526 /**
6527 * 削除済みチェック
6528 *
6529 * @param string $log_key [order_id]_[trans_id].
6530 * @return boolean
6531 */
6532 private function check_deleted( $log_key ) {
6533 $deleted = false;
6534 $log_data = $this->get_acting_history_log( $log_key );
6535 if ( $log_data ) {
6536 foreach ( (array) $log_data as $data ) {
6537 $log = usces_unserialize( $data['log'] );
6538 if ( isset( $log['OperateId'] ) && '2Del' === $log['OperateId'] ) {
6539 $deleted = true;
6540 break;
6541 }
6542 }
6543 }
6544 return $deleted;
6545 }
6546
6547 /**
6548 * 継続課金会員データ取得
6549 *
6550 * @param int $order_id Order number.
6551 * @param int $member_id Member ID.
6552 * @return array
6553 */
6554 private function get_continuation_data( $order_id, $member_id ) {
6555 global $wpdb;
6556
6557 $query = $wpdb->prepare( "SELECT
6558 `con_acting` AS `acting`,
6559 `con_order_price` AS `order_price`,
6560 `con_price` AS `price`,
6561 `con_next_charging` AS `chargedday`,
6562 `con_next_contracting` AS `contractedday`,
6563 `con_startdate` AS `startdate`,
6564 `con_status` AS `status`
6565 FROM {$wpdb->prefix}usces_continuation
6566 WHERE con_order_id = %d AND con_member_id = %d",
6567 $order_id,
6568 $member_id
6569 );
6570 $data = $wpdb->get_row( $query, ARRAY_A ); // phpcs:ignore
6571 return $data;
6572 }
6573
6574 /**
6575 * 継続課金会員データ更新
6576 *
6577 * @param int $order_id Order number.
6578 * @param int $member_id Member ID.
6579 * @param array $data Continuation data.
6580 * @param boolean $stop Stop continuous billing.
6581 * @return boolean
6582 */
6583 private function update_continuation_data( $order_id, $member_id, $data, $stop = false ) {
6584 global $wpdb;
6585
6586 if ( $stop ) {
6587 $query = $wpdb->prepare( "UPDATE {$wpdb->prefix}usces_continuation SET
6588 `con_status` = 'cancellation'
6589 WHERE `con_order_id` = %d AND `con_member_id` = %d",
6590 $order_id,
6591 $member_id
6592 );
6593 } else {
6594 $query = $wpdb->prepare( "UPDATE {$wpdb->prefix}usces_continuation SET
6595 `con_price` = %f,
6596 `con_next_charging` = %s,
6597 `con_next_contracting` = %s,
6598 `con_status` = %s
6599 WHERE `con_order_id` = %d AND `con_member_id` = %d",
6600 $data['price'],
6601 $data['chargedday'],
6602 $data['contractedday'],
6603 $data['status'],
6604 $order_id,
6605 $member_id
6606 );
6607 }
6608 $res = $wpdb->query( $query ); // phpcs:ignore
6609 return $res;
6610 }
6611
6612 /**
6613 * 日付チェック
6614 *
6615 * @param object $date DateTime.
6616 * @return boolean
6617 */
6618 private function isdate( $date ) {
6619 if ( empty( $date ) ) {
6620 return false;
6621 }
6622 try {
6623 new DateTime( $date );
6624 list( $year, $month, $day ) = explode( '-', $date );
6625 $res = checkdate( (int) $month, (int) $day, (int) $year );
6626 return $res;
6627 } catch ( Exception $e ) {
6628 return false;
6629 }
6630 }
6631
6632 /**
6633 * 支払方法
6634 * usces_fiter_the_payment_method
6635 *
6636 * @param array $payments Payment data.
6637 * @return array
6638 */
6639 public function payment_method( $payments ) {
6640 global $usces;
6641
6642 $conv_exclusion = false;
6643 $atodene_exclusion = false;
6644
6645 if ( usces_have_regular_order() ) {
6646 $conv_exclusion = true;
6647
6648 } elseif ( usces_have_continue_charge() ) {
6649 $conv_exclusion = true;
6650 $atodene_exclusion = true;
6651
6652 } else {
6653 $acting_opts = $this->get_acting_settings();
6654 if ( 'on' === $acting_opts['atodene_byitem'] ) { /* 商品ごとの可否が有効 */
6655 $cart = $usces->cart->get_cart();
6656 foreach ( $cart as $cart_row ) {
6657 $product = wel_get_product( $cart_row['post_id'] );
6658 $atodene_propriety = $product['atodene_propriety'];
6659 if ( 1 === (int) $atodene_propriety ) {
6660 $atodene_exclusion = true;
6661 break;
6662 }
6663 }
6664 }
6665 }
6666
6667 if ( $conv_exclusion ) {
6668 foreach ( $payments as $key => $payment ) {
6669 if ( $this->acting_flg_conv === $payment['settlement'] ) {
6670 unset( $payments[ $key ] );
6671 }
6672 }
6673 }
6674 if ( $atodene_exclusion ) {
6675 foreach ( $payments as $key => $payment ) {
6676 if ( $this->acting_flg_atodene === $payment['settlement'] ) {
6677 unset( $payments[ $key ] );
6678 }
6679 }
6680 }
6681
6682 return $payments;
6683 }
6684
6685 /**
6686 * ATODENE CSVアップロード
6687 * usces_after_cart_instant
6688 */
6689 public function atodene_upload() {
6690 if ( isset( $_POST['page'] ) && 'atodene_results_csv' === wp_unslash( $_POST['page'] ) && isset( $_POST['action'] ) && 'atodene_upload' === wp_unslash( $_POST['action'] ) ) {
6691 $path = WP_CONTENT_DIR . '/uploads/';
6692 $workfile = $_FILES['atodene_upcsv']['tmp_name'];
6693 if ( ! is_uploaded_file( $workfile ) ) {
6694 $message = __( 'The file was not uploaded.', 'usces' );
6695 wp_redirect(
6696 add_query_arg(
6697 array(
6698 'page' => 'usces_orderlist',
6699 'usces_status' => 'error',
6700 'usces_message' => urlencode( $message ),
6701 'order_action' => 'atodene_upload',
6702 ),
6703 USCES_ADMIN_URL
6704 )
6705 );
6706 exit();
6707 }
6708
6709 list( $fname, $fext ) = explode( '.', $_FILES['atodene_upcsv']['name'], 2 );
6710 if ( 'csv' !== $fext ) {
6711 $message = __( 'The file is not supported.', 'usces' ) . $fname . '.' . $fext;
6712 wp_redirect(
6713 add_query_arg(
6714 array(
6715 'page' => 'usces_orderlist',
6716 'usces_status' => 'error',
6717 'usces_message' => urlencode( $message ),
6718 'order_action' => 'atodene_upload',
6719 ),
6720 USCES_ADMIN_URL
6721 )
6722 );
6723 exit();
6724 }
6725
6726 $new_filename = base64_encode( $fname . '_' . time() . '.' . $fext );
6727 if ( ! move_uploaded_file( $_FILES['atodene_upcsv']['tmp_name'], $path . $new_filename ) ) {
6728 $message = __( 'The file was not stored.', 'usces' ) . $_FILES['atodene_upcsv']['name'];
6729 wp_redirect(
6730 add_query_arg(
6731 array(
6732 'page' => 'usces_orderlist',
6733 'usces_status' => 'error',
6734 'usces_message' => urlencode( $message ),
6735 'order_action' => 'atodene_upload',
6736 ),
6737 USCES_ADMIN_URL
6738 )
6739 );
6740 exit();
6741 }
6742
6743 wp_redirect(
6744 add_query_arg(
6745 array(
6746 'page' => 'usces_orderlist',
6747 'usces_status' => 'none',
6748 'usces_message' => '',
6749 'order_action' => 'upload_atodene_results',
6750 'atodene_upfile' => urlencode( $new_filename ),
6751 'wc_nonce' => wp_create_nonce( 'order_list' ),
6752 ),
6753 USCES_ADMIN_URL
6754 )
6755 );
6756 exit();
6757 }
6758 }
6759
6760 /**
6761 * ATODENE CSV出力・CSVアップロード
6762 * usces_action_order_list_page
6763 *
6764 * @param string $order_action Order action.
6765 */
6766 public function output_atodene_csv( $order_action ) {
6767 switch ( $order_action ) {
6768 case 'download_atodene_register':
6769 $this->download_atodene_register();
6770 break;
6771 case 'download_atodene_update':
6772 $this->download_atodene_update();
6773 break;
6774 case 'download_atodene_report':
6775 $this->download_atodene_report();
6776 break;
6777 case 'upload_atodene_results':
6778 if ( isset( $_GET['atodene_upfile'] ) && ! WCUtils::is_blank( wp_unslash( $_GET['atodene_upfile'] ) ) ) {
6779 $res = $this->upload_atodene_results();
6780 $_GET['usces_status'] = ( isset( $res['status'] ) ) ? $res['status'] : '';
6781 $_GET['usces_message'] = ( isset( $res['message'] ) ) ? $res['message'] : '';
6782 }
6783 break;
6784 }
6785 }
6786
6787 /**
6788 * ATODENE アクションボタン
6789 * usces_action_order_list_searchbox_bottom
6790 */
6791 public function action_atodene_button() {
6792 ?>
6793 <input type="button" id="dl_atodene_register_csv" class="searchbutton button" value="<?php esc_attr_e( 'ATODENE transaction registration CSV output', 'usces' ); ?>" />
6794 <!--<input type="button" id="dl_atodene_update_csv" class="searchbutton" value="<?php esc_attr_e( 'ATODENE transaction batch change and cancel CSV output', 'usces' ); ?>" />-->
6795 <input type="button" id="up_atodene_results_csv" class="searchbutton button" value="<?php esc_attr_e( 'ATODENE credit review result CSV upload', 'usces' ); ?>" />
6796 <input type="button" id="dl_atodene_report_csv" class="searchbutton button" value="<?php esc_attr_e( 'ATODENE shipping report registration CSV output', 'usces' ); ?>" />
6797 <?php
6798 }
6799
6800 /**
6801 * ATODENE CSVアップロードダイアログ
6802 * usces_action_order_list_footer
6803 */
6804 public function order_list_footer() {
6805 ?>
6806 <div id="atodene_upload_dialog" class="upload_dialog" style="display:none;">
6807 <p><?php _e( "Upload the prescribed CSV file and import credit screening results.<br />Please choose a file, and press 'Start of capture'.", 'usces' ); ?></p>
6808 <form action="<?php echo esc_url( USCES_ADMIN_URL ); ?>" method="post" enctype="multipart/form-data" name="atodene_upform" id="atodene_upform">
6809 <fieldset>
6810 <p><input name="atodene_upcsv" type="file" class="filename" /></p>
6811 </fieldset>
6812 <p><input name="atodene_uploadcsv" type="submit" class="button" value="<?php esc_attr_e( 'Start of capture', 'usces' ); ?>" /></p>
6813 <input name="page" type="hidden" value="atodene_results_csv" />
6814 <input name="action" type="hidden" value="atodene_upload" />
6815 </form>
6816 </div>
6817 <?php
6818 }
6819
6820 /**
6821 * ATODENE CSVダウンロードダイアログ
6822 * usces_filter_order_list_page_js
6823 *
6824 * @param string $html HTML.
6825 * @return string
6826 */
6827 public function order_list_page_js( $html ) {
6828 $html .= '
6829 $(document).on( "click", "#dl_atodene_register_csv", function() {
6830 if( $("input[name*=\'listcheck\']:checked").length == 0 ) {
6831 alert( "' . __( 'Choose the data.', 'usces' ) . '" );
6832 $("#orderlistaction").val("");
6833 return false;
6834 }
6835 var listcheck = "";
6836 $("input[name*=\'listcheck\']").each( function( i ) {
6837 if( $(this).prop("checked") ) {
6838 listcheck += "&listcheck["+i+"]="+$(this).val();
6839 }
6840 });
6841 location.href = "' . USCES_ADMIN_URL . '?page=usces_orderlist&order_action=download_atodene_register"+listcheck+"&noheader=true&_nonce=' . wp_create_nonce( 'csv_nonce' ) . '";
6842 });';
6843
6844 $html .= '
6845 $(document).on( "click", "#dl_atodene_report_csv", function() {
6846 if( $("input[name*=\'listcheck\']:checked").length == 0 ) {
6847 alert("' . __( 'Choose the data.', 'usces' ) . '");
6848 $("#orderlistaction").val("");
6849 return false;
6850 }
6851 var listcheck = "";
6852 $("input[name*=\'listcheck\']").each( function( i ) {
6853 if( $(this).prop("checked") ) {
6854 listcheck += "&listcheck["+i+"]="+$(this).val();
6855 }
6856 });
6857 location.href = "' . USCES_ADMIN_URL . '?page=usces_orderlist&order_action=download_atodene_report"+listcheck+"&noheader=true&_nonce=' . wp_create_nonce( 'csv_nonce' ) . '";
6858 });
6859
6860 $(document).on( "click", "#up_atodene_results_csv", function() {
6861 $("#atodene_upload_dialog").dialog({
6862 bgiframe: true,
6863 autoOpen: false,
6864 title: "' . __( 'Credit Review Result CSV Capture', 'usces' ) . '",
6865 height: 350,
6866 width: 550,
6867 modal: true,
6868 buttons: {
6869 "' . __( 'Close' ) . '": function() {
6870 $(this).dialog("close");
6871 }
6872 },
6873 close: function() {
6874 }
6875 }).dialog("open");
6876 });';
6877
6878 return $html;
6879 }
6880
6881 /**
6882 * ATODENE アクションステータス
6883 * usces_order_list_action_status
6884 *
6885 * @param string $status Status.
6886 * @return string
6887 */
6888 public function order_list_action_status( $status ) {
6889 if ( isset( $_GET['order_action'] ) && ( 'atodene_upload' === filter_input( INPUT_GET, 'order_action', FILTER_DEFAULT ) || 'upload_atodene_results' === filter_input( INPUT_GET, 'order_action', FILTER_DEFAULT ) ) && isset( $_GET['usces_status'] ) && ! empty( $_GET['usces_status'] ) ) {
6890 $status = filter_input( INPUT_GET, 'usces_status' );
6891 }
6892 return $status;
6893 }
6894
6895 /**
6896 * ATODENE アクションステータスメッセージ
6897 * usces_order_list_action_message
6898 *
6899 * @param string $message Message.
6900 * @return string
6901 */
6902 public function order_list_action_message( $message ) {
6903 if ( isset( $_GET['order_action'] ) && ( 'atodene_upload' === filter_input( INPUT_GET, 'order_action', FILTER_DEFAULT ) || 'upload_atodene_results' === filter_input( INPUT_GET, 'order_action', FILTER_DEFAULT ) ) && isset( $_GET['usces_message'] ) && ! empty( $_GET['usces_message'] ) ) {
6904 $message = urldecode( filter_input( INPUT_GET, 'usces_message' ) );
6905 }
6906 return $message;
6907 }
6908
6909 /**
6910 * ATODENE 運送会社名
6911 * usces_filter_deli_comps
6912 *
6913 * @param array $deli_comps Delivery company.
6914 * @return array
6915 */
6916 public function delivery_company_name( $deli_comps ) {
6917 $deli_comps = array(
6918 '佐川急便',
6919 'ヤマト運輸',
6920 'クロネコメール便',
6921 'ゆうパック',
6922 'レターパック',
6923 '福山通運',
6924 '西濃運輸',
6925 );
6926 $deli_comps = apply_filters( 'usces_filter_deli_comps_atodene', $deli_comps );
6927 return $deli_comps;
6928 }
6929
6930 /**
6931 * 後払い決済の可否
6932 * usces_item_master_second_section
6933 *
6934 * @param string $second_section Second section area.
6935 * @param int $post_id Post ID.
6936 * @return string
6937 */
6938 public function edit_item_atodene_byitem( $second_section, $post_id ) {
6939 global $usces;
6940
6941 $division = $usces->getItemDivision( $post_id );
6942 $charging_type = $usces->getItemChargingType( $post_id );
6943 $acting_opts = $this->get_acting_settings();
6944 if ( 'shipped' === $division && 'continue' !== $charging_type && 'on' === $acting_opts['atodene_byitem'] ) { /* 商品ごとの可否が有効 */
6945 $product = wel_get_product( $post_id );
6946 $atodene_propriety = $product['atodene_propriety'];
6947 $checked = ( 1 === (int) $atodene_propriety ) ? array( '', ' checked="checked"' ) : array( ' checked="checked"', '' );
6948 $second_section .= '
6949 <tr>
6950 <th>' . __( 'Atobarai Propriety', 'usces' ) . '</th>
6951 <td>
6952 <label for="atodene_propriety_0"><input name="atodene_propriety" id="atodene_propriety_0" type="radio" value="0"' . $checked[0] . '>' . __( 'available', 'usces' ) . '</label>
6953 <label for="atodene_propriety_1"><input name="atodene_propriety" id="atodene_propriety_1" type="radio" value="1"' . $checked[1] . '>' . __( 'not available', 'usces' ) . '</label>
6954 </td>
6955 </tr>';
6956 }
6957 return $second_section;
6958 }
6959
6960 /**
6961 * 後払い決済の可否更新
6962 * usces_action_save_product
6963 *
6964 * @param int $post_id Post ID.
6965 * @param array $post Post data.
6966 */
6967 public function save_item_atodene_byitem( $post_id, $post ) {
6968 /* This process has moved to item_post.php 1567. */
6969
6970 // if ( isset( $_POST['atodene_propriety'] ) ) {
6971 // update_post_meta( $post_id, 'atodene_propriety', $_POST['atodene_propriety'] );
6972 // }
6973 }
6974
6975 /**
6976 * 接続しない決済モジュール
6977 * usces_filter_nonacting_settlements
6978 *
6979 * @param array $nonacting_settlements Non-working settlement module..
6980 * @return array
6981 */
6982 public function nonacting_settlements( $nonacting_settlements ) {
6983 if ( ! in_array( 'acting_welcart_atodene', $nonacting_settlements ) ) {
6984 $nonacting_settlements[] = 'acting_welcart_atodene';
6985 }
6986 return $nonacting_settlements;
6987 }
6988
6989 /**
6990 * 利用可能な支払方法
6991 * wcad_filter_the_payment_method_restriction
6992 *
6993 * @param array $payments_restriction Payment method.
6994 * @param string $payments_value Input value.
6995 * @return array
6996 */
6997 public function payment_method_restriction_atodene( $payments_restriction, $payments_value ) {
6998 global $usces;
6999
7000 $acting_opts = $this->get_acting_settings();
7001 if ( usces_have_regular_order() ) {
7002 $atodene_exclusion = false;
7003 if ( 'on' === $acting_opts['atodene_byitem'] ) { /* 商品ごとの可否が有効 */
7004 $cart = $usces->cart->get_cart();
7005 foreach ( $cart as $cart_row ) {
7006 $product = wel_get_product( $cart_row['post_id'] );
7007 $atodene_propriety = $product['atodene_propriety'];
7008 if ( 1 === (int) $atodene_propriety ) {
7009 $atodene_exclusion = true;
7010 break;
7011 }
7012 }
7013 }
7014 if ( ! $atodene_exclusion ) {
7015 $payments = usces_get_system_option( 'usces_payment_method', 'settlement' );
7016 $payments_restriction[] = $payments['acting_welcart_atodene'];
7017 foreach ( (array) $payments_restriction as $key => $value ) {
7018 $sort[ $key ] = $value['sort'];
7019 }
7020 array_multisort( $sort, SORT_ASC, $payments_restriction );
7021 }
7022 }
7023 return $payments_restriction;
7024 }
7025
7026 /**
7027 * ATODENE 取引登録CSV出力
7028 */
7029 public function download_atodene_register() {
7030 global $usces;
7031
7032 $acting_opts = $this->get_acting_settings();
7033 $filename = mb_convert_encoding( __( 'ATODENE_transaction_', 'usces' ), 'SJIS', 'UTF-8' ) . date_i18n( 'YmdHis', current_time( 'timestamp' ) ) . '.csv';
7034
7035 $line = '"ご購�
7036 �店受注番号","購�
7037 ��
7038 注文日","会社名","部署名","氏名","氏名(フリガナ)","郵便番号","住所","電話番号","メールアドレス","�
7039 �送�
7040 �会社名","�
7041 �送�
7042 �部署名","�
7043 �送�
7044 �氏名","�
7045 �送�
7046 �氏名(フリガナ)","�
7047 �送�
7048 �郵便番号","�
7049 �送�
7050 �住所","�
7051 �送�
7052 �電話番号","請求書送付方法","予備領域1","予備領域2","予備領域3","顧客請求総額(税込)","明細名(商品名)","単価(税込)","数量"' . "\r\n";
7053
7054 $ids = $_GET['listcheck'];
7055 foreach ( (array) $ids as $order_id ) {
7056 $order_data = $usces->get_order_data( $order_id, 'direct' );
7057 $payment = $usces->getPayments( $order_data['order_payment_name'] );
7058 if ( 'acting_welcart_atodene' !== $payment['settlement'] ) {
7059 continue;
7060 }
7061
7062 $delivery = usces_unserialize( $order_data['order_delivery'] );
7063 $cart = usces_get_ordercartdata( $order_id );
7064
7065 $order_date = substr( $order_data['order_date'], 0, 10 );
7066 $date = str_replace( '-', '/', $order_date );
7067
7068 $company = $usces->get_order_meta_value( 'cscs_company', $order_id );
7069 $order_name = $order_data['order_name1'] . $order_data['order_name2'];
7070 $order_kana = mb_convert_kana( $order_data['order_name3'], 'ak', 'UTF-8' ) . mb_convert_kana( $order_data['order_name4'], 'ak', 'UTF-8' );
7071 $order_zip = str_replace( '', '', mb_convert_kana( $order_data['order_zip'], 'a', 'UTF-8' ) );
7072 $order_post = str_replace( '-', '', $order_zip );
7073 $order_address = $order_data['order_pref'] . $order_data['order_address1'];
7074 if ( ! empty( $order_data['order_address2'] ) ) {
7075 $order_address .= mb_convert_kana( $order_data['order_address2'], 'ak', 'UTF-8' );
7076 }
7077 if ( ! empty( $order_data['order_address3'] ) ) {
7078 $order_address .= mb_convert_kana( $order_data['order_address3'], 'ak', 'UTF-8' );
7079 }
7080 $order_tel = $order_data['order_tel'];
7081 $email = $order_data['order_email'];
7082
7083 $shipto_company = $usces->get_order_meta_value( 'csde_company', $order_id );
7084 $shipto_name = $delivery['name1'] . $delivery['name2'];
7085 $shipto_kana = mb_convert_kana( $delivery['name3'], 'ak', 'UTF-8' ) . mb_convert_kana( $delivery['name4'], 'ak', 'UTF-8' );
7086 $shipto_zip = str_replace( '', '', mb_convert_kana( $delivery['zipcode'], 'a', 'UTF-8' ) );
7087 $shipto_post = str_replace( '-', '', $delivery['zipcode'] );
7088 $shipto_address = $delivery['pref'] . $delivery['address1'];
7089 if ( ! empty( $delivery['address2'] ) ) {
7090 $shipto_address .= mb_convert_kana( $delivery['address2'], 'ak', 'UTF-8' );
7091 }
7092 if ( ! empty( $delivery['address3'] ) ) {
7093 $shipto_address .= mb_convert_kana( $delivery['address3'], 'ak', 'UTF-8' );
7094 }
7095 $shipto_tel = $delivery['tel'];
7096
7097 $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'];
7098
7099 $line .= '"' . $order_id . '",' .
7100 '"' . $date . '",' .
7101 '"' . $company . '","",' .
7102 '"' . $order_name . '",' .
7103 '"' . $order_kana . '",' .
7104 '"' . $order_post . '",' .
7105 '"' . $order_address . '",' .
7106 '"' . $order_tel . '",' .
7107 '"' . $email . '",' .
7108 '"' . $shipto_company . '","",' .
7109 '"' . $shipto_name . '",' .
7110 '"' . $shipto_kana . '",' .
7111 '"' . $shipto_post . '",' .
7112 '"' . $shipto_address . '",' .
7113 '"' . $shipto_tel . '",' .
7114 '"' . $acting_opts['atodene_billing_method'] . '","","","",' .
7115 '"' . $amount . '",';
7116
7117 $row = 1;
7118 foreach ( $cart as $cart_row ) {
7119 if ( 1 < $row ) {
7120 $line .= '"","","","","","","","","","","","","","","","","","","","","","",';
7121 }
7122 $line .= '"' . $cart_row['item_name'] . '",';
7123 $line .= '"' . usces_crform( $cart_row['price'], false, false, 'return', false ) . '",';
7124 $line .= '"' . $cart_row['quantity'] . '"' . "\r\n";
7125 $row++;
7126 }
7127
7128 if ( 0 !== (int) $order_data['order_discount'] ) {
7129 $line .= '"","","","","","","","","","","","","","","","","","","","","","",';
7130 $line .= '"' . apply_filters( 'usces_confirm_discount_label', __( 'Discount', 'usces' ), $order_id ) . '",';
7131 $line .= '"' . usces_crform( $cart_row['order_discount'], false, false, 'return', false ) . '","1"' . "\r\n";
7132 }
7133
7134 if ( usces_is_tax_display() && 'products' === usces_get_tax_target() && 'exclude' === usces_get_tax_mode() ) {
7135 $line .= '"","","","","","","","","","","","","","","","","","","","","","",';
7136 $line .= '"' . usces_tax_label( $order_data, 'return' ) . '",';
7137 $line .= '"' . usces_crform( $order_data['order_tax'], false, false, 'return', false ) . '","1"' . "\r\n";
7138 }
7139
7140 if ( usces_is_member_system() && usces_is_member_system_point() && 0 === (int) usces_point_coverage() && 0 !== (int) $order_data['order_usedpoint'] ) {
7141 $line .= '"","","","","","","","","","","","","","","","","","","","","","",';
7142 $line .= '"' . __( 'use of points', 'usces' ) . '",';
7143 $line .= '"' . usces_crform( $order_data['order_usedpoint'], false, false, 'return', false ) . '","1"' . "\r\n";
7144 }
7145
7146 if ( 0 < $order_data['order_shipping_charge'] ) {
7147 $line .= '"","","","","","","","","","","","","","","","","","","","","","",';
7148 $line .= '"' . __( 'Shipping', 'usces' ) . '",';
7149 $line .= '"' . usces_crform( $order_data['order_shipping_charge'], false, false, 'return', false ) . '","1"' . "\r\n";
7150 }
7151
7152 if ( 0 < $order_data['order_cod_fee'] ) {
7153 $line .= '"","","","","","","","","","","","","","","","","","","","","","",';
7154 $line .= '"' . apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ) ) . '",';
7155 $line .= '"' . usces_crform( $order_data['order_cod_fee'], false, false, 'return', false ) . '","1"' . "\r\n";
7156 }
7157
7158 if ( usces_is_tax_display() && 'all' === usces_get_tax_target() && 'exclude' === usces_get_tax_mode() ) {
7159 $line .= '"","","","","","","","","","","","","","","","","","","","","","",';
7160 $line .= '"' . usces_tax_label( $order_data, 'return' ) . '",';
7161 $line .= '"' . usces_crform( $order_data['order_tax'], false, false, 'return', false ) . '","1"' . "\r\n";
7162 }
7163
7164 if ( usces_is_member_system() && usces_is_member_system_point() && 1 === (int) usces_point_coverage() && 0 !== (int) $order_data['order_usedpoint'] ) {
7165 $line .= '"","","","","","","","","","","","","","","","","","","","","","",';
7166 $line .= '"' . __( 'use of points', 'usces' ) . '",';
7167 $line .= '"' . usces_crform( $order_data['order_usedpoint'], false, false, 'return', false ) . '","1"' . "\r\n";
7168 }
7169 }
7170
7171 header( 'Content-Type: application/octet-stream' );
7172 header( "Content-disposition: attachment; filename=$filename" );
7173 mb_http_output( 'pass' );
7174 print( mb_convert_encoding( $line, 'SJIS-win', 'UTF-8' ) ); // phpcs:ignore
7175 exit();
7176 }
7177
7178 /**
7179 * ATODENE 取引一括変更・キャンセルCSV出力
7180 */
7181 public function download_atodene_update() {
7182 exit();
7183 }
7184
7185 /**
7186 * ATODENE 出荷報告登録CSV出力
7187 */
7188 public function download_atodene_report() {
7189 global $usces;
7190
7191 $acting_opts = $this->get_acting_settings();
7192 $filename = mb_convert_encoding( __( 'ATODENE_shippingreport_', 'usces' ), 'SJIS', 'UTF-8' ) . date_i18n( 'YmdHis', current_time( 'timestamp' ) ) . '.csv';
7193
7194 $line = '"運送会社名","�
7195 �送伝票番号","購�
7196 ��
7197 注文日","お問合せ番号","ご購�
7198 �店受注番号","氏名","予備�
7199 目","�
7200 �送�
7201 �氏名","�
7202 �送�
7203 �住所","顧客請求金額(税込)","請求書送付方法","審査結果"' . "\r\n";
7204
7205 $ids = $_GET['listcheck'];
7206 foreach ( (array) $ids as $order_id ) {
7207 $order_data = $usces->get_order_data( $order_id, 'direct' );
7208 $payment = $usces->getPayments( $order_data['order_payment_name'] );
7209 if ( 'acting_welcart_atodene' !== $payment['settlement'] ) {
7210 continue;
7211 }
7212
7213 $delivery_company = $usces->get_order_meta_value( 'delivery_company', $order_id );
7214 $tracking_number = $usces->get_order_meta_value( apply_filters( 'usces_filter_tracking_meta_key', 'tracking_number' ), $order_id );
7215 $atodene_number = $usces->get_order_meta_value( 'atodene_number', $order_id );
7216
7217 if ( ! empty( $delivery_company ) && ! empty( $tracking_number ) && ! empty( $atodene_number ) ) {
7218 $line .= '"' . $delivery_company . '",' .
7219 '"' . $tracking_number . '","",' .
7220 '"' . $atodene_number . '",' .
7221 '"' . $order_id . '","","","","","","",""' . "\r\n";
7222 }
7223 }
7224
7225 header( 'Content-Type: application/octet-stream' );
7226 header( "Content-disposition: attachment; filename=$filename" );
7227 mb_http_output( 'pass' );
7228 print( mb_convert_encoding( $line, 'SJIS-win', 'UTF-8' ) ); // phpcs:ignore
7229 exit();
7230 }
7231
7232 /**
7233 * ATODENE 与信審査結果CSV取込
7234 *
7235 * @return array
7236 */
7237 public function upload_atodene_results() {
7238 global $usces, $wpdb;
7239
7240 $res = array();
7241 $path = WP_CONTENT_DIR . '/uploads/';
7242
7243 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 ) ) {
7244 $file_name = urldecode( filter_input( INPUT_GET, 'atodene_upfile' ) );
7245 $decode_filename = base64_decode( $file_name );
7246 if ( ! file_exists( $path . $file_name ) ) {
7247 $res['status'] = 'error';
7248 $res['message'] = __( 'CSV file does not exist.', 'usces' ) . esc_html( $decode_filename );
7249 return( $res );
7250 }
7251 }
7252
7253 $wpdb->query( 'SET SQL_BIG_SELECTS=1' );
7254 set_time_limit( 3600 );
7255
7256 define( 'COL_ORDER_ID', 0 ); /* ご購�
7257 �店受注番号 */
7258 define( 'COL_ATODINE_NUMBER', 1 ); /* お問合せ番号 */
7259 define( 'COL_NAME', 2 ); /* 氏名 */
7260 define( 'COL_AMOUNT', 3 ); /* 顧客請求金額(税込) */
7261 define( 'COL_BILLING_METHOD', 4 ); /* 請求書送付方法(別送/同梱) */
7262 define( 'COL_RESULTS', 5 ); /* 与信審査結果(OK/NG/保留/審査中) */
7263
7264 if ( ! ( $fpo = fopen( $path . $file_name, 'r' ) ) ) {
7265 $res['status'] = 'error';
7266 $res['message'] = __( 'A file does not open.', 'usces' ) . esc_html( $decode_filename );
7267 return $res;
7268 }
7269
7270 $orglines = array();
7271 $sp = ',';
7272
7273 $fname_parts = explode( '.', $decode_filename );
7274 if ( 'csv' !== end( $fname_parts ) ) {
7275 $res['status'] = 'error';
7276 $res['message'] = __( 'This file is not in the CSV file.', 'usces' ) . esc_html( $decode_filename );
7277 return $res;
7278 }
7279
7280 $buf = '';
7281 while ( ! feof( $fpo ) ) {
7282 $temp = fgets( $fpo, 10240 );
7283 if ( 0 === strlen( $temp ) ) {
7284 continue;
7285 }
7286 $orglines[] = str_replace( '"', '', $temp );
7287 }
7288 fclose( $fpo );
7289
7290 foreach ( $orglines as $sjisline ) {
7291 $line = mb_convert_encoding( $sjisline, 'UTF-8', 'SJIS' );
7292 list( $order_id, $atodene_number, $name, $amount, $billing_method, $atodene_results ) = explode( $sp, $line );
7293 if ( ! is_numeric( $order_id ) ) {
7294 continue;
7295 }
7296 $order_data = $usces->get_order_data( $order_id, 'direct' );
7297 if ( $order_data ) {
7298 $atodene_results = mb_convert_kana( $atodene_results, 'r', 'UTF-8' );
7299 if ( 'OK' === trim( $atodene_results ) ) {
7300 $res = usces_change_order_receipt( (int) $order_id, 'receipted' );
7301 usces_action_acting_getpoint( (int) $order_id );
7302 }
7303 if ( ! empty( $atodene_number ) ) {
7304 $usces->set_order_meta_value( 'atodene_number', trim( $atodene_number ), (int) $order_id );
7305 }
7306 if ( ! empty( $atodene_results ) ) {
7307 $usces->set_order_meta_value( 'atodene_results', trim( $atodene_results ), (int) $order_id );
7308 }
7309 }
7310 }
7311 unlink( $path . $file_name );
7312
7313 return $res;
7314 }
7315
7316 /**
7317 * Temporary storage of session data.
7318 * usces_filter_save_order_acting_data
7319 *
7320 * @param array $data Session data.
7321 * @return array
7322 */
7323 public function save_order_acting_data( $data ) {
7324 if ( isset( $_POST['_nonce'] ) ) {
7325 $data['_nonce'] = filter_input( INPUT_POST, '_nonce' );
7326 }
7327 return $data;
7328 }
7329
7330 /**
7331 * Save admin log.
7332 *
7333 * @since 2.7.2
7334 * @see admin_ajax()
7335 * @param integer $order_id The order id.
7336 * @param string $log_key The log key.
7337 * @return void
7338 */
7339 private function save_admin_log( $order_id, $log_key ) {
7340 $latest_log = array();
7341 $log_data = $this->get_acting_history_log( $log_key );
7342 if ( ! empty( $log_data ) ) {
7343 $latest_log = current( $log_data );
7344 }
7345
7346 Logger::log( $order_id, 'orderedit', 'update', array( 'acting_welcart_card' => $latest_log ) );
7347 }
7348 }
7349