PluginProbe
Welcart e-Commerce / 2.11.30
Welcart e-Commerce v2.11.30
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 / paymentZeus.class.php

paymentZeus.class.php in Welcart e-Commerce 2.11.30, at classes/paymentZeus.class.php

8,431 lines 355.5 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 * ZEUS
5 *
6 * @package Welcart
7 * @author Welcart Inc.
8 * @version 1.1.0
9 * @since 2.4.0
10 */
11
12 /**
13 * ゼウス決済モジュール
14 */
15 class ZEUS_SETTLEMENT {
16
17 /**
18 * Instance of this class.
19 *
20 * @var object
21 */
22 protected static $instance = null;
23
24 /**
25 * 決済代行会社ID
26 *
27 * @var string
28 */
29 protected $paymod_id;
30
31 /**
32 * 決済種別
33 *
34 * @var string
35 */
36 protected $pay_method;
37
38 /**
39 * 決済代行会社略称
40 *
41 * @var string
42 */
43 protected $acting_name;
44
45 /**
46 * 決済代行会社正式名称
47 *
48 * @var string
49 */
50 protected $acting_formal_name;
51
52 /**
53 * 決済代行会社URL
54 *
55 * @var string
56 */
57 protected $acting_company_url;
58
59 /**
60 * 併用不可決済モジュール
61 *
62 * @var array
63 */
64 protected $unavailable_method;
65
66 /**
67 * エラーメッセージ
68 *
69 * @var string
70 */
71 protected $error_mes;
72
73 /**
74 * 自動継続課金処理結果メール
75 *
76 * @var array
77 */
78 protected $continuation_charging_mail;
79
80 /**
81 * 決済結果(正常)
82 *
83 * @var array
84 */
85 protected $payment_normal_results = array(
86 'OK',
87 'Success_order',
88 'SuccessOK',
89 'success',
90 '決済完了',
91 '与信完了',
92 '仮売完了',
93 '取り消し',
94 );
95
96 /**
97 * 決済結果(異常)
98 *
99 * @var array
100 */
101 protected $payment_error_results = array(
102 'failure_order',
103 'Invalid',
104 'maintenance',
105 'connect error',
106 );
107
108 /**
109 * 運送会社コード表
110 *
111 * @var array
112 */
113 protected $shipping_company = array(
114 '11' => '佐川急便',
115 '12' => 'ヤマト運輸',
116 '15' => '郵便書留',
117 '16' => 'ゆうパック',
118 '27' => 'エコ�
119 �',
120 '18' => '福山通運',
121 '14' => '西濃運輸',
122 '13' => '日本通運',
123 '26' => 'JPロジスティクス',
124 '30' => 'セイノーエクスプレス',
125 '21' => '名鉄運輸',
126 '23' => '信州名鉄運輸',
127 '20' => '新潟運輸',
128 '29' => 'トナミ運輸',
129 '31' => '大川�
130 �送サービス',
131 '32' => 'プラスサービス',
132 '99' => 'その他',
133 );
134
135 /**
136 * 決済オプション
137 *
138 * @var array
139 */
140 public $acting_opts;
141
142 /**
143 * Construct.
144 */
145 public function __construct() {
146 $this->paymod_id = 'zeus';
147 $this->pay_method = array(
148 'acting_zeus_card',
149 'acting_zeus_bank',
150 'acting_zeus_conv',
151 'acting_zeus_bnpl',
152 );
153 $this->acting_name = 'ゼウス';
154 $this->acting_formal_name = 'ゼウス';
155 $this->acting_company_url = 'https://www.cardservice.co.jp/';
156
157 $this->initialize_data();
158 $this->acting_opts = $this->get_acting_settings();
159
160 if ( is_admin() ) {
161 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
162 add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
163 add_action( 'usces_action_admin_settlement_update', array( $this, 'settlement_update' ) );
164 add_action( 'usces_action_settlement_tab_title', array( $this, 'settlement_tab_title' ) );
165 add_action( 'usces_action_settlement_tab_body', array( $this, 'settlement_tab_body' ) );
166 add_action( 'usces_filter_add_payment_method', array( $this, 'add_payment_method' ) );
167 }
168
169 if ( $this->is_validity_acting( 'card' ) || $this->is_validity_acting( 'bank' ) || $this->is_validity_acting( 'conv' ) || $this->is_validity_acting( 'bnpl' ) ) {
170 add_action( 'plugins_loaded', array( $this, 'acting_construct' ), 11 );
171 add_action( 'usces_after_cart_instant', array( $this, 'acting_transaction' ), 11 );
172 add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'order_confirm_mail_payment' ), 10, 5 );
173 add_filter( 'usces_filter_is_complete_settlement', array( $this, 'is_complete_settlement' ), 10, 3 );
174 add_action( 'usces_filter_completion_settlement_message', array( $this, 'completion_settlement_message' ), 10, 2 );
175 add_filter( 'usces_filter_get_link_key', array( $this, 'get_link_key' ), 10, 2 );
176 add_action( 'usces_action_revival_order_data', array( $this, 'revival_orderdata' ), 10, 3 );
177 if ( is_admin() ) {
178 add_action( 'usces_action_admin_ajax', array( $this, 'admin_ajax' ) );
179 add_filter( 'usces_filter_orderlist_detail_value', array( $this, 'orderlist_settlement_status' ), 10, 4 );
180 add_action( 'usces_action_order_edit_form_status_block_middle', array( $this, 'settlement_status' ), 10, 3 );
181 add_action( 'usces_action_order_edit_form_settle_info', array( $this, 'settlement_information' ), 10, 2 );
182 add_action( 'usces_action_endof_order_edit_form', array( $this, 'settlement_dialog' ), 10, 2 );
183 add_filter( 'usces_filter_settle_info_field_meta_keys', array( $this, 'settlement_info_field_meta_keys' ) );
184 add_filter( 'usces_filter_settle_info_field_keys', array( $this, 'settlement_info_field_keys' ), 10, 2 );
185 add_filter( 'usces_filter_settle_info_field_value', array( $this, 'settlement_info_field_value' ), 10, 3 );
186 add_filter( 'usces_filter_deli_comps', array( $this, 'bnpl_delivery_company' ), 10, 2 );
187 } else {
188 add_filter( 'usces_filter_payment_detail', array( $this, 'payment_detail' ), 10, 2 );
189 add_filter( 'usces_filter_payments_str', array( $this, 'payments_str' ), 10, 2 );
190 add_filter( 'usces_filter_payments_arr', array( $this, 'payments_arr' ), 10, 2 );
191 add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
192 add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
193 add_filter( 'usces_filter_confirm_inform', array( $this, 'confirm_inform' ), 10, 5 );
194 add_action( 'usces_action_confirm_page_point_inform', array( $this, 'e_point_inform' ), 10, 5 );
195 add_filter( 'usces_filter_confirm_point_inform', array( $this, 'point_inform' ), 10, 5 );
196 add_filter( 'usces_filter_custom_field_info', array( $this, 'confirm_addition_bnpl' ), 20, 4 );
197 if ( defined( 'WCEX_COUPON' ) ) {
198 add_filter( 'wccp_filter_coupon_inform', array( $this, 'point_inform' ), 10, 5 );
199 }
200 add_action( 'usces_pre_purchase', array( $this, 'pre_purchase' ) );
201 add_action( 'usces_action_acting_processing', array( $this, 'acting_processing' ), 10, 2 );
202 add_action( 'usces_pre_acting_return', array( $this, 'pre_acting_return' ) );
203 add_filter( 'usces_filter_check_acting_return_results', array( $this, 'acting_return' ) );
204 add_filter( 'usces_filter_check_acting_return_duplicate', array( $this, 'check_acting_return_duplicate' ), 10, 2 );
205 add_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) );
206 add_action( 'usces_post_reg_orderdata', array( $this, 'post_register_orderdata' ), 10, 2 );
207 add_filter( 'usces_filter_get_error_settlement', array( $this, 'error_page_message' ) );
208 }
209 }
210
211 if ( $this->is_validity_acting( 'card' ) ) {
212 if ( $this->is_activate_card( 'api' ) && 1 === (int) $this->acting_opts['3dsecur'] ) {
213 add_action( 'wp_ajax_zeus_3dsecure_enrol', array( $this, 'zeus_3dsecure_enrol' ) );
214 add_action( 'wp_ajax_nopriv_zeus_3dsecure_enrol', array( $this, 'zeus_3dsecure_enrol' ) );
215 }
216 add_action( 'usces_action_admin_member_info', array( $this, 'admin_member_info' ), 10, 3 );
217 add_action( 'usces_action_post_update_memberdata', array( $this, 'admin_update_memberdata' ), 10, 2 );
218 add_filter( 'usces_filter_uscesL10n', array( $this, 'set_uscesL10n' ), 12, 2 );
219 add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ), 9 );
220 add_filter( 'usces_filter_available_payment_method', array( $this, 'set_available_payment_method' ) );
221 add_filter( 'usces_filter_template_redirect', array( $this, 'member_update_settlement' ), 1 );
222 add_action( 'usces_action_member_submenu_list', array( $this, 'e_update_settlement' ) );
223 add_filter( 'usces_filter_member_submenu_list', array( $this, 'update_settlement' ), 10, 2 );
224 add_filter( 'usces_filter_delete_member_check', array( $this, 'delete_member_check' ), 10, 2 );
225 add_filter( 'usces_filter_delete_member_check_front', array( $this, 'delete_member_check' ), 10, 2 );
226
227 /* WCEX DL Seller */
228 if ( defined( 'WCEX_DLSELLER' ) ) {
229 add_filter( 'usces_filter_the_continue_payment_method', array( $this, 'continuation_payment_method' ) );
230 add_filter( 'dlseller_filter_first_charging', array( $this, 'first_charging_date' ), 9, 5 );
231 add_filter( 'dlseller_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction' ), 10, 2 );
232 add_filter( 'dlseller_filter_continue_member_list_condition', array( $this, 'continue_member_list_condition' ), 10, 4 );
233 add_action( 'dlseller_action_continue_member_list_page', array( $this, 'continue_member_list_page' ) );
234 add_action( 'dlseller_action_do_continuation_charging', array( $this, 'auto_continuation_charging' ), 10, 4 );
235 add_action( 'dlseller_action_do_continuation', array( $this, 'do_auto_continuation' ), 10, 2 );
236 add_filter( 'dlseller_filter_reminder_mail_body', array( $this, 'reminder_mail_body' ), 10, 3 );
237 add_filter( 'dlseller_filter_contract_renewal_mail_body', array( $this, 'contract_renewal_mail_body' ), 10, 3 );
238 }
239 }
240
241 if ( $this->is_validity_acting( 'bnpl' ) ) {
242 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
243 add_filter( 'usces_fiter_the_payment_method', array( $this, 'payment_method' ) );
244 add_filter( 'usces_filter_cod_label', array( $this, 'set_fee_label' ) );
245 add_filter( 'usces_filter_member_history_cod_label', array( $this, 'set_member_history_fee_label' ), 10, 2 );
246 add_filter( 'usces_filter_set_cart_fees_cod', array( $this, 'add_fee' ), 10, 7 );
247 add_filter( 'usces_filter_delivery_check', array( $this, 'check_fee_limit' ) );
248 add_filter( 'usces_filter_point_check_last', array( $this, 'check_fee_limit' ) );
249 }
250 }
251
252 /**
253 * Return an instance of this class.
254 */
255 public static function get_instance() {
256 if ( is_null( self::$instance ) ) {
257 self::$instance = new self();
258 }
259 return self::$instance;
260 }
261
262 /**
263 * Initialize.
264 */
265 public function initialize_data() {
266 $options = get_option( 'usces', array() );
267 $options['acting_settings']['zeus']['ipaddrs'] = ( isset( $options['acting_settings']['zeus']['ipaddrs'] ) ) ? $options['acting_settings']['zeus']['ipaddrs'] : array();
268 $options['acting_settings']['zeus']['card_url'] = ( isset( $options['acting_settings']['zeus']['card_url'] ) ) ? $options['acting_settings']['zeus']['card_url'] : '';
269 $options['acting_settings']['zeus']['card_secureurl'] = ( isset( $options['acting_settings']['zeus']['card_secureurl'] ) ) ? $options['acting_settings']['zeus']['card_secureurl'] : '';
270 $options['acting_settings']['zeus']['card_tokenurl'] = ( isset( $options['acting_settings']['zeus']['card_tokenurl'] ) ) ? $options['acting_settings']['zeus']['card_tokenurl'] : '';
271 $options['acting_settings']['zeus']['bank_url'] = ( isset( $options['acting_settings']['zeus']['bank_url'] ) ) ? $options['acting_settings']['zeus']['bank_url'] : '';
272 $options['acting_settings']['zeus']['conv_url'] = ( isset( $options['acting_settings']['zeus']['conv_url'] ) ) ? $options['acting_settings']['zeus']['conv_url'] : '';
273 $options['acting_settings']['zeus']['card_activate'] = ( isset( $options['acting_settings']['zeus']['card_activate'] ) ) ? $options['acting_settings']['zeus']['card_activate'] : 'off';
274 $options['acting_settings']['zeus']['clientip'] = ( isset( $options['acting_settings']['zeus']['clientip'] ) ) ? $options['acting_settings']['zeus']['clientip'] : '';
275 $options['acting_settings']['zeus']['connection'] = ( isset( $options['acting_settings']['zeus']['connection'] ) ) ? $options['acting_settings']['zeus']['connection'] : 1;
276 $options['acting_settings']['zeus']['3dsecur'] = ( isset( $options['acting_settings']['zeus']['3dsecur'] ) ) ? $options['acting_settings']['zeus']['3dsecur'] : 2;
277 $options['acting_settings']['zeus']['3ds_pattern'] = ( isset( $options['acting_settings']['zeus']['3ds_pattern'] ) ) ? $options['acting_settings']['zeus']['3ds_pattern'] : '';
278 $options['acting_settings']['zeus']['security'] = ( isset( $options['acting_settings']['zeus']['security'] ) ) ? $options['acting_settings']['zeus']['security'] : 2;
279 $options['acting_settings']['zeus']['authkey'] = ( isset( $options['acting_settings']['zeus']['authkey'] ) ) ? $options['acting_settings']['zeus']['authkey'] : '';
280 $options['acting_settings']['zeus']['quickcharge'] = ( isset( $options['acting_settings']['zeus']['quickcharge'] ) ) ? $options['acting_settings']['zeus']['quickcharge'] : '';
281 $options['acting_settings']['zeus']['batch'] = ( isset( $options['acting_settings']['zeus']['batch'] ) ) ? $options['acting_settings']['zeus']['batch'] : '';
282 $options['acting_settings']['zeus']['auto_settlement_mail'] = ( isset( $options['acting_settings']['zeus']['auto_settlement_mail'] ) ) ? $options['acting_settings']['zeus']['auto_settlement_mail'] : 'off';
283 $options['acting_settings']['zeus']['howpay'] = ( isset( $options['acting_settings']['zeus']['howpay'] ) ) ? $options['acting_settings']['zeus']['howpay'] : '';
284 $options['acting_settings']['zeus']['howpay_B1'] = ( isset( $options['acting_settings']['zeus']['howpay_B1'] ) ) ? $options['acting_settings']['zeus']['howpay_B1'] : '';
285 $options['acting_settings']['zeus']['howpay_02'] = ( isset( $options['acting_settings']['zeus']['howpay_02'] ) ) ? $options['acting_settings']['zeus']['howpay_02'] : '';
286 $options['acting_settings']['zeus']['bank_activate'] = ( isset( $options['acting_settings']['zeus']['bank_activate'] ) ) ? $options['acting_settings']['zeus']['bank_activate'] : 'off';
287 $options['acting_settings']['zeus']['bank_ope'] = ( isset( $options['acting_settings']['zeus']['bank_ope'] ) ) ? $options['acting_settings']['zeus']['bank_ope'] : '';
288 $options['acting_settings']['zeus']['clientip_bank'] = ( isset( $options['acting_settings']['zeus']['clientip_bank'] ) ) ? $options['acting_settings']['zeus']['clientip_bank'] : '';
289 $options['acting_settings']['zeus']['testid_bank'] = ( isset( $options['acting_settings']['zeus']['testid_bank'] ) ) ? $options['acting_settings']['zeus']['testid_bank'] : '';
290 $options['acting_settings']['zeus']['bank_expired_date'] = ( isset( $options['acting_settings']['zeus']['bank_expired_date'] ) ) ? $options['acting_settings']['zeus']['bank_expired_date'] : '';
291 $options['acting_settings']['zeus']['conv_activate'] = ( isset( $options['acting_settings']['zeus']['conv_activate'] ) ) ? $options['acting_settings']['zeus']['conv_activate'] : 'off';
292 $options['acting_settings']['zeus']['conv_ope'] = ( isset( $options['acting_settings']['zeus']['conv_ope'] ) ) ? $options['acting_settings']['zeus']['conv_ope'] : '';
293 $options['acting_settings']['zeus']['clientip_conv'] = ( isset( $options['acting_settings']['zeus']['clientip_conv'] ) ) ? $options['acting_settings']['zeus']['clientip_conv'] : '';
294 $options['acting_settings']['zeus']['testid_conv'] = ( isset( $options['acting_settings']['zeus']['testid_conv'] ) ) ? $options['acting_settings']['zeus']['testid_conv'] : '';
295 $options['acting_settings']['zeus']['test_type_conv'] = ( isset( $options['acting_settings']['zeus']['test_type_conv'] ) ) ? $options['acting_settings']['zeus']['test_type_conv'] : '';
296 $options['acting_settings']['zeus']['pay_cvs'] = ( isset( $options['acting_settings']['zeus']['pay_cvs'] ) ) ? $options['acting_settings']['zeus']['pay_cvs'] : array();
297 $options['acting_settings']['zeus']['conv_span'] = ( isset( $options['acting_settings']['zeus']['conv_span'] ) ) ? $options['acting_settings']['zeus']['conv_span'] : '';
298 $options['acting_settings']['zeus']['bnpl_activate'] = ( isset( $options['acting_settings']['zeus']['bnpl_activate'] ) ) ? $options['acting_settings']['zeus']['bnpl_activate'] : 'off';
299 $options['acting_settings']['zeus']['bnpl_linkid'] = ( isset( $options['acting_settings']['zeus']['bnpl_linkid'] ) ) ? $options['acting_settings']['zeus']['bnpl_linkid'] : 'sbifstest1';
300 $options['acting_settings']['zeus']['clientip_bnpl'] = ( isset( $options['acting_settings']['zeus']['clientip_bnpl'] ) ) ? $options['acting_settings']['zeus']['clientip_bnpl'] : '';
301 $options['acting_settings']['zeus']['bnpl_linkpassword'] = ( isset( $options['acting_settings']['zeus']['bnpl_linkpassword'] ) ) ? $options['acting_settings']['zeus']['bnpl_linkpassword'] : '';
302 $options['acting_settings']['zeus']['bnpl_transaction_url'] = ( isset( $options['acting_settings']['zeus']['bnpl_transaction_url'] ) ) ? $options['acting_settings']['zeus']['bnpl_transaction_url'] : '';
303 $options['acting_settings']['zeus']['bnpl_shippingrequest_url'] = ( isset( $options['acting_settings']['zeus']['bnpl_shippingrequest_url'] ) ) ? $options['acting_settings']['zeus']['bnpl_shippingrequest_url'] : '';
304 $options['acting_settings']['zeus']['bnpl_modifytransaction_url'] = ( isset( $options['acting_settings']['zeus']['bnpl_modifytransaction_url'] ) ) ? $options['acting_settings']['zeus']['bnpl_modifytransaction_url'] : '';
305 $options['acting_settings']['zeus']['bnpl_fee_type'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_type'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_type'] : '';
306 $options['acting_settings']['zeus']['bnpl_fee'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee'] : '';
307 $options['acting_settings']['zeus']['bnpl_fee_limit_amount'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_limit_amount'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_limit_amount'] : '';
308 $options['acting_settings']['zeus']['bnpl_fee_first_amount'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_first_amount'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_first_amount'] : '';
309 $options['acting_settings']['zeus']['bnpl_fee_first_fee'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_first_fee'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_first_fee'] : '';
310 $options['acting_settings']['zeus']['bnpl_fee_amounts'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_amounts'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_amounts'] : array();
311 $options['acting_settings']['zeus']['bnpl_fee_fees'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_fees'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_fees'] : array();
312 $options['acting_settings']['zeus']['bnpl_fee_end_fee'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_end_fee'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_end_fee'] : '';
313 $options['acting_settings']['zeus']['activate'] = ( isset( $options['acting_settings']['zeus']['activate'] ) ) ? $options['acting_settings']['zeus']['activate'] : 'off';
314 if ( 'on' === $options['acting_settings']['zeus']['activate'] && 'on' === $options['acting_settings']['zeus']['card_activate'] ) {
315 if ( ! isset( $options['acting_settings']['zeus']['card_order_ref'] ) ) {
316 $options['acting_settings']['zeus']['card_order_ref'] = 'https://linkpt.cardservice.co.jp/cgi-bin/order_ref.cgi';
317 }
318 if ( ! isset( $options['acting_settings']['zeus']['card_price_change'] ) ) {
319 $options['acting_settings']['zeus']['card_price_change'] = 'https://linkpt.cardservice.co.jp/cgi-bin/credit/price_change/reflect/index.cgi';
320 }
321 }
322 update_option( 'usces', $options );
323
324 $this->unavailable_method = array( 'acting_welcart_card', 'acting_escott_card', 'acting_sbps_card', 'acting_paygent_card' );
325 }
326
327 /**
328 * 併用不可決済モジュール
329 * usces_filter_unavailable_payments
330 *
331 * @return array
332 */
333 public function unavailable_payments() {
334 return $this->unavailable_method;
335 }
336
337 /**
338 * 決済有効判定
339 * 支払方法で使用している場合に true
340 *
341 * @param string $type Module type.
342 * @return bool
343 */
344 public function is_validity_acting( $type = '' ) {
345 $acting_opts = $this->get_acting_settings();
346 if ( empty( $acting_opts ) ) {
347 return false;
348 }
349
350 $payment_method = usces_get_system_option( 'usces_payment_method', 'sort' );
351 $method = false;
352
353 switch ( $type ) {
354 case 'card':
355 foreach ( $payment_method as $payment ) {
356 if ( 'acting_zeus_card' === $payment['settlement'] && 'activate' === $payment['use'] ) {
357 $method = true;
358 break;
359 }
360 }
361 if ( $method && $this->is_activate_card() ) {
362 return true;
363 } else {
364 return false;
365 }
366 break;
367
368 case 'bank':
369 foreach ( $payment_method as $payment ) {
370 if ( 'acting_zeus_bank' === $payment['settlement'] && 'activate' === $payment['use'] ) {
371 $method = true;
372 break;
373 }
374 }
375 if ( $method && $this->is_activate_bank() ) {
376 return true;
377 } else {
378 return false;
379 }
380 break;
381
382 case 'conv':
383 foreach ( $payment_method as $payment ) {
384 if ( 'acting_zeus_conv' === $payment['settlement'] && 'activate' === $payment['use'] ) {
385 $method = true;
386 break;
387 }
388 }
389 if ( $method && $this->is_activate_conv() ) {
390 return true;
391 } else {
392 return false;
393 }
394 break;
395
396 case 'bnpl':
397 foreach ( $payment_method as $payment ) {
398 if ( 'acting_zeus_bnpl' === $payment['settlement'] && 'activate' === $payment['use'] ) {
399 $method = true;
400 break;
401 }
402 }
403 if ( $method && $this->is_activate_bnpl() ) {
404 return true;
405 } else {
406 return false;
407 }
408 break;
409
410 default:
411 if ( 'on' === $acting_opts['activate'] ) {
412 return true;
413 } else {
414 return false;
415 }
416 }
417 }
418
419 /**
420 * クレジットカード決済有効判定
421 *
422 * @param string $type 'link' Secure Link|'api' Secure API.
423 * @return boolean
424 */
425 public function is_activate_card( $type = '' ) {
426 $acting_opts = $this->get_acting_settings();
427 if ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) {
428 if ( empty( $type ) ) {
429 if ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] ) {
430 $res = true;
431 } else {
432 $res = false;
433 }
434 } elseif ( 'link' === $type ) {
435 if ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] && isset( $acting_opts['connection'] ) && 1 === (int) $acting_opts['connection'] ) {
436 $res = true;
437 } else {
438 $res = false;
439 }
440 } elseif ( 'api' === $type ) {
441 if ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] && isset( $acting_opts['connection'] ) && 2 === (int) $acting_opts['connection'] ) {
442 $res = true;
443 } else {
444 $res = false;
445 }
446 } else {
447 $res = false;
448 }
449 } else {
450 $res = false;
451 }
452 return $res;
453 }
454
455 /**
456 * 銀行振込決済(�
457 �金おまかせサービス)有効判定
458 *
459 * @return bool
460 */
461 public function is_activate_bank() {
462 $acting_opts = $this->get_acting_settings();
463 if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
464 ( isset( $acting_opts['bank_activate'] ) && 'on' === $acting_opts['bank_activate'] ) ) {
465 $res = true;
466 } else {
467 $res = false;
468 }
469 return $res;
470 }
471
472 /**
473 * コンビニ決済有効判定
474 *
475 * @return bool
476 */
477 public function is_activate_conv() {
478 $acting_opts = $this->get_acting_settings();
479 if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
480 ( isset( $acting_opts['conv_activate'] ) && 'on' === $acting_opts['conv_activate'] ) ) {
481 $res = true;
482 } else {
483 $res = false;
484 }
485 return $res;
486 }
487
488 /**
489 * あと払い決済有効判定
490 *
491 * @return bool
492 */
493 public function is_activate_bnpl() {
494 $acting_opts = $this->get_acting_settings();
495 if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
496 ( isset( $acting_opts['bnpl_activate'] ) && 'on' === $acting_opts['bnpl_activate'] ) ) {
497 $res = true;
498 } else {
499 $res = false;
500 }
501 return $res;
502 }
503
504 /**
505 * 管理画面メッセージ表示
506 * admin_notices
507 */
508 public function admin_notices() {
509 $acting_opts = $this->get_acting_settings();
510 if ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) {
511 if ( ! isset( $acting_opts['vercheck'] ) || '115' !== $acting_opts['vercheck'] ) {
512 echo '<div class="error"><p>決済に「ゼウス」をご利用の場合は、<a href="' . esc_url( admin_url( 'admin.php?usces_page=usces_settlement' ) ) . '">「セキュリティーコード」の設定�
513 容を確認</a>して更新ボタンを押してください。設定を更新するとこのメッセージは表示されなくなります。</p></div>';
514 }
515 }
516 }
517
518 /**
519 * 管理画面スクリプト
520 * admin_print_footer_scripts
521 */
522 public function admin_scripts() {
523 $admin_page = filter_input( INPUT_GET, 'page' );
524 switch ( $admin_page ) :
525 /* クレジット決済設定画面 */
526 case 'usces_settlement':
527 $settlement_selected = get_option( 'usces_settlement_selected', array() );
528 if ( in_array( $this->paymod_id, (array) $settlement_selected, true ) ) :
529 $acting_opts = $this->get_acting_settings();
530 ?>
531 <script type="text/javascript">
532 jQuery(document).ready(function($) {
533 var card_activate = "<?php echo esc_js( $acting_opts['card_activate'] ); ?>";
534 if( "on" == card_activate ) {
535 $(".card_zeus").css("display","");
536 } else {
537 $(".card_zeus").css("display","none");
538 }
539 $(document).on( "change", ".card_activate_zeus", function() {
540 if( "on" == $(this).val() ) {
541 $(".card_zeus").css("display","");
542 } else {
543 $(".card_zeus").css("display","none");
544 }
545 });
546
547 if( '2' == $("input[name='connection']:checked").val() ) {
548 $(".3dsecur_zeus").css("display","");
549 } else {
550 $(".3dsecur_zeus").css("display","none");
551 }
552 $(document).on( "click", "input[name='connection']", function() {
553 if( '2' == $("input[name='connection']:checked").val() ) {
554 $(".3dsecur_zeus").css("display","");
555 } else {
556 $(".3dsecur_zeus").css("display","none");
557 }
558 });
559
560 if( 'on' == $("input[name='howpay']:checked").val() ) {
561 $(".howpay_option_zeus").css("display","");
562 } else {
563 $(".howpay_option_zeus").css("display","none");
564 }
565 $(document).on( "click", "input[name='howpay']", function() {
566 if( 'on' == $("input[name='howpay']:checked").val() ) {
567 $(".howpay_option_zeus").css("display","");
568 } else {
569 $(".howpay_option_zeus").css("display","none");
570 }
571 });
572
573 var bank_activate = "<?php echo esc_js( $acting_opts['bank_activate'] ); ?>";
574 if( "on" == bank_activate ) {
575 $(".bank_zeus").css("display","");
576 } else {
577 $(".bank_zeus").css("display","none");
578 }
579 $(document).on( "change", ".bank_activate_zeus", function() {
580 if( "on" == $(this).val() ) {
581 $(".bank_zeus").css("display","");
582 } else {
583 $(".bank_zeus").css("display","none");
584 }
585 });
586
587 var conv_activate = "<?php echo esc_js( $acting_opts['conv_activate'] ); ?>";
588 if( "on" == conv_activate ) {
589 $(".conv_zeus").css("display","");
590 } else {
591 $(".conv_zeus").css("display","none");
592 }
593 $(document).on( "change", ".conv_activate_zeus", function() {
594 if( "on" == $(this).val() ) {
595 $(".conv_zeus").css("display","");
596 } else {
597 $(".conv_zeus").css("display","none");
598 }
599 });
600
601 var bnpl_activate = "<?php echo esc_js( $acting_opts['bnpl_activate'] ); ?>";
602 if( "on" == bnpl_activate ) {
603 $(".bnpl_zeus").css("display","");
604 } else {
605 $(".bnpl_zeus").css("display","none");
606 }
607 $(document).on( "change", ".bnpl_activate_zeus", function() {
608 if( "on" == $(this).val() ) {
609 $(".bnpl_zeus").css("display","");
610 } else {
611 $(".bnpl_zeus").css("display","none");
612 }
613 });
614
615 adminSettlementZeus = {
616 openFee : function(mode) {
617 $("#fee_change_field").html("");
618 $("#fee_fix").val($("#"+mode+"_fee").val());
619 $("#fee_limit_amount_fix").val($("#"+mode+"_fee_limit_amount_fix").val());
620 $("#fee_first_amount").val($("#"+mode+"_fee_first_amount").val());
621 $("#fee_first_fee").val($("#"+mode+"_fee_first_fee").val());
622 $("#fee_limit_amount_change").val($("#"+mode+"_fee_limit_amount_change").val());
623 var fee_amounts = new Array();
624 var fee_fees = new Array();
625 if( 0 < $("#"+mode+"_fee_amounts").val().length ) {
626 fee_amounts = $("#"+mode+"_fee_amounts").val().split("|");
627 }
628 if( 0 < $("#"+mode+"_fee_fees").val().length ) {
629 fee_fees = $("#"+mode+"_fee_fees").val().split("|");
630 }
631 if( 0 < fee_amounts.length ) {
632 var amount = parseInt($("#fee_first_amount").val()) + 1;
633 for( var i = 0; i < fee_amounts.length; i++ ) {
634 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>';
635 $("#fee_change_field").append(html);
636 amount = parseInt(fee_amounts[i]) + 1;
637 }
638 $("#end_amount").html(amount);
639 } else {
640 $("#end_amount").html(parseInt($("#"+mode+"_fee_first_amount").val()) + 1);
641 }
642 $("#fee_end_fee").val($("#"+mode+"_fee_end_fee").val());
643
644 var fee_type = $("#"+mode+"_fee_type").val();
645 if( "change" == fee_type ) {
646 $("#fee_type_change").prop("checked",true);
647 $("#zeus_fee_fix_table").css("display","none");
648 $("#zeus_fee_change_table").css("display","");
649 } else {
650 $("#fee_type_fix").prop("checked",true);
651 $("#zeus_fee_fix_table").css("display","");
652 $("#zeus_fee_change_table").css("display","none");
653 }
654 },
655
656 updateFee : function(mode) {
657 var fee_type = $("input[name='fee_type']:checked").val();
658 $("#"+mode+"_fee_type").val(fee_type);
659 $("#"+mode+"_fee").val($("#fee_fix").val());
660 $("#"+mode+"_fee_limit_amount_"+fee_type).val($("#fee_limit_amount_"+fee_type).val());
661 $("#"+mode+"_fee_first_amount").val($("#fee_first_amount").val());
662 $("#"+mode+"_fee_first_fee").val($("#fee_first_fee").val());
663 var fee_amounts = "";
664 var fee_fees = "";
665 var sp = "";
666 var fee_amounts_length = $("input[name^='fee_amounts']").length;
667 for( var i = 0; i < fee_amounts_length; i++ ) {
668 fee_amounts += sp + $("input[name='fee_amounts\["+i+"\]']").val();
669 fee_fees += sp + $("input[name='fee_fees\["+i+"\]']").val();
670 sp = "|";
671 }
672 $("#"+mode+"_fee_amounts").val(fee_amounts);
673 $("#"+mode+"_fee_fees").val(fee_fees);
674 $("#"+mode+"_fee_end_fee").val($("#fee_end_fee").val());
675 },
676
677 setFeeType : function( mode, closed ) {
678 var fee_type = $("input[name='fee_type']:checked").val();
679 if( "change" == fee_type ) {
680 if( "" == $("#fee_first_fee").val() && closed ) {
681 $("#"+mode+"_fee_type_field").html("");
682 } else {
683 $("#"+mode+"_fee_type_field").html("<?php esc_attr_e( 'Variable', 'usces' ); ?> ");
684 }
685 if( !closed ) {
686 $("#zeus_fee_fix_table").css("display","none");
687 $("#zeus_fee_change_table").css("display","");
688 }
689 } else if( "fix" == fee_type ) {
690 if( "" == $("#fee_fix").val() && closed ) {
691 $("#"+mode+"_fee_type_field").html("");
692 } else {
693 $("#"+mode+"_fee_type_field").html("<?php esc_attr_e( 'Fixation', 'usces' ); ?> ");
694 }
695 if( !closed ) {
696 $("#zeus_fee_fix_table").css("display","");
697 $("#zeus_fee_change_table").css("display","none");
698 }
699 }
700 }
701 };
702
703 $("#zeus_fee_dialog").dialog({
704 autoOpen: false,
705 height: 500,
706 width: 450,
707 modal: true,
708 open: function() {
709 adminSettlementZeus.openFee($("#zeus_fee_mode").val());
710 },
711 buttons: {
712 "<?php esc_attr_e( 'Settings' ); ?>": function() {
713 adminSettlementZeus.updateFee($("#zeus_fee_mode").val());
714 },
715 "<?php esc_attr_e( 'Close' ); ?>": function() {
716 $(this).dialog('close');
717 }
718 },
719 close: function() {
720 adminSettlementZeus.setFeeType($("#zeus_fee_mode").val(),true);
721 }
722 });
723
724 $(document).on( "click", "#bnpl_fee_setting", function() {
725 $("#zeus_fee_mode").val("bnpl");
726 $("#zeus_fee_dialog").dialog("option","title","請求手数料設定");
727 $("#zeus_fee_dialog").dialog("open");
728 });
729
730 $(document).on( "click", ".fee_type", function() {
731 if( "change" == $(this).val() ) {
732 $("#zeus_fee_fix_table").css("display","none");
733 $("#zeus_fee_change_table").css("display","");
734 } else {
735 $("#zeus_fee_fix_table").css("display","");
736 $("#zeus_fee_change_table").css("display","none");
737 }
738 });
739
740 $(document).on( "change", "input[name='fee_first_amount']", function() {
741 var rows = $("input[name^='fee_amounts']");
742 var first_amount = $("input[name='fee_first_amount']");
743 if( 0 == rows.length && $(first_amount).val() != '' ) {
744 $("#end_amount").html(parseInt($(first_amount).val()) + 1);
745 } else if( 0 < rows.length && $(first_amount).val() != '' ) {
746 $('#amount_0').html(parseInt($(first_amount).val()) + 1);
747 }
748 });
749
750 $(document).on( "change", "#fee_limit_amount_change", function() {
751 if( "change" == $("input[name='fee_type']:checked").val() ) {
752 var amount = parseInt($("#end_amount").html());
753 var limit = parseInt($("#fee_limit_amount_change").val());
754 if( amount >= limit ) {
755 alert("<?php esc_attr_e( 'A value of the amount of upper limit is incorrect.', 'usces' ); ?>"+amount+' : '+limit);
756 }
757 }
758 });
759
760 $(document).on( "change", "input[name^='fee_amounts']", function() {
761 var rows = $("input[name^='fee_amounts']");
762 var cnt = $(rows).length;
763 var end_amount = $("#end_amount");
764 var id = $(rows).index(this);
765 if( id >= cnt-1 ) {
766 $( end_amount ).html(parseInt($(rows).eq(id).val()) + 1);
767 } else if( id < cnt - 1 ) {
768 $("#amount_"+(id + 1)).html(parseInt($(rows).eq(id).val()) + 1);
769 }
770 });
771
772 $(document).on( "click", "#fee_add_row", function() {
773 var rows = $("input[name^='fee_amounts']");
774 $(rows).unbind("change");
775 var first_amount = $("input[name='fee_first_amount']");
776 var first_fee = $("input[name='fee_first_fee']");
777 var end_amount = $("#end_amount");
778 var enf_fee = $("input[name='fee_end_fee']");
779 if( 0 == rows.length ) {
780 amount = ( $(first_amount).val() == '' ) ? '' : parseInt($(first_amount).val()) + 1;
781 } else if( 0 < rows.length ) {
782 amount = ( $(rows).eq(rows.length-1).val() == '' ) ? '' : parseInt($(rows).eq(rows.length-1).val()) + 1;
783 }
784 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>';
785 $("#fee_change_field").append(html);
786 rows = $("input[name^='fee_amounts']");
787 $(rows).bind( "change", function() {
788 var cnt = $(rows).length - 1;
789 var id = $(rows).index(this);
790 if( id >= cnt ) {
791 $(end_amount).html(parseInt($(rows).eq(id).val()) + 1);
792 } else if( id < cnt ) {
793 $("#amount_"+(id + 1)).html(parseInt($(rows).eq(id).val()) + 1);
794 }
795 });
796 });
797
798 $(document).on( "click", "#fee_del_row", function() {
799 var rows = $("input[name^='fee_amounts']");
800 var first_amount = $("input[name='fee_first_amount']");
801 var end_amount = $("#end_amount");
802 var del_id = rows.length - 1;
803 if( 0 < rows.length ) {
804 $("#row_"+del_id).remove();
805 }
806 rows = $("input[name^='fee_amounts']");
807 if( 0 == rows.length && $(first_amount).val() != "" ) {
808 $(end_amount).html(parseInt($(first_amount).val()) + 1);
809 } else if( 0 < rows.length && $(rows).eq(rows.length - 1).val() != "" ) {
810 $(end_amount).html(parseInt($(rows).eq(rows.length - 1).val()) + 1);
811 }
812 });
813
814 adminSettlementZeus.setFeeType("bnpl",false);
815 });
816 </script>
817 <?php
818 endif;
819 break;
820
821 /* 受注編集画面・継続課金会員詳細画面 */
822 case 'usces_orderlist':
823 case 'usces_continue':
824 $order_id = '';
825 $acting_flg = '';
826 $dialog_title = '';
827 $order_action = filter_input( INPUT_GET, 'order_action' );
828 $continue_action = filter_input( INPUT_GET, 'continue_action' );
829 if ( ( 'usces_orderlist' === $admin_page && ( 'edit' === $order_action || 'editpost' === $order_action || 'newpost' === $order_action ) ) ||
830 ( 'usces_continue' === $admin_page && 'settlement_zeus_card' === $continue_action ) ) {
831 $order_id = ( isset( $_REQUEST['order_id'] ) ) ? wp_unslash( $_REQUEST['order_id'] ) : '';
832 if ( ! empty( $order_id ) ) {
833 $payment_name = $this->get_order_payment_name( $order_id );
834 $acting_flg = $this->get_acting_flg( $payment_name );
835 $payment = usces_get_payments_by_name( $payment_name );
836 if ( isset( $payment['name'] ) ) {
837 $dialog_title = $payment['name'];
838 }
839 }
840 }
841 if ( 'acting_zeus_card' === $acting_flg || 'acting_zeus_bnpl' === $acting_flg ) :
842 ?>
843 <script type="text/javascript">
844 jQuery(document).ready(function($) {
845 adminOrderEdit = {
846 <?php
847 if ( 'acting_zeus_card' === $acting_flg ) :
848 ?>
849 getSettlementCard: function() {
850 $("#settlement-response").html("");
851 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
852 var mode = ( "" != $("#error").val() ) ? "error_zeus_card" : "get_zeus_card";
853 $.ajax({
854 url:ajaxurl,
855 type:"POST",
856 cache:false,
857 dataType:"json",
858 data:{
859 action:"usces_admin_ajax",
860 mode:mode,
861 order_id:$("#order_id").val(),
862 order_num:$("#order_num").val(),
863 tracking_id:$("#tracking_id").val(),
864 member_id:$("#member_id").val(),
865 wc_nonce:$("#wc_nonce").val()
866 }
867 }).done( function(retVal,dataType) {
868 if( retVal.acting_status ) {
869 var num = $("#order_num").val();
870 if( $("#settlement-status-"+num).length ) {
871 $("#settlement-status-"+num).html(retVal.acting_status);
872 } else {
873 $("#settlement-status").html(retVal.acting_status);
874 }
875 }
876 if( retVal.result ) {
877 $("#settlement-response").html(retVal.result);
878 }
879 $("#settlement-response-loading").html("");
880 }).fail( function(jqXHR,textStatus,errorThrown) {
881 console.log(textStatus);
882 console.log(jqXHR.status);
883 console.log(errorThrown.message);
884 $("#settlement-response-loading").html("");
885 });
886 return false;
887 },
888 saleSettlementCard: function(amount) {
889 $("#settlement-response").html("");
890 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
891 $.ajax({
892 url:ajaxurl,
893 type:"POST",
894 cache:false,
895 dataType:"json",
896 data:{
897 action:"usces_admin_ajax",
898 mode:"sale_zeus_card",
899 order_id:$("#order_id").val(),
900 order_num:$("#order_num").val(),
901 tracking_id:$("#tracking_id").val(),
902 member_id:$("#member_id").val(),
903 amount:amount,
904 wc_nonce:$("#wc_nonce").val()
905 }
906 }).done( function(retVal,dataType) {
907 if( retVal.acting_status ) {
908 var num = $("#order_num").val();
909 if( $("#settlement-status-"+num).length ) {
910 $("#settlement-status-"+num).html(retVal.acting_status);
911 } else {
912 $("#settlement-status").html(retVal.acting_status);
913 }
914 }
915 if( retVal.result ) {
916 $("#settlement-response").html(retVal.result);
917 }
918 $("#settlement-response-loading").html("");
919 }).fail( function(jqXHR,textStatus,errorThrown) {
920 console.log(textStatus);
921 console.log(jqXHR.status);
922 console.log(errorThrown.message);
923 $("#settlement-response-loading").html("");
924 });
925 return false;
926 },
927 cancelSettlementCard: function() {
928 $("#settlement-response").html("");
929 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
930 $.ajax({
931 url:ajaxurl,
932 type:"POST",
933 cache:false,
934 dataType:"json",
935 data:{
936 action:"usces_admin_ajax",
937 mode:"cancel_zeus_card",
938 order_id:$("#order_id").val(),
939 order_num:$("#order_num").val(),
940 tracking_id:$("#tracking_id").val(),
941 member_id:$("#member_id").val(),
942 wc_nonce:$("#wc_nonce").val()
943 }
944 }).done( function(retVal,dataType) {
945 if( retVal.acting_status ) {
946 var num = $("#order_num").val();
947 if( $("#settlement-status-"+num).length ) {
948 $("#settlement-status-"+num).html(retVal.acting_status);
949 } else {
950 $("#settlement-status").html(retVal.acting_status);
951 }
952 }
953 if( retVal.result ) {
954 $("#settlement-response").html(retVal.result);
955 }
956 $("#settlement-response-loading").html("");
957 }).fail( function(jqXHR,textStatus,errorThrown) {
958 console.log(textStatus);
959 console.log(jqXHR.status);
960 console.log(errorThrown.message);
961 $("#settlement-response-loading").html("");
962 });
963 return false;
964 },
965 changeSettlementCard: function(amount) {
966 $("#settlement-response").html("");
967 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
968 $.ajax({
969 url:ajaxurl,
970 type:"POST",
971 cache:false,
972 dataType:"json",
973 data:{
974 action:"usces_admin_ajax",
975 mode:"change_zeus_card",
976 order_id:$("#order_id").val(),
977 order_num:$("#order_num").val(),
978 tracking_id:$("#tracking_id").val(),
979 member_id:$("#member_id").val(),
980 amount:amount,
981 wc_nonce:$("#wc_nonce").val()
982 }
983 }).done( function(retVal,dataType) {
984 if( retVal.acting_status ) {
985 var num = $("#order_num").val();
986 if( $("#settlement-status-"+num).length ) {
987 $("#settlement-status-"+num).html(retVal.acting_status);
988 } else {
989 $("#settlement-status").html(retVal.acting_status);
990 }
991 }
992 if( retVal.result ) {
993 $("#settlement-response").html(retVal.result);
994 }
995 $("#settlement-response-loading").html("");
996 }).fail( function(jqXHR,textStatus,errorThrown) {
997 console.log(textStatus);
998 console.log(jqXHR.status);
999 console.log(errorThrown.message);
1000 $("#settlement-response-loading").html("");
1001 });
1002 return false;
1003 },
1004 reSettlementCard: function(amount) {
1005 $("#settlement-response").html("");
1006 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
1007 $.ajax({
1008 url:ajaxurl,
1009 type:"POST",
1010 cache:false,
1011 dataType:"json",
1012 data:{
1013 action:"usces_admin_ajax",
1014 mode:"re_settlement_zeus_card",
1015 order_id:$("#order_id").val(),
1016 order_num:$("#order_num").val(),
1017 tracking_id:$("#tracking_id").val(),
1018 member_id:$("#member_id").val(),
1019 amount:amount,
1020 wc_nonce:$("#wc_nonce").val()
1021 }
1022 }).done( function(retVal,dataType) {
1023 if( retVal.acting_status ) {
1024 var num = $("#order_num").val();
1025 if( $("#settlement-status-"+num).length ) {
1026 $("#settlement-status-"+num).html(retVal.acting_status);
1027 } else {
1028 $("#settlement-status").html(retVal.acting_status);
1029 }
1030 }
1031 if( retVal.result ) {
1032 $("#settlement-response").html(retVal.result);
1033 }
1034 $("#settlement-response-loading").html("");
1035 }).fail( function(jqXHR,textStatus,errorThrown) {
1036 console.log(textStatus);
1037 console.log(jqXHR.status);
1038 console.log(errorThrown.message);
1039 $("#settlement-response-loading").html("");
1040 });
1041 return false;
1042 },
1043 <?php
1044 elseif ( 'acting_zeus_bnpl' === $acting_flg ) :
1045 ?>
1046 getSettlementBnpl: function() {
1047 $("#settlement-response").html("");
1048 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
1049 $.ajax({
1050 url:ajaxurl,
1051 type:"POST",
1052 cache:false,
1053 dataType:"json",
1054 data:{
1055 action:"usces_admin_ajax",
1056 mode:"get_zeus_bnpl",
1057 order_id:$("#order_id").val(),
1058 shoporder_id:$("#tracking_id").val(),
1059 order_status:$("select[name='offer[taio]'] option:selected").val(),
1060 delivery_company:$("select[name='delivery_company'] option:selected").val(),
1061 tracking_number:$("input[name='tracking_number']").val(),
1062 wc_nonce:$("#wc_nonce").val()
1063 }
1064 }).done( function(retVal,dataType) {
1065 if( retVal.acting_status ) {
1066 $("#settlement-status").html(retVal.acting_status);
1067 }
1068 if( retVal.result ) {
1069 $("#settlement-response").html(retVal.result);
1070 }
1071 $("#settlement-response-loading").html("");
1072 }).fail( function(jqXHR,textStatus,errorThrown) {
1073 console.log(textStatus);
1074 console.log(jqXHR.status);
1075 console.log(errorThrown.message);
1076 $("#settlement-response-loading").html("");
1077 });
1078 return false;
1079 },
1080 shippingRequestBnpl: function() {
1081 $("#settlement-response").html("");
1082 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
1083 $.ajax({
1084 url:ajaxurl,
1085 type:"POST",
1086 cache:false,
1087 dataType:"json",
1088 data:{
1089 action:"usces_admin_ajax",
1090 mode:"shippingrequest_zeus_bnpl",
1091 order_id:$("#order_id").val(),
1092 shoporder_id:$("#tracking_id").val(),
1093 order_status:$("select[name='offer[taio]'] option:selected").val(),
1094 delivery_company:$("select[name='delivery_company'] option:selected").val(),
1095 tracking_number:$("input[name='tracking_number']").val(),
1096 wc_nonce:$("#wc_nonce").val()
1097 }
1098 }).done( function(retVal,dataType) {
1099 if( retVal.acting_status ) {
1100 $("#settlement-status").html(retVal.acting_status);
1101 }
1102 if( retVal.result ) {
1103 $("#settlement-response").html(retVal.result);
1104 }
1105 $("#settlement-response-loading").html("");
1106 }).fail( function(jqXHR,textStatus,errorThrown) {
1107 console.log(textStatus);
1108 console.log(jqXHR.status);
1109 console.log(errorThrown.message);
1110 $("#settlement-response-loading").html("");
1111 });
1112 return false;
1113 },
1114 cancelBnpl: function() {
1115 $("#settlement-response").html("");
1116 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
1117 $.ajax({
1118 url:ajaxurl,
1119 type:"POST",
1120 cache:false,
1121 dataType:"json",
1122 data:{
1123 action:"usces_admin_ajax",
1124 mode:"cancel_zeus_bnpl",
1125 order_id:$("#order_id").val(),
1126 shoporder_id:$("#tracking_id").val(),
1127 order_status:$("select[name='offer[taio]'] option:selected").val(),
1128 delivery_company:$("select[name='delivery_company'] option:selected").val(),
1129 tracking_number:$("input[name='tracking_number']").val(),
1130 wc_nonce:$("#wc_nonce").val()
1131 }
1132 }).done( function(retVal,dataType) {
1133 if( retVal.acting_status ) {
1134 $("#settlement-status").html(retVal.acting_status);
1135 }
1136 if( retVal.result ) {
1137 $("#settlement-response").html(retVal.result);
1138 }
1139 $("#settlement-response-loading").html("");
1140 }).fail( function(jqXHR,textStatus,errorThrown) {
1141 console.log(textStatus);
1142 console.log(jqXHR.status);
1143 console.log(errorThrown.message);
1144 $("#settlement-response-loading").html("");
1145 });
1146 return false;
1147 },
1148 <?php
1149 endif;
1150 ?>
1151 };
1152
1153 $("#settlement_dialog").dialog({
1154 dialogClass:"admin-zeus-dialog",
1155 bgiframe:true,
1156 autoOpen:false,
1157 height:"auto",
1158 width:800,
1159 resizable:true,
1160 modal:true,
1161 buttons: {
1162 "<?php esc_html_e( 'Close' ); ?>":function() {
1163 $(this).dialog("close");
1164 }
1165 },
1166 open: function() {
1167 <?php
1168 if ( 'acting_zeus_card' === $acting_flg ) :
1169 ?>
1170 adminOrderEdit.getSettlementCard();
1171 <?php
1172 elseif ( 'acting_zeus_bnpl' === $acting_flg ) :
1173 ?>
1174 adminOrderEdit.getSettlementBnpl();
1175 <?php
1176 endif;
1177 ?>
1178 },
1179 close: function() {
1180 }
1181 });
1182
1183 $(document).on( "click", ".settlement-information", function() {
1184 var tracking_id = $(this).attr("data-tracking_id");
1185 var order_num = $(this).attr("data-num");
1186 $("#tracking_id").val(tracking_id);
1187 $("#order_num").val(order_num);
1188 $("#settlement_dialog").dialog("option","title","<?php echo esc_js( $dialog_title ); ?>");
1189 $("#settlement_dialog").dialog("open");
1190 });
1191 <?php
1192 if ( 'acting_zeus_card' === $acting_flg ) :
1193 ?>
1194 $(document).on( "click", "#sale_settlement", function() {
1195 var amount = parseInt($("#amount_change").val())||0;
1196 if( 0 == amount ) {
1197 if( ! confirm("取消処理を実行します。よろしいですか?") ) {
1198 return;
1199 }
1200 adminOrderEdit.cancelSettlementCard();
1201 } else {
1202 if( ! confirm("売上処理を実行します。よろしいですか?") ) {
1203 return;
1204 }
1205 adminOrderEdit.saleSettlementCard(amount);
1206 }
1207 });
1208
1209 $(document).on( "click", "#cancel_settlement", function() {
1210 if( ! confirm("取消処理を実行します。よろしいですか?") ) {
1211 return;
1212 }
1213 adminOrderEdit.cancelSettlementCard();
1214 });
1215
1216 $(document).on( "click", "#change_settlement", function() {
1217 var amount_change = parseInt($("#amount_change").val())||0;
1218 if( 0 == amount_change ) {
1219 if( ! confirm("取消処理を実行します。よろしいですか?") ) {
1220 return;
1221 }
1222 adminOrderEdit.cancelSettlementCard();
1223 } else {
1224 if( ! confirm("決済金額を"+amount_change+"円に変更します。よろしいですか?") ) {
1225 return;
1226 }
1227 adminOrderEdit.changeSettlementCard(amount_change);
1228 }
1229 });
1230
1231 $(document).on( "click", "#re_settlement", function() {
1232 var amount = parseInt($("#amount_change").val())||0;
1233 if( 0 < amount ) {
1234 if( ! confirm("新規決済を実行します。よろしいですか?") ) {
1235 return;
1236 }
1237 adminOrderEdit.reSettlementCard( amount );
1238 }
1239 });
1240 <?php
1241 elseif ( 'acting_zeus_bnpl' === $acting_flg ) :
1242 ?>
1243 $(document).on( "click", "#shippingrequest_bnpl", function() {
1244 if( ! confirm("出荷登録を実行します。よろしいですか?") ) {
1245 return;
1246 }
1247 adminOrderEdit.shippingRequestBnpl();
1248 });
1249 $(document).on( "click", "#cancel_bnpl", function() {
1250 if( ! confirm("取引のキャンセルを実行します。よろしいですか?") ) {
1251 return;
1252 }
1253 adminOrderEdit.cancelBnpl();
1254 });
1255 <?php
1256 endif;
1257 ?>
1258 $(document).on( "keydown", ".settlement-amount", function(e) {
1259 var halfVal = $(this).val().replace(/[-]/g,
1260 function(tmpStr) {
1261 return String.fromCharCode(tmpStr.charCodeAt(0)-0xFEE0);
1262 }
1263 );
1264 $(this).val(halfVal.replace(/[^0-9]/g,''));
1265 });
1266 $(document).on( "keyup", ".settlement-amount", function() {
1267 this.value = this.value.replace(/[^0-9]+/i,'');
1268 this.value = Number(this.value)||0;
1269 });
1270 $(document).on( "blur", ".settlement-amount", function() {
1271 this.value = this.value.replace(/[^0-9]+/i,'');
1272 });
1273 <?php if ( 'usces_continue' === $admin_page ) : ?>
1274 adminContinuation = {
1275 update : function() {
1276 $.ajax({
1277 url: ajaxurl,
1278 type: "POST",
1279 cache: false,
1280 dataType: 'json',
1281 data: {
1282 action: "usces_admin_ajax",
1283 mode: "continuation_update",
1284 member_id: $("#member_id").val(),
1285 order_id: $("#order_id").val(),
1286 contracted_year: $("#contracted-year option:selected").val(),
1287 contracted_month: $("#contracted-month option:selected").val(),
1288 contracted_day: $("#contracted-day option:selected").val(),
1289 charged_year: $("#charged-year option:selected").val(),
1290 charged_month: $("#charged-month option:selected").val(),
1291 charged_day: $("#charged-day option:selected").val(),
1292 price: $("#price").val(),
1293 status: $("#dlseller-status").val(),
1294 wc_nonce: $("#wc_nonce").val()
1295 }
1296 }).done( function(retVal,dataType) {
1297 if( "OK" == retVal.status ) {
1298 adminOperation.setActionStatus("success","<?php esc_html_e( 'The update was completed.', 'usces' ); ?>");
1299 } else {
1300 var message = ( retVal.message != "" ) ? retVal.message : "<?php esc_html_e( 'failure in update', 'usces' ); ?>";
1301 adminOperation.setActionStatus("error",message);
1302 }
1303 }).fail( function(jqXHR,textStatus,errorThrown) {
1304 console.log(textStatus);
1305 console.log(jqXHR.status);
1306 console.log(errorThrown.message);
1307 adminOperation.setActionStatus("error","<?php esc_html_e( 'failure in update', 'usces' ); ?>");
1308 });
1309 return false;
1310 }
1311 };
1312
1313 $(document).on( "click", "#continuation-update", function() {
1314 var status = $("#dlseller-status option:selected").val();
1315 if( "continuation" == status ) {
1316 var year = $("#charged-year option:selected").val();
1317 var month = $("#charged-month option:selected").val();
1318 var day = $("#charged-day option:selected").val();
1319 if( 0 == year || 0 == month || 0 == day ) {
1320 alert("<?php esc_html_e( 'Data have deficiency.', 'usces' ); ?>");
1321 $("#charged-year").focus();
1322 return;
1323 }
1324 if( "" == $("#price").val() || 0 == parseFloat($("#price").val()) ) {
1325 alert("<?php printf( __( 'Input the %s', 'usces' ), esc_html__( 'Amount', 'dlseller' ) ); ?>");
1326 $("#price").focus();
1327 return;
1328 }
1329 }
1330 if( ! confirm("<?php esc_html_e( 'Are you sure you want to update the settings?', 'usces' ); ?>") ) {
1331 return;
1332 }
1333 adminContinuation.update();
1334 });
1335 <?php endif; ?>
1336 });
1337 </script>
1338 <?php
1339 endif;
1340 break;
1341 endswitch;
1342 }
1343
1344 /**
1345 * 決済オプション登録・更新
1346 * usces_action_admin_settlement_update
1347 */
1348 public function settlement_update() {
1349 global $usces;
1350
1351 if ( filter_input( INPUT_POST, 'acting' ) !== $this->paymod_id ) {
1352 return;
1353 }
1354
1355 $this->error_mes = '';
1356 $options = get_option( 'usces', array() );
1357 $payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
1358 $post_data = wp_unslash( $_POST );
1359
1360 unset( $options['acting_settings']['zeus'] );
1361 $options['acting_settings']['zeus']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : '';
1362 $options['acting_settings']['zeus']['clientip'] = ( isset( $post_data['clientip'] ) ) ? trim( $post_data['clientip'] ) : '';
1363 $options['acting_settings']['zeus']['connection'] = ( isset( $post_data['connection'] ) ) ? $post_data['connection'] : 1;
1364 $options['acting_settings']['zeus']['3dsecur'] = ( isset( $post_data['3dsecur'] ) ) ? $post_data['3dsecur'] : 2;
1365 if ( isset( $post_data['3ds_pattern'] ) ) {
1366 $options['acting_settings']['zeus']['3ds_pattern'] = $post_data['3ds_pattern'];
1367 }
1368 $options['acting_settings']['zeus']['security'] = ( isset( $post_data['security'] ) ) ? $post_data['security'] : 2;
1369 if ( isset( $post_data['authkey'] ) ) {
1370 $options['acting_settings']['zeus']['authkey'] = trim( $post_data['authkey'] );
1371 }
1372 $options['acting_settings']['zeus']['quickcharge'] = ( isset( $post_data['quickcharge'] ) ) ? $post_data['quickcharge'] : '';
1373 $options['acting_settings']['zeus']['batch'] = ( isset( $post_data['batch'] ) ) ? $post_data['batch'] : '';
1374 $options['acting_settings']['zeus']['auto_settlement_mail'] = ( isset( $post_data['auto_settlement_mail'] ) ) ? $post_data['auto_settlement_mail'] : 'off';
1375 $options['acting_settings']['zeus']['howpay'] = ( isset( $post_data['howpay'] ) ) ? $post_data['howpay'] : '';
1376 $options['acting_settings']['zeus']['howpay_B1'] = ( isset( $post_data['howpay_B1'] ) ) ? $post_data['howpay_B1'] : '';
1377 $options['acting_settings']['zeus']['howpay_02'] = ( isset( $post_data['howpay_02'] ) ) ? $post_data['howpay_02'] : '';
1378 $options['acting_settings']['zeus']['bank_activate'] = ( isset( $post_data['bank_activate'] ) ) ? $post_data['bank_activate'] : '';
1379 $options['acting_settings']['zeus']['bank_ope'] = ( isset( $post_data['bank_ope'] ) ) ? $post_data['bank_ope'] : '';
1380 $options['acting_settings']['zeus']['clientip_bank'] = ( isset( $post_data['clientip_bank'] ) ) ? trim( $post_data['clientip_bank'] ) : '';
1381 $options['acting_settings']['zeus']['testid_bank'] = ( isset( $post_data['testid_bank'] ) ) ? trim( $post_data['testid_bank'] ) : '';
1382 $options['acting_settings']['zeus']['bank_expired_date'] = ( isset( $post_data['bank_expired_date'] ) ) ? trim( $post_data['bank_expired_date'] ) : '';
1383 $options['acting_settings']['zeus']['conv_activate'] = ( isset( $post_data['conv_activate'] ) ) ? $post_data['conv_activate'] : '';
1384 $options['acting_settings']['zeus']['conv_ope'] = ( isset( $post_data['conv_ope'] ) ) ? $post_data['conv_ope'] : '';
1385 $options['acting_settings']['zeus']['clientip_conv'] = ( isset( $post_data['clientip_conv'] ) ) ? trim( $post_data['clientip_conv'] ) : '';
1386 $options['acting_settings']['zeus']['testid_conv'] = ( isset( $post_data['testid_conv'] ) ) ? trim( $post_data['testid_conv'] ) : '';
1387 $options['acting_settings']['zeus']['test_type_conv'] = ( ( isset( $post_data['testid_conv'] ) && WCUtils::is_blank( $post_data['testid_conv'] ) ) || ( ! isset( $post_data['test_type'] ) ) ) ? 0 : $post_data['test_type'];
1388 $options['acting_settings']['zeus']['pay_cvs'] = ( isset( $post_data['pay_cvs'] ) ) ? $post_data['pay_cvs'] : array();
1389 $options['acting_settings']['zeus']['conv_span'] = ( isset( $post_data['conv_span'] ) ) ? trim( $post_data['conv_span'] ) : '';
1390 $options['acting_settings']['zeus']['bnpl_activate'] = ( isset( $post_data['bnpl_activate'] ) ) ? $post_data['bnpl_activate'] : '';
1391 $options['acting_settings']['zeus']['clientip_bnpl'] = ( isset( $post_data['clientip_bnpl'] ) ) ? trim( $post_data['clientip_bnpl'] ) : '';
1392 $options['acting_settings']['zeus']['bnpl_linkpassword'] = ( isset( $post_data['bnpl_linkpassword'] ) ) ? trim( $post_data['bnpl_linkpassword'] ) : '';
1393 $options['acting_settings']['zeus']['bnpl_fee_type'] = ( isset( $post_data['bnpl_fee_type'] ) ) ? $post_data['bnpl_fee_type'] : '';
1394 $options['acting_settings']['zeus']['bnpl_fee'] = ( isset( $post_data['bnpl_fee'] ) ) ? $post_data['bnpl_fee'] : '';
1395 $options['acting_settings']['zeus']['bnpl_fee_limit_amount'] = ( isset( $post_data[ 'bnpl_fee_limit_amount_' . $options['acting_settings']['zeus']['bnpl_fee_type'] ] ) ) ? $post_data[ 'bnpl_fee_limit_amount_' . $options['acting_settings']['zeus']['bnpl_fee_type'] ] : '';
1396 $options['acting_settings']['zeus']['bnpl_fee_first_amount'] = ( isset( $post_data['bnpl_fee_first_amount'] ) ) ? $post_data['bnpl_fee_first_amount'] : '';
1397 $options['acting_settings']['zeus']['bnpl_fee_first_fee'] = ( isset( $post_data['bnpl_fee_first_fee'] ) ) ? $post_data['bnpl_fee_first_fee'] : '';
1398 $options['acting_settings']['zeus']['bnpl_fee_amounts'] = ( isset( $post_data['bnpl_fee_amounts'] ) ) ? explode( '|', $post_data['bnpl_fee_amounts'] ) : array();
1399 $options['acting_settings']['zeus']['bnpl_fee_fees'] = ( isset( $post_data['bnpl_fee_fees'] ) ) ? explode( '|', $post_data['bnpl_fee_fees'] ) : array();
1400 $options['acting_settings']['zeus']['bnpl_fee_end_fee'] = ( isset( $post_data['bnpl_fee_end_fee'] ) ) ? $post_data['bnpl_fee_end_fee'] : '';
1401
1402 if ( 'on' === $options['acting_settings']['zeus']['card_activate'] ) {
1403 if ( WCUtils::is_blank( $post_data['clientip'] ) ) {
1404 $this->error_mes .= '※カード決済IPコードを�
1405 �力してください<br />';
1406 }
1407 if ( WCUtils::is_blank( $post_data['authkey'] ) && 2 === (int) $post_data['connection'] ) {
1408 $this->error_mes .= '※認証キーを�
1409 �力してください<br />';
1410 }
1411 if ( isset( $post_data['batch'] ) && 'on' === $post_data['batch'] ) {
1412 if ( isset( $post_data['quickcharge'] ) && 'on' === $post_data['quickcharge'] ) {
1413 } else {
1414 $this->error_mes .= '※バッチ処理を利用する場合は、QuickCharge を「利用する」にしてください<br />';
1415 $options['acting_settings']['zeus']['quickcharge'] = 'on';
1416 }
1417 }
1418 }
1419 if ( 'on' === $options['acting_settings']['zeus']['bank_activate'] ) {
1420 if ( WCUtils::is_blank( $post_data['clientip_bank'] ) ) {
1421 $this->error_mes .= '※銀行振込決済(�
1422 �金おまかせサービス)IPコードを�
1423 �力してください<br />';
1424 }
1425 if ( WCUtils::is_blank( $post_data['testid_bank'] ) && isset( $post_data['bank_ope'] ) && 'test' === $post_data['bank_ope'] ) {
1426 $this->error_mes .= '※銀行振込決済(�
1427 �金おまかせサービス)テストIDを�
1428 �力してください<br />';
1429 }
1430 }
1431 if ( 'on' === $options['acting_settings']['zeus']['conv_activate'] ) {
1432 if ( WCUtils::is_blank( $post_data['clientip_conv'] ) ) {
1433 $this->error_mes .= '※コンビニ決済IPコードを�
1434 �力してください<br />';
1435 }
1436 if ( WCUtils::is_blank( $post_data['testid_conv'] ) && isset( $post_data['conv_ope'] ) && 'test' === $post_data['conv_ope'] ) {
1437 $this->error_mes .= '※コンビニ決済テストIDを�
1438 �力してください<br />';
1439 }
1440 if ( empty( $post_data['pay_cvs'] ) ) {
1441 $this->error_mes .= '※コンビニ種類を選択してください<br />';
1442 }
1443 }
1444 if ( 'on' === $options['acting_settings']['zeus']['bnpl_activate'] ) {
1445 if ( WCUtils::is_blank( $post_data['clientip_bnpl'] ) ) {
1446 $this->error_mes .= '※あと払い決済IPコードを�
1447 �力してください<br />';
1448 }
1449 if ( WCUtils::is_blank( $post_data['bnpl_linkpassword'] ) ) {
1450 $this->error_mes .= '※あと払い決済APIキーを�
1451 �力してください<br />';
1452 }
1453 }
1454 if ( 'on' === $options['acting_settings']['zeus']['card_activate'] || 'on' === $options['acting_settings']['zeus']['bank_activate'] || 'on' === $options['acting_settings']['zeus']['conv_activate'] || 'on' === $options['acting_settings']['zeus']['bnpl_activate'] ) {
1455 $unavailable_activate = false;
1456 foreach ( $payment_method as $settlement => $payment ) {
1457 if ( in_array( $settlement, $this->unavailable_method ) && 'activate' === $payment['use'] ) {
1458 $unavailable_activate = true;
1459 break;
1460 }
1461 }
1462 if ( $unavailable_activate ) {
1463 $this->error_mes .= __( '* Settlement that can not be used together is activated.', 'usces' ) . '<br />';
1464 }
1465 }
1466
1467 if ( '' === $this->error_mes ) {
1468 $usces->action_status = 'success';
1469 $usces->action_message = __( 'Options are updated.', 'usces' );
1470 if ( 'on' === $options['acting_settings']['zeus']['card_activate'] || 'on' === $options['acting_settings']['zeus']['bank_activate'] || 'on' === $options['acting_settings']['zeus']['conv_activate'] || 'on' === $options['acting_settings']['zeus']['bnpl_activate'] ) {
1471 $options['acting_settings']['zeus']['activate'] = 'on';
1472 $options['acting_settings']['zeus']['ipaddrs'] = array( '210.164.6.67', '202.221.139.50' );
1473 $toactive = array();
1474 if ( 'on' === $options['acting_settings']['zeus']['card_activate'] ) {
1475 $options['acting_settings']['zeus']['card_url'] = 'https://linkpt.cardservice.co.jp/cgi-bin/secure.cgi';
1476 $options['acting_settings']['zeus']['card_secureurl'] = 'https://linkpt.cardservice.co.jp/cgi-bin/secure/api.cgi';
1477 $options['acting_settings']['zeus']['card_tokenurl'] = 'https://linkpt.cardservice.co.jp/cgi-bin/token/token.cgi';
1478 $options['acting_settings']['zeus']['card_order_ref'] = 'https://linkpt.cardservice.co.jp/cgi-bin/order_ref.cgi';
1479 $options['acting_settings']['zeus']['card_price_change'] = 'https://linkpt.cardservice.co.jp/cgi-bin/credit/price_change/reflect/index.cgi';
1480 $usces->payment_structure['acting_zeus_card'] = 'カード決済(ZEUS)';
1481 foreach ( $payment_method as $settlement => $payment ) {
1482 if ( 'acting_zeus_card' === $settlement && 'activate' !== $payment['use'] ) {
1483 $toactive[] = $payment['name'];
1484 }
1485 }
1486 } else {
1487 unset( $usces->payment_structure['acting_zeus_card'] );
1488 }
1489 if ( 'on' === $options['acting_settings']['zeus']['bank_activate'] ) {
1490 $options['acting_settings']['zeus']['bank_url'] = 'https://linkpt.cardservice.co.jp/cgi-bin/ebank.cgi';
1491 $usces->payment_structure['acting_zeus_bank'] = '銀行振込決済(ZEUS)';
1492 foreach ( $payment_method as $settlement => $payment ) {
1493 if ( 'acting_zeus_bank' === $settlement && 'activate' !== $payment['use'] ) {
1494 $toactive[] = $payment['name'];
1495 }
1496 }
1497 } else {
1498 unset( $usces->payment_structure['acting_zeus_bank'] );
1499 }
1500 if ( 'on' === $options['acting_settings']['zeus']['conv_activate'] ) {
1501 $options['acting_settings']['zeus']['conv_url'] = 'https://linkpt.cardservice.co.jp/cgi-bin/cvs.cgi';
1502 $usces->payment_structure['acting_zeus_conv'] = 'コンビニ決済(ZEUS)';
1503 foreach ( $payment_method as $settlement => $payment ) {
1504 if ( 'acting_zeus_conv' === $settlement && 'activate' !== $payment['use'] ) {
1505 $toactive[] = $payment['name'];
1506 }
1507 }
1508 } else {
1509 unset( $usces->payment_structure['acting_zeus_conv'] );
1510 }
1511 if ( 'on' === $options['acting_settings']['zeus']['bnpl_activate'] ) {
1512 $options['acting_settings']['zeus']['bnpl_linkid'] = 'sbifsprd01';
1513 $options['acting_settings']['zeus']['bnpl_transaction_url'] = 'https://atobarai.sbi-finsol.co.jp/api/transaction.do';
1514 $options['acting_settings']['zeus']['bnpl_shippingrequest_url'] = 'https://atobarai.sbi-finsol.co.jp/api/shippingrequest.do';
1515 $options['acting_settings']['zeus']['bnpl_modifytransaction_url'] = 'https://atobarai.sbi-finsol.co.jp/api/modifytransaction.do';
1516 $usces->payment_structure['acting_zeus_bnpl'] = 'あと払い決済(ZEUS)';
1517 foreach ( $payment_method as $settlement => $payment ) {
1518 if ( 'acting_zeus_bnpl' === $settlement && 'activate' !== $payment['use'] ) {
1519 $toactive[] = $payment['name'];
1520 }
1521 }
1522 } else {
1523 unset( $usces->payment_structure['acting_zeus_bnpl'] );
1524 }
1525 $options['acting_settings']['zeus']['vercheck'] = '115';
1526 usces_admin_orderlist_show_wc_trans_id();
1527 if ( 0 < count( $toactive ) ) {
1528 $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' );
1529 }
1530 } else {
1531 $options['acting_settings']['zeus']['activate'] = 'off';
1532 unset( $usces->payment_structure['acting_zeus_card'], $usces->payment_structure['acting_zeus_bank'], $usces->payment_structure['acting_zeus_conv'], $usces->payment_structure['acting_zeus_bnpl'] );
1533 }
1534 if ( 'on' !== $options['acting_settings']['zeus']['quickcharge'] || 'off' === $options['acting_settings']['zeus']['activate'] ) {
1535 usces_clear_quickcharge( 'zeus_pcid' );
1536 }
1537 $deactivate = array();
1538 foreach ( $payment_method as $settlement => $payment ) {
1539 if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
1540 if ( 'deactivate' !== $payment['use'] ) {
1541 $payment['use'] = 'deactivate';
1542 $deactivate[] = $payment['name'];
1543 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
1544 }
1545 }
1546 }
1547 if ( 0 < count( $deactivate ) ) {
1548 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
1549 $usces->action_message .= $deactivate_message;
1550 }
1551 } else {
1552 $usces->action_status = 'error';
1553 $usces->action_message = __( 'Data have deficiency.', 'usces' );
1554 $options['acting_settings']['zeus']['activate'] = 'off';
1555 unset( $usces->payment_structure['acting_zeus_card'], $usces->payment_structure['acting_zeus_bank'], $usces->payment_structure['acting_zeus_conv'], $usces->payment_structure['acting_zeus_bnpl'] );
1556 $deactivate = array();
1557 foreach ( $payment_method as $settlement => $payment ) {
1558 if ( in_array( $settlement, $this->pay_method ) ) {
1559 if ( 'deactivate' !== $payment['use'] ) {
1560 $payment['use'] = 'deactivate';
1561 $deactivate[] = $payment['name'];
1562 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
1563 }
1564 }
1565 }
1566 if ( 0 < count( $deactivate ) ) {
1567 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
1568 $usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
1569 }
1570 }
1571 ksort( $usces->payment_structure );
1572 update_option( 'usces', $options );
1573 update_option( 'usces_payment_structure', $usces->payment_structure );
1574 }
1575
1576 /**
1577 * クレジット決済設定画面タブ
1578 * usces_action_settlement_tab_title
1579 */
1580 public function settlement_tab_title() {
1581 $settlement_selected = get_option( 'usces_settlement_selected', array() );
1582 if ( in_array( 'zeus', (array) $settlement_selected, true ) ) {
1583 echo '<li><a href="#uscestabs_zeus">ゼウス</a></li>';
1584 }
1585 }
1586
1587 /**
1588 * クレジット決済設定画面フォーム
1589 * usces_action_settlement_tab_body
1590 */
1591 public function settlement_tab_body() {
1592 global $usces;
1593
1594 $acting_opts = $this->get_acting_settings();
1595 $settlement_selected = get_option( 'usces_settlement_selected', array() );
1596 if ( in_array( 'zeus', (array) $settlement_selected, true ) ) :
1597 $card_activate = ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] ) ? 'on' : 'off';
1598 $client_ip = ( isset( $acting_opts['clientip'] ) ) ? $acting_opts['clientip'] : '';
1599 $connection = ( isset( $acting_opts['connection'] ) ) ? (int) $acting_opts['connection'] : 0;
1600 $authkey = ( isset( $acting_opts['authkey'] ) ) ? $acting_opts['authkey'] : '';
1601 $threedsecure = ( 2 === $connection && isset( $acting_opts['3dsecur'] ) && 1 === (int) $acting_opts['3dsecur'] ) ? 1 : 2;
1602 $pattern = ( 2 === $connection && isset( $acting_opts['3ds_pattern'] ) ) ? $acting_opts['3ds_pattern'] : '';
1603 $security = ( isset( $acting_opts['security'] ) && 1 === (int) $acting_opts['security'] ) ? 1 : 2;
1604 $quickcharge = ( isset( $acting_opts['quickcharge'] ) && 'on' === $acting_opts['quickcharge'] ) ? $acting_opts['quickcharge'] : 'off';
1605 $batch = ( isset( $acting_opts['batch'] ) && 'on' === $acting_opts['batch'] ) ? $acting_opts['batch'] : 'off';
1606 $howpay = ( isset( $acting_opts['howpay'] ) && 'on' === $acting_opts['howpay'] ) ? $acting_opts['howpay'] : 'off';
1607 $howpay_b1 = ( isset( $acting_opts['howpay_B1'] ) && 'on' === $acting_opts['howpay_B1'] ) ? $acting_opts['howpay_B1'] : '';
1608 $howpay_02 = ( isset( $acting_opts['howpay_02'] ) && 'on' === $acting_opts['howpay_02'] ) ? $acting_opts['howpay_02'] : '';
1609 $wcex_name = '';
1610 if ( defined( 'WCEX_DLSELLER' ) ) {
1611 $wcex_name = '自動継続課金';
1612 } elseif ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
1613 $wcex_name = '定期購�
1614 �';
1615 }
1616 $auto_settlement_mail = ( isset( $acting_opts['auto_settlement_mail'] ) && 'on' === $acting_opts['auto_settlement_mail'] ) ? 'on' : 'off';
1617
1618 $bank_activate = ( isset( $acting_opts['bank_activate'] ) && 'on' === $acting_opts['bank_activate'] ) ? 'on' : 'off';
1619 $bank_ope = ( isset( $acting_opts['bank_ope'] ) && 'public' === $acting_opts['bank_ope'] ) ? 'public' : 'test';
1620 $client_ip_bank = ( isset( $acting_opts['clientip_bank'] ) ) ? $acting_opts['clientip_bank'] : '';
1621 $testid_bank = ( isset( $acting_opts['testid_bank'] ) ) ? $acting_opts['testid_bank'] : '';
1622 $bank_expired_date = ( isset( $acting_opts['bank_expired_date'] ) ) ? $acting_opts['bank_expired_date'] : '';
1623
1624 $conv_activate = ( isset( $acting_opts['conv_activate'] ) && 'on' === $acting_opts['conv_activate'] ) ? 'on' : 'off';
1625 $conv_ope = ( isset( $acting_opts['conv_ope'] ) && 'public' === $acting_opts['conv_ope'] ) ? 'public' : 'test';
1626 $client_ip_conv = ( isset( $acting_opts['clientip_conv'] ) ) ? $acting_opts['clientip_conv'] : '';
1627 $testid_conv = ( isset( $acting_opts['testid_conv'] ) ) ? $acting_opts['testid_conv'] : '';
1628 $test_type_conv = ( isset( $acting_opts['test_type_conv'] ) ) ? (int) $acting_opts['test_type_conv'] : 0;
1629 $pay_cvs = ( isset( $acting_opts['pay_cvs'] ) && is_array( $acting_opts['pay_cvs'] ) ) ? $acting_opts['pay_cvs'] : array();
1630 $conv_span = ( isset( $acting_opts['conv_span'] ) ) ? $acting_opts['conv_span'] : '';
1631
1632 $bnpl_activate = ( isset( $acting_opts['bnpl_activate'] ) && 'on' === $acting_opts['bnpl_activate'] ) ? 'on' : 'off';
1633 $client_ip_bnpl = ( isset( $acting_opts['clientip_bnpl'] ) ) ? $acting_opts['clientip_bnpl'] : '';
1634 $bnpl_linkpassword = ( isset( $acting_opts['bnpl_linkpassword'] ) ) ? $acting_opts['bnpl_linkpassword'] : '';
1635
1636 if ( 'fix' === $acting_opts['bnpl_fee_type'] ) {
1637 $bnpl_fee_type_field = ( ! empty( $acting_opts['bnpl_fee'] ) ) ? $this->get_fee_name( $acting_opts['bnpl_fee_type'] ) . ' ' : '';
1638 } elseif ( 'change' === $acting_opts['bnpl_fee_type'] ) {
1639 $bnpl_fee_type_field = ( ! empty( $acting_opts['bnpl_fee_first_fee'] ) ) ? $this->get_fee_name( $acting_opts['bnpl_fee_type'] ) . ' ' : '';
1640 } else {
1641 $bnpl_fee_type_field = '';
1642 }
1643 ?>
1644 <div id="uscestabs_zeus">
1645 <div class="settlement_service"><span class="service_title"><?php echo esc_html( $this->acting_formal_name ); ?></span></div>
1646 <?php
1647 if ( 'zeus' === filter_input( INPUT_POST, 'acting' ) ) :
1648 if ( '' !== $this->error_mes ) :
1649 ?>
1650 <div class="error_message"><?php echo wp_kses_post( $this->error_mes ); ?></div>
1651 <?php
1652 elseif ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) :
1653 ?>
1654 <div class="message">十分にテストを行ってから運用してください。</div>
1655 <?php
1656 endif;
1657 endif;
1658 ?>
1659 <form action="" method="post" name="zeus_form" id="zeus_form">
1660 <table class="settle_table">
1661 <tr>
1662 <th>クレジットカード決済</th>
1663 <td><label><input name="card_activate" type="radio" class="card_activate_zeus" id="card_activate_zeus_1" value="on"<?php checked( $card_activate, 'on' ); ?> /><span>利用する</span></label><br />
1664 <label><input name="card_activate" type="radio" class="card_activate_zeus" id="card_activate_zeus_2" value="off"<?php checked( $card_activate, 'off' ); ?> /><span>利用しない</span></label>
1665 </td>
1666 </tr>
1667 <tr class="card_zeus">
1668 <th><a class="explanation-label" id="label_ex_clid_zeus">カード決済IPコード</a></th>
1669 <td><input name="clientip" type="text" id="clid_zeus" value="<?php echo esc_attr( $client_ip ); ?>" class="regular-text" /></td>
1670 </tr>
1671 <tr id="ex_clid_zeus" class="explanation card_zeus"><td colspan="2">契約時にゼウスから発行されるクレジットカード決済用のIPコード(半角数字)</td></tr>
1672 <tr class="card_zeus">
1673 <th><a class="explanation-label" id="label_ex_connection_zeus">接続方式</a></th>
1674 <td><label><input name="connection" type="radio" id="connection_zeus_1" value="1"<?php checked( $connection, 1 ); ?> /><span>Secure Link</span></label><br />
1675 <label><input name="connection" type="radio" id="connection_zeus_2" value="2"<?php checked( $connection, 2 ); ?> /><span>Secure API</span></label>
1676 </td>
1677 </tr>
1678 <tr id="ex_connection_zeus" class="explanation card_zeus"><td colspan="2">認証接続方法。契約に従って指定する�
1679 要があります。</td></tr>
1680 <tr class="card_zeus">
1681 <th><a class="explanation-label" id="label_ex_authkey_zeus">認証キー</a></th>
1682 <td><input name="authkey" type="text" id="clid_zeus" value="<?php echo esc_attr( $authkey ); ?>" class="regular-text" /></td>
1683 </tr>
1684 <tr id="ex_authkey_zeus" class="explanation card_zeus"><td colspan="2">契約時にゼウスから発行される認証キー(半角数字)</td></tr>
1685 <tr class="card_zeus 3dsecur_zeus">
1686 <th><a class="explanation-label" id="label_ex_3dsecur_zeus">3Dセキュア(※)</a></th>
1687 <td><label><input name="3dsecur" type="radio" id="3dsecur_zeus_1" value="1"<?php checked( $threedsecure, 1 ); ?> /><span>利用する</span></label><br />
1688 <label><input name="3dsecur" type="radio" id="3dsecur_zeus_2" value="2"<?php checked( $threedsecure, 2 ); ?> /><span>利用しない</span></label>
1689 </td>
1690 </tr>
1691 <tr id="ex_3dsecur_zeus" class="explanation card_zeus 3dsecur_zeus"><td colspan="2">3Dセキュアを利用するには Secure API を利用した接続が�
1692 要です。契約に従って指定する�
1693 要があります。</td></tr>
1694 <tr class="card_zeus">
1695 <th><a class="explanation-label" id="label_ex_security_zeus">セキュリティーコード(※)</a></th>
1696 <td><label><input name="security" type="radio" id="security_zeus_1" value="1"<?php checked( $security, 1 ); ?> /><span>利用する</span></label><br />
1697 <label><input name="security" type="radio" id="security_zeus_2" value="2"<?php checked( $security, 2 ); ?> /><span>利用しない</span></label>
1698 </td>
1699 </tr>
1700 <tr id="ex_security_zeus" class="explanation card_zeus"><td colspan="2">セキュリティーコードの�
1701 �力を�
1702 須とするかどうかを指定します。契約に従って指定する�
1703 要があります。</td></tr>
1704 <tr class="card_zeus">
1705 <th><a class="explanation-label" id="label_ex_quickcharge_zeus">QuickCharge</a></th>
1706 <td><label><input name="quickcharge" type="radio" id="quickcharge_zeus_1" value="on"<?php checked( $quickcharge, 'on' ); ?> /><span>利用する</span></label><br />
1707 <label><input name="quickcharge" type="radio" id="quickcharge_zeus_2" value="off"<?php checked( $quickcharge, 'off' ); ?> /><span>利用しない</span></label>
1708 </td>
1709 </tr>
1710 <tr id="ex_quickcharge_zeus" class="explanation card_zeus"><td colspan="2">ログインして一度購�
1711 �したメンバーは、次の購�
1712 �時にはカード番号を�
1713 �力する�
1714 要がなくなります。</td></tr>
1715 <?php if ( defined( 'WCEX_DLSELLER' ) || defined( 'WCEX_AUTO_DELIVERY' ) ) : ?>
1716 <tr class="card_zeus">
1717 <th><a class="explanation-label" id="label_ex_batch_zeus">バッチ処理</a></th>
1718 <td><label><input name="batch" type="radio" id="batch_zeus_1" value="on"<?php checked( $batch, 'on' ); ?> /><span>利用する</span></label><br />
1719 <label><input name="batch" type="radio" id="batch_zeus_2" value="off"<?php checked( $batch, 'off' ); ?> /><span>利用しない</span></label>
1720 </td>
1721 </tr>
1722 <tr id="ex_batch_zeus" class="explanation card_zeus"><td colspan="2">ゼウス決済を<?php echo esc_html( $wcex_name ); ?>でご利用の場合は、「利用する」にしてください。また、QuickCharge も「利用する」にしてください。</td></tr>
1723 <?php endif; ?>
1724 <?php if ( defined( 'WCEX_DLSELLER' ) ) : ?>
1725 <tr class="card_zeus">
1726 <th><a class="explanation-label" id="label_ex_auto_settlement_mail_zeus">自動継続課金完了メール</a></th>
1727 <td><label><input name="auto_settlement_mail" type="radio" id="auto_settlement_mail_zeus_on" value="on"<?php checked( $auto_settlement_mail, 'on' ); ?> /><span><?php esc_html_e( 'Send', 'usces' ); ?></span></label><br />
1728 <label><input name="auto_settlement_mail" type="radio" id="auto_settlement_mail_zeus_off" value="off"<?php checked( $auto_settlement_mail, 'off' ); ?> /><span><?php esc_html_e( "Don't send", 'usces' ); ?></span></label>
1729 </td>
1730 </tr>
1731 <tr id="ex_auto_settlement_mail_zeus" class="explanation card_zeus"><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>
1732 <?php endif; ?>
1733 <tr class="card_zeus">
1734 <th><a class="explanation-label" id="label_ex_howpay_zeus">お客様の支払方法</a></th>
1735 <td><label><input name="howpay" type="radio" id="howpay_zeus_2" value="off"<?php checked( $howpay, 'off' ); ?> /><span>一括払いのみ</span></label><br />
1736 <label><input name="howpay" type="radio" id="howpay_zeus_1" value="on"<?php checked( $howpay, 'on' ); ?> /><span>分割払いに対応する</span></label><br />
1737 <div class="howpay_option_zeus">
1738 <label><input name="howpay_B1" type="checkbox" id="howpay_zeus_B1" value="on"<?php checked( $howpay_b1, 'on' ); ?> /><span>ボーナス一括に対応する</span></label><br />
1739 <label><input name="howpay_02" type="checkbox" id="howpay_zeus_02" value="on"<?php checked( $howpay_02, 'on' ); ?> /><span>2回払いに対応する</span></label>
1740 </div/>
1741 </td>
1742 </tr>
1743 <tr id="ex_howpay_zeus" class="explanation card_zeus"><td colspan="2">お客様が利用するクレジットカードのカード会社により、選択できる分割回数が異なります。ボーナス一括、2回払いは契約がある場合にのみご利用いただけます。<?php if ( ! empty( $wcex_name ) ) echo esc_html( $wcex_name ) . '商品は常に「一括払い」で決済されます。'; ?></td></tr>
1744 </table>
1745 <table class="settle_table">
1746 <tr>
1747 <th><a class="explanation-label" id="label_ex_bank_zeus">銀行振込決済(�
1748 �金おまかせサービス)</a></th>
1749 <td><label><input name="bank_activate" type="radio" class="bank_activate_zeus" id="bank_activate_zeus_1" value="on"<?php checked( $bank_activate, 'on' ); ?> /><span>利用する</span></label><br />
1750 <label><input name="bank_activate" type="radio" class="bank_activate_zeus" id="bank_activate_zeus_2" value="off"<?php checked( $bank_activate, 'off' ); ?> /><span>利用しない</span></label>
1751 </td>
1752 </tr>
1753 <tr id="ex_bank_zeus" class="explanation"><td colspan="2">銀行振込支払いの自動�
1754 �会機能です。振込みがあった場合、自動的に�
1755 �金済みになり、�
1756 �金確認メールが自動送信されます。</td></tr>
1757 <tr class="bank_zeus">
1758 <th><a class="explanation-label" id="label_ex_bank_ope_zeus">稼働環境</a></th>
1759 <td><label><input name="bank_ope" type="radio" id="bank_ope_zeus_1" value="test"<?php checked( $bank_ope, 'test' ); ?> /><span>テスト環境</span></label><br />
1760 <label><input name="bank_ope" type="radio" id="bank_ope_zeus_2" value="public"<?php checked( $bank_ope, 'public' ); ?> /><span>本番環境</span></label>
1761 </td>
1762 </tr>
1763 <tr id="ex_bank_ope_zeus" class="explanation bank_zeus"><td colspan="2">動作環境を切り替えます。</td></tr>
1764 <tr class="bank_zeus">
1765 <th><a class="explanation-label" id="label_ex_bank_clid_zeus">銀行振込決済IPコード</a></th>
1766 <td><input name="clientip_bank" type="text" id="bank_clid_zeus" value="<?php echo esc_attr( $client_ip_bank ); ?>" class="regular-text" /></td>
1767 </tr>
1768 <tr id="ex_bank_clid_zeus" class="explanation bank_zeus"><td colspan="2">契約時にゼウスから発行される�
1769 �金おまかせサービス用のIPコード(半角数字)</td></tr>
1770 <tr class="bank_zeus">
1771 <th><a class="explanation-label" id="label_ex_bank_testid_zeus">テストID</a></th>
1772 <td><input name="testid_bank" type="text" id="testid_bank_zeus" value="<?php echo esc_attr( $testid_bank ); ?>" class="regular-text" /></td>
1773 </tr>
1774 <tr id="ex_bank_testid_zeus" class="explanation bank_zeus"><td colspan="2">契約時にゼウスから発行される�
1775 �金おまかせサービス接続テストで�
1776 要なテストID(半角数字)</td></tr>
1777 <tr class="bank_zeus">
1778 <th><a class="explanation-label" id="label_ex_bank_expired_date_zeus">支払期日</a></th>
1779 <td>当日+<select name="bank_expired_date">
1780 <option value=""></option>
1781 <?php for ( $i = 1; $i <= 30; $i++ ) : ?>
1782 <option value="<?php echo esc_html( $i ); ?>"<?php selected( $bank_expired_date, $i, true ); ?>><?php echo esc_html( $i ); ?></option>
1783 <?php endfor; ?>
1784 </select></td>
1785 </tr>
1786 <tr id="ex_bank_expired_date_zeus" class="explanation"><td colspan="2">お申し込みごとに支払期日を設定することができます。設定がない場合には、予め設定していた加盟店指定の支払期日が設定されます。</td></tr>
1787 </table>
1788 <table class="settle_table">
1789 <tr>
1790 <th><a class="explanation-label" id="label_ex_conv_zeus">コンビニ決済サービス</a></th>
1791 <td><label><input name="conv_activate" type="radio" class="conv_activate_zeus" id="conv_activate_zeus_1" value="on"<?php checked( $conv_activate, 'on' ); ?> /><span>利用する</span></label><br />
1792 <label><input name="conv_activate" type="radio" class="conv_activate_zeus" id="conv_activate_zeus_2" value="off"<?php checked( $conv_activate, 'off' ); ?> /><span>利用しない</span></label>
1793 </td>
1794 </tr>
1795 <tr id="ex_conv_zeus" class="explanation"><td colspan="2">コンビニ支払いができる決済サービスです。払い込みがあった場合、自動的に�
1796 �金済みになります。</td></tr>
1797 <tr class="conv_zeus">
1798 <th><a class="explanation-label" id="label_ex_conv_ope_zeus">稼働環境</a></th>
1799 <td><label><input name="conv_ope" type="radio" id="conv_ope_zeus_1" value="test"<?php checked( $conv_ope, 'test' ); ?> /><span>テスト環境</span></label><br />
1800 <label><input name="conv_ope" type="radio" id="conv_ope_zeus_2" value="public"<?php checked( $conv_ope, 'public' ); ?> /><span>本番環境</span></label>
1801 </td>
1802 </tr>
1803 <tr id="ex_conv_ope_zeus" class="explanation conv_zeus"><td colspan="2">動作環境を切り替えます。</td></tr>
1804 <tr class="conv_zeus">
1805 <th><a class="explanation-label" id="label_ex_conv_clid_zeus">コンビニ決済IPコード</a></th>
1806 <td><input name="clientip_conv" type="text" id="conv_clid_zeus" value="<?php echo esc_attr( $client_ip_conv ); ?>" class="regular-text" /></td>
1807 </tr>
1808 <tr id="ex_conv_clid_zeus" class="explanation conv_zeus"><td colspan="2">契約時にゼウスから発行されるコンビニ決済サービス用のIPコード(半角数字)</td></tr>
1809 <tr class="conv_zeus">
1810 <th><a class="explanation-label" id="label_ex_conv_testid_zeus">テストID</a></th>
1811 <td><input name="testid_conv" type="text" id="testid_conv_zeus" value="<?php echo esc_attr( $testid_conv ); ?>" class="regular-text" /></td>
1812 </tr>
1813 <tr id="ex_conv_testid_zeus" class="explanation conv_zeus"><td colspan="2">契約時にゼウスから発行されるコンビニ決済サービス接続テストで�
1814 要なテストID(半角数字)</td></tr>
1815 <tr class="conv_zeus">
1816 <th><a class="explanation-label" id="label_ex_conv_testtype_zeus">テストタイプ</a></th>
1817 <td><label><input name="test_type" type="radio" id="conv_testtype_zeus_1" value="0"<?php checked( $test_type_conv, 0 ); ?> /><span>�
1818 �金テスト無し</span></label><br />
1819 <label><input name="test_type" type="radio" id="conv_testtype_zeus_2" value="1"<?php checked( $test_type_conv, 1 ); ?> /><span>売上確定テスト</span></label><br />
1820 <label><input name="test_type" type="radio" id="conv_testtype_zeus_3" value="2"<?php checked( $test_type_conv, 2 ); ?> /><span>売上取消テスト</span></label>
1821 </td>
1822 </tr>
1823 <tr id="ex_conv_testtype_zeus" class="explanation conv_zeus"><td colspan="2">テスト環境でのテストタイプを指定します。</td></tr>
1824 <tr class="conv_zeus">
1825 <th rowspan="6"><a class="explanation-label" id="label_ex_pay_cvs_zeus">コンビニ種類</a></th>
1826 <td><label><input name="pay_cvs[]" type="checkbox" id="pay_cvs_D001" value="D001"<?php checked( in_array( 'D001', $pay_cvs, true ), true ); ?> /><span><?php echo esc_html( usces_get_conv_name( 'D001' ) ); ?></span></label></td>
1827 </tr>
1828 <tr class="conv_zeus">
1829 <td><label><input name="pay_cvs[]" type="checkbox" id="pay_cvs_D002" value="D002"<?php checked( in_array( 'D002', $pay_cvs, true ), true ); ?> /><span><?php echo esc_html( usces_get_conv_name( 'D002' ) ); ?></span></label></td>
1830 </tr>
1831 <tr class="conv_zeus">
1832 <td><label><input name="pay_cvs[]" type="checkbox" id="pay_cvs_D030" value="D030"<?php checked( in_array( 'D030', $pay_cvs, true ), true ); ?> /><span><?php echo esc_html( usces_get_conv_name( 'D030' ) ); ?></span></label></td>
1833 </tr>
1834 <tr class="conv_zeus">
1835 <td><label><input name="pay_cvs[]" type="checkbox" id="pay_cvs_D015" value="D015"<?php checked( in_array( 'D015', $pay_cvs, true ), true ); ?> /><span><?php echo esc_html( usces_get_conv_name( 'D015' ) ); ?></span></label></td>
1836 </tr>
1837 <tr class="conv_zeus">
1838 <td><label><input name="pay_cvs[]" type="checkbox" id="pay_cvs_D050" value="D050"<?php checked( in_array( 'D050', $pay_cvs, true ), true ); ?> /><span><?php echo esc_html( usces_get_conv_name( 'D050' ) ); ?></span></label></td>
1839 </tr>
1840 <tr class="conv_zeus">
1841 <td><label><input name="pay_cvs[]" type="checkbox" id="pay_cvs_D060" value="D060"<?php checked( in_array( 'D060', $pay_cvs, true ), true ); ?> /><span><?php echo esc_html( usces_get_conv_name( 'D060' ) ); ?></span></label></td>
1842 </tr>
1843 <tr id="ex_pay_cvs_zeus" class="explanation conv_zeus"><td colspan="2">契約時にご利用のお申込みをいただいたコンビニを選択します。</td></tr>
1844 <tr class="conv_zeus">
1845 <th><a class="explanation-label" id="label_ex_conv_span_zeus">支払期日</a></th>
1846 <td>当日+<select name="conv_span">
1847 <option value=""></option>
1848 <?php for ( $i = 2; $i <= 59; $i++ ) : ?>
1849 <option value="<?php echo esc_attr( $i ); ?>"<?php selected( $conv_span, $i, true ); ?>><?php echo esc_html( $i ); ?></option>
1850 <?php endfor; ?>
1851 </select></td>
1852 </tr>
1853 <tr id="ex_conv_span_zeus" class="explanation"><td colspan="2">お申し込みごとに支払期日を設定することができます。設定がない場合には、予め設定していた加盟店指定の支払期日が設定されます。</td></tr>
1854 </table>
1855 <table class="settle_table">
1856 <tr>
1857 <th>あと払い決済</th>
1858 <td><label><input name="bnpl_activate" type="radio" class="bnpl_activate_zeus" id="bnpl_activate_zeus_1" value="on"<?php checked( $bnpl_activate, 'on' ); ?> /><span>利用する</span></label><br />
1859 <label><input name="bnpl_activate" type="radio" class="bnpl_activate_zeus" id="bnpl_activate_zeus_2" value="off"<?php checked( $bnpl_activate, 'off' ); ?> /><span>利用しない</span></label>
1860 </td>
1861 </tr>
1862 <tr class="bnpl_zeus">
1863 <th><a class="explanation-label" id="label_ex_bnpl_clid_zeus">あと払い決済IPコード</a></th>
1864 <td><input name="clientip_bnpl" type="text" id="bnpl_clid_zeus" value="<?php echo esc_attr( $client_ip_bnpl ); ?>" class="regular-text" /></td>
1865 </tr>
1866 <tr id="ex_bnpl_clid_zeus" class="explanation bnpl_zeus"><td colspan="2">契約時にゼウスから発行されるあと払い決済用のIPコード(半角数字)</td></tr>
1867 <tr class="bnpl_zeus">
1868 <th><a class="explanation-label" id="label_ex_bnpl_linkpassword_zeus">APIキー</a></th>
1869 <td><input name="bnpl_linkpassword" type="text" id="bnpl_linkpassword_zeus" value="<?php echo esc_attr( $bnpl_linkpassword ); ?>" class="regular-text" /></td>
1870 </tr>
1871 <tr id="ex_bnpl_linkpassword_zeus" class="explanation bnpl_zeus"><td colspan="2">契約時にゼウスから発行されるあと払い決済用のAPIキー(半角英数字)</td></tr>
1872 <tr class="bnpl_zeus">
1873 <th><a class="explanation-label" id="label_ex_bnpl_fee_zeus">請求手数料</a></th>
1874 <td><span id="bnpl_fee_type_field" class="fee_type_field"><?php echo esc_html( $bnpl_fee_type_field ); ?></span><input type="button" class="button" value="<?php esc_attr_e( 'Detailed setting', 'usces' ); ?>" id="bnpl_fee_setting" /></td>
1875 </tr>
1876 <tr id="ex_bnpl_fee_zeus" class="explanation bnpl_zeus"><td colspan="2">あと払い決済手数料と決済上限額を設定します。�
1877 要ない場合は空白にしておきます。</td></tr>
1878 </table>
1879 <input name="acting" type="hidden" value="zeus" />
1880 <input type="hidden" name="bnpl_fee_type" id="bnpl_fee_type" value="<?php echo esc_attr( $acting_opts['bnpl_fee_type'] ); ?>" />
1881 <input type="hidden" name="bnpl_fee" id="bnpl_fee" value="<?php echo esc_attr( $acting_opts['bnpl_fee'] ); ?>" />
1882 <input type="hidden" name="bnpl_fee_limit_amount_fix" id="bnpl_fee_limit_amount_fix" value="<?php echo esc_attr( $acting_opts['bnpl_fee_limit_amount'] ); ?>" />
1883 <input type="hidden" name="bnpl_fee_first_amount" id="bnpl_fee_first_amount" value="<?php echo esc_attr( $acting_opts['bnpl_fee_first_amount'] ); ?>" />
1884 <input type="hidden" name="bnpl_fee_first_fee" id="bnpl_fee_first_fee" value="<?php echo esc_attr( $acting_opts['bnpl_fee_first_fee'] ); ?>" />
1885 <input type="hidden" name="bnpl_fee_limit_amount_change" id="bnpl_fee_limit_amount_change" value="<?php echo esc_attr( $acting_opts['bnpl_fee_limit_amount'] ); ?>" />
1886 <input type="hidden" name="bnpl_fee_amounts" id="bnpl_fee_amounts" value="<?php echo esc_attr( implode( '|', $acting_opts['bnpl_fee_amounts'] ) ); ?>" />
1887 <input type="hidden" name="bnpl_fee_fees" id="bnpl_fee_fees" value="<?php echo esc_attr( implode( '|', $acting_opts['bnpl_fee_fees'] ) ); ?>" />
1888 <input type="hidden" name="bnpl_fee_end_fee" id="bnpl_fee_end_fee" value="<?php echo esc_attr( $acting_opts['bnpl_fee_end_fee'] ); ?>" />
1889 <input name="usces_option_update" type="submit" class="button button-primary" value="ゼウスの設定を更新する" />
1890 <?php wp_nonce_field( 'admin_settlement', 'wc_nonce' ); ?>
1891 </form>
1892 <div class="settle_exp">
1893 <p><strong><?php esc_html_e( 'ZEUS Japanese Settlement', 'usces' ); ?></strong></p>
1894 <a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank">ゼウス決済サービスの詳細はこちら </a>
1895 <p> </p>
1896 <p>この決済は「非通過型・トークン方式」の決済システムです。</p>
1897 <p>「非通過型」とは、決済会社のページへは遷移せず、Welcart のページのみで完結する決済システムです。<br />
1898 デザインの統一されたスタイリッシュな決済が可能です。但し、カード番号を扱いますので専用SSLが�
1899 須となります。<br />
1900
1901 �力されたカード番号はトークンに置き換えてゼウスのシステムに送信されますので、Welcart に保存することはありません。</a>
1902 <p>※ボーナス一括、2回払いは契約がある場合にのみご利用いただけます。</p>
1903 <p> </p>
1904 <p> 3Dセキュアとセキュリティーコード</p>
1905 <p>3Dセキュアとおよびセキュリティーコードの利用は、決済サービス契約時に決定します。契約�
1906 容に従って指定しないと正常に動作しませんのでご注意ください。<br />
1907 3Dセキュアを利用する場合はテストカードを使用してのテスト決済はできません。<br />
1908 詳しくは<a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank">株式会社ゼウス</a>(代表:03-3498-9030)にお問い合わせください。</p>
1909 <p> </p>
1910 <p><strong>テスト稼動について</strong></p>
1911 <p>銀行振込決済(�
1912 �金おまかせサービス)およびコンビニ決済のテストを行う際は、「稼働環境」で「テスト環境」を選択し、「テストID」の�
1913 目にゼウスから発行されるテストIDを�
1914 �力してください。<br />
1915 また、本稼働の際には、「本番環境」を選択して更新してください。</p>
1916 </div>
1917 </div><!--uscestabs_zeus-->
1918
1919 <div id="zeus_fee_dialog" class="cod_dialog">
1920 <fieldset>
1921 <table id="zeus_fee_type_table" class="cod_type_table">
1922 <tr>
1923 <th><?php esc_html_e( 'Type of the fee', 'usces' ); ?></th>
1924 <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>
1925 <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>
1926 </tr>
1927 </table>
1928 <table id="zeus_fee_fix_table" class="cod_fix_table">
1929 <tr>
1930 <th><?php esc_html_e( 'Fee', 'usces' ); ?></th>
1931 <td><input name="fee" type="text" id="fee_fix" class="short_str num" /><?php usces_crcode(); ?></td>
1932 </tr>
1933 <tr>
1934 <th><?php esc_html_e( 'Upper limit', 'usces' ); ?></th>
1935 <td><input name="fee_limit_amount_fix" type="text" id="fee_limit_amount_fix" class="short_str num" /><?php usces_crcode(); ?></td>
1936 </tr>
1937 </table>
1938 <div id="zeus_fee_change_table" class="cod_change_table">
1939 <input type="button" class="button" id="fee_add_row" value="<?php esc_attr_e( 'Add row', 'usces' ); ?>" />
1940 <input type="button" class="button" id="fee_del_row" value="<?php esc_attr_e( 'Delete row', 'usces' ); ?>" />
1941 <table>
1942 <thead>
1943 <tr>
1944 <th colspan="3"><?php esc_html_e( 'A purchase amount', 'usces' ); ?>(<?php usces_crcode(); ?>)</th>
1945 <th><?php esc_html_e( 'Fee', 'usces' ); ?>(<?php usces_crcode(); ?>)</th>
1946 </tr>
1947 <tr>
1948 <td class="cod_f">0</td>
1949 <td class="cod_m"><?php esc_html_e( ' - ', 'usces' ); ?></td>
1950 <td class="cod_e"><input name="fee_first_amount" id="fee_first_amount" type="text" class="short_str num" /></td>
1951 <td class="cod_cod"><input name="fee_first_fee" id="fee_first_fee" type="text" class="short_str num" /></td>
1952 </tr>
1953 </thead>
1954 <tbody id="fee_change_field"></tbody>
1955 <tfoot>
1956 <tr>
1957 <td class="cod_f"><span id="end_amount"></span></td>
1958 <td class="cod_m"><?php esc_html_e( ' - ', 'usces' ); ?></td>
1959 <td class="cod_e"><input name="fee_limit_amount_change" type="text" id="fee_limit_amount_change" class="short_str num" /></td>
1960 <td class="cod_cod"><input name="fee_end_fee" type="text" id="fee_end_fee" class="short_str num" /></td>
1961 </tr>
1962 </tfoot>
1963 </table>
1964 </div>
1965 </fieldset>
1966 <input type="hidden" id="zeus_fee_mode">
1967 </div><!--zeus_fee_dialog-->
1968 <?php
1969 endif;
1970 }
1971
1972 /**
1973 * 支払方法追加
1974 * usces_filter_add_payment_method
1975 *
1976 * @param array $newvalue Payment method data.
1977 * @return array
1978 */
1979 public function add_payment_method( $newvalue ) {
1980 if ( empty( $newvalue['explanation'] ) ) {
1981 if ( 'acting_zeus_bnpl' === $newvalue['settlement'] ) {
1982 $newvalue['explanation'] = 'SBIグループのあと払い決済をご利用の際は、<a href="https://www.sbi-finsol.co.jp/atobarai/purchaser/" target="_blank">ご利用規約</a>および下記の注意事�
1983 をご確認いただき、ご同意の上お申し込みください。<br>
1984 <ul>
1985 <li>ご利用限度額(未払い累計金額)は55,000円(税込)です。</li>
1986 <li>ご利用にあたり審査がございます。審査結果によっては、あと払い決済をご利用いただけないことがございますので、その場合は別のお支払方法をご利用ください。</li>
1987 <li>ご請求メールは、購�
1988 ��
1989 さまのメールアドレス宛にSBI FinTech Solutions株式会社(atobarai@sbi-finsol.co.jp)よりお送りします。</li>
1990 <li>商品をお受取り後、メールに記載のお支払い期日まで(発行日から14日以�
1991 )にコンビニエンスストアまたは銀行振込にてお支払いください。コンビニ払いの場合は、電子バーコードを提示してのお支払いになりますので、スマートフォンで受け取れるメールアドレスをご�
1992 �力ください。</li>
1993 <li>未成年の方は�
1994 ず親権�
1995 (法定代理人)の同意を得てご利用ください。</li>
1996 <li>商品のお届け�
1997 �住所が「運送業�
1998 の営業所留め」「郵便局留め」の場合や「学校」「�
1999 院」「ホテル」など一時滞在�
2000 �の場合は、「あと払い決済」をご利用いただけません。また、商品の海外転送サービスもご利用いただけません。</li>
2001 <li>あと払い決済のサービス詳細・よくあるご質問は下記をご参�
2002 �ください。<br><a href="https://www.sbi-finsol.co.jp/atobarai/purchaser/"target="_blank">https://www.sbi-finsol.co.jp/atobarai/purchaser/</a></li>
2003 </ul>
2004 <a href="https://www.sbi-finsol.co.jp/atobarai/purchaser/" target="_blank"><img src="https://www.cardservice.co.jp/zmc/manual/images/download_atobarai_01.png"></a>';
2005 }
2006 }
2007 return $newvalue;
2008 }
2009
2010 /**
2011 * 結果通知前処理
2012 * usces_construct
2013 */
2014 public function acting_construct() {
2015 $acting_opts = $this->get_acting_settings();
2016 if ( ! empty( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], $acting_opts['ipaddrs'] ) ) {
2017 $result_data = wp_unslash( $_REQUEST );
2018 if ( isset( $result_data['sendpoint'] ) ) {
2019 $sendpoint = $result_data['sendpoint'];
2020 $acting_data = usces_get_order_acting_data( $sendpoint );
2021 if ( empty( $acting_data['sesid'] ) ) {
2022 if ( isset( $result_data['result'] ) && 'OK' === $result_data['result'] && isset( $result_data['money'] ) && 0 === (int) $result_data['money'] ) {
2023 } else {
2024 $log = array(
2025 'acting' => 'zeus',
2026 'key' => $sendpoint,
2027 'result' => 'SESSION ERROR',
2028 'data' => $result_data,
2029 );
2030 usces_save_order_acting_error( $log );
2031 }
2032 } else {
2033 if ( isset( $result_data['acting'] ) && 'zeus_bank' === $result_data['acting'] ) {
2034 usces_restore_order_acting_data( $sendpoint );
2035 }
2036 }
2037 }
2038 }
2039 }
2040
2041 /**
2042 * 結果通知処理
2043 * usces_after_cart_instant
2044 */
2045 public function acting_transaction() {
2046 global $usces;
2047
2048 /* zeus_card */
2049 if ( isset( $_REQUEST['acting'] ) && 'zeus_card' === $_REQUEST['acting'] && isset( $_REQUEST['result'] ) && isset( $_REQUEST['ordd'] ) ) {
2050 foreach ( $_REQUEST as $key => $value ) {
2051 if ( 'uscesid' === $key ) {
2052 continue;
2053 }
2054 $data[ $key ] = $value;
2055 }
2056
2057 if ( empty( $data['sendpoint'] ) ) {
2058 $log = array(
2059 'acting' => $data['acting'],
2060 'key' => '(empty key)',
2061 'result' => $data['result'],
2062 'data' => $data,
2063 );
2064 usces_save_order_acting_error( $log );
2065 header( 'HTTP/1.0 200 OK' );
2066 die( 'error1' );
2067 }
2068
2069 if ( 'OK' === $data['result'] ) {
2070 $order_data = usces_restore_order_acting_data( $data['sendpoint'] );
2071 $order_id = $this->get_order_id( $data['sendpoint'] );
2072 if ( empty( $order_id ) && ! empty( $order_data ) ) {
2073 $res = $usces->order_processing( $data );
2074 if ( 'ordercompletion' === $res ) {
2075 $_nonce = ( isset( $order_data['_nonce'] ) ) ? $order_data['_nonce'] : wp_create_nonce( 'acting_zeus_card' );
2076 wp_redirect(
2077 add_query_arg(
2078 array(
2079 'acting' => $data['acting'],
2080 'acting_return' => 1,
2081 'result' => 1,
2082 '_nonce' => $_nonce,
2083 ),
2084 USCES_CART_URL
2085 )
2086 );
2087 } else {
2088 $log = array(
2089 'acting' => $data['acting'],
2090 'key' => $rand,
2091 'result' => 'ORDER DATA REGISTERED ERROR',
2092 'data' => $data,
2093 );
2094 usces_save_order_acting_error( $log );
2095 wp_redirect(
2096 add_query_arg(
2097 array(
2098 'acting' => $data['acting'],
2099 'acting_return' => 0,
2100 'result' => 0,
2101 ),
2102 USCES_CART_URL
2103 )
2104 );
2105 }
2106 } else {
2107 $log = array(
2108 'acting' => $data['acting'],
2109 'key' => $data['sendpoint'],
2110 'result' => 'ORDER DATA RESTORE ERROR',
2111 'data' => $data,
2112 );
2113 usces_save_order_acting_error( $log );
2114 wp_redirect(
2115 add_query_arg(
2116 array(
2117 'acting' => $data['acting'],
2118 'acting_return' => 0,
2119 'result' => 0,
2120 ),
2121 USCES_CART_URL
2122 )
2123 );
2124 }
2125 header( 'HTTP/1.0 200 OK' );
2126 die( 'zeus' );
2127
2128 } else {
2129 $log = array(
2130 'acting' => $data['acting'],
2131 'key' => $data['sendpoint'],
2132 'result' => $data['result'],
2133 'data' => $data,
2134 );
2135 usces_save_order_acting_error( $log );
2136 header( 'HTTP/1.0 200 OK' );
2137 die( 'error3' );
2138 }
2139
2140 /* zeus_bank */
2141 } elseif ( isset( $_REQUEST['acting'] ) && 'zeus_bank' === $_REQUEST['acting'] && isset( $_REQUEST['order_no'] ) && isset( $_REQUEST['tracking_no'] ) ) {
2142 foreach ( $_REQUEST as $key => $value ) {
2143 if ( 'uscesid' === $key ) {
2144 continue;
2145 }
2146 $data[ $key ] = $value;
2147 }
2148
2149 if ( '04' === $data['status'] || '05' === $data['status'] ) {
2150 $log = array(
2151 'acting' => $data['acting'],
2152 'key' => $data['sendpoint'],
2153 'result' => $data['status'],
2154 'data' => $data,
2155 );
2156 usces_save_order_acting_error( $log );
2157 header( 'HTTP/1.0 200 OK' );
2158 die( 'error0' );
2159 }
2160
2161 $order_id = $this->get_order_id( $data['tracking_no'] );
2162 if ( empty( $order_id ) ) {
2163 $res = $usces->order_processing( $data );
2164 if ( 'error' === $res ) {
2165 $log = array(
2166 'acting' => $data['acting'],
2167 'key' => $data['sendpoint'],
2168 'result' => 'ORDER DATA REGISTERED ERROR',
2169 'data' => $data,
2170 );
2171 usces_save_order_acting_error( $log );
2172 header( 'HTTP/1.0 200 OK' );
2173 die( 'error1' );
2174
2175 } else {
2176 $order_id = $usces->cart->get_order_entry( 'ID' );
2177 if ( $order_id ) {
2178 $usces->cart->clear_cart();
2179 }
2180 }
2181 }
2182
2183 if ( ! empty( $order_id ) ) {
2184 if ( '03' === $data['status'] ) {
2185 $res = usces_change_order_receipt( $order_id, 'receipted' );
2186 do_action( 'usces_action_zeus_bank_receipted', $order_id, $data );
2187 } else {
2188 $res = usces_change_order_receipt( $order_id, 'noreceipt' );
2189 }
2190 if ( false === $res ) {
2191 $log = array(
2192 'acting' => $data['acting'],
2193 'key' => $data['sendpoint'],
2194 'result' => 'ORDER DATA UPDATE ERROR',
2195 'data' => $data,
2196 );
2197 usces_save_order_acting_error( $log );
2198 header( 'HTTP/1.0 200 OK' );
2199 die( 'error2' );
2200 }
2201 if ( '03' === $data['status'] ) {
2202 usces_action_acting_getpoint( $order_id );
2203 }
2204
2205 $res = $usces->set_order_meta_value( 'acting_' . $data['tracking_no'], usces_serialize( $data ), $order_id );
2206 if ( false === $res ) {
2207 $log = array(
2208 'acting' => $data['acting'],
2209 'key' => $data['sendpoint'],
2210 'result' => 'ORDER META DATA UPDATE ERROR',
2211 'data' => $data,
2212 );
2213 usces_save_order_acting_error( $log );
2214 header( 'HTTP/1.0 200 OK' );
2215 die( 'error3' );
2216 }
2217 }
2218
2219 header( 'HTTP/1.0 200 OK' );
2220 die( 'zeus' );
2221
2222 /* zeus_conv */
2223 } elseif ( isset( $_REQUEST['acting'] ) && 'zeus_conv' === $_REQUEST['acting'] && isset( $_REQUEST['status'] ) && isset( $_REQUEST['sendpoint'] ) && isset( $_REQUEST['clientip'] ) ) {
2224 foreach ( $_REQUEST as $key => $value ) {
2225 if ( 'uscesid' === $key ) {
2226 continue;
2227 }
2228 if ( 'username' === $key ) {
2229 $data[ $key ] = mb_convert_encoding( $value, 'UTF-8', 'SJIS' );
2230 } else {
2231 $data[ $key ] = $value;
2232 }
2233 }
2234
2235 $order_id = $this->get_order_id( $data['sendpoint'] );
2236 if ( ! empty( $order_id ) ) {
2237 if ( '05' !== $data['status'] ) {
2238 if ( '04' === $data['status'] ) {
2239 $res = usces_change_order_receipt( $order_id, 'receipted' );
2240 do_action( 'usces_action_zeus_conv_receipted', $order_id, $data );
2241 } else {
2242 $res = usces_change_order_receipt( $order_id, 'noreceipt' );
2243 }
2244 if ( false === $res ) {
2245 $log = array(
2246 'acting' => $data['acting'],
2247 'key' => $data['sendpoint'],
2248 'result' => 'ORDER DATA UPDATE ERROR',
2249 'data' => $data,
2250 );
2251 usces_save_order_acting_error( $log );
2252 header( 'HTTP/1.0 200 OK' );
2253 die( 'error2' );
2254 }
2255 if ( '04' === $data['status'] ) {
2256 usces_action_acting_getpoint( $order_id );
2257 }
2258
2259 $res = $usces->set_order_meta_value( 'acting_' . $data['sendpoint'], usces_serialize( $data ), $order_id );
2260 if ( false === $res ) {
2261 $log = array(
2262 'acting' => $data['acting'],
2263 'key' => $data['sendpoint'],
2264 'result' => 'ORDER META DATA UPDATE ERROR',
2265 'data' => $data,
2266 );
2267 usces_save_order_acting_error( $log );
2268 header( 'HTTP/1.0 200 OK' );
2269 die( 'error3' );
2270 }
2271 }
2272 }
2273
2274 header( 'HTTP/1.0 200 OK' );
2275 die( 'zeus' );
2276 }
2277
2278 if ( isset( $_REQUEST['backfrom_zeus_bank'] ) && '1' === $_REQUEST['backfrom_zeus_bank'] ) {
2279 $usces->cart->clear_cart();
2280 }
2281 }
2282
2283 /**
2284 * 管理画面送信メール
2285 * usces_filter_order_confirm_mail_payment
2286 *
2287 * @param string $msg_payment Default payment message.
2288 * @param int $order_id Order number.
2289 * @param array $payment Payment information.
2290 * @param array $cart Cart data.
2291 * @param array $data Order data.
2292 * @return string
2293 */
2294 public function order_confirm_mail_payment( $msg_payment, $order_id, $payment, $cart, $data ) {
2295 global $usces;
2296
2297 switch ( $payment['settlement'] ) {
2298 case 'acting_zeus_card':
2299 $div_name = '';
2300 $acting_opts = $this->get_acting_settings();
2301 if ( 'on' === $acting_opts['howpay'] ) {
2302 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_zeus_card', $order_id ) );
2303 $howpay = ( isset( $acting_data['howpay'] ) ) ? $acting_data['howpay'] : '1';
2304 $div = ( isset( $acting_data['div'] ) ) ? $acting_data['div'] : '01';
2305 if ( '1' == $howpay ) {
2306 $div_name = ' 一括払い';
2307 } else {
2308 switch ( $div ) {
2309 case '01':
2310 $div_name = ' 一括払い';
2311 break;
2312 case '02':
2313 $div_name = ' 分割(2回)';
2314 break;
2315 case '03':
2316 $div_name = ' 分割(3回)';
2317 break;
2318 case '05':
2319 $div_name = ' 分割(5回)';
2320 break;
2321 case '06':
2322 $div_name = ' 分割(6回)';
2323 break;
2324 case '10':
2325 $div_name = ' 分割(10回)';
2326 break;
2327 case '12':
2328 $div_name = ' 分割(12回)';
2329 break;
2330 case '15':
2331 $div_name = ' 分割(15回)';
2332 break;
2333 case '18':
2334 $div_name = ' 分割(18回)';
2335 break;
2336 case '20':
2337 $div_name = ' 分割(20回)';
2338 break;
2339 case '24':
2340 $div_name = ' 分割(24回)';
2341 break;
2342 case '99':
2343 $div_name = ' 分割(リボ払い)';
2344 break;
2345 case 'B1':
2346 $div_name = ' 分割(ボーナス一括払い)';
2347 break;
2348 }
2349 }
2350 }
2351 if ( '' !== $div_name && isset( $payment['name'] ) ) {
2352 if ( usces_is_html_mail() ) {
2353 $msg_payment = '<tr><td colspan="2" style="padding: 0 0 25px 0;">';
2354 $msg_payment .= $payment['name'] . $div_name;
2355 $msg_payment .= '</td></tr>';
2356 } else {
2357 $msg_payment = __( '** Payment method **', 'usces' ) . "\r\n";
2358 $msg_payment .= usces_mail_line( 1, $data['order_email'] ); // ********************
2359 $msg_payment .= $payment['name'] . $div_name;
2360 $msg_payment .= "\r\n\r\n";
2361 }
2362 }
2363 break;
2364
2365 case 'acting_zeus_bank':
2366 break;
2367
2368 case 'acting_zeus_conv':
2369 $conv_name = '';
2370 $acting_data = $this->get_order_meta_acting( $order_id );
2371 if ( isset( $acting_data['pay_cvs'] ) ) {
2372 $conv_name = usces_get_conv_name( $acting_data['pay_cvs'] );
2373 }
2374 if ( '' !== $conv_name && isset( $payment['name'] ) ) {
2375 if ( usces_is_html_mail() ) {
2376 $msg_payment = '<tr><td colspan="2" style="padding: 0 0 25px 0;">';
2377 $msg_payment .= $payment['name'] . ' (' . $conv_name . '';
2378 $msg_payment .= '</td></tr>';
2379 } else {
2380 $msg_payment = __( '** Payment method **', 'usces' ) . "\r\n";
2381 $msg_payment .= usces_mail_line( 1, $data['order_email'] ); // ********************
2382 $msg_payment .= $payment['name'] . ' (' . $conv_name . '';
2383 $msg_payment .= "\r\n\r\n";
2384 }
2385 }
2386 break;
2387
2388 case 'acting_zeus_bnpl':
2389 break;
2390 }
2391
2392 return $msg_payment;
2393 }
2394
2395 /**
2396 * ポイント即時付与
2397 * usces_filter_is_complete_settlement
2398 *
2399 * @param bool $complete Complete the payment.
2400 * @param string $payment_name Payment name.
2401 * @param string $status Payment status.
2402 * @return bool
2403 */
2404 public function is_complete_settlement( $complete, $payment_name, $status ) {
2405 $acting_flg = $this->get_acting_flg( $payment_name );
2406 if ( 'acting_zeus_card' === $acting_flg ) {
2407 $complete = true;
2408 }
2409 return $complete;
2410 }
2411
2412 /**
2413 * 購�
2414 �完了メッセージ
2415 * usces_filter_completion_settlement_message
2416 *
2417 * @param string $form Message form.
2418 * @param array $entry Entry data.
2419 * @return string
2420 */
2421 public function completion_settlement_message( $form, $entry ) {
2422 global $usces;
2423
2424 if ( isset( $_REQUEST['acting'] ) && 'zeus_conv' === wp_unslash( $_REQUEST['acting'] ) ) {
2425 $form .= '<div id="status_table"><h5>ゼウス・コンビニ決済</h5>';
2426 $form .= '<table>';
2427 $form .= '<tr><th>オーダー番号</th><td>' . esc_html( $usces->payment_results['order_no'] ) . '</td></tr>';
2428 $form .= '<tr><th>お支払�
2429 �</th><td>' . esc_html( usces_get_conv_name( $usces->payment_results['pay_cvs'] ) ) . '</td></tr>';
2430 switch ( $usces->payment_results['pay_cvs'] ) {
2431 case 'D001': /* セブンイレブン */
2432 $form .= '<tr><th>払込票番号</th><td>' . esc_html( $usces->payment_results['pay_no1'] ) . '</td></tr>';
2433 $form .= '<tr><th>URL</th><td><a href="' . esc_attr( $usces->payment_results['pay_url'] ) . '" target="_blank">' . esc_html( $usces->payment_results['pay_url'] ) . '</a></td></tr>';
2434 break;
2435 case 'D002': /* ローソン */
2436 case 'D050': /* ミニストップ */
2437 $form .= '<tr><th>受付番号</th><td>' . esc_html( $usces->payment_results['pay_no1'] ) . '</td></tr>';
2438 if ( isset( $usces->payment_results['pay_no2'] ) ) {
2439 $form .= '<tr><th>確認番号</th><td>' . esc_html( $usces->payment_results['pay_no2'] ) . '</td></tr>';
2440 }
2441 break;
2442 case 'D040': /* サークルKサンクス */
2443 case 'D015': /* セイコーマート */
2444 $form .= '<tr><th>お支払受付番号</th><td>' . esc_html( $usces->payment_results['pay_no1'] ) . '</td></tr>';
2445 break;
2446 case 'D030': /* ファミリーマート */
2447 $form .= '<tr><th>注文番号</th><td>' . esc_html( $usces->payment_results['pay_no1'] ) . '</td></tr>';
2448 $form .= '<tr><th>企業コード</th><td>' . esc_html( $usces->payment_results['pay_no2'] ) . '</td></tr>';
2449 break;
2450 case 'D060': /* デイリーヤマザキ */
2451 $form .= '<tr><th>オンライン決済番号</th><td>' . esc_html( $usces->payment_results['pay_no1'] ) . '</td></tr>';
2452 break;
2453 }
2454 $form .= '<tr><th>お支払期限</th><td>' . esc_html( substr( $usces->payment_results['pay_limit'], 0, 4 ) . '' . substr( $usces->payment_results['pay_limit'], 4, 2 ) . '' . substr( $usces->payment_results['pay_limit'], 6, 2 ) . '' ) . '(期限を過ぎますとお支払ができません)</td></tr>';
2455 // $form .= '<!-- <tr><th>エラーコード</th><td>' . esc_html( $usces->payment_results['error_code'] ) . '</td></tr>';
2456 $form .= '</table>';
2457 $form .= '<p>「お支払いのご案�
2458 」は、' . esc_html( $entry['customer']['mailaddress1'] ) . ' 宛にメールさせていただいております。</p>';
2459 $form .= '</div>';
2460 }
2461 return $form;
2462 }
2463
2464 /**
2465 * 決済リンクキー
2466 * usces_filter_get_link_key
2467 *
2468 * @param string $linkkey Settlement link key.
2469 * @param array $results Response data.
2470 * @return string
2471 */
2472 public function get_link_key( $linkkey, $results ) {
2473 if ( isset( $results['order_number'] ) && isset( $results['sendpoint'] ) ) {
2474 $linkkey = $results['sendpoint'];
2475 }
2476 return $linkkey;
2477 }
2478
2479 /**
2480 * 受注データ復旧処理
2481 * usces_action_revival_order_data
2482 *
2483 * @param int $order_id Order number.
2484 * @param string $log_key Link key.
2485 * @param string $acting Payment type.
2486 */
2487 public function revival_orderdata( $order_id, $log_key, $acting ) {
2488 global $usces;
2489
2490 if ( ! in_array( $acting, $this->pay_method, true ) ) {
2491 return;
2492 }
2493
2494 $data = array();
2495 switch ( $acting ) {
2496 case 'acting_zeus_card':
2497 $data['sendpoint'] = $log_key;
2498 $usces->set_order_meta_value( $acting, usces_serialize( $data ), $order_id );
2499 case 'acting_zeus_conv':
2500 case 'acting_zeus_bank':
2501 $usces->set_order_meta_value( 'acting_' . $log_key, usces_serialize( $data ), $order_id );
2502 break;
2503 }
2504 }
2505
2506 /**
2507 * 管理画面決済処理
2508 * usces_action_admin_ajax
2509 */
2510 public function admin_ajax() {
2511 global $usces;
2512
2513 $mode = filter_input( INPUT_POST, 'mode' );
2514 $data = array();
2515
2516 switch ( $mode ) {
2517 /* クレジットカード参�
2518 � */
2519 case 'get_zeus_card':
2520 check_admin_referer( 'order_edit', 'wc_nonce' );
2521 $order_id = filter_input( INPUT_POST, 'order_id' );
2522 $order_num = filter_input( INPUT_POST, 'order_num' );
2523 $tracking_id = filter_input( INPUT_POST, 'tracking_id' );
2524 $member_id = filter_input( INPUT_POST, 'member_id' );
2525 if ( empty( $order_id ) || empty( $tracking_id ) ) {
2526 $data['status'] = 'NG';
2527 wp_send_json( $data );
2528 break;
2529 }
2530
2531 $res = '';
2532 $status = '';
2533
2534 $latest_log = $this->get_acting_latest_log( $order_id, $tracking_id );
2535 if ( ! empty( $latest_log['order_no'] ) ) {
2536 $order_ref = wel_zeus_get_order_ref( $latest_log['order_no'] );
2537 if ( 'TEST' === $order_ref['status'] ) {
2538 $status = 'OK';
2539 $status_name = $this->get_status_name( $order_ref['status'] );
2540 $res .= '<div class="zeus-settlement-admin card-test">' . $status_name . '</div>';
2541 $res .= '<table class="settlement-admin-table">';
2542 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2543 $res .= '<td><input type="tel" class="settlement-amount" value="' . intval( $latest_log['amount'] ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2544 $res .= '</tr>';
2545 $res .= '</table>';
2546 } elseif ( 'payment' === $order_ref['status'] || 'change' === $order_ref['status'] ) {
2547 $status = 'OK';
2548 $status_name = $this->get_status_name( $order_ref['status'] );
2549 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
2550 $res .= '<table class="settlement-admin-table">';
2551 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2552 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $latest_log['amount'] ) . '" /></td>';
2553 $res .= '</tr>';
2554 $res .= '</table>';
2555 $res .= '<div class="settlement-admin-button">';
2556 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2557 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2558 $res .= '</div>';
2559 } elseif ( 'auth' === $order_ref['status'] ) {
2560 $status = 'OK';
2561 $status_name = $this->get_status_name( $order_ref['status'] );
2562 $res .= '<div class="zeus-settlement-admin card-auth">' . $status_name . '</div>';
2563 $res .= '<table class="settlement-admin-table">';
2564 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2565 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $latest_log['amount'] ) . '" /></td>';
2566 $res .= '</tr>';
2567 $res .= '</table>';
2568 $res .= '<div class="settlement-admin-button">';
2569 $res .= '<input id="sale_settlement" type="button" class="button" value="売上処理" />';
2570 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2571 $res .= '</div>';
2572 } elseif ( 'cancel' === $order_ref['status'] ) {
2573 $status = 'OK';
2574 $status_name = $this->get_status_name( $order_ref['status'] );
2575 $res .= '<div class="zeus-settlement-admin card-cancel">' . $status_name . '</div>';
2576 $res .= '<table class="settlement-admin-table">';
2577 if ( ! empty( $member_id ) ) {
2578 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2579 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2580 $res .= '</tr>';
2581 $res .= '</table>';
2582 $res .= '<div class="settlement-admin-button">';
2583 $res .= '<input id="re_settlement" type="button" class="button" value="新規決済" />';
2584 $res .= '</div>';
2585 } else {
2586 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2587 $res .= '<td><input type="tel" class="settlement-amount" value="' . intval( $latest_log['amount'] ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2588 $res .= '</tr>';
2589 $res .= '</table>';
2590 }
2591 } else {
2592 if ( 'TEST' === $latest_log['status'] ) {
2593 $status = 'OK';
2594 $status_name = $this->get_status_name( $latest_log['status'] );
2595 $res .= '<div class="zeus-settlement-admin card-test">' . $status_name . '</div>';
2596 $res .= '<table class="settlement-admin-table">';
2597 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2598 $res .= '<td><input type="tel" class="settlement-amount" value="' . intval( $latest_log['amount'] ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2599 $res .= '</tr>';
2600 $res .= '</table>';
2601 } elseif ( 'payment' === $latest_log['status'] || 'change' === $latest_log['status'] ) {
2602 $status = 'OK';
2603 $status_name = $this->get_status_name( 'payment' );
2604 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
2605 $res .= '<table class="settlement-admin-table">';
2606 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2607 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $latest_log['amount'] ) . '" /></td>';
2608 $res .= '</tr>';
2609 $res .= '</table>';
2610 $res .= '<div class="settlement-admin-button">';
2611 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2612 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2613 $res .= '</div>';
2614 } elseif ( 'auth' === $latest_log['status'] ) {
2615 $status = 'OK';
2616 $status_name = $this->get_status_name( $latest_log['status'] );
2617 $res .= '<div class="zeus-settlement-admin card-auth">' . $status_name . '</div>';
2618 $res .= '<table class="settlement-admin-table">';
2619 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2620 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $latest_log['amount'] ) . '" /></td>';
2621 $res .= '</tr>';
2622 $res .= '</table>';
2623 $res .= '<div class="settlement-admin-button">';
2624 $res .= '<input id="sale_settlement" type="button" class="button" value="売上処理" />';
2625 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2626 $res .= '</div>';
2627 } elseif ( 'cancel' === $latest_log['status'] ) {
2628 $status = 'OK';
2629 $status_name = $this->get_status_name( $latest_log['status'] );
2630 $res .= '<div class="zeus-settlement-admin card-cancel">' . $status_name . '</div>';
2631 $res .= '<table class="settlement-admin-table">';
2632 if ( ! empty( $member_id ) ) {
2633 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2634 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2635 $res .= '</tr>';
2636 $res .= '</table>';
2637 $res .= '<div class="settlement-admin-button">';
2638 $res .= '<input id="re_settlement" type="button" class="button" value="新規決済" />';
2639 $res .= '</div>';
2640 } else {
2641 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2642 $res .= '<td><input type="tel" class="settlement-amount" value="' . intval( $latest_log['amount'] ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2643 $res .= '</tr>';
2644 $res .= '</table>';
2645 }
2646 } else {
2647 $status = 'ERROR';
2648 $status_name = $this->get_status_name( 'error' );
2649 $res .= '<div class="zeus-settlement-admin card-error">' . $status_name . '</div>';
2650 }
2651 }
2652 } else {
2653 $latest_log = $this->get_acting_latest_log( $order_id, $tracking_id, 'ALL' );
2654 if ( 'autodelivery' === $latest_log['status'] || 'dlseller' === $latest_log['status'] ) {
2655 $status = 'OK';
2656 $status_name = $this->get_status_name( $latest_log['status'] );
2657 $res .= '<div class="zeus-settlement-admin card-error">' . $status_name . '</div>';
2658 $res .= '<table class="settlement-admin-table">';
2659 if ( ! empty( $member_id ) ) {
2660 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2661 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2662 $res .= '</tr>';
2663 $res .= '</table>';
2664 $res .= '<div class="settlement-admin-button">';
2665 $res .= '<input id="re_settlement" type="button" class="button" value="新規決済" />';
2666 $res .= '</div>';
2667 } else {
2668 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2669 $res .= '<td><input type="tel" class="settlement-amount" value="' . intval( $latest_log['amount'] ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2670 $res .= '</tr>';
2671 $res .= '</table>';
2672 }
2673 } else {
2674 $status = 'ERROR';
2675 $status_name = $this->get_status_name( $latest_log['status'], $latest_log['result'] );
2676 $res .= '<div class="zeus-settlement-admin card-error">' . $status_name . '</div>';
2677 }
2678 }
2679 $res .= $this->settlement_history( $order_id, $tracking_id );
2680 $data['result'] = $res;
2681 $data['status'] = $status;
2682 wp_send_json( $data );
2683 break;
2684
2685 /* クレジットカード売上処理 */
2686 case 'sale_zeus_card':
2687 check_admin_referer( 'order_edit', 'wc_nonce' );
2688 $order_id = filter_input( INPUT_POST, 'order_id' );
2689 $order_num = filter_input( INPUT_POST, 'order_num' );
2690 $tracking_id = filter_input( INPUT_POST, 'tracking_id' );
2691 $amount = filter_input( INPUT_POST, 'amount' );
2692 if ( empty( $order_id ) || empty( $tracking_id ) || empty( $amount ) ) {
2693 $data['status'] = 'NG';
2694 wp_send_json( $data );
2695 break;
2696 }
2697
2698 $res = '';
2699 $status = '';
2700 $acting_status = '';
2701
2702 $latest_log = $this->get_acting_latest_log( $order_id, $tracking_id );
2703 if ( ! empty( $latest_log['order_no'] ) ) {
2704 $acting_opts = $this->get_acting_settings();
2705
2706 $params = array();
2707 $params['clientip'] = $acting_opts['clientip'];
2708 $params['king'] = $amount;
2709 $params['date'] = wp_date( 'Ymd' );
2710 $params['ordd'] = $latest_log['order_no'];
2711 $params['autype'] = 'sale';
2712
2713 $page_sale = $this->secure_link_batch( $acting_opts['card_url'], $params );
2714 if ( false !== strpos( $page_sale, 'Success_order' ) ) {
2715 $status = 'OK';
2716 $params = apply_filters( 'usces_filter_zeus_card_sale_log', $params, $order_id, $tracking_id );
2717 wel_zeus_save_acting_log( $params, 'zeus_card', 'sale', $status, $order_id, $tracking_id );
2718 $status_name = $this->get_status_name( 'sale' );
2719 $res .= '<div class="zeus-settlement-admin card-sale">' . $status_name . '</div>';
2720 $res .= '<table class="settlement-admin-table">';
2721 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2722 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $amount ) . '" /></td>';
2723 $res .= '</tr>';
2724 $res .= '</table>';
2725 $res .= '<div class="settlement-admin-button">';
2726 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2727 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2728 $res .= '</div>';
2729 $acting_status = '<span class="acting-status card-sale">' . $status_name . '</span>';
2730 } else {
2731 $status = $this->get_error_results( $page_sale );
2732 if ( empty( $status ) ) {
2733 $status = 'ERROR';
2734 }
2735 wel_zeus_save_acting_log( $params, 'zeus_card', 'sale', $status, $order_id, $tracking_id );
2736 $res .= '<div class="zeus-settlement-admin card-error">売上処理エラー</div>';
2737 $res .= '<table class="settlement-admin-table">';
2738 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2739 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $latest_log['amount'] ) . '" /></td>';
2740 $res .= '</tr>';
2741 $res .= '</table>';
2742 $res .= '<div class="settlement-admin-button">';
2743 $res .= '<input id="sale_settlement" type="button" class="button" value="売上処理" />';
2744 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2745 $res .= '</div>';
2746 }
2747 } else {
2748 $status = 'NG';
2749 wel_zeus_save_acting_log( array(), 'zeus_card', 'sale', $status, $order_id, $tracking_id );
2750 $res .= '<div class="zeus-settlement-admin card-error">売上処理不可</div>';
2751 }
2752 $res .= $this->settlement_history( $order_id, $tracking_id );
2753 $data['result'] = $res;
2754 $data['status'] = $status;
2755 $data['acting_status'] = $acting_status;
2756 wp_send_json( $data );
2757 break;
2758
2759 /* クレジットカード取消処理 */
2760 case 'cancel_zeus_card':
2761 check_admin_referer( 'order_edit', 'wc_nonce' );
2762 $order_id = filter_input( INPUT_POST, 'order_id' );
2763 $order_num = filter_input( INPUT_POST, 'order_num' );
2764 $tracking_id = filter_input( INPUT_POST, 'tracking_id' );
2765 if ( empty( $order_id ) || empty( $tracking_id ) ) {
2766 $data['status'] = 'NG';
2767 wp_send_json( $data );
2768 break;
2769 }
2770
2771 $res = '';
2772 $status = '';
2773 $acting_status = '';
2774
2775 $latest_log = $this->get_acting_latest_log( $order_id, $tracking_id );
2776 if ( ! empty( $latest_log['order_no'] ) ) {
2777 $acting_opts = $this->get_acting_settings();
2778 /**
2779 * Cancel API
2780 $params = array();
2781 $params['authentication']['clientip'] = $acting_opts['clientip'];
2782 $params['authentication']['key'] = $acting_opts['authkey'];
2783 $params['return']['order_number'] = $latest_log['order_no'];
2784
2785 $cancel_req = '<?xml version="1.0" encoding="utf-8"?>';
2786 $cancel_req .= '<request service="secure_link" action="payment_return">';
2787 $cancel_req .= $this->assoc2xml( $params );
2788 $cancel_req .= '</request>';
2789 $xml = $this->get_xml( $acting_opts['card_secureurl'], $cancel_req );
2790 if ( ! empty( $xml ) ) {
2791 $cancel_res = $this->xml2assoc( $xml );
2792 if ( 'success' === $cancel_res['response']['result']['status'] ) {
2793 $status = 'OK';
2794 $cancel_res['order_no'] = $latest_log['order_no'];
2795 wel_zeus_save_acting_log( $cancel_res, 'zeus_card', 'cancel', 'OK', $order_id, $tracking_id );
2796 } else {
2797 $status = 'ERROR';
2798 $cancel_res['order_no'] = $latest_log['order_no'];
2799 wel_zeus_save_acting_log( $cancel_res, 'zeus_card', 'cancel', $cancel_res['response']['result']['status'], $order_id, $tracking_id );
2800 }
2801 } else {
2802 $status = 'NG';
2803 wel_zeus_save_acting_log( $params, 'zeus_card', 'cancel', 'NG', $order_id, $tracking_id );
2804 }
2805 */
2806 $params = array();
2807 $params['clientip'] = $acting_opts['clientip'];
2808 $params['return'] = 'yes';
2809 $params['ordd'] = $latest_log['order_no'];
2810
2811 $page_cancel = $this->secure_link_batch( $acting_opts['card_url'], $params );
2812 if ( false !== strpos( $page_cancel, 'SuccessOK' ) ) {
2813 $status = 'OK';
2814 $params = apply_filters( 'usces_filter_zeus_card_cancel_log', $params, $order_id, $tracking_id );
2815 wel_zeus_save_acting_log( $params, 'zeus_card', 'cancel', $status, $order_id, $tracking_id );
2816 $status_name = $this->get_status_name( 'cancel' );
2817 $res .= '<div class="zeus-settlement-admin card-cancel">' . $status_name . '</div>';
2818 $res .= '<table class="settlement-admin-table">';
2819 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2820 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="0" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2821 $res .= '</tr>';
2822 $res .= '</table>';
2823 $res .= '<div class="settlement-admin-button">';
2824 $res .= '<input id="re_settlement" type="button" class="button" value="新規決済" />';
2825 $res .= '</div>';
2826 $acting_status = '<span class="acting-status card-cancel">' . $status_name . '</span>';
2827 $acting_data = $usces->get_order_meta_value( 'acting_zeus_card', $order_id );
2828 if ( $acting_data ) {
2829 $acting_data = usces_unserialize( $acting_data );
2830 if ( isset( $acting_data['money'] ) ) {
2831 $acting_data['money'] = 0;
2832 }
2833 $usces->set_order_meta_value( 'acting_zeus_card', usces_serialize( $acting_data ), $order_id );
2834 }
2835 } else {
2836 $status = $this->get_error_results( $page_cancel );
2837 if ( empty( $status ) ) {
2838 $status = 'ERROR';
2839 }
2840 wel_zeus_save_acting_log( $params, 'zeus_card', 'cancel', $status, $order_id, $tracking_id );
2841 $res .= '<div class="zeus-settlement-admin card-error">取消処理エラー</div>';
2842 }
2843 } else {
2844 $status = 'NG';
2845 wel_zeus_save_acting_log( array(), 'zeus_card', 'cancel', $status, $order_id, $tracking_id );
2846 $res .= '<div class="zeus-settlement-admin card-error">取消処理不可</div>';
2847 }
2848 $res .= $this->settlement_history( $order_id, $tracking_id );
2849 $data['result'] = $res;
2850 $data['status'] = $status;
2851 $data['acting_status'] = $acting_status;
2852 wp_send_json( $data );
2853 break;
2854
2855 /* クレジットカード金額変更 */
2856 case 'change_zeus_card':
2857 check_admin_referer( 'order_edit', 'wc_nonce' );
2858 $order_id = filter_input( INPUT_POST, 'order_id' );
2859 $order_num = filter_input( INPUT_POST, 'order_num' );
2860 $tracking_id = filter_input( INPUT_POST, 'tracking_id' );
2861 $amount = filter_input( INPUT_POST, 'amount' );
2862 if ( empty( $order_id ) || empty( $tracking_id ) || empty( $amount ) ) {
2863 $data['status'] = 'NG';
2864 wp_send_json( $data );
2865 break;
2866 }
2867
2868 $res = '';
2869 $status = '';
2870 $acting_status = '';
2871
2872 $latest_log = $this->get_acting_latest_log( $order_id, $tracking_id );
2873 if ( ! empty( $latest_log['order_no'] ) ) {
2874 $order_no = $latest_log['order_no'];
2875 $acting_opts = $this->get_acting_settings();
2876
2877 $params = array();
2878 $params['authentication']['clientip'] = $acting_opts['clientip'];
2879 $params['authentication']['key'] = $acting_opts['authkey'];
2880 $params['transaction']['money'] = $amount;
2881 $params['transaction']['order_number'] = $latest_log['order_no'];
2882 $params['transaction']['pubsec'] = 'yes';
2883
2884 $change_req = '<?xml version="1.0" encoding="utf-8"?>';
2885 $change_req .= '<request>';
2886 $change_req .= $this->assoc2xml( $params );
2887 $change_req .= '</request>';
2888
2889 $xml = $this->get_xml( $acting_opts['card_price_change'], $change_req );
2890 if ( ! empty( $xml ) ) {
2891 $change_res = $this->xml2assoc( $xml );
2892 if ( 'success' === $change_res['response']['result']['status'] ) {
2893 $status = 'OK';
2894 $log = $change_res['response']['result'];
2895 $log['amount'] = $amount;
2896 wel_zeus_save_acting_log( $log, 'zeus_card', 'change', $status, $order_id, $tracking_id );
2897
2898 $new_order_no = ( isset( $change_res['response']['result']['result_order_number'] ) ) ? $change_res['response']['result']['result_order_number'] : '';
2899 if ( ! empty( $new_order_no ) ) {
2900 $usces->set_order_meta_value( 'wc_trans_id', $new_order_no, $order_id );
2901 $usces->set_order_meta_value( 'trans_id', $new_order_no, $order_id );
2902 }
2903 $acting_data = $usces->get_order_meta_value( 'acting_zeus_card', $order_id );
2904 if ( $acting_data ) {
2905 $acting_data = usces_unserialize( $acting_data );
2906 if ( isset( $acting_data['ordd'] ) && ! empty( $new_order_no ) ) {
2907 $acting_data['ordd'] = $new_order_no;
2908 }
2909 if ( isset( $acting_data['money'] ) ) {
2910 $acting_data['money'] = $amount;
2911 }
2912 $usces->set_order_meta_value( 'acting_zeus_card', usces_serialize( $acting_data ), $order_id );
2913 }
2914
2915 if ( ! empty( $new_order_no ) ) {
2916 $order_ref = wel_zeus_get_order_ref( $new_order_no );
2917 if ( 'payment' === $order_ref['status'] ) {
2918 $status_name = $this->get_status_name( $order_ref['status'] );
2919 $order_ref = apply_filters( 'usces_filter_zeus_card_change_log', $order_ref, $order_id, $tracking_id );
2920 wel_zeus_save_acting_log( $order_ref, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
2921 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
2922 $res .= '<table class="settlement-admin-table">';
2923 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2924 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $amount ) . '" /></td>';
2925 $res .= '</tr>';
2926 $res .= '</table>';
2927 $res .= '<div class="settlement-admin-button">';
2928 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2929 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2930 $res .= '</div>';
2931 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
2932 } elseif ( 'auth' === $order_ref['status'] ) {
2933 $status_name = $this->get_status_name( $order_ref['status'] );
2934 $order_ref = apply_filters( 'usces_filter_zeus_card_change_log', $order_ref, $order_id, $tracking_id );
2935 wel_zeus_save_acting_log( $order_ref, 'zeus_card', 'auth', $status, $order_id, $tracking_id );
2936 $res .= '<div class="zeus-settlement-admin card-auth">' . $status_name . '</div>';
2937 $res .= '<table class="settlement-admin-table">';
2938 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2939 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $amount ) . '" /></td>';
2940 $res .= '</tr>';
2941 $res .= '</table>';
2942 $res .= '<div class="settlement-admin-button">';
2943 if ( '仮売完了' === $order_ref['RESULT'] ) {
2944 $res .= '<input id="sale_settlement" type="button" class="button" value="売上処理" />';
2945 }
2946 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2947 $res .= '</div>';
2948 $acting_status = '<span class="acting-status card-auth">' . $status_name . '</span>';
2949 } else {
2950 $status_name = $this->get_status_name( 'payment' );
2951 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
2952 $res .= '<table class="settlement-admin-table">';
2953 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2954 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $amount ) . '" /></td>';
2955 $res .= '</tr>';
2956 $res .= '</table>';
2957 $res .= '<div class="settlement-admin-button">';
2958 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2959 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2960 $res .= '</div>';
2961 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
2962 }
2963 } else {
2964 $status_name = $this->get_status_name( 'payment' );
2965 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
2966 $res .= '<table class="settlement-admin-table">';
2967 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2968 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $amount ) . '" /></td>';
2969 $res .= '</tr>';
2970 $res .= '</table>';
2971 $res .= '<div class="settlement-admin-button">';
2972 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2973 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2974 $res .= '</div>';
2975 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
2976 }
2977 } else {
2978 $status = $change_res['response']['result']['status'];
2979 if ( empty( $status ) ) {
2980 $status = 'ERROR';
2981 }
2982 wel_zeus_save_acting_log( $change_res, 'zeus_card', 'change', $status, $order_id, $tracking_id );
2983 $res .= '<div class="zeus-settlement-admin card-error">金額変更エラー</div>';
2984 }
2985 } else {
2986 $status = 'ERROR';
2987 wel_zeus_save_acting_log( $params, 'zeus_card', 'change', $status, $order_id, $tracking_id );
2988 $res .= '<div class="zeus-settlement-admin card-error">金額変更エラー</div>';
2989 }
2990 } else {
2991 $status = 'NG';
2992 wel_zeus_save_acting_log( $params, 'zeus_card', 'change', $status, $order_id, $tracking_id );
2993 $res .= '<div class="zeus-settlement-admin card-error">金額変更不可</div>';
2994 }
2995 $res .= $this->settlement_history( $order_id, $tracking_id );
2996 $data['result'] = $res;
2997 $data['status'] = $status;
2998 $data['acting_status'] = $acting_status;
2999 wp_send_json( $data );
3000 break;
3001
3002 /* クレジットカード新規決済 */
3003 case 're_settlement_zeus_card':
3004 check_admin_referer( 'order_edit', 'wc_nonce' );
3005 $order_id = filter_input( INPUT_POST, 'order_id' );
3006 $order_num = filter_input( INPUT_POST, 'order_num' );
3007 $tracking_id = filter_input( INPUT_POST, 'tracking_id' );
3008 $member_id = filter_input( INPUT_POST, 'member_id' );
3009 $amount = filter_input( INPUT_POST, 'amount' );
3010 if ( empty( $order_id ) || empty( $tracking_id ) || empty( $amount ) ) {
3011 $data['status'] = 'NG';
3012 wp_send_json( $data );
3013 break;
3014 }
3015
3016 $res = '';
3017 $status = '';
3018 $acting_status = '';
3019
3020 $acting_opts = $this->get_acting_settings();
3021
3022 $params = array();
3023 $params['clientip'] = $acting_opts['clientip'];
3024 $params['cardnumber'] = '9999999999999992';
3025 $params['expyy'] = '00';
3026 $params['expmm'] = '00';
3027 $params['money'] = $amount;
3028 $params['send'] = 'mall';
3029 $params['telno'] = '0000000000';
3030 $params['email'] = $this->get_email( $order_id );
3031 $params['sendid'] = $member_id;
3032 $params['sendpoint'] = $tracking_id;
3033 $params['pubsec'] = 'yes';
3034 $params['printord'] = 'yes';
3035
3036 $page = $this->secure_link_batch( $acting_opts['card_url'], $params );
3037 if ( false !== strpos( $page, 'Success_order' ) ) {
3038 $status = 'OK';
3039
3040 $new_order_no = $this->get_order_number( $page );
3041 if ( ! empty( $new_order_no ) ) {
3042 $usces->set_order_meta_value( 'wc_trans_id', $new_order_no, $order_id );
3043 $usces->set_order_meta_value( 'trans_id', $new_order_no, $order_id );
3044 }
3045 $acting_data = $usces->get_order_meta_value( 'acting_zeus_card', $order_id );
3046 if ( $acting_data ) {
3047 $acting_data = usces_unserialize( $acting_data );
3048 $acting_data['ordd'] = $new_order_no;
3049 $acting_data['money'] = $amount;
3050 if ( ! isset( $acting_data['acting'] ) ) {
3051 $acting_data['acting'] = 'zeus_card';
3052 }
3053 if ( ! isset( $acting_data['sendpoint'] ) ) {
3054 $acting_data['sendpoint'] = $tracking_id;
3055 }
3056 if ( isset( $acting_data['settltment_status'] ) ) {
3057 unset( $acting_data['settltment_status'] );
3058 }
3059 if ( isset( $acting_data['settltment_errmsg'] ) ) {
3060 unset( $acting_data['settltment_errmsg'] );
3061 }
3062 } else {
3063 $acting_data = array(
3064 'acting' => 'zeus_card',
3065 'ordd' => $new_order_no,
3066 'sendpoint' => $tracking_id,
3067 'money' => $amount,
3068 );
3069 }
3070 $usces->set_order_meta_value( 'acting_zeus_card', usces_serialize( $acting_data ), $order_id );
3071
3072 if ( ! empty( $new_order_no ) ) {
3073 $order_ref = wel_zeus_get_order_ref( $new_order_no );
3074 if ( 'payment' === $order_ref['status'] ) {
3075 $status_name = $this->get_status_name( $order_ref['status'] );
3076 $order_ref = apply_filters( 'usces_filter_zeus_card_re_settlement_log', $order_ref, $order_id, $tracking_id );
3077 wel_zeus_save_acting_log( $order_ref, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
3078 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
3079 $res .= '<table class="settlement-admin-table">';
3080 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3081 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $amount ) . '" /></td>';
3082 $res .= '</tr>';
3083 $res .= '</table>';
3084 $res .= '<div class="settlement-admin-button">';
3085 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
3086 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
3087 $res .= '</div>';
3088 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
3089 } elseif ( 'auth' === $order_ref['status'] ) {
3090 $status_name = $this->get_status_name( $order_ref['status'] );
3091 $order_ref = apply_filters( 'usces_filter_zeus_card_re_settlement_log', $order_ref, $order_id, $tracking_id );
3092 wel_zeus_save_acting_log( $order_ref, 'zeus_card', 'auth', $status, $order_id, $tracking_id );
3093 $res .= '<div class="zeus-settlement-admin card-auth">' . $status_name . '</div>';
3094 $res .= '<table class="settlement-admin-table">';
3095 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3096 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $amount ) . '" /></td>';
3097 $res .= '</tr>';
3098 $res .= '</table>';
3099 $res .= '<div class="settlement-admin-button">';
3100 if ( '仮売完了' === $order_ref['RESULT'] ) {
3101 $res .= '<input id="sale_settlement" type="button" class="button" value="売上処理" />';
3102 }
3103 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
3104 $res .= '</div>';
3105 $acting_status = '<span class="acting-status card-auth">' . $status_name . '</span>';
3106 } else {
3107 $status_name = $this->get_status_name( 'payment' );
3108 if ( ! isset( $params['ordd'] ) ) {
3109 $params['ordd'] = $new_order_no;
3110 }
3111 $params = apply_filters( 'usces_filter_zeus_card_re_settlement_log', $params, $order_id, $tracking_id );
3112 wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
3113 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
3114 $res .= '<table class="settlement-admin-table">';
3115 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3116 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $amount ) . '" /></td>';
3117 $res .= '</tr>';
3118 $res .= '</table>';
3119 $res .= '<div class="settlement-admin-button">';
3120 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
3121 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
3122 $res .= '</div>';
3123 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
3124 }
3125 } else {
3126 $status_name = $this->get_status_name( 'payment' );
3127 $params = apply_filters( 'usces_filter_zeus_card_re_settlement_log', $params, $order_id, $tracking_id );
3128 wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
3129 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
3130 $res .= '<table class="settlement-admin-table">';
3131 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3132 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '<input type="hidden" id="amount_original" value="' . intval( $amount ) . '" /></td>';
3133 $res .= '</tr>';
3134 $res .= '</table>';
3135 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
3136 }
3137 } else {
3138 $status = $this->get_error_results( $page );
3139 if ( empty( $status ) ) {
3140 $status = 'ERROR';
3141 }
3142 wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
3143 $res .= '<div class="zeus-settlement-admin card-error">新規決済エラー</div>';
3144 $res .= '<table class="settlement-admin-table">';
3145 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3146 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3147 $res .= '</tr>';
3148 $res .= '</table>';
3149 $res .= '<div class="settlement-admin-button">';
3150 $res .= '<input id="re_settlement" type="button" class="button" value="新規決済" />';
3151 $res .= '</div>';
3152 }
3153
3154 $res .= $this->settlement_history( $order_id, $tracking_id );
3155 $data['result'] = $res;
3156 $data['status'] = $status;
3157 $data['acting_status'] = $acting_status;
3158 wp_send_json( $data );
3159 break;
3160
3161 /* あと払い参�
3162 � */
3163 case 'get_zeus_bnpl':
3164 check_admin_referer( 'order_edit', 'wc_nonce' );
3165 $order_id = filter_input( INPUT_POST, 'order_id' );
3166 $shoporder_id = filter_input( INPUT_POST, 'shoporder_id' );
3167 $order_status = filter_input( INPUT_POST, 'order_status' );
3168 $delivery_company = filter_input( INPUT_POST, 'delivery_company' );
3169 $tracking_number = filter_input( INPUT_POST, 'tracking_number' );
3170 if ( empty( $order_id ) || empty( $shoporder_id ) ) {
3171 $data['status'] = 'NG';
3172 wp_send_json( $data );
3173 break;
3174 }
3175
3176 $res = '';
3177 $status = '';
3178
3179 $latest_log = $this->get_acting_latest_log( $order_id, $shoporder_id, 'ALL' );
3180 if ( ! empty( $latest_log['status'] ) && ! empty( $latest_log['result'] ) ) {
3181 if ( 'transaction' === $latest_log['status'] ) {
3182 $status = $latest_log['result'];
3183 $status_name = $this->get_status_name( $latest_log['status'] . $latest_log['result'] );
3184 $res .= '<div class="zeus-settlement-admin bnpl-transaction">' . $status_name . '</div>';
3185 $res .= '<div class="settlement-admin-button">';
3186 if ( 'OK' === $latest_log['result'] ) {
3187 $delivery_company_cd = array_search( $delivery_company, $this->shipping_company );
3188 $shippingrequest_disabled = ( ! $delivery_company_cd || ! $tracking_number ) ? ' disabled="disabled"' : '';
3189 $cancel_disabled = '';
3190 $res .= '<input id="shippingrequest_bnpl" type="button" class="button" value="出荷登録"' . $shippingrequest_disabled . ' />';
3191 } else {
3192 $cancel_disabled = ' disabled="disabled"';
3193 }
3194 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル"' . $cancel_disabled . ' />';
3195 $res .= '</div>';
3196 } elseif ( 'shippingrequest' === $latest_log['status'] ) {
3197 $status = $latest_log['result'];
3198 $status_name = $this->get_status_name( $latest_log['status'] . $latest_log['result'] );
3199 if ( 'OK' === $latest_log['result'] ) {
3200 $res .= '<div class="zeus-settlement-admin bnpl-shippingrequest">' . $status_name . '</div>';
3201 $res .= '<div class="settlement-admin-button">';
3202 } else {
3203 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3204 $res .= '<div class="settlement-admin-button">';
3205 $res .= '<input id="shippingrequest_bnpl" type="button" class="button" value="出荷登録" />';
3206 }
3207 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3208 $res .= '</div>';
3209 } elseif ( 'canceltransaction' === $latest_log['status'] ) {
3210 $status = $latest_log['result'];
3211 $status_name = $this->get_status_name( $latest_log['status'] . $latest_log['result'] );
3212 if ( 'OK' === $latest_log['result'] ) {
3213 $res .= '<div class="zeus-settlement-admin bnpl-canceltransaction">' . $status_name . '</div>';
3214 } else {
3215 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3216 $res .= '<div class="settlement-admin-button">';
3217 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3218 $res .= '</div>';
3219 }
3220 }
3221 } else {
3222 $status = 'ERROR';
3223 $status_name = $this->get_status_name( 'error' );
3224 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3225 }
3226
3227 $res .= $this->settlement_history_bnpl( $order_id, $shoporder_id );
3228 $data['result'] = $res;
3229 $data['status'] = $status;
3230 wp_send_json( $data );
3231 break;
3232
3233 /* あと払い出荷登録 */
3234 case 'shippingrequest_zeus_bnpl':
3235 check_admin_referer( 'order_edit', 'wc_nonce' );
3236 $order_id = filter_input( INPUT_POST, 'order_id' );
3237 $shoporder_id = filter_input( INPUT_POST, 'shoporder_id' );
3238 $order_status = filter_input( INPUT_POST, 'order_status' );
3239 $delivery_company = filter_input( INPUT_POST, 'delivery_company' );
3240 $tracking_number = filter_input( INPUT_POST, 'tracking_number' );
3241 if ( empty( $order_id ) || empty( $shoporder_id ) ) {
3242 $data['status'] = 'NG';
3243 wp_send_json( $data );
3244 break;
3245 }
3246
3247 $delivery_company_cd = array_search( $delivery_company, $this->shipping_company );
3248 if ( ! $delivery_company_cd || ! $tracking_number ) {
3249 $data['status'] = 'NG';
3250 wp_send_json( $data );
3251 break;
3252 }
3253
3254 $res = '';
3255 $status = '';
3256 $acting_status = '';
3257
3258 $acting_opts = $this->get_acting_settings();
3259 $latest_log = $this->get_acting_latest_log( $order_id, $shoporder_id );
3260
3261 $data = array();
3262 $data['linkInfo'] = array(
3263 'shopCode' => $acting_opts['clientip_bnpl'],
3264 'linkId' => $acting_opts['bnpl_linkid'],
3265 'linkPassword' => $acting_opts['bnpl_linkpassword'],
3266 );
3267 $data['transactionInfo'] = array(
3268 'deliveryType' => '1',
3269 'transactionId' => $latest_log['log']['transactionInfo']['transactionId'],
3270 'deliveryCompanyCode' => $delivery_company_cd,
3271 'deliverySlipNo' => $tracking_number,
3272 );
3273
3274 $request = '<?xml version="1.0" encoding="UTF-8"?>';
3275 $request .= '<request>';
3276 $request .= $this->assoc2xml( $data );
3277 $request .= '</request>';
3278
3279 $xml = $this->get_xml_bnpl( $acting_opts['bnpl_shippingrequest_url'], $request );
3280 if ( empty( $xml ) ) {
3281 $status = 'NG';
3282 wel_zeus_save_acting_log( $data, 'zeus_bnpl', 'shippingrequest', $status, $order_id, $shoporder_id );
3283 $status_name = $this->get_status_name( 'shippingrequest' . $status );
3284 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3285 $res .= '<div class="settlement-admin-button">';
3286 $res .= '<input id="shippingrequest_bnpl" type="button" class="button" value="出荷登録" />';
3287 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3288 $res .= '</div>';
3289 $acting_status = '<span class="acting-status bnpl-error">' . $status_name . '</span>';
3290 } else {
3291 $response = $this->xml2assoc( $xml );
3292 $status = ( isset( $response['response']['result'] ) ) ? $response['response']['result'] : 'NG';
3293 wel_zeus_save_acting_log( $response['response'], 'zeus_bnpl', 'shippingrequest', $status, $order_id, $shoporder_id );
3294 $status_name = $this->get_status_name( 'shippingrequest' . $status );
3295 if ( 'OK' === $status ) {
3296 $res .= '<div class="zeus-settlement-admin bnpl-shippingrequest">' . $status_name . '</div>';
3297 $res .= '<div class="settlement-admin-button">';
3298 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3299 $res .= '</div>';
3300 $acting_status = '<span class="acting-status bnpl-shippingrequest">' . $status_name . '</span>';
3301 } else {
3302 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3303 $res .= '<div class="settlement-admin-button">';
3304 $res .= '<input id="shippingrequest_bnpl" type="button" class="button" value="出荷登録" />';
3305 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3306 $res .= '</div>';
3307 $acting_status = '<span class="acting-status bnpl-error">' . $status_name . '</span>';
3308 }
3309 }
3310
3311 $res .= $this->settlement_history_bnpl( $order_id, $shoporder_id );
3312 $data['result'] = $res;
3313 $data['status'] = $status;
3314 $data['acting_status'] = $acting_status;
3315 wp_send_json( $data );
3316 break;
3317
3318 /* あと払い取消 */
3319 case 'cancel_zeus_bnpl':
3320 check_admin_referer( 'order_edit', 'wc_nonce' );
3321 $order_id = filter_input( INPUT_POST, 'order_id' );
3322 $shoporder_id = filter_input( INPUT_POST, 'shoporder_id' );
3323 $order_status = filter_input( INPUT_POST, 'order_status' );
3324 if ( empty( $order_id ) || empty( $shoporder_id ) ) {
3325 $data['status'] = 'NG';
3326 wp_send_json( $data );
3327 break;
3328 }
3329
3330 $res = '';
3331 $status = '';
3332 $acting_status = '';
3333
3334 $acting_opts = $this->get_acting_settings();
3335 $latest_log = $this->get_acting_latest_log( $order_id, $shoporder_id );
3336
3337 $data = array();
3338 $data['linkInfo'] = array(
3339 'shopCode' => $acting_opts['clientip_bnpl'],
3340 'linkId' => $acting_opts['bnpl_linkid'],
3341 'linkPassword' => $acting_opts['bnpl_linkpassword'],
3342 );
3343 // 出荷登録API 出荷取消.
3344 // $data['transactionInfo'] = array(
3345 // 'deliveryType' => '3',
3346 // 'transactionId' => $latest_log['log']['transactionInfo']['transactionId'],
3347 // 'deliveryCompanyCode' => '',
3348 // 'deliverySlipNo' => '',
3349 // );
3350 // 取引修正API キャンセル.
3351 $data['transactionInfo'] = array(
3352 'updateTypeFlag' => '1',
3353 'transactionId' => $latest_log['log']['transactionInfo']['transactionId'],
3354 );
3355 $data['customer'] = array(
3356 'shopOrderId' => '',
3357 'shopOrderDate' => '',
3358 'name' => '',
3359 'kanaName' => '',
3360 'zip' => '',
3361 'address' => '',
3362 'companyName' => '',
3363 'sectionName' => '',
3364 'tel' => '',
3365 'email' => '',
3366 'billedAmount' => '',
3367 'expand1' => '',
3368 'service' => '',
3369 );
3370 $data['ship'] = array(
3371 'shipName' => '',
3372 'shipKananame' => '',
3373 'shipZip' => '',
3374 'shipAddress' => '',
3375 'shipCompanyName' => '',
3376 'shipSectionName' => '',
3377 'shipTel' => '',
3378 );
3379 $data['details'] = array(
3380 'detail' => array(
3381 'goods' => '',
3382 'goodsPrice' => '',
3383 'goodsAmount' => '',
3384 'expand2' => '',
3385 'expand3' => '',
3386 'expand4' => '',
3387 ),
3388 );
3389
3390 $request = '<?xml version="1.0" encoding="UTF-8"?>';
3391 $request .= '<request>';
3392 $request .= $this->assoc2xml( $data );
3393 $request .= '</request>';
3394
3395 // $xml = $this->get_xml_bnpl( $acting_opts['bnpl_shippingrequest_url'], $request );
3396 $xml = $this->get_xml_bnpl( $acting_opts['bnpl_modifytransaction_url'], $request );
3397 if ( empty( $xml ) ) {
3398 $status = 'NG';
3399 wel_zeus_save_acting_log( $data, 'zeus_bnpl', 'canceltransaction', $status, $order_id, $shoporder_id );
3400 $status_name = $this->get_status_name( 'canceltransaction' . $status );
3401 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3402 $res .= '<div class="settlement-admin-button">';
3403 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3404 $res .= '</div>';
3405 $acting_status = '<span class="acting-status bnpl-error">' . $status_name . '</span>';
3406 } else {
3407 $response = $this->xml2assoc( $xml );
3408 $status = ( isset( $response['response']['result'] ) ) ? $response['response']['result'] : 'NG';
3409 wel_zeus_save_acting_log( $response['response'], 'zeus_bnpl', 'canceltransaction', $status, $order_id, $shoporder_id );
3410 $status_name = $this->get_status_name( 'canceltransaction' . $status );
3411 if ( 'OK' === $status ) {
3412 $res .= '<div class="zeus-settlement-admin bnpl-canceltransaction">' . $status_name . '</div>';
3413 $acting_status = '<span class="acting-status bnpl-canceltransaction">' . $status_name . '</span>';
3414 } else {
3415 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3416 $res .= '<div class="settlement-admin-button">';
3417 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3418 $res .= '</div>';
3419 $acting_status = '<span class="acting-status bnpl-error">' . $status_name . '</span>';
3420 }
3421 }
3422
3423 $res .= $this->settlement_history_bnpl( $order_id, $shoporder_id );
3424 $data['result'] = $res;
3425 $data['status'] = $status;
3426 $data['acting_status'] = $acting_status;
3427 wp_send_json( $data );
3428 break;
3429
3430 /* 継続課金�
3431 報更新 */
3432 case 'continuation_update':
3433 check_admin_referer( 'order_edit', 'wc_nonce' );
3434 $order_id = filter_input( INPUT_POST, 'order_id' );
3435 $member_id = filter_input( INPUT_POST, 'member_id' );
3436 $contracted_year = filter_input( INPUT_POST, 'contracted_year' );
3437 $contracted_month = filter_input( INPUT_POST, 'contracted_month' );
3438 $contracted_day = filter_input( INPUT_POST, 'contracted_day' );
3439 $charged_year = filter_input( INPUT_POST, 'charged_year' );
3440 $charged_month = filter_input( INPUT_POST, 'charged_month' );
3441 $charged_day = filter_input( INPUT_POST, 'charged_day' );
3442 $price = filter_input( INPUT_POST, 'price', FILTER_VALIDATE_INT, array( 'options' => array( 'default' => 0 ) ) );
3443 $status = filter_input( INPUT_POST, 'status' );
3444
3445 $continue_data = $this->get_continuation_data( $member_id, $order_id );
3446 if ( ! $continue_data ) {
3447 $data['status'] = 'NG';
3448 wp_send_json( $data );
3449 break;
3450 }
3451
3452 /* 継続中→停止 */
3453 if ( 'continuation' === $continue_data['status'] && 'cancellation' === $status ) {
3454 $this->update_continuation_data( $member_id, $order_id, $continue_data, true );
3455 } else {
3456 if ( ! empty( $contracted_year ) && ! empty( $contracted_month ) && ! empty( $contracted_day ) ) {
3457 $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
3458 if ( $contracted_date ) {
3459 $new_contracted_date = $contracted_year . '-' . $contracted_month . '-' . $contracted_day;
3460 if ( ! $this->isdate( $new_contracted_date ) ) {
3461 $data['status'] = 'NG';
3462 $data['message'] = __( 'Next contract renewal date is incorrect.', 'dlseller' );
3463 wp_send_json( $data );
3464 }
3465 }
3466 } else {
3467 $new_contracted_date = '';
3468 }
3469 $new_charged_date = $charged_year . '-' . $charged_month . '-' . $charged_day;
3470 if ( ! $this->isdate( $new_charged_date ) ) {
3471 $data['status'] = 'NG';
3472 $data['message'] = __( 'Next settlement date is incorrect.', 'dlseller' );
3473 wp_send_json( $data );
3474 }
3475 $tomorrow = date_i18n( 'Y-m-d', strtotime( '+1 day' ) );
3476 if ( $new_charged_date < $tomorrow ) {
3477 $data['status'] = 'NG';
3478 $data['message'] = sprintf( __( 'The next settlement date must be after %s.', 'dlseller' ), $tomorrow );
3479 wp_send_json( $data );
3480 }
3481 $continue_data['contractedday'] = $new_contracted_date;
3482 $continue_data['chargedday'] = $new_charged_date;
3483 $continue_data['price'] = usces_crform( $price, false, false, 'return', false );
3484 $continue_data['status'] = $status;
3485 $this->update_continuation_data( $member_id, $order_id, $continue_data );
3486 }
3487 $data['status'] = 'OK';
3488 wp_send_json( $data );
3489 break;
3490 }
3491 }
3492
3493 /**
3494 * 決済履歴
3495 *
3496 * @param int $order_id Order number.
3497 * @param string $tracking_id Tracking ID.
3498 * @return string
3499 */
3500 private function settlement_history( $order_id, $tracking_id ) {
3501 $history = '';
3502 $log_data = $this->get_acting_log( $order_id, $tracking_id, 'ALL' );
3503 if ( $log_data ) {
3504 $num = count( $log_data );
3505 $history = '<table class="settlement-history">';
3506 $history .= '<thead class="settlement-history-head">';
3507 $history .= '<tr><th></th><th>' . __( 'Processing date', 'usces' ) . '</th><th>オーダーNo</th><th>処理結果</th><th>' . __( 'Settlement amount', 'usces' ) . '</th><th>エラーメッセージ</th></tr>';
3508 $history .= '</thead>';
3509 $history .= '<tbody class="settlement-history-body">';
3510 foreach ( (array) $log_data as $data ) {
3511 $log = usces_unserialize( $data['log'] );
3512 $order_no = $this->get_order_no( $log );
3513 $status_name = $this->get_status_name( $data['status'], $data['result'] );
3514 $err_result = '';
3515 $class = '';
3516 $amount = usces_crform( $data['amount'], false, true, 'return', true );
3517 if ( ! in_array( $data['result'], $this->payment_normal_results, true ) ) {
3518 $err_result = $data['result'];
3519 $class = ' error';
3520 }
3521 $history .= '<tr>';
3522 $history .= '<td class="num">' . $num . '</td>';
3523 $history .= '<td class="datetime">' . $data['datetime'] . '</td>';
3524 $history .= '<td class="transactionid">' . $order_no . '</td>';
3525 $history .= '<td class="status">' . $status_name . '</td>';
3526 $history .= '<td class="amount">' . $amount . '</td>';
3527 $history .= '<td class="result' . $class . '">' . $err_result . '</td>';
3528 $history .= '</tr>';
3529 $num--;
3530 }
3531 $history .= '</tbody>';
3532 $history .= '</table>';
3533 }
3534 return $history;
3535 }
3536
3537 /**
3538 * 決済履歴(あと払い)
3539 *
3540 * @param int $order_id Order number.
3541 * @param string $tracking_id Tracking ID.
3542 * @return string
3543 */
3544 private function settlement_history_bnpl( $order_id, $tracking_id ) {
3545 $history = '';
3546 $log_data = $this->get_acting_log( $order_id, $tracking_id, 'ALL' );
3547 if ( $log_data ) {
3548 $num = count( $log_data );
3549 $history = '<table class="settlement-history">';
3550 $history .= '<thead class="settlement-history-head">';
3551 $history .= '<tr><th></th><th>' . __( 'Processing date', 'usces' ) . '</th><th>問い合わせ番号</th><th>処理</th><th>処理結果</th><th>' . __( 'Settlement amount', 'usces' ) . '</th><th>エラーメッセージ</th></tr>';
3552 $history .= '</thead>';
3553 $history .= '<tbody class="settlement-history-body">';
3554 foreach ( (array) $log_data as $data ) {
3555 $log = usces_unserialize( $data['log'] );
3556 $transaction_id = ( isset( $log['transactionInfo']['transactionId'] ) ) ? $log['transactionInfo']['transactionId'] : '';
3557 $status_name = $this->get_status_name( $data['status'] );
3558 $err_result = '';
3559 $class = '';
3560 $amount = ( 0 !== (int) $data['amount'] ) ? usces_crform( $data['amount'], false, true, 'return', true ) : '';
3561 if ( ! in_array( $data['result'], $this->payment_normal_results, true ) ) {
3562 if ( isset( $log['errors']['error']['errorCode'] ) && isset( $log['errors']['error']['errorMessage'] ) ) {
3563 $err_result = $log['errors']['error']['errorCode'] . ':' . $log['errors']['error']['errorMessage'];
3564 }
3565 $class = ' error';
3566 }
3567 $history .= '<tr>';
3568 $history .= '<td class="num">' . $num . '</td>';
3569 $history .= '<td class="datetime">' . $data['datetime'] . '</td>';
3570 $history .= '<td class="transaction_id">' . $transaction_id . '</td>';
3571 $history .= '<td class="status">' . $status_name . '</td>';
3572 $history .= '<td class="status">' . $data['result'] . '</td>';
3573 $history .= '<td class="amount">' . $amount . '</td>';
3574 $history .= '<td class="result' . $class . '">' . $err_result . '</td>';
3575 $history .= '</tr>';
3576 $num--;
3577 }
3578 $history .= '</tbody>';
3579 $history .= '</table>';
3580 }
3581 return $history;
3582 }
3583
3584 /**
3585 * 決済状況
3586 * usces_filter_orderlist_detail_value
3587 *
3588 * @param string $detail HTML.
3589 * @param string $value Settlement info key.
3590 * @param string $key Settlement info value.
3591 * @param int $order_id Order number.
3592 * @return array
3593 */
3594 public function orderlist_settlement_status( $detail, $value, $key, $order_id ) {
3595 if ( 'wc_trans_id' !== $key ) {
3596 return $detail;
3597 }
3598
3599 $payment_name = $this->get_order_payment_name( $order_id );
3600 $acting_flg = $this->get_acting_flg( $payment_name );
3601 if ( 'acting_zeus_card' === $acting_flg ) {
3602 $tracking_id = $this->get_tracking_id( $order_id );
3603 if ( ! empty( $tracking_id ) ) {
3604 $acting_status = $this->get_acting_status( $order_id, $tracking_id, 'ALL' );
3605 $status_name = $this->get_status_name( $acting_status );
3606 if ( ! empty( $status_name ) ) {
3607 $detail = '<td>' . esc_html( $value ) . '<span class="acting-status card-' . esc_html( $acting_status ) . '">' . esc_html( $status_name ) . '</span></td>';
3608 }
3609 }
3610 } elseif ( 'acting_zeus_bnpl' === $acting_flg ) {
3611 $tracking_id = $this->get_tracking_id( $order_id );
3612 if ( ! empty( $tracking_id ) ) {
3613 $acting_status = $this->get_acting_status( $order_id, $tracking_id, 'ALL' );
3614 $status_name = $this->get_status_name( $acting_status );
3615 if ( ! empty( $status_name ) ) {
3616 $class = ( 'NG' === substr( $acting_status, -2 ) ) ? 'error' : $acting_status;
3617 $detail = '<td>' . esc_html( $value ) . '<span class="acting-status bnpl-' . esc_html( $class ) . '">' . esc_html( $status_name ) . '</span></td>';
3618 }
3619 }
3620 }
3621 return $detail;
3622 }
3623
3624 /**
3625 * 受注編集画面【ステータス】
3626 * usces_action_order_edit_form_status_block_middle
3627 *
3628 * @param array $data Order data.
3629 * @param array $cscs_meta Custom field data.
3630 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3631 */
3632 public function settlement_status( $data, $cscs_meta, $action_args ) {
3633 $order_action = ( isset( $action_args['order_action'] ) ) ? $action_args['order_action'] : '';
3634 $order_id = ( isset( $action_args['order_id'] ) ) ? $action_args['order_id'] : '';
3635 if ( 'new' !== $order_action && ! empty( $order_id ) ) {
3636 $acting_flg = $this->get_acting_flg( $data['order_payment_name'] );
3637 if ( 'acting_zeus_card' === $acting_flg ) {
3638 $tracking_id = $this->get_tracking_id( $order_id );
3639 $acting_status = $this->get_acting_status( $order_id, $tracking_id, 'ALL' );
3640 $status_name = $this->get_status_name( $acting_status );
3641 if ( ! empty( $status_name ) ) {
3642 echo '
3643 <tr>
3644 <td class="label status">' . esc_html__( 'Settlement status', 'usces' ) . '</td>
3645 <td class="col1 status"><span id="settlement-status"><span class="acting-status card-' . esc_attr( $acting_status ) . '">' . esc_html( $status_name ) . '</span></span></td>
3646 </tr>';
3647 }
3648 } elseif ( 'acting_zeus_bnpl' === $acting_flg ) {
3649 $tracking_id = $this->get_tracking_id( $order_id );
3650 $acting_status = $this->get_acting_status( $order_id, $tracking_id, 'ALL' );
3651 $class = ' bnpl-' . $acting_status;
3652 $status_name = $this->get_status_name( $acting_status );
3653 if ( ! empty( $status_name ) ) {
3654 $class = ( 'NG' === substr( $acting_status, -2 ) ) ? 'error' : $acting_status;
3655 echo '
3656 <tr>
3657 <td class="label status">' . esc_html__( 'Settlement status', 'usces' ) . '</td>
3658 <td class="col1 status"><span id="settlement-status"><span class="acting-status bnpl-' . esc_attr( $class ) . '">' . esc_html( $status_name ) . '</span></span></td>
3659 </tr>';
3660 }
3661 }
3662 }
3663 }
3664
3665 /**
3666 * 受注編集画面【支払�
3667 報】
3668 * usces_action_order_edit_form_settle_info
3669 *
3670 * @param array $data Order data.
3671 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3672 */
3673 public function settlement_information( $data, $action_args ) {
3674 $order_action = ( isset( $action_args['order_action'] ) ) ? $action_args['order_action'] : '';
3675 $order_id = ( isset( $action_args['order_id'] ) ) ? $action_args['order_id'] : '';
3676 if ( 'new' !== $order_action && ! empty( $order_id ) ) {
3677 $acting_flg = $this->get_acting_flg( $data['order_payment_name'] );
3678 if ( 'acting_zeus_card' === $acting_flg || 'acting_zeus_bnpl' === $acting_flg ) {
3679 $tracking_id = $this->get_tracking_id( $order_id );
3680 if ( ! empty( $tracking_id ) ) {
3681 echo '<input type="button" class="button settlement-information" id="settlement-information-' . esc_attr( $tracking_id ) . '" data-tracking_id="' . esc_attr( $tracking_id ) . '" data-num="1" value="' . esc_attr__( 'Settlement info', 'usces' ) . '">';
3682 }
3683 }
3684 }
3685 }
3686
3687 /**
3688 * 決済�
3689 報ダイアログ
3690 * usces_action_endof_order_edit_form
3691 *
3692 * @param array $data Order data.
3693 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3694 */
3695 public function settlement_dialog( $data, $action_args ) {
3696 $order_action = ( isset( $action_args['order_action'] ) ) ? $action_args['order_action'] : '';
3697 $order_id = ( isset( $action_args['order_id'] ) ) ? $action_args['order_id'] : '';
3698 if ( 'new' !== $order_action && ! empty( $order_id ) ) :
3699 $acting_flg = $this->get_acting_flg( $data['order_payment_name'] );
3700 if ( 'acting_zeus_card' === $acting_flg || 'acting_zeus_bnpl' === $acting_flg ) :
3701 ?>
3702 <div id="settlement_dialog" title="">
3703 <div id="settlement-response-loading"></div>
3704 <fieldset>
3705 <div id="settlement-response"></div>
3706 <input type="hidden" id="order_num">
3707 <input type="hidden" id="tracking_id">
3708 <input type="hidden" id="acting" value="<?php echo esc_attr( $acting_flg ); ?>">
3709 <input type="hidden" id="error">
3710 </fieldset>
3711 </div>
3712 <?php
3713 endif;
3714 endif;
3715 }
3716
3717 /**
3718 * 受注データから取得する決済�
3719 報のキー
3720 * usces_filter_settle_info_field_meta_keys
3721 *
3722 * @param array $keys Settlement information key.
3723 * @return array
3724 */
3725 public function settlement_info_field_meta_keys( $keys ) {
3726 $keys = array_merge( $keys, array( 'div', 'auth_code', 'shopOrderId', 'transactionId' ) );
3727 return $keys;
3728 }
3729
3730 /**
3731 * 受注編集画面に表示する決済�
3732 報のキー
3733 * usces_filter_settle_info_field_keys
3734 *
3735 * @param array $keys Settlement information keys.
3736 * @param array $fields Settlement information fields.
3737 * @return array
3738 */
3739 public function settlement_info_field_keys( $keys, $fields ) {
3740 if ( isset( $fields['acting'] ) ) {
3741 if ( 'zeus_card' === $fields['acting'] ) {
3742 $field_keys = array( 'div' );
3743 $acting_opts = $this->get_acting_settings();
3744 if ( 2 === (int) $acting_opts['connection'] && 1 === (int) $acting_opts['3dsecur'] ) {
3745 $field_keys[] = 'auth_code';
3746 }
3747 $keys = array_merge( $keys, $field_keys );
3748 } elseif ( 'zeus_bnpl' === $fields['acting'] ) {
3749 $keys = array( 'acting', 'shopOrderId', 'transactionId' );
3750 }
3751 }
3752 return $keys;
3753 }
3754
3755 /**
3756 * 受注編集画面に表示する決済�
3757 報の値整形
3758 * usces_filter_settle_info_field_value
3759 *
3760 * @param string $value Settlement information value.
3761 * @param string $key Settlement information key.
3762 * @param string $acting Acting type.
3763 * @return string
3764 */
3765 public function settlement_info_field_value( $value, $key, $acting ) {
3766 if ( false !== strpos( $acting, 'zeus_card' ) ) {
3767 if ( 'acting' === $key ) {
3768 $value = 'カード決済(ZEUS)';
3769 } elseif ( 'div' === $key ) {
3770 switch ( $value ) {
3771 case '01':
3772 $value = '一括払い';
3773 break;
3774 case '02':
3775 $value = '分割(2回)';
3776 break;
3777 case '03':
3778 $value = '分割(3回)';
3779 break;
3780 case '05':
3781 $value = '分割(5回)';
3782 break;
3783 case '06':
3784 $value = '分割(6回)';
3785 break;
3786 case '10':
3787 $value = '分割(10回)';
3788 break;
3789 case '12':
3790 $value = '分割(12回)';
3791 break;
3792 case '15':
3793 $value = '分割(15回)';
3794 break;
3795 case '18':
3796 $value = '分割(18回)';
3797 break;
3798 case '20':
3799 $value = '分割(20回)';
3800 break;
3801 case '24':
3802 $value = '分割(24回)';
3803 break;
3804 case '99':
3805 $value = '分割(リボ払い)';
3806 break;
3807 case 'B1':
3808 $value = '分割(ボーナス一括払い)';
3809 break;
3810 }
3811 }
3812 } elseif ( 'zeus_bank' === $acting ) {
3813 if ( 'acting' === $key ) {
3814 $value = '銀行振込決済(ZEUS)';
3815 } elseif ( 'status' === $key ) {
3816 if ( '01' === $value ) {
3817 $value = '受付中';
3818 } elseif ( '02' === $value ) {
3819 $value = '未�
3820 �金';
3821 } elseif ( '03' === $value ) {
3822 $value = '�
3823 �金済';
3824 } elseif ( '04' === $value ) {
3825 $value = 'エラー';
3826 } elseif ( '05' === $value ) {
3827 $value = '�
3828 �金失敗';
3829 }
3830 } elseif ( 'error_message' === $key ) {
3831 if ( '0002' === $value ) {
3832 $value = '�
3833 �金不足';
3834 } elseif ( '0003' === $value ) {
3835 $value = '過剰�
3836 �金';
3837 }
3838 }
3839 } elseif ( 'zeus_conv' === $acting ) {
3840 if ( 'acting' === $key ) {
3841 $value = 'コンビニ決済(ZEUS)';
3842 } elseif ( 'pay_cvs' === $key ) {
3843 $value = esc_html( usces_get_conv_name( $value ) );
3844 } elseif ( 'status' === $key ) {
3845 if ( '01' === $value ) {
3846 $value = '未�
3847 �金';
3848 } elseif ( '02' === $value ) {
3849 $value = '申込エラー';
3850 } elseif ( '03' === $value ) {
3851 $value = '期日切';
3852 } elseif ( '04' === $value ) {
3853 $value = '�
3854 �金済';
3855 } elseif ( '05' === $value ) {
3856 $value = '売上確定';
3857 } elseif ( '06' === $value ) {
3858 $value = '�
3859 �金取消';
3860 } elseif ( '11' === $value ) {
3861 $value = 'キャンセル後�
3862 �金';
3863 } elseif ( '12' === $value ) {
3864 $value = 'キャンセル後売上';
3865 } elseif ( '13' === $value ) {
3866 $value = 'キャンセル後取消';
3867 }
3868 } elseif ( 'pay_limit' === $key ) {
3869 $value = substr( $value, 0, 4 ) . '' . substr( $value, 4, 2 ) . '' . substr( $value, 6, 2 ) . '';
3870 }
3871 } elseif ( 'zeus_bnpl' === $acting ) {
3872 if ( 'acting' === $key ) {
3873 $value = 'あと払い決済(ZEUS)';
3874 }
3875 }
3876 return $value;
3877 }
3878
3879 /**
3880 * あと払い運送会社名
3881 * usces_filter_deli_comps
3882 *
3883 * @param array $deli_comps Delivery company.
3884 * @param array $data Order data.
3885 * @return array
3886 */
3887 public function bnpl_delivery_company( $deli_comps, $data ) {
3888 if ( isset( $data['order_payment_name'] ) ) {
3889 $acting_flg = $this->get_acting_flg( $data['order_payment_name'] );
3890 if ( 'acting_zeus_bnpl' === $acting_flg ) {
3891 $deli_comps = array_values( $this->shipping_company );
3892 }
3893 }
3894 return $deli_comps;
3895 }
3896
3897 /**
3898 * 会員データ編集画面 カード�
3899 報登録�
3900
3901 * usces_action_admin_member_info
3902 *
3903 * @param array $member Member data.
3904 * @param array $member_metas Member meta data.
3905 * @param array $member_history Member's history order data.
3906 */
3907 public function admin_member_info( $member, $member_metas, $member_history ) {
3908 $acting_opts = $this->get_acting_settings();
3909 if ( 'on' !== $acting_opts['quickcharge'] ) {
3910 return;
3911 }
3912
3913 $cardinfo = array();
3914 foreach ( $member_metas as $value ) {
3915 if ( in_array( $value['meta_key'], array( 'zeus_pcid', 'zeus_partofcard' ), true ) ) {
3916 $cardinfo[ $value['meta_key'] ] = $value['meta_value'];
3917 }
3918 }
3919 if ( 0 < count( $cardinfo ) ) :
3920 foreach ( $cardinfo as $key => $value ) :
3921 if ( 'zeus_pcid' !== $key ) :
3922 if ( 'zeus_partofcard' === $key ) {
3923 $label = __( 'Lower 4 digits', 'usces' );
3924 } elseif ( 'zeus_limitofcard' === $key ) {
3925 $label = __( 'Expiration date', 'usces' );
3926 } else {
3927 $label = $key;
3928 }
3929 ?>
3930 <tr>
3931 <td class="label"><?php echo esc_html( $label ); ?></td>
3932 <td><div class="rod_left shortm"><?php echo esc_html( $value ); ?></div></td>
3933 </tr>
3934 <?php
3935 endif;
3936 endforeach;
3937 if ( array_key_exists( 'zeus_pcid', $cardinfo ) ) :
3938 ?>
3939 <tr>
3940 <td class="label">QuickCharge</td>
3941 <td><div class="rod_left shortm"><?php esc_html_e( 'Registered', 'usces' ); ?></div></td>
3942 </tr>
3943 <?php
3944 if ( ! usces_have_member_continue_order( $member['ID'] ) && ! usces_have_member_regular_order( $member['ID'] ) ) :
3945 ?>
3946 <tr>
3947 <td class="label"><input type="checkbox" name="zeus_pcid" id="zeus_pcid" value="delete"></td>
3948 <td><label for="zeus_pcid">QuickCharge を解除する</label></td>
3949 </tr>
3950 <?php
3951 endif;
3952 endif;
3953 endif;
3954 }
3955
3956 /**
3957 * 会員データ編集画面 カード�
3958 報登録解除
3959 * usces_action_post_update_memberdata
3960 *
3961 * @param int $member_id Member ID.
3962 * @param bool $res Member data update results.
3963 */
3964 public function admin_update_memberdata( $member_id, $res ) {
3965 global $usces;
3966
3967 if ( ! $this->is_activate_card() || false === $res ) {
3968 return;
3969 }
3970
3971 if ( 'delete' === filter_input( INPUT_POST, 'zeus_pcid' ) ) {
3972 $usces->del_member_meta( 'zeus_pcid', $member_id );
3973 $usces->del_member_meta( 'zeus_partofcard', $member_id );
3974 $usces->del_member_meta( 'zeus_limitofcard', $member_id );
3975 }
3976 }
3977
3978 /**
3979 * 支払方法説明
3980 * usces_filter_payment_detail
3981 *
3982 * @param string $str Payment method description.
3983 * @param array $entry Entry data.
3984 * @return string
3985 */
3986 public function payment_detail( $str, $entry ) {
3987 $acting_flg = $this->get_acting_flg( $entry['order']['payment_name'] );
3988
3989 switch ( $acting_flg ) {
3990 case 'acting_zeus_card':
3991 if ( ! isset( $entry['order']['cbrand'] ) || ( isset( $entry['order']['howpay'] ) && '1' == $entry['order']['howpay'] ) ) {
3992 $str = ' 一括払い';
3993 } else {
3994 $div_name = 'div_' . $entry['order']['cbrand'];
3995 switch ( $entry['order'][ $div_name ] ) {
3996 case '01':
3997 $str = ' 一括払い';
3998 break;
3999 case '02':
4000 $str = ' 分割(2回)';
4001 break;
4002 case '03':
4003 $str = ' 分割(3回)';
4004 break;
4005 case '05':
4006 $str = ' 分割(5回)';
4007 break;
4008 case '06':
4009 $str = ' 分割(6回)';
4010 break;
4011 case '10':
4012 $str = ' 分割(10回)';
4013 break;
4014 case '12':
4015 $str = ' 分割(12回)';
4016 break;
4017 case '15':
4018 $str = ' 分割(15回)';
4019 break;
4020 case '18':
4021 $str = ' 分割(18回)';
4022 break;
4023 case '20':
4024 $str = ' 分割(20回)';
4025 break;
4026 case '24':
4027 $str = ' 分割(24回)';
4028 break;
4029 case '99':
4030 $str = ' 分割(リボ払い)';
4031 break;
4032 case 'B1':
4033 $str = ' 分割(ボーナス一括払い)';
4034 break;
4035 }
4036 }
4037 break;
4038
4039 case 'acting_zeus_bank':
4040 $acting_opts = $this->get_acting_settings();
4041 if ( ! empty( $acting_opts['bank_expired_date'] ) ) {
4042 $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['bank_expired_date'] ) . __( ')', 'usces' );
4043 $str = apply_filters( 'usces_filter_zeus_payment_limit_bank', $payment_detail, $acting_opts['bank_expired_date'] );
4044 }
4045 break;
4046
4047 case 'acting_zeus_conv':
4048 if ( isset( $entry['order']['pay_cvs'] ) ) {
4049 $conv_name = usces_get_conv_name( $entry['order']['pay_cvs'] );
4050 $str = ( '' !== $conv_name ) ? __( '(', 'usces' ) . $conv_name . __( ')', 'usces' ) : '';
4051 }
4052 $acting_opts = $this->get_acting_settings();
4053 if ( ! empty( $acting_opts['conv_span'] ) ) {
4054 $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['conv_span'] ) . __( ')', 'usces' );
4055 $str .= apply_filters( 'usces_filter_zeus_payment_limit_conv', $payment_detail, $acting_opts['conv_span'] );
4056 }
4057 break;
4058 }
4059 return $str;
4060 }
4061
4062 /**
4063 * 携帯電話番号
4064 * usces_filter_custom_field_info
4065 *
4066 * @param string $html Custom field information.
4067 * @param array $entry Entry data.
4068 * @param string $custom_field Custom field.
4069 * @param string $position Position.
4070 * @return string
4071 */
4072 public function confirm_addition_bnpl( $html, $entry, $custom_field, $position ) {
4073 if ( 'order' === $custom_field ) {
4074 $acting_flg = $this->get_acting_flg( $entry['order']['payment_name'] );
4075 if ( 'acting_zeus_bnpl' === $acting_flg ) {
4076 $tel_mobile = ( isset( $_POST['tel_mobile'] ) ) ? filter_input( INPUT_POST, 'tel_mobile' ) : $entry['customer']['tel'];
4077 $html = '
4078 <tr>
4079 <th>携帯電話番号</th>
4080 <td>' . $tel_mobile . '</td>
4081 </tr>' . $html;
4082 }
4083 }
4084 return $html;
4085 }
4086
4087 /**
4088 * 支払方法 JavaScript 用決済名追加
4089 * usces_filter_payments_str
4090 *
4091 * @param string $payments_str Payments.
4092 * @param array $payment Selected payment.
4093 * @return string
4094 */
4095 public function payments_str( $payments_str, $payment ) {
4096 switch ( $payment['settlement'] ) {
4097 case 'acting_zeus_card':
4098 if ( $this->is_validity_acting( 'card' ) ) {
4099 $payments_str .= "'" . $payment['name'] . "': 'zeus', ";
4100 }
4101 break;
4102 case 'acting_zeus_bank':
4103 if ( $this->is_validity_acting( 'bank' ) ) {
4104 $payments_str .= "'" . $payment['name'] . "': 'zeus_bank', ";
4105 }
4106 break;
4107 case 'acting_zeus_conv':
4108 if ( $this->is_validity_acting( 'conv' ) ) {
4109 $payments_str .= "'" . $payment['name'] . "': 'zeus_conv', ";
4110 }
4111 break;
4112 case 'acting_zeus_bnpl':
4113 if ( $this->is_validity_acting( 'bnpl' ) ) {
4114 $payments_str .= "'" . $payment['name'] . "': 'zeus_bnpl', ";
4115 }
4116 break;
4117 }
4118 return $payments_str;
4119 }
4120
4121 /**
4122 * 支払方法 JavaScript 用決済追加
4123 * usces_filter_payments_arr
4124 *
4125 * @param array $payments_arr Payments.
4126 * @param array $payment Selected payment.
4127 * @return array
4128 */
4129 public function payments_arr( $payments_arr, $payment ) {
4130 switch ( $payment['settlement'] ) {
4131 case 'acting_zeus_card':
4132 if ( $this->is_validity_acting( 'card' ) ) {
4133 $payments_arr[] = 'zeus';
4134 }
4135 break;
4136 case 'acting_zeus_bank':
4137 if ( $this->is_validity_acting( 'bank' ) ) {
4138 $payments_arr[] = 'zeus_bank';
4139 }
4140 break;
4141 case 'acting_zeus_conv':
4142 if ( $this->is_validity_acting( 'conv' ) ) {
4143 $payments_arr[] = 'zeus_conv';
4144 }
4145 break;
4146 case 'acting_zeus_bnpl':
4147 if ( $this->is_validity_acting( 'bnpl' ) ) {
4148 $payments_arr[] = 'zeus_bnpl';
4149 }
4150 break;
4151 }
4152 return $payments_arr;
4153 }
4154
4155 /**
4156 * カード�
4157 報�
4158 �力チェック
4159 * usces_filter_delivery_check
4160 *
4161 * @param string $mes Validation check message.
4162 * @return string
4163 */
4164 public function delivery_check( $mes ) {
4165 if ( ! isset( $_POST['offer']['payment_name'] ) ) {
4166 return $mes;
4167 }
4168
4169 if ( ! empty( $mes ) ) {
4170 return $mes;
4171 }
4172
4173 $acting_flg = $this->get_acting_flg( $_POST['offer']['payment_name'] );
4174
4175 switch ( $acting_flg ) {
4176 case 'acting_zeus_card':
4177 if ( isset( $_POST['acting'] ) && 'zeus' !== filter_input( INPUT_POST, 'acting' ) ) {
4178 $mes .= 'カード決済データが不正です!';
4179 } elseif ( empty( $_POST['zeus_card_option'] ) || ( 'new' === filter_input( INPUT_POST, 'zeus_card_option' ) && empty( $_POST['zeus_token_value'] ) ) ) {
4180 $mes .= 'カード決済データが不正です!';
4181 } elseif ( ! empty( $_POST['zeus_token_value'] ) ) {
4182 if ( ! wel_check_credit_security() ) {
4183 $mes .= __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '<br />';
4184 }
4185 }
4186 break;
4187
4188 case 'acting_zeus_bank':
4189 if ( WCUtils::is_blank( $_POST['username_bank'] ) ) {
4190 $mes .= 'お振込名義を�
4191 �力してください。<br />';
4192 } elseif ( ! preg_match( '/^[ァ-ヶー]+$/u', filter_input( INPUT_POST, 'username_bank' ) ) ) {
4193 $mes .= 'お振込名義は�
4194 �角カタカナで�
4195 �力してください。<br />';
4196 }
4197 break;
4198
4199 case 'acting_zeus_conv':
4200 if ( WCUtils::is_blank( $_POST['username_conv'] ) ) {
4201 $mes .= 'お名前を�
4202 �力してください。<br />';
4203 } elseif ( ! preg_match( '/^[ァ-ヶー]+$/u', filter_input( INPUT_POST, 'username_conv' ) ) ) {
4204 $mes .= 'お名前は�
4205 �角カタカナで�
4206 �力してください。<br />';
4207 }
4208 break;
4209
4210 case 'acting_zeus_bnpl':
4211 if ( WCUtils::is_blank( $_POST['tel_mobile'] ) ) {
4212 $mes .= '携帯電話番号を�
4213 �力してください。<br />';
4214 } else {
4215 $tel_mobile = filter_input( INPUT_POST, 'tel_mobile' );
4216 if ( ! preg_match( '/^[0-9-]+$/', $tel_mobile ) ) {
4217 $mes .= '携帯電話番号は半角数値で�
4218 �力してください。<br />';
4219 } else {
4220 $cleannumber = preg_replace( '/[-\s]/', '', $tel_mobile );
4221 if ( '0' !== substr( $cleannumber, 0, 1 ) ) {
4222 $mes .= '携帯電話番号を�
4223 �力してください。<br />';
4224 } elseif ( strlen( $cleannumber ) < 8 || 15 < strlen( $cleannumber ) ) {
4225 $mes .= '携帯電話番号が不正です!<br />';
4226 }
4227 }
4228 }
4229 break;
4230 }
4231 return $mes;
4232 }
4233
4234 /**
4235 * 支払方法ページ用�
4236 �力フォーム
4237 * usces_filter_delivery_secure_form_loop
4238 *
4239 * @param string $nouse Empty.
4240 * @param array $payment Payment data.
4241 * @return string
4242 */
4243 public function delivery_secure_form_loop( $nouse, $payment ) {
4244 global $usces;
4245
4246 $form = '';
4247
4248 switch ( $payment['settlement'] ) {
4249 case 'acting_zeus_card':
4250 $acting_opts = $this->get_acting_settings();
4251 if ( ( ! isset( $acting_opts['activate'] ) || 'on' !== $acting_opts['activate'] ) ||
4252 ( ! isset( $acting_opts['card_activate'] ) || 'on' !== $acting_opts['card_activate'] ) ||
4253 'activate' !== $payment['use'] ) {
4254 return $form;
4255 }
4256
4257 $form = '<input type="hidden" name="acting" value="' . $this->paymod_id . '">';
4258 $form .= '<table class="customer_form" id="' . $this->paymod_id . '">';
4259 $form .= '<tr><th scope="row">クレジットカード�
4260 </th><td id="zeus_token_card_info_area"></td></tr>';
4261
4262 $howpay = ( isset( $_POST['howpay'] ) ) ? filter_input( INPUT_POST, 'howpay' ) : '1';
4263 $cbrand = ( isset( $_POST['cbrand'] ) ) ? filter_input( INPUT_POST, 'cbrand' ) : '';
4264 $div = ( isset( $_POST['div'] ) ) ? filter_input( INPUT_POST, 'div' ) : '';
4265
4266 $form_howpay = '';
4267 $member_page = ( isset( $_GET['usces_page'] ) && 'member_update_settlement' === filter_input( INPUT_GET, 'usces_page' ) ) ? true : false;
4268 if ( 'on' === $acting_opts['howpay'] && ! $member_page ) {
4269 $howpay_b1 = ( 'on' === $acting_opts['howpay_B1'] ) ? '</option><option value="B1"' . selected( $div, 'B1', false ) . '>' . __( 'Bonus lump-sum payment', 'usces' ) : '';
4270 $howpay_02 = ( 'on' === $acting_opts['howpay_02'] ) ? '</option><option value="02"' . selected( $div, '02', false ) . '>2' . __( '-time payment', 'usces' ) : '';
4271 $form_howpay .= '
4272 <tr>
4273 <th scope="row">' . __( 'payment method', 'usces' ) . '</th>
4274 <td>
4275 <input name="offer[howpay]" type="radio" value="1" id="howdiv1"' . checked( $howpay, '1', false ) . ' /><label for="howdiv1">' . __( 'Single payment', 'usces' ) . '</label>&nbsp;&nbsp;&nbsp;
4276 <input name="offer[howpay]" type="radio" value="0" id="howdiv2"' . checked( $howpay, '0', false ) . ' /><label for="howdiv2">' . __( 'Payment in installments', 'usces' ) . '</label>
4277 </td>
4278 </tr>
4279 <tr id="cbrand_zeus">
4280 <th scope="row">' . __( 'Card brand', 'usces' ) . '</th>
4281 <td>
4282 <select name="offer[cbrand]" id="cbrand">
4283 <option value=""' . selected( WCUtils::is_blank( $cbrand ), true, false ) . '>--------</option>
4284 <option value="1"' . selected( $cbrand, '1', false ) . '>JCB</option>
4285 <option value="1"' . selected( $cbrand, '1', false ) . '>VISA</option>
4286 <option value="1"' . selected( $cbrand, '1', false ) . '>MASTER</option>
4287 <option value="2"' . selected( $cbrand, '2', false ) . '>DINERS</option>
4288 <option value="3"' . selected( $cbrand, '3', false ) . '>AMEX</option>
4289 </select>
4290 </td>
4291 </tr>
4292 <tr id="div_zeus">
4293 <th scope="row">' . __( 'Number of payments', 'usces' ) . '</th>
4294 <td>
4295 <select name="offer[div_1]" id="brand1">
4296 <option value="01"' . selected( $div, '01', false ) . '>' . __( 'Single payment', 'usces' ) . $howpay_02 . '</option>
4297 <option value="03"' . selected( $div, '03', false ) . '>3' . __( '-time payment', 'usces' ) . '</option>
4298 <option value="05"' . selected( $div, '05', false ) . '>5' . __( '-time payment', 'usces' ) . '</option>
4299 <option value="06"' . selected( $div, '06', false ) . '>6' . __( '-time payment', 'usces' ) . '</option>
4300 <option value="10"' . selected( $div, '10', false ) . '>10' . __( '-time payment', 'usces' ) . '</option>
4301 <option value="12"' . selected( $div, '12', false ) . '>12' . __( '-time payment', 'usces' ) . '</option>
4302 <option value="15"' . selected( $div, '15', false ) . '>15' . __( '-time payment', 'usces' ) . '</option>
4303 <option value="18"' . selected( $div, '18', false ) . '>18' . __( '-time payment', 'usces' ) . '</option>
4304 <option value="20"' . selected( $div, '20', false ) . '>20' . __( '-time payment', 'usces' ) . '</option>
4305 <option value="24"' . selected( $div, '24', false ) . '>24' . __( '-time payment', 'usces' ) . '</option>
4306 <option value="99"' . selected( $div, '99', false ) . '>' . __( 'Libor Funding pay', 'usces' ) . $howpay_b1 . '</option>
4307 </select>
4308 <select name="offer[div_2]" id="brand2">
4309 <option value="01"' . selected( $div, '01', false ) . '>' . __( 'Single payment', 'usces' ) . '</option>
4310 <option value="99"' . selected( $div, '99', false ) . '>' . __( 'Libor Funding pay', 'usces' ) . $howpay_b1 . '</option>
4311 </select>
4312 <select name="offer[div_3]" id="brand3">
4313 <option value="01"' . selected( $div, '01', false ) . '>' . __( 'Single payment', 'usces' ) . '</option>
4314 <option value="03"' . selected( $div, '03', false ) . '>3' . __( '-time payment', 'usces' ) . '</option>
4315 <option value="05"' . selected( $div, '05', false ) . '>5' . __( '-time payment', 'usces' ) . '</option>
4316 <option value="06"' . selected( $div, '06', false ) . '>6' . __( '-time payment', 'usces' ) . '</option>
4317 <option value="10"' . selected( $div, '10', false ) . '>10' . __( '-time payment', 'usces' ) . '</option>
4318 <option value="12"' . selected( $div, '12', false ) . '>12' . __( '-time payment', 'usces' ) . '</option>
4319 <option value="15"' . selected( $div, '15', false ) . '>15' . __( '-time payment', 'usces' ) . '</option>
4320 <option value="18"' . selected( $div, '18', false ) . '>18' . __( '-time payment', 'usces' ) . '</option>
4321 <option value="20"' . selected( $div, '20', false ) . '>20' . __( '-time payment', 'usces' ) . '</option>
4322 <option value="24"' . selected( $div, '24', false ) . '>24' . __( '-time payment', 'usces' ) . '</option>
4323 <option value="99"' . selected( $div, '99', false ) . '>' . __( 'Libor Funding pay', 'usces' ) . $howpay_b1 . '</option>
4324 </select>
4325 </td>
4326 </tr>
4327 </table>';
4328 }
4329 $form .= apply_filters( 'usces_filter_delivery_secure_form_howpay', $form_howpay );
4330 break;
4331
4332 case 'acting_zeus_bank':
4333 $acting_opts = $this->get_acting_settings();
4334 if ( ( ! isset( $acting_opts['activate'] ) || 'on' !== $acting_opts['activate'] ) ||
4335 ( ! isset( $acting_opts['bank_activate'] ) || 'on' !== $acting_opts['bank_activate'] ) ||
4336 'activate' !== $payment['use'] ) {
4337 return $form;
4338 }
4339
4340 $entry = $usces->cart->get_entry();
4341 $username = ( isset( $_POST['username_bank'] ) ) ? filter_input( INPUT_POST, 'username_bank' ) : $entry['customer']['name3'] . $entry['customer']['name4'];
4342
4343 $form = '
4344 <table class="customer_form" id="' . $this->paymod_id . '_bank">
4345 <tr>
4346 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>お振込名義</th>
4347 <td colspan="2"><input name="username_bank" id="username_bank" type="text" size="30" value="' . esc_attr( $username ) . '" />' . __( '(full-width Kana)', 'usces' ) . '</td>
4348 </tr>
4349 </table>';
4350 break;
4351
4352 case 'acting_zeus_conv':
4353 $acting_opts = $this->get_acting_settings();
4354 if ( ( ! isset( $acting_opts['activate'] ) || 'on' !== $acting_opts['activate'] ) ||
4355 ( ! isset( $acting_opts['conv_activate'] ) || 'on' !== $acting_opts['conv_activate'] ) ||
4356 'activate' !== $payment['use'] ) {
4357 return $form;
4358 }
4359
4360 $pay_cvs = ( isset( $_POST['pay_cvs'] ) ) ? filter_input( INPUT_POST, 'pay_cvs' ) : '';
4361 $entry = $usces->cart->get_entry();
4362 $username = ( isset( $_POST['username_conv'] ) ) ? filter_input( INPUT_POST, 'username_conv' ) : $entry['customer']['name3'] . $entry['customer']['name4'];
4363
4364 $form = '
4365 <table class="customer_form" id="' . $this->paymod_id . '_conv">
4366 <tr>
4367 <th scope="row">' . __( 'Convenience store for payment', 'usces' ) . '</th>
4368 <td colspan="2">
4369 <select name="offer[pay_cvs]" id="pay_cvs_zeus">';
4370 foreach ( (array) $acting_opts['pay_cvs'] as $pay_cvs_code ) {
4371 if ( 'D040' === $pay_cvs_code ) {
4372 continue;
4373 }
4374 $form .= '
4375 <option value="' . $pay_cvs_code . '"' . selected( $pay_cvs_code, $pay_cvs, false ) . '>' . usces_get_conv_name( $pay_cvs_code ) . '</option>';
4376 }
4377 $form .= '
4378 </select>
4379 </td>
4380 </tr>
4381 <tr>
4382 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>' . __( 'Full name', 'usces' ) . '</th>
4383 <td colspan="2"><input name="username_conv" id="username_conv" type="text" size="30" value="' . esc_attr( $username ) . '" />' . __( '(full-width Kana)', 'usces' ) . '</td>
4384 </tr>
4385 </table>';
4386 break;
4387
4388 case 'acting_zeus_bnpl':
4389 $acting_opts = $this->get_acting_settings();
4390 if ( ( ! isset( $acting_opts['activate'] ) || 'on' !== $acting_opts['activate'] ) ||
4391 ( ! isset( $acting_opts['bnpl_activate'] ) || 'on' !== $acting_opts['bnpl_activate'] ) ||
4392 'activate' !== $payment['use'] ) {
4393 return $form;
4394 }
4395
4396 $entry = $usces->cart->get_entry();
4397 $tel_mobile = ( isset( $_POST['tel_mobile'] ) ) ? filter_input( INPUT_POST, 'tel_mobile' ) : $entry['customer']['tel'];
4398
4399 $form = '
4400 <table class="customer_form" id="' . $this->paymod_id . '_bnpl">
4401 <tr>
4402 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>携帯電話番号</th>
4403 <td colspan="2"><input name="tel_mobile" id="tel_mobile" type="text" size="30" value="' . esc_attr( $tel_mobile ) . '" />' . __( '(Single-byte numbers only)', 'usces' ) . '</td>
4404 </tr>
4405 </table>';
4406 break;
4407 }
4408
4409 return $form;
4410 }
4411
4412 /**
4413 * �
4414 容確認ページ [注文する] ボタン
4415 * usces_filter_confirm_inform
4416 *
4417 * @param string $form Purchase post form.
4418 * @param array $payments Payment data.
4419 * @param string $acting_flg Payment type.
4420 * @param string $rand Welcart transaction key.
4421 * @param string $purchase_disabled Disable purchase button.
4422 * @return string
4423 */
4424 public function confirm_inform( $form, $payments, $acting_flg, $rand, $purchase_disabled ) {
4425 global $usces;
4426
4427 if ( ! in_array( $acting_flg, $this->pay_method, true ) ) {
4428 return $form;
4429 }
4430
4431 $entry = $usces->cart->get_entry();
4432 if ( ! $entry['order']['total_full_price'] ) {
4433 return $form;
4434 }
4435
4436 switch ( $acting_flg ) {
4437 case 'acting_zeus_card':
4438 $acting_opts = $this->get_acting_settings();
4439 $usces->save_order_acting_data( $rand );
4440 usces_save_order_acting_data( $rand );
4441 $mem_id = '';
4442 if ( $usces->is_member_logged_in() ) {
4443 $member = $usces->get_member();
4444 $mem_id = $member['ID'];
4445 }
4446 $zeus_card_option = ( isset( $_POST['zeus_card_option'] ) ) ? filter_input( INPUT_POST, 'zeus_card_option' ) : '';
4447 $zeus_token_value = ( isset( $_POST['zeus_token_value'] ) ) ? filter_input( INPUT_POST, 'zeus_token_value' ) : '';
4448 $zeus_card_name = ( isset( $_POST['zeus_token_return_card_name'] ) ) ? filter_input( INPUT_POST, 'zeus_token_return_card_name' ) : '';
4449 $form = '';
4450 if ( $this->is_activate_card( 'api' ) && 1 === (int) $acting_opts['3dsecur'] ) {
4451 $form .= '<div id="3dscontainer"></div>';
4452 }
4453 $amount = apply_filters( 'zeus_secure_payreq_amount', usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ), $entry );
4454
4455 $form .= '<form name="purchase_form" id="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}">
4456 <input type="hidden" name="card_option" id="card_option" value="' . esc_attr( $zeus_card_option ) . '">
4457 <input type="hidden" name="token_key" id="token_key" value="' . esc_attr( $zeus_token_value ) . '">
4458 <input type="hidden" name="money" value="' . $amount . '">
4459 <input type="hidden" name="telno" value="' . esc_attr( str_replace( '-', '', $entry['customer']['tel'] ) ) . '">
4460 <input type="hidden" name="email" value="' . esc_attr( $entry['customer']['mailaddress1'] ) . '">
4461 <input type="hidden" name="card_name" id="card_name" value="' . esc_attr( $zeus_card_name ) . '">
4462 <input type="hidden" name="sendid" id="sendid" value="' . $mem_id . '">
4463 <input type="hidden" name="sendpoint" id="sendpoint" value="' . $rand . '">';
4464 if ( isset( $entry['order']['cbrand'] ) && isset( $entry['order']['howpay'] ) && WCUtils::is_zero( $entry['order']['howpay'] ) ) {
4465 $div_name = 'div_' . esc_attr( $entry['order']['cbrand'] );
4466 $form .= '<input type="hidden" name="howpay" value="' . esc_attr( $entry['order']['howpay'] ) . '">
4467 <input type="hidden" name="cbrand" value="' . esc_attr( $entry['order']['cbrand'] ) . '">
4468 <input type="hidden" name="div" value="' . esc_attr( $entry['order'][ $div_name ] ) . '">
4469 <input type="hidden" name="div_1" value="' . esc_attr( $entry['order']['div_1'] ) . '">
4470 <input type="hidden" name="div_2" value="' . esc_attr( $entry['order']['div_2'] ) . '">
4471 <input type="hidden" name="div_3" value="' . esc_attr( $entry['order']['div_3'] ) . '">';
4472 }
4473 $form .= '<div class="send">';
4474 if ( $this->is_activate_card( 'api' ) && 1 === (int) $acting_opts['3dsecur'] ) {
4475 $form .= '<div id="zeus-loading" style="display:none"><div id="welcart-loading-text">' . __( 'Processing...', 'usces' ) . '</div></div>';
4476 }
4477 $form .= apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4478 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4479 <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 . ' /></div>
4480 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4481 break;
4482
4483 case 'acting_zeus_conv':
4484 $member = $usces->get_member();
4485 $acting_opts = $this->get_acting_settings();
4486 $usces->save_order_acting_data( $rand );
4487 usces_save_order_acting_data( $rand );
4488 $pay_cvs = ( isset( $entry['order']['pay_cvs'] ) ) ? $entry['order']['pay_cvs'] : '';
4489 $username_conv = ( isset( $_POST['username_conv'] ) ) ? filter_input( INPUT_POST, 'username_conv' ) : '';
4490 $form = '<form id="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}">
4491 <input type="hidden" name="act" value="secure_order">
4492 <input type="hidden" name="money" value="' . usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ) . '">
4493 <input type="hidden" name="username" value="' . esc_attr( $username_conv ) . '">
4494 <input type="hidden" name="telno" value="' . esc_attr( str_replace( '-', '', $entry['customer']['tel'] ) ) . '">
4495 <input type="hidden" name="email" value="' . esc_attr( $entry['customer']['mailaddress1'] ) . '">
4496 <input type="hidden" name="pay_cvs" value="' . esc_attr( $pay_cvs ) . '">
4497 <input type="hidden" name="sendid" value="' . $member['ID'] . '">
4498 <input type="hidden" name="sendpoint" value="' . $rand . '">';
4499 $form .= '
4500 <div class="send">
4501 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4502 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4503 <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 . ' /></div>
4504 <input type="hidden" name="username_conv" value="' . esc_attr( $username_conv ) . '">
4505 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4506 break;
4507
4508 case 'acting_zeus_bank':
4509 $member = $usces->get_member();
4510 $acting_opts = $this->get_acting_settings();
4511 $usces->save_order_acting_data( $rand );
4512 usces_save_order_acting_data( $rand );
4513 $username_bank = ( isset( $_POST['username_bank'] ) ) ? filter_input( INPUT_POST, 'username_bank' ) : '';
4514 $form = '<form id="purchase_form" action="' . $acting_opts['bank_url'] . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}" accept-charset="Shift_JIS">
4515 <input type="hidden" name="clientip" value="' . esc_attr( $acting_opts['clientip_bank'] ) . '">
4516 <input type="hidden" name="act" value="order">
4517 <input type="hidden" name="money" value="' . usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ) . '">';
4518 if ( isset( $acting_opts['bank_ope'] ) && 'test' === $acting_opts['bank_ope'] ) {
4519 $form .= '<input type="hidden" name="username" value="' . esc_attr( trim( $username_bank ) . '_' . $acting_opts['testid_bank'] ) . '">';
4520 $form .= '<input type="hidden" name="telno" value="99999999999">';
4521 } else {
4522 $form .= '<input type="hidden" name="username" value="' . esc_attr( trim( $username_bank ) ) . '">';
4523 $form .= '<input type="hidden" name="telno" value="' . esc_attr( str_replace( '-', '', $entry['customer']['tel'] ) ) . '">';
4524 }
4525 if ( ! empty( $acting_opts['bank_expired_date'] ) ) {
4526 $form .= '<input type="hidden" name="expired_date" value="' . esc_attr( $acting_opts['bank_expired_date'] ) . '">';
4527 $form .= '<input type="hidden" name="expired_date_of_user" value="' . esc_attr( $acting_opts['bank_expired_date'] ) . '">';
4528 }
4529 $form .= '<input type="hidden" name="email" value="' . esc_attr( $entry['customer']['mailaddress1'] ) . '">
4530 <input type="hidden" name="sendid" value="' . $member['ID'] . '">
4531 <input type="hidden" name="sendpoint" value="' . $rand . '">
4532 <input type="hidden" name="siteurl" value="' . esc_url( get_option( 'home' ) ) . '/?backfrom_zeus_bank=1">
4533 <input type="hidden" name="sitestr" value="「' . esc_attr( get_option( 'blogname' ) ) . '」トップページへ">';
4534 $form .= '<input type="hidden" name="dummy" value="&#65533;" />';
4535 $form .= '<div class="send"><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', ' onClick="document.charset=\'Shift_JIS\';"' ) . $purchase_disabled . ' /></div>';
4536 $form .= '</form>';
4537 $form .= '<form action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}">
4538 <div class="send"><input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' /></div>
4539 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4540 break;
4541
4542 case 'acting_zeus_bnpl':
4543 $member = $usces->get_member();
4544 $acting_opts = $this->get_acting_settings();
4545 $usces->save_order_acting_data( $rand );
4546 usces_save_order_acting_data( $rand );
4547 $tel_mobile = ( isset( $_POST['tel_mobile'] ) ) ? filter_input( INPUT_POST, 'tel_mobile' ) : '';
4548 $form = '<form id="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}">
4549 <input type="hidden" name="money" value="' . usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ) . '">
4550 <input type="hidden" name="tel_mobile" value="' . esc_attr( $tel_mobile ) . '">
4551 <input type="hidden" name="sendpoint" value="' . $rand . '">';
4552 $form .= '
4553 <div class="send">
4554 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4555 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4556 <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 . ' /></div>
4557 <input type="hidden" name="tel_mobile" value="' . esc_attr( $tel_mobile ) . '">
4558 <input type="hidden" id="fraudbuster" name="fraudbuster" />
4559 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4560 break;
4561 }
4562 return $form;
4563 }
4564
4565 /**
4566 * �
4567 容確認ページ ポイントフォーム
4568 * usces_action_confirm_page_point_inform
4569 */
4570 public function e_point_inform() {
4571 $form = $this->point_inform( '' );
4572 wel_esc_script_e( $form );
4573 }
4574
4575 /**
4576 * �
4577 容確認ページ ポイントフォーム
4578 * usces_filter_confirm_point_inform
4579 *
4580 * @param string $form Input point form.
4581 * @return string
4582 */
4583 public function point_inform( $form ) {
4584 global $usces;
4585
4586 $entry = $usces->cart->get_entry();
4587 $acting_flg = $this->get_acting_flg( $entry['order']['payment_name'] );
4588
4589 switch ( $acting_flg ) {
4590 case 'acting_zeus_card':
4591 $acting_opts = $this->get_acting_settings();
4592 if ( isset( $_POST['zeus_card_option'] ) ) {
4593 $form .= '<input type="hidden" name="zeus_card_option" value="' . esc_attr( filter_input( INPUT_POST, 'zeus_card_option' ) ) . '">';
4594 }
4595 if ( isset( $_POST['zeus_card_option'] ) && 'new' === filter_input( INPUT_POST, 'zeus_card_option' ) ) {
4596 $form .= '<input type="hidden" name="zeus_token_value" value="' . esc_attr( filter_input( INPUT_POST, 'zeus_token_value' ) ) . '">';
4597 $form .= '<input type="hidden" name="zeus_token_return_card_name" value="' . esc_attr( filter_input( INPUT_POST, 'zeus_token_return_card_name' ) ) . '">';
4598 }
4599 break;
4600
4601 case 'acting_zeus_bank':
4602 if ( isset( $_POST['username_bank'] ) ) {
4603 $form .= '<input type="hidden" name="username_bank" value="' . esc_attr( filter_input( INPUT_POST, 'username_bank' ) ) . '">';
4604 }
4605 break;
4606
4607 case 'acting_zeus_conv':
4608 if ( isset( $entry['order']['pay_cvs'] ) ) {
4609 $form .= '<input type="hidden" name="offer[pay_cvs]" value="' . esc_attr( $entry['order']['pay_cvs'] ) . '">';
4610 }
4611 if ( isset( $_POST['username_conv'] ) ) {
4612 $form .= '<input type="hidden" name="username_conv" value="' . esc_attr( filter_input( INPUT_POST, 'username_conv' ) ) . '">';
4613 }
4614 break;
4615
4616 case 'acting_zeus_bnpl':
4617 if ( isset( $_POST['tel_mobile'] ) ) {
4618 $form .= '<input type="hidden" name="tel_mobile" value="' . esc_attr( filter_input( INPUT_POST, 'tel_mobile' ) ) . '">';
4619 }
4620 break;
4621 }
4622 return $form;
4623 }
4624
4625 /**
4626 * Scripts.
4627 * wp_enqueue_scripts
4628 */
4629 public function enqueue_scripts() {
4630 global $usces;
4631
4632 /* �
4633 容確認ページ */
4634 if ( ! is_admin() && 'confirm' === $usces->page && $this->is_validity_acting( 'bnpl' ) ) :
4635 $entry = $usces->cart->get_entry();
4636 $acting_flg = $this->get_acting_flg( $entry['order']['payment_name'] );
4637 if ( 'acting_zeus_bnpl' === $acting_flg ) :
4638 ?>
4639 <script type="text/javascript" src="//fraud-buster.appspot.com/js/fraudbuster.js" ></script>
4640 <?php
4641 endif;
4642 endif;
4643 }
4644
4645 /**
4646 * 支払方法
4647 * usces_fiter_the_payment_method
4648 *
4649 * @param array $payments Payments.
4650 * @return array
4651 */
4652 public function payment_method( $payments ) {
4653 global $usces;
4654
4655 $bnpl_exclusion = false;
4656 $cart = $usces->cart->get_cart();
4657 foreach ( (array) $cart as $cart_row ) {
4658 if ( 'shipped' !== $usces->getItemDivision( $cart_row['post_id'] ) ) {
4659 $bnpl_exclusion = true;
4660 break;
4661 }
4662 }
4663 if ( ! $bnpl_exclusion ) {
4664 if ( usces_have_regular_order() ) {
4665 $bnpl_exclusion = true;
4666 } elseif ( usces_have_continue_charge() ) {
4667 $bnpl_exclusion = true;
4668 }
4669 }
4670
4671 if ( $bnpl_exclusion ) {
4672 foreach ( $payments as $key => $payment ) {
4673 if ( 'acting_zeus_bnpl' === $payment['settlement'] ) {
4674 unset( $payments[ $key ] );
4675 }
4676 }
4677 }
4678
4679 return $payments;
4680 }
4681
4682 /**
4683 * 手数料ラベル
4684 * usces_filter_cod_label
4685 *
4686 * @param string $label Fee label.
4687 * @return string
4688 */
4689 public function set_fee_label( $label ) {
4690 global $usces;
4691
4692 if ( is_admin() ) {
4693 $order_id = ( isset( $_REQUEST['order_id'] ) ) ? wp_unslash( $_REQUEST['order_id'] ) : '';
4694 if ( ! empty( $order_id ) ) {
4695 $payment_name = $this->get_order_payment_name( $order_id );
4696 $payment = usces_get_payments_by_name( $payment_name );
4697 if ( 'acting_zeus_bnpl' === $payment['settlement'] ) {
4698 $label = $payment['name'] . __( 'Fee', 'usces' );
4699 }
4700 }
4701 } else {
4702 $entry = $usces->cart->get_entry();
4703 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
4704 if ( 'acting_zeus_bnpl' === $payment['settlement'] ) {
4705 $label = $payment['name'] . __( 'Fee', 'usces' );
4706 }
4707 }
4708 return $label;
4709 }
4710
4711 /**
4712 * 手数料ラベル
4713 * usces_filter_member_history_cod_label
4714 *
4715 * @param string $label Fee label.
4716 * @param int $order_id Order number.
4717 * @return string
4718 */
4719 public function set_member_history_fee_label( $label, $order_id ) {
4720 $payment_name = $this->get_order_payment_name( $order_id );
4721 $payment = usces_get_payments_by_name( $payment_name );
4722 if ( 'acting_zeus_bnpl' === $payment['settlement'] ) {
4723 $label = $payment['name'] . __( 'Fee', 'usces' );
4724 }
4725 return $label;
4726 }
4727
4728 /**
4729 * 決済手数料
4730 * usces_filter_set_cart_fees_cod
4731 *
4732 * @param float $cod_fee COD fee.
4733 * @param array $usces_entries Entry data.
4734 * @param float $total_items_price Total amount of items.
4735 * @param int $use_point Use point.
4736 * @param float $discount Discount.
4737 * @param float $shipping_charge Shipping charge.
4738 * @param float $amount_by_cod COD.
4739 * @return float
4740 */
4741 public function add_fee( $cod_fee, $usces_entries, $total_items_price, $use_point, $discount, $shipping_charge, $amount_by_cod ) {
4742 global $usces;
4743
4744 $payment = usces_get_payments_by_name( $usces_entries['order']['payment_name'] );
4745 if ( 'acting_zeus_bnpl' !== $payment['settlement'] ) {
4746 return $cod_fee;
4747 }
4748
4749 $acting_opts = $this->get_acting_settings();
4750 $acting = explode( '_', $payment['settlement'] );
4751 $fee = 0;
4752 if ( ! empty( $acting_opts[ $acting[2] . '_fee_type' ] ) ) {
4753 if ( 'fix' === $acting_opts[ $acting[2] . '_fee_type' ] ) {
4754 $fee = (int) $acting_opts[ $acting[2] . '_fee' ];
4755 } else {
4756 $materials = array(
4757 'total_items_price' => $total_items_price,
4758 'discount' => $discount,
4759 'shipping_charge' => $shipping_charge,
4760 'cod_fee' => $cod_fee,
4761 'use_point' => $use_point,
4762 );
4763 $amount_by_fee = $total_items_price - $use_point + $discount;
4764 if ( 'all' === usces_is_fee_subject() ) {
4765 $amount_by_fee += $shipping_charge;
4766 }
4767 $price = $amount_by_fee + $usces->getTax( $amount_by_fee, $materials );
4768 if ( $price <= (int) $acting_opts[ $acting[2] . '_fee_first_amount' ] ) {
4769 $fee = $acting_opts[ $acting[2] . '_fee_first_fee' ];
4770 } elseif ( isset( $acting_opts[ $acting[2] . '_fee_amounts' ] ) && ! empty( $acting_opts[ $acting[2] . '_fee_amounts' ] ) ) {
4771 $last = count( $acting_opts[ $acting[2] . '_fee_amounts' ] ) - 1;
4772 if ( $price > $acting_opts[ $acting[2] . '_fee_amounts' ][ $last ] ) {
4773 $fee = $acting_opts[ $acting[2] . '_fee_end_fee' ];
4774 } else {
4775 foreach ( $acting_opts[ $acting[2] . '_fee_amounts' ] as $key => $value ) {
4776 if ( $price <= $value ) {
4777 $fee = $acting_opts[ $acting[2] . '_fee_fees' ][ $key ];
4778 break;
4779 }
4780 }
4781 }
4782 } else {
4783 $fee = $acting_opts[ $acting[2] . '_fee_end_fee' ];
4784 }
4785 }
4786 }
4787 return $cod_fee + $fee;
4788 }
4789
4790 /**
4791 * 決済手数料チェック
4792 * usces_filter_delivery_check usces_filter_point_check_last
4793 *
4794 * @param string $mes Message.
4795 * @return string
4796 */
4797 public function check_fee_limit( $mes ) {
4798 global $usces;
4799
4800 $member = $usces->get_member();
4801 $usces->set_cart_fees( $member, array() );
4802 $entry = $usces->cart->get_entry();
4803 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
4804 if ( 'acting_zeus_bnpl' !== $payment['settlement'] ) {
4805 return $mes;
4806 }
4807
4808 if ( 2 === (int) $entry['delivery']['delivery_flag'] ) {
4809 $mes .= sprintf( __( "If you specify multiple shipping address, you cannot use '%s' payment method.", 'usces' ), $entry['order']['payment_name'] );
4810 return $mes;
4811 }
4812
4813 $acting_opts = $this->get_acting_settings();
4814 $fee_limit_amount = 0;
4815 if ( ! empty( $acting_opts['bnpl_fee_limit_amount'] ) ) {
4816 $fee_limit_amount = (int) $acting_opts['bnpl_fee_limit_amount'];
4817 }
4818
4819 if ( 0 < $fee_limit_amount && $entry['order']['total_full_price'] > $fee_limit_amount ) {
4820 $mes .= sprintf( __( 'It exceeds the maximum amount of "%1$s" (total amount %2$s).', 'usces' ), $entry['order']['payment_name'], usces_crform( $fee_limit_amount, true, false, 'return', true ) );
4821 }
4822
4823 return $mes;
4824 }
4825
4826 /**
4827 * セッション復帰処理
4828 * usces_pre_purchase
4829 */
4830 public function pre_purchase() {
4831 global $usces;
4832
4833 $cart = $usces->cart->get_cart();
4834 if ( empty( $cart ) ) {
4835 $tracking_id = filter_input( INPUT_GET, 'sendpoint' );
4836 if ( ! empty( $tracking_id ) ) {
4837 usces_restore_order_acting_data( $tracking_id );
4838 }
4839 }
4840 }
4841
4842 /**
4843 * 決済処理
4844 * usces_action_acting_processing
4845 *
4846 * @param string $acting_flg Payment type.
4847 * @param array $post_query Post data.
4848 */
4849 public function acting_processing( $acting_flg, $post_query ) {
4850 global $usces;
4851
4852 if ( ! in_array( $acting_flg, $this->pay_method, true ) ) {
4853 return;
4854 }
4855
4856 $cart = $usces->cart->get_cart();
4857
4858 if ( empty( $cart ) ) {
4859 if ( isset( $_REQUEST['sendpoint'] ) ) {
4860 usces_restore_order_acting_data( wp_unslash( $_REQUEST['sendpoint'] ) );
4861 $cart = $usces->cart->get_cart();
4862 if ( empty( $cart ) ) {
4863 wp_redirect( USCES_CART_URL );
4864 }
4865 } else {
4866 wp_redirect( USCES_CART_URL );
4867 }
4868 } else {
4869 if ( ! wp_verify_nonce( $_REQUEST['_nonce'], $acting_flg ) ) {
4870 wp_redirect( USCES_CART_URL );
4871 }
4872 }
4873
4874 $usces->error_message = $usces->zaiko_check();
4875 if ( '' !== $usces->error_message || 0 === $usces->cart->num_row() ) {
4876 wp_redirect( USCES_CART_URL );
4877 exit();
4878 }
4879
4880 $acting_opts = $this->get_acting_settings();
4881 parse_str( $post_query, $post_data );
4882
4883 /* Secure API */
4884 if ( 'acting_zeus_card' === $acting_flg && 2 === (int) $acting_opts['connection'] ) {
4885
4886 /* 3D Secure */
4887 if ( 1 === (int) $acting_opts['3dsecur'] && ! isset( $post_data['outside'] ) ) {
4888 /* Auth Reqest */
4889 $this->zeus_3dsecure_auth();
4890 } else {
4891 $res = $this->zeus_secure_payreq();
4892 return $res;
4893 }
4894
4895 /* Secure Link */
4896 } elseif ( 'acting_zeus_card' === $acting_flg && 1 === (int) $acting_opts['connection'] ) {
4897
4898 $sendid = ( 'on' === $acting_opts['quickcharge'] && $usces->is_member_logged_in() && isset( $post_data['sendid'] ) ) ? $post_data['sendid'] : '';
4899 $sendpoint = ( isset( $post_data['sendpoint'] ) ) ? $post_data['sendpoint'] : '';
4900
4901 $params = array();
4902 $params['send'] = 'mall';
4903 $params['clientip'] = $acting_opts['clientip'];
4904 if ( 'on' === $acting_opts['quickcharge'] && isset( $post_data['card_option'] ) && 'prev' === $post_data['card_option'] && ! empty( $sendid ) ) {
4905 $params['cardnumber'] = '8888888888888882';
4906 $params['expyy'] = '00';
4907 $params['expmm'] = '00';
4908 } elseif ( isset( $post_data['token_key'] ) ) {
4909 $params['token_key'] = $post_data['token_key'];
4910 }
4911 $params['money'] = $post_data['money'];
4912 $params['telno'] = str_replace( '-', '', $post_data['telno'] );
4913 $params['email'] = $post_data['email'];
4914 $params['sendid'] = $sendid;
4915 $params['sendpoint'] = $sendpoint;
4916 $params['printord'] = 'yes';
4917 $params['return_value'] = 'yes';
4918 if ( 'on' === $acting_opts['howpay'] && isset( $post_data['howpay'] ) && WCUtils::is_zero( $post_data['howpay'] ) ) {
4919 $params['div'] = $post_data['div'];
4920 }
4921
4922 $page = $this->secure_link_batch( $acting_opts['card_url'], $params );
4923 if ( false !== strpos( $page, 'Success_order' ) ) {
4924 usces_ordered_acting_data( $sendpoint, 'propriety' );
4925 $_nonce = ( isset( $post_data['_nonce'] ) ) ? $post_data['_nonce'] : wp_create_nonce( 'acting_zeus_card' );
4926 wp_redirect(
4927 add_query_arg(
4928 array(
4929 'acting' => 'zeus_card',
4930 'acting_return' => 1,
4931 'result' => 1,
4932 '_nonce' => $_nonce,
4933 ),
4934 USCES_CART_URL
4935 )
4936 );
4937 } else {
4938 $err_code = $this->get_err_code( $page );
4939 $data = explode( "\r\n", $page );
4940 $log = array(
4941 'acting' => 'zeus_card',
4942 'key' => $sendpoint,
4943 'result' => $err_code,
4944 'data' => $data,
4945 );
4946 usces_save_order_acting_error( $log );
4947 wp_redirect(
4948 add_query_arg(
4949 array(
4950 'acting' => 'zeus_card',
4951 'acting_return' => 0,
4952 'err_code' => substr( $err_code, -3 ),
4953 ),
4954 USCES_CART_URL
4955 )
4956 );
4957 }
4958 exit();
4959
4960 } elseif ( 'acting_zeus_conv' === $acting_flg ) {
4961
4962 $interface = $this->get_interface( $acting_opts['conv_url'] );
4963
4964 $params = array();
4965 $params['clientip'] = $acting_opts['clientip_conv'];
4966 $params['act'] = $post_data['act'];
4967 $params['money'] = $post_data['money'];
4968 $params['username'] = mb_convert_encoding( $post_data['username'], 'SJIS', 'UTF-8' );
4969 $params['telno'] = str_replace( '-', '', $post_data['telno'] );
4970 $params['email'] = $post_data['email'];
4971 $params['pay_cvs'] = $post_data['pay_cvs'];
4972 $params['sendid'] = $post_data['sendid'];
4973 $params['sendpoint'] = $post_data['sendpoint'];
4974 if ( isset( $acting_opts['conv_ope'] ) && 'test' === $acting_opts['conv_ope'] ) {
4975 $params['testid'] = $acting_opts['testid_conv'];
4976 $params['test_type'] = $acting_opts['test_type_conv'];
4977 }
4978 if ( ! empty( $acting_opts['conv_span'] ) ) {
4979 $params['span'] = $acting_opts['conv_span'];
4980 }
4981 $vars = http_build_query( $params );
4982
4983 $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
4984 $header .= 'Host: ' . $interface['host'] . "\r\n";
4985 $header .= "User-Agent: PHP Script\r\n";
4986 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
4987 $header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
4988 $header .= "Connection: close\r\n\r\n";
4989 $header .= $vars;
4990
4991 $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
4992 if ( ! $fp ) {
4993 $log = array(
4994 'acting' => 'zeus_conv',
4995 'key' => $post_data['sendpoint'],
4996 'result' => 'SSL/TLS ERROR ( ' . $errno . ' )',
4997 'data' => array( $errstr ),
4998 );
4999 usces_save_order_acting_error( $log );
5000 wp_redirect(
5001 add_query_arg(
5002 array(
5003 'acting' => 'zeus_conv',
5004 'acting_return' => '0',
5005 ),
5006 USCES_CART_URL
5007 )
5008 );
5009 exit();
5010 }
5011
5012 if ( $fp ) {
5013 $page = '';
5014 $qstr = '';
5015 fwrite( $fp, $header );
5016 while ( ! feof( $fp ) ) {
5017 $scr = fgets( $fp, 1024 );
5018 $page .= $scr;
5019 if ( false !== strpos( $scr, 'order_no' ) ) {
5020 $qstr .= trim( $scr ) . '&';
5021 }
5022 if ( false !== strpos( $scr, 'pay_no1' ) ) {
5023 $qstr .= trim( $scr ) . '&';
5024 }
5025 if ( false !== strpos( $scr, 'pay_no2' ) ) {
5026 $qstr .= trim( $scr ) . '&';
5027 }
5028 if ( false !== strpos( $scr, 'pay_limit' ) ) {
5029 $qstr .= trim( $scr ) . '&';
5030 }
5031 if ( false !== strpos( $scr, 'pay_url' ) ) {
5032 $qstr .= trim( $scr ) . '&';
5033 }
5034 if ( false !== strpos( $scr, 'error_code' ) ) {
5035 $qstr .= trim( $scr ) . '&';
5036 }
5037 if ( false !== strpos( $scr, 'sendpoint' ) ) {
5038 $qstr .= trim( $scr ) . '&';
5039 }
5040 }
5041 $qstr .= 'pay_cvs=' . $post_data['pay_cvs'] . '&wctid=' . $post_data['sendpoint'];
5042 fclose( $fp );
5043
5044 if ( false !== strpos( $page, 'Success_order' ) ) {
5045 $result_data = array(
5046 'acting' => 'zeus_conv',
5047 'acting_return' => '1',
5048 );
5049 parse_str( $qstr, $data );
5050 $result_data = array_merge( $result_data, $data );
5051 wp_redirect( add_query_arg( $result_data, USCES_CART_URL ) );
5052 exit();
5053
5054 } else {
5055 parse_str( $qstr, $data );
5056 $log = array(
5057 'acting' => 'zeus_conv',
5058 'key' => $post_data['sendpoint'],
5059 'result' => 'CERTIFICATION ERROR',
5060 'data' => $data,
5061 );
5062 usces_save_order_acting_error( $log );
5063 wp_redirect(
5064 add_query_arg(
5065 array(
5066 'acting' => 'zeus_conv',
5067 'acting_return' => '0',
5068 ),
5069 USCES_CART_URL
5070 )
5071 );
5072 exit();
5073 }
5074 }
5075 exit();
5076
5077 } elseif ( 'acting_zeus_bnpl' === $acting_flg ) {
5078
5079 $entry = $usces->cart->get_entry();
5080 $sendpoint = ( isset( $post_data['sendpoint'] ) ) ? $post_data['sendpoint'] : '';
5081
5082 $httpheader = $this->get_header_information();
5083 $deviceinfo = ( ! empty( $post_data['fraudbuster'] ) ) ? $post_data['fraudbuster'] : '';
5084
5085 $data = array();
5086 $data['linkInfo'] = array(
5087 'shopCode' => $acting_opts['clientip_bnpl'],
5088 'linkId' => $acting_opts['bnpl_linkid'],
5089 'linkPassword' => $acting_opts['bnpl_linkpassword'],
5090 );
5091 $data['browserInfo'] = array(
5092 'httpHeader' => $httpheader,
5093 'deviceInfo' => $fraudbuster,
5094 );
5095 $data['customer'] = array(
5096 'shopOrderId' => $sendpoint,
5097 'shopOrderDate' => wp_date( 'Y/m/d' ),
5098 'name' => trim( $entry['customer']['name1'] ) . trim( $entry['customer']['name2'] ),
5099 'kanaName' => '',
5100 'zip' => trim( $entry['customer']['zipcode'] ),
5101 'address' => trim( $entry['customer']['pref'] ) . trim( $entry['customer']['address1'] ) . trim( $entry['customer']['address2'] ) . trim( $entry['customer']['address3'] ),
5102 'companyName' => ( ! empty( $entry['custom_customer']['company'] ) ) ? trim( $entry['custom_customer']['company'] ) : '',
5103 'sectionName' => '',
5104 'tel' => $post_data['tel_mobile'],
5105 'email' => trim( $entry['customer']['mailaddress1'] ),
5106 'billedAmount' => $post_data['money'],
5107 'expand1' => '',
5108 'service' => '2',
5109 );
5110 if ( defined( 'WCEX_MSA' ) && isset( $entry['delivery']['delivery_flag'] ) && 2 === (int) $entry['delivery']['delivery_flag'] ) {
5111 $msacart = ( isset( $_SESSION['msa_cart'] ) ) ? current( $_SESSION['msa_cart'] ) : array();
5112 if ( isset( $msacart['delivery']['destination_id'] ) ) {
5113 $member = $usces->get_member();
5114 $msadelivery = msa_get_destination( $member['ID'], $msacart['delivery']['destination_id'] );
5115 $data['ship'] = array(
5116 'shipName' => trim( $msadelivery['msa_name'] ) . trim( $msadelivery['msa_name2'] ),
5117 'shipKananame' => '',
5118 'shipZip' => trim( mb_convert_kana( $msadelivery['msa_zip'], 'a', 'UTF-8' ) ),
5119 'shipAddress' => trim( $msadelivery['msa_pref'] ) . trim( $msadelivery['msa_address1'] ) . trim( $msadelivery['msa_address2'] ) . trim( $msadelivery['msa_address3'] ),
5120 'shipCompanyName' => '',
5121 'shipSectionName' => '',
5122 'shipTel' => trim( $msadelivery['msa_tel'] ),
5123 );
5124 } else {
5125 $data['ship'] = array(
5126 'shipName' => '',
5127 'shipKananame' => '',
5128 'shipZip' => '',
5129 'shipAddress' => '',
5130 'shipCompanyName' => '',
5131 'shipSectionName' => '',
5132 'shipTel' => '',
5133 );
5134 }
5135 } else {
5136 $data['ship'] = array(
5137 'shipName' => trim( $entry['delivery']['name1'] ) . trim( $entry['delivery']['name2'] ),
5138 'shipKananame' => '',
5139 'shipZip' => trim( $entry['delivery']['zipcode'] ),
5140 'shipAddress' => trim( $entry['delivery']['pref'] ) . trim( $entry['delivery']['address1'] ) . trim( $entry['delivery']['address2'] ) . trim( $entry['delivery']['address3'] ),
5141 'shipCompanyName' => ( ! empty( $entry['custom_delivery']['company'] ) ) ? trim( $entry['custom_delivery']['company'] ) : '',
5142 'shipSectionName' => '',
5143 'shipTel' => trim( $entry['delivery']['tel'] ),
5144 );
5145 }
5146 $details = array();
5147 $cart_count = count( $cart );
5148 for ( $i = 0; $i < $cart_count; $i++ ) {
5149 $cart_row = $cart[ $i ];
5150 $details['detail'] = array(
5151 'goods' => $usces->getItemName( $cart_row['post_id'] ),
5152 'goodsPrice' => usces_crform( $cart_row['price'], false, false, 'return', false ),
5153 'goodsAmount' => $cart_row['quantity'],
5154 'expand2' => $i + 1,
5155 'expand3' => '',
5156 'expand4' => '',
5157 );
5158 }
5159 $data['details'] = $details;
5160
5161 $request = '<?xml version="1.0" encoding="UTF-8"?>';
5162 $request .= '<request>';
5163 $request .= $this->assoc2xml( $data );
5164 $request .= '</request>';
5165
5166 $xml = $this->get_xml_bnpl( $acting_opts['bnpl_transaction_url'], $request );
5167 if ( empty( $xml ) ) {
5168 $log = array(
5169 'acting' => 'zeus_bnpl',
5170 'key' => $sendpoint,
5171 'result' => 'Request Error',
5172 'data' => $request,
5173 );
5174 usces_save_order_acting_error( $log );
5175 wp_redirect(
5176 add_query_arg(
5177 array(
5178 'acting' => 'zeus_bnpl',
5179 'acting_return' => '0',
5180 'status' => 'error',
5181 ),
5182 USCES_CART_URL
5183 )
5184 );
5185 exit();
5186 }
5187
5188 $response = $this->xml2assoc( $xml );
5189 if ( ( isset( $response['response']['result'] ) && 'OK' === $response['response']['result'] ) &&
5190 ( isset( $response['response']['transactionInfo']['autoAuthoriresult'] ) && 'OK' === $response['response']['transactionInfo']['autoAuthoriresult'] ) ) {
5191 $result_data = array(
5192 'acting' => 'zeus_bnpl',
5193 'money' => $post_data['money'],
5194 'response' => $response['response'],
5195 );
5196 $res = $usces->order_processing( $result_data );
5197 if ( 'ordercompletion' === $res ) {
5198 $_nonce = ( isset( $post_data['_nonce'] ) ) ? $post_data['_nonce'] : wp_create_nonce( 'acting_zeus_bnpl' );
5199 wp_redirect(
5200 add_query_arg(
5201 array(
5202 'acting' => 'zeus_bnpl',
5203 'acting_return' => 1,
5204 'result' => 1,
5205 '_nonce' => $_nonce,
5206 ),
5207 USCES_CART_URL
5208 )
5209 );
5210 } else {
5211 $log = array(
5212 'acting' => 'zeus_bnpl',
5213 'key' => $sendpoint,
5214 'result' => 'ORDER DATA REGISTERED ERROR',
5215 'data' => $result_data,
5216 );
5217 usces_save_order_acting_error( $log );
5218 wp_redirect(
5219 add_query_arg(
5220 array(
5221 'acting' => 'zeus_bnpl',
5222 'acting_return' => 0,
5223 'result' => 0,
5224 ),
5225 USCES_CART_URL
5226 )
5227 );
5228 }
5229 exit();
5230 } else {
5231 if ( ( isset( $response['response']['result'] ) && 'OK' === $response['response']['result'] ) &&
5232 ( isset( $response['response']['transactionInfo']['autoAuthoriresult'] ) && 'OK' !== $response['response']['transactionInfo']['autoAuthoriresult'] ) ) {
5233 $log = array(
5234 'acting' => 'zeus_bnpl',
5235 'key' => $sendpoint,
5236 'result' => $response['response']['transactionInfo']['autoAuthoriresult'] . ':自動審査結果NG',
5237 'data' => $response,
5238 );
5239 usces_save_order_acting_error( $log );
5240 wp_redirect(
5241 add_query_arg(
5242 array(
5243 'acting' => 'zeus_bnpl',
5244 'acting_return' => '0',
5245 'status' => $response['response']['transactionInfo']['autoAuthoriresult'],
5246 ),
5247 USCES_CART_URL
5248 )
5249 );
5250 } else {
5251 $log = array(
5252 'acting' => 'zeus_bnpl',
5253 'key' => $sendpoint,
5254 'result' => $response['response']['result'] . ':' . $response['errors']['error']['errorCode'],
5255 'data' => $response,
5256 );
5257 usces_save_order_acting_error( $log );
5258 wp_redirect(
5259 add_query_arg(
5260 array(
5261 'acting' => 'zeus_bnpl',
5262 'acting_return' => '0',
5263 'status' => $response['response']['result'],
5264 'code' => $response['errors']['error']['errorCode'],
5265 ),
5266 USCES_CART_URL
5267 )
5268 );
5269 }
5270 exit();
5271 }
5272 }
5273 }
5274
5275 /**
5276 * 結果通知前処理
5277 * usces_pre_acting_return
5278 */
5279 public function pre_acting_return() {
5280 global $usces;
5281
5282 $tracking_id = filter_input( INPUT_GET, 'wctid' );
5283 if ( empty( $tracking_id ) ) {
5284 $tracking_id = filter_input( INPUT_GET, 'sendpoint' );
5285 }
5286 if ( ! empty( $tracking_id ) ) {
5287 $cart = $usces->cart->get_cart();
5288 if ( empty( $cart ) ) {
5289 usces_restore_order_acting_data( $tracking_id );
5290 }
5291 }
5292 }
5293
5294 /**
5295 * 決済完了ページ制御
5296 * usces_filter_check_acting_return_results
5297 *
5298 * @param array $results Result data.
5299 * @return array
5300 */
5301 public function acting_return( $results ) {
5302 $acting = filter_input( INPUT_GET, 'acting' );
5303 switch ( $acting ) {
5304 case 'zeus_card':
5305 if ( $results['acting_return'] && isset( $results['wctid'] ) && usces_is_trusted_acting_data( $results['wctid'] ) ) {
5306 $results[0] = 1;
5307 } else {
5308 $results[0] = ( isset( $results['acting_return'] ) ) ? $results['acting_return'] : 0;
5309 }
5310 $results['reg_order'] = false;
5311 break;
5312
5313 case 'zeus_conv':
5314 if ( $results['acting_return'] ) {
5315 $results[0] = 1;
5316 } else {
5317 $results[0] = 0;
5318 }
5319 $results['reg_order'] = true;
5320 break;
5321
5322 case 'zeus_bnpl':
5323 $results[0] = $results['acting_return'];
5324 $results['reg_order'] = false;
5325 break;
5326 }
5327
5328 return $results;
5329 }
5330
5331 /**
5332 * 重複オーダー禁止処理
5333 * usces_filter_check_acting_return_duplicate
5334 *
5335 * @param string $trans_id Transaction ID.
5336 * @param array $results Result data.
5337 * @return string
5338 */
5339 public function check_acting_return_duplicate( $trans_id, $results ) {
5340 $result_data = wp_unslash( $_REQUEST );
5341 $acting = ( isset( $result_data['acting'] ) ) ? $result_data['acting'] : '';
5342 switch ( $acting ) {
5343 case 'zeus_card':
5344 if ( isset( $result_data['ordd'] ) ) {
5345 $trans_id = $result_data['ordd'];
5346 } elseif ( isset( $result_data['zeusordd'] ) ) {
5347 $trans_id = $result_data['zeusordd'];
5348 }
5349 break;
5350 case 'zeus_conv':
5351 case 'zeus_bank':
5352 $trans_id = ( isset( $result_data['order_no'] ) ) ? $result_data['order_no'] : '';
5353 break;
5354 case 'zeus_bnpl':
5355 $trans_id = ( isset( $result_data['sendpoint'] ) ) ? $result_data['sendpoint'] : '';
5356 break;
5357 }
5358 return $trans_id;
5359 }
5360
5361 /**
5362 * 受注データ登録
5363 * Called by usces_reg_orderdata() and usces_new_orderdata().
5364 * usces_action_reg_orderdata
5365 *
5366 * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $results ).
5367 */
5368 public function register_orderdata( $args ) {
5369 global $usces;
5370 extract( $args );
5371
5372 $acting_flg = ( isset( $payments['settlement'] ) ) ? $payments['settlement'] : '';
5373 if ( ! in_array( $acting_flg, $this->pay_method, true ) ) {
5374 return;
5375 }
5376
5377 if ( ! $entry['order']['total_full_price'] ) {
5378 return;
5379 }
5380
5381 /* zeus card */
5382 if ( 'acting_zeus_card' === $acting_flg ) {
5383 $acting_opts = $this->get_acting_settings();
5384 /* Secure API */
5385 if ( 2 === (int) $acting_opts['connection'] && ! empty( $results['zeusordd'] ) && ! empty( $results['zeussuffix'] ) ) {
5386 if ( ! isset( $results['acting'] ) ) {
5387 $results['acting'] = 'zeus_card';
5388 }
5389 if ( 'on' === $acting_opts['howpay'] ) {
5390 if ( isset( $entry['order']['howpay'] ) && '0' === $entry['order']['howpay'] ) {
5391 $div_name = 'div_' . $entry['order']['cbrand'];
5392 $results['howpay'] = '0';
5393 $results['div'] = $entry['order'][ $div_name ];
5394 } else {
5395 $results['howpay'] = '1';
5396 $results['div'] = '01';
5397 }
5398 }
5399 $usces->set_order_meta_value( 'acting_zeus_card', usces_serialize( $results ), $order_id );
5400 $usces->set_order_meta_value( 'wc_trans_id', $results['zeusordd'], $order_id );
5401 $usces->set_order_meta_value( 'trans_id', $results['zeusordd'], $order_id );
5402 if ( 'on' === $acting_opts['quickcharge'] && $usces->is_member_logged_in() ) {
5403 $usces->set_member_meta_value( 'zeus_pcid', '8888888888888882' );
5404 $usces->set_member_meta_value( 'zeus_partofcard', $results['zeussuffix'] );
5405 }
5406 if ( isset( $results['auth_code'] ) ) {
5407 $usces->set_order_meta_value( 'auth_code', $results['auth_code'], $order_id );
5408 }
5409
5410 $tracking_id = ( isset( $results['wctid'] ) ) ? $results['wctid'] : '';
5411 if ( empty( $tracking_id ) ) {
5412 $tracking_id = ( isset( $results['sendpoint'] ) ) ? $results['sendpoint'] : '';
5413 }
5414 if ( ! empty( $tracking_id ) ) {
5415 $usces->set_order_meta_value( 'tracking_id', $tracking_id, $order_id );
5416
5417 $order_ref = wel_zeus_get_order_ref( $results['zeusordd'] );
5418 $status = ( empty( $order_ref['status'] ) ) ? 'payment' : $order_ref['status'];
5419 if ( ! isset( $results['money'] ) ) {
5420 $amount = apply_filters( 'zeus_secure_payreq_amount', usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ), $entry );
5421 $results['money'] = $amount;
5422 }
5423 $results = apply_filters( 'usces_filter_zeus_card_register_orderdata_log', $results, $args );
5424 wel_zeus_save_acting_log( $results, 'zeus_card', $status, 'OK', $order_id, $tracking_id );
5425 }
5426
5427 /* Secure Link */
5428 } elseif ( 1 === (int) $acting_opts['connection'] && ! empty( $results['ordd'] ) ) {
5429 if ( 'on' === $acting_opts['howpay'] ) {
5430 if ( isset( $entry['order']['howpay'] ) && '0' === $entry['order']['howpay'] ) {
5431 $div_name = 'div_' . $entry['order']['cbrand'];
5432 $results['howpay'] = '0';
5433 $results['div'] = $entry['order'][ $div_name ];
5434 } else {
5435 $results['howpay'] = '1';
5436 $results['div'] = '01';
5437 }
5438 }
5439 $usces->set_order_meta_value( 'acting_zeus_card', usces_serialize( $results ), $order_id );
5440 $usces->set_order_meta_value( 'wc_trans_id', $results['ordd'], $order_id );
5441 $usces->set_order_meta_value( 'trans_id', $results['ordd'], $order_id );
5442
5443 if ( 'on' === $acting_opts['quickcharge'] && ! empty( $results['sendid'] ) ) {
5444 if ( isset( $results['cardnumber'] ) ) {
5445 $usces->set_member_meta_value( 'zeus_partofcard', $results['cardnumber'], $results['sendid'] );
5446 $usces->set_member_meta_value( 'zeus_pcid', '8888888888888882', $results['sendid'] );
5447 }
5448 }
5449
5450 $tracking_id = ( isset( $results['sendpoint'] ) ) ? $results['sendpoint'] : '';
5451 if ( ! empty( $tracking_id ) ) {
5452 $usces->set_order_meta_value( 'tracking_id', $tracking_id, $order_id );
5453
5454 $order_ref = wel_zeus_get_order_ref( $results['ordd'] );
5455 $status = ( empty( $order_ref['status'] ) ) ? 'payment' : $order_ref['status'];
5456 $results = apply_filters( 'usces_filter_zeus_card_register_orderdata_log', $results, $args );
5457 wel_zeus_save_acting_log( $results, 'zeus_card', $status, 'OK', $order_id, $tracking_id );
5458 }
5459 }
5460
5461 /* zeus_bank */
5462 } elseif ( 'acting_zeus_bank' === $acting_flg && isset( $results['order_no'] ) && isset( $results['tracking_no'] ) ) {
5463 if ( isset( $results['acting_return'] ) ) {
5464 unset( $results['acting_return'] );
5465 unset( $results['0'] );
5466 unset( $results['reg_order'] );
5467 }
5468 $usces->set_order_meta_value( 'acting_' . $results['tracking_no'], usces_serialize( $results ), $order_id );
5469 $usces->set_order_meta_value( 'wc_trans_id', $results['order_no'], $order_id );
5470 $usces->set_order_meta_value( 'trans_id', $results['order_no'], $order_id );
5471
5472 /* zeus conv */
5473 } elseif ( 'acting_zeus_conv' === $acting_flg && ! empty( $results['wctid'] ) ) {
5474 if ( isset( $results['acting_return'] ) ) {
5475 unset( $results['acting_return'] );
5476 unset( $results['0'] );
5477 unset( $results['reg_order'] );
5478 }
5479 $usces->set_order_meta_value( 'acting_' . $results['wctid'], usces_serialize( $results ), $order_id );
5480 if ( ! empty( $results['order_no'] ) ) {
5481 $usces->set_order_meta_value( 'wc_trans_id', $results['order_no'], $order_id );
5482 $usces->set_order_meta_value( 'trans_id', $results['order_no'], $order_id );
5483 }
5484
5485 /* zeus bnpl */
5486 } elseif ( 'acting_zeus_bnpl' === $acting_flg ) {
5487 $response = ( isset( $results['response'] ) ) ? $results['response'] : array();
5488 $tracking_id = ( isset( $response['transactionInfo']['shopOrderId'] ) ) ? $response['transactionInfo']['shopOrderId'] : '';
5489 if ( ! empty( $tracking_id ) ) {
5490 unset( $results['response'] );
5491 $results['shopOrderId'] = $tracking_id;
5492 $results['transactionId'] = $response['transactionInfo']['transactionId'];
5493 $results['autoAuthoriresult'] = $response['transactionInfo']['autoAuthoriresult'];
5494 $usces->set_order_meta_value( 'acting_zeus_bnpl', usces_serialize( $results ), $order_id );
5495 $usces->set_order_meta_value( 'tracking_id', $tracking_id, $order_id );
5496 $usces->set_order_meta_value( 'wc_trans_id', $response['transactionInfo']['transactionId'], $order_id );
5497 $usces->set_order_meta_value( 'trans_id', $response['transactionInfo']['transactionId'], $order_id );
5498 $response['money'] = $results['money'];
5499 wel_zeus_save_acting_log( $response, 'zeus_bnpl', 'transaction', $response['transactionInfo']['autoAuthoriresult'], $order_id, $tracking_id );
5500 }
5501 }
5502 }
5503
5504 /**
5505 * 受注データ登録後処理
5506 * usces_post_reg_orderdata
5507 *
5508 * @param string $order_id Order Number.
5509 * @param array $results Results.
5510 */
5511 public function post_register_orderdata( $order_id, $results ) {
5512 if ( ! empty( $order_id ) && isset( $results['acting'] ) && 'zeus_card' === $results['acting'] ) {
5513 $tracking_id = ( isset( $results['wctid'] ) ) ? $results['wctid'] : '';
5514 if ( empty( $tracking_id ) ) {
5515 $tracking_id = ( isset( $results['sendpoint'] ) ) ? $results['sendpoint'] : '';
5516 }
5517 if ( ! empty( $tracking_id ) ) {
5518 // usces_ordered_acting_data( $_REQUEST['wctid'] ); �
5519 ��
5520 の処理.
5521 usces_delete_ordered_acting_data( $tracking_id );
5522 }
5523 }
5524 }
5525
5526 /**
5527 * 決済エラーメッセージ
5528 * usces_filter_get_error_settlement
5529 *
5530 * @param string $form Payment error message.
5531 * @return string
5532 */
5533 public function error_page_message( $form ) {
5534 $acting = ( isset( $_REQUEST['acting'] ) ) ? wp_unslash( $_REQUEST['acting'] ) : '';
5535 if ( 'zeus_card' === $acting ) {
5536 $form .= '<div class="support_box">';
5537 if ( isset( $_GET['code'] ) ) {
5538 $code = filter_input( INPUT_GET, 'code' );
5539 $form .= '<br />エラーコード:' . esc_html( $code );
5540 if ( in_array( $code, array( '02130514', '02130517', '02130619', '02130620', '02130621', '02130640' ), true ) ) {
5541 $form .= '<br />カード番号が正しくないようです。';
5542 } elseif ( in_array( $code, array( '02130714', '02130717', '02130725', '02130814', '02130817', '02130825' ), true ) ) {
5543 $form .= '<br />カードの有効期限が正しくないようです。';
5544 } elseif ( in_array( $code, array( '02130922' ), true ) ) {
5545 $form .= '<br />カードの有効期限が切れているようです。';
5546 } elseif ( in_array( $code, array( '02131014', '02131017' ), true ) ) {
5547 $form .= '<br />セキュリティコードが正しくないようです。';
5548 } elseif ( in_array( $code, array( '02131117', '02131123', '02131124' ), true ) ) {
5549 $form .= '<br />カードの名義が正しくないようです。';
5550 } elseif ( in_array( $code, array( '02131317', '02131325', '02131310', '02131326' ), true ) ) {
5551 $form .= '<br />指定の支払い回数はご利用いただけません。';
5552 } elseif ( in_array( $code, array( '02131414', '02131417', '02131437' ), true ) ) {
5553 $form .= '<br />お客様�
5554 報の電話番号が正しくないようです。';
5555 } elseif ( in_array( $code, array( '02131527', '02131528', '02131529', '02131537' ), true ) ) {
5556 $form .= '<br />お客様�
5557 報のEメールアドレスが正しくないようです。';
5558 } elseif ( in_array( $code, array( '02100431' ), true ) ) {
5559 $form .= '<br />今回のお申し込みは受け付けられませんでした。ご利用サイトは3Dセキュアの認証が�
5560 要のため、お使いのクレジットカードではお取扱出来ません。';
5561 } else {
5562 $form .= '<br />今回のお申し込みは受け付けられませんでした。';
5563 }
5564 $form .= '<br />
5565 <br />
5566 <a href="' . USCES_CUSTOMER_URL . '">もう一度決済を行う </a><br />';
5567 } else {
5568 if ( isset( $_GET['err_code'] ) ) {
5569 $form .= '<br />エラーコード:' . filter_input( INPUT_GET, 'err_code' );
5570 }
5571 $form .= '<br />
5572 カード番号を再�
5573 �力する場合はこちらをクリックしてください。<br />
5574 <br />
5575 <a href="' . USCES_CUSTOMER_URL . '">もう一度決済を行う </a><br />';
5576 }
5577 $form .= '<br />
5578 株式会社ゼウス カスタマーサポート (24時間365日対応)<br />
5579 電話番号:0570-02-3939 (つながらないときは 03-4334-0500<br />
5580 E-mail:support@cardservice.co.jp
5581 </div>';
5582
5583 } elseif ( 'zeus_conv' === $acting || 'zeus_bank' === $acting ) {
5584 $form .= '<div class="support_box">';
5585 if ( isset( $_GET['code'] ) ) {
5586 $code = filter_input( INPUT_GET, 'code' );
5587 $form .= '<br />エラーコード:' . esc_html( $code );
5588 if ( in_array( $code, array( '800002', '0013' ), true ) ) {
5589 $form .= '<br />このコンビニはお取り扱いできません。詳細に関してはカスタマーサポートまでお問い合わせください。';
5590 } elseif ( in_array( $code, array( '900000', '0011' ), true ) ) {
5591 $form .= '<br />お申し込み�
5592 報が正しく�
5593 �力されていないか、通信時にエラーが発生している可能性がございます。�
5594 �力�
5595 報を再度ご確認いただいた上でお申し込みをいただくか、カスタマーサポートまでお問い合わせください。';
5596 } elseif ( in_array( $code, array( '0008' ), true ) ) {
5597 $form .= '<br />このコンビニはお取り扱いできません。別のコンビニをご選択いただき、再度お申し込みをいただくか、カスタマーサポートまでお問い合わせください。';
5598 } else {
5599 $form .= '<br />詳細に関してはカスタマーサポートまでお問い合わせください。';
5600 }
5601 } else {
5602 if ( 'zeus_conv' === $acting ) {
5603 $form .= '<br />このコンビニはお取り扱いできません。詳細に関してはカスタマーサポートまでお問い合わせください。';
5604 } else {
5605 $form .= '<br />詳細に関してはカスタマーサポートまでお問い合わせください。';
5606 }
5607 }
5608 $form .= '<br /><br />
5609 <a href="' . USCES_CUSTOMER_URL . '">もう一度決済を行う 》</a><br /><br />
5610 株式会社ゼウス カスタマーサポート (24時間365日対応)<br />
5611 電話番号:0570-08-3000 (つながらないときは 03-3498-9888)<br />
5612 E-mail:support@cardservice.co.jp
5613 </div>';
5614
5615 } elseif ( 'zeus_bnpl' === $acting ) {
5616 $form .= '<div class="support_box">';
5617 if ( isset( $_GET['code'] ) ) {
5618 $code = filter_input( INPUT_GET, 'code' );
5619 $form .= '<br />エラーコード:' . esc_html( $code );
5620 }
5621 $form .= '<br /><br />
5622 <a href="' . USCES_CUSTOMER_URL . '">もう一度決済を行う 》</a><br /><br />
5623 株式会社ゼウス カスタマーサポート (24時間365日対応)<br />
5624 電話番号:0570-08-3000 (つながらないときは 03-3498-9888)<br />
5625 E-mail:support@cardservice.co.jp
5626 </div>';
5627 }
5628 return $form;
5629 }
5630
5631 /**
5632 * Set uscesL10n.
5633 * usces_filter_uscesL10n
5634 *
5635 * @param string $l10n uscesL10n.
5636 * @param int $post_id Post ID.
5637 * @return string
5638 */
5639 public function set_uscesL10n( $l10n, $post_id ) {
5640 global $usces;
5641
5642 if ( ! $this->is_validity_acting( 'card' ) ) {
5643 return $l10n;
5644 }
5645
5646 if ( 'delivery' === $usces->page ) {
5647 $acting_opts = $this->get_acting_settings();
5648 $pcid = null;
5649 $partofcard = null;
5650 if ( $usces->is_member_logged_in() ) {
5651 $member = $usces->get_member();
5652 if ( ! isset( $_GET['re-enter'] ) ) {
5653 $pcid = $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] );
5654 $partofcard = $usces->get_member_meta_value( 'zeus_partofcard', $member['ID'] );
5655 }
5656 }
5657 $l10n .= "'zeus_form': 'cart',\n";
5658 $l10n .= "'zeus_security': '" . $acting_opts['security'] . "',\n";
5659 $l10n .= "'zeus_quickcharge': '" . $acting_opts['quickcharge'] . "',\n";
5660 $l10n .= "'zeus_howpay': '" . $acting_opts['howpay'] . "',\n";
5661 $l10n .= "'zeus_thisyear': '" . date_i18n( 'Y' ) . "',\n";
5662 $l10n .= "'zeus_pcid': '" . $pcid . "',\n";
5663 $l10n .= "'zeus_partofcard': '" . $partofcard . "',\n";
5664 if ( ! empty( $pcid ) && ! empty( $partofcard ) ) {
5665 $member_update_settlement = add_query_arg(
5666 array(
5667 'usces_page' => 'member_update_settlement',
5668 're-enter' => 1,
5669 ),
5670 USCES_MEMBER_URL
5671 );
5672 $l10n .= "'zeus_cardupdate_url': '" . urlencode( $member_update_settlement ) . "',\n";
5673 }
5674 $l10n .= "'zeus_card_error': '" . __( 'Credit card information is not appropriate.', 'usces' ) . "',\n";
5675 $l10n .= "'zeus_3ds': '" . $acting_opts['3dsecur'] . "',\n";
5676 } elseif ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
5677 if ( isset( $_GET['usces_page'] ) && ( 'member_register_settlement' === filter_input( INPUT_GET, 'usces_page' ) || 'member_update_settlement' === filter_input( INPUT_GET, 'usces_page' ) ) ) {
5678 $acting_opts = $this->get_acting_settings();
5679 $member = $usces->get_member();
5680 $pcid = $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] );
5681 $partofcard = $usces->get_member_meta_value( 'zeus_partofcard', $member['ID'] );
5682 $l10n .= "'zeus_form': 'member',\n";
5683 $l10n .= "'zeus_security': '" . $acting_opts['security'] . "',\n";
5684 $l10n .= "'zeus_quickcharge': '" . $acting_opts['quickcharge'] . "',\n";
5685 $l10n .= "'zeus_thisyear': '" . date_i18n( 'Y' ) . "',\n";
5686 $l10n .= "'zeus_thismonth': '" . date_i18n( 'm' ) . "',\n";
5687 $l10n .= "'zeus_pcid': '" . $pcid . "',\n";
5688 $l10n .= "'zeus_partofcard': '" . $partofcard . "',\n";
5689 $l10n .= "'zeus_card_error': '" . __( 'Credit card information is not appropriate.', 'usces' ) . "',\n";
5690 $l10n .= "'zeus_3ds': '" . $acting_opts['3dsecur'] . "',\n";
5691 }
5692 }
5693 return $l10n;
5694 }
5695
5696 /**
5697 * Front scripts.
5698 * wp_print_footer_scripts
5699 */
5700 public function footer_scripts() {
5701 global $usces;
5702
5703 if ( ! $this->is_validity_acting( 'card' ) ) {
5704 return;
5705 }
5706
5707 /* 発送・支払方法ページ */
5708 if ( 'delivery' === $usces->page ) :
5709 $acting_opts = $this->get_acting_settings();
5710 if ( 'on' === $acting_opts['card_activate'] ) :
5711 wp_enqueue_style( 'zeus-token-style', USCES_FRONT_PLUGIN_URL . '/css/zeus_token.css', array(), USCES_VERSION );
5712 wp_enqueue_script( 'zeus-token-script', USCES_FRONT_PLUGIN_URL . '/js/zeus_token.js', array(), USCES_VERSION );
5713 wp_enqueue_script( 'usces_cart_zeus', USCES_FRONT_PLUGIN_URL . '/js/cart_zeus.js', array( 'jquery' ), USCES_VERSION, true );
5714 ?>
5715 <script type="text/javascript">
5716 var zeusTokenIpcode = "<?php echo esc_attr( $acting_opts['clientip'] ); ?>";
5717 </script>
5718 <?php
5719 endif;
5720
5721 /* �
5722 容確認ページ */
5723 elseif ( 'confirm' === $usces->page ) :
5724 $entry = $usces->cart->get_entry();
5725 $cart = $usces->cart->get_cart();
5726 if ( empty( $cart ) || empty( $entry['order']['total_full_price'] ) ) {
5727 return;
5728 }
5729
5730 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
5731 if ( 'acting_zeus_card' === $payment['settlement'] && 'activate' === $payment['use'] ) :
5732 $acting_opts = $this->get_acting_settings();
5733 if ( $this->is_activate_card( 'api' ) && 1 === (int) $acting_opts['3dsecur'] ) :
5734 wp_enqueue_script( 'zeus-3ds-script', USCES_FRONT_PLUGIN_URL . '/js/zeus_3ds.js', array(), USCES_VERSION );
5735 wp_enqueue_style( 'usces-loading', USCES_FRONT_PLUGIN_URL . '/css/loading.css', array(), USCES_VERSION );
5736 ob_start();
5737 ?>
5738 <script>
5739 var loading_img = document.getElementById('zeus-loading');
5740 var purchase_button = document.getElementById('purchase_button');
5741 purchase_button.dataset.clicked = '';
5742 purchase_button.addEventListener( 'click', function(event) {
5743 purchase_button.dataset.clicked = 'clicked';
5744 });
5745 var purchase_form = document.getElementById('purchase_form');
5746 purchase_form.addEventListener( 'submit', function(event) {
5747 if( purchase_button.dataset.clicked === 'clicked' ) {
5748 loading_img.style.display = 'block';
5749 event.preventDefault();
5750 let params = new URLSearchParams();
5751 params.append("action","zeus_3dsecure_enrol");
5752 params.append("card_option",document.getElementById("card_option").value);
5753 params.append("token_key",document.getElementById("token_key").value);
5754 params.append("card_name",document.getElementById("card_name").value);
5755 params.append("sendid",document.getElementById("sendid").value);
5756 params.append("sendpoint",document.getElementById("sendpoint").value);
5757 params.append("_nonce","<?php echo esc_attr( wp_create_nonce( 'acting_zeus_card' ) ); ?>");
5758 return fetch( uscesL10n.ajaxurl+"?uscesid="+uscesL10n.uscesid, {
5759 method:'POST',
5760 cache:'no-cache',
5761 body:params
5762 }).then( function(res) {
5763 return res.json();
5764 }).then( function(data) {
5765 if( 'stock' == data.action && 'error' == data.status ) {
5766 location.href = "<?php echo esc_js( USCES_CART_URL ); ?>";
5767 }
5768 if( 'EnrolReq' == data.action && 'success' == data.status ) {
5769 purchase_button.disabled = true;
5770 try {
5771 setPareqParams(data.MD,data.iframeUrl,data.TermUrl,data.threeDSMehtod,data.iframeUrl);
5772 } catch(error) {
5773 purchase_button.disabled = false;
5774 loading_img.style.display = 'none';
5775 }
5776 } else if( 'EnrolReq' == data.action && 'outside' == data.status ) {
5777 if( null !== data.code ) {
5778 var outside = document.createElement('input');
5779 outside.setAttribute('type','hidden');
5780 outside.setAttribute('name','outside');
5781 outside.setAttribute('value',data.code);
5782 }
5783 var purchase = document.createElement('input');
5784 purchase.setAttribute('type','hidden');
5785 purchase.setAttribute('name','purchase');
5786 purchase.setAttribute('value','purchase');
5787 document.purchase_form.appendChild(outside);
5788 document.purchase_form.appendChild(purchase);
5789 document.purchase_form.submit();
5790 } else {
5791 location.href = "<?php echo esc_js( trailingslashit( USCES_CART_URL ) ); ?>?acting=zeus_card&acting_return=0&status="+data.status+"&code="+data.code;
5792 }
5793 }).catch((reason) => {
5794 loading_img.style.display = 'none';
5795 });
5796 }
5797 });
5798 </script>
5799 <?php
5800 $scripts = ob_get_contents();
5801 ob_end_clean();
5802 $scripts = apply_filters( 'usces_filter_purchase_button_script_zeus', $scripts );
5803 echo $scripts;
5804 endif;
5805 endif;
5806
5807 /* マイページ */
5808 elseif ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) :
5809 if ( isset( $_GET['usces_page'] ) && ( 'member_register_settlement' === filter_input( INPUT_GET, 'usces_page' ) || 'member_update_settlement' === filter_input( INPUT_GET, 'usces_page' ) ) ) :
5810 $acting_opts = $this->get_acting_settings();
5811 wp_enqueue_style( 'zeus-token-style', USCES_FRONT_PLUGIN_URL . '/css/zeus_token.css', array(), USCES_VERSION );
5812 wp_enqueue_script( 'zeus-token-script', USCES_FRONT_PLUGIN_URL . '/js/zeus_token.js', array(), USCES_VERSION );
5813 wp_enqueue_script( 'usces_member_zeus', USCES_FRONT_PLUGIN_URL . '/js/member_zeus.js', array( 'jquery' ), USCES_VERSION, true );
5814 ?>
5815 <script type="text/javascript">
5816 var zeusTokenIpcode = "<?php echo esc_attr( $acting_opts['clientip'] ); ?>";
5817 </script>
5818 <?php
5819 print_google_recaptcha_response( filter_input( INPUT_GET, 'usces_page' ), 'member-card-info', 'member_update_settlement' );
5820 else :
5821 $member = $usces->get_member();
5822 if ( usces_have_member_continue_order( $member['ID'] ) || usces_have_member_regular_order( $member['ID'] ) ) :
5823 ?>
5824 <script type="text/javascript">
5825 jQuery(document).ready(function($) {
5826 $("input[name='deletemember']").css("display","none");
5827 });
5828 </script>
5829 <?php
5830 endif;
5831 endif;
5832 endif;
5833 }
5834
5835 /**
5836 * 利用可能な決済モジュール
5837 * usces_filter_available_payment_method
5838 *
5839 * @param array $payments Payments.
5840 * @return array
5841 */
5842 public function set_available_payment_method( $payments ) {
5843 global $usces;
5844
5845 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
5846 $payment_method = array();
5847 foreach ( (array) $payments as $id => $payment ) {
5848 if ( isset( $payment['settlement'] ) && 'acting_zeus_card' === $payment['settlement'] ) {
5849 $payment_method[ $id ] = $payments[ $id ];
5850 break;
5851 }
5852 }
5853 if ( ! empty( $payment_method ) ) {
5854 $payments = $payment_method;
5855 }
5856 }
5857 return $payments;
5858 }
5859
5860 /**
5861 * クレジットカード登録・変更ページ表示
5862 * usces_filter_template_redirect
5863 */
5864 public function member_update_settlement() {
5865 global $usces;
5866
5867 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
5868 if ( ! usces_is_membersystem_state() || ! usces_is_login() ) {
5869 return;
5870 }
5871
5872 $acting_opts = $this->get_acting_settings();
5873 if ( 'on' !== $acting_opts['quickcharge'] ) {
5874 return;
5875 }
5876
5877 if ( isset( $_REQUEST['usces_page'] ) && 'member_update_settlement' === $_REQUEST['usces_page'] ) {
5878 add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) );
5879 $usces->page = 'member_update_settlement';
5880 $this->member_update_settlement_form();
5881 exit();
5882
5883 } elseif ( isset( $_REQUEST['usces_page'] ) && 'member_register_settlement' === $_REQUEST['usces_page'] && 'on' === $acting_opts['batch'] ) {
5884 add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) );
5885 $usces->page = 'member_register_settlement';
5886 $this->member_update_settlement_form();
5887 exit();
5888 }
5889 }
5890 return false;
5891 }
5892
5893 /**
5894 * クレジットカード登録・変更ページ表示
5895 * usces_filter_states_form_js
5896 *
5897 * @param string $js Scripts.
5898 * @return string
5899 */
5900 public function states_form_js( $js ) {
5901 return '';
5902 }
5903
5904 /**
5905 * クレジットカード登録・変更ページリンク
5906 * usces_action_member_submenu_list
5907 */
5908 public function e_update_settlement() {
5909 global $usces;
5910
5911 $member = $usces->get_member();
5912 $form = $this->update_settlement( '', $member );
5913 echo $form; // no escape.
5914 }
5915
5916 /**
5917 * クレジットカード登録・変更ページリンク
5918 * usces_filter_member_submenu_list
5919 *
5920 * @param string $form HTML Form.
5921 * @param array $member Members data.
5922 * @return string
5923 */
5924 public function update_settlement( $form, $member ) {
5925 global $usces;
5926
5927 $acting_opts = $this->get_acting_settings();
5928 if ( 'on' === $acting_opts['quickcharge'] ) {
5929 $member = $usces->get_member();
5930 $pcid = $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] );
5931 $partofcard = $usces->get_member_meta_value( 'zeus_partofcard', $member['ID'] );
5932 if ( ! empty( $pcid ) && ! empty( $partofcard ) ) {
5933 $update_settlement_url = add_query_arg(
5934 array(
5935 'usces_page' => 'member_update_settlement',
5936 're-enter' => 1,
5937 ),
5938 USCES_MEMBER_URL
5939 );
5940 $form .= '<li class="settlement-update gotoedit"><a href="' . $update_settlement_url . '">' . __( 'Change the credit card is here >>', 'usces' ) . '</a></li>';
5941 } elseif ( 'on' === $acting_opts['batch'] ) {
5942 $register_settlement_url = add_query_arg(
5943 array(
5944 'usces_page' => 'member_register_settlement',
5945 're-enter' => 1,
5946 ),
5947 USCES_MEMBER_URL
5948 );
5949 $form .= '<li class="settlement-register gotoedit"><a href="' . $register_settlement_url . '">' . __( 'Credit card registration is here >>', 'usces' ) . '</a></li>';
5950 }
5951 }
5952 return $form;
5953 }
5954
5955 /**
5956 * クレジットカード登録・変更ページ
5957 */
5958 public function member_update_settlement_form() {
5959 global $usces;
5960
5961 $script = '';
5962 $message = '';
5963 $form = '';
5964 $register = ( 'member_register_settlement' === $usces->page ) ? true : false;
5965
5966 $update_settlement_url = add_query_arg(
5967 array(
5968 'usces_page' => 'member_update_settlement',
5969 'settlement' => 1,
5970 're-enter' => 1,
5971 ),
5972 USCES_MEMBER_URL
5973 );
5974
5975 $member = $usces->get_member();
5976 $acting_opts = $this->get_acting_settings();
5977
5978 if ( isset( $_POST['zeus_card_update'] ) ) {
5979 if ( ! wp_verify_nonce( filter_input( INPUT_POST, 'wc_nonce' ), 'member_update_settlement' ) || empty( $_POST['zeus_token_value'] ) ) {
5980 $usces->error_message .= __( 'failure in update', 'usces' );
5981 } else {
5982 $verify_action = wel_verify_update_settlement( $member['ID'] );
5983 if ( ! $verify_action ) {
5984 $usces->error_message .= '<p>' . __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '</p>';
5985 } else {
5986 $params = array();
5987 $params['send'] = 'mall';
5988 $params['clientip'] = $acting_opts['clientip'];
5989 $params['token_key'] = filter_input( INPUT_POST, 'zeus_token_value' );
5990 $params['cardnumber'] = '8888888888888882';
5991 $params['expyy'] = '00';
5992 $params['expmm'] = '00';
5993 $params['money'] = '0';
5994 $params['telno'] = str_replace( '-', '', $member['tel'] );
5995 $params['email'] = $member['mailaddress1'];
5996 $params['sendid'] = $member['ID'];
5997 $params['sendpoint'] = usces_rand();
5998 $params['pubsec'] = 'yes';
5999 $params['printord'] = '';
6000 $params['return_value'] = 'yes';
6001
6002 $page = $this->secure_link_batch( $acting_opts['card_url'], $params );
6003 if ( false !== strpos( $page, 'Success_order' ) ) {
6004 $usces->error_message = '';
6005 $message = __( 'Successfully updated.', 'usces' );
6006 if ( ! empty( $_POST['zeus_token_masked_card_no'] ) ) {
6007 $partofcard = substr( filter_input( INPUT_POST, 'zeus_token_masked_card_no' ), -4 );
6008 $usces->set_member_meta_value( 'zeus_partofcard', $partofcard );
6009 }
6010 $pcid = $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] );
6011 if ( empty( $pcid ) ) {
6012 $usces->set_member_meta_value( 'zeus_pcid', '8888888888888882' );
6013 }
6014 $this->send_update_settlement_mail();
6015 } else {
6016 $err_code = $this->get_err_code( $page );
6017 $usces->error_message .= __( 'failure in update', 'usces' );
6018 }
6019
6020 if ( '' !== $message ) {
6021 $script .= "
6022 <script type=\"text/javascript\">
6023 jQuery.event.add(window,'load',function() {
6024 alert('" . $message . "');
6025 });
6026 </script>";
6027 }
6028 }
6029 }
6030 }
6031 $error_message = apply_filters( 'usces_filter_member_update_settlement_error_message', $usces->error_message );
6032
6033 ob_start();
6034 get_header();
6035 ?>
6036 <div id="content" class="two-column">
6037 <div class="catbox">
6038 <?php
6039 if ( have_posts() ) :
6040 usces_remove_filter();
6041 ?>
6042 <div class="post" id="wc_member_update_settlement">
6043 <?php if ( $register ) : ?>
6044 <h1 class="member_page_title"><?php esc_html_e( 'Credit card registration', 'usces' ); ?></h1>
6045 <?php else : ?>
6046 <h1 class="member_page_title"><?php esc_html_e( 'Credit card update', 'usces' ); ?></h1>
6047 <?php endif; ?>
6048 <div class="entry">
6049 <div id="memberpages">
6050 <div class="whitebox">
6051 <div id="memberinfo">
6052 <div class="header_explanation">
6053 <?php do_action( 'usces_action_member_update_settlement_page_header' ); ?>
6054 </div>
6055 <div class="error_message"><?php echo wp_kses_post( $error_message ); ?></div>
6056 <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;}">
6057 <input type="hidden" name="acting" value="<?php echo esc_attr( $this->paymod_id ); ?>">
6058 <table class="customer_form" id="<?php echo esc_attr( $this->paymod_id ); ?>">
6059 <tr><th scope="row"><?php esc_html_e( 'Credit card information', 'usces' ); ?></th><td id="zeus_token_card_info_area"></td></tr>
6060 </table>
6061 <div class="send">
6062 <?php if ( $register ) : ?>
6063 <input type="hidden" name="zeus_card_update" value="register" />
6064 <input type="button" id="card-register" class="card-update" value="<?php esc_attr_e( 'Register' ); ?>" />
6065 <?php else : ?>
6066 <input type="hidden" name="zeus_card_update" value="update" />
6067 <input type="button" id="card-update" class="card-update" value="<?php esc_attr_e( 'update it', 'usces' ); ?>" />
6068 <?php endif; ?>
6069 <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 ); ?>'" />
6070 <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() ); ?>'" />
6071 </div>
6072 <?php do_action( 'usces_action_member_update_settlement_page_inform' ); ?>
6073 <?php wp_nonce_field( 'member_update_settlement', 'wc_nonce' ); ?>
6074 </form>
6075 <div class="footer_explanation">
6076 <?php do_action( 'usces_action_member_update_settlement_page_footer' ); ?>
6077 </div>
6078 </div><!-- end of memberinfo -->
6079 </div><!-- end of whitebox -->
6080 </div><!-- end of memberpages -->
6081 </div><!-- end of entry -->
6082 </div><!-- end of post -->
6083 <?php else : ?>
6084 <p><?php esc_html_e( 'Sorry, no posts matched your criteria.', 'usces' ); ?></p>
6085 <?php endif; ?>
6086 </div><!-- end of catbox -->
6087 </div><!-- end of content -->
6088 <?php
6089 if ( '' !== $script ) {
6090 echo $script; // no escape due to script.
6091 }
6092 $sidebar = apply_filters( 'usces_filter_member_update_settlement_page_sidebar', 'cartmember' );
6093 if ( ! empty( $sidebar ) ) {
6094 get_sidebar( $sidebar );
6095 }
6096
6097 get_footer();
6098 $form = ob_get_contents();
6099 ob_end_clean();
6100
6101 echo $form; // no escape.
6102 }
6103
6104 /**
6105 * クレジットカード変更メール
6106 */
6107 public function send_update_settlement_mail() {
6108 global $usces;
6109
6110 $member = $usces->get_member();
6111
6112 $subject = apply_filters( 'usces_filter_send_update_settlement_mail_subject', __( 'Confirmation of credit card update', 'usces' ), $member );
6113 $mail_header = __( 'Your credit card information has been updated on the membership page.', 'usces' ) . "\r\n\r\n";
6114 $mail_footer = get_option( 'blogname' ) . "\r\n";
6115 $name = usces_localized_name( $member['name1'], $member['name2'], 'return' );
6116 $to_name = sprintf( _x( '%s', 'honorific', 'usces' ), $name );
6117
6118 $message = '--------------------------------' . "\r\n";
6119 $message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
6120 $message .= __( 'Name', 'usces' ) . ' : ' . $to_name . "\r\n";
6121 $message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
6122 $message .= '--------------------------------' . "\r\n\r\n";
6123 $message .= __( 'If you have not requested this email, sorry to trouble you, but please contact us.', 'usces' ) . "\r\n\r\n";
6124 $message = apply_filters( 'usces_filter_send_update_settlement_mail_message', $message, $member );
6125 $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";
6126 $message = sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n" . $message;
6127
6128 $send_para = array(
6129 'to_name' => $to_name,
6130 'to_address' => $member['mailaddress1'],
6131 'from_name' => get_option( 'blogname' ),
6132 'from_address' => $usces->options['sender_mail'],
6133 'reply_name' => get_option( 'blogname' ),
6134 'reply_to' => usces_get_first_order_mail(),
6135 'return_path' => $usces->options['sender_mail'],
6136 'subject' => $subject,
6137 'message' => do_shortcode( $message ),
6138 );
6139 usces_send_mail( $send_para );
6140
6141 $admin_message = $mail_header;
6142 $admin_message .= '--------------------------------' . "\r\n";
6143 $admin_message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
6144 $admin_message .= __( 'Name', 'usces' ) . ' : ' . $to_name . "\r\n";
6145 $admin_message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
6146 $admin_message .= '--------------------------------' . "\r\n\r\n";
6147 if ( usces_have_member_continue_order( $member['ID'] ) ) {
6148 $admin_message .= $this->message_continue_order( $member['ID'] );
6149 }
6150 if ( usces_have_member_regular_order( $member['ID'] ) ) {
6151 $admin_message .= $this->message_regular_order( $member['ID'] );
6152 }
6153 $admin_message .=
6154 "\r\n----------------------------------------------------\r\n" .
6155 'REMOTE_ADDR : ' . $_SERVER['REMOTE_ADDR'] .
6156 "\r\n----------------------------------------------------\r\n";
6157
6158 $admin_para = array(
6159 'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
6160 'to_address' => $usces->options['order_mail'],
6161 'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
6162 'from_address' => $usces->options['sender_mail'],
6163 'reply_name' => get_option( 'blogname' ),
6164 'reply_to' => usces_get_first_order_mail(),
6165 'return_path' => $usces->options['sender_mail'],
6166 'subject' => $subject . '( ' . $to_name . ' )',
6167 'message' => do_shortcode( $admin_message ),
6168 );
6169 usces_send_mail( $admin_para );
6170 }
6171
6172 /**
6173 * 契約中の自動継続課金�
6174
6175 *
6176 * @param int $member_id Member ID.
6177 */
6178 public function message_continue_order( $member_id ) {
6179 global $usces, $wpdb;
6180 $message = '';
6181
6182 $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}usces_continuation WHERE `con_member_id` = %d AND `con_acting` = %s AND `con_status` = 'continuation'", $member_id, 'acting_paygent_card' );
6183 $continue_order = $wpdb->get_results( $query, ARRAY_A );
6184 if ( 0 < count( $continue_order ) ) {
6185 $message .= '--------------------------------' . "\r\n";
6186 $message .= __( 'Auto-continuation charging Information under Contract with a credit card', 'usces' ) . "\r\n";
6187 foreach ( $continue_order as $continue_data ) {
6188 $con_id = $continue_data['con_id'];
6189 $con_order_id = $continue_data['con_order_id'];
6190 $message .= __( 'Order number', 'usces' ) . ' : ' . $con_order_id;
6191 $latest_log = $this->get_acting_latest_log( $con_order_id, 0, 'ALL' );
6192 if ( ! empty( $latest_log ) ) {
6193 $next_charging = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_charging( $con_order_id ) : $continue_data['con_next_contracting'];
6194 $message .= ' ( ' . __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $next_charging ) );
6195 if ( 0 < (int) $continue_data['con_interval'] ) {
6196 $next_contracting = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_contracting( $con_order_id ) : $continue_data['con_next_contracting'];
6197 $message .= ', ' . __( 'Renewal Date', 'dlseller' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $next_contracting ) );
6198 }
6199 $message .= ' )';
6200 if ( isset( $latest_log['result'] ) && 'OK' !== $latest_log['result'] ) {
6201 $message .= ' ' . __( 'Condition', 'dlseller' ) . ' : ' . __( 'Settlement error', 'usces' );
6202 if ( ! empty( $latest_log['tracking_id'] ) ) {
6203 $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $latest_log['tracking_id'] . ' )';
6204 }
6205 }
6206 }
6207 $message .= "\r\n";
6208 }
6209 $message .= '--------------------------------' . "\r\n\r\n";
6210 }
6211 return $message;
6212 }
6213
6214 /**
6215 * 契約中の定期購�
6216 ��
6217
6218 *
6219 * @param int $member_id Member ID.
6220 */
6221 public function message_regular_order( $member_id ) {
6222 global $usces, $wpdb;
6223 $message = '';
6224
6225 $query_order = $wpdb->prepare(
6226 "SELECT r.reg_id, r.reg_payment_name, d.regdet_schedule_date
6227 FROM {$wpdb->prefix}usces_regular_detail AS `d`
6228 RIGHT JOIN {$wpdb->prefix}usces_regular AS `r` ON r.reg_id = d.reg_id
6229 WHERE r.reg_mem_id = %d AND d.regdet_condition = 'continuation'
6230 GROUP BY r.reg_id",
6231 $member_id
6232 );
6233 $regular_order = $wpdb->get_results( $query_order, ARRAY_A );
6234 if ( 0 < count( $regular_order ) ) {
6235 foreach ( $regular_order as $regular_data ) {
6236 $acting_flg = $this->get_acting_flg( $regular_data['reg_payment_name'] );
6237 if ( 'acting_zeus_card' !== $acting_flg ) {
6238 continue;
6239 }
6240 $reg_id = $regular_data['reg_id'];
6241 $query = $wpdb->prepare(
6242 "SELECT o.ID AS `order_id`, meta.meta_value AS `deco_id`, DATE_FORMAT( o.order_date, %s ) AS `order_date`
6243 FROM {$wpdb->prefix}usces_order AS `o`
6244 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta` ON o.ID = meta.order_id AND meta.meta_key = 'dec_order_id'
6245 LEFT JOIN {$wpdb->prefix}usces_regular ON o.ID = `reg_order_id`
6246 WHERE `reg_id` = %d
6247 UNION ALL
6248 SELECT o1.ID AS `order_id`, meta1.meta_value AS `deco_id`, DATE_FORMAT( o1.order_date, %s ) AS `order_date`
6249 FROM {$wpdb->prefix}usces_order AS `o1`
6250 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta1` ON o1.ID = meta1.order_id AND meta1.meta_key = 'dec_order_id'
6251 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta2` ON o1.ID = meta2.order_id AND meta2.meta_key = 'regular_id'
6252 WHERE meta2.meta_value = %d
6253 ORDER BY `order_id` DESC, `order_date` DESC",
6254 '%Y-%m-%d',
6255 $reg_id,
6256 '%Y-%m-%d',
6257 $reg_id
6258 );
6259 $regular_order_data = $wpdb->get_results( $query, ARRAY_A );
6260 if ( 0 < count( $regular_order_data ) ) {
6261 $message .= __( 'Regular ID', 'autodelivery' ) . ' : ' . $reg_id;
6262 $reg_order_id = $regular_order_data[0]['order_id'];
6263 $latest_log = $this->get_acting_latest_log( $reg_order_id, 0, 'ALL' );
6264 if ( isset( $latest_log['result'] ) && 'OK' !== $latest_log['result'] ) {
6265 $message .= ' ' . __( 'Condition', 'autodelivery' ) . ' : ' . __( 'Settlement error', 'usces' );
6266 $trans_id = $usces->get_order_meta_value( 'trans_id', $reg_order_id );
6267 if ( $trans_id ) {
6268 $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $trans_id . ' )';
6269 }
6270 } else {
6271 if ( $this->isdate( $regular_data['regdet_schedule_date'] ) ) {
6272 $message .= ' ( ' . __( 'Scheduled order date', 'autodelivery' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $regular_data['regdet_schedule_date'] ) ) . ' )';
6273 }
6274 }
6275 $message .= "\r\n";
6276 }
6277 }
6278 if ( '' !== $message ) {
6279 $message = '--------------------------------' . "\r\n"
6280 . __( 'Subscription Information under Contract with a credit card', 'usces' ) . "\r\n"
6281 . $message
6282 . '--------------------------------' . "\r\n\r\n";
6283 }
6284 }
6285 return $message;
6286 }
6287
6288 /**
6289 * 日付チェック
6290 *
6291 * @param object $date DateTime.
6292 * @return boolean
6293 */
6294 private function isdate( $date ) {
6295 if ( empty( $date ) ) {
6296 return false;
6297 }
6298 try {
6299 new DateTime( $date );
6300 list( $year, $month, $day ) = explode( '-', $date );
6301 $res = checkdate( (int) $month, (int) $day, (int) $year );
6302 return $res;
6303 } catch ( Exception $e ) {
6304 return false;
6305 }
6306 }
6307
6308 /**
6309 * 会員データ削除チェック
6310 * usces_filter_delete_member_check
6311 *
6312 * @param bool $del Deletable.
6313 * @param int $member_id Member ID.
6314 * @return bool
6315 */
6316 public function delete_member_check( $del, $member_id ) {
6317 if ( usces_have_member_continue_order( $member_id ) || usces_have_member_regular_order( $member_id ) ) {
6318 $del = false;
6319 }
6320 return $del;
6321 }
6322
6323 /**
6324 * 利用可能な支払方法(継続課金・定期購�
6325 �)
6326 * dlseller_filter_the_payment_method_restriction
6327 * wcad_filter_the_payment_method_restriction
6328 *
6329 * @param array $payments_restriction Payment method.
6330 * @param string $value Input value.
6331 * @return array
6332 */
6333 public function payment_method_restriction( $payments_restriction, $value ) {
6334 if ( ( usces_have_regular_order() || usces_have_continue_charge() ) && usces_is_login() ) {
6335 $zeus_card = false;
6336 foreach ( (array) $payments_restriction as $key => $payment ) {
6337 if ( isset( $payment['settlement'] ) && 'acting_zeus_card' === $payment['settlement'] ) {
6338 $zeus_card = true;
6339 }
6340 }
6341 if ( ! $zeus_card ) {
6342 $payments = usces_get_system_option( 'usces_payment_method', 'settlement' );
6343 $payments_restriction[] = $payments['acting_zeus_card'];
6344 }
6345 $sort = array();
6346 foreach ( (array) $payments_restriction as $key => $payment ) {
6347 $sort[ $key ] = $payment['sort'];
6348 }
6349 array_multisort( $sort, SORT_ASC, $payments_restriction );
6350 }
6351 return $payments_restriction;
6352 }
6353
6354 /**
6355 * 利用可能な支払方法
6356 * usces_filter_the_continue_payment_method
6357 *
6358 * @param array $payment_method Payment method.
6359 * @return array
6360 */
6361 public function continuation_payment_method( $payment_method ) {
6362 if ( ! array_key_exists( 'acting_zeus_card', $payment_method ) ) {
6363 $payment_method[] = 'acting_zeus_card';
6364 }
6365 return $payment_method;
6366 }
6367
6368 /**
6369 * 「初回引落し日」
6370 * dlseller_filter_first_charging
6371 *
6372 * @param object $time Datetime.
6373 * @param int $post_id Post ID.
6374 * @param array $usces_item Item data.
6375 * @param int $order_id Order number.
6376 * @param array $continue_data Continuation data.
6377 * @return object
6378 */
6379 public function first_charging_date( $time, $post_id, $usces_item, $order_id, $continue_data ) {
6380 if ( 99 === (int) $usces_item['item_chargingday'] ) {
6381 if ( empty( $order_id ) ) {
6382 $today = date_i18n( 'Y-m-d', current_time( 'timestamp' ) );
6383 list( $year, $month, $day ) = explode( '-', $today );
6384 $time = mktime( 0, 0, 0, (int) $month, (int) $day, (int) $year );
6385 }
6386 }
6387 return $time;
6388 }
6389
6390 /**
6391 * 継続課金会員リスト「状�
6392 �」
6393 * dlseller_filter_continue_member_list_condition
6394 *
6395 * @param string $condition Continuation condition.
6396 * @param int $member_id Member ID.
6397 * @param int $order_id Order number.
6398 * @param array $continue_data Continuation data.
6399 * @return string
6400 */
6401 public function continue_member_list_condition( $condition, $member_id, $order_id, $continue_data ) {
6402 if ( isset( $continue_data['acting'] ) && 'acting_zeus_card' === $continue_data['acting'] ) {
6403 $url = admin_url( 'admin.php?page=usces_continue&continue_action=settlement_zeus_card&member_id=' . esc_attr( $member_id ) . '&order_id=' . esc_attr( $order_id ) );
6404 $condition = '<a href="' . $url . '">' . __( 'Detail', 'usces' ) . '</a>';
6405 if ( 'continuation' === $continue_data['status'] ) {
6406 $latest_log = $this->get_acting_latest_log( $order_id, 0, 'ALL' );
6407 if ( isset( $latest_log['result'] ) && ! in_array( $latest_log['result'], $this->payment_normal_results, true ) ) {
6408 $condition .= '<div class="acting-status zeus-error">' . __( 'Settlement error', 'usces' ) . '</div>';
6409 }
6410 }
6411 }
6412 return $condition;
6413 }
6414
6415 /**
6416 * 継続課金会員決済状況ページ表示
6417 * dlseller_action_continue_member_list_page
6418 *
6419 * @param string $continue_action Continuation action.
6420 */
6421 public function continue_member_list_page( $continue_action ) {
6422 if ( 'settlement_zeus_card' === $continue_action ) {
6423 $member_id = filter_input( INPUT_GET, 'member_id' );
6424 $order_id = filter_input( INPUT_GET, 'order_id' );
6425 if ( ! empty( $member_id ) && ! empty( $order_id ) ) {
6426 $this->continue_member_settlement_info_page( $member_id, $order_id );
6427 exit();
6428 }
6429 }
6430 }
6431
6432 /**
6433 * 継続課金会員決済詳細ページ
6434 *
6435 * @param int $member_id Member ID.
6436 * @param int $order_id Order number.
6437 */
6438 public function continue_member_settlement_info_page( $member_id, $order_id ) {
6439 global $usces;
6440
6441 $order_data = $usces->get_order_data( $order_id, 'direct' );
6442 if ( ! $order_data ) {
6443 return;
6444 }
6445
6446 $acting_flg = $this->get_acting_flg( $order_data['order_payment_name'] );
6447 if ( 'acting_zeus_card' !== $acting_flg ) {
6448 return;
6449 }
6450
6451 $continue_data = $this->get_continuation_data( $member_id, $order_id );
6452 if ( 'acting_zeus_card' !== $continue_data['acting'] ) {
6453 return;
6454 }
6455
6456 $con_id = $continue_data['con_id'];
6457 $curent_url = $_SERVER['REQUEST_URI'];
6458
6459 $member_info = $usces->get_member_info( $member_id );
6460 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
6461
6462 $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
6463 if ( ! empty( $contracted_date ) ) {
6464 list( $contracted_year, $contracted_month, $contracted_day ) = explode( '-', $contracted_date );
6465 } else {
6466 $contracted_year = 0;
6467 $contracted_month = 0;
6468 $contracted_day = 0;
6469 }
6470 $charged_date = ( empty( $continue_data['chargedday'] ) ) ? dlseller_next_charging( $order_id ) : $continue_data['chargedday'];
6471 if ( ! empty( $charged_date ) ) {
6472 list( $charged_year, $charged_month, $charged_day ) = explode( '-', $charged_date );
6473 } else {
6474 $charged_year = 0;
6475 $charged_month = 0;
6476 $charged_day = 0;
6477 }
6478 $this_year = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 4 );
6479
6480 $log_data = $this->get_acting_log( $order_id, 0, 'ALL' );
6481 $num = ( $log_data ) ? count( $log_data ) : 1;
6482 ?>
6483 <div class="wrap">
6484 <div class="usces_admin">
6485 <h1>Welcart Management <?php esc_html_e( 'Continuation charging member information', 'dlseller' ); ?></h1>
6486 <p class="version_info">Version <?php echo esc_html( WCEX_DLSELLER_VERSION ); ?></p>
6487 <?php usces_admin_action_status(); ?>
6488 <div class="edit_pagenav"><a href="<?php echo esc_url( $_SERVER['HTTP_REFERER'] ); ?>" class="back-list"><span class="dashicons dashicons-list-view"></span><?php esc_html_e( 'Back to the continue members list', 'dlseller' ); ?></a></div>
6489 <div id="datatable">
6490 <div id="tablesearch" class="usces_tablesearch">
6491 <div id="searchBox" style="display:block">
6492 <table class="search_table">
6493 <tr>
6494 <td class="label"><?php esc_html_e( 'Continuation charging information', 'dlseller' ); ?></td>
6495 <td>
6496 <table class="order_info">
6497 <tr>
6498 <th><?php esc_html_e( 'Member ID', 'dlseller' ); ?></th>
6499 <td><?php echo esc_html( $member_id ); ?></td>
6500 <th><?php esc_html_e( 'Contractor name', 'dlseller' ); ?></th>
6501 <td><?php echo esc_html( $name ); ?></td>
6502 </tr>
6503 <tr>
6504 <th><?php esc_html_e( 'Order ID', 'dlseller' ); ?></th>
6505 <td><?php echo esc_html( $order_id ); ?></td>
6506 <th><?php esc_html_e( 'Application Date', 'dlseller' ); ?></th>
6507 <td><?php echo esc_html( $order_data['order_date'] ); ?></td>
6508 </tr>
6509 <tr>
6510 <th><?php esc_html_e( 'Renewal Date', 'dlseller' ); ?></th>
6511 <td>
6512 <?php
6513 echo '<select id="contracted-year">';
6514 echo '<option value="0"' . selected( (int) $contracted_year, 0, false ) . '></option>';
6515 for ( $i = 0; $i <= 10; $i++ ) {
6516 $year = (int) $this_year + $i;
6517 echo '<option value="' . esc_html( $year ) . '"' . selected( (int) $contracted_year, $year, false ) . '>' . esc_html( $year ) . '</option>';
6518 }
6519 echo '</select>-<select id="contracted-month">';
6520 echo '<option value="0"' . selected( (int) $contracted_month, 0, false ) . '></option>';
6521 for ( $i = 1; $i <= 12; $i++ ) {
6522 $month = sprintf( '%02d', $i );
6523 echo '<option value="' . esc_html( $month ) . '"' . selected( (int) $contracted_month, $i, false ) . '>' . esc_html( $month ) . '</option>';
6524 }
6525 echo '</select>-<select id="contracted-day">';
6526 echo '<option value="0"' . selected( (int) $contracted_day, 0, false ) . '></option>';
6527 for ( $i = 1; $i <= 31; $i++ ) {
6528 $day = sprintf( '%02d', $i );
6529 echo '<option value="' . esc_html( $day ) . '"' . selected( (int) $contracted_day, $i, false ) . '>' . esc_html( $day ) . '</option>';
6530 }
6531 echo '</select>';
6532 ?>
6533 </td>
6534 <th><?php esc_html_e( 'Next Withdrawal Date', 'dlseller' ); ?></th>
6535 <td>
6536 <?php
6537 echo '<select id="charged-year">';
6538 echo '<option value="0"' . selected( (int) $charged_year, 0, false ) . '></option>';
6539 echo '<option value="' . esc_html( $this_year ) . '"' . selected( (int) $charged_year, $this_year, false ) . '>' . esc_html( $this_year ) . '</option>';
6540 $next_year = (int) $this_year + 1;
6541 echo '<option value="' . esc_html( $next_year ) . '"' . selected( (int) $charged_year, $next_year, false ) . '>' . esc_html( $next_year ) . '</option>';
6542 echo '</select>-<select id="charged-month">';
6543 echo '<option value="0"' . selected( (int) $charged_month, 0, false ) . '></option>';
6544 for ( $i = 1; $i <= 12; $i++ ) {
6545 $month = sprintf( '%02d', $i );
6546 echo '<option value="' . esc_html( $month ) . '"' . selected( (int) $charged_month, $i, false ) . '>' . esc_html( $month ) . '</option>';
6547 }
6548 echo '</select>-<select id="charged-day">';
6549 echo '<option value="0"' . selected( (int) $charged_day, 0, false ) . '></option>';
6550 for ( $i = 1; $i <= 31; $i++ ) {
6551 $day = sprintf( '%02d', $i );
6552 echo '<option value="' . esc_html( $day ) . '"' . selected( (int) $charged_day, $i, false ) . '>' . esc_html( $day ) . '</option>';
6553 }
6554 echo '</select>';
6555 ?>
6556 </td>
6557 </tr>
6558 <tr>
6559 <th><?php esc_html_e( 'Amount on order', 'usces' ); ?></th>
6560 <td><?php usces_crform( $continue_data['order_price'], false ); ?></td>
6561 <th><?php esc_html_e( 'Transaction amount', 'usces' ); ?></th>
6562 <td><input type="text" class="amount" id="price" style="text-align: right;" value="<?php usces_crform( $continue_data['price'], false, false, '', false ); ?>"><?php usces_crcode(); ?></td>
6563 </tr>
6564 <tr>
6565 <th><?php esc_html_e( 'Status', 'dlseller' ); ?></th>
6566 <td><select id="dlseller-status">
6567 <?php ob_start(); ?>
6568 <?php if ( 'continuation' === $continue_data['status'] ) : ?>
6569 <option value="continuation" selected><?php esc_html_e( 'Continuation', 'dlseller' ); ?></option>
6570 <option value="cancellation"><?php esc_html_e( 'Stop', 'dlseller' ); ?></option>
6571 <?php else : ?>
6572 <option value="cancellation" selected><?php esc_html_e( 'Cancellation', 'dlseller' ); ?></option>
6573 <option value="continuation"><?php esc_html_e( 'Resumption', 'dlseller' ); ?></option>
6574 <?php endif; ?>
6575 <?php
6576 $dlseller_status_options = ob_get_contents();
6577 ob_end_clean();
6578 $dlseller_status_options = apply_filters( 'usces_filter_continuation_charging_status_options', $dlseller_status_options, $continue_data );
6579 wel_esc_script_e( $dlseller_status_options );
6580 ?>
6581 </select></td>
6582 <td colspan="2"><input id="continuation-update" type="button" class="button button-primary" value="<?php esc_attr_e( 'Update' ); ?>" /></td>
6583 </tr>
6584 </table>
6585 <?php do_action( 'usces_action_continuation_charging_information', $continue_data, $member_id, $order_id ); ?>
6586 </td>
6587 </tr>
6588 </table>
6589 </div><!-- searchBox -->
6590 </div><!-- tablesearch -->
6591 <table id="mainDataTable" class="new-table order-new-table">
6592 <thead>
6593 <tr>
6594 <th scope="col">&nbsp;</th>
6595 <th scope="col"><?php esc_html_e( 'Processing date', 'usces' ); ?></th>
6596 <th scope="col">オーダーNo</th>
6597 <th scope="col"><?php esc_html_e( 'Settlement amount', 'usces' ); ?></th>
6598 <th scope="col"><?php esc_html_e( 'Processing classification', 'usces' ); ?></th>
6599 <th scope="col">&nbsp;</th>
6600 </tr>
6601 </thead>
6602 <?php
6603 foreach ( (array) $log_data as $data ) :
6604 $log = usces_unserialize( $data['log'] );
6605 $order_no = $this->get_order_no( $log );
6606 $tracking_id = $data['tracking_id'];
6607 $status = $this->get_acting_status( $order_id, $tracking_id, 'ALL' );
6608 $class = ' card-' . $status;
6609 $status_name = $this->get_status_name( $status );
6610 $amount = usces_crform( $data['amount'], false, true, 'return', true );
6611 ?>
6612 <tbody>
6613 <tr>
6614 <td><?php echo esc_html( $num ); ?></td>
6615 <td><?php echo esc_html( $data['datetime'] ); ?></td>
6616 <td><?php echo esc_html( $order_no ); ?></td>
6617 <td class="amount"><?php echo esc_attr( $amount ); ?></td>
6618 <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>
6619 <td>
6620 <input type="button" class="button settlement-information" id="settlement-information-<?php echo esc_attr( $tracking_id ); ?>" data-tracking_id="<?php echo esc_attr( $tracking_id ); ?>" data-num="<?php echo esc_attr( $num ); ?>" value="<?php esc_attr_e( 'Settlement info', 'usces' ); ?>">
6621 </td>
6622 </tr>
6623 </tbody>
6624 <?php
6625 $num--;
6626 endforeach;
6627 ?>
6628 </table>
6629 </div><!--datatable-->
6630 <input name="member_id" type="hidden" id="member_id" value="<?php echo esc_attr( $member_id ); ?>" />
6631 <input name="order_id" type="hidden" id="order_id" value="<?php echo esc_attr( $order_id ); ?>" />
6632 <input name="con_id" type="hidden" id="con_id" value="<?php echo esc_attr( $con_id ); ?>" />
6633 <input name="usces_referer" type="hidden" id="usces_referer" value="<?php echo esc_url( $curent_url ); ?>" />
6634 <?php wp_nonce_field( 'order_edit', 'wc_nonce' ); ?>
6635 </div><!--usces_admin-->
6636 </div><!--wrap-->
6637 <?php
6638 $order_action = 'edit';
6639 $cart = array();
6640 $action_args = compact( 'order_action', 'order_id', 'cart' );
6641 $this->settlement_dialog( $order_data, $action_args );
6642 include ABSPATH . 'wp-admin/admin-footer.php';
6643 }
6644
6645 /**
6646 * 自動継続課金処理
6647 * dlseller_action_do_continuation_charging
6648 *
6649 * @param string $today Today.
6650 * @param int $member_id Member ID.
6651 * @param int $order_id Order number.
6652 * @param array $continue_data Continuation data.
6653 */
6654 public function auto_continuation_charging( $today, $member_id, $order_id, $continue_data ) {
6655 global $usces;
6656
6657 if ( ! usces_is_membersystem_state() || 0 >= $continue_data['price'] || 'acting_zeus_card' !== $continue_data['acting'] ) {
6658 return;
6659 }
6660
6661 $order_data = $usces->get_order_data( $order_id, 'direct' );
6662 if ( ! $order_data || $usces->is_status( 'cancel', $order_data['order_status'] ) ) {
6663 return;
6664 }
6665
6666 $acting_opts = $this->get_acting_settings();
6667 if ( 'on' !== $acting_opts['quickcharge'] || 'on' !== $acting_opts['batch'] ) {
6668 return;
6669 }
6670
6671 $tracking_id = usces_acting_key();
6672 $amount = usces_crform( $continue_data['price'], false, false, 'return', false );
6673
6674 $params = array();
6675 $params['clientip'] = $acting_opts['clientip'];
6676 $params['cardnumber'] = '9999999999999992';
6677 $params['expyy'] = '00';
6678 $params['expmm'] = '00';
6679 $params['money'] = $amount;
6680 $params['send'] = 'mall';
6681 $params['telno'] = '0000000000';
6682 $params['email'] = $this->get_email( $order_id );
6683 $params['sendid'] = $member_id;
6684 $params['sendpoint'] = $tracking_id;
6685 $params['pubsec'] = 'yes';
6686 $params['printord'] = 'yes';
6687
6688 $page = $this->secure_link_batch( $acting_opts['card_url'], $params );
6689 if ( false !== strpos( $page, 'Success_order' ) ) {
6690 $status = 'OK';
6691 $data = array( 'result' => 'OK' );
6692 $new_order_no = $this->get_order_number( $page );
6693 if ( ! empty( $new_order_no ) ) {
6694 $order_ref = wel_zeus_get_order_ref( $new_order_no );
6695 if ( 'payment' === $order_ref['status'] || 'auth' === $order_ref['status'] ) {
6696 $order_ref = apply_filters( 'usces_filter_zeus_card_auto_continuation_charging_log', $order_ref, $order_id, $tracking_id );
6697 wel_zeus_save_acting_log( $order_ref, 'zeus_card', $order_ref['status'], $status, $order_id, $tracking_id );
6698 $this->auto_settlement_mail( $member_id, $order_id, $data, $continue_data );
6699 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $order_ref );
6700 } else {
6701 if ( ! isset( $params['ordd'] ) ) {
6702 $params['ordd'] = $new_order_no;
6703 }
6704 $params = apply_filters( 'usces_filter_zeus_card_auto_continuation_charging_log', $params, $order_id, $tracking_id );
6705 wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
6706 $this->auto_settlement_mail( $member_id, $order_id, $data, $continue_data );
6707 $order_ref = wel_zeus_get_order_ref( $new_order_no );
6708 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $params );
6709 }
6710 } else {
6711 $params = apply_filters( 'usces_filter_zeus_card_auto_continuation_charging_log', $params, $order_id, $tracking_id );
6712 wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
6713 $this->auto_settlement_mail( $member_id, $order_id, $data, $continue_data );
6714 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $params );
6715 }
6716 } else {
6717 $status = $this->get_error_results( $page );
6718 if ( empty( $status ) ) {
6719 $status = 'ERROR';
6720 }
6721 $data = explode( "\r\n", $page );
6722 $log = array(
6723 'acting' => 'zeus_card',
6724 'key' => $tracking_id,
6725 'result' => $status,
6726 'data' => $data,
6727 );
6728 usces_save_order_acting_error( $log );
6729 wel_zeus_save_acting_log( $data, 'zeus_card', 'dlseller', $status, $order_id, $tracking_id );
6730 $this->auto_settlement_error_mail( $member_id, $order_id, array( 'result' => $status ), $continue_data );
6731 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $data );
6732 }
6733 }
6734
6735 /**
6736 * 自動継続課金処理メール(正常)
6737 *
6738 * @param int $member_id Member ID.
6739 * @param int $order_id Order number.
6740 * @param array $response_data Response data.
6741 * @param array $continue_data Continuation data.
6742 */
6743 public function auto_settlement_mail( $member_id, $order_id, $response_data, $continue_data ) {
6744 global $usces;
6745
6746 $acting_opts = $this->get_acting_settings();
6747 $order_data = $usces->get_order_data( $order_id, 'direct' );
6748 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data, false );
6749
6750 if ( 'on' === $acting_opts['auto_settlement_mail'] ) {
6751 $subject = apply_filters( 'usces_filter_zeus_auto_settlement_mail_subject', __( 'Announcement of automatic continuing charging process', 'usces' ), $member_id, $order_id, $order_data, $response_data, $continue_data );
6752 $member_info = $usces->get_member_info( $member_id );
6753 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
6754 $mail_data = usces_mail_data();
6755 $mail_header = '';
6756 if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
6757 $mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
6758 }
6759 $mail_header .= __( 'We will report automated accounting process was carried out as follows.', 'usces' ) . "\r\n\r\n";
6760 $mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
6761 $message = apply_filters( 'usces_filter_zeus_auto_settlement_mail_header', $mail_header, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
6762 apply_filters( 'usces_filter_zeus_auto_settlement_mail_body', $mail_body, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
6763 apply_filters( 'usces_filter_zeus_auto_settlement_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $response_data, $continue_data );
6764 $headers = apply_filters( 'usces_filter_zeus_auto_settlement_mail_headers', '' );
6765 $to_customer = array(
6766 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
6767 'to_address' => $member_info['mem_email'],
6768 'from_name' => get_option( 'blogname' ),
6769 'from_address' => $usces->options['sender_mail'],
6770 'reply_name' => get_option( 'blogname' ),
6771 'reply_to' => usces_get_first_order_mail(),
6772 'return_path' => $usces->options['sender_mail'],
6773 'subject' => $subject,
6774 'message' => do_shortcode( $message ),
6775 'headers' => $headers,
6776 );
6777 usces_send_mail( $to_customer );
6778 }
6779
6780 $ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
6781 $this->continuation_charging_mail['OK'] = $ok + 1;
6782 $this->continuation_charging_mail['mail'][] = $mail_body;
6783 }
6784
6785 /**
6786 * 自動継続課金処理メール(エラー)
6787 *
6788 * @param int $member_id Member ID.
6789 * @param int $order_id Order number.
6790 * @param array $response_data Response data.
6791 * @param array $continue_data Continuation data.
6792 */
6793 public function auto_settlement_error_mail( $member_id, $order_id, $response_data, $continue_data ) {
6794 global $usces;
6795
6796 $acting_opts = $this->get_acting_settings();
6797 $order_data = $usces->get_order_data( $order_id, 'direct' );
6798 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data, false );
6799
6800 if ( 'on' === $acting_opts['auto_settlement_mail'] ) {
6801 $subject = apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_subject', __( 'Announcement of automatic continuing charging process', 'usces' ), $member_id, $order_id, $order_data, $response_data, $continue_data );
6802 $member_info = $usces->get_member_info( $member_id );
6803 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
6804 $mail_data = usces_mail_data();
6805 $mail_header = '';
6806 if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
6807 $mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
6808 }
6809 $mail_header .= __( 'We will reported that an error occurred in automated accounting process.', 'usces' ) . "\r\n\r\n";
6810 $mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
6811 $message = apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_header', $mail_header, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
6812 apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_body', $mail_body, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
6813 apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $response_data, $continue_data );
6814 $headers = apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_headers', '' );
6815 $to_customer = array(
6816 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
6817 'to_address' => $member_info['mem_email'],
6818 'from_name' => get_option( 'blogname' ),
6819 'from_address' => $usces->options['sender_mail'],
6820 'reply_name' => get_option( 'blogname' ),
6821 'reply_to' => usces_get_first_order_mail(),
6822 'return_path' => $usces->options['sender_mail'],
6823 'subject' => $subject,
6824 'message' => do_shortcode( $message ),
6825 'headers' => $headers,
6826 );
6827 usces_send_mail( $to_customer );
6828 }
6829
6830 $error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
6831 $this->continuation_charging_mail['NG'] = $error + 1;
6832 $this->continuation_charging_mail['mail'][] = $mail_body;
6833 }
6834
6835 /**
6836 * 自動継続課金処理メール本文
6837 *
6838 * @param int $member_id Member ID.
6839 * @param int $order_id Order number.
6840 * @param array $order_data Order data.
6841 * @param array $data Response data.
6842 * @param array $continue_data Continuation data.
6843 * @param boolean $html HTML mail.
6844 * @return string
6845 */
6846 public function auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data, $html = true ) {
6847 global $usces;
6848
6849 $member_info = $usces->get_member_info( $member_id );
6850 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
6851 $contracted_date = ( isset( $continue_data['contractedday'] ) ) ? $continue_data['contractedday'] : '';
6852 $charged_date = ( isset( $continue_data['chargedday'] ) ) ? $continue_data['chargedday'] : '';
6853
6854 $cart = usces_get_ordercartdata( $order_id );
6855 if ( is_array( $cart ) && 0 < count( $cart ) ) {
6856 $cart_row = current( $cart );
6857 $item_name = $usces->getCartItemName_byOrder( $cart_row );
6858 $options = ( isset( $cart_row['options'] ) ) ? $cart_row['options'] : array();
6859 }
6860
6861 if ( usces_is_html_mail() && $html ) {
6862 $message = '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;"><tbody>';
6863 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6864 $message .= __( 'Order ID', 'dlseller' );
6865 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6866 $message .= $order_id;
6867 $message .= '</td></tr>';
6868
6869 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6870 $message .= __( 'Application Date', 'dlseller' );
6871 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6872 $message .= $order_data['order_date'];
6873 $message .= '</td></tr>';
6874
6875 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6876 $message .= __( 'Member ID', 'dlseller' );
6877 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6878 $message .= $member_id;
6879 $message .= '</td></tr>';
6880
6881 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6882 $message .= __( 'Contractor name', 'dlseller' );
6883 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6884 $message .= sprintf( _x( '%s', 'honorific', 'usces' ), $name );
6885 $message .= '</td></tr>';
6886 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6887 $message .= __( 'Items', 'usces' );
6888 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6889 $message .= $item_name;
6890 if ( is_array( $options ) && 0 < count( $options ) ) {
6891 $optstr = '';
6892 foreach ( $options as $key => $value ) {
6893 if ( ! empty( $key ) ) {
6894 $key = urldecode( $key );
6895 $value = maybe_unserialize( $value );
6896 if ( is_array( $value ) ) {
6897 $c = '';
6898 $optstr .= '( ' . $key . ' : ';
6899 foreach ( $value as $v ) {
6900 $optstr .= $c . rawurldecode( $v );
6901 $c = ', ';
6902 }
6903 $optstr .= ' )<br>';
6904 } else {
6905 $optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . ' )<br>';
6906 }
6907 }
6908 }
6909 $message .= $optstr;
6910 }
6911 $message .= '</td></tr>';
6912
6913 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6914 $message .= __( 'Settlement amount', 'usces' );
6915 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6916 $message .= usces_crform( $continue_data['price'], true, false, 'return' );
6917 $message .= '</td></tr>';
6918 if ( isset( $data['reminder'] ) ) {
6919 if ( ! empty( $charged_date ) ) {
6920 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6921 $message .= __( 'Next Withdrawal Date', 'dlseller' );
6922 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6923 $message .= $charged_date;
6924 $message .= '</td></tr>';
6925 }
6926 if ( ! empty( $contracted_date ) ) {
6927 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6928 $message .= __( 'Renewal Date', 'dlseller' );
6929 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6930 $message .= $contracted_date;
6931 $message .= '</td></tr>';
6932 }
6933 } else {
6934 if ( ! empty( $charged_date ) ) {
6935 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6936 $message .= __( 'Next Withdrawal Date', 'dlseller' );
6937 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6938 $message .= $charged_date;
6939 $message .= '</td></tr>';
6940 }
6941 if ( ! empty( $contracted_date ) ) {
6942 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6943 $message .= __( 'Renewal Date', 'dlseller' );
6944 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6945 $message .= $contracted_date;
6946 $message .= '</td></tr>';
6947 }
6948 if ( isset( $data['result'] ) && in_array( $data['result'], $this->payment_normal_results, true ) ) {
6949 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6950 $message .= __( 'Result', 'usces' );
6951 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6952 $message .= __( 'Normal done', 'usces' );
6953 $message .= '</td></tr>';
6954 } else {
6955 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6956 $message .= __( 'Result', 'usces' );
6957 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6958 $message .= __( 'Error', 'usces' );
6959 $message .= '</td></tr>';
6960 }
6961 }
6962 $message .= '</tbody></table>';
6963
6964 } else {
6965 $message = usces_mail_line( 2 ); // --------------------
6966 $message .= __( 'Order ID', 'dlseller' ) . ' : ' . $order_id . "\r\n";
6967 $message .= __( 'Application Date', 'dlseller' ) . ' : ' . $order_data['order_date'] . "\r\n";
6968 $message .= __( 'Member ID', 'dlseller' ) . ' : ' . $member_id . "\r\n";
6969 $message .= __( 'Contractor name', 'dlseller' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
6970
6971 $message .= __( 'Items', 'usces' ) . ' : ' . $item_name . "\r\n";
6972 if ( is_array( $options ) && 0 < count( $options ) ) {
6973 $optstr = '';
6974 foreach ( $options as $key => $value ) {
6975 if ( ! empty( $key ) ) {
6976 $key = urldecode( $key );
6977 $value = maybe_unserialize( $value );
6978 if ( is_array( $value ) ) {
6979 $c = '';
6980 $optstr .= '( ' . $key . ' : ';
6981 foreach ( $value as $v ) {
6982 $optstr .= $c . rawurldecode( $v );
6983 $c = ', ';
6984 }
6985 $optstr .= " )\r\n";
6986 } else {
6987 $optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . " )\r\n";
6988 }
6989 }
6990 }
6991 $message .= $optstr;
6992 }
6993
6994 $message .= __( 'Settlement amount', 'usces' ) . ' : ' . usces_crform( $continue_data['price'], true, false, 'return' ) . "\r\n";
6995 if ( ! empty( $charged_date ) ) {
6996 $message .= __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . $charged_date . "\r\n";
6997 }
6998 if ( ! empty( $contracted_date ) ) {
6999 $message .= __( 'Renewal Date', 'dlseller' ) . ' : ' . $contracted_date . "\r\n";
7000 }
7001 if ( isset( $data['reminder'] ) ) {
7002 } else {
7003 $message .= "\r\n";
7004 if ( isset( $data['result'] ) && in_array( $data['result'], $this->payment_normal_results, true ) ) {
7005 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Normal done', 'usces' ) . "\r\n";
7006 } else {
7007 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Error', 'usces' ) . "\r\n";
7008 }
7009 }
7010 $message .= usces_mail_line( 2 ) . "\r\n"; // --------------------
7011 }
7012 return $message;
7013 }
7014
7015 /**
7016 * 自動継続課金処理
7017 * dlseller_action_do_continuation
7018 *
7019 * @param string $today Today.
7020 * @param array $todays_charging Charged data.
7021 */
7022 public function do_auto_continuation( $today, $todays_charging ) {
7023 global $usces;
7024
7025 if ( empty( $todays_charging ) ) {
7026 return;
7027 }
7028
7029 $ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
7030 $error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
7031 $admin_subject = apply_filters( 'usces_filter_zeus_autobilling_email_admin_subject', __( 'Automatic Continuing Charging Process Result', 'usces' ) . ' ' . $today, $today );
7032 $admin_footer = apply_filters( 'usces_filter_zeus_autobilling_email_admin_mail_footer', __( 'For details, please check on the administration panel > Continuous charge member list > Continuous charge member information.', 'usces' ) );
7033 $admin_message = __( 'Report that automated accounting process has been completed.', 'usces' ) . "\r\n\r\n"
7034 . __( 'Processing date', 'usces' ) . ' : ' . wp_date( 'Y-m-d H:i:s' ) . "\r\n"
7035 . __( 'Normal done', 'usces' ) . ' : ' . $ok . "\r\n"
7036 . __( 'Abnormal done', 'usces' ) . ' : ' . $error . "\r\n\r\n";
7037 foreach ( (array) $this->continuation_charging_mail['mail'] as $mail ) {
7038 $admin_message .= $mail . "\r\n";
7039 }
7040 $admin_message .= $admin_footer . "\r\n";
7041
7042 $to_admin = array(
7043 'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
7044 'to_address' => $usces->options['order_mail'],
7045 'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
7046 'from_address' => $usces->options['sender_mail'],
7047 'reply_name' => get_option( 'blogname' ),
7048 'reply_to' => usces_get_first_order_mail(),
7049 'return_path' => $usces->options['sender_mail'],
7050 'subject' => $admin_subject,
7051 'message' => do_shortcode( $admin_message ),
7052 );
7053 usces_send_mail( $to_admin );
7054 unset( $this->continuation_charging_mail );
7055 }
7056
7057 /**
7058 * 課金日通知メール
7059 * dlseller_filter_reminder_mail_body
7060 *
7061 * @param string $mail_body Message body.
7062 * @param int $order_id Order number.
7063 * @param array $continue_data Continuation data.
7064 * @return string
7065 */
7066 public function reminder_mail_body( $mail_body, $order_id, $continue_data ) {
7067 global $usces;
7068
7069 $member_id = $continue_data['member_id'];
7070 $order_id = $continue_data['order_id'];
7071 $order_data = $usces->get_order_data( $order_id, 'direct' );
7072 $data = array( 'reminder' => 'reminder' );
7073 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data );
7074 return $mail_body;
7075 }
7076
7077 /**
7078 * 契約更新日通知メール
7079 * dlseller_filter_contract_renewal_mail_body
7080 *
7081 * @param string $mail_body Message body.
7082 * @param int $order_id Order number.
7083 * @param array $continue_data Continuation data.
7084 * @return string
7085 */
7086 public function contract_renewal_mail_body( $mail_body, $order_id, $continue_data ) {
7087 global $usces;
7088
7089 $member_id = $continue_data['member_id'];
7090 $order_data = $usces->get_order_data( $order_id, 'direct' );
7091 $data = array( 'reminder' => 'contract_renewal' );
7092 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data );
7093 return $mail_body;
7094 }
7095
7096 /**
7097 * 継続課金会員データ取得
7098 *
7099 * @param int $member_id Member ID.
7100 * @param int $order_id Order number.
7101 * @return array
7102 */
7103 private function get_continuation_data( $member_id, $order_id ) {
7104 global $wpdb;
7105
7106 $query = $wpdb->prepare(
7107 "SELECT
7108 `con_id` AS `con_id`,
7109 `con_acting` AS `acting`,
7110 `con_order_price` AS `order_price`,
7111 `con_price` AS `price`,
7112 `con_next_charging` AS `chargedday`,
7113 `con_next_contracting` AS `contractedday`,
7114 `con_startdate` AS `startdate`,
7115 `con_status` AS `status`
7116 FROM {$wpdb->prefix}usces_continuation
7117 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7118 $order_id,
7119 $member_id
7120 );
7121 $data = $wpdb->get_row( $query, ARRAY_A );
7122 return $data;
7123 }
7124
7125 /**
7126 * 継続課金会員データ更新
7127 *
7128 * @param int $member_id Member ID.
7129 * @param int $order_id Order number.
7130 * @param array $data Continuation data.
7131 * @param boolean $stop Stop continuous billing.
7132 * @return boolean
7133 */
7134 private function update_continuation_data( $member_id, $order_id, $data, $stop = false ) {
7135 global $wpdb;
7136
7137 if ( $stop ) {
7138 $query = $wpdb->prepare(
7139 "UPDATE {$wpdb->prefix}usces_continuation SET
7140 `con_status` = 'cancellation'
7141 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7142 $order_id,
7143 $member_id
7144 );
7145 } else {
7146 $query = $wpdb->prepare(
7147 "UPDATE {$wpdb->prefix}usces_continuation SET
7148 `con_price` = %f,
7149 `con_next_charging` = %s,
7150 `con_next_contracting` = %s,
7151 `con_status` = %s
7152 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7153 $data['price'],
7154 $data['chargedday'],
7155 $data['contractedday'],
7156 $data['status'],
7157 $order_id,
7158 $member_id
7159 );
7160 }
7161 $res = $wpdb->query( $query );
7162 return $res;
7163 }
7164
7165 /**
7166 * 決済オプション取得
7167 *
7168 * @return array
7169 */
7170 public function get_acting_settings() {
7171 global $usces;
7172
7173 $acting_settings = ( isset( $usces->options['acting_settings'][ $this->paymod_id ] ) ) ? $usces->options['acting_settings'][ $this->paymod_id ] : array();
7174 return apply_filters( 'usces_filter_get_acting_settings_zeus', $acting_settings );
7175 }
7176
7177 /**
7178 * Secure API
7179 * 3D Secure Enrol.
7180 */
7181 public function zeus_3dsecure_enrol() {
7182 global $usces;
7183
7184 check_ajax_referer( 'acting_zeus_card', '_nonce' );
7185
7186 $entry = $usces->cart->get_entry();
7187 if ( empty( $entry ) ) {
7188 $result_data = array(
7189 'action' => 'session',
7190 'status' => 'error',
7191 );
7192 wp_send_json( $result_data );
7193 }
7194
7195 $usces->error_message = $usces->zaiko_check();
7196 if ( '' !== $usces->error_message || 0 === (int) $usces->cart->num_row() ) {
7197 $result_data = array(
7198 'action' => 'stock',
7199 'status' => 'error',
7200 );
7201 wp_send_json( $result_data );
7202 }
7203
7204 $acting_opts = $this->get_acting_settings();
7205 $result_data = array();
7206 if ( $this->is_activate_card( 'api' ) && 1 === (int) $acting_opts['3dsecur'] ) {
7207 $sendid = ( 'on' === $acting_opts['quickcharge'] && isset( $_POST['sendid'] ) ) ? filter_input( INPUT_POST, 'sendid' ) : '';
7208 $sendpoint = filter_input( INPUT_POST, 'sendpoint', FILTER_DEFAULT, array( 'options' => array( 'default' => '' ) ) );
7209 $_nonce = filter_input( INPUT_POST, '_nonce', FILTER_DEFAULT, array( 'options' => array( 'default' => wp_create_nonce( 'acting_zeus_card' ) ) ) );
7210 $uscesid = filter_input( INPUT_GET, 'uscesid', FILTER_DEFAULT, array( 'options' => array( 'default' => $usces->get_uscesid( false ) ) ) );
7211
7212 $data = array();
7213 $data['authentication']['clientip'] = $acting_opts['clientip'];
7214 $data['authentication']['key'] = $acting_opts['authkey'];
7215 if ( 'on' === $acting_opts['quickcharge'] && isset( $_POST['card_option'] ) && 'prev' === filter_input( INPUT_POST, 'card_option' ) && ! empty( $sendid ) ) {
7216 $data['card']['history']['key'] = 'sendid';
7217 $data['card']['history']['action'] = 'send_email';
7218 } elseif ( isset( $_POST['token_key'] ) ) {
7219 $data['token_key'] = filter_input( INPUT_POST, 'token_key' );
7220 }
7221 $data['payment']['amount'] = apply_filters( 'zeus_secure_payreq_amount', usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ), $entry );
7222 if ( isset( $entry['order']['cbrand'] ) && isset( $entry['order']['howpay'] ) && WCUtils::is_zero( $entry['order']['howpay'] ) ) {
7223 $div_name = 'div_' . $entry['order']['cbrand'];
7224 $data['payment']['count'] = $entry['order'][ $div_name ];
7225 } else {
7226 $data['payment']['count'] = '01';
7227 }
7228 $data['user']['telno'] = str_replace( '-', '', $entry['customer']['tel'] );
7229 $data['user']['email'] = $entry['customer']['mailaddress1'];
7230 $data['uniq_key']['sendid'] = $sendid;
7231 $data['uniq_key']['sendpoint'] = $sendpoint;
7232 $data['use_3ds2_flag'] = '1';
7233
7234 // リスクベース認証用追加パラメータ.
7235 $data['cardHolderInfo']['cardholderName'] = filter_input( INPUT_POST, 'card_name' );
7236 $data['cardHolderInfo']['email'] = $entry['customer']['mailaddress1'];
7237
7238 $enrol_req = '<?xml version="1.0" encoding="utf-8"?>';
7239 $enrol_req .= '<request service="secure_link_3d" action="enroll">';
7240 $enrol_req .= $this->assoc2xml( $data );
7241 $enrol_req .= '</request>';
7242
7243 $xml = $this->get_xml( $acting_opts['card_secureurl'], $enrol_req );
7244 if ( empty( $xml ) ) {
7245 $log = array(
7246 'acting' => 'zeus_card_API(3D Enrol)',
7247 'key' => $sendpoint,
7248 'result' => 'EnrolRes Error',
7249 'data' => $enrol_req,
7250 );
7251 usces_save_order_acting_error( $log );
7252 $result_data = array(
7253 'action' => 'EnrolReq',
7254 'status' => 'error',
7255 );
7256 } else {
7257 $enrol_res = $this->xml2assoc( $xml );
7258 if ( 'outside' === $enrol_res['response']['result']['status'] ) {
7259 usces_ordered_acting_data( $sendpoint, 'propriety' );
7260 $result_data = array(
7261 'action' => 'EnrolReq',
7262 'status' => $enrol_res['response']['result']['status'],
7263 'xid' => $enrol_res['response']['xid'],
7264 'code' => $enrol_res['response']['result']['code'],
7265 );
7266 } elseif ( 'success' === $enrol_res['response']['result']['status'] ) {
7267 usces_ordered_acting_data( $sendpoint, 'propriety' );
7268 $term_data = array(
7269 'purchase' => '1',
7270 'sendpoint' => $sendpoint,
7271 '_nonce' => $_nonce,
7272 'uscesid' => $uscesid,
7273 );
7274 $term_url = add_query_arg( $term_data, USCES_CART_URL );
7275 $result_data = array(
7276 'action' => 'EnrolReq',
7277 'status' => $enrol_res['response']['result']['status'],
7278 'MD' => $enrol_res['response']['xid'],
7279 'PaReq' => $enrol_res['response']['redirection']['PaReq'],
7280 'TermUrl' => $term_url,
7281 'threeDSMehtod' => '2',
7282 'iframeUrl' => $enrol_res['response']['iframeUrl'],
7283 );
7284 } else {
7285 $log = array(
7286 'acting' => 'zeus_card_API(3D Enrol)',
7287 'key' => $sendpoint,
7288 'result' => $enrol_res['response']['result']['status'] . ':' . $enrol_res['response']['result']['code'],
7289 'data' => $enrol_res,
7290 );
7291 usces_save_order_acting_error( $log );
7292 $result_data = array(
7293 'action' => 'EnrolReq',
7294 'status' => $enrol_res['response']['result']['status'],
7295 'code' => $enrol_res['response']['result']['code'],
7296 );
7297 }
7298 }
7299 }
7300 wp_send_json( $result_data );
7301 }
7302
7303 /**
7304 * Secure API
7305 * 3D Secure Authentication.
7306 * usces_zeus_3dsecure_auth
7307 * ( call from acting_processing )
7308 */
7309 public function zeus_3dsecure_auth() {
7310 global $usces;
7311
7312 $acting_opts = $this->get_acting_settings();
7313 $sendpoint = filter_input( INPUT_GET, 'sendpoint', FILTER_DEFAULT, array( 'options' => array( 'default' => '' ) ) );
7314 $_nonce = filter_input( INPUT_GET, '_nonce', FILTER_DEFAULT, array( 'options' => array( 'default' => wp_create_nonce( 'acting_zeus_card' ) ) ) );
7315
7316 $request_body = file_get_contents( 'php://input' );
7317 $body = json_decode( $request_body, true );
7318 if ( ! empty( $body['MD'] ) && ! empty( $body['PaRes'] ) && ! empty( $body['status'] ) ) {
7319 if ( 'failure' === $body['status'] || 'invalid' === $body['status'] || 'maintenance' === $body['status'] ) {
7320 $log = array(
7321 'acting' => 'zeus_card_API(3D Auth)',
7322 'key' => $sendpoint,
7323 'result' => 'PaRes Error',
7324 'data' => $body,
7325 );
7326 usces_save_order_acting_error( $log );
7327 wp_redirect(
7328 add_query_arg(
7329 array(
7330 'acting' => 'zeus_card',
7331 'acting_return' => '0',
7332 'status' => $body['status'],
7333 ),
7334 USCES_CART_URL
7335 )
7336 );
7337 exit();
7338 }
7339
7340 $data = array();
7341 $data['xid'] = $body['MD'];
7342 $data['PaRes'] = $body['PaRes'];
7343 $auth_req = '<?xml version="1.0" encoding="utf-8" ?>';
7344 $auth_req .= '<request service="secure_link_3d" action="authentication">';
7345 $auth_req .= $this->assoc2xml( $data );
7346 $auth_req .= '</request>';
7347
7348 $xml = $this->get_xml( $acting_opts['card_secureurl'], $auth_req );
7349 if ( false !== strpos( $xml, 'Invalid' ) ) {
7350 $log = array(
7351 'acting' => 'zeus_card_API(3D Auth)',
7352 'key' => $sendpoint,
7353 'result' => 'AuthReq Error',
7354 'data' => $auth_req,
7355 );
7356 usces_save_order_acting_error( $log );
7357 wp_redirect(
7358 add_query_arg(
7359 array(
7360 'acting' => 'zeus_card',
7361 'acting_return' => '0',
7362 'status' => 'error',
7363 ),
7364 USCES_CART_URL
7365 )
7366 );
7367 exit();
7368 }
7369
7370 $auth_res = $this->xml2assoc( $xml );
7371 if ( 'success' !== $auth_res['response']['result']['status'] ) {
7372 $log = array(
7373 'acting' => 'zeus_card_API(3D Auth)',
7374 'key' => $sendpoint,
7375 'result' => $auth_res['response']['result']['status'] . ':' . $auth_res['response']['result']['code'],
7376 'data' => $auth_res,
7377 );
7378 usces_save_order_acting_error( $log );
7379 wp_redirect(
7380 add_query_arg(
7381 array(
7382 'acting' => 'zeus_card',
7383 'acting_return' => '0',
7384 'status' => $auth_res['response']['result']['status'],
7385 'code' => $auth_res['response']['result']['code'],
7386 ),
7387 USCES_CART_URL
7388 )
7389 );
7390 exit();
7391 }
7392
7393 $data = array();
7394 $data['xid'] = $body['MD'];
7395 $pay_req = '<?xml version="1.0" encoding="utf-8" ?>';
7396 $pay_req .= '<request service="secure_link_3d" action="payment">';
7397 $pay_req .= $this->assoc2xml( $data );
7398 $pay_req .= '</request>';
7399
7400 $xml = $this->get_xml( $acting_opts['card_secureurl'], $pay_req );
7401 if ( empty( $xml ) ) {
7402 $log = array(
7403 'acting' => 'zeus_card_API(3D Auth)',
7404 'key' => $sendpoint,
7405 'result' => 'PayReq Error',
7406 'data' => $pay_req,
7407 );
7408 usces_save_order_acting_error( $log );
7409 wp_redirect(
7410 add_query_arg(
7411 array(
7412 'acting' => 'zeus_card',
7413 'acting_return' => '0',
7414 'status' => 'error',
7415 ),
7416 USCES_CART_URL
7417 )
7418 );
7419 exit();
7420 }
7421
7422 $pay_res = $this->xml2assoc( $xml );
7423 if ( 'success' === $pay_res['response']['result']['status'] ) {
7424 $result_data = array(
7425 'acting' => 'zeus_card',
7426 'acting_return' => '1',
7427 'zeussuffix' => $pay_res['response']['card']['number']['suffix'],
7428 'zeusordd' => $pay_res['response']['order_number'],
7429 'wctid' => $sendpoint,
7430 'auth_code' => $auth_res['response']['result']['code'],
7431 );
7432 $res = $usces->order_processing( $result_data );
7433 if ( 'ordercompletion' === $res ) {
7434 wp_redirect(
7435 add_query_arg(
7436 array(
7437 'acting' => 'zeus_card',
7438 'acting_return' => 1,
7439 'result' => 1,
7440 '_nonce' => $_nonce,
7441 'uscesid' => $usces->get_uscesid( false ),
7442 ),
7443 USCES_CART_URL
7444 )
7445 );
7446 exit();
7447 } else {
7448 $log = array(
7449 'acting' => 'zeus_card',
7450 'key' => $sendpoint,
7451 'result' => 'ORDER DATA REGISTERED ERROR',
7452 'data' => $result_data,
7453 );
7454 usces_save_order_acting_error( $log );
7455 wp_redirect(
7456 add_query_arg(
7457 array(
7458 'acting' => 'zeus_card',
7459 'acting_return' => 0,
7460 'result' => 0,
7461 ),
7462 USCES_CART_URL
7463 )
7464 );
7465 exit();
7466 }
7467 } else {
7468 $log = array(
7469 'acting' => 'zeus_card_API(3D Auth)',
7470 'key' => $sendpoint,
7471 'result' => $pay_res['response']['result']['status'] . ':' . $pay_res['response']['result']['code'],
7472 'data' => $pay_res,
7473 );
7474 usces_save_order_acting_error( $log );
7475 wp_redirect(
7476 add_query_arg(
7477 array(
7478 'acting' => 'zeus_card',
7479 'acting_return' => '0',
7480 'status' => $pay_res['response']['result']['status'],
7481 'code' => $pay_res['response']['result']['code'],
7482 ),
7483 USCES_CART_URL
7484 )
7485 );
7486 exit();
7487 }
7488 }
7489 exit();
7490 }
7491
7492 /**
7493 * Secure API
7494 * Payment Request. (3D Secure Not used.)
7495 * usces_zeus_secure_payreq
7496 * ( call from acting_processing )
7497 */
7498 protected function zeus_secure_payreq() {
7499 global $usces;
7500
7501 $acting_opts = $this->get_acting_settings();
7502 $sendid = ( 'on' == $acting_opts['quickcharge'] && isset( $_POST['sendid'] ) ) ? filter_input( INPUT_POST, 'sendid' ) : '';
7503 $sendpoint = ( isset( $_POST['sendpoint'] ) ) ? filter_input( INPUT_POST, 'sendpoint' ) : '';
7504 $outside = ( isset( $_POST['outside'] ) ) ? filter_input( INPUT_POST, 'outside' ) : '';
7505
7506 $data = array();
7507 $data['authentication']['clientip'] = $acting_opts['clientip'];
7508 $data['authentication']['key'] = $acting_opts['authkey'];
7509 if ( 'on' === $acting_opts['quickcharge'] && isset( $_POST['card_option'] ) && 'prev' === filter_input( INPUT_POST, 'card_option' ) && ! empty( $sendid ) ) {
7510 $data['card']['history']['key'] = 'sendid';
7511 $data['card']['history']['action'] = 'send_email';
7512 } elseif ( isset( $_POST['token_key'] ) ) {
7513 $data['token_key'] = filter_input( INPUT_POST, 'token_key' );
7514 }
7515 $data['payment']['amount'] = apply_filters( 'zeus_secure_payreq_amount', filter_input( INPUT_POST, 'money' ), $entry );
7516 if ( isset( $_POST['howpay'] ) && WCUtils::is_zero( filter_input( INPUT_POST, 'howpay' ) ) ) {
7517 $data['payment']['count'] = filter_input( INPUT_POST, 'div' );
7518 } else {
7519 $data['payment']['count'] = '01';
7520 }
7521 $data['user']['telno'] = str_replace( '-', '', filter_input( INPUT_POST, 'telno' ) );
7522 $data['user']['email'] = filter_input( INPUT_POST, 'email' );
7523 $data['uniq_key']['sendid'] = $sendid;
7524 $data['uniq_key']['sendpoint'] = $sendpoint;
7525
7526 $pay_req = '<?xml version="1.0" encoding="utf-8" ?>';
7527 $pay_req .= '<request service="secure_link" action="payment">';
7528 $pay_req .= $this->assoc2xml( $data );
7529 $pay_req .= '</request>';
7530
7531 $xml = $this->get_xml( $acting_opts['card_secureurl'], $pay_req );
7532 if ( empty( $xml ) ) {
7533 $log = array(
7534 'acting' => 'zeus_card_API',
7535 'key' => $sendpoint,
7536 'result' => 'PayReq Error',
7537 'data' => $pay_req,
7538 );
7539 usces_save_order_acting_error( $log );
7540 wp_redirect(
7541 add_query_arg(
7542 array(
7543 'acting' => 'zeus_card',
7544 'acting_return' => '0',
7545 'status' => 'error',
7546 ),
7547 USCES_CART_URL
7548 )
7549 );
7550 exit();
7551 }
7552
7553 usces_ordered_acting_data( $sendpoint, 'propriety' );
7554
7555 $pay_res = $this->xml2assoc( $xml );
7556 if ( 'success' === $pay_res['response']['result']['status'] ) {
7557 $result_data = array(
7558 'acting' => 'zeus_card',
7559 'zeussuffix' => $pay_res['response']['card']['number']['suffix'],
7560 'zeusordd' => $pay_res['response']['order_number'],
7561 'wctid' => $sendpoint,
7562 );
7563 if ( ! empty( $outside ) ) {
7564 $result_data['auth_code'] = $outside;
7565 }
7566 $res = $usces->order_processing( $result_data );
7567 if ( 'ordercompletion' === $res ) {
7568 $_nonce = ( isset( $_POST['_nonce'] ) ) ? filter_input( INPUT_POST, '_nonce' ) : wp_create_nonce( 'acting_zeus_card' );
7569 wp_redirect(
7570 add_query_arg(
7571 array(
7572 'acting' => 'zeus_card',
7573 'acting_return' => 1,
7574 'result' => 1,
7575 '_nonce' => $_nonce,
7576 ),
7577 USCES_CART_URL
7578 )
7579 );
7580 } else {
7581 $log = array(
7582 'acting' => 'zeus_card',
7583 'key' => $sendpoint,
7584 'result' => 'ORDER DATA REGISTERED ERROR',
7585 'data' => $result_data,
7586 );
7587 usces_save_order_acting_error( $log );
7588 wp_redirect(
7589 add_query_arg(
7590 array(
7591 'acting' => 'zeus_card',
7592 'acting_return' => 0,
7593 'result' => 0,
7594 ),
7595 USCES_CART_URL
7596 )
7597 );
7598 }
7599 exit();
7600 } else {
7601 $log = array(
7602 'acting' => 'zeus_card_API',
7603 'key' => $sendpoint,
7604 'result' => $pay_res['response']['result']['status'] . ':' . $pay_res['response']['result']['code'],
7605 'data' => $pay_res,
7606 );
7607 usces_save_order_acting_error( $log );
7608 wp_redirect(
7609 add_query_arg(
7610 array(
7611 'acting' => 'zeus_card',
7612 'acting_return' => '0',
7613 'status' => $pay_res['response']['result']['status'],
7614 'code' => $pay_res['response']['result']['code'],
7615 ),
7616 USCES_CART_URL
7617 )
7618 );
7619 exit();
7620 }
7621 }
7622
7623 /**
7624 * XML to Association.
7625 * usces_xml2assoc
7626 *
7627 * @param string $xml XML data.
7628 * @return array
7629 */
7630 public function xml2assoc( $xml ) {
7631 $arr = array();
7632 if ( ! preg_match_all( '|\<\s*?(\w+).*?\>(.*)\<\/\s*\\1.*?\>|s', $xml, $m ) ) {
7633 return $xml;
7634 }
7635 if ( is_array( $m[1] ) ) {
7636 for ( $i = 0; $i < sizeof( $m[1] ); $i++ ) {
7637 $arr[ $m[1][ $i ] ] = $this->xml2assoc( $m[2][ $i ] );
7638 }
7639 } else {
7640 $arr[ $m[1] ] = $this->xml2assoc( $m[2] );
7641 }
7642 return $arr;
7643 }
7644
7645 /**
7646 * Association to XML.
7647 * usces_assoc2xml
7648 *
7649 * @param array $prm_array Parameters.
7650 * @return string
7651 */
7652 protected function assoc2xml( $prm_array ) {
7653 $xml = '';
7654 if ( is_array( $prm_array ) ) {
7655 $i = 0;
7656 foreach ( $prm_array as $index => $element ) {
7657 if ( is_array( $element ) ) {
7658 $acts = explode( '_', $index, 3 );
7659 if ( is_array( $acts ) && 2 < count( $acts ) && 'history' === $acts[0] && 'action' === $acts[1] ) {
7660 $xml .= '<history action="' . $acts[2] . '">';
7661 $xml .= $this->assoc2xml( $element );
7662 $xml .= '</history>';
7663 } else {
7664 $xml .= '<' . $index . '>';
7665 $xml .= $this->assoc2xml( $element );
7666 $xml .= '</' . $index . '>';
7667 }
7668 } else {
7669 $xml .= '<' . $index . '>' . $element . '</' . $index . '>';
7670 }
7671 $i++;
7672 if ( $i > 500 ) {
7673 break;
7674 }
7675 }
7676 }
7677 return $xml;
7678 }
7679
7680 /**
7681 * Get XML Response.
7682 * usces_get_xml
7683 *
7684 * @param string $url Connect url.
7685 * @param string $params Sending parameters.
7686 * @return string
7687 */
7688 protected function get_xml( $url, $params ) {
7689 $interface = $this->get_interface( $url );
7690
7691 $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
7692 $header .= 'Host: ' . $interface['host'] . "\r\n";
7693 $header .= "User-Agent: PHP Script\r\n";
7694 $header .= "Content-Type: text/xml\r\n";
7695 $header .= 'Content-Length: ' . strlen( $params ) . "\r\n";
7696 $header .= "Connection: close\r\n\r\n";
7697 $header .= $params;
7698
7699 $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
7700 if ( ! $fp ) {
7701 usces_log( 'zeus API : TLS(v1.2) Error', 'acting_transaction.log' );
7702 }
7703
7704 $xml = '';
7705 if ( $fp ) {
7706 fwrite( $fp, $header );
7707 while ( ! feof( $fp ) ) {
7708 $xml .= fgets( $fp, 1024 );
7709 }
7710 fclose( $fp );
7711 }
7712 return $xml;
7713 }
7714
7715 /**
7716 * Get XML Response.
7717 *
7718 * @param string $url Connect url.
7719 * @param string $params Sending parameters.
7720 * @return string
7721 */
7722 protected function get_xml_bnpl( $url, $params ) {
7723 $args = array(
7724 'method' => 'POST',
7725 'headers' => array(
7726 'Content-Type' => 'application/xml; charset=UTF-8',
7727 'Accept' => 'application/xml; charset=UTF-8',
7728 ),
7729 'body' => $params,
7730 );
7731
7732 $xml = '';
7733 $response = wp_remote_post( $url, $args );
7734 if ( ! is_wp_error( $response ) ) {
7735 $xml = wp_remote_retrieve_body( $response );
7736 }
7737 return $xml;
7738 }
7739
7740 /**
7741 * Secure Link Batch.
7742 *
7743 * @param string $url Connect url.
7744 * @param array $params Sending parameters.
7745 * @return string
7746 */
7747 protected function secure_link_batch( $url, $params ) {
7748 $page = '';
7749 $interface = $this->get_interface( $url );
7750 $vars = http_build_query( $params );
7751
7752 $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
7753 $header .= 'Host: ' . $interface['host'] . "\r\n";
7754 $header .= "User-Agent: PHP Script\r\n";
7755 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
7756 $header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
7757 $header .= "Connection: close\r\n\r\n";
7758 $header .= $vars;
7759
7760 $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
7761 if ( $fp ) {
7762 fwrite( $fp, $header );
7763 while ( ! feof( $fp ) ) {
7764 $scr = fgets( $fp, 1024 );
7765 $page .= $scr;
7766 }
7767 fclose( $fp );
7768 }
7769
7770 return $page;
7771 }
7772
7773 /**
7774 * Get clientip.
7775 *
7776 * @param string $acting Acting type.
7777 * @return string
7778 */
7779 protected function get_clientip( $acting ) {
7780 $client_ip = '';
7781 $acting_opts = $this->get_acting_settings();
7782 switch ( $acting ) {
7783 case 'zeus_card':
7784 $client_ip = $acting_opts['clientip'];
7785 break;
7786 case 'zeus_conv':
7787 $client_ip = $acting_opts['clientip_conv'];
7788 break;
7789 case 'zeus_bank':
7790 $client_ip = $acting_opts['clientip_bank'];
7791 break;
7792 }
7793 return $client_ip;
7794 }
7795
7796 /**
7797 * Get order_number.
7798 *
7799 * @param string $page Post data.
7800 * @return string
7801 */
7802 protected function get_order_number( $page ) {
7803 if ( empty( $page ) ) {
7804 return '';
7805 }
7806
7807 $log = explode( "\r\n", $page );
7808 $ordd = '';
7809 foreach ( (array) $log as $line ) {
7810 if ( false !== strpos( $line, 'ordd' ) ) {
7811 list( $status, $ordd ) = explode( '=', $line );
7812 }
7813 }
7814 if ( empty( $ordd ) ) {
7815 foreach ( (array) $log as $idx => $line ) {
7816 if ( false !== strpos( $line, 'Success_order' ) ) {
7817 list( $status, $ordd ) = explode( "\n", $line );
7818 break;
7819 }
7820 }
7821 }
7822 return $ordd;
7823 }
7824
7825 /**
7826 * Get err_code.
7827 *
7828 * @param string $page Post data.
7829 * @return string
7830 */
7831 protected function get_err_code( $page ) {
7832 if ( empty( $page ) ) {
7833 return '';
7834 }
7835
7836 $log = explode( "\r\n", $page );
7837 $err_code = '';
7838 foreach ( (array) $log as $line ) {
7839 if ( false !== strpos( $line, 'err_code' ) ) {
7840 list( $name, $err_code ) = explode( '=', $line );
7841 }
7842 }
7843 return $err_code;
7844 }
7845
7846 /**
7847 * Get err_code.
7848 *
7849 * @param string $page Post data.
7850 * @return string
7851 */
7852 protected function get_error_results( $page ) {
7853 $error_results = '';
7854 if ( ! empty( $page ) ) {
7855 $log = explode( "\r\n", $page );
7856 foreach ( (array) $log as $line ) {
7857 foreach ( $this->payment_error_results as $error ) {
7858 if ( false !== strpos( $line, $error ) ) {
7859 $error_results = $line;
7860 break;
7861 }
7862 }
7863 if ( ! empty( $error_results ) ) {
7864 break;
7865 }
7866 }
7867 }
7868 return $error_results;
7869 }
7870
7871 /**
7872 * Get order_id by meta_data ( conv, bank )
7873 *
7874 * @param int $key Order number.
7875 * @return string
7876 */
7877 protected function get_order_id( $key ) {
7878 global $wpdb;
7879
7880 $query = $wpdb->prepare( "SELECT `order_id` FROM {$wpdb->prefix}usces_order_meta WHERE `meta_key` = %s", 'acting_' . $key );
7881 $order_id = $wpdb->get_var( $query );
7882 return $order_id;
7883 }
7884
7885 /**
7886 * Get order_meta_data ( conv, bank )
7887 *
7888 * @param int $order_id Order number.
7889 * @return array
7890 */
7891 protected function get_order_meta_acting( $order_id ) {
7892 global $wpdb;
7893
7894 $query = $wpdb->prepare( "SELECT `meta_value` FROM {$wpdb->prefix}usces_order_meta WHERE `order_id` = %d AND `meta_key` LIKE %s", $order_id, 'acting_%' );
7895 $meta_value = $wpdb->get_var( $query );
7896 $acting_data = usces_unserialize( $meta_value );
7897 return $acting_data;
7898 }
7899
7900 /**
7901 * Tracking ID 取得
7902 *
7903 * @param int $order_id Order number.
7904 * @return string
7905 */
7906 protected function get_tracking_id( $order_id ) {
7907 global $usces;
7908
7909 $tracking_id = $usces->get_order_meta_value( 'tracking_id', $order_id );
7910 return $tracking_id;
7911 }
7912
7913 /**
7914 * 受注ステータス取得
7915 *
7916 * @param int $order_id Order number.
7917 * @return string
7918 */
7919 protected function get_order_status( $order_id ) {
7920 global $wpdb;
7921
7922 $query = $wpdb->prepare( "SELECT LOCATE( 'receipted', `order_status` ) FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
7923 $order_status = $wpdb->get_var( $query );
7924 return $order_status;
7925 }
7926
7927 /**
7928 * 受注データ支払方法取得
7929 *
7930 * @param int $order_id Order number.
7931 * @return string
7932 */
7933 protected function get_order_payment_name( $order_id ) {
7934 global $wpdb;
7935
7936 $query = $wpdb->prepare( "SELECT `order_payment_name` FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
7937 $order_payment_name = $wpdb->get_var( $query );
7938 return $order_payment_name;
7939 }
7940
7941 /**
7942 * 決済ログ取得
7943 *
7944 * @param int $order_id Order number.
7945 * @param string $tracking_id Tracking ID.
7946 * @param string $result Result.
7947 * @return array
7948 */
7949 public function get_acting_log( $order_id = 0, $tracking_id = 0, $result = 'OK' ) {
7950 global $wpdb;
7951
7952 if ( empty( $order_id ) ) {
7953 if ( 'OK' === $result ) {
7954 $query = $wpdb->prepare(
7955 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `tracking_id` = %s AND `result` IN( %s ) ORDER BY `ID` DESC, `datetime` DESC",
7956 $tracking_id,
7957 implode( "','", $this->payment_normal_results )
7958 );
7959 $query = stripslashes( $query );
7960 } else {
7961 $query = $wpdb->prepare(
7962 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `tracking_id` = %s ORDER BY `ID` DESC, `datetime` DESC",
7963 $tracking_id
7964 );
7965 }
7966 } else {
7967 if ( empty( $tracking_id ) ) {
7968 if ( 'OK' === $result ) {
7969 $query = $wpdb->prepare(
7970 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `datetime` IN( SELECT MAX( `datetime` ) FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d GROUP BY `tracking_id` ) AND `order_id` = %d AND `result` IN( %s ) ORDER BY `ID` DESC, `datetime` DESC",
7971 $order_id,
7972 $order_id,
7973 implode( "','", $this->payment_normal_results )
7974 );
7975 $query = stripslashes( $query );
7976 } else {
7977 $query = $wpdb->prepare(
7978 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `datetime` IN( SELECT MAX( `datetime` ) FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d GROUP BY `tracking_id` ) AND `order_id` = %d ORDER BY `ID` DESC, `datetime` DESC",
7979 $order_id,
7980 $order_id
7981 );
7982 }
7983 } else {
7984 if ( 'OK' === $result ) {
7985 $query = $wpdb->prepare(
7986 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d AND `tracking_id` = %s AND `result` IN( %s ) ORDER BY `ID` DESC, `datetime` DESC",
7987 $order_id,
7988 $tracking_id,
7989 implode( "','", $this->payment_normal_results )
7990 );
7991 $query = stripslashes( $query );
7992 } else {
7993 $query = $wpdb->prepare(
7994 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d AND `tracking_id` = %s ORDER BY `ID` DESC, `datetime` DESC",
7995 $order_id,
7996 $tracking_id
7997 );
7998 }
7999 }
8000 }
8001 $log_data = $wpdb->get_results( $query, ARRAY_A );
8002 return $log_data;
8003 }
8004
8005 /**
8006 * 最新処理取得
8007 *
8008 * @param int $order_id Order number.
8009 * @param string $tracking_id Tracking ID.
8010 * @param string $result Result.
8011 * @return array
8012 */
8013 public function get_acting_latest_log( $order_id, $tracking_id, $result = 'OK' ) {
8014 $latest_log = array();
8015 $log_data = $this->get_acting_log( $order_id, $tracking_id, $result );
8016 if ( $log_data ) {
8017 $data = current( $log_data );
8018 $log = usces_unserialize( $data['log'] );
8019 $order_no = $this->get_order_no( $log );
8020 $latest_log['acting'] = $data['acting'];
8021 $latest_log['status'] = $data['status'];
8022 $latest_log['result'] = $data['result'];
8023 $latest_log['log'] = $log;
8024 $latest_log['amount'] = (int) $data['amount'];
8025 $latest_log['order_id'] = $data['order_id'];
8026 $latest_log['order_no'] = $order_no;
8027 $latest_log['tracking_id'] = $data['tracking_id'];
8028 }
8029 return $latest_log;
8030 }
8031
8032 /**
8033 * 決済処理取得
8034 *
8035 * @param int $order_id Order number.
8036 * @param string $tracking_id Tracking ID.
8037 * @param string $result Result.
8038 * @return string
8039 */
8040 private function get_acting_status( $order_id, $tracking_id, $result = 'OK' ) {
8041 $acting_status = '';
8042 $log_data = $this->get_acting_log( $order_id, $tracking_id, $result );
8043 if ( $log_data ) {
8044 foreach ( (array) $log_data as $data ) {
8045 if ( 'change' === $data['status'] ) {
8046 continue;
8047 }
8048 if ( 'TEST' === $data['status'] || 'test' === $data['status'] ) {
8049 $acting_status = 'test';
8050 } elseif ( 'cancel' === $data['status'] || 'sale' === $data['status'] || 'auth' === $data['status'] ) {
8051 $acting_status = $data['status'];
8052 } elseif ( 'autodelivery' === $data['status'] || 'dlseller' === $data['status'] ) {
8053 $acting_status = 'error';
8054 } elseif ( '仮売完了' === $data['result'] ) {
8055 $acting_status = 'auth';
8056 } elseif ( '決済完了' === $data['result'] || 'payment' === $data['status'] ) {
8057 $acting_status = 'payment';
8058 } elseif ( 'transaction' === $data['status'] || 'shippingrequest' === $data['status'] || 'canceltransaction' === $data['status'] ) {
8059 $acting_status = $data['status'] . $data['result'];
8060 }
8061 if ( '' !== $acting_status ) {
8062 break;
8063 }
8064 }
8065 }
8066 return $acting_status;
8067 }
8068
8069 /**
8070 * 処理区分名称取得
8071 *
8072 * @param string $payment_status Payment status code.
8073 * @param string $payment_result Payment result.
8074 * @return string
8075 */
8076 private function get_status_name( $payment_status, $payment_result = '' ) {
8077 $status_name = '';
8078 switch ( $payment_status ) {
8079 case 'TEST':
8080 case 'test':
8081 $status_name = 'テスト決済';
8082 break;
8083 case 'payment':
8084 $status_name = '決済完了';
8085 break;
8086 case 'auth':
8087 $status_name = '仮売完了';
8088 break;
8089 case 'sale':
8090 $status_name = '決済完了';
8091 break;
8092 case 'cancel':
8093 $status_name = '取り消し';
8094 break;
8095 case 'change':
8096 $status_name = '金額変更';
8097 break;
8098 case 'error':
8099 $status_name = 'エラー';
8100 break;
8101 case 'dlseller':
8102 $status_name = '継続課金決済エラー';
8103 break;
8104 case 'autodelivery':
8105 $status_name = '定期購�
8106 �決済エラー';
8107 break;
8108 case 'transaction':
8109 $status_name = '取引登録';
8110 break;
8111 case 'transactionOK':
8112 $status_name = '取引登録完了';
8113 break;
8114 case 'transactionNG':
8115 $status_name = '取引登録エラー';
8116 break;
8117 case 'shippingrequest':
8118 $status_name = '出荷登録';
8119 break;
8120 case 'shippingrequestOK':
8121 $status_name = '出荷登録完了';
8122 break;
8123 case 'shippingrequestNG':
8124 $status_name = '出荷登録エラー';
8125 break;
8126 case 'canceltransaction':
8127 $status_name = '取引キャンセル';
8128 break;
8129 case 'canceltransactionOK':
8130 $status_name = '取引取消完了';
8131 break;
8132 case 'canceltransactionNG':
8133 $status_name = '取引取消エラー';
8134 break;
8135 default:
8136 if ( in_array( $payment_result, $this->payment_normal_results, true ) ) {
8137 if ( 'OK' === $payment_result || 'Success_order' === $payment_result || 'SuccessOK' === $payment_result ) {
8138 $status_name = '決済完了';
8139 } else {
8140 $status_name = $payment_result;
8141 }
8142 } else {
8143 $status_name = ( ! empty( $payment_result ) ) ? $payment_result : '決済完了';
8144 }
8145 $status_name = $payment_status;
8146 }
8147 return $status_name;
8148 }
8149
8150 /**
8151 * オーダーNo 取得
8152 *
8153 * @param array $log Log data.
8154 * @return string
8155 */
8156 private function get_order_no( $log ) {
8157 $order_no = ( isset( $log['ordd'] ) ) ? $log['ordd'] : '';
8158 if ( empty( $order_no ) && isset( $log['zeusordd'] ) ) {
8159 $order_no = $log['zeusordd'];
8160 }
8161 if ( empty( $order_no ) && isset( $log['ordd'] ) ) {
8162 $order_no = $log['ordd'];
8163 }
8164 if ( empty( $order_no ) && isset( $log['order_no'] ) ) {
8165 $order_no = $log['order_no'];
8166 }
8167 if ( empty( $order_no ) && isset( $log['ORDER_NO'] ) ) {
8168 $order_no = $log['ORDER_NO'];
8169 }
8170 if ( empty( $order_no ) && isset( $log['result_order_number'] ) ) {
8171 $order_no = $log['result_order_number'];
8172 }
8173 if ( empty( $order_no ) && isset( $log['response']['data']['ORDER_NO'] ) ) {
8174 $order_no = $log['response']['data']['ORDER_NO'];
8175 }
8176 if ( empty( $order_no ) && isset( $log['response']['result']['result_order_number'] ) ) {
8177 $order_no = $log['response']['result']['result_order_number'];
8178 }
8179 return $order_no;
8180 }
8181
8182 /**
8183 * Email 取得
8184 *
8185 * @param int $order_id Order number.
8186 * @return string
8187 */
8188 private function get_email( $order_id ) {
8189 global $wpdb;
8190
8191 $query = $wpdb->prepare( "SELECT `order_email` FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
8192 $email = $wpdb->get_var( $query );
8193 return $email;
8194 }
8195
8196 /**
8197 * Get interface.
8198 *
8199 * @param string $url URL.
8200 * @return array
8201 */
8202 public function get_interface( $url ) {
8203 $interface = parse_url( $url );
8204 if ( defined( 'ZEUS_SSL_TEST' ) ) {
8205 $interface['host'] = ZEUS_SSL_TEST . $interface['host'];
8206 }
8207 if ( defined( 'ZEUS_TLS_TEST' ) ) {
8208 $interface['host'] = ZEUS_TLS_TEST;
8209 }
8210 return $interface;
8211 }
8212
8213 /**
8214 * Get acting flg.
8215 *
8216 * @param string $payment_name Payment name.
8217 * @return string
8218 */
8219 private function get_acting_flg( $payment_name ) {
8220 $payment = usces_get_payments_by_name( $payment_name );
8221 $acting_flg = ( isset( $payment['settlement'] ) && 'acting' === $payment['settlement'] ) ? $payment['module'] : $payment['settlement'];
8222 return $acting_flg;
8223 }
8224
8225 /**
8226 * Get Header Information.
8227 *
8228 * @return string
8229 */
8230 private function get_header_information() {
8231 // ヘッダー�
8232 報を格納する�
8233 �列.
8234 $header_info = array();
8235
8236 // 1-14の指定されたヘッダーを取得.
8237 $header_info[] = $_SERVER['HTTP_ACCEPT'] ?? '';
8238 $header_info[] = $_SERVER['HTTP_ACCEPT_CHARSET'] ?? '';
8239 $header_info[] = $_SERVER['HTTP_ACCEPT_ENCODING'] ?? '';
8240 $header_info[] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '';
8241 $header_info[] = $_SERVER['HTTP_CLIENT_IP'] ?? '';
8242 $header_info[] = $_SERVER['HTTP_CONNECTION'] ?? '';
8243
8244 // 7) DNTヘッダーの処理(Mozilla系ブラウザの判定).
8245 $user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
8246 if ( strpos( $user_agent, 'Mozilla' ) !== false ) {
8247 $header_info[] = $_SERVER['HTTP_DNT'] ?? '';
8248 } else {
8249 $header_info[] = $_SERVER['HTTP_X_DO_NOT_TRACK'] ?? '';
8250 }
8251
8252 $header_info[] = $_SERVER['HTTP_HOST'] ?? '';
8253 $header_info[] = $_SERVER['HTTP_REFERER'] ?? '';
8254 $header_info[] = $user_agent;
8255 $header_info[] = $_SERVER['HTTP_KEEP_ALIVE'] ?? '';
8256 $header_info[] = $_SERVER['HTTP_UA_CPU'] ?? '';
8257 $header_info[] = $_SERVER['HTTP_VIA'] ?? '';
8258 $header_info[] = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? '';
8259
8260 // 15) その他のヘッダーの処理.
8261 $other_headers = array();
8262 $all_headers = getallheaders(); // �
8263 �ヘッダーを取得.
8264
8265 // 除外するヘッダー名のリスト(大文字小文字を区別しない比較のため小文字で保持).
8266 $exclude_headers = array_map(
8267 'strtolower', [
8268 'Accept', 'Accept-Charset', 'Accept-Encoding', 'Accept-Language',
8269 'Client-IP', 'Connection', 'DNT', 'X-Do-Not-Track', 'Host',
8270 'Referer', 'User-Agent', 'Keep-Alive', 'UA-CPU', 'Via',
8271 'X-Forwarded-For',
8272 ]
8273 );
8274
8275 foreach ( $all_headers as $header => $value ) {
8276 if ( ! in_array( strtolower( $header ), $exclude_headers ) ) {
8277 $other_headers[] = $header . '--' . $value;
8278 }
8279 }
8280 $header_info[] = implode( '::', $other_headers );
8281
8282 // 16) クライアントIPアドレスの取得.
8283 $client_ip = '';
8284 if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
8285 $client_ip = $_SERVER['HTTP_CLIENT_IP'];
8286 } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
8287 $client_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
8288 } else {
8289 $client_ip = $_SERVER['REMOTE_ADDR'] ?? '';
8290 }
8291 $header_info[] = $client_ip;
8292
8293 // 17) 携帯端末識別IDの取得.
8294 $mobile_id = '';
8295 if ( isset( $_SERVER['HTTP_X_DCMGUID'] ) ) { // DoCoMo.
8296 $mobile_id = $_SERVER['HTTP_X_DCMGUID'];
8297 } elseif ( isset( $_SERVER['HTTP_X_UP_SUBNO'] ) ) { // au.
8298 $mobile_id = $_SERVER['HTTP_X_UP_SUBNO'];
8299 } elseif ( isset( $_SERVER['HTTP_X_JPHONE_UID'] ) ) { // SoftBank.
8300 $mobile_id = $_SERVER['HTTP_X_JPHONE_UID'];
8301 }
8302 $header_info[] = $mobile_id;
8303
8304 // �
8305 �ての値をセミコロンとコロンで連結.
8306 return implode( ';:', array_map( function( $value ) {
8307 return trim( $value );
8308 }, $header_info ) );
8309 }
8310
8311 /**
8312 * 手数料名称
8313 *
8314 * @param string $fee_type Fee type.
8315 * @return string
8316 */
8317 protected function get_fee_name( $fee_type ) {
8318 $fee_name = '';
8319 if ( 'fix' === $fee_type ) {
8320 $fee_name = __( 'Fixation', 'usces' );
8321 } elseif ( 'change' === $fee_type ) {
8322 $fee_name = __( 'Variable', 'usces' );
8323 }
8324 return $fee_name;
8325 }
8326 }
8327
8328 /**
8329 * Get order_ref
8330 *
8331 * @param string $order_no Order No.
8332 * @return array
8333 */
8334 function wel_zeus_get_order_ref( $order_no ) {
8335 $order_ref = array();
8336 $zeus_settlement = ZEUS_SETTLEMENT::get_instance();
8337 $acting_opts = $zeus_settlement->get_acting_settings();
8338 $interface = $zeus_settlement->get_interface( $acting_opts['card_order_ref'] );
8339
8340 $params = array();
8341 $params['clientip'] = $acting_opts['clientip'];
8342 $params['zkey'] = $acting_opts['authkey'];
8343 $params['order_no'] = $order_no;
8344 $vars = http_build_query( $params );
8345
8346 $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
8347 $header .= 'Host: ' . $interface['host'] . "\r\n";
8348 $header .= "User-Agent: PHP Script\r\n";
8349 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
8350 $header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
8351 $header .= "Connection: close\r\n\r\n";
8352 $header .= $vars;
8353
8354 $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
8355 if ( $fp ) {
8356 $xml = '';
8357 fwrite( $fp, $header );
8358 while ( ! feof( $fp ) ) {
8359 $scr = fgets( $fp, 1024 );
8360 if ( false !== strpos( $scr, '<' ) ) {
8361 $xml .= mb_convert_encoding( $scr, 'UTF-8', 'sjis-win' );
8362 }
8363 }
8364 fclose( $fp );
8365 $assoc = $zeus_settlement->xml2assoc( $xml );
8366 if ( isset( $assoc['message']['response']['data'] ) ) {
8367 $order_ref = $assoc['message']['response']['data'];
8368 if ( isset( $order_ref['RESULT'] ) ) {
8369 if ( '決済完了' === $order_ref['RESULT'] ) {
8370 $order_ref['status'] = 'payment';
8371 } elseif ( '与信完了' === $order_ref['RESULT'] || '仮売完了' === $order_ref['RESULT'] ) {
8372 $order_ref['status'] = 'auth';
8373 } elseif ( '取り消し' === $order_ref['RESULT'] ) {
8374 $order_ref['status'] = 'cancel';
8375 } else {
8376 $order_ref['status'] = $order_ref['RESULT'];
8377 }
8378 } else {
8379 $order_ref['status'] = '';
8380 }
8381 } else {
8382 $order_ref['status'] = '';
8383 }
8384 }
8385 if ( empty( $order_ref['status'] ) && false !== strpos( $order_no, 'TEST' ) ) {
8386 $order_ref['status'] = 'TEST';
8387 }
8388
8389 return $order_ref;
8390 }
8391
8392 /**
8393 * 決済ログ出力
8394 *
8395 * @param string $log Log data.
8396 * @param string $acting Acting type.
8397 * @param string $status Status.
8398 * @param string $result Result.
8399 * @param int $order_id Order number.
8400 * @param string $tracking_id Tracking ID.
8401 * @return array
8402 */
8403 function wel_zeus_save_acting_log( $log, $acting, $status, $result, $order_id, $tracking_id ) {
8404 global $wpdb;
8405
8406 if ( isset( $log['money'] ) ) {
8407 $amount = $log['money'];
8408 } elseif ( isset( $log['amount'] ) ) {
8409 $amount = $log['amount'];
8410 } elseif ( isset( $log['king'] ) ) {
8411 $amount = $log['king'];
8412 } elseif ( isset( $log['KING'] ) ) {
8413 $amount = $log['KING'];
8414 } else {
8415 $amount = 0;
8416 }
8417 $query = $wpdb->prepare(
8418 "INSERT INTO {$wpdb->prefix}usces_acting_log ( `datetime`, `log`, `acting`, `status`, `result`, `amount`, `order_id`, `tracking_id` ) VALUES ( %s, %s, %s, %s, %s, %f, %d, %s )",
8419 wp_date( 'Y-m-d H:i:s' ),
8420 usces_serialize( $log ),
8421 $acting,
8422 $status,
8423 $result,
8424 $amount,
8425 $order_id,
8426 $tracking_id
8427 );
8428 $res = $wpdb->query( $query );
8429 return $res;
8430 }
8431