PluginProbe
Welcart e-Commerce / 2.12.3
Welcart e-Commerce v2.12.3
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 1.4.13 All 291 releases
usc-e-shop / classes / paymentZeus.class.php

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

8,485 lines 357.7 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 * 決済結果通知(zeus_conv / zeus_bank)の送信�
19 �IP許可リスト
20 *
21 * @var array
22 */
23 const ACTING_NOTICE_IPADDRS = array( '210.164.6.67', '202.221.139.50' );
24
25 /**
26 * Instance of this class.
27 *
28 * @var object
29 */
30 protected static $instance = null;
31
32 /**
33 * 決済代行会社ID
34 *
35 * @var string
36 */
37 protected $paymod_id;
38
39 /**
40 * 決済種別
41 *
42 * @var string
43 */
44 protected $pay_method;
45
46 /**
47 * 決済代行会社略称
48 *
49 * @var string
50 */
51 protected $acting_name;
52
53 /**
54 * 決済代行会社正式名称
55 *
56 * @var string
57 */
58 protected $acting_formal_name;
59
60 /**
61 * 決済代行会社URL
62 *
63 * @var string
64 */
65 protected $acting_company_url;
66
67 /**
68 * 併用不可決済モジュール
69 *
70 * @var array
71 */
72 protected $unavailable_method;
73
74 /**
75 * エラーメッセージ
76 *
77 * @var string
78 */
79 protected $error_mes;
80
81 /**
82 * 自動継続課金処理結果メール
83 *
84 * @var array
85 */
86 protected $continuation_charging_mail;
87
88 /**
89 * 決済結果(正常)
90 *
91 * @var array
92 */
93 protected $payment_normal_results = array(
94 'OK',
95 'Success_order',
96 'SuccessOK',
97 'success',
98 '決済完了',
99 '与信完了',
100 '仮売完了',
101 '取り消し',
102 );
103
104 /**
105 * 決済結果(異常)
106 *
107 * @var array
108 */
109 protected $payment_error_results = array(
110 'failure_order',
111 'Invalid',
112 'maintenance',
113 'connect error',
114 );
115
116 /**
117 * 運送会社コード表
118 *
119 * @var array
120 */
121 protected $shipping_company = array(
122 '11' => '佐川急便',
123 '12' => 'ヤマト運輸',
124 '15' => '郵便書留',
125 '16' => 'ゆうパック',
126 '27' => 'エコ�
127 �',
128 '18' => '福山通運',
129 '14' => '西濃運輸',
130 '13' => '日本通運',
131 '26' => 'JPロジスティクス',
132 '30' => 'セイノーエクスプレス',
133 '21' => '名鉄運輸',
134 '23' => '信州名鉄運輸',
135 '20' => '新潟運輸',
136 '29' => 'トナミ運輸',
137 '31' => '大川�
138 �送サービス',
139 '32' => 'プラスサービス',
140 '99' => 'その他',
141 );
142
143 /**
144 * 決済オプション
145 *
146 * @var array
147 */
148 public $acting_opts;
149
150 /**
151 * Construct.
152 */
153 public function __construct() {
154 $this->paymod_id = 'zeus';
155 $this->pay_method = array(
156 'acting_zeus_card',
157 'acting_zeus_bank',
158 'acting_zeus_conv',
159 'acting_zeus_bnpl',
160 );
161 $this->acting_name = 'ゼウス';
162 $this->acting_formal_name = 'ゼウス';
163 $this->acting_company_url = 'https://www.cardservice.co.jp/';
164
165 $this->initialize_data();
166 $this->acting_opts = $this->get_acting_settings();
167
168 if ( is_admin() ) {
169 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
170 add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
171 add_action( 'usces_action_admin_settlement_update', array( $this, 'settlement_update' ) );
172 add_action( 'usces_action_settlement_tab_title', array( $this, 'settlement_tab_title' ) );
173 add_action( 'usces_action_settlement_tab_body', array( $this, 'settlement_tab_body' ) );
174 add_action( 'usces_filter_add_payment_method', array( $this, 'add_payment_method' ) );
175 }
176
177 if ( $this->is_validity_acting( 'card' ) || $this->is_validity_acting( 'bank' ) || $this->is_validity_acting( 'conv' ) || $this->is_validity_acting( 'bnpl' ) ) {
178 add_action( 'plugins_loaded', array( $this, 'acting_construct' ), 11 );
179 add_action( 'usces_after_cart_instant', array( $this, 'acting_transaction' ), 11 );
180 add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'order_confirm_mail_payment' ), 10, 5 );
181 add_filter( 'usces_filter_is_complete_settlement', array( $this, 'is_complete_settlement' ), 10, 3 );
182 add_action( 'usces_filter_completion_settlement_message', array( $this, 'completion_settlement_message' ), 10, 2 );
183 add_filter( 'usces_filter_get_link_key', array( $this, 'get_link_key' ), 10, 2 );
184 add_action( 'usces_action_revival_order_data', array( $this, 'revival_orderdata' ), 10, 3 );
185 if ( is_admin() ) {
186 add_action( 'usces_action_admin_ajax', array( $this, 'admin_ajax' ) );
187 add_filter( 'usces_filter_orderlist_detail_value', array( $this, 'orderlist_settlement_status' ), 10, 4 );
188 add_action( 'usces_action_order_edit_form_status_block_middle', array( $this, 'settlement_status' ), 10, 3 );
189 add_action( 'usces_action_order_edit_form_settle_info', array( $this, 'settlement_information' ), 10, 2 );
190 add_action( 'usces_action_endof_order_edit_form', array( $this, 'settlement_dialog' ), 10, 2 );
191 add_filter( 'usces_filter_settle_info_field_meta_keys', array( $this, 'settlement_info_field_meta_keys' ) );
192 add_filter( 'usces_filter_settle_info_field_keys', array( $this, 'settlement_info_field_keys' ), 10, 2 );
193 add_filter( 'usces_filter_settle_info_field_value', array( $this, 'settlement_info_field_value' ), 10, 3 );
194 add_filter( 'usces_filter_deli_comps', array( $this, 'bnpl_delivery_company' ), 10, 2 );
195 } else {
196 add_filter( 'usces_filter_payment_detail', array( $this, 'payment_detail' ), 10, 2 );
197 add_filter( 'usces_filter_payments_str', array( $this, 'payments_str' ), 10, 2 );
198 add_filter( 'usces_filter_payments_arr', array( $this, 'payments_arr' ), 10, 2 );
199 add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
200 add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
201 add_filter( 'usces_filter_confirm_inform', array( $this, 'confirm_inform' ), 10, 5 );
202 add_action( 'usces_action_confirm_page_point_inform', array( $this, 'e_point_inform' ), 10, 5 );
203 add_filter( 'usces_filter_confirm_point_inform', array( $this, 'point_inform' ), 10, 5 );
204 add_filter( 'usces_filter_custom_field_info', array( $this, 'confirm_addition_bnpl' ), 20, 4 );
205 if ( defined( 'WCEX_COUPON' ) ) {
206 add_filter( 'wccp_filter_coupon_inform', array( $this, 'point_inform' ), 10, 5 );
207 }
208 add_action( 'usces_pre_purchase', array( $this, 'pre_purchase' ) );
209 add_action( 'usces_action_acting_processing', array( $this, 'acting_processing' ), 10, 2 );
210 add_action( 'usces_pre_acting_return', array( $this, 'pre_acting_return' ) );
211 add_filter( 'usces_filter_check_acting_return_results', array( $this, 'acting_return' ) );
212 add_filter( 'usces_filter_check_acting_return_duplicate', array( $this, 'check_acting_return_duplicate' ), 10, 2 );
213 add_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) );
214 add_action( 'usces_post_reg_orderdata', array( $this, 'post_register_orderdata' ), 10, 2 );
215 add_filter( 'usces_filter_get_error_settlement', array( $this, 'error_page_message' ) );
216 }
217 }
218
219 if ( $this->is_validity_acting( 'card' ) ) {
220 if ( $this->is_activate_card( 'api' ) && 1 === (int) $this->acting_opts['3dsecur'] ) {
221 add_action( 'wp_ajax_zeus_3dsecure_enrol', array( $this, 'zeus_3dsecure_enrol' ) );
222 add_action( 'wp_ajax_nopriv_zeus_3dsecure_enrol', array( $this, 'zeus_3dsecure_enrol' ) );
223 }
224 add_action( 'usces_action_admin_member_info', array( $this, 'admin_member_info' ), 10, 3 );
225 add_action( 'usces_action_post_update_memberdata', array( $this, 'admin_update_memberdata' ), 10, 2 );
226 add_filter( 'usces_filter_uscesL10n', array( $this, 'set_uscesL10n' ), 12, 2 );
227 add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ), 9 );
228 add_filter( 'usces_filter_available_payment_method', array( $this, 'set_available_payment_method' ) );
229 add_filter( 'usces_filter_template_redirect', array( $this, 'member_update_settlement' ), 1 );
230 add_action( 'usces_action_member_submenu_list', array( $this, 'e_update_settlement' ) );
231 add_filter( 'usces_filter_member_submenu_list', array( $this, 'update_settlement' ), 10, 2 );
232 add_filter( 'usces_filter_delete_member_check', array( $this, 'delete_member_check' ), 10, 2 );
233 add_filter( 'usces_filter_delete_member_check_front', array( $this, 'delete_member_check' ), 10, 2 );
234
235 /* WCEX DL Seller */
236 if ( defined( 'WCEX_DLSELLER' ) ) {
237 add_filter( 'usces_filter_the_continue_payment_method', array( $this, 'continuation_payment_method' ) );
238 add_filter( 'dlseller_filter_first_charging', array( $this, 'first_charging_date' ), 9, 5 );
239 add_filter( 'dlseller_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction' ), 10, 2 );
240 add_filter( 'dlseller_filter_continue_member_list_condition', array( $this, 'continue_member_list_condition' ), 10, 4 );
241 add_action( 'dlseller_action_continue_member_list_page', array( $this, 'continue_member_list_page' ) );
242 add_action( 'dlseller_action_do_continuation_charging', array( $this, 'auto_continuation_charging' ), 10, 4 );
243 add_action( 'dlseller_action_do_continuation', array( $this, 'do_auto_continuation' ), 10, 2 );
244 add_filter( 'dlseller_filter_reminder_mail_body', array( $this, 'reminder_mail_body' ), 10, 3 );
245 add_filter( 'dlseller_filter_contract_renewal_mail_body', array( $this, 'contract_renewal_mail_body' ), 10, 3 );
246 }
247 }
248
249 if ( $this->is_validity_acting( 'bnpl' ) ) {
250 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
251 add_filter( 'usces_fiter_the_payment_method', array( $this, 'payment_method' ) );
252 add_filter( 'usces_filter_cod_label', array( $this, 'set_fee_label' ) );
253 add_filter( 'usces_filter_member_history_cod_label', array( $this, 'set_member_history_fee_label' ), 10, 2 );
254 add_filter( 'usces_filter_set_cart_fees_cod', array( $this, 'add_fee' ), 10, 7 );
255 add_filter( 'usces_filter_delivery_check', array( $this, 'check_fee_limit' ) );
256 add_filter( 'usces_filter_point_check_last', array( $this, 'check_fee_limit' ) );
257 }
258 }
259
260 /**
261 * Return an instance of this class.
262 */
263 public static function get_instance() {
264 if ( is_null( self::$instance ) ) {
265 self::$instance = new self();
266 }
267 return self::$instance;
268 }
269
270 /**
271 * Initialize.
272 */
273 public function initialize_data() {
274 $options = get_option( 'usces', array() );
275 $options['acting_settings']['zeus']['ipaddrs'] = ( isset( $options['acting_settings']['zeus']['ipaddrs'] ) ) ? $options['acting_settings']['zeus']['ipaddrs'] : array();
276 $options['acting_settings']['zeus']['card_url'] = ( isset( $options['acting_settings']['zeus']['card_url'] ) ) ? $options['acting_settings']['zeus']['card_url'] : '';
277 $options['acting_settings']['zeus']['card_secureurl'] = ( isset( $options['acting_settings']['zeus']['card_secureurl'] ) ) ? $options['acting_settings']['zeus']['card_secureurl'] : '';
278 $options['acting_settings']['zeus']['card_tokenurl'] = ( isset( $options['acting_settings']['zeus']['card_tokenurl'] ) ) ? $options['acting_settings']['zeus']['card_tokenurl'] : '';
279 $options['acting_settings']['zeus']['bank_url'] = ( isset( $options['acting_settings']['zeus']['bank_url'] ) ) ? $options['acting_settings']['zeus']['bank_url'] : '';
280 $options['acting_settings']['zeus']['conv_url'] = ( isset( $options['acting_settings']['zeus']['conv_url'] ) ) ? $options['acting_settings']['zeus']['conv_url'] : '';
281 $options['acting_settings']['zeus']['card_activate'] = ( isset( $options['acting_settings']['zeus']['card_activate'] ) ) ? $options['acting_settings']['zeus']['card_activate'] : 'off';
282 $options['acting_settings']['zeus']['clientip'] = ( isset( $options['acting_settings']['zeus']['clientip'] ) ) ? $options['acting_settings']['zeus']['clientip'] : '';
283 $options['acting_settings']['zeus']['connection'] = ( isset( $options['acting_settings']['zeus']['connection'] ) ) ? $options['acting_settings']['zeus']['connection'] : 1;
284 $options['acting_settings']['zeus']['3dsecur'] = ( isset( $options['acting_settings']['zeus']['3dsecur'] ) ) ? $options['acting_settings']['zeus']['3dsecur'] : 2;
285 $options['acting_settings']['zeus']['3ds_pattern'] = ( isset( $options['acting_settings']['zeus']['3ds_pattern'] ) ) ? $options['acting_settings']['zeus']['3ds_pattern'] : '';
286 $options['acting_settings']['zeus']['security'] = ( isset( $options['acting_settings']['zeus']['security'] ) ) ? $options['acting_settings']['zeus']['security'] : 2;
287 $options['acting_settings']['zeus']['authkey'] = ( isset( $options['acting_settings']['zeus']['authkey'] ) ) ? $options['acting_settings']['zeus']['authkey'] : '';
288 $options['acting_settings']['zeus']['quickcharge'] = ( isset( $options['acting_settings']['zeus']['quickcharge'] ) ) ? $options['acting_settings']['zeus']['quickcharge'] : '';
289 $options['acting_settings']['zeus']['batch'] = ( isset( $options['acting_settings']['zeus']['batch'] ) ) ? $options['acting_settings']['zeus']['batch'] : '';
290 $options['acting_settings']['zeus']['auto_settlement_mail'] = ( isset( $options['acting_settings']['zeus']['auto_settlement_mail'] ) ) ? $options['acting_settings']['zeus']['auto_settlement_mail'] : 'off';
291 $options['acting_settings']['zeus']['howpay'] = ( isset( $options['acting_settings']['zeus']['howpay'] ) ) ? $options['acting_settings']['zeus']['howpay'] : '';
292 $options['acting_settings']['zeus']['howpay_B1'] = ( isset( $options['acting_settings']['zeus']['howpay_B1'] ) ) ? $options['acting_settings']['zeus']['howpay_B1'] : '';
293 $options['acting_settings']['zeus']['howpay_02'] = ( isset( $options['acting_settings']['zeus']['howpay_02'] ) ) ? $options['acting_settings']['zeus']['howpay_02'] : '';
294 $options['acting_settings']['zeus']['bank_activate'] = ( isset( $options['acting_settings']['zeus']['bank_activate'] ) ) ? $options['acting_settings']['zeus']['bank_activate'] : 'off';
295 $options['acting_settings']['zeus']['bank_ope'] = ( isset( $options['acting_settings']['zeus']['bank_ope'] ) ) ? $options['acting_settings']['zeus']['bank_ope'] : '';
296 $options['acting_settings']['zeus']['clientip_bank'] = ( isset( $options['acting_settings']['zeus']['clientip_bank'] ) ) ? $options['acting_settings']['zeus']['clientip_bank'] : '';
297 $options['acting_settings']['zeus']['testid_bank'] = ( isset( $options['acting_settings']['zeus']['testid_bank'] ) ) ? $options['acting_settings']['zeus']['testid_bank'] : '';
298 $options['acting_settings']['zeus']['bank_expired_date'] = ( isset( $options['acting_settings']['zeus']['bank_expired_date'] ) ) ? $options['acting_settings']['zeus']['bank_expired_date'] : '';
299 $options['acting_settings']['zeus']['conv_activate'] = ( isset( $options['acting_settings']['zeus']['conv_activate'] ) ) ? $options['acting_settings']['zeus']['conv_activate'] : 'off';
300 $options['acting_settings']['zeus']['conv_ope'] = ( isset( $options['acting_settings']['zeus']['conv_ope'] ) ) ? $options['acting_settings']['zeus']['conv_ope'] : '';
301 $options['acting_settings']['zeus']['clientip_conv'] = ( isset( $options['acting_settings']['zeus']['clientip_conv'] ) ) ? $options['acting_settings']['zeus']['clientip_conv'] : '';
302 $options['acting_settings']['zeus']['testid_conv'] = ( isset( $options['acting_settings']['zeus']['testid_conv'] ) ) ? $options['acting_settings']['zeus']['testid_conv'] : '';
303 $options['acting_settings']['zeus']['test_type_conv'] = ( isset( $options['acting_settings']['zeus']['test_type_conv'] ) ) ? $options['acting_settings']['zeus']['test_type_conv'] : '';
304 $options['acting_settings']['zeus']['pay_cvs'] = ( isset( $options['acting_settings']['zeus']['pay_cvs'] ) ) ? $options['acting_settings']['zeus']['pay_cvs'] : array();
305 $options['acting_settings']['zeus']['conv_span'] = ( isset( $options['acting_settings']['zeus']['conv_span'] ) ) ? $options['acting_settings']['zeus']['conv_span'] : '';
306 $options['acting_settings']['zeus']['bnpl_activate'] = ( isset( $options['acting_settings']['zeus']['bnpl_activate'] ) ) ? $options['acting_settings']['zeus']['bnpl_activate'] : 'off';
307 $options['acting_settings']['zeus']['bnpl_linkid'] = ( isset( $options['acting_settings']['zeus']['bnpl_linkid'] ) ) ? $options['acting_settings']['zeus']['bnpl_linkid'] : 'sbifstest1';
308 $options['acting_settings']['zeus']['clientip_bnpl'] = ( isset( $options['acting_settings']['zeus']['clientip_bnpl'] ) ) ? $options['acting_settings']['zeus']['clientip_bnpl'] : '';
309 $options['acting_settings']['zeus']['bnpl_linkpassword'] = ( isset( $options['acting_settings']['zeus']['bnpl_linkpassword'] ) ) ? $options['acting_settings']['zeus']['bnpl_linkpassword'] : '';
310 $options['acting_settings']['zeus']['bnpl_transaction_url'] = ( isset( $options['acting_settings']['zeus']['bnpl_transaction_url'] ) ) ? $options['acting_settings']['zeus']['bnpl_transaction_url'] : '';
311 $options['acting_settings']['zeus']['bnpl_shippingrequest_url'] = ( isset( $options['acting_settings']['zeus']['bnpl_shippingrequest_url'] ) ) ? $options['acting_settings']['zeus']['bnpl_shippingrequest_url'] : '';
312 $options['acting_settings']['zeus']['bnpl_modifytransaction_url'] = ( isset( $options['acting_settings']['zeus']['bnpl_modifytransaction_url'] ) ) ? $options['acting_settings']['zeus']['bnpl_modifytransaction_url'] : '';
313 $options['acting_settings']['zeus']['bnpl_fee_type'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_type'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_type'] : '';
314 $options['acting_settings']['zeus']['bnpl_fee'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee'] : '';
315 $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'] : '';
316 $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'] : '';
317 $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'] : '';
318 $options['acting_settings']['zeus']['bnpl_fee_amounts'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_amounts'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_amounts'] : array();
319 $options['acting_settings']['zeus']['bnpl_fee_fees'] = ( isset( $options['acting_settings']['zeus']['bnpl_fee_fees'] ) ) ? $options['acting_settings']['zeus']['bnpl_fee_fees'] : array();
320 $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'] : '';
321 $options['acting_settings']['zeus']['activate'] = ( isset( $options['acting_settings']['zeus']['activate'] ) ) ? $options['acting_settings']['zeus']['activate'] : 'off';
322 if ( 'on' === $options['acting_settings']['zeus']['activate'] && 'on' === $options['acting_settings']['zeus']['card_activate'] ) {
323 if ( ! isset( $options['acting_settings']['zeus']['card_order_ref'] ) ) {
324 $options['acting_settings']['zeus']['card_order_ref'] = 'https://linkpt.cardservice.co.jp/cgi-bin/order_ref.cgi';
325 }
326 if ( ! isset( $options['acting_settings']['zeus']['card_price_change'] ) ) {
327 $options['acting_settings']['zeus']['card_price_change'] = 'https://linkpt.cardservice.co.jp/cgi-bin/credit/price_change/reflect/index.cgi';
328 }
329 }
330 update_option( 'usces', $options );
331
332 $this->unavailable_method = array( 'acting_welcart_card', 'acting_escott_card', 'acting_sbps_card', 'acting_paygent_card' );
333 }
334
335 /**
336 * 併用不可決済モジュール
337 * usces_filter_unavailable_payments
338 *
339 * @return array
340 */
341 public function unavailable_payments() {
342 return $this->unavailable_method;
343 }
344
345 /**
346 * 決済有効判定
347 * 支払方法で使用している場合に true
348 *
349 * @param string $type Module type.
350 * @return bool
351 */
352 public function is_validity_acting( $type = '' ) {
353 $acting_opts = $this->get_acting_settings();
354 if ( empty( $acting_opts ) ) {
355 return false;
356 }
357
358 $payment_method = usces_get_system_option( 'usces_payment_method', 'sort' );
359 $method = false;
360
361 switch ( $type ) {
362 case 'card':
363 foreach ( $payment_method as $payment ) {
364 if ( 'acting_zeus_card' === $payment['settlement'] && 'activate' === $payment['use'] ) {
365 $method = true;
366 break;
367 }
368 }
369 if ( $method && $this->is_activate_card() ) {
370 return true;
371 } else {
372 return false;
373 }
374 break;
375
376 case 'bank':
377 foreach ( $payment_method as $payment ) {
378 if ( 'acting_zeus_bank' === $payment['settlement'] && 'activate' === $payment['use'] ) {
379 $method = true;
380 break;
381 }
382 }
383 if ( $method && $this->is_activate_bank() ) {
384 return true;
385 } else {
386 return false;
387 }
388 break;
389
390 case 'conv':
391 foreach ( $payment_method as $payment ) {
392 if ( 'acting_zeus_conv' === $payment['settlement'] && 'activate' === $payment['use'] ) {
393 $method = true;
394 break;
395 }
396 }
397 if ( $method && $this->is_activate_conv() ) {
398 return true;
399 } else {
400 return false;
401 }
402 break;
403
404 case 'bnpl':
405 foreach ( $payment_method as $payment ) {
406 if ( 'acting_zeus_bnpl' === $payment['settlement'] && 'activate' === $payment['use'] ) {
407 $method = true;
408 break;
409 }
410 }
411 if ( $method && $this->is_activate_bnpl() ) {
412 return true;
413 } else {
414 return false;
415 }
416 break;
417
418 default:
419 if ( 'on' === $acting_opts['activate'] ) {
420 return true;
421 } else {
422 return false;
423 }
424 }
425 }
426
427 /**
428 * クレジットカード決済有効判定
429 *
430 * @param string $type 'link' Secure Link|'api' Secure API.
431 * @return boolean
432 */
433 public function is_activate_card( $type = '' ) {
434 $acting_opts = $this->get_acting_settings();
435 if ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) {
436 if ( empty( $type ) ) {
437 if ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] ) {
438 $res = true;
439 } else {
440 $res = false;
441 }
442 } elseif ( 'link' === $type ) {
443 if ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] && isset( $acting_opts['connection'] ) && 1 === (int) $acting_opts['connection'] ) {
444 $res = true;
445 } else {
446 $res = false;
447 }
448 } elseif ( 'api' === $type ) {
449 if ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] && isset( $acting_opts['connection'] ) && 2 === (int) $acting_opts['connection'] ) {
450 $res = true;
451 } else {
452 $res = false;
453 }
454 } else {
455 $res = false;
456 }
457 } else {
458 $res = false;
459 }
460 return $res;
461 }
462
463 /**
464 * 銀行振込決済(�
465 �金おまかせサービス)有効判定
466 *
467 * @return bool
468 */
469 public function is_activate_bank() {
470 $acting_opts = $this->get_acting_settings();
471 if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
472 ( isset( $acting_opts['bank_activate'] ) && 'on' === $acting_opts['bank_activate'] ) ) {
473 $res = true;
474 } else {
475 $res = false;
476 }
477 return $res;
478 }
479
480 /**
481 * コンビニ決済有効判定
482 *
483 * @return bool
484 */
485 public function is_activate_conv() {
486 $acting_opts = $this->get_acting_settings();
487 if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
488 ( isset( $acting_opts['conv_activate'] ) && 'on' === $acting_opts['conv_activate'] ) ) {
489 $res = true;
490 } else {
491 $res = false;
492 }
493 return $res;
494 }
495
496 /**
497 * あと払い決済有効判定
498 *
499 * @return bool
500 */
501 public function is_activate_bnpl() {
502 $acting_opts = $this->get_acting_settings();
503 if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
504 ( isset( $acting_opts['bnpl_activate'] ) && 'on' === $acting_opts['bnpl_activate'] ) ) {
505 $res = true;
506 } else {
507 $res = false;
508 }
509 return $res;
510 }
511
512 /**
513 * 管理画面メッセージ表示
514 * admin_notices
515 */
516 public function admin_notices() {
517 $acting_opts = $this->get_acting_settings();
518 if ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) {
519 if ( ! isset( $acting_opts['vercheck'] ) || '115' !== $acting_opts['vercheck'] ) {
520 echo '<div class="error"><p>決済に「ゼウス」をご利用の場合は、<a href="' . esc_url( admin_url( 'admin.php?usces_page=usces_settlement' ) ) . '">「セキュリティーコード」の設定�
521 容を確認</a>して更新ボタンを押してください。設定を更新するとこのメッセージは表示されなくなります。</p></div>';
522 }
523 }
524 }
525
526 /**
527 * 管理画面スクリプト
528 * admin_print_footer_scripts
529 */
530 public function admin_scripts() {
531 $admin_page = filter_input( INPUT_GET, 'page' );
532 switch ( $admin_page ) :
533 /* クレジット決済設定画面 */
534 case 'usces_settlement':
535 $settlement_selected = get_option( 'usces_settlement_selected', array() );
536 if ( in_array( $this->paymod_id, (array) $settlement_selected, true ) ) :
537 $acting_opts = $this->get_acting_settings();
538 ?>
539 <script type="text/javascript">
540 jQuery(document).ready(function($) {
541 var card_activate = "<?php echo esc_js( $acting_opts['card_activate'] ); ?>";
542 if( "on" == card_activate ) {
543 $(".card_zeus").css("display","");
544 } else {
545 $(".card_zeus").css("display","none");
546 }
547 $(document).on( "change", ".card_activate_zeus", function() {
548 if( "on" == $(this).val() ) {
549 $(".card_zeus").css("display","");
550 } else {
551 $(".card_zeus").css("display","none");
552 }
553 });
554
555 if( '2' == $("input[name='connection']:checked").val() ) {
556 $(".3dsecur_zeus").css("display","");
557 } else {
558 $(".3dsecur_zeus").css("display","none");
559 }
560 $(document).on( "click", "input[name='connection']", function() {
561 if( '2' == $("input[name='connection']:checked").val() ) {
562 $(".3dsecur_zeus").css("display","");
563 } else {
564 $(".3dsecur_zeus").css("display","none");
565 }
566 });
567
568 if( 'on' == $("input[name='howpay']:checked").val() ) {
569 $(".howpay_option_zeus").css("display","");
570 } else {
571 $(".howpay_option_zeus").css("display","none");
572 }
573 $(document).on( "click", "input[name='howpay']", function() {
574 if( 'on' == $("input[name='howpay']:checked").val() ) {
575 $(".howpay_option_zeus").css("display","");
576 } else {
577 $(".howpay_option_zeus").css("display","none");
578 }
579 });
580
581 var bank_activate = "<?php echo esc_js( $acting_opts['bank_activate'] ); ?>";
582 if( "on" == bank_activate ) {
583 $(".bank_zeus").css("display","");
584 } else {
585 $(".bank_zeus").css("display","none");
586 }
587 $(document).on( "change", ".bank_activate_zeus", function() {
588 if( "on" == $(this).val() ) {
589 $(".bank_zeus").css("display","");
590 } else {
591 $(".bank_zeus").css("display","none");
592 }
593 });
594
595 var conv_activate = "<?php echo esc_js( $acting_opts['conv_activate'] ); ?>";
596 if( "on" == conv_activate ) {
597 $(".conv_zeus").css("display","");
598 } else {
599 $(".conv_zeus").css("display","none");
600 }
601 $(document).on( "change", ".conv_activate_zeus", function() {
602 if( "on" == $(this).val() ) {
603 $(".conv_zeus").css("display","");
604 } else {
605 $(".conv_zeus").css("display","none");
606 }
607 });
608
609 var bnpl_activate = "<?php echo esc_js( $acting_opts['bnpl_activate'] ); ?>";
610 if( "on" == bnpl_activate ) {
611 $(".bnpl_zeus").css("display","");
612 } else {
613 $(".bnpl_zeus").css("display","none");
614 }
615 $(document).on( "change", ".bnpl_activate_zeus", function() {
616 if( "on" == $(this).val() ) {
617 $(".bnpl_zeus").css("display","");
618 } else {
619 $(".bnpl_zeus").css("display","none");
620 }
621 });
622
623 adminSettlementZeus = {
624 openFee : function(mode) {
625 $("#fee_change_field").html("");
626 $("#fee_fix").val($("#"+mode+"_fee").val());
627 $("#fee_limit_amount_fix").val($("#"+mode+"_fee_limit_amount_fix").val());
628 $("#fee_first_amount").val($("#"+mode+"_fee_first_amount").val());
629 $("#fee_first_fee").val($("#"+mode+"_fee_first_fee").val());
630 $("#fee_limit_amount_change").val($("#"+mode+"_fee_limit_amount_change").val());
631 var fee_amounts = new Array();
632 var fee_fees = new Array();
633 if( 0 < $("#"+mode+"_fee_amounts").val().length ) {
634 fee_amounts = $("#"+mode+"_fee_amounts").val().split("|");
635 }
636 if( 0 < $("#"+mode+"_fee_fees").val().length ) {
637 fee_fees = $("#"+mode+"_fee_fees").val().split("|");
638 }
639 if( 0 < fee_amounts.length ) {
640 var amount = parseInt($("#fee_first_amount").val()) + 1;
641 for( var i = 0; i < fee_amounts.length; i++ ) {
642 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>';
643 $("#fee_change_field").append(html);
644 amount = parseInt(fee_amounts[i]) + 1;
645 }
646 $("#end_amount").html(amount);
647 } else {
648 $("#end_amount").html(parseInt($("#"+mode+"_fee_first_amount").val()) + 1);
649 }
650 $("#fee_end_fee").val($("#"+mode+"_fee_end_fee").val());
651
652 var fee_type = $("#"+mode+"_fee_type").val();
653 if( "change" == fee_type ) {
654 $("#fee_type_change").prop("checked",true);
655 $("#zeus_fee_fix_table").css("display","none");
656 $("#zeus_fee_change_table").css("display","");
657 } else {
658 $("#fee_type_fix").prop("checked",true);
659 $("#zeus_fee_fix_table").css("display","");
660 $("#zeus_fee_change_table").css("display","none");
661 }
662 },
663
664 updateFee : function(mode) {
665 var fee_type = $("input[name='fee_type']:checked").val();
666 $("#"+mode+"_fee_type").val(fee_type);
667 $("#"+mode+"_fee").val($("#fee_fix").val());
668 $("#"+mode+"_fee_limit_amount_"+fee_type).val($("#fee_limit_amount_"+fee_type).val());
669 $("#"+mode+"_fee_first_amount").val($("#fee_first_amount").val());
670 $("#"+mode+"_fee_first_fee").val($("#fee_first_fee").val());
671 var fee_amounts = "";
672 var fee_fees = "";
673 var sp = "";
674 var fee_amounts_length = $("input[name^='fee_amounts']").length;
675 for( var i = 0; i < fee_amounts_length; i++ ) {
676 fee_amounts += sp + $("input[name='fee_amounts\["+i+"\]']").val();
677 fee_fees += sp + $("input[name='fee_fees\["+i+"\]']").val();
678 sp = "|";
679 }
680 $("#"+mode+"_fee_amounts").val(fee_amounts);
681 $("#"+mode+"_fee_fees").val(fee_fees);
682 $("#"+mode+"_fee_end_fee").val($("#fee_end_fee").val());
683 },
684
685 setFeeType : function( mode, closed ) {
686 var fee_type = $("input[name='fee_type']:checked").val();
687 if( "change" == fee_type ) {
688 if( "" == $("#fee_first_fee").val() && closed ) {
689 $("#"+mode+"_fee_type_field").html("");
690 } else {
691 $("#"+mode+"_fee_type_field").html("<?php esc_attr_e( 'Variable', 'usces' ); ?> ");
692 }
693 if( !closed ) {
694 $("#zeus_fee_fix_table").css("display","none");
695 $("#zeus_fee_change_table").css("display","");
696 }
697 } else if( "fix" == fee_type ) {
698 if( "" == $("#fee_fix").val() && closed ) {
699 $("#"+mode+"_fee_type_field").html("");
700 } else {
701 $("#"+mode+"_fee_type_field").html("<?php esc_attr_e( 'Fixation', 'usces' ); ?> ");
702 }
703 if( !closed ) {
704 $("#zeus_fee_fix_table").css("display","");
705 $("#zeus_fee_change_table").css("display","none");
706 }
707 }
708 }
709 };
710
711 $("#zeus_fee_dialog").dialog({
712 autoOpen: false,
713 height: 500,
714 width: 450,
715 modal: true,
716 open: function() {
717 adminSettlementZeus.openFee($("#zeus_fee_mode").val());
718 },
719 buttons: {
720 "<?php esc_attr_e( 'Settings' ); ?>": function() {
721 adminSettlementZeus.updateFee($("#zeus_fee_mode").val());
722 },
723 "<?php esc_attr_e( 'Close' ); ?>": function() {
724 $(this).dialog('close');
725 }
726 },
727 close: function() {
728 adminSettlementZeus.setFeeType($("#zeus_fee_mode").val(),true);
729 }
730 });
731
732 $(document).on( "click", "#bnpl_fee_setting", function() {
733 $("#zeus_fee_mode").val("bnpl");
734 $("#zeus_fee_dialog").dialog("option","title","請求手数料設定");
735 $("#zeus_fee_dialog").dialog("open");
736 });
737
738 $(document).on( "click", ".fee_type", function() {
739 if( "change" == $(this).val() ) {
740 $("#zeus_fee_fix_table").css("display","none");
741 $("#zeus_fee_change_table").css("display","");
742 } else {
743 $("#zeus_fee_fix_table").css("display","");
744 $("#zeus_fee_change_table").css("display","none");
745 }
746 });
747
748 $(document).on( "change", "input[name='fee_first_amount']", function() {
749 var rows = $("input[name^='fee_amounts']");
750 var first_amount = $("input[name='fee_first_amount']");
751 if( 0 == rows.length && $(first_amount).val() != '' ) {
752 $("#end_amount").html(parseInt($(first_amount).val()) + 1);
753 } else if( 0 < rows.length && $(first_amount).val() != '' ) {
754 $('#amount_0').html(parseInt($(first_amount).val()) + 1);
755 }
756 });
757
758 $(document).on( "change", "#fee_limit_amount_change", function() {
759 if( "change" == $("input[name='fee_type']:checked").val() ) {
760 var amount = parseInt($("#end_amount").html());
761 var limit = parseInt($("#fee_limit_amount_change").val());
762 if( amount >= limit ) {
763 alert("<?php esc_attr_e( 'A value of the amount of upper limit is incorrect.', 'usces' ); ?>"+amount+' : '+limit);
764 }
765 }
766 });
767
768 $(document).on( "change", "input[name^='fee_amounts']", function() {
769 var rows = $("input[name^='fee_amounts']");
770 var cnt = $(rows).length;
771 var end_amount = $("#end_amount");
772 var id = $(rows).index(this);
773 if( id >= cnt-1 ) {
774 $( end_amount ).html(parseInt($(rows).eq(id).val()) + 1);
775 } else if( id < cnt - 1 ) {
776 $("#amount_"+(id + 1)).html(parseInt($(rows).eq(id).val()) + 1);
777 }
778 });
779
780 $(document).on( "click", "#fee_add_row", function() {
781 var rows = $("input[name^='fee_amounts']");
782 $(rows).unbind("change");
783 var first_amount = $("input[name='fee_first_amount']");
784 var first_fee = $("input[name='fee_first_fee']");
785 var end_amount = $("#end_amount");
786 var enf_fee = $("input[name='fee_end_fee']");
787 if( 0 == rows.length ) {
788 amount = ( $(first_amount).val() == '' ) ? '' : parseInt($(first_amount).val()) + 1;
789 } else if( 0 < rows.length ) {
790 amount = ( $(rows).eq(rows.length-1).val() == '' ) ? '' : parseInt($(rows).eq(rows.length-1).val()) + 1;
791 }
792 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>';
793 $("#fee_change_field").append(html);
794 rows = $("input[name^='fee_amounts']");
795 $(rows).bind( "change", function() {
796 var cnt = $(rows).length - 1;
797 var id = $(rows).index(this);
798 if( id >= cnt ) {
799 $(end_amount).html(parseInt($(rows).eq(id).val()) + 1);
800 } else if( id < cnt ) {
801 $("#amount_"+(id + 1)).html(parseInt($(rows).eq(id).val()) + 1);
802 }
803 });
804 });
805
806 $(document).on( "click", "#fee_del_row", function() {
807 var rows = $("input[name^='fee_amounts']");
808 var first_amount = $("input[name='fee_first_amount']");
809 var end_amount = $("#end_amount");
810 var del_id = rows.length - 1;
811 if( 0 < rows.length ) {
812 $("#row_"+del_id).remove();
813 }
814 rows = $("input[name^='fee_amounts']");
815 if( 0 == rows.length && $(first_amount).val() != "" ) {
816 $(end_amount).html(parseInt($(first_amount).val()) + 1);
817 } else if( 0 < rows.length && $(rows).eq(rows.length - 1).val() != "" ) {
818 $(end_amount).html(parseInt($(rows).eq(rows.length - 1).val()) + 1);
819 }
820 });
821
822 adminSettlementZeus.setFeeType("bnpl",false);
823 });
824 </script>
825 <?php
826 endif;
827 break;
828
829 /* 受注編集画面・継続課金会員詳細画面 */
830 case 'usces_orderlist':
831 case 'usces_continue':
832 $order_id = '';
833 $acting_flg = '';
834 $dialog_title = '';
835 $order_action = filter_input( INPUT_GET, 'order_action' );
836 $continue_action = filter_input( INPUT_GET, 'continue_action' );
837 if ( ( 'usces_orderlist' === $admin_page && ( 'edit' === $order_action || 'editpost' === $order_action || 'newpost' === $order_action ) ) ||
838 ( 'usces_continue' === $admin_page && 'settlement_zeus_card' === $continue_action ) ) {
839 $order_id = ( isset( $_REQUEST['order_id'] ) ) ? wp_unslash( $_REQUEST['order_id'] ) : '';
840 if ( ! empty( $order_id ) ) {
841 $payment_name = $this->get_order_payment_name( $order_id );
842 $acting_flg = $this->get_acting_flg( $payment_name );
843 $payment = usces_get_payments_by_name( $payment_name );
844 if ( isset( $payment['name'] ) ) {
845 $dialog_title = $payment['name'];
846 }
847 }
848 }
849 if ( 'acting_zeus_card' === $acting_flg || 'acting_zeus_bnpl' === $acting_flg ) :
850 ?>
851 <script type="text/javascript">
852 jQuery(document).ready(function($) {
853 adminOrderEdit = {
854 <?php
855 if ( 'acting_zeus_card' === $acting_flg ) :
856 ?>
857 getSettlementCard: function() {
858 $("#settlement-response").html("");
859 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
860 var mode = ( "" != $("#error").val() ) ? "error_zeus_card" : "get_zeus_card";
861 $.ajax({
862 url:ajaxurl,
863 type:"POST",
864 cache:false,
865 dataType:"json",
866 data:{
867 action:"usces_admin_ajax",
868 mode:mode,
869 order_id:$("#order_id").val(),
870 order_num:$("#order_num").val(),
871 tracking_id:$("#tracking_id").val(),
872 member_id:$("#member_id").val(),
873 wc_nonce:$("#wc_nonce").val()
874 }
875 }).done( function(retVal,dataType) {
876 if( retVal.acting_status ) {
877 var num = $("#order_num").val();
878 if( $("#settlement-status-"+num).length ) {
879 $("#settlement-status-"+num).html(retVal.acting_status);
880 } else {
881 $("#settlement-status").html(retVal.acting_status);
882 }
883 }
884 if( retVal.result ) {
885 $("#settlement-response").html(retVal.result);
886 }
887 $("#settlement-response-loading").html("");
888 }).fail( function(jqXHR,textStatus,errorThrown) {
889 console.log(textStatus);
890 console.log(jqXHR.status);
891 console.log(errorThrown.message);
892 $("#settlement-response-loading").html("");
893 });
894 return false;
895 },
896 saleSettlementCard: function(amount) {
897 $("#settlement-response").html("");
898 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
899 $.ajax({
900 url:ajaxurl,
901 type:"POST",
902 cache:false,
903 dataType:"json",
904 data:{
905 action:"usces_admin_ajax",
906 mode:"sale_zeus_card",
907 order_id:$("#order_id").val(),
908 order_num:$("#order_num").val(),
909 tracking_id:$("#tracking_id").val(),
910 member_id:$("#member_id").val(),
911 amount:amount,
912 wc_nonce:$("#wc_nonce").val()
913 }
914 }).done( function(retVal,dataType) {
915 if( retVal.acting_status ) {
916 var num = $("#order_num").val();
917 if( $("#settlement-status-"+num).length ) {
918 $("#settlement-status-"+num).html(retVal.acting_status);
919 } else {
920 $("#settlement-status").html(retVal.acting_status);
921 }
922 }
923 if( retVal.result ) {
924 $("#settlement-response").html(retVal.result);
925 }
926 $("#settlement-response-loading").html("");
927 }).fail( function(jqXHR,textStatus,errorThrown) {
928 console.log(textStatus);
929 console.log(jqXHR.status);
930 console.log(errorThrown.message);
931 $("#settlement-response-loading").html("");
932 });
933 return false;
934 },
935 cancelSettlementCard: function() {
936 $("#settlement-response").html("");
937 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
938 $.ajax({
939 url:ajaxurl,
940 type:"POST",
941 cache:false,
942 dataType:"json",
943 data:{
944 action:"usces_admin_ajax",
945 mode:"cancel_zeus_card",
946 order_id:$("#order_id").val(),
947 order_num:$("#order_num").val(),
948 tracking_id:$("#tracking_id").val(),
949 member_id:$("#member_id").val(),
950 wc_nonce:$("#wc_nonce").val()
951 }
952 }).done( function(retVal,dataType) {
953 if( retVal.acting_status ) {
954 var num = $("#order_num").val();
955 if( $("#settlement-status-"+num).length ) {
956 $("#settlement-status-"+num).html(retVal.acting_status);
957 } else {
958 $("#settlement-status").html(retVal.acting_status);
959 }
960 }
961 if( retVal.result ) {
962 $("#settlement-response").html(retVal.result);
963 }
964 $("#settlement-response-loading").html("");
965 }).fail( function(jqXHR,textStatus,errorThrown) {
966 console.log(textStatus);
967 console.log(jqXHR.status);
968 console.log(errorThrown.message);
969 $("#settlement-response-loading").html("");
970 });
971 return false;
972 },
973 changeSettlementCard: function(amount) {
974 $("#settlement-response").html("");
975 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
976 $.ajax({
977 url:ajaxurl,
978 type:"POST",
979 cache:false,
980 dataType:"json",
981 data:{
982 action:"usces_admin_ajax",
983 mode:"change_zeus_card",
984 order_id:$("#order_id").val(),
985 order_num:$("#order_num").val(),
986 tracking_id:$("#tracking_id").val(),
987 member_id:$("#member_id").val(),
988 amount:amount,
989 wc_nonce:$("#wc_nonce").val()
990 }
991 }).done( function(retVal,dataType) {
992 if( retVal.acting_status ) {
993 var num = $("#order_num").val();
994 if( $("#settlement-status-"+num).length ) {
995 $("#settlement-status-"+num).html(retVal.acting_status);
996 } else {
997 $("#settlement-status").html(retVal.acting_status);
998 }
999 }
1000 if( retVal.result ) {
1001 $("#settlement-response").html(retVal.result);
1002 }
1003 $("#settlement-response-loading").html("");
1004 }).fail( function(jqXHR,textStatus,errorThrown) {
1005 console.log(textStatus);
1006 console.log(jqXHR.status);
1007 console.log(errorThrown.message);
1008 $("#settlement-response-loading").html("");
1009 });
1010 return false;
1011 },
1012 reSettlementCard: function(amount) {
1013 $("#settlement-response").html("");
1014 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
1015 $.ajax({
1016 url:ajaxurl,
1017 type:"POST",
1018 cache:false,
1019 dataType:"json",
1020 data:{
1021 action:"usces_admin_ajax",
1022 mode:"re_settlement_zeus_card",
1023 order_id:$("#order_id").val(),
1024 order_num:$("#order_num").val(),
1025 tracking_id:$("#tracking_id").val(),
1026 member_id:$("#member_id").val(),
1027 amount:amount,
1028 wc_nonce:$("#wc_nonce").val()
1029 }
1030 }).done( function(retVal,dataType) {
1031 if( retVal.acting_status ) {
1032 var num = $("#order_num").val();
1033 if( $("#settlement-status-"+num).length ) {
1034 $("#settlement-status-"+num).html(retVal.acting_status);
1035 } else {
1036 $("#settlement-status").html(retVal.acting_status);
1037 }
1038 }
1039 if( retVal.result ) {
1040 $("#settlement-response").html(retVal.result);
1041 }
1042 $("#settlement-response-loading").html("");
1043 }).fail( function(jqXHR,textStatus,errorThrown) {
1044 console.log(textStatus);
1045 console.log(jqXHR.status);
1046 console.log(errorThrown.message);
1047 $("#settlement-response-loading").html("");
1048 });
1049 return false;
1050 },
1051 <?php
1052 elseif ( 'acting_zeus_bnpl' === $acting_flg ) :
1053 ?>
1054 getSettlementBnpl: function() {
1055 $("#settlement-response").html("");
1056 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
1057 $.ajax({
1058 url:ajaxurl,
1059 type:"POST",
1060 cache:false,
1061 dataType:"json",
1062 data:{
1063 action:"usces_admin_ajax",
1064 mode:"get_zeus_bnpl",
1065 order_id:$("#order_id").val(),
1066 shoporder_id:$("#tracking_id").val(),
1067 order_status:$("select[name='offer[taio]'] option:selected").val(),
1068 delivery_company:$("select[name='delivery_company'] option:selected").val(),
1069 tracking_number:$("input[name='tracking_number']").val(),
1070 wc_nonce:$("#wc_nonce").val()
1071 }
1072 }).done( function(retVal,dataType) {
1073 if( retVal.acting_status ) {
1074 $("#settlement-status").html(retVal.acting_status);
1075 }
1076 if( retVal.result ) {
1077 $("#settlement-response").html(retVal.result);
1078 }
1079 $("#settlement-response-loading").html("");
1080 }).fail( function(jqXHR,textStatus,errorThrown) {
1081 console.log(textStatus);
1082 console.log(jqXHR.status);
1083 console.log(errorThrown.message);
1084 $("#settlement-response-loading").html("");
1085 });
1086 return false;
1087 },
1088 shippingRequestBnpl: function() {
1089 $("#settlement-response").html("");
1090 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
1091 $.ajax({
1092 url:ajaxurl,
1093 type:"POST",
1094 cache:false,
1095 dataType:"json",
1096 data:{
1097 action:"usces_admin_ajax",
1098 mode:"shippingrequest_zeus_bnpl",
1099 order_id:$("#order_id").val(),
1100 shoporder_id:$("#tracking_id").val(),
1101 order_status:$("select[name='offer[taio]'] option:selected").val(),
1102 delivery_company:$("select[name='delivery_company'] option:selected").val(),
1103 tracking_number:$("input[name='tracking_number']").val(),
1104 wc_nonce:$("#wc_nonce").val()
1105 }
1106 }).done( function(retVal,dataType) {
1107 if( retVal.acting_status ) {
1108 $("#settlement-status").html(retVal.acting_status);
1109 }
1110 if( retVal.result ) {
1111 $("#settlement-response").html(retVal.result);
1112 }
1113 $("#settlement-response-loading").html("");
1114 }).fail( function(jqXHR,textStatus,errorThrown) {
1115 console.log(textStatus);
1116 console.log(jqXHR.status);
1117 console.log(errorThrown.message);
1118 $("#settlement-response-loading").html("");
1119 });
1120 return false;
1121 },
1122 cancelBnpl: function() {
1123 $("#settlement-response").html("");
1124 $("#settlement-response-loading").html('<img src="'+uscesL10n.USCES_PLUGIN_URL+'/images/loading.gif" />');
1125 $.ajax({
1126 url:ajaxurl,
1127 type:"POST",
1128 cache:false,
1129 dataType:"json",
1130 data:{
1131 action:"usces_admin_ajax",
1132 mode:"cancel_zeus_bnpl",
1133 order_id:$("#order_id").val(),
1134 shoporder_id:$("#tracking_id").val(),
1135 order_status:$("select[name='offer[taio]'] option:selected").val(),
1136 delivery_company:$("select[name='delivery_company'] option:selected").val(),
1137 tracking_number:$("input[name='tracking_number']").val(),
1138 wc_nonce:$("#wc_nonce").val()
1139 }
1140 }).done( function(retVal,dataType) {
1141 if( retVal.acting_status ) {
1142 $("#settlement-status").html(retVal.acting_status);
1143 }
1144 if( retVal.result ) {
1145 $("#settlement-response").html(retVal.result);
1146 }
1147 $("#settlement-response-loading").html("");
1148 }).fail( function(jqXHR,textStatus,errorThrown) {
1149 console.log(textStatus);
1150 console.log(jqXHR.status);
1151 console.log(errorThrown.message);
1152 $("#settlement-response-loading").html("");
1153 });
1154 return false;
1155 },
1156 <?php
1157 endif;
1158 ?>
1159 };
1160
1161 $("#settlement_dialog").dialog({
1162 dialogClass:"admin-zeus-dialog",
1163 bgiframe:true,
1164 autoOpen:false,
1165 height:"auto",
1166 width:800,
1167 resizable:true,
1168 modal:true,
1169 buttons: {
1170 "<?php esc_html_e( 'Close' ); ?>":function() {
1171 $(this).dialog("close");
1172 }
1173 },
1174 open: function() {
1175 <?php
1176 if ( 'acting_zeus_card' === $acting_flg ) :
1177 ?>
1178 adminOrderEdit.getSettlementCard();
1179 <?php
1180 elseif ( 'acting_zeus_bnpl' === $acting_flg ) :
1181 ?>
1182 adminOrderEdit.getSettlementBnpl();
1183 <?php
1184 endif;
1185 ?>
1186 },
1187 close: function() {
1188 }
1189 });
1190
1191 $(document).on( "click", ".settlement-information", function() {
1192 var tracking_id = $(this).attr("data-tracking_id");
1193 var order_num = $(this).attr("data-num");
1194 $("#tracking_id").val(tracking_id);
1195 $("#order_num").val(order_num);
1196 $("#settlement_dialog").dialog("option","title","<?php echo esc_js( $dialog_title ); ?>");
1197 $("#settlement_dialog").dialog("open");
1198 });
1199 <?php
1200 if ( 'acting_zeus_card' === $acting_flg ) :
1201 ?>
1202 $(document).on( "click", "#sale_settlement", function() {
1203 var amount = parseInt($("#amount_change").val())||0;
1204 if( 0 == amount ) {
1205 if( ! confirm("取消処理を実行します。よろしいですか?") ) {
1206 return;
1207 }
1208 adminOrderEdit.cancelSettlementCard();
1209 } else {
1210 if( ! confirm("売上処理を実行します。よろしいですか?") ) {
1211 return;
1212 }
1213 adminOrderEdit.saleSettlementCard(amount);
1214 }
1215 });
1216
1217 $(document).on( "click", "#cancel_settlement", function() {
1218 if( ! confirm("取消処理を実行します。よろしいですか?") ) {
1219 return;
1220 }
1221 adminOrderEdit.cancelSettlementCard();
1222 });
1223
1224 $(document).on( "click", "#change_settlement", function() {
1225 var amount_change = parseInt($("#amount_change").val())||0;
1226 if( 0 == amount_change ) {
1227 if( ! confirm("取消処理を実行します。よろしいですか?") ) {
1228 return;
1229 }
1230 adminOrderEdit.cancelSettlementCard();
1231 } else {
1232 if( ! confirm("決済金額を"+amount_change+"円に変更します。よろしいですか?") ) {
1233 return;
1234 }
1235 adminOrderEdit.changeSettlementCard(amount_change);
1236 }
1237 });
1238
1239 $(document).on( "click", "#re_settlement", function() {
1240 var amount = parseInt($("#amount_change").val())||0;
1241 if( 0 < amount ) {
1242 if( ! confirm("新規決済を実行します。よろしいですか?") ) {
1243 return;
1244 }
1245 adminOrderEdit.reSettlementCard( amount );
1246 }
1247 });
1248 <?php
1249 elseif ( 'acting_zeus_bnpl' === $acting_flg ) :
1250 ?>
1251 $(document).on( "click", "#shippingrequest_bnpl", function() {
1252 if( ! confirm("出荷登録を実行します。よろしいですか?") ) {
1253 return;
1254 }
1255 adminOrderEdit.shippingRequestBnpl();
1256 });
1257 $(document).on( "click", "#cancel_bnpl", function() {
1258 if( ! confirm("取引のキャンセルを実行します。よろしいですか?") ) {
1259 return;
1260 }
1261 adminOrderEdit.cancelBnpl();
1262 });
1263 <?php
1264 endif;
1265 ?>
1266 $(document).on( "keydown", ".settlement-amount", function(e) {
1267 var halfVal = $(this).val().replace(/[-]/g,
1268 function(tmpStr) {
1269 return String.fromCharCode(tmpStr.charCodeAt(0)-0xFEE0);
1270 }
1271 );
1272 $(this).val(halfVal.replace(/[^0-9]/g,''));
1273 });
1274 $(document).on( "keyup", ".settlement-amount", function() {
1275 this.value = this.value.replace(/[^0-9]+/i,'');
1276 this.value = Number(this.value)||0;
1277 });
1278 $(document).on( "blur", ".settlement-amount", function() {
1279 this.value = this.value.replace(/[^0-9]+/i,'');
1280 });
1281 <?php if ( 'usces_continue' === $admin_page ) : ?>
1282 adminContinuation = {
1283 update : function() {
1284 $.ajax({
1285 url: ajaxurl,
1286 type: "POST",
1287 cache: false,
1288 dataType: 'json',
1289 data: {
1290 action: "usces_admin_ajax",
1291 mode: "continuation_update",
1292 member_id: $("#member_id").val(),
1293 order_id: $("#order_id").val(),
1294 contracted_year: $("#contracted-year option:selected").val(),
1295 contracted_month: $("#contracted-month option:selected").val(),
1296 contracted_day: $("#contracted-day option:selected").val(),
1297 charged_year: $("#charged-year option:selected").val(),
1298 charged_month: $("#charged-month option:selected").val(),
1299 charged_day: $("#charged-day option:selected").val(),
1300 price: $("#price").val(),
1301 status: $("#dlseller-status").val(),
1302 wc_nonce: $("#wc_nonce").val()
1303 }
1304 }).done( function(retVal,dataType) {
1305 if( "OK" == retVal.status ) {
1306 adminOperation.setActionStatus("success","<?php esc_html_e( 'The update was completed.', 'usces' ); ?>");
1307 } else {
1308 var message = ( retVal.message != "" ) ? retVal.message : "<?php esc_html_e( 'failure in update', 'usces' ); ?>";
1309 adminOperation.setActionStatus("error",message);
1310 }
1311 }).fail( function(jqXHR,textStatus,errorThrown) {
1312 console.log(textStatus);
1313 console.log(jqXHR.status);
1314 console.log(errorThrown.message);
1315 adminOperation.setActionStatus("error","<?php esc_html_e( 'failure in update', 'usces' ); ?>");
1316 });
1317 return false;
1318 }
1319 };
1320
1321 $(document).on( "click", "#continuation-update", function() {
1322 var status = $("#dlseller-status option:selected").val();
1323 if( "continuation" == status ) {
1324 var year = $("#charged-year option:selected").val();
1325 var month = $("#charged-month option:selected").val();
1326 var day = $("#charged-day option:selected").val();
1327 if( 0 == year || 0 == month || 0 == day ) {
1328 alert("<?php esc_html_e( 'Data have deficiency.', 'usces' ); ?>");
1329 $("#charged-year").focus();
1330 return;
1331 }
1332 if( "" == $("#price").val() || 0 == parseFloat($("#price").val()) ) {
1333 alert("<?php printf( __( 'Input the %s', 'usces' ), esc_html__( 'Amount', 'dlseller' ) ); ?>");
1334 $("#price").focus();
1335 return;
1336 }
1337 }
1338 if( ! confirm("<?php esc_html_e( 'Are you sure you want to update the settings?', 'usces' ); ?>") ) {
1339 return;
1340 }
1341 adminContinuation.update();
1342 });
1343 <?php endif; ?>
1344 });
1345 </script>
1346 <?php
1347 endif;
1348 break;
1349 endswitch;
1350 }
1351
1352 /**
1353 * 決済オプション登録・更新
1354 * usces_action_admin_settlement_update
1355 */
1356 public function settlement_update() {
1357 global $usces;
1358
1359 if ( filter_input( INPUT_POST, 'acting' ) !== $this->paymod_id ) {
1360 return;
1361 }
1362
1363 $this->error_mes = '';
1364 $options = get_option( 'usces', array() );
1365 $payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
1366 $post_data = wp_unslash( $_POST );
1367
1368 unset( $options['acting_settings']['zeus'] );
1369 $options['acting_settings']['zeus']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : '';
1370 $options['acting_settings']['zeus']['clientip'] = ( isset( $post_data['clientip'] ) ) ? trim( $post_data['clientip'] ) : '';
1371 $options['acting_settings']['zeus']['connection'] = ( isset( $post_data['connection'] ) ) ? $post_data['connection'] : 1;
1372 $options['acting_settings']['zeus']['3dsecur'] = ( isset( $post_data['3dsecur'] ) ) ? $post_data['3dsecur'] : 2;
1373 if ( isset( $post_data['3ds_pattern'] ) ) {
1374 $options['acting_settings']['zeus']['3ds_pattern'] = $post_data['3ds_pattern'];
1375 }
1376 $options['acting_settings']['zeus']['security'] = ( isset( $post_data['security'] ) ) ? $post_data['security'] : 2;
1377 if ( isset( $post_data['authkey'] ) ) {
1378 $options['acting_settings']['zeus']['authkey'] = trim( $post_data['authkey'] );
1379 }
1380 $options['acting_settings']['zeus']['quickcharge'] = ( isset( $post_data['quickcharge'] ) ) ? $post_data['quickcharge'] : '';
1381 $options['acting_settings']['zeus']['batch'] = ( isset( $post_data['batch'] ) ) ? $post_data['batch'] : '';
1382 $options['acting_settings']['zeus']['auto_settlement_mail'] = ( isset( $post_data['auto_settlement_mail'] ) ) ? $post_data['auto_settlement_mail'] : 'off';
1383 $options['acting_settings']['zeus']['howpay'] = ( isset( $post_data['howpay'] ) ) ? $post_data['howpay'] : '';
1384 $options['acting_settings']['zeus']['howpay_B1'] = ( isset( $post_data['howpay_B1'] ) ) ? $post_data['howpay_B1'] : '';
1385 $options['acting_settings']['zeus']['howpay_02'] = ( isset( $post_data['howpay_02'] ) ) ? $post_data['howpay_02'] : '';
1386 $options['acting_settings']['zeus']['bank_activate'] = ( isset( $post_data['bank_activate'] ) ) ? $post_data['bank_activate'] : '';
1387 $options['acting_settings']['zeus']['bank_ope'] = ( isset( $post_data['bank_ope'] ) ) ? $post_data['bank_ope'] : '';
1388 $options['acting_settings']['zeus']['clientip_bank'] = ( isset( $post_data['clientip_bank'] ) ) ? trim( $post_data['clientip_bank'] ) : '';
1389 $options['acting_settings']['zeus']['testid_bank'] = ( isset( $post_data['testid_bank'] ) ) ? trim( $post_data['testid_bank'] ) : '';
1390 $options['acting_settings']['zeus']['bank_expired_date'] = ( isset( $post_data['bank_expired_date'] ) ) ? trim( $post_data['bank_expired_date'] ) : '';
1391 $options['acting_settings']['zeus']['conv_activate'] = ( isset( $post_data['conv_activate'] ) ) ? $post_data['conv_activate'] : '';
1392 $options['acting_settings']['zeus']['conv_ope'] = ( isset( $post_data['conv_ope'] ) ) ? $post_data['conv_ope'] : '';
1393 $options['acting_settings']['zeus']['clientip_conv'] = ( isset( $post_data['clientip_conv'] ) ) ? trim( $post_data['clientip_conv'] ) : '';
1394 $options['acting_settings']['zeus']['testid_conv'] = ( isset( $post_data['testid_conv'] ) ) ? trim( $post_data['testid_conv'] ) : '';
1395 $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'];
1396 $options['acting_settings']['zeus']['pay_cvs'] = ( isset( $post_data['pay_cvs'] ) ) ? $post_data['pay_cvs'] : array();
1397 $options['acting_settings']['zeus']['conv_span'] = ( isset( $post_data['conv_span'] ) ) ? trim( $post_data['conv_span'] ) : '';
1398 $options['acting_settings']['zeus']['bnpl_activate'] = ( isset( $post_data['bnpl_activate'] ) ) ? $post_data['bnpl_activate'] : '';
1399 $options['acting_settings']['zeus']['clientip_bnpl'] = ( isset( $post_data['clientip_bnpl'] ) ) ? trim( $post_data['clientip_bnpl'] ) : '';
1400 $options['acting_settings']['zeus']['bnpl_linkpassword'] = ( isset( $post_data['bnpl_linkpassword'] ) ) ? trim( $post_data['bnpl_linkpassword'] ) : '';
1401 $options['acting_settings']['zeus']['bnpl_fee_type'] = ( isset( $post_data['bnpl_fee_type'] ) ) ? $post_data['bnpl_fee_type'] : '';
1402 $options['acting_settings']['zeus']['bnpl_fee'] = ( isset( $post_data['bnpl_fee'] ) ) ? $post_data['bnpl_fee'] : '';
1403 $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'] ] : '';
1404 $options['acting_settings']['zeus']['bnpl_fee_first_amount'] = ( isset( $post_data['bnpl_fee_first_amount'] ) ) ? $post_data['bnpl_fee_first_amount'] : '';
1405 $options['acting_settings']['zeus']['bnpl_fee_first_fee'] = ( isset( $post_data['bnpl_fee_first_fee'] ) ) ? $post_data['bnpl_fee_first_fee'] : '';
1406 $options['acting_settings']['zeus']['bnpl_fee_amounts'] = ( isset( $post_data['bnpl_fee_amounts'] ) ) ? explode( '|', $post_data['bnpl_fee_amounts'] ) : array();
1407 $options['acting_settings']['zeus']['bnpl_fee_fees'] = ( isset( $post_data['bnpl_fee_fees'] ) ) ? explode( '|', $post_data['bnpl_fee_fees'] ) : array();
1408 $options['acting_settings']['zeus']['bnpl_fee_end_fee'] = ( isset( $post_data['bnpl_fee_end_fee'] ) ) ? $post_data['bnpl_fee_end_fee'] : '';
1409
1410 if ( 'on' === $options['acting_settings']['zeus']['card_activate'] ) {
1411 if ( WCUtils::is_blank( $post_data['clientip'] ) ) {
1412 $this->error_mes .= '※カード決済IPコードを�
1413 �力してください<br />';
1414 }
1415 if ( WCUtils::is_blank( $post_data['authkey'] ) && 2 === (int) $post_data['connection'] ) {
1416 $this->error_mes .= '※認証キーを�
1417 �力してください<br />';
1418 }
1419 if ( isset( $post_data['batch'] ) && 'on' === $post_data['batch'] ) {
1420 if ( isset( $post_data['quickcharge'] ) && 'on' === $post_data['quickcharge'] ) {
1421 } else {
1422 $this->error_mes .= '※バッチ処理を利用する場合は、QuickCharge を「利用する」にしてください<br />';
1423 $options['acting_settings']['zeus']['quickcharge'] = 'on';
1424 }
1425 }
1426 }
1427 if ( 'on' === $options['acting_settings']['zeus']['bank_activate'] ) {
1428 if ( WCUtils::is_blank( $post_data['clientip_bank'] ) ) {
1429 $this->error_mes .= '※銀行振込決済(�
1430 �金おまかせサービス)IPコードを�
1431 �力してください<br />';
1432 }
1433 if ( WCUtils::is_blank( $post_data['testid_bank'] ) && isset( $post_data['bank_ope'] ) && 'test' === $post_data['bank_ope'] ) {
1434 $this->error_mes .= '※銀行振込決済(�
1435 �金おまかせサービス)テストIDを�
1436 �力してください<br />';
1437 }
1438 }
1439 if ( 'on' === $options['acting_settings']['zeus']['conv_activate'] ) {
1440 if ( WCUtils::is_blank( $post_data['clientip_conv'] ) ) {
1441 $this->error_mes .= '※コンビニ決済IPコードを�
1442 �力してください<br />';
1443 }
1444 if ( WCUtils::is_blank( $post_data['testid_conv'] ) && isset( $post_data['conv_ope'] ) && 'test' === $post_data['conv_ope'] ) {
1445 $this->error_mes .= '※コンビニ決済テストIDを�
1446 �力してください<br />';
1447 }
1448 if ( empty( $post_data['pay_cvs'] ) ) {
1449 $this->error_mes .= '※コンビニ種類を選択してください<br />';
1450 }
1451 }
1452 if ( 'on' === $options['acting_settings']['zeus']['bnpl_activate'] ) {
1453 if ( WCUtils::is_blank( $post_data['clientip_bnpl'] ) ) {
1454 $this->error_mes .= '※あと払い決済IPコードを�
1455 �力してください<br />';
1456 }
1457 if ( WCUtils::is_blank( $post_data['bnpl_linkpassword'] ) ) {
1458 $this->error_mes .= '※あと払い決済APIキーを�
1459 �力してください<br />';
1460 }
1461 }
1462 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'] ) {
1463 $unavailable_activate = false;
1464 foreach ( $payment_method as $settlement => $payment ) {
1465 if ( in_array( $settlement, $this->unavailable_method ) && 'activate' === $payment['use'] ) {
1466 $unavailable_activate = true;
1467 break;
1468 }
1469 }
1470 if ( $unavailable_activate ) {
1471 $this->error_mes .= __( '* Settlement that can not be used together is activated.', 'usces' ) . '<br />';
1472 }
1473 }
1474
1475 if ( '' === $this->error_mes ) {
1476 $usces->action_status = 'success';
1477 $usces->action_message = __( 'Options are updated.', 'usces' );
1478 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'] ) {
1479 $options['acting_settings']['zeus']['activate'] = 'on';
1480 $options['acting_settings']['zeus']['ipaddrs'] = self::ACTING_NOTICE_IPADDRS;
1481 $toactive = array();
1482 if ( 'on' === $options['acting_settings']['zeus']['card_activate'] ) {
1483 $options['acting_settings']['zeus']['card_url'] = 'https://linkpt.cardservice.co.jp/cgi-bin/secure.cgi';
1484 $options['acting_settings']['zeus']['card_secureurl'] = 'https://linkpt.cardservice.co.jp/cgi-bin/secure/api.cgi';
1485 $options['acting_settings']['zeus']['card_tokenurl'] = 'https://linkpt.cardservice.co.jp/cgi-bin/token/token.cgi';
1486 $options['acting_settings']['zeus']['card_order_ref'] = 'https://linkpt.cardservice.co.jp/cgi-bin/order_ref.cgi';
1487 $options['acting_settings']['zeus']['card_price_change'] = 'https://linkpt.cardservice.co.jp/cgi-bin/credit/price_change/reflect/index.cgi';
1488 $usces->payment_structure['acting_zeus_card'] = 'カード決済(ZEUS)';
1489 foreach ( $payment_method as $settlement => $payment ) {
1490 if ( 'acting_zeus_card' === $settlement && 'activate' !== $payment['use'] ) {
1491 $toactive[] = $payment['name'];
1492 }
1493 }
1494 } else {
1495 unset( $usces->payment_structure['acting_zeus_card'] );
1496 }
1497 if ( 'on' === $options['acting_settings']['zeus']['bank_activate'] ) {
1498 $options['acting_settings']['zeus']['bank_url'] = 'https://linkpt.cardservice.co.jp/cgi-bin/ebank.cgi';
1499 $usces->payment_structure['acting_zeus_bank'] = '銀行振込決済(ZEUS)';
1500 foreach ( $payment_method as $settlement => $payment ) {
1501 if ( 'acting_zeus_bank' === $settlement && 'activate' !== $payment['use'] ) {
1502 $toactive[] = $payment['name'];
1503 }
1504 }
1505 } else {
1506 unset( $usces->payment_structure['acting_zeus_bank'] );
1507 }
1508 if ( 'on' === $options['acting_settings']['zeus']['conv_activate'] ) {
1509 $options['acting_settings']['zeus']['conv_url'] = 'https://linkpt.cardservice.co.jp/cgi-bin/cvs.cgi';
1510 $usces->payment_structure['acting_zeus_conv'] = 'コンビニ決済(ZEUS)';
1511 foreach ( $payment_method as $settlement => $payment ) {
1512 if ( 'acting_zeus_conv' === $settlement && 'activate' !== $payment['use'] ) {
1513 $toactive[] = $payment['name'];
1514 }
1515 }
1516 } else {
1517 unset( $usces->payment_structure['acting_zeus_conv'] );
1518 }
1519 if ( 'on' === $options['acting_settings']['zeus']['bnpl_activate'] ) {
1520 $options['acting_settings']['zeus']['bnpl_linkid'] = 'sbifsprd01';
1521 $options['acting_settings']['zeus']['bnpl_transaction_url'] = 'https://atobarai.sbi-finsol.co.jp/api/transaction.do';
1522 $options['acting_settings']['zeus']['bnpl_shippingrequest_url'] = 'https://atobarai.sbi-finsol.co.jp/api/shippingrequest.do';
1523 $options['acting_settings']['zeus']['bnpl_modifytransaction_url'] = 'https://atobarai.sbi-finsol.co.jp/api/modifytransaction.do';
1524 $usces->payment_structure['acting_zeus_bnpl'] = 'あと払い決済(ZEUS)';
1525 foreach ( $payment_method as $settlement => $payment ) {
1526 if ( 'acting_zeus_bnpl' === $settlement && 'activate' !== $payment['use'] ) {
1527 $toactive[] = $payment['name'];
1528 }
1529 }
1530 } else {
1531 unset( $usces->payment_structure['acting_zeus_bnpl'] );
1532 }
1533 $options['acting_settings']['zeus']['vercheck'] = '115';
1534 usces_admin_orderlist_show_wc_trans_id();
1535 if ( 0 < count( $toactive ) ) {
1536 $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' );
1537 }
1538 } else {
1539 $options['acting_settings']['zeus']['activate'] = 'off';
1540 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'] );
1541 }
1542 if ( 'on' !== $options['acting_settings']['zeus']['quickcharge'] || 'off' === $options['acting_settings']['zeus']['activate'] ) {
1543 usces_clear_quickcharge( 'zeus_pcid' );
1544 }
1545 $deactivate = array();
1546 foreach ( $payment_method as $settlement => $payment ) {
1547 if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
1548 if ( 'deactivate' !== $payment['use'] ) {
1549 $payment['use'] = 'deactivate';
1550 $deactivate[] = $payment['name'];
1551 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
1552 }
1553 }
1554 }
1555 if ( 0 < count( $deactivate ) ) {
1556 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
1557 $usces->action_message .= $deactivate_message;
1558 }
1559 } else {
1560 $usces->action_status = 'error';
1561 $usces->action_message = __( 'Data have deficiency.', 'usces' );
1562 $options['acting_settings']['zeus']['activate'] = 'off';
1563 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'] );
1564 $deactivate = array();
1565 foreach ( $payment_method as $settlement => $payment ) {
1566 if ( in_array( $settlement, $this->pay_method ) ) {
1567 if ( 'deactivate' !== $payment['use'] ) {
1568 $payment['use'] = 'deactivate';
1569 $deactivate[] = $payment['name'];
1570 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
1571 }
1572 }
1573 }
1574 if ( 0 < count( $deactivate ) ) {
1575 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
1576 $usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
1577 }
1578 }
1579 ksort( $usces->payment_structure );
1580 update_option( 'usces', $options );
1581 update_option( 'usces_payment_structure', $usces->payment_structure );
1582 }
1583
1584 /**
1585 * クレジット決済設定画面タブ
1586 * usces_action_settlement_tab_title
1587 */
1588 public function settlement_tab_title() {
1589 $settlement_selected = get_option( 'usces_settlement_selected', array() );
1590 if ( in_array( 'zeus', (array) $settlement_selected, true ) ) {
1591 echo '<li><a href="#uscestabs_zeus">ゼウス</a></li>';
1592 }
1593 }
1594
1595 /**
1596 * クレジット決済設定画面フォーム
1597 * usces_action_settlement_tab_body
1598 */
1599 public function settlement_tab_body() {
1600 global $usces;
1601
1602 $acting_opts = $this->get_acting_settings();
1603 $settlement_selected = get_option( 'usces_settlement_selected', array() );
1604 if ( in_array( 'zeus', (array) $settlement_selected, true ) ) :
1605 $card_activate = ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] ) ? 'on' : 'off';
1606 $client_ip = ( isset( $acting_opts['clientip'] ) ) ? $acting_opts['clientip'] : '';
1607 $connection = ( isset( $acting_opts['connection'] ) ) ? (int) $acting_opts['connection'] : 0;
1608 $authkey = ( isset( $acting_opts['authkey'] ) ) ? $acting_opts['authkey'] : '';
1609 $threedsecure = ( 2 === $connection && isset( $acting_opts['3dsecur'] ) && 1 === (int) $acting_opts['3dsecur'] ) ? 1 : 2;
1610 $pattern = ( 2 === $connection && isset( $acting_opts['3ds_pattern'] ) ) ? $acting_opts['3ds_pattern'] : '';
1611 $security = ( isset( $acting_opts['security'] ) && 1 === (int) $acting_opts['security'] ) ? 1 : 2;
1612 $quickcharge = ( isset( $acting_opts['quickcharge'] ) && 'on' === $acting_opts['quickcharge'] ) ? $acting_opts['quickcharge'] : 'off';
1613 $batch = ( isset( $acting_opts['batch'] ) && 'on' === $acting_opts['batch'] ) ? $acting_opts['batch'] : 'off';
1614 $howpay = ( isset( $acting_opts['howpay'] ) && 'on' === $acting_opts['howpay'] ) ? $acting_opts['howpay'] : 'off';
1615 $howpay_b1 = ( isset( $acting_opts['howpay_B1'] ) && 'on' === $acting_opts['howpay_B1'] ) ? $acting_opts['howpay_B1'] : '';
1616 $howpay_02 = ( isset( $acting_opts['howpay_02'] ) && 'on' === $acting_opts['howpay_02'] ) ? $acting_opts['howpay_02'] : '';
1617 $wcex_name = '';
1618 if ( defined( 'WCEX_DLSELLER' ) ) {
1619 $wcex_name = '自動継続課金';
1620 } elseif ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
1621 $wcex_name = '定期購�
1622 �';
1623 }
1624 $auto_settlement_mail = ( isset( $acting_opts['auto_settlement_mail'] ) && 'on' === $acting_opts['auto_settlement_mail'] ) ? 'on' : 'off';
1625
1626 $bank_activate = ( isset( $acting_opts['bank_activate'] ) && 'on' === $acting_opts['bank_activate'] ) ? 'on' : 'off';
1627 $bank_ope = ( isset( $acting_opts['bank_ope'] ) && 'public' === $acting_opts['bank_ope'] ) ? 'public' : 'test';
1628 $client_ip_bank = ( isset( $acting_opts['clientip_bank'] ) ) ? $acting_opts['clientip_bank'] : '';
1629 $testid_bank = ( isset( $acting_opts['testid_bank'] ) ) ? $acting_opts['testid_bank'] : '';
1630 $bank_expired_date = ( isset( $acting_opts['bank_expired_date'] ) ) ? $acting_opts['bank_expired_date'] : '';
1631
1632 $conv_activate = ( isset( $acting_opts['conv_activate'] ) && 'on' === $acting_opts['conv_activate'] ) ? 'on' : 'off';
1633 $conv_ope = ( isset( $acting_opts['conv_ope'] ) && 'public' === $acting_opts['conv_ope'] ) ? 'public' : 'test';
1634 $client_ip_conv = ( isset( $acting_opts['clientip_conv'] ) ) ? $acting_opts['clientip_conv'] : '';
1635 $testid_conv = ( isset( $acting_opts['testid_conv'] ) ) ? $acting_opts['testid_conv'] : '';
1636 $test_type_conv = ( isset( $acting_opts['test_type_conv'] ) ) ? (int) $acting_opts['test_type_conv'] : 0;
1637 $pay_cvs = ( isset( $acting_opts['pay_cvs'] ) && is_array( $acting_opts['pay_cvs'] ) ) ? $acting_opts['pay_cvs'] : array();
1638 $conv_span = ( isset( $acting_opts['conv_span'] ) ) ? $acting_opts['conv_span'] : '';
1639
1640 $bnpl_activate = ( isset( $acting_opts['bnpl_activate'] ) && 'on' === $acting_opts['bnpl_activate'] ) ? 'on' : 'off';
1641 $client_ip_bnpl = ( isset( $acting_opts['clientip_bnpl'] ) ) ? $acting_opts['clientip_bnpl'] : '';
1642 $bnpl_linkpassword = ( isset( $acting_opts['bnpl_linkpassword'] ) ) ? $acting_opts['bnpl_linkpassword'] : '';
1643
1644 if ( 'fix' === $acting_opts['bnpl_fee_type'] ) {
1645 $bnpl_fee_type_field = ( ! empty( $acting_opts['bnpl_fee'] ) ) ? $this->get_fee_name( $acting_opts['bnpl_fee_type'] ) . ' ' : '';
1646 } elseif ( 'change' === $acting_opts['bnpl_fee_type'] ) {
1647 $bnpl_fee_type_field = ( ! empty( $acting_opts['bnpl_fee_first_fee'] ) ) ? $this->get_fee_name( $acting_opts['bnpl_fee_type'] ) . ' ' : '';
1648 } else {
1649 $bnpl_fee_type_field = '';
1650 }
1651 ?>
1652 <div id="uscestabs_zeus">
1653 <div class="settlement_service"><span class="service_title"><?php echo esc_html( $this->acting_formal_name ); ?></span></div>
1654 <?php
1655 if ( 'zeus' === filter_input( INPUT_POST, 'acting' ) ) :
1656 if ( '' !== $this->error_mes ) :
1657 ?>
1658 <div class="error_message"><?php echo wp_kses_post( $this->error_mes ); ?></div>
1659 <?php
1660 elseif ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) :
1661 ?>
1662 <div class="message">十分にテストを行ってから運用してください。</div>
1663 <?php
1664 endif;
1665 endif;
1666 ?>
1667 <form action="" method="post" name="zeus_form" id="zeus_form">
1668 <table class="settle_table">
1669 <tr>
1670 <th>クレジットカード決済</th>
1671 <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 />
1672 <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>
1673 </td>
1674 </tr>
1675 <tr class="card_zeus">
1676 <th><a class="explanation-label" id="label_ex_clid_zeus">カード決済IPコード</a></th>
1677 <td><input name="clientip" type="text" id="clid_zeus" value="<?php echo esc_attr( $client_ip ); ?>" class="regular-text" /></td>
1678 </tr>
1679 <tr id="ex_clid_zeus" class="explanation card_zeus"><td colspan="2">契約時にゼウスから発行されるクレジットカード決済用のIPコード(半角数字)</td></tr>
1680 <tr class="card_zeus">
1681 <th><a class="explanation-label" id="label_ex_connection_zeus">接続方式</a></th>
1682 <td><label><input name="connection" type="radio" id="connection_zeus_1" value="1"<?php checked( $connection, 1 ); ?> /><span>Secure Link</span></label><br />
1683 <label><input name="connection" type="radio" id="connection_zeus_2" value="2"<?php checked( $connection, 2 ); ?> /><span>Secure API</span></label>
1684 </td>
1685 </tr>
1686 <tr id="ex_connection_zeus" class="explanation card_zeus"><td colspan="2">認証接続方法。契約に従って指定する�
1687 要があります。</td></tr>
1688 <tr class="card_zeus">
1689 <th><a class="explanation-label" id="label_ex_authkey_zeus">認証キー</a></th>
1690 <td><input name="authkey" type="text" id="clid_zeus" value="<?php echo esc_attr( $authkey ); ?>" class="regular-text" /></td>
1691 </tr>
1692 <tr id="ex_authkey_zeus" class="explanation card_zeus"><td colspan="2">契約時にゼウスから発行される認証キー(半角数字)</td></tr>
1693 <tr class="card_zeus 3dsecur_zeus">
1694 <th><a class="explanation-label" id="label_ex_3dsecur_zeus">3Dセキュア(※)</a></th>
1695 <td><label><input name="3dsecur" type="radio" id="3dsecur_zeus_1" value="1"<?php checked( $threedsecure, 1 ); ?> /><span>利用する</span></label><br />
1696 <label><input name="3dsecur" type="radio" id="3dsecur_zeus_2" value="2"<?php checked( $threedsecure, 2 ); ?> /><span>利用しない</span></label>
1697 </td>
1698 </tr>
1699 <tr id="ex_3dsecur_zeus" class="explanation card_zeus 3dsecur_zeus"><td colspan="2">3Dセキュアを利用するには Secure API を利用した接続が�
1700 要です。契約に従って指定する�
1701 要があります。</td></tr>
1702 <tr class="card_zeus">
1703 <th><a class="explanation-label" id="label_ex_security_zeus">セキュリティーコード(※)</a></th>
1704 <td><label><input name="security" type="radio" id="security_zeus_1" value="1"<?php checked( $security, 1 ); ?> /><span>利用する</span></label><br />
1705 <label><input name="security" type="radio" id="security_zeus_2" value="2"<?php checked( $security, 2 ); ?> /><span>利用しない</span></label>
1706 </td>
1707 </tr>
1708 <tr id="ex_security_zeus" class="explanation card_zeus"><td colspan="2">セキュリティーコードの�
1709 �力を�
1710 須とするかどうかを指定します。契約に従って指定する�
1711 要があります。</td></tr>
1712 <tr class="card_zeus">
1713 <th><a class="explanation-label" id="label_ex_quickcharge_zeus">QuickCharge</a></th>
1714 <td><label><input name="quickcharge" type="radio" id="quickcharge_zeus_1" value="on"<?php checked( $quickcharge, 'on' ); ?> /><span>利用する</span></label><br />
1715 <label><input name="quickcharge" type="radio" id="quickcharge_zeus_2" value="off"<?php checked( $quickcharge, 'off' ); ?> /><span>利用しない</span></label>
1716 </td>
1717 </tr>
1718 <tr id="ex_quickcharge_zeus" class="explanation card_zeus"><td colspan="2">ログインして一度購�
1719 �したメンバーは、次の購�
1720 �時にはカード番号を�
1721 �力する�
1722 要がなくなります。</td></tr>
1723 <?php if ( defined( 'WCEX_DLSELLER' ) || defined( 'WCEX_AUTO_DELIVERY' ) ) : ?>
1724 <tr class="card_zeus">
1725 <th><a class="explanation-label" id="label_ex_batch_zeus">バッチ処理</a></th>
1726 <td><label><input name="batch" type="radio" id="batch_zeus_1" value="on"<?php checked( $batch, 'on' ); ?> /><span>利用する</span></label><br />
1727 <label><input name="batch" type="radio" id="batch_zeus_2" value="off"<?php checked( $batch, 'off' ); ?> /><span>利用しない</span></label>
1728 </td>
1729 </tr>
1730 <tr id="ex_batch_zeus" class="explanation card_zeus"><td colspan="2">ゼウス決済を<?php echo esc_html( $wcex_name ); ?>でご利用の場合は、「利用する」にしてください。また、QuickCharge も「利用する」にしてください。</td></tr>
1731 <?php endif; ?>
1732 <?php if ( defined( 'WCEX_DLSELLER' ) ) : ?>
1733 <tr class="card_zeus">
1734 <th><a class="explanation-label" id="label_ex_auto_settlement_mail_zeus">自動継続課金完了メール</a></th>
1735 <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 />
1736 <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>
1737 </td>
1738 </tr>
1739 <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>
1740 <?php endif; ?>
1741 <tr class="card_zeus">
1742 <th><a class="explanation-label" id="label_ex_howpay_zeus">お客様の支払方法</a></th>
1743 <td><label><input name="howpay" type="radio" id="howpay_zeus_2" value="off"<?php checked( $howpay, 'off' ); ?> /><span>一括払いのみ</span></label><br />
1744 <label><input name="howpay" type="radio" id="howpay_zeus_1" value="on"<?php checked( $howpay, 'on' ); ?> /><span>分割払いに対応する</span></label><br />
1745 <div class="howpay_option_zeus">
1746 <label><input name="howpay_B1" type="checkbox" id="howpay_zeus_B1" value="on"<?php checked( $howpay_b1, 'on' ); ?> /><span>ボーナス一括に対応する</span></label><br />
1747 <label><input name="howpay_02" type="checkbox" id="howpay_zeus_02" value="on"<?php checked( $howpay_02, 'on' ); ?> /><span>2回払いに対応する</span></label>
1748 </div/>
1749 </td>
1750 </tr>
1751 <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>
1752 </table>
1753 <table class="settle_table">
1754 <tr>
1755 <th><a class="explanation-label" id="label_ex_bank_zeus">銀行振込決済(�
1756 �金おまかせサービス)</a></th>
1757 <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 />
1758 <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>
1759 </td>
1760 </tr>
1761 <tr id="ex_bank_zeus" class="explanation"><td colspan="2">銀行振込支払いの自動�
1762 �会機能です。振込みがあった場合、自動的に�
1763 �金済みになり、�
1764 �金確認メールが自動送信されます。</td></tr>
1765 <tr class="bank_zeus">
1766 <th><a class="explanation-label" id="label_ex_bank_ope_zeus">稼働環境</a></th>
1767 <td><label><input name="bank_ope" type="radio" id="bank_ope_zeus_1" value="test"<?php checked( $bank_ope, 'test' ); ?> /><span>テスト環境</span></label><br />
1768 <label><input name="bank_ope" type="radio" id="bank_ope_zeus_2" value="public"<?php checked( $bank_ope, 'public' ); ?> /><span>本番環境</span></label>
1769 </td>
1770 </tr>
1771 <tr id="ex_bank_ope_zeus" class="explanation bank_zeus"><td colspan="2">動作環境を切り替えます。</td></tr>
1772 <tr class="bank_zeus">
1773 <th><a class="explanation-label" id="label_ex_bank_clid_zeus">銀行振込決済IPコード</a></th>
1774 <td><input name="clientip_bank" type="text" id="bank_clid_zeus" value="<?php echo esc_attr( $client_ip_bank ); ?>" class="regular-text" /></td>
1775 </tr>
1776 <tr id="ex_bank_clid_zeus" class="explanation bank_zeus"><td colspan="2">契約時にゼウスから発行される�
1777 �金おまかせサービス用のIPコード(半角数字)</td></tr>
1778 <tr class="bank_zeus">
1779 <th><a class="explanation-label" id="label_ex_bank_testid_zeus">テストID</a></th>
1780 <td><input name="testid_bank" type="text" id="testid_bank_zeus" value="<?php echo esc_attr( $testid_bank ); ?>" class="regular-text" /></td>
1781 </tr>
1782 <tr id="ex_bank_testid_zeus" class="explanation bank_zeus"><td colspan="2">契約時にゼウスから発行される�
1783 �金おまかせサービス接続テストで�
1784 要なテストID(半角数字)</td></tr>
1785 <tr class="bank_zeus">
1786 <th><a class="explanation-label" id="label_ex_bank_expired_date_zeus">支払期日</a></th>
1787 <td>当日+<select name="bank_expired_date">
1788 <option value=""></option>
1789 <?php for ( $i = 1; $i <= 30; $i++ ) : ?>
1790 <option value="<?php echo esc_html( $i ); ?>"<?php selected( $bank_expired_date, $i, true ); ?>><?php echo esc_html( $i ); ?></option>
1791 <?php endfor; ?>
1792 </select></td>
1793 </tr>
1794 <tr id="ex_bank_expired_date_zeus" class="explanation"><td colspan="2">お申し込みごとに支払期日を設定することができます。設定がない場合には、予め設定していた加盟店指定の支払期日が設定されます。</td></tr>
1795 </table>
1796 <table class="settle_table">
1797 <tr>
1798 <th><a class="explanation-label" id="label_ex_conv_zeus">コンビニ決済サービス</a></th>
1799 <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 />
1800 <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>
1801 </td>
1802 </tr>
1803 <tr id="ex_conv_zeus" class="explanation"><td colspan="2">コンビニ支払いができる決済サービスです。払い込みがあった場合、自動的に�
1804 �金済みになります。</td></tr>
1805 <tr class="conv_zeus">
1806 <th><a class="explanation-label" id="label_ex_conv_ope_zeus">稼働環境</a></th>
1807 <td><label><input name="conv_ope" type="radio" id="conv_ope_zeus_1" value="test"<?php checked( $conv_ope, 'test' ); ?> /><span>テスト環境</span></label><br />
1808 <label><input name="conv_ope" type="radio" id="conv_ope_zeus_2" value="public"<?php checked( $conv_ope, 'public' ); ?> /><span>本番環境</span></label>
1809 </td>
1810 </tr>
1811 <tr id="ex_conv_ope_zeus" class="explanation conv_zeus"><td colspan="2">動作環境を切り替えます。</td></tr>
1812 <tr class="conv_zeus">
1813 <th><a class="explanation-label" id="label_ex_conv_clid_zeus">コンビニ決済IPコード</a></th>
1814 <td><input name="clientip_conv" type="text" id="conv_clid_zeus" value="<?php echo esc_attr( $client_ip_conv ); ?>" class="regular-text" /></td>
1815 </tr>
1816 <tr id="ex_conv_clid_zeus" class="explanation conv_zeus"><td colspan="2">契約時にゼウスから発行されるコンビニ決済サービス用のIPコード(半角数字)</td></tr>
1817 <tr class="conv_zeus">
1818 <th><a class="explanation-label" id="label_ex_conv_testid_zeus">テストID</a></th>
1819 <td><input name="testid_conv" type="text" id="testid_conv_zeus" value="<?php echo esc_attr( $testid_conv ); ?>" class="regular-text" /></td>
1820 </tr>
1821 <tr id="ex_conv_testid_zeus" class="explanation conv_zeus"><td colspan="2">契約時にゼウスから発行されるコンビニ決済サービス接続テストで�
1822 要なテストID(半角数字)</td></tr>
1823 <tr class="conv_zeus">
1824 <th><a class="explanation-label" id="label_ex_conv_testtype_zeus">テストタイプ</a></th>
1825 <td><label><input name="test_type" type="radio" id="conv_testtype_zeus_1" value="0"<?php checked( $test_type_conv, 0 ); ?> /><span>�
1826 �金テスト無し</span></label><br />
1827 <label><input name="test_type" type="radio" id="conv_testtype_zeus_2" value="1"<?php checked( $test_type_conv, 1 ); ?> /><span>売上確定テスト</span></label><br />
1828 <label><input name="test_type" type="radio" id="conv_testtype_zeus_3" value="2"<?php checked( $test_type_conv, 2 ); ?> /><span>売上取消テスト</span></label>
1829 </td>
1830 </tr>
1831 <tr id="ex_conv_testtype_zeus" class="explanation conv_zeus"><td colspan="2">テスト環境でのテストタイプを指定します。</td></tr>
1832 <tr class="conv_zeus">
1833 <th rowspan="6"><a class="explanation-label" id="label_ex_pay_cvs_zeus">コンビニ種類</a></th>
1834 <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>
1835 </tr>
1836 <tr class="conv_zeus">
1837 <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>
1838 </tr>
1839 <tr class="conv_zeus">
1840 <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>
1841 </tr>
1842 <tr class="conv_zeus">
1843 <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>
1844 </tr>
1845 <tr class="conv_zeus">
1846 <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>
1847 </tr>
1848 <tr class="conv_zeus">
1849 <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>
1850 </tr>
1851 <tr id="ex_pay_cvs_zeus" class="explanation conv_zeus"><td colspan="2">契約時にご利用のお申込みをいただいたコンビニを選択します。</td></tr>
1852 <tr class="conv_zeus">
1853 <th><a class="explanation-label" id="label_ex_conv_span_zeus">支払期日</a></th>
1854 <td>当日+<select name="conv_span">
1855 <option value=""></option>
1856 <?php for ( $i = 2; $i <= 59; $i++ ) : ?>
1857 <option value="<?php echo esc_attr( $i ); ?>"<?php selected( $conv_span, $i, true ); ?>><?php echo esc_html( $i ); ?></option>
1858 <?php endfor; ?>
1859 </select></td>
1860 </tr>
1861 <tr id="ex_conv_span_zeus" class="explanation"><td colspan="2">お申し込みごとに支払期日を設定することができます。設定がない場合には、予め設定していた加盟店指定の支払期日が設定されます。</td></tr>
1862 </table>
1863 <table class="settle_table">
1864 <tr>
1865 <th>あと払い決済</th>
1866 <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 />
1867 <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>
1868 </td>
1869 </tr>
1870 <tr class="bnpl_zeus">
1871 <th><a class="explanation-label" id="label_ex_bnpl_clid_zeus">あと払い決済IPコード</a></th>
1872 <td><input name="clientip_bnpl" type="text" id="bnpl_clid_zeus" value="<?php echo esc_attr( $client_ip_bnpl ); ?>" class="regular-text" /></td>
1873 </tr>
1874 <tr id="ex_bnpl_clid_zeus" class="explanation bnpl_zeus"><td colspan="2">契約時にゼウスから発行されるあと払い決済用のIPコード(半角数字)</td></tr>
1875 <tr class="bnpl_zeus">
1876 <th><a class="explanation-label" id="label_ex_bnpl_linkpassword_zeus">APIキー</a></th>
1877 <td><input name="bnpl_linkpassword" type="text" id="bnpl_linkpassword_zeus" value="<?php echo esc_attr( $bnpl_linkpassword ); ?>" class="regular-text" /></td>
1878 </tr>
1879 <tr id="ex_bnpl_linkpassword_zeus" class="explanation bnpl_zeus"><td colspan="2">契約時にゼウスから発行されるあと払い決済用のAPIキー(半角英数字)</td></tr>
1880 <tr class="bnpl_zeus">
1881 <th><a class="explanation-label" id="label_ex_bnpl_fee_zeus">請求手数料</a></th>
1882 <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>
1883 </tr>
1884 <tr id="ex_bnpl_fee_zeus" class="explanation bnpl_zeus"><td colspan="2">あと払い決済手数料と決済上限額を設定します。�
1885 要ない場合は空白にしておきます。</td></tr>
1886 </table>
1887 <input name="acting" type="hidden" value="zeus" />
1888 <input type="hidden" name="bnpl_fee_type" id="bnpl_fee_type" value="<?php echo esc_attr( $acting_opts['bnpl_fee_type'] ); ?>" />
1889 <input type="hidden" name="bnpl_fee" id="bnpl_fee" value="<?php echo esc_attr( $acting_opts['bnpl_fee'] ); ?>" />
1890 <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'] ); ?>" />
1891 <input type="hidden" name="bnpl_fee_first_amount" id="bnpl_fee_first_amount" value="<?php echo esc_attr( $acting_opts['bnpl_fee_first_amount'] ); ?>" />
1892 <input type="hidden" name="bnpl_fee_first_fee" id="bnpl_fee_first_fee" value="<?php echo esc_attr( $acting_opts['bnpl_fee_first_fee'] ); ?>" />
1893 <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'] ); ?>" />
1894 <input type="hidden" name="bnpl_fee_amounts" id="bnpl_fee_amounts" value="<?php echo esc_attr( implode( '|', $acting_opts['bnpl_fee_amounts'] ) ); ?>" />
1895 <input type="hidden" name="bnpl_fee_fees" id="bnpl_fee_fees" value="<?php echo esc_attr( implode( '|', $acting_opts['bnpl_fee_fees'] ) ); ?>" />
1896 <input type="hidden" name="bnpl_fee_end_fee" id="bnpl_fee_end_fee" value="<?php echo esc_attr( $acting_opts['bnpl_fee_end_fee'] ); ?>" />
1897 <input name="usces_option_update" type="submit" class="button button-primary" value="ゼウスの設定を更新する" />
1898 <?php wp_nonce_field( 'admin_settlement', 'wc_nonce' ); ?>
1899 </form>
1900 <div class="settle_exp">
1901 <p><strong><?php esc_html_e( 'ZEUS Japanese Settlement', 'usces' ); ?></strong></p>
1902 <a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank">ゼウス決済サービスの詳細はこちら </a>
1903 <p> </p>
1904 <p>この決済は「非通過型・トークン方式」の決済システムです。</p>
1905 <p>「非通過型」とは、決済会社のページへは遷移せず、Welcart のページのみで完結する決済システムです。<br />
1906 デザインの統一されたスタイリッシュな決済が可能です。但し、カード番号を扱いますので専用SSLが�
1907 須となります。<br />
1908
1909 �力されたカード番号はトークンに置き換えてゼウスのシステムに送信されますので、Welcart に保存することはありません。</a>
1910 <p>※ボーナス一括、2回払いは契約がある場合にのみご利用いただけます。</p>
1911 <p> </p>
1912 <p> 3Dセキュアとセキュリティーコード</p>
1913 <p>3Dセキュアとおよびセキュリティーコードの利用は、決済サービス契約時に決定します。契約�
1914 容に従って指定しないと正常に動作しませんのでご注意ください。<br />
1915 3Dセキュアを利用する場合はテストカードを使用してのテスト決済はできません。<br />
1916 詳しくは<a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank">株式会社ゼウス</a>(代表:03-3498-9030)にお問い合わせください。</p>
1917 <p> </p>
1918 <p><strong>テスト稼動について</strong></p>
1919 <p>銀行振込決済(�
1920 �金おまかせサービス)およびコンビニ決済のテストを行う際は、「稼働環境」で「テスト環境」を選択し、「テストID」の�
1921 目にゼウスから発行されるテストIDを�
1922 �力してください。<br />
1923 また、本稼働の際には、「本番環境」を選択して更新してください。</p>
1924 </div>
1925 </div><!--uscestabs_zeus-->
1926
1927 <div id="zeus_fee_dialog" class="cod_dialog">
1928 <fieldset>
1929 <table id="zeus_fee_type_table" class="cod_type_table">
1930 <tr>
1931 <th><?php esc_html_e( 'Type of the fee', 'usces' ); ?></th>
1932 <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>
1933 <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>
1934 </tr>
1935 </table>
1936 <table id="zeus_fee_fix_table" class="cod_fix_table">
1937 <tr>
1938 <th><?php esc_html_e( 'Fee', 'usces' ); ?></th>
1939 <td><input name="fee" type="text" id="fee_fix" class="short_str num" /><?php usces_crcode(); ?></td>
1940 </tr>
1941 <tr>
1942 <th><?php esc_html_e( 'Upper limit', 'usces' ); ?></th>
1943 <td><input name="fee_limit_amount_fix" type="text" id="fee_limit_amount_fix" class="short_str num" /><?php usces_crcode(); ?></td>
1944 </tr>
1945 </table>
1946 <div id="zeus_fee_change_table" class="cod_change_table">
1947 <input type="button" class="button" id="fee_add_row" value="<?php esc_attr_e( 'Add row', 'usces' ); ?>" />
1948 <input type="button" class="button" id="fee_del_row" value="<?php esc_attr_e( 'Delete row', 'usces' ); ?>" />
1949 <table>
1950 <thead>
1951 <tr>
1952 <th colspan="3"><?php esc_html_e( 'A purchase amount', 'usces' ); ?>(<?php usces_crcode(); ?>)</th>
1953 <th><?php esc_html_e( 'Fee', 'usces' ); ?>(<?php usces_crcode(); ?>)</th>
1954 </tr>
1955 <tr>
1956 <td class="cod_f">0</td>
1957 <td class="cod_m"><?php esc_html_e( ' - ', 'usces' ); ?></td>
1958 <td class="cod_e"><input name="fee_first_amount" id="fee_first_amount" type="text" class="short_str num" /></td>
1959 <td class="cod_cod"><input name="fee_first_fee" id="fee_first_fee" type="text" class="short_str num" /></td>
1960 </tr>
1961 </thead>
1962 <tbody id="fee_change_field"></tbody>
1963 <tfoot>
1964 <tr>
1965 <td class="cod_f"><span id="end_amount"></span></td>
1966 <td class="cod_m"><?php esc_html_e( ' - ', 'usces' ); ?></td>
1967 <td class="cod_e"><input name="fee_limit_amount_change" type="text" id="fee_limit_amount_change" class="short_str num" /></td>
1968 <td class="cod_cod"><input name="fee_end_fee" type="text" id="fee_end_fee" class="short_str num" /></td>
1969 </tr>
1970 </tfoot>
1971 </table>
1972 </div>
1973 </fieldset>
1974 <input type="hidden" id="zeus_fee_mode">
1975 </div><!--zeus_fee_dialog-->
1976 <?php
1977 endif;
1978 }
1979
1980 /**
1981 * 支払方法追加
1982 * usces_filter_add_payment_method
1983 *
1984 * @param array $newvalue Payment method data.
1985 * @return array
1986 */
1987 public function add_payment_method( $newvalue ) {
1988 if ( empty( $newvalue['explanation'] ) ) {
1989 if ( 'acting_zeus_bnpl' === $newvalue['settlement'] ) {
1990 $newvalue['explanation'] = 'SBIグループのあと払い決済をご利用の際は、<a href="https://www.sbi-finsol.co.jp/atobarai/purchaser/" target="_blank">ご利用規約</a>および下記の注意事�
1991 をご確認いただき、ご同意の上お申し込みください。<br>
1992 <ul>
1993 <li>ご利用限度額(未払い累計金額)は55,000円(税込)です。</li>
1994 <li>ご利用にあたり審査がございます。審査結果によっては、あと払い決済をご利用いただけないことがございますので、その場合は別のお支払方法をご利用ください。</li>
1995 <li>ご請求メールは、購�
1996 ��
1997 さまのメールアドレス宛にSBI FinTech Solutions株式会社(atobarai@sbi-finsol.co.jp)よりお送りします。</li>
1998 <li>商品をお受取り後、メールに記載のお支払い期日まで(発行日から14日以�
1999 )にコンビニエンスストアまたは銀行振込にてお支払いください。コンビニ払いの場合は、電子バーコードを提示してのお支払いになりますので、スマートフォンで受け取れるメールアドレスをご�
2000 �力ください。</li>
2001 <li>未成年の方は�
2002 ず親権�
2003 (法定代理人)の同意を得てご利用ください。</li>
2004 <li>商品のお届け�
2005 �住所が「運送業�
2006 の営業所留め」「郵便局留め」の場合や「学校」「�
2007 院」「ホテル」など一時滞在�
2008 �の場合は、「あと払い決済」をご利用いただけません。また、商品の海外転送サービスもご利用いただけません。</li>
2009 <li>あと払い決済のサービス詳細・よくあるご質問は下記をご参�
2010 �ください。<br><a href="https://www.sbi-finsol.co.jp/atobarai/purchaser/"target="_blank">https://www.sbi-finsol.co.jp/atobarai/purchaser/</a></li>
2011 </ul>
2012 <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>';
2013 }
2014 }
2015 return $newvalue;
2016 }
2017
2018 /**
2019 * 結果通知前処理
2020 * usces_construct
2021 */
2022 public function acting_construct() {
2023 $acting_opts = $this->get_acting_settings();
2024 if ( ! empty( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], $acting_opts['ipaddrs'] ) ) {
2025 $result_data = wp_unslash( $_REQUEST );
2026 if ( isset( $result_data['sendpoint'] ) ) {
2027 $sendpoint = $result_data['sendpoint'];
2028 $acting_data = usces_get_order_acting_data( $sendpoint );
2029 if ( empty( $acting_data['sesid'] ) ) {
2030 if ( isset( $result_data['result'] ) && 'OK' === $result_data['result'] && isset( $result_data['money'] ) && 0 === (int) $result_data['money'] ) {
2031 } else {
2032 $log = array(
2033 'acting' => 'zeus',
2034 'key' => $sendpoint,
2035 'result' => 'SESSION ERROR',
2036 'data' => $result_data,
2037 );
2038 usces_save_order_acting_error( $log );
2039 }
2040 } else {
2041 if ( isset( $result_data['acting'] ) && 'zeus_bank' === $result_data['acting'] ) {
2042 usces_restore_order_acting_data( $sendpoint );
2043 }
2044 }
2045 }
2046 }
2047 }
2048
2049 /**
2050 * 決済結果通知(zeus_conv / zeus_bank)の送信�
2051 �IPを検証する
2052 *
2053 * 許可IP以外からのリクエストはエラーログを残して処理を終了する
2054 * �
2055 �金状�
2056 �を変更するサーバー間通知でのみ呼び出すこと
2057 * ブラウザ戻りを伴う zeus_card では呼び出さない
2058 *
2059 * @return void
2060 */
2061 private function acting_notice_ip_guard() {
2062 $remote_addr = ( isset( $_SERVER['REMOTE_ADDR'] ) ) ? wp_unslash( $_SERVER['REMOTE_ADDR'] ) : '';
2063 if ( usces_acting_notice_ip_allowed( $remote_addr, self::ACTING_NOTICE_IPADDRS ) ) {
2064 return;
2065 }
2066 $log = array(
2067 'acting' => ( isset( $_REQUEST['acting'] ) ) ? wp_unslash( $_REQUEST['acting'] ) : 'zeus',
2068 'key' => ( isset( $_REQUEST['sendpoint'] ) ) ? wp_unslash( $_REQUEST['sendpoint'] ) : '',
2069 'result' => 'IP ADDRESS NOT ALLOWED: ' . $remote_addr,
2070 'data' => wp_unslash( $_REQUEST ),
2071 );
2072 usces_save_order_acting_error( $log );
2073 usces_log( 'zeus notice denied ip : ' . $remote_addr, 'acting_transaction.log' );
2074 header( 'HTTP/1.0 200 OK' );
2075 die( 'error0' );
2076 }
2077
2078 /**
2079 * 結果通知処理
2080 * usces_after_cart_instant
2081 */
2082 public function acting_transaction() {
2083 global $usces;
2084
2085 /* zeus_card */
2086 if ( isset( $_REQUEST['acting'] ) && 'zeus_card' === $_REQUEST['acting'] && isset( $_REQUEST['result'] ) && isset( $_REQUEST['ordd'] ) ) {
2087 foreach ( $_REQUEST as $key => $value ) {
2088 if ( 'uscesid' === $key ) {
2089 continue;
2090 }
2091 $data[ $key ] = $value;
2092 }
2093
2094 if ( empty( $data['sendpoint'] ) ) {
2095 $log = array(
2096 'acting' => $data['acting'],
2097 'key' => '(empty key)',
2098 'result' => $data['result'],
2099 'data' => $data,
2100 );
2101 usces_save_order_acting_error( $log );
2102 header( 'HTTP/1.0 200 OK' );
2103 die( 'error1' );
2104 }
2105
2106 if ( 'OK' === $data['result'] ) {
2107 $order_data = usces_restore_order_acting_data( $data['sendpoint'] );
2108 $order_id = $this->get_order_id( $data['sendpoint'] );
2109 if ( empty( $order_id ) && ! empty( $order_data ) ) {
2110 $res = $usces->order_processing( $data );
2111 if ( 'ordercompletion' === $res ) {
2112 $_nonce = ( isset( $order_data['_nonce'] ) ) ? $order_data['_nonce'] : wp_create_nonce( 'acting_zeus_card' );
2113 wp_redirect(
2114 add_query_arg(
2115 array(
2116 'acting' => $data['acting'],
2117 'acting_return' => 1,
2118 'result' => 1,
2119 '_nonce' => $_nonce,
2120 ),
2121 USCES_CART_URL
2122 )
2123 );
2124 } else {
2125 $log = array(
2126 'acting' => $data['acting'],
2127 'key' => $rand,
2128 'result' => 'ORDER DATA REGISTERED ERROR',
2129 'data' => $data,
2130 );
2131 usces_save_order_acting_error( $log );
2132 wp_redirect(
2133 add_query_arg(
2134 array(
2135 'acting' => $data['acting'],
2136 'acting_return' => 0,
2137 'result' => 0,
2138 ),
2139 USCES_CART_URL
2140 )
2141 );
2142 }
2143 } else {
2144 $log = array(
2145 'acting' => $data['acting'],
2146 'key' => $data['sendpoint'],
2147 'result' => 'ORDER DATA RESTORE ERROR',
2148 'data' => $data,
2149 );
2150 usces_save_order_acting_error( $log );
2151 wp_redirect(
2152 add_query_arg(
2153 array(
2154 'acting' => $data['acting'],
2155 'acting_return' => 0,
2156 'result' => 0,
2157 ),
2158 USCES_CART_URL
2159 )
2160 );
2161 }
2162 header( 'HTTP/1.0 200 OK' );
2163 die( 'zeus' );
2164
2165 } else {
2166 $log = array(
2167 'acting' => $data['acting'],
2168 'key' => $data['sendpoint'],
2169 'result' => $data['result'],
2170 'data' => $data,
2171 );
2172 usces_save_order_acting_error( $log );
2173 header( 'HTTP/1.0 200 OK' );
2174 die( 'error3' );
2175 }
2176
2177 /* zeus_bank */
2178 } elseif ( isset( $_REQUEST['acting'] ) && 'zeus_bank' === $_REQUEST['acting'] && isset( $_REQUEST['order_no'] ) && isset( $_REQUEST['tracking_no'] ) ) {
2179 $this->acting_notice_ip_guard();
2180 foreach ( $_REQUEST as $key => $value ) {
2181 if ( 'uscesid' === $key ) {
2182 continue;
2183 }
2184 $data[ $key ] = $value;
2185 }
2186
2187 if ( '04' === $data['status'] || '05' === $data['status'] ) {
2188 $log = array(
2189 'acting' => $data['acting'],
2190 'key' => $data['sendpoint'],
2191 'result' => $data['status'],
2192 'data' => $data,
2193 );
2194 usces_save_order_acting_error( $log );
2195 header( 'HTTP/1.0 200 OK' );
2196 die( 'error0' );
2197 }
2198
2199 $order_id = $this->get_order_id( $data['tracking_no'] );
2200 if ( empty( $order_id ) ) {
2201 $res = $usces->order_processing( $data );
2202 if ( 'error' === $res ) {
2203 $log = array(
2204 'acting' => $data['acting'],
2205 'key' => $data['sendpoint'],
2206 'result' => 'ORDER DATA REGISTERED ERROR',
2207 'data' => $data,
2208 );
2209 usces_save_order_acting_error( $log );
2210 header( 'HTTP/1.0 200 OK' );
2211 die( 'error1' );
2212
2213 } else {
2214 $order_id = $usces->cart->get_order_entry( 'ID' );
2215 if ( $order_id ) {
2216 $usces->cart->clear_cart();
2217 }
2218 }
2219 }
2220
2221 if ( ! empty( $order_id ) ) {
2222 if ( '03' === $data['status'] ) {
2223 $res = usces_change_order_receipt( $order_id, 'receipted' );
2224 do_action( 'usces_action_zeus_bank_receipted', $order_id, $data );
2225 } else {
2226 $res = usces_change_order_receipt( $order_id, 'noreceipt' );
2227 }
2228 if ( false === $res ) {
2229 $log = array(
2230 'acting' => $data['acting'],
2231 'key' => $data['sendpoint'],
2232 'result' => 'ORDER DATA UPDATE ERROR',
2233 'data' => $data,
2234 );
2235 usces_save_order_acting_error( $log );
2236 header( 'HTTP/1.0 200 OK' );
2237 die( 'error2' );
2238 }
2239 if ( '03' === $data['status'] ) {
2240 usces_action_acting_getpoint( $order_id );
2241 }
2242
2243 $res = $usces->set_order_meta_value( 'acting_' . $data['tracking_no'], usces_serialize( $data ), $order_id );
2244 if ( false === $res ) {
2245 $log = array(
2246 'acting' => $data['acting'],
2247 'key' => $data['sendpoint'],
2248 'result' => 'ORDER META DATA UPDATE ERROR',
2249 'data' => $data,
2250 );
2251 usces_save_order_acting_error( $log );
2252 header( 'HTTP/1.0 200 OK' );
2253 die( 'error3' );
2254 }
2255 }
2256
2257 header( 'HTTP/1.0 200 OK' );
2258 die( 'zeus' );
2259
2260 /* zeus_conv */
2261 } elseif ( isset( $_REQUEST['acting'] ) && 'zeus_conv' === $_REQUEST['acting'] && isset( $_REQUEST['status'] ) && isset( $_REQUEST['sendpoint'] ) && isset( $_REQUEST['clientip'] ) ) {
2262 $this->acting_notice_ip_guard();
2263 foreach ( $_REQUEST as $key => $value ) {
2264 if ( 'uscesid' === $key ) {
2265 continue;
2266 }
2267 if ( 'username' === $key ) {
2268 $data[ $key ] = mb_convert_encoding( $value, 'UTF-8', 'SJIS' );
2269 } else {
2270 $data[ $key ] = $value;
2271 }
2272 }
2273
2274 $order_id = $this->get_order_id( $data['sendpoint'] );
2275 if ( ! empty( $order_id ) ) {
2276 if ( '05' !== $data['status'] ) {
2277 if ( '04' === $data['status'] ) {
2278 $res = usces_change_order_receipt( $order_id, 'receipted' );
2279 do_action( 'usces_action_zeus_conv_receipted', $order_id, $data );
2280 } else {
2281 $res = usces_change_order_receipt( $order_id, 'noreceipt' );
2282 }
2283 if ( false === $res ) {
2284 $log = array(
2285 'acting' => $data['acting'],
2286 'key' => $data['sendpoint'],
2287 'result' => 'ORDER DATA UPDATE ERROR',
2288 'data' => $data,
2289 );
2290 usces_save_order_acting_error( $log );
2291 header( 'HTTP/1.0 200 OK' );
2292 die( 'error2' );
2293 }
2294 if ( '04' === $data['status'] ) {
2295 usces_action_acting_getpoint( $order_id );
2296 }
2297
2298 $res = $usces->set_order_meta_value( 'acting_' . $data['sendpoint'], usces_serialize( $data ), $order_id );
2299 if ( false === $res ) {
2300 $log = array(
2301 'acting' => $data['acting'],
2302 'key' => $data['sendpoint'],
2303 'result' => 'ORDER META DATA UPDATE ERROR',
2304 'data' => $data,
2305 );
2306 usces_save_order_acting_error( $log );
2307 header( 'HTTP/1.0 200 OK' );
2308 die( 'error3' );
2309 }
2310 }
2311 }
2312
2313 header( 'HTTP/1.0 200 OK' );
2314 die( 'zeus' );
2315 }
2316
2317 if ( isset( $_REQUEST['backfrom_zeus_bank'] ) && '1' === $_REQUEST['backfrom_zeus_bank'] ) {
2318 $usces->cart->clear_cart();
2319 }
2320 }
2321
2322 /**
2323 * 管理画面送信メール
2324 * usces_filter_order_confirm_mail_payment
2325 *
2326 * @param string $msg_payment Default payment message.
2327 * @param int $order_id Order number.
2328 * @param array $payment Payment information.
2329 * @param array $cart Cart data.
2330 * @param array $data Order data.
2331 * @return string
2332 */
2333 public function order_confirm_mail_payment( $msg_payment, $order_id, $payment, $cart, $data ) {
2334 global $usces;
2335
2336 switch ( $payment['settlement'] ) {
2337 case 'acting_zeus_card':
2338 $div_name = '';
2339 $acting_opts = $this->get_acting_settings();
2340 if ( 'on' === $acting_opts['howpay'] ) {
2341 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_zeus_card', $order_id ) );
2342 $howpay = ( isset( $acting_data['howpay'] ) ) ? $acting_data['howpay'] : '1';
2343 $div = ( isset( $acting_data['div'] ) ) ? $acting_data['div'] : '01';
2344 if ( '1' == $howpay ) {
2345 $div_name = ' 一括払い';
2346 } else {
2347 switch ( $div ) {
2348 case '01':
2349 $div_name = ' 一括払い';
2350 break;
2351 case '02':
2352 $div_name = ' 分割(2回)';
2353 break;
2354 case '03':
2355 $div_name = ' 分割(3回)';
2356 break;
2357 case '05':
2358 $div_name = ' 分割(5回)';
2359 break;
2360 case '06':
2361 $div_name = ' 分割(6回)';
2362 break;
2363 case '10':
2364 $div_name = ' 分割(10回)';
2365 break;
2366 case '12':
2367 $div_name = ' 分割(12回)';
2368 break;
2369 case '15':
2370 $div_name = ' 分割(15回)';
2371 break;
2372 case '18':
2373 $div_name = ' 分割(18回)';
2374 break;
2375 case '20':
2376 $div_name = ' 分割(20回)';
2377 break;
2378 case '24':
2379 $div_name = ' 分割(24回)';
2380 break;
2381 case '99':
2382 $div_name = ' 分割(リボ払い)';
2383 break;
2384 case 'B1':
2385 $div_name = ' 分割(ボーナス一括払い)';
2386 break;
2387 }
2388 }
2389 }
2390 if ( '' !== $div_name && isset( $payment['name'] ) ) {
2391 if ( usces_is_html_mail() ) {
2392 $msg_payment = '<tr><td colspan="2" style="padding: 0 0 25px 0;">';
2393 $msg_payment .= $payment['name'] . $div_name;
2394 $msg_payment .= '</td></tr>';
2395 } else {
2396 $msg_payment = __( '** Payment method **', 'usces' ) . "\r\n";
2397 $msg_payment .= usces_mail_line( 1, $data['order_email'] ); // ********************
2398 $msg_payment .= $payment['name'] . $div_name;
2399 $msg_payment .= "\r\n\r\n";
2400 }
2401 }
2402 break;
2403
2404 case 'acting_zeus_bank':
2405 break;
2406
2407 case 'acting_zeus_conv':
2408 $conv_name = '';
2409 $acting_data = $this->get_order_meta_acting( $order_id );
2410 if ( isset( $acting_data['pay_cvs'] ) ) {
2411 $conv_name = usces_get_conv_name( $acting_data['pay_cvs'] );
2412 }
2413 if ( '' !== $conv_name && isset( $payment['name'] ) ) {
2414 if ( usces_is_html_mail() ) {
2415 $msg_payment = '<tr><td colspan="2" style="padding: 0 0 25px 0;">';
2416 $msg_payment .= $payment['name'] . ' (' . $conv_name . '';
2417 $msg_payment .= '</td></tr>';
2418 } else {
2419 $msg_payment = __( '** Payment method **', 'usces' ) . "\r\n";
2420 $msg_payment .= usces_mail_line( 1, $data['order_email'] ); // ********************
2421 $msg_payment .= $payment['name'] . ' (' . $conv_name . '';
2422 $msg_payment .= "\r\n\r\n";
2423 }
2424 }
2425 break;
2426
2427 case 'acting_zeus_bnpl':
2428 break;
2429 }
2430
2431 return $msg_payment;
2432 }
2433
2434 /**
2435 * ポイント即時付与
2436 * usces_filter_is_complete_settlement
2437 *
2438 * @param bool $complete Complete the payment.
2439 * @param string $payment_name Payment name.
2440 * @param string $status Payment status.
2441 * @return bool
2442 */
2443 public function is_complete_settlement( $complete, $payment_name, $status ) {
2444 $acting_flg = $this->get_acting_flg( $payment_name );
2445 if ( 'acting_zeus_card' === $acting_flg ) {
2446 $complete = true;
2447 }
2448 return $complete;
2449 }
2450
2451 /**
2452 * 購�
2453 �完了メッセージ
2454 * usces_filter_completion_settlement_message
2455 *
2456 * @param string $form Message form.
2457 * @param array $entry Entry data.
2458 * @return string
2459 */
2460 public function completion_settlement_message( $form, $entry ) {
2461 global $usces;
2462
2463 if ( isset( $_REQUEST['acting'] ) && 'zeus_conv' === wp_unslash( $_REQUEST['acting'] ) ) {
2464 $form .= '<div id="status_table"><h5>ゼウス・コンビニ決済</h5>';
2465 $form .= '<table>';
2466 $form .= '<tr><th>オーダー番号</th><td>' . esc_html( $usces->payment_results['order_no'] ) . '</td></tr>';
2467 $form .= '<tr><th>お支払�
2468 �</th><td>' . esc_html( usces_get_conv_name( $usces->payment_results['pay_cvs'] ) ) . '</td></tr>';
2469 switch ( $usces->payment_results['pay_cvs'] ) {
2470 case 'D001': /* セブンイレブン */
2471 $form .= '<tr><th>払込票番号</th><td>' . esc_html( $usces->payment_results['pay_no1'] ) . '</td></tr>';
2472 $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>';
2473 break;
2474 case 'D002': /* ローソン */
2475 case 'D050': /* ミニストップ */
2476 $form .= '<tr><th>受付番号</th><td>' . esc_html( $usces->payment_results['pay_no1'] ) . '</td></tr>';
2477 if ( isset( $usces->payment_results['pay_no2'] ) ) {
2478 $form .= '<tr><th>確認番号</th><td>' . esc_html( $usces->payment_results['pay_no2'] ) . '</td></tr>';
2479 }
2480 break;
2481 case 'D040': /* サークルKサンクス */
2482 case 'D015': /* セイコーマート */
2483 $form .= '<tr><th>お支払受付番号</th><td>' . esc_html( $usces->payment_results['pay_no1'] ) . '</td></tr>';
2484 break;
2485 case 'D030': /* ファミリーマート */
2486 $form .= '<tr><th>注文番号</th><td>' . esc_html( $usces->payment_results['pay_no1'] ) . '</td></tr>';
2487 $form .= '<tr><th>企業コード</th><td>' . esc_html( $usces->payment_results['pay_no2'] ) . '</td></tr>';
2488 break;
2489 case 'D060': /* デイリーヤマザキ */
2490 $form .= '<tr><th>オンライン決済番号</th><td>' . esc_html( $usces->payment_results['pay_no1'] ) . '</td></tr>';
2491 break;
2492 }
2493 $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>';
2494 // $form .= '<!-- <tr><th>エラーコード</th><td>' . esc_html( $usces->payment_results['error_code'] ) . '</td></tr>';
2495 $form .= '</table>';
2496 $form .= '<p>「お支払いのご案�
2497 」は、' . esc_html( $entry['customer']['mailaddress1'] ) . ' 宛にメールさせていただいております。</p>';
2498 $form .= '</div>';
2499 }
2500 return $form;
2501 }
2502
2503 /**
2504 * 決済リンクキー
2505 * usces_filter_get_link_key
2506 *
2507 * @param string $linkkey Settlement link key.
2508 * @param array $results Response data.
2509 * @return string
2510 */
2511 public function get_link_key( $linkkey, $results ) {
2512 if ( isset( $results['order_number'] ) && isset( $results['sendpoint'] ) ) {
2513 $linkkey = $results['sendpoint'];
2514 }
2515 return $linkkey;
2516 }
2517
2518 /**
2519 * 受注データ復旧処理
2520 * usces_action_revival_order_data
2521 *
2522 * @param int $order_id Order number.
2523 * @param string $log_key Link key.
2524 * @param string $acting Payment type.
2525 */
2526 public function revival_orderdata( $order_id, $log_key, $acting ) {
2527 global $usces;
2528
2529 if ( ! in_array( $acting, $this->pay_method, true ) ) {
2530 return;
2531 }
2532
2533 $data = array();
2534 switch ( $acting ) {
2535 case 'acting_zeus_card':
2536 $data['sendpoint'] = $log_key;
2537 $usces->set_order_meta_value( $acting, usces_serialize( $data ), $order_id );
2538 case 'acting_zeus_conv':
2539 case 'acting_zeus_bank':
2540 $usces->set_order_meta_value( 'acting_' . $log_key, usces_serialize( $data ), $order_id );
2541 break;
2542 }
2543 }
2544
2545 /**
2546 * 管理画面決済処理
2547 * usces_action_admin_ajax
2548 */
2549 public function admin_ajax() {
2550 global $usces;
2551
2552 $mode = filter_input( INPUT_POST, 'mode' );
2553 $data = array();
2554
2555 switch ( $mode ) {
2556 /* クレジットカード参�
2557 � */
2558 case 'get_zeus_card':
2559 check_admin_referer( 'order_edit', 'wc_nonce' );
2560 $order_id = filter_input( INPUT_POST, 'order_id' );
2561 $order_num = filter_input( INPUT_POST, 'order_num' );
2562 $tracking_id = filter_input( INPUT_POST, 'tracking_id' );
2563 $member_id = filter_input( INPUT_POST, 'member_id' );
2564 if ( empty( $order_id ) || empty( $tracking_id ) ) {
2565 $data['status'] = 'NG';
2566 wp_send_json( $data );
2567 break;
2568 }
2569
2570 $res = '';
2571 $status = '';
2572
2573 $latest_log = $this->get_acting_latest_log( $order_id, $tracking_id );
2574 if ( ! empty( $latest_log['order_no'] ) ) {
2575 $order_ref = wel_zeus_get_order_ref( $latest_log['order_no'] );
2576 if ( 'TEST' === $order_ref['status'] ) {
2577 $status = 'OK';
2578 $status_name = $this->get_status_name( $order_ref['status'] );
2579 $res .= '<div class="zeus-settlement-admin card-test">' . $status_name . '</div>';
2580 $res .= '<table class="settlement-admin-table">';
2581 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2582 $res .= '<td><input type="tel" class="settlement-amount" value="' . intval( $latest_log['amount'] ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2583 $res .= '</tr>';
2584 $res .= '</table>';
2585 } elseif ( 'payment' === $order_ref['status'] || 'change' === $order_ref['status'] ) {
2586 $status = 'OK';
2587 $status_name = $this->get_status_name( $order_ref['status'] );
2588 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
2589 $res .= '<table class="settlement-admin-table">';
2590 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2591 $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>';
2592 $res .= '</tr>';
2593 $res .= '</table>';
2594 $res .= '<div class="settlement-admin-button">';
2595 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2596 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2597 $res .= '</div>';
2598 } elseif ( 'auth' === $order_ref['status'] ) {
2599 $status = 'OK';
2600 $status_name = $this->get_status_name( $order_ref['status'] );
2601 $res .= '<div class="zeus-settlement-admin card-auth">' . $status_name . '</div>';
2602 $res .= '<table class="settlement-admin-table">';
2603 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2604 $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>';
2605 $res .= '</tr>';
2606 $res .= '</table>';
2607 $res .= '<div class="settlement-admin-button">';
2608 $res .= '<input id="sale_settlement" type="button" class="button" value="売上処理" />';
2609 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2610 $res .= '</div>';
2611 } elseif ( 'cancel' === $order_ref['status'] ) {
2612 $status = 'OK';
2613 $status_name = $this->get_status_name( $order_ref['status'] );
2614 $res .= '<div class="zeus-settlement-admin card-cancel">' . $status_name . '</div>';
2615 $res .= '<table class="settlement-admin-table">';
2616 if ( ! empty( $member_id ) ) {
2617 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2618 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2619 $res .= '</tr>';
2620 $res .= '</table>';
2621 $res .= '<div class="settlement-admin-button">';
2622 $res .= '<input id="re_settlement" type="button" class="button" value="新規決済" />';
2623 $res .= '</div>';
2624 } else {
2625 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2626 $res .= '<td><input type="tel" class="settlement-amount" value="' . intval( $latest_log['amount'] ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2627 $res .= '</tr>';
2628 $res .= '</table>';
2629 }
2630 } else {
2631 if ( 'TEST' === $latest_log['status'] ) {
2632 $status = 'OK';
2633 $status_name = $this->get_status_name( $latest_log['status'] );
2634 $res .= '<div class="zeus-settlement-admin card-test">' . $status_name . '</div>';
2635 $res .= '<table class="settlement-admin-table">';
2636 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2637 $res .= '<td><input type="tel" class="settlement-amount" value="' . intval( $latest_log['amount'] ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2638 $res .= '</tr>';
2639 $res .= '</table>';
2640 } elseif ( 'payment' === $latest_log['status'] || 'change' === $latest_log['status'] ) {
2641 $status = 'OK';
2642 $status_name = $this->get_status_name( 'payment' );
2643 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
2644 $res .= '<table class="settlement-admin-table">';
2645 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2646 $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>';
2647 $res .= '</tr>';
2648 $res .= '</table>';
2649 $res .= '<div class="settlement-admin-button">';
2650 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2651 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2652 $res .= '</div>';
2653 } elseif ( 'auth' === $latest_log['status'] ) {
2654 $status = 'OK';
2655 $status_name = $this->get_status_name( $latest_log['status'] );
2656 $res .= '<div class="zeus-settlement-admin card-auth">' . $status_name . '</div>';
2657 $res .= '<table class="settlement-admin-table">';
2658 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2659 $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>';
2660 $res .= '</tr>';
2661 $res .= '</table>';
2662 $res .= '<div class="settlement-admin-button">';
2663 $res .= '<input id="sale_settlement" type="button" class="button" value="売上処理" />';
2664 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2665 $res .= '</div>';
2666 } elseif ( 'cancel' === $latest_log['status'] ) {
2667 $status = 'OK';
2668 $status_name = $this->get_status_name( $latest_log['status'] );
2669 $res .= '<div class="zeus-settlement-admin card-cancel">' . $status_name . '</div>';
2670 $res .= '<table class="settlement-admin-table">';
2671 if ( ! empty( $member_id ) ) {
2672 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2673 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2674 $res .= '</tr>';
2675 $res .= '</table>';
2676 $res .= '<div class="settlement-admin-button">';
2677 $res .= '<input id="re_settlement" type="button" class="button" value="新規決済" />';
2678 $res .= '</div>';
2679 } else {
2680 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2681 $res .= '<td><input type="tel" class="settlement-amount" value="' . intval( $latest_log['amount'] ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2682 $res .= '</tr>';
2683 $res .= '</table>';
2684 }
2685 } else {
2686 $status = 'ERROR';
2687 $status_name = $this->get_status_name( 'error' );
2688 $res .= '<div class="zeus-settlement-admin card-error">' . $status_name . '</div>';
2689 }
2690 }
2691 } else {
2692 $latest_log = $this->get_acting_latest_log( $order_id, $tracking_id, 'ALL' );
2693 if ( 'autodelivery' === $latest_log['status'] || 'dlseller' === $latest_log['status'] ) {
2694 $status = 'OK';
2695 $status_name = $this->get_status_name( $latest_log['status'] );
2696 $res .= '<div class="zeus-settlement-admin card-error">' . $status_name . '</div>';
2697 $res .= '<table class="settlement-admin-table">';
2698 if ( ! empty( $member_id ) ) {
2699 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2700 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $latest_log['amount'] ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2701 $res .= '</tr>';
2702 $res .= '</table>';
2703 $res .= '<div class="settlement-admin-button">';
2704 $res .= '<input id="re_settlement" type="button" class="button" value="新規決済" />';
2705 $res .= '</div>';
2706 } else {
2707 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2708 $res .= '<td><input type="tel" class="settlement-amount" value="' . intval( $latest_log['amount'] ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2709 $res .= '</tr>';
2710 $res .= '</table>';
2711 }
2712 } else {
2713 $status = 'ERROR';
2714 $status_name = $this->get_status_name( $latest_log['status'], $latest_log['result'] );
2715 $res .= '<div class="zeus-settlement-admin card-error">' . $status_name . '</div>';
2716 }
2717 }
2718 $res .= $this->settlement_history( $order_id, $tracking_id );
2719 $data['result'] = $res;
2720 $data['status'] = $status;
2721 wp_send_json( $data );
2722 break;
2723
2724 /* クレジットカード売上処理 */
2725 case 'sale_zeus_card':
2726 check_admin_referer( 'order_edit', 'wc_nonce' );
2727 $order_id = filter_input( INPUT_POST, 'order_id' );
2728 $order_num = filter_input( INPUT_POST, 'order_num' );
2729 $tracking_id = filter_input( INPUT_POST, 'tracking_id' );
2730 $amount = filter_input( INPUT_POST, 'amount' );
2731 if ( empty( $order_id ) || empty( $tracking_id ) || empty( $amount ) ) {
2732 $data['status'] = 'NG';
2733 wp_send_json( $data );
2734 break;
2735 }
2736
2737 $res = '';
2738 $status = '';
2739 $acting_status = '';
2740
2741 $latest_log = $this->get_acting_latest_log( $order_id, $tracking_id );
2742 if ( ! empty( $latest_log['order_no'] ) ) {
2743 $acting_opts = $this->get_acting_settings();
2744
2745 $params = array();
2746 $params['clientip'] = $acting_opts['clientip'];
2747 $params['king'] = $amount;
2748 $params['date'] = wp_date( 'Ymd' );
2749 $params['ordd'] = $latest_log['order_no'];
2750 $params['autype'] = 'sale';
2751
2752 $page_sale = $this->secure_link_batch( $acting_opts['card_url'], $params );
2753 if ( false !== strpos( $page_sale, 'Success_order' ) ) {
2754 $status = 'OK';
2755 $params = apply_filters( 'usces_filter_zeus_card_sale_log', $params, $order_id, $tracking_id );
2756 wel_zeus_save_acting_log( $params, 'zeus_card', 'sale', $status, $order_id, $tracking_id );
2757 $status_name = $this->get_status_name( 'sale' );
2758 $res .= '<div class="zeus-settlement-admin card-sale">' . $status_name . '</div>';
2759 $res .= '<table class="settlement-admin-table">';
2760 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2761 $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>';
2762 $res .= '</tr>';
2763 $res .= '</table>';
2764 $res .= '<div class="settlement-admin-button">';
2765 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2766 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2767 $res .= '</div>';
2768 $acting_status = '<span class="acting-status card-sale">' . $status_name . '</span>';
2769 } else {
2770 $status = $this->get_error_results( $page_sale );
2771 if ( empty( $status ) ) {
2772 $status = 'ERROR';
2773 }
2774 wel_zeus_save_acting_log( $params, 'zeus_card', 'sale', $status, $order_id, $tracking_id );
2775 $res .= '<div class="zeus-settlement-admin card-error">売上処理エラー</div>';
2776 $res .= '<table class="settlement-admin-table">';
2777 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2778 $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>';
2779 $res .= '</tr>';
2780 $res .= '</table>';
2781 $res .= '<div class="settlement-admin-button">';
2782 $res .= '<input id="sale_settlement" type="button" class="button" value="売上処理" />';
2783 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2784 $res .= '</div>';
2785 }
2786 } else {
2787 $status = 'NG';
2788 wel_zeus_save_acting_log( array(), 'zeus_card', 'sale', $status, $order_id, $tracking_id );
2789 $res .= '<div class="zeus-settlement-admin card-error">売上処理不可</div>';
2790 }
2791 $res .= $this->settlement_history( $order_id, $tracking_id );
2792 $data['result'] = $res;
2793 $data['status'] = $status;
2794 $data['acting_status'] = $acting_status;
2795 wp_send_json( $data );
2796 break;
2797
2798 /* クレジットカード取消処理 */
2799 case 'cancel_zeus_card':
2800 check_admin_referer( 'order_edit', 'wc_nonce' );
2801 $order_id = filter_input( INPUT_POST, 'order_id' );
2802 $order_num = filter_input( INPUT_POST, 'order_num' );
2803 $tracking_id = filter_input( INPUT_POST, 'tracking_id' );
2804 if ( empty( $order_id ) || empty( $tracking_id ) ) {
2805 $data['status'] = 'NG';
2806 wp_send_json( $data );
2807 break;
2808 }
2809
2810 $res = '';
2811 $status = '';
2812 $acting_status = '';
2813
2814 $latest_log = $this->get_acting_latest_log( $order_id, $tracking_id );
2815 if ( ! empty( $latest_log['order_no'] ) ) {
2816 $acting_opts = $this->get_acting_settings();
2817 /**
2818 * Cancel API
2819 $params = array();
2820 $params['authentication']['clientip'] = $acting_opts['clientip'];
2821 $params['authentication']['key'] = $acting_opts['authkey'];
2822 $params['return']['order_number'] = $latest_log['order_no'];
2823
2824 $cancel_req = '<?xml version="1.0" encoding="utf-8"?>';
2825 $cancel_req .= '<request service="secure_link" action="payment_return">';
2826 $cancel_req .= $this->assoc2xml( $params );
2827 $cancel_req .= '</request>';
2828 $xml = $this->get_xml( $acting_opts['card_secureurl'], $cancel_req );
2829 if ( ! empty( $xml ) ) {
2830 $cancel_res = $this->xml2assoc( $xml );
2831 if ( 'success' === $cancel_res['response']['result']['status'] ) {
2832 $status = 'OK';
2833 $cancel_res['order_no'] = $latest_log['order_no'];
2834 wel_zeus_save_acting_log( $cancel_res, 'zeus_card', 'cancel', 'OK', $order_id, $tracking_id );
2835 } else {
2836 $status = 'ERROR';
2837 $cancel_res['order_no'] = $latest_log['order_no'];
2838 wel_zeus_save_acting_log( $cancel_res, 'zeus_card', 'cancel', $cancel_res['response']['result']['status'], $order_id, $tracking_id );
2839 }
2840 } else {
2841 $status = 'NG';
2842 wel_zeus_save_acting_log( $params, 'zeus_card', 'cancel', 'NG', $order_id, $tracking_id );
2843 }
2844 */
2845 $params = array();
2846 $params['clientip'] = $acting_opts['clientip'];
2847 $params['return'] = 'yes';
2848 $params['ordd'] = $latest_log['order_no'];
2849
2850 $page_cancel = $this->secure_link_batch( $acting_opts['card_url'], $params );
2851 if ( false !== strpos( $page_cancel, 'SuccessOK' ) ) {
2852 $status = 'OK';
2853 $params = apply_filters( 'usces_filter_zeus_card_cancel_log', $params, $order_id, $tracking_id );
2854 wel_zeus_save_acting_log( $params, 'zeus_card', 'cancel', $status, $order_id, $tracking_id );
2855 $status_name = $this->get_status_name( 'cancel' );
2856 $res .= '<div class="zeus-settlement-admin card-cancel">' . $status_name . '</div>';
2857 $res .= '<table class="settlement-admin-table">';
2858 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2859 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="0" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
2860 $res .= '</tr>';
2861 $res .= '</table>';
2862 $res .= '<div class="settlement-admin-button">';
2863 $res .= '<input id="re_settlement" type="button" class="button" value="新規決済" />';
2864 $res .= '</div>';
2865 $acting_status = '<span class="acting-status card-cancel">' . $status_name . '</span>';
2866 $acting_data = $usces->get_order_meta_value( 'acting_zeus_card', $order_id );
2867 if ( $acting_data ) {
2868 $acting_data = usces_unserialize( $acting_data );
2869 if ( isset( $acting_data['money'] ) ) {
2870 $acting_data['money'] = 0;
2871 }
2872 $usces->set_order_meta_value( 'acting_zeus_card', usces_serialize( $acting_data ), $order_id );
2873 }
2874 } else {
2875 $status = $this->get_error_results( $page_cancel );
2876 if ( empty( $status ) ) {
2877 $status = 'ERROR';
2878 }
2879 wel_zeus_save_acting_log( $params, 'zeus_card', 'cancel', $status, $order_id, $tracking_id );
2880 $res .= '<div class="zeus-settlement-admin card-error">取消処理エラー</div>';
2881 }
2882 } else {
2883 $status = 'NG';
2884 wel_zeus_save_acting_log( array(), 'zeus_card', 'cancel', $status, $order_id, $tracking_id );
2885 $res .= '<div class="zeus-settlement-admin card-error">取消処理不可</div>';
2886 }
2887 $res .= $this->settlement_history( $order_id, $tracking_id );
2888 $data['result'] = $res;
2889 $data['status'] = $status;
2890 $data['acting_status'] = $acting_status;
2891 wp_send_json( $data );
2892 break;
2893
2894 /* クレジットカード金額変更 */
2895 case 'change_zeus_card':
2896 check_admin_referer( 'order_edit', 'wc_nonce' );
2897 $order_id = filter_input( INPUT_POST, 'order_id' );
2898 $order_num = filter_input( INPUT_POST, 'order_num' );
2899 $tracking_id = filter_input( INPUT_POST, 'tracking_id' );
2900 $amount = filter_input( INPUT_POST, 'amount' );
2901 if ( empty( $order_id ) || empty( $tracking_id ) || empty( $amount ) ) {
2902 $data['status'] = 'NG';
2903 wp_send_json( $data );
2904 break;
2905 }
2906
2907 $res = '';
2908 $status = '';
2909 $acting_status = '';
2910
2911 $latest_log = $this->get_acting_latest_log( $order_id, $tracking_id );
2912 if ( ! empty( $latest_log['order_no'] ) ) {
2913 $order_no = $latest_log['order_no'];
2914 $acting_opts = $this->get_acting_settings();
2915
2916 $params = array();
2917 $params['authentication']['clientip'] = $acting_opts['clientip'];
2918 $params['authentication']['key'] = $acting_opts['authkey'];
2919 $params['transaction']['money'] = $amount;
2920 $params['transaction']['order_number'] = $latest_log['order_no'];
2921 $params['transaction']['pubsec'] = 'yes';
2922
2923 $change_req = '<?xml version="1.0" encoding="utf-8"?>';
2924 $change_req .= '<request>';
2925 $change_req .= $this->assoc2xml( $params );
2926 $change_req .= '</request>';
2927
2928 $xml = $this->get_xml( $acting_opts['card_price_change'], $change_req );
2929 if ( ! empty( $xml ) ) {
2930 $change_res = $this->xml2assoc( $xml );
2931 if ( 'success' === $change_res['response']['result']['status'] ) {
2932 $status = 'OK';
2933 $log = $change_res['response']['result'];
2934 $log['amount'] = $amount;
2935 wel_zeus_save_acting_log( $log, 'zeus_card', 'change', $status, $order_id, $tracking_id );
2936
2937 $new_order_no = ( isset( $change_res['response']['result']['result_order_number'] ) ) ? $change_res['response']['result']['result_order_number'] : '';
2938 if ( ! empty( $new_order_no ) ) {
2939 $usces->set_order_meta_value( 'wc_trans_id', $new_order_no, $order_id );
2940 $usces->set_order_meta_value( 'trans_id', $new_order_no, $order_id );
2941 }
2942 $acting_data = $usces->get_order_meta_value( 'acting_zeus_card', $order_id );
2943 if ( $acting_data ) {
2944 $acting_data = usces_unserialize( $acting_data );
2945 if ( isset( $acting_data['ordd'] ) && ! empty( $new_order_no ) ) {
2946 $acting_data['ordd'] = $new_order_no;
2947 }
2948 if ( isset( $acting_data['money'] ) ) {
2949 $acting_data['money'] = $amount;
2950 }
2951 $usces->set_order_meta_value( 'acting_zeus_card', usces_serialize( $acting_data ), $order_id );
2952 }
2953
2954 if ( ! empty( $new_order_no ) ) {
2955 $order_ref = wel_zeus_get_order_ref( $new_order_no );
2956 if ( 'payment' === $order_ref['status'] ) {
2957 $status_name = $this->get_status_name( $order_ref['status'] );
2958 $order_ref = apply_filters( 'usces_filter_zeus_card_change_log', $order_ref, $order_id, $tracking_id );
2959 wel_zeus_save_acting_log( $order_ref, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
2960 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
2961 $res .= '<table class="settlement-admin-table">';
2962 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2963 $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>';
2964 $res .= '</tr>';
2965 $res .= '</table>';
2966 $res .= '<div class="settlement-admin-button">';
2967 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2968 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2969 $res .= '</div>';
2970 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
2971 } elseif ( 'auth' === $order_ref['status'] ) {
2972 $status_name = $this->get_status_name( $order_ref['status'] );
2973 $order_ref = apply_filters( 'usces_filter_zeus_card_change_log', $order_ref, $order_id, $tracking_id );
2974 wel_zeus_save_acting_log( $order_ref, 'zeus_card', 'auth', $status, $order_id, $tracking_id );
2975 $res .= '<div class="zeus-settlement-admin card-auth">' . $status_name . '</div>';
2976 $res .= '<table class="settlement-admin-table">';
2977 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2978 $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>';
2979 $res .= '</tr>';
2980 $res .= '</table>';
2981 $res .= '<div class="settlement-admin-button">';
2982 if ( '仮売完了' === $order_ref['RESULT'] ) {
2983 $res .= '<input id="sale_settlement" type="button" class="button" value="売上処理" />';
2984 }
2985 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2986 $res .= '</div>';
2987 $acting_status = '<span class="acting-status card-auth">' . $status_name . '</span>';
2988 } else {
2989 $status_name = $this->get_status_name( 'payment' );
2990 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
2991 $res .= '<table class="settlement-admin-table">';
2992 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
2993 $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>';
2994 $res .= '</tr>';
2995 $res .= '</table>';
2996 $res .= '<div class="settlement-admin-button">';
2997 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
2998 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
2999 $res .= '</div>';
3000 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
3001 }
3002 } else {
3003 $status_name = $this->get_status_name( 'payment' );
3004 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
3005 $res .= '<table class="settlement-admin-table">';
3006 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3007 $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>';
3008 $res .= '</tr>';
3009 $res .= '</table>';
3010 $res .= '<div class="settlement-admin-button">';
3011 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
3012 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
3013 $res .= '</div>';
3014 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
3015 }
3016 } else {
3017 $status = $change_res['response']['result']['status'];
3018 if ( empty( $status ) ) {
3019 $status = 'ERROR';
3020 }
3021 wel_zeus_save_acting_log( $change_res, 'zeus_card', 'change', $status, $order_id, $tracking_id );
3022 $res .= '<div class="zeus-settlement-admin card-error">金額変更エラー</div>';
3023 }
3024 } else {
3025 $status = 'ERROR';
3026 wel_zeus_save_acting_log( $params, 'zeus_card', 'change', $status, $order_id, $tracking_id );
3027 $res .= '<div class="zeus-settlement-admin card-error">金額変更エラー</div>';
3028 }
3029 } else {
3030 $status = 'NG';
3031 wel_zeus_save_acting_log( $params, 'zeus_card', 'change', $status, $order_id, $tracking_id );
3032 $res .= '<div class="zeus-settlement-admin card-error">金額変更不可</div>';
3033 }
3034 $res .= $this->settlement_history( $order_id, $tracking_id );
3035 $data['result'] = $res;
3036 $data['status'] = $status;
3037 $data['acting_status'] = $acting_status;
3038 wp_send_json( $data );
3039 break;
3040
3041 /* クレジットカード新規決済 */
3042 case 're_settlement_zeus_card':
3043 check_admin_referer( 'order_edit', 'wc_nonce' );
3044 $order_id = filter_input( INPUT_POST, 'order_id' );
3045 $order_num = filter_input( INPUT_POST, 'order_num' );
3046 $tracking_id = filter_input( INPUT_POST, 'tracking_id' );
3047 $member_id = filter_input( INPUT_POST, 'member_id' );
3048 $amount = filter_input( INPUT_POST, 'amount' );
3049 if ( empty( $order_id ) || empty( $tracking_id ) || empty( $amount ) ) {
3050 $data['status'] = 'NG';
3051 wp_send_json( $data );
3052 break;
3053 }
3054
3055 $res = '';
3056 $status = '';
3057 $acting_status = '';
3058
3059 $acting_opts = $this->get_acting_settings();
3060
3061 $params = array();
3062 $params['clientip'] = $acting_opts['clientip'];
3063 $params['cardnumber'] = '9999999999999992';
3064 $params['expyy'] = '00';
3065 $params['expmm'] = '00';
3066 $params['money'] = $amount;
3067 $params['send'] = 'mall';
3068 $params['telno'] = '0000000000';
3069 $params['email'] = $this->get_email( $order_id );
3070 $params['sendid'] = $member_id;
3071 $params['sendpoint'] = $tracking_id;
3072 $params['pubsec'] = 'yes';
3073 $params['printord'] = 'yes';
3074
3075 $page = $this->secure_link_batch( $acting_opts['card_url'], $params );
3076 if ( false !== strpos( $page, 'Success_order' ) ) {
3077 $status = 'OK';
3078
3079 $new_order_no = $this->get_order_number( $page );
3080 if ( ! empty( $new_order_no ) ) {
3081 $usces->set_order_meta_value( 'wc_trans_id', $new_order_no, $order_id );
3082 $usces->set_order_meta_value( 'trans_id', $new_order_no, $order_id );
3083 }
3084 $acting_data = $usces->get_order_meta_value( 'acting_zeus_card', $order_id );
3085 if ( $acting_data ) {
3086 $acting_data = usces_unserialize( $acting_data );
3087 $acting_data['ordd'] = $new_order_no;
3088 $acting_data['money'] = $amount;
3089 if ( ! isset( $acting_data['acting'] ) ) {
3090 $acting_data['acting'] = 'zeus_card';
3091 }
3092 if ( ! isset( $acting_data['sendpoint'] ) ) {
3093 $acting_data['sendpoint'] = $tracking_id;
3094 }
3095 if ( isset( $acting_data['settltment_status'] ) ) {
3096 unset( $acting_data['settltment_status'] );
3097 }
3098 if ( isset( $acting_data['settltment_errmsg'] ) ) {
3099 unset( $acting_data['settltment_errmsg'] );
3100 }
3101 } else {
3102 $acting_data = array(
3103 'acting' => 'zeus_card',
3104 'ordd' => $new_order_no,
3105 'sendpoint' => $tracking_id,
3106 'money' => $amount,
3107 );
3108 }
3109 $usces->set_order_meta_value( 'acting_zeus_card', usces_serialize( $acting_data ), $order_id );
3110
3111 if ( ! empty( $new_order_no ) ) {
3112 $order_ref = wel_zeus_get_order_ref( $new_order_no );
3113 if ( 'payment' === $order_ref['status'] ) {
3114 $status_name = $this->get_status_name( $order_ref['status'] );
3115 $order_ref = apply_filters( 'usces_filter_zeus_card_re_settlement_log', $order_ref, $order_id, $tracking_id );
3116 wel_zeus_save_acting_log( $order_ref, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
3117 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
3118 $res .= '<table class="settlement-admin-table">';
3119 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3120 $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>';
3121 $res .= '</tr>';
3122 $res .= '</table>';
3123 $res .= '<div class="settlement-admin-button">';
3124 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
3125 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
3126 $res .= '</div>';
3127 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
3128 } elseif ( 'auth' === $order_ref['status'] ) {
3129 $status_name = $this->get_status_name( $order_ref['status'] );
3130 $order_ref = apply_filters( 'usces_filter_zeus_card_re_settlement_log', $order_ref, $order_id, $tracking_id );
3131 wel_zeus_save_acting_log( $order_ref, 'zeus_card', 'auth', $status, $order_id, $tracking_id );
3132 $res .= '<div class="zeus-settlement-admin card-auth">' . $status_name . '</div>';
3133 $res .= '<table class="settlement-admin-table">';
3134 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3135 $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>';
3136 $res .= '</tr>';
3137 $res .= '</table>';
3138 $res .= '<div class="settlement-admin-button">';
3139 if ( '仮売完了' === $order_ref['RESULT'] ) {
3140 $res .= '<input id="sale_settlement" type="button" class="button" value="売上処理" />';
3141 }
3142 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
3143 $res .= '</div>';
3144 $acting_status = '<span class="acting-status card-auth">' . $status_name . '</span>';
3145 } else {
3146 $status_name = $this->get_status_name( 'payment' );
3147 if ( ! isset( $params['ordd'] ) ) {
3148 $params['ordd'] = $new_order_no;
3149 }
3150 $params = apply_filters( 'usces_filter_zeus_card_re_settlement_log', $params, $order_id, $tracking_id );
3151 wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
3152 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
3153 $res .= '<table class="settlement-admin-table">';
3154 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3155 $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>';
3156 $res .= '</tr>';
3157 $res .= '</table>';
3158 $res .= '<div class="settlement-admin-button">';
3159 $res .= '<input id="change_settlement" type="button" class="button" value="金額変更" />';
3160 $res .= '<input id="cancel_settlement" type="button" class="button" value="取消処理" />';
3161 $res .= '</div>';
3162 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
3163 }
3164 } else {
3165 $status_name = $this->get_status_name( 'payment' );
3166 $params = apply_filters( 'usces_filter_zeus_card_re_settlement_log', $params, $order_id, $tracking_id );
3167 wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
3168 $res .= '<div class="zeus-settlement-admin card-payment">' . $status_name . '</div>';
3169 $res .= '<table class="settlement-admin-table">';
3170 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3171 $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>';
3172 $res .= '</tr>';
3173 $res .= '</table>';
3174 $acting_status = '<span class="acting-status card-payment">' . $status_name . '</span>';
3175 }
3176 } else {
3177 $status = $this->get_error_results( $page );
3178 if ( empty( $status ) ) {
3179 $status = 'ERROR';
3180 }
3181 wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
3182 $res .= '<div class="zeus-settlement-admin card-error">新規決済エラー</div>';
3183 $res .= '<table class="settlement-admin-table">';
3184 $res .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3185 $res .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3186 $res .= '</tr>';
3187 $res .= '</table>';
3188 $res .= '<div class="settlement-admin-button">';
3189 $res .= '<input id="re_settlement" type="button" class="button" value="新規決済" />';
3190 $res .= '</div>';
3191 }
3192
3193 $res .= $this->settlement_history( $order_id, $tracking_id );
3194 $data['result'] = $res;
3195 $data['status'] = $status;
3196 $data['acting_status'] = $acting_status;
3197 wp_send_json( $data );
3198 break;
3199
3200 /* あと払い参�
3201 � */
3202 case 'get_zeus_bnpl':
3203 check_admin_referer( 'order_edit', 'wc_nonce' );
3204 $order_id = filter_input( INPUT_POST, 'order_id' );
3205 $shoporder_id = filter_input( INPUT_POST, 'shoporder_id' );
3206 $order_status = filter_input( INPUT_POST, 'order_status' );
3207 $delivery_company = filter_input( INPUT_POST, 'delivery_company' );
3208 $tracking_number = filter_input( INPUT_POST, 'tracking_number' );
3209 if ( empty( $order_id ) || empty( $shoporder_id ) ) {
3210 $data['status'] = 'NG';
3211 wp_send_json( $data );
3212 break;
3213 }
3214
3215 $res = '';
3216 $status = '';
3217
3218 $latest_log = $this->get_acting_latest_log( $order_id, $shoporder_id, 'ALL' );
3219 if ( ! empty( $latest_log['status'] ) && ! empty( $latest_log['result'] ) ) {
3220 if ( 'transaction' === $latest_log['status'] ) {
3221 $status = $latest_log['result'];
3222 $status_name = $this->get_status_name( $latest_log['status'] . $latest_log['result'] );
3223 $res .= '<div class="zeus-settlement-admin bnpl-transaction">' . $status_name . '</div>';
3224 $res .= '<div class="settlement-admin-button">';
3225 if ( 'OK' === $latest_log['result'] ) {
3226 $delivery_company_cd = array_search( $delivery_company, $this->shipping_company );
3227 $shippingrequest_disabled = ( ! $delivery_company_cd || ! $tracking_number ) ? ' disabled="disabled"' : '';
3228 $cancel_disabled = '';
3229 $res .= '<input id="shippingrequest_bnpl" type="button" class="button" value="出荷登録"' . $shippingrequest_disabled . ' />';
3230 } else {
3231 $cancel_disabled = ' disabled="disabled"';
3232 }
3233 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル"' . $cancel_disabled . ' />';
3234 $res .= '</div>';
3235 } elseif ( 'shippingrequest' === $latest_log['status'] ) {
3236 $status = $latest_log['result'];
3237 $status_name = $this->get_status_name( $latest_log['status'] . $latest_log['result'] );
3238 if ( 'OK' === $latest_log['result'] ) {
3239 $res .= '<div class="zeus-settlement-admin bnpl-shippingrequest">' . $status_name . '</div>';
3240 $res .= '<div class="settlement-admin-button">';
3241 } else {
3242 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3243 $res .= '<div class="settlement-admin-button">';
3244 $res .= '<input id="shippingrequest_bnpl" type="button" class="button" value="出荷登録" />';
3245 }
3246 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3247 $res .= '</div>';
3248 } elseif ( 'canceltransaction' === $latest_log['status'] ) {
3249 $status = $latest_log['result'];
3250 $status_name = $this->get_status_name( $latest_log['status'] . $latest_log['result'] );
3251 if ( 'OK' === $latest_log['result'] ) {
3252 $res .= '<div class="zeus-settlement-admin bnpl-canceltransaction">' . $status_name . '</div>';
3253 } else {
3254 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3255 $res .= '<div class="settlement-admin-button">';
3256 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3257 $res .= '</div>';
3258 }
3259 }
3260 } else {
3261 $status = 'ERROR';
3262 $status_name = $this->get_status_name( 'error' );
3263 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3264 }
3265
3266 $res .= $this->settlement_history_bnpl( $order_id, $shoporder_id );
3267 $data['result'] = $res;
3268 $data['status'] = $status;
3269 wp_send_json( $data );
3270 break;
3271
3272 /* あと払い出荷登録 */
3273 case 'shippingrequest_zeus_bnpl':
3274 check_admin_referer( 'order_edit', 'wc_nonce' );
3275 $order_id = filter_input( INPUT_POST, 'order_id' );
3276 $shoporder_id = filter_input( INPUT_POST, 'shoporder_id' );
3277 $order_status = filter_input( INPUT_POST, 'order_status' );
3278 $delivery_company = filter_input( INPUT_POST, 'delivery_company' );
3279 $tracking_number = filter_input( INPUT_POST, 'tracking_number' );
3280 if ( empty( $order_id ) || empty( $shoporder_id ) ) {
3281 $data['status'] = 'NG';
3282 wp_send_json( $data );
3283 break;
3284 }
3285
3286 $delivery_company_cd = array_search( $delivery_company, $this->shipping_company );
3287 if ( ! $delivery_company_cd || ! $tracking_number ) {
3288 $data['status'] = 'NG';
3289 wp_send_json( $data );
3290 break;
3291 }
3292
3293 $res = '';
3294 $status = '';
3295 $acting_status = '';
3296
3297 $acting_opts = $this->get_acting_settings();
3298 $latest_log = $this->get_acting_latest_log( $order_id, $shoporder_id );
3299
3300 $data = array();
3301 $data['linkInfo'] = array(
3302 'shopCode' => $acting_opts['clientip_bnpl'],
3303 'linkId' => $acting_opts['bnpl_linkid'],
3304 'linkPassword' => $acting_opts['bnpl_linkpassword'],
3305 );
3306 $data['transactionInfo'] = array(
3307 'deliveryType' => '1',
3308 'transactionId' => $latest_log['log']['transactionInfo']['transactionId'],
3309 'deliveryCompanyCode' => $delivery_company_cd,
3310 'deliverySlipNo' => $tracking_number,
3311 );
3312
3313 $request = '<?xml version="1.0" encoding="UTF-8"?>';
3314 $request .= '<request>';
3315 $request .= $this->assoc2xml( $data );
3316 $request .= '</request>';
3317
3318 $xml = $this->get_xml_bnpl( $acting_opts['bnpl_shippingrequest_url'], $request );
3319 if ( empty( $xml ) ) {
3320 $status = 'NG';
3321 wel_zeus_save_acting_log( $data, 'zeus_bnpl', 'shippingrequest', $status, $order_id, $shoporder_id );
3322 $status_name = $this->get_status_name( 'shippingrequest' . $status );
3323 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3324 $res .= '<div class="settlement-admin-button">';
3325 $res .= '<input id="shippingrequest_bnpl" type="button" class="button" value="出荷登録" />';
3326 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3327 $res .= '</div>';
3328 $acting_status = '<span class="acting-status bnpl-error">' . $status_name . '</span>';
3329 } else {
3330 $response = $this->xml2assoc( $xml );
3331 $status = ( isset( $response['response']['result'] ) ) ? $response['response']['result'] : 'NG';
3332 wel_zeus_save_acting_log( $response['response'], 'zeus_bnpl', 'shippingrequest', $status, $order_id, $shoporder_id );
3333 $status_name = $this->get_status_name( 'shippingrequest' . $status );
3334 if ( 'OK' === $status ) {
3335 $res .= '<div class="zeus-settlement-admin bnpl-shippingrequest">' . $status_name . '</div>';
3336 $res .= '<div class="settlement-admin-button">';
3337 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3338 $res .= '</div>';
3339 $acting_status = '<span class="acting-status bnpl-shippingrequest">' . $status_name . '</span>';
3340 } else {
3341 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3342 $res .= '<div class="settlement-admin-button">';
3343 $res .= '<input id="shippingrequest_bnpl" type="button" class="button" value="出荷登録" />';
3344 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3345 $res .= '</div>';
3346 $acting_status = '<span class="acting-status bnpl-error">' . $status_name . '</span>';
3347 }
3348 }
3349
3350 $res .= $this->settlement_history_bnpl( $order_id, $shoporder_id );
3351 $data['result'] = $res;
3352 $data['status'] = $status;
3353 $data['acting_status'] = $acting_status;
3354 wp_send_json( $data );
3355 break;
3356
3357 /* あと払い取消 */
3358 case 'cancel_zeus_bnpl':
3359 check_admin_referer( 'order_edit', 'wc_nonce' );
3360 $order_id = filter_input( INPUT_POST, 'order_id' );
3361 $shoporder_id = filter_input( INPUT_POST, 'shoporder_id' );
3362 $order_status = filter_input( INPUT_POST, 'order_status' );
3363 if ( empty( $order_id ) || empty( $shoporder_id ) ) {
3364 $data['status'] = 'NG';
3365 wp_send_json( $data );
3366 break;
3367 }
3368
3369 $res = '';
3370 $status = '';
3371 $acting_status = '';
3372
3373 $acting_opts = $this->get_acting_settings();
3374 $latest_log = $this->get_acting_latest_log( $order_id, $shoporder_id );
3375
3376 $data = array();
3377 $data['linkInfo'] = array(
3378 'shopCode' => $acting_opts['clientip_bnpl'],
3379 'linkId' => $acting_opts['bnpl_linkid'],
3380 'linkPassword' => $acting_opts['bnpl_linkpassword'],
3381 );
3382 // 出荷登録API 出荷取消.
3383 // $data['transactionInfo'] = array(
3384 // 'deliveryType' => '3',
3385 // 'transactionId' => $latest_log['log']['transactionInfo']['transactionId'],
3386 // 'deliveryCompanyCode' => '',
3387 // 'deliverySlipNo' => '',
3388 // );
3389 // 取引修正API キャンセル.
3390 $data['transactionInfo'] = array(
3391 'updateTypeFlag' => '1',
3392 'transactionId' => $latest_log['log']['transactionInfo']['transactionId'],
3393 );
3394 $data['customer'] = array(
3395 'shopOrderId' => '',
3396 'shopOrderDate' => '',
3397 'name' => '',
3398 'kanaName' => '',
3399 'zip' => '',
3400 'address' => '',
3401 'companyName' => '',
3402 'sectionName' => '',
3403 'tel' => '',
3404 'email' => '',
3405 'billedAmount' => '',
3406 'expand1' => '',
3407 'service' => '',
3408 );
3409 $data['ship'] = array(
3410 'shipName' => '',
3411 'shipKananame' => '',
3412 'shipZip' => '',
3413 'shipAddress' => '',
3414 'shipCompanyName' => '',
3415 'shipSectionName' => '',
3416 'shipTel' => '',
3417 );
3418 $data['details'] = array(
3419 'detail' => array(
3420 'goods' => '',
3421 'goodsPrice' => '',
3422 'goodsAmount' => '',
3423 'expand2' => '',
3424 'expand3' => '',
3425 'expand4' => '',
3426 ),
3427 );
3428
3429 $request = '<?xml version="1.0" encoding="UTF-8"?>';
3430 $request .= '<request>';
3431 $request .= $this->assoc2xml( $data );
3432 $request .= '</request>';
3433
3434 // $xml = $this->get_xml_bnpl( $acting_opts['bnpl_shippingrequest_url'], $request );
3435 $xml = $this->get_xml_bnpl( $acting_opts['bnpl_modifytransaction_url'], $request );
3436 if ( empty( $xml ) ) {
3437 $status = 'NG';
3438 wel_zeus_save_acting_log( $data, 'zeus_bnpl', 'canceltransaction', $status, $order_id, $shoporder_id );
3439 $status_name = $this->get_status_name( 'canceltransaction' . $status );
3440 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3441 $res .= '<div class="settlement-admin-button">';
3442 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3443 $res .= '</div>';
3444 $acting_status = '<span class="acting-status bnpl-error">' . $status_name . '</span>';
3445 } else {
3446 $response = $this->xml2assoc( $xml );
3447 $status = ( isset( $response['response']['result'] ) ) ? $response['response']['result'] : 'NG';
3448 wel_zeus_save_acting_log( $response['response'], 'zeus_bnpl', 'canceltransaction', $status, $order_id, $shoporder_id );
3449 $status_name = $this->get_status_name( 'canceltransaction' . $status );
3450 if ( 'OK' === $status ) {
3451 $res .= '<div class="zeus-settlement-admin bnpl-canceltransaction">' . $status_name . '</div>';
3452 $acting_status = '<span class="acting-status bnpl-canceltransaction">' . $status_name . '</span>';
3453 } else {
3454 $res .= '<div class="zeus-settlement-admin bnpl-error">' . $status_name . '</div>';
3455 $res .= '<div class="settlement-admin-button">';
3456 $res .= '<input id="cancel_bnpl" type="button" class="button" value="取引キャンセル" />';
3457 $res .= '</div>';
3458 $acting_status = '<span class="acting-status bnpl-error">' . $status_name . '</span>';
3459 }
3460 }
3461
3462 $res .= $this->settlement_history_bnpl( $order_id, $shoporder_id );
3463 $data['result'] = $res;
3464 $data['status'] = $status;
3465 $data['acting_status'] = $acting_status;
3466 wp_send_json( $data );
3467 break;
3468
3469 /* 継続課金�
3470 報更新 */
3471 case 'continuation_update':
3472 check_admin_referer( 'order_edit', 'wc_nonce' );
3473 $order_id = filter_input( INPUT_POST, 'order_id' );
3474 $member_id = filter_input( INPUT_POST, 'member_id' );
3475 $contracted_year = filter_input( INPUT_POST, 'contracted_year' );
3476 $contracted_month = filter_input( INPUT_POST, 'contracted_month' );
3477 $contracted_day = filter_input( INPUT_POST, 'contracted_day' );
3478 $charged_year = filter_input( INPUT_POST, 'charged_year' );
3479 $charged_month = filter_input( INPUT_POST, 'charged_month' );
3480 $charged_day = filter_input( INPUT_POST, 'charged_day' );
3481 $price = filter_input( INPUT_POST, 'price', FILTER_VALIDATE_INT, array( 'options' => array( 'default' => 0 ) ) );
3482 $status = filter_input( INPUT_POST, 'status' );
3483
3484 $continue_data = $this->get_continuation_data( $member_id, $order_id );
3485 if ( ! $continue_data ) {
3486 $data['status'] = 'NG';
3487 wp_send_json( $data );
3488 break;
3489 }
3490
3491 /* 継続中→停止 */
3492 if ( 'continuation' === $continue_data['status'] && 'cancellation' === $status ) {
3493 $this->update_continuation_data( $member_id, $order_id, $continue_data, true );
3494 } else {
3495 if ( ! empty( $contracted_year ) && ! empty( $contracted_month ) && ! empty( $contracted_day ) ) {
3496 $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
3497 if ( $contracted_date ) {
3498 $new_contracted_date = $contracted_year . '-' . $contracted_month . '-' . $contracted_day;
3499 if ( ! $this->isdate( $new_contracted_date ) ) {
3500 $data['status'] = 'NG';
3501 $data['message'] = __( 'Next contract renewal date is incorrect.', 'dlseller' );
3502 wp_send_json( $data );
3503 }
3504 }
3505 } else {
3506 $new_contracted_date = '';
3507 }
3508 $new_charged_date = $charged_year . '-' . $charged_month . '-' . $charged_day;
3509 if ( ! $this->isdate( $new_charged_date ) ) {
3510 $data['status'] = 'NG';
3511 $data['message'] = __( 'Next settlement date is incorrect.', 'dlseller' );
3512 wp_send_json( $data );
3513 }
3514 $tomorrow = date_i18n( 'Y-m-d', strtotime( '+1 day' ) );
3515 if ( $new_charged_date < $tomorrow ) {
3516 $data['status'] = 'NG';
3517 $data['message'] = sprintf( __( 'The next settlement date must be after %s.', 'dlseller' ), $tomorrow );
3518 wp_send_json( $data );
3519 }
3520 $continue_data['contractedday'] = $new_contracted_date;
3521 $continue_data['chargedday'] = $new_charged_date;
3522 $continue_data['price'] = usces_crform( $price, false, false, 'return', false );
3523 $continue_data['status'] = $status;
3524 $this->update_continuation_data( $member_id, $order_id, $continue_data );
3525 }
3526 $data['status'] = 'OK';
3527 wp_send_json( $data );
3528 break;
3529 }
3530 }
3531
3532 /**
3533 * 決済履歴
3534 *
3535 * @param int $order_id Order number.
3536 * @param string $tracking_id Tracking ID.
3537 * @return string
3538 */
3539 private function settlement_history( $order_id, $tracking_id ) {
3540 $history = '';
3541 $log_data = $this->get_acting_log( $order_id, $tracking_id, 'ALL' );
3542 if ( $log_data ) {
3543 $num = count( $log_data );
3544 $history = '<table class="settlement-history">';
3545 $history .= '<thead class="settlement-history-head">';
3546 $history .= '<tr><th></th><th>' . __( 'Processing date', 'usces' ) . '</th><th>オーダーNo</th><th>処理結果</th><th>' . __( 'Settlement amount', 'usces' ) . '</th><th>エラーメッセージ</th></tr>';
3547 $history .= '</thead>';
3548 $history .= '<tbody class="settlement-history-body">';
3549 foreach ( (array) $log_data as $data ) {
3550 $log = usces_unserialize( $data['log'] );
3551 $order_no = $this->get_order_no( $log );
3552 $status_name = $this->get_status_name( $data['status'], $data['result'] );
3553 $err_result = '';
3554 $class = '';
3555 $amount = usces_crform( $data['amount'], false, true, 'return', true );
3556 if ( ! in_array( $data['result'], $this->payment_normal_results, true ) ) {
3557 $err_result = $data['result'];
3558 $class = ' error';
3559 }
3560 $history .= '<tr>';
3561 $history .= '<td class="num">' . $num . '</td>';
3562 $history .= '<td class="datetime">' . $data['datetime'] . '</td>';
3563 $history .= '<td class="transactionid">' . $order_no . '</td>';
3564 $history .= '<td class="status">' . $status_name . '</td>';
3565 $history .= '<td class="amount">' . $amount . '</td>';
3566 $history .= '<td class="result' . $class . '">' . $err_result . '</td>';
3567 $history .= '</tr>';
3568 $num--;
3569 }
3570 $history .= '</tbody>';
3571 $history .= '</table>';
3572 }
3573 return $history;
3574 }
3575
3576 /**
3577 * 決済履歴(あと払い)
3578 *
3579 * @param int $order_id Order number.
3580 * @param string $tracking_id Tracking ID.
3581 * @return string
3582 */
3583 private function settlement_history_bnpl( $order_id, $tracking_id ) {
3584 $history = '';
3585 $log_data = $this->get_acting_log( $order_id, $tracking_id, 'ALL' );
3586 if ( $log_data ) {
3587 $num = count( $log_data );
3588 $history = '<table class="settlement-history">';
3589 $history .= '<thead class="settlement-history-head">';
3590 $history .= '<tr><th></th><th>' . __( 'Processing date', 'usces' ) . '</th><th>問い合わせ番号</th><th>処理</th><th>処理結果</th><th>' . __( 'Settlement amount', 'usces' ) . '</th><th>エラーメッセージ</th></tr>';
3591 $history .= '</thead>';
3592 $history .= '<tbody class="settlement-history-body">';
3593 foreach ( (array) $log_data as $data ) {
3594 $log = usces_unserialize( $data['log'] );
3595 $transaction_id = ( isset( $log['transactionInfo']['transactionId'] ) ) ? $log['transactionInfo']['transactionId'] : '';
3596 $status_name = $this->get_status_name( $data['status'] );
3597 $err_result = '';
3598 $class = '';
3599 $amount = ( 0 !== (int) $data['amount'] ) ? usces_crform( $data['amount'], false, true, 'return', true ) : '';
3600 if ( ! in_array( $data['result'], $this->payment_normal_results, true ) ) {
3601 if ( isset( $log['errors']['error']['errorCode'] ) && isset( $log['errors']['error']['errorMessage'] ) ) {
3602 $err_result = $log['errors']['error']['errorCode'] . ':' . $log['errors']['error']['errorMessage'];
3603 }
3604 $class = ' error';
3605 }
3606 $history .= '<tr>';
3607 $history .= '<td class="num">' . $num . '</td>';
3608 $history .= '<td class="datetime">' . $data['datetime'] . '</td>';
3609 $history .= '<td class="transaction_id">' . $transaction_id . '</td>';
3610 $history .= '<td class="status">' . $status_name . '</td>';
3611 $history .= '<td class="status">' . $data['result'] . '</td>';
3612 $history .= '<td class="amount">' . $amount . '</td>';
3613 $history .= '<td class="result' . $class . '">' . $err_result . '</td>';
3614 $history .= '</tr>';
3615 $num--;
3616 }
3617 $history .= '</tbody>';
3618 $history .= '</table>';
3619 }
3620 return $history;
3621 }
3622
3623 /**
3624 * 決済状況
3625 * usces_filter_orderlist_detail_value
3626 *
3627 * @param string $detail HTML.
3628 * @param string $value Settlement info key.
3629 * @param string $key Settlement info value.
3630 * @param int $order_id Order number.
3631 * @return array
3632 */
3633 public function orderlist_settlement_status( $detail, $value, $key, $order_id ) {
3634 if ( 'wc_trans_id' !== $key ) {
3635 return $detail;
3636 }
3637
3638 $payment_name = $this->get_order_payment_name( $order_id );
3639 $acting_flg = $this->get_acting_flg( $payment_name );
3640 if ( 'acting_zeus_card' === $acting_flg ) {
3641 $tracking_id = $this->get_tracking_id( $order_id );
3642 if ( ! empty( $tracking_id ) ) {
3643 $acting_status = $this->get_acting_status( $order_id, $tracking_id, 'ALL' );
3644 $status_name = $this->get_status_name( $acting_status );
3645 if ( ! empty( $status_name ) ) {
3646 $detail = '<td>' . esc_html( $value ) . '<span class="acting-status card-' . esc_html( $acting_status ) . '">' . esc_html( $status_name ) . '</span></td>';
3647 }
3648 }
3649 } elseif ( 'acting_zeus_bnpl' === $acting_flg ) {
3650 $tracking_id = $this->get_tracking_id( $order_id );
3651 if ( ! empty( $tracking_id ) ) {
3652 $acting_status = $this->get_acting_status( $order_id, $tracking_id, 'ALL' );
3653 $status_name = $this->get_status_name( $acting_status );
3654 if ( ! empty( $status_name ) ) {
3655 $class = ( 'NG' === substr( $acting_status, -2 ) ) ? 'error' : $acting_status;
3656 $detail = '<td>' . esc_html( $value ) . '<span class="acting-status bnpl-' . esc_html( $class ) . '">' . esc_html( $status_name ) . '</span></td>';
3657 }
3658 }
3659 }
3660 return $detail;
3661 }
3662
3663 /**
3664 * 受注編集画面【ステータス】
3665 * usces_action_order_edit_form_status_block_middle
3666 *
3667 * @param array $data Order data.
3668 * @param array $cscs_meta Custom field data.
3669 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3670 */
3671 public function settlement_status( $data, $cscs_meta, $action_args ) {
3672 $order_action = ( isset( $action_args['order_action'] ) ) ? $action_args['order_action'] : '';
3673 $order_id = ( isset( $action_args['order_id'] ) ) ? $action_args['order_id'] : '';
3674 if ( 'new' !== $order_action && ! empty( $order_id ) ) {
3675 $acting_flg = $this->get_acting_flg( $data['order_payment_name'] );
3676 if ( 'acting_zeus_card' === $acting_flg ) {
3677 $tracking_id = $this->get_tracking_id( $order_id );
3678 $acting_status = $this->get_acting_status( $order_id, $tracking_id, 'ALL' );
3679 $status_name = $this->get_status_name( $acting_status );
3680 if ( ! empty( $status_name ) ) {
3681 echo '
3682 <tr>
3683 <td class="label status">' . esc_html__( 'Settlement status', 'usces' ) . '</td>
3684 <td class="col1 status"><span id="settlement-status"><span class="acting-status card-' . esc_attr( $acting_status ) . '">' . esc_html( $status_name ) . '</span></span></td>
3685 </tr>';
3686 }
3687 } elseif ( 'acting_zeus_bnpl' === $acting_flg ) {
3688 $tracking_id = $this->get_tracking_id( $order_id );
3689 $acting_status = $this->get_acting_status( $order_id, $tracking_id, 'ALL' );
3690 $class = ' bnpl-' . $acting_status;
3691 $status_name = $this->get_status_name( $acting_status );
3692 if ( ! empty( $status_name ) ) {
3693 $class = ( 'NG' === substr( $acting_status, -2 ) ) ? 'error' : $acting_status;
3694 echo '
3695 <tr>
3696 <td class="label status">' . esc_html__( 'Settlement status', 'usces' ) . '</td>
3697 <td class="col1 status"><span id="settlement-status"><span class="acting-status bnpl-' . esc_attr( $class ) . '">' . esc_html( $status_name ) . '</span></span></td>
3698 </tr>';
3699 }
3700 }
3701 }
3702 }
3703
3704 /**
3705 * 受注編集画面【支払�
3706 報】
3707 * usces_action_order_edit_form_settle_info
3708 *
3709 * @param array $data Order data.
3710 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3711 */
3712 public function settlement_information( $data, $action_args ) {
3713 $order_action = ( isset( $action_args['order_action'] ) ) ? $action_args['order_action'] : '';
3714 $order_id = ( isset( $action_args['order_id'] ) ) ? $action_args['order_id'] : '';
3715 if ( 'new' !== $order_action && ! empty( $order_id ) ) {
3716 $acting_flg = $this->get_acting_flg( $data['order_payment_name'] );
3717 if ( 'acting_zeus_card' === $acting_flg || 'acting_zeus_bnpl' === $acting_flg ) {
3718 $tracking_id = $this->get_tracking_id( $order_id );
3719 if ( ! empty( $tracking_id ) ) {
3720 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' ) . '">';
3721 }
3722 }
3723 }
3724 }
3725
3726 /**
3727 * 決済�
3728 報ダイアログ
3729 * usces_action_endof_order_edit_form
3730 *
3731 * @param array $data Order data.
3732 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3733 */
3734 public function settlement_dialog( $data, $action_args ) {
3735 $order_action = ( isset( $action_args['order_action'] ) ) ? $action_args['order_action'] : '';
3736 $order_id = ( isset( $action_args['order_id'] ) ) ? $action_args['order_id'] : '';
3737 if ( 'new' !== $order_action && ! empty( $order_id ) ) :
3738 $acting_flg = $this->get_acting_flg( $data['order_payment_name'] );
3739 if ( 'acting_zeus_card' === $acting_flg || 'acting_zeus_bnpl' === $acting_flg ) :
3740 ?>
3741 <div id="settlement_dialog" title="">
3742 <div id="settlement-response-loading"></div>
3743 <fieldset>
3744 <div id="settlement-response"></div>
3745 <input type="hidden" id="order_num">
3746 <input type="hidden" id="tracking_id">
3747 <input type="hidden" id="acting" value="<?php echo esc_attr( $acting_flg ); ?>">
3748 <input type="hidden" id="error">
3749 </fieldset>
3750 </div>
3751 <?php
3752 endif;
3753 endif;
3754 }
3755
3756 /**
3757 * 受注データから取得する決済�
3758 報のキー
3759 * usces_filter_settle_info_field_meta_keys
3760 *
3761 * @param array $keys Settlement information key.
3762 * @return array
3763 */
3764 public function settlement_info_field_meta_keys( $keys ) {
3765 $keys = array_merge( $keys, array( 'div', 'auth_code', 'shopOrderId', 'transactionId' ) );
3766 return $keys;
3767 }
3768
3769 /**
3770 * 受注編集画面に表示する決済�
3771 報のキー
3772 * usces_filter_settle_info_field_keys
3773 *
3774 * @param array $keys Settlement information keys.
3775 * @param array $fields Settlement information fields.
3776 * @return array
3777 */
3778 public function settlement_info_field_keys( $keys, $fields ) {
3779 if ( isset( $fields['acting'] ) ) {
3780 if ( 'zeus_card' === $fields['acting'] ) {
3781 $field_keys = array( 'div' );
3782 $acting_opts = $this->get_acting_settings();
3783 if ( 2 === (int) $acting_opts['connection'] && 1 === (int) $acting_opts['3dsecur'] ) {
3784 $field_keys[] = 'auth_code';
3785 }
3786 $keys = array_merge( $keys, $field_keys );
3787 } elseif ( 'zeus_bnpl' === $fields['acting'] ) {
3788 $keys = array( 'acting', 'shopOrderId', 'transactionId' );
3789 }
3790 }
3791 return $keys;
3792 }
3793
3794 /**
3795 * 受注編集画面に表示する決済�
3796 報の値整形
3797 * usces_filter_settle_info_field_value
3798 *
3799 * @param string $value Settlement information value.
3800 * @param string $key Settlement information key.
3801 * @param string $acting Acting type.
3802 * @return string
3803 */
3804 public function settlement_info_field_value( $value, $key, $acting ) {
3805 if ( false !== strpos( $acting, 'zeus_card' ) ) {
3806 if ( 'acting' === $key ) {
3807 $value = 'カード決済(ZEUS)';
3808 } elseif ( 'div' === $key ) {
3809 switch ( $value ) {
3810 case '01':
3811 $value = '一括払い';
3812 break;
3813 case '02':
3814 $value = '分割(2回)';
3815 break;
3816 case '03':
3817 $value = '分割(3回)';
3818 break;
3819 case '05':
3820 $value = '分割(5回)';
3821 break;
3822 case '06':
3823 $value = '分割(6回)';
3824 break;
3825 case '10':
3826 $value = '分割(10回)';
3827 break;
3828 case '12':
3829 $value = '分割(12回)';
3830 break;
3831 case '15':
3832 $value = '分割(15回)';
3833 break;
3834 case '18':
3835 $value = '分割(18回)';
3836 break;
3837 case '20':
3838 $value = '分割(20回)';
3839 break;
3840 case '24':
3841 $value = '分割(24回)';
3842 break;
3843 case '99':
3844 $value = '分割(リボ払い)';
3845 break;
3846 case 'B1':
3847 $value = '分割(ボーナス一括払い)';
3848 break;
3849 }
3850 }
3851 } elseif ( 'zeus_bank' === $acting ) {
3852 if ( 'acting' === $key ) {
3853 $value = '銀行振込決済(ZEUS)';
3854 } elseif ( 'status' === $key ) {
3855 if ( '01' === $value ) {
3856 $value = '受付中';
3857 } elseif ( '02' === $value ) {
3858 $value = '未�
3859 �金';
3860 } elseif ( '03' === $value ) {
3861 $value = '�
3862 �金済';
3863 } elseif ( '04' === $value ) {
3864 $value = 'エラー';
3865 } elseif ( '05' === $value ) {
3866 $value = '�
3867 �金失敗';
3868 }
3869 } elseif ( 'error_message' === $key ) {
3870 if ( '0002' === $value ) {
3871 $value = '�
3872 �金不足';
3873 } elseif ( '0003' === $value ) {
3874 $value = '過剰�
3875 �金';
3876 }
3877 }
3878 } elseif ( 'zeus_conv' === $acting ) {
3879 if ( 'acting' === $key ) {
3880 $value = 'コンビニ決済(ZEUS)';
3881 } elseif ( 'pay_cvs' === $key ) {
3882 $value = esc_html( usces_get_conv_name( $value ) );
3883 } elseif ( 'status' === $key ) {
3884 if ( '01' === $value ) {
3885 $value = '未�
3886 �金';
3887 } elseif ( '02' === $value ) {
3888 $value = '申込エラー';
3889 } elseif ( '03' === $value ) {
3890 $value = '期日切';
3891 } elseif ( '04' === $value ) {
3892 $value = '�
3893 �金済';
3894 } elseif ( '05' === $value ) {
3895 $value = '売上確定';
3896 } elseif ( '06' === $value ) {
3897 $value = '�
3898 �金取消';
3899 } elseif ( '11' === $value ) {
3900 $value = 'キャンセル後�
3901 �金';
3902 } elseif ( '12' === $value ) {
3903 $value = 'キャンセル後売上';
3904 } elseif ( '13' === $value ) {
3905 $value = 'キャンセル後取消';
3906 }
3907 } elseif ( 'pay_limit' === $key ) {
3908 $value = substr( $value, 0, 4 ) . '' . substr( $value, 4, 2 ) . '' . substr( $value, 6, 2 ) . '';
3909 }
3910 } elseif ( 'zeus_bnpl' === $acting ) {
3911 if ( 'acting' === $key ) {
3912 $value = 'あと払い決済(ZEUS)';
3913 }
3914 }
3915 return $value;
3916 }
3917
3918 /**
3919 * あと払い運送会社名
3920 * usces_filter_deli_comps
3921 *
3922 * @param array $deli_comps Delivery company.
3923 * @param array $data Order data.
3924 * @return array
3925 */
3926 public function bnpl_delivery_company( $deli_comps, $data ) {
3927 if ( isset( $data['order_payment_name'] ) ) {
3928 $acting_flg = $this->get_acting_flg( $data['order_payment_name'] );
3929 if ( 'acting_zeus_bnpl' === $acting_flg ) {
3930 $deli_comps = array_values( $this->shipping_company );
3931 }
3932 }
3933 return $deli_comps;
3934 }
3935
3936 /**
3937 * 会員データ編集画面 カード�
3938 報登録�
3939
3940 * usces_action_admin_member_info
3941 *
3942 * @param array $member Member data.
3943 * @param array $member_metas Member meta data.
3944 * @param array $member_history Member's history order data.
3945 */
3946 public function admin_member_info( $member, $member_metas, $member_history ) {
3947 $acting_opts = $this->get_acting_settings();
3948 if ( 'on' !== $acting_opts['quickcharge'] ) {
3949 return;
3950 }
3951
3952 $cardinfo = array();
3953 foreach ( $member_metas as $value ) {
3954 if ( in_array( $value['meta_key'], array( 'zeus_pcid', 'zeus_partofcard' ), true ) ) {
3955 $cardinfo[ $value['meta_key'] ] = $value['meta_value'];
3956 }
3957 }
3958 if ( 0 < count( $cardinfo ) ) :
3959 foreach ( $cardinfo as $key => $value ) :
3960 if ( 'zeus_pcid' !== $key ) :
3961 if ( 'zeus_partofcard' === $key ) {
3962 $label = __( 'Lower 4 digits', 'usces' );
3963 } elseif ( 'zeus_limitofcard' === $key ) {
3964 $label = __( 'Expiration date', 'usces' );
3965 } else {
3966 $label = $key;
3967 }
3968 ?>
3969 <tr>
3970 <td class="label"><?php echo esc_html( $label ); ?></td>
3971 <td><div class="rod_left shortm"><?php echo esc_html( $value ); ?></div></td>
3972 </tr>
3973 <?php
3974 endif;
3975 endforeach;
3976 if ( array_key_exists( 'zeus_pcid', $cardinfo ) ) :
3977 ?>
3978 <tr>
3979 <td class="label">QuickCharge</td>
3980 <td><div class="rod_left shortm"><?php esc_html_e( 'Registered', 'usces' ); ?></div></td>
3981 </tr>
3982 <?php
3983 if ( ! usces_have_member_continue_order( $member['ID'] ) && ! usces_have_member_regular_order( $member['ID'] ) ) :
3984 ?>
3985 <tr>
3986 <td class="label"><input type="checkbox" name="zeus_pcid" id="zeus_pcid" value="delete"></td>
3987 <td><label for="zeus_pcid">QuickCharge を解除する</label></td>
3988 </tr>
3989 <?php
3990 endif;
3991 endif;
3992 endif;
3993 }
3994
3995 /**
3996 * 会員データ編集画面 カード�
3997 報登録解除
3998 * usces_action_post_update_memberdata
3999 *
4000 * @param int $member_id Member ID.
4001 * @param bool $res Member data update results.
4002 */
4003 public function admin_update_memberdata( $member_id, $res ) {
4004 global $usces;
4005
4006 if ( ! $this->is_activate_card() || false === $res ) {
4007 return;
4008 }
4009
4010 if ( 'delete' === filter_input( INPUT_POST, 'zeus_pcid' ) ) {
4011 $usces->del_member_meta( 'zeus_pcid', $member_id );
4012 $usces->del_member_meta( 'zeus_partofcard', $member_id );
4013 $usces->del_member_meta( 'zeus_limitofcard', $member_id );
4014 }
4015 }
4016
4017 /**
4018 * 支払方法説明
4019 * usces_filter_payment_detail
4020 *
4021 * @param string $str Payment method description.
4022 * @param array $entry Entry data.
4023 * @return string
4024 */
4025 public function payment_detail( $str, $entry ) {
4026 $acting_flg = $this->get_acting_flg( $entry['order']['payment_name'] );
4027
4028 switch ( $acting_flg ) {
4029 case 'acting_zeus_card':
4030 if ( ! isset( $entry['order']['cbrand'] ) || ( isset( $entry['order']['howpay'] ) && '1' == $entry['order']['howpay'] ) ) {
4031 $str = ' 一括払い';
4032 } else {
4033 $div_name = 'div_' . $entry['order']['cbrand'];
4034 switch ( $entry['order'][ $div_name ] ) {
4035 case '01':
4036 $str = ' 一括払い';
4037 break;
4038 case '02':
4039 $str = ' 分割(2回)';
4040 break;
4041 case '03':
4042 $str = ' 分割(3回)';
4043 break;
4044 case '05':
4045 $str = ' 分割(5回)';
4046 break;
4047 case '06':
4048 $str = ' 分割(6回)';
4049 break;
4050 case '10':
4051 $str = ' 分割(10回)';
4052 break;
4053 case '12':
4054 $str = ' 分割(12回)';
4055 break;
4056 case '15':
4057 $str = ' 分割(15回)';
4058 break;
4059 case '18':
4060 $str = ' 分割(18回)';
4061 break;
4062 case '20':
4063 $str = ' 分割(20回)';
4064 break;
4065 case '24':
4066 $str = ' 分割(24回)';
4067 break;
4068 case '99':
4069 $str = ' 分割(リボ払い)';
4070 break;
4071 case 'B1':
4072 $str = ' 分割(ボーナス一括払い)';
4073 break;
4074 }
4075 }
4076 break;
4077
4078 case 'acting_zeus_bank':
4079 $acting_opts = $this->get_acting_settings();
4080 if ( ! empty( $acting_opts['bank_expired_date'] ) ) {
4081 $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['bank_expired_date'] ) . __( ')', 'usces' );
4082 $str = apply_filters( 'usces_filter_zeus_payment_limit_bank', $payment_detail, $acting_opts['bank_expired_date'] );
4083 }
4084 break;
4085
4086 case 'acting_zeus_conv':
4087 if ( isset( $entry['order']['pay_cvs'] ) ) {
4088 $conv_name = usces_get_conv_name( $entry['order']['pay_cvs'] );
4089 $str = ( '' !== $conv_name ) ? __( '(', 'usces' ) . $conv_name . __( ')', 'usces' ) : '';
4090 }
4091 $acting_opts = $this->get_acting_settings();
4092 if ( ! empty( $acting_opts['conv_span'] ) ) {
4093 $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['conv_span'] ) . __( ')', 'usces' );
4094 $str .= apply_filters( 'usces_filter_zeus_payment_limit_conv', $payment_detail, $acting_opts['conv_span'] );
4095 }
4096 break;
4097 }
4098 return $str;
4099 }
4100
4101 /**
4102 * 携帯電話番号
4103 * usces_filter_custom_field_info
4104 *
4105 * @param string $html Custom field information.
4106 * @param array $entry Entry data.
4107 * @param string $custom_field Custom field.
4108 * @param string $position Position.
4109 * @return string
4110 */
4111 public function confirm_addition_bnpl( $html, $entry, $custom_field, $position ) {
4112 if ( 'order' === $custom_field ) {
4113 $acting_flg = $this->get_acting_flg( $entry['order']['payment_name'] );
4114 if ( 'acting_zeus_bnpl' === $acting_flg ) {
4115 $tel_mobile = ( isset( $_POST['tel_mobile'] ) ) ? filter_input( INPUT_POST, 'tel_mobile' ) : $entry['customer']['tel'];
4116 $html = '
4117 <tr>
4118 <th>携帯電話番号</th>
4119 <td>' . $tel_mobile . '</td>
4120 </tr>' . $html;
4121 }
4122 }
4123 return $html;
4124 }
4125
4126 /**
4127 * 支払方法 JavaScript 用決済名追加
4128 * usces_filter_payments_str
4129 *
4130 * @param string $payments_str Payments.
4131 * @param array $payment Selected payment.
4132 * @return string
4133 */
4134 public function payments_str( $payments_str, $payment ) {
4135 switch ( $payment['settlement'] ) {
4136 case 'acting_zeus_card':
4137 if ( $this->is_validity_acting( 'card' ) ) {
4138 $payments_str .= "'" . $payment['name'] . "': 'zeus', ";
4139 }
4140 break;
4141 case 'acting_zeus_bank':
4142 if ( $this->is_validity_acting( 'bank' ) ) {
4143 $payments_str .= "'" . $payment['name'] . "': 'zeus_bank', ";
4144 }
4145 break;
4146 case 'acting_zeus_conv':
4147 if ( $this->is_validity_acting( 'conv' ) ) {
4148 $payments_str .= "'" . $payment['name'] . "': 'zeus_conv', ";
4149 }
4150 break;
4151 case 'acting_zeus_bnpl':
4152 if ( $this->is_validity_acting( 'bnpl' ) ) {
4153 $payments_str .= "'" . $payment['name'] . "': 'zeus_bnpl', ";
4154 }
4155 break;
4156 }
4157 return $payments_str;
4158 }
4159
4160 /**
4161 * 支払方法 JavaScript 用決済追加
4162 * usces_filter_payments_arr
4163 *
4164 * @param array $payments_arr Payments.
4165 * @param array $payment Selected payment.
4166 * @return array
4167 */
4168 public function payments_arr( $payments_arr, $payment ) {
4169 switch ( $payment['settlement'] ) {
4170 case 'acting_zeus_card':
4171 if ( $this->is_validity_acting( 'card' ) ) {
4172 $payments_arr[] = 'zeus';
4173 }
4174 break;
4175 case 'acting_zeus_bank':
4176 if ( $this->is_validity_acting( 'bank' ) ) {
4177 $payments_arr[] = 'zeus_bank';
4178 }
4179 break;
4180 case 'acting_zeus_conv':
4181 if ( $this->is_validity_acting( 'conv' ) ) {
4182 $payments_arr[] = 'zeus_conv';
4183 }
4184 break;
4185 case 'acting_zeus_bnpl':
4186 if ( $this->is_validity_acting( 'bnpl' ) ) {
4187 $payments_arr[] = 'zeus_bnpl';
4188 }
4189 break;
4190 }
4191 return $payments_arr;
4192 }
4193
4194 /**
4195 * カード�
4196 報�
4197 �力チェック
4198 * usces_filter_delivery_check
4199 *
4200 * @param string $mes Validation check message.
4201 * @return string
4202 */
4203 public function delivery_check( $mes ) {
4204 if ( ! isset( $_POST['offer']['payment_name'] ) ) {
4205 return $mes;
4206 }
4207
4208 if ( ! empty( $mes ) ) {
4209 return $mes;
4210 }
4211
4212 $acting_flg = $this->get_acting_flg( $_POST['offer']['payment_name'] );
4213
4214 switch ( $acting_flg ) {
4215 case 'acting_zeus_card':
4216 if ( isset( $_POST['acting'] ) && 'zeus' !== filter_input( INPUT_POST, 'acting' ) ) {
4217 $mes .= 'カード決済データが不正です!';
4218 } elseif ( empty( $_POST['zeus_card_option'] ) || ( 'new' === filter_input( INPUT_POST, 'zeus_card_option' ) && empty( $_POST['zeus_token_value'] ) ) ) {
4219 $mes .= 'カード決済データが不正です!';
4220 } elseif ( ! empty( $_POST['zeus_token_value'] ) ) {
4221 if ( ! wel_check_credit_security() ) {
4222 $mes .= __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '<br />';
4223 }
4224 }
4225 break;
4226
4227 case 'acting_zeus_bank':
4228 if ( WCUtils::is_blank( $_POST['username_bank'] ) ) {
4229 $mes .= 'お振込名義を�
4230 �力してください。<br />';
4231 } elseif ( ! preg_match( '/^[ァ-ヶー]+$/u', filter_input( INPUT_POST, 'username_bank' ) ) ) {
4232 $mes .= 'お振込名義は�
4233 �角カタカナで�
4234 �力してください。<br />';
4235 }
4236 break;
4237
4238 case 'acting_zeus_conv':
4239 if ( WCUtils::is_blank( $_POST['username_conv'] ) ) {
4240 $mes .= 'お名前を�
4241 �力してください。<br />';
4242 } elseif ( ! preg_match( '/^[ァ-ヶー]+$/u', filter_input( INPUT_POST, 'username_conv' ) ) ) {
4243 $mes .= 'お名前は�
4244 �角カタカナで�
4245 �力してください。<br />';
4246 }
4247 break;
4248
4249 case 'acting_zeus_bnpl':
4250 if ( WCUtils::is_blank( $_POST['tel_mobile'] ) ) {
4251 $mes .= '携帯電話番号を�
4252 �力してください。<br />';
4253 } else {
4254 $tel_mobile = filter_input( INPUT_POST, 'tel_mobile' );
4255 if ( ! preg_match( '/^[0-9-]+$/', $tel_mobile ) ) {
4256 $mes .= '携帯電話番号は半角数値で�
4257 �力してください。<br />';
4258 } else {
4259 $cleannumber = preg_replace( '/[-\s]/', '', $tel_mobile );
4260 if ( '0' !== substr( $cleannumber, 0, 1 ) ) {
4261 $mes .= '携帯電話番号を�
4262 �力してください。<br />';
4263 } elseif ( strlen( $cleannumber ) < 8 || 15 < strlen( $cleannumber ) ) {
4264 $mes .= '携帯電話番号が不正です!<br />';
4265 }
4266 }
4267 }
4268 break;
4269 }
4270 return $mes;
4271 }
4272
4273 /**
4274 * 支払方法ページ用�
4275 �力フォーム
4276 * usces_filter_delivery_secure_form_loop
4277 *
4278 * @param string $nouse Empty.
4279 * @param array $payment Payment data.
4280 * @return string
4281 */
4282 public function delivery_secure_form_loop( $nouse, $payment ) {
4283 global $usces;
4284
4285 $form = '';
4286
4287 switch ( $payment['settlement'] ) {
4288 case 'acting_zeus_card':
4289 $acting_opts = $this->get_acting_settings();
4290 if ( ( ! isset( $acting_opts['activate'] ) || 'on' !== $acting_opts['activate'] ) ||
4291 ( ! isset( $acting_opts['card_activate'] ) || 'on' !== $acting_opts['card_activate'] ) ||
4292 'activate' !== $payment['use'] ) {
4293 return $form;
4294 }
4295
4296 $form = '<input type="hidden" name="acting" value="' . $this->paymod_id . '">';
4297 $form .= '<table class="customer_form" id="' . $this->paymod_id . '">';
4298 $form .= '<tr><th scope="row">クレジットカード�
4299 </th><td id="zeus_token_card_info_area"></td></tr>';
4300
4301 $howpay = ( isset( $_POST['howpay'] ) ) ? filter_input( INPUT_POST, 'howpay' ) : '1';
4302 $cbrand = ( isset( $_POST['cbrand'] ) ) ? filter_input( INPUT_POST, 'cbrand' ) : '';
4303 $div = ( isset( $_POST['div'] ) ) ? filter_input( INPUT_POST, 'div' ) : '';
4304
4305 $form_howpay = '';
4306 $member_page = ( isset( $_GET['usces_page'] ) && 'member_update_settlement' === filter_input( INPUT_GET, 'usces_page' ) ) ? true : false;
4307 if ( 'on' === $acting_opts['howpay'] && ! $member_page ) {
4308 $howpay_b1 = ( 'on' === $acting_opts['howpay_B1'] ) ? '</option><option value="B1"' . selected( $div, 'B1', false ) . '>' . __( 'Bonus lump-sum payment', 'usces' ) : '';
4309 $howpay_02 = ( 'on' === $acting_opts['howpay_02'] ) ? '</option><option value="02"' . selected( $div, '02', false ) . '>2' . __( '-time payment', 'usces' ) : '';
4310 $form_howpay .= '
4311 <tr>
4312 <th scope="row">' . __( 'payment method', 'usces' ) . '</th>
4313 <td>
4314 <input name="offer[howpay]" type="radio" value="1" id="howdiv1"' . checked( $howpay, '1', false ) . ' /><label for="howdiv1">' . __( 'Single payment', 'usces' ) . '</label>&nbsp;&nbsp;&nbsp;
4315 <input name="offer[howpay]" type="radio" value="0" id="howdiv2"' . checked( $howpay, '0', false ) . ' /><label for="howdiv2">' . __( 'Payment in installments', 'usces' ) . '</label>
4316 </td>
4317 </tr>
4318 <tr id="cbrand_zeus">
4319 <th scope="row">' . __( 'Card brand', 'usces' ) . '</th>
4320 <td>
4321 <select name="offer[cbrand]" id="cbrand">
4322 <option value=""' . selected( WCUtils::is_blank( $cbrand ), true, false ) . '>--------</option>
4323 <option value="1"' . selected( $cbrand, '1', false ) . '>JCB</option>
4324 <option value="1"' . selected( $cbrand, '1', false ) . '>VISA</option>
4325 <option value="1"' . selected( $cbrand, '1', false ) . '>MASTER</option>
4326 <option value="2"' . selected( $cbrand, '2', false ) . '>DINERS</option>
4327 <option value="3"' . selected( $cbrand, '3', false ) . '>AMEX</option>
4328 </select>
4329 </td>
4330 </tr>
4331 <tr id="div_zeus">
4332 <th scope="row">' . __( 'Number of payments', 'usces' ) . '</th>
4333 <td>
4334 <select name="offer[div_1]" id="brand1">
4335 <option value="01"' . selected( $div, '01', false ) . '>' . __( 'Single payment', 'usces' ) . $howpay_02 . '</option>
4336 <option value="03"' . selected( $div, '03', false ) . '>3' . __( '-time payment', 'usces' ) . '</option>
4337 <option value="05"' . selected( $div, '05', false ) . '>5' . __( '-time payment', 'usces' ) . '</option>
4338 <option value="06"' . selected( $div, '06', false ) . '>6' . __( '-time payment', 'usces' ) . '</option>
4339 <option value="10"' . selected( $div, '10', false ) . '>10' . __( '-time payment', 'usces' ) . '</option>
4340 <option value="12"' . selected( $div, '12', false ) . '>12' . __( '-time payment', 'usces' ) . '</option>
4341 <option value="15"' . selected( $div, '15', false ) . '>15' . __( '-time payment', 'usces' ) . '</option>
4342 <option value="18"' . selected( $div, '18', false ) . '>18' . __( '-time payment', 'usces' ) . '</option>
4343 <option value="20"' . selected( $div, '20', false ) . '>20' . __( '-time payment', 'usces' ) . '</option>
4344 <option value="24"' . selected( $div, '24', false ) . '>24' . __( '-time payment', 'usces' ) . '</option>
4345 <option value="99"' . selected( $div, '99', false ) . '>' . __( 'Libor Funding pay', 'usces' ) . $howpay_b1 . '</option>
4346 </select>
4347 <select name="offer[div_2]" id="brand2">
4348 <option value="01"' . selected( $div, '01', false ) . '>' . __( 'Single payment', 'usces' ) . '</option>
4349 <option value="99"' . selected( $div, '99', false ) . '>' . __( 'Libor Funding pay', 'usces' ) . $howpay_b1 . '</option>
4350 </select>
4351 <select name="offer[div_3]" id="brand3">
4352 <option value="01"' . selected( $div, '01', false ) . '>' . __( 'Single payment', 'usces' ) . '</option>
4353 <option value="03"' . selected( $div, '03', false ) . '>3' . __( '-time payment', 'usces' ) . '</option>
4354 <option value="05"' . selected( $div, '05', false ) . '>5' . __( '-time payment', 'usces' ) . '</option>
4355 <option value="06"' . selected( $div, '06', false ) . '>6' . __( '-time payment', 'usces' ) . '</option>
4356 <option value="10"' . selected( $div, '10', false ) . '>10' . __( '-time payment', 'usces' ) . '</option>
4357 <option value="12"' . selected( $div, '12', false ) . '>12' . __( '-time payment', 'usces' ) . '</option>
4358 <option value="15"' . selected( $div, '15', false ) . '>15' . __( '-time payment', 'usces' ) . '</option>
4359 <option value="18"' . selected( $div, '18', false ) . '>18' . __( '-time payment', 'usces' ) . '</option>
4360 <option value="20"' . selected( $div, '20', false ) . '>20' . __( '-time payment', 'usces' ) . '</option>
4361 <option value="24"' . selected( $div, '24', false ) . '>24' . __( '-time payment', 'usces' ) . '</option>
4362 <option value="99"' . selected( $div, '99', false ) . '>' . __( 'Libor Funding pay', 'usces' ) . $howpay_b1 . '</option>
4363 </select>
4364 </td>
4365 </tr>
4366 </table>';
4367 }
4368 $form .= apply_filters( 'usces_filter_delivery_secure_form_howpay', $form_howpay );
4369 break;
4370
4371 case 'acting_zeus_bank':
4372 $acting_opts = $this->get_acting_settings();
4373 if ( ( ! isset( $acting_opts['activate'] ) || 'on' !== $acting_opts['activate'] ) ||
4374 ( ! isset( $acting_opts['bank_activate'] ) || 'on' !== $acting_opts['bank_activate'] ) ||
4375 'activate' !== $payment['use'] ) {
4376 return $form;
4377 }
4378
4379 $entry = $usces->cart->get_entry();
4380 $username = ( isset( $_POST['username_bank'] ) ) ? filter_input( INPUT_POST, 'username_bank' ) : $entry['customer']['name3'] . $entry['customer']['name4'];
4381
4382 $form = '
4383 <table class="customer_form" id="' . $this->paymod_id . '_bank">
4384 <tr>
4385 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>お振込名義</th>
4386 <td colspan="2"><input name="username_bank" id="username_bank" type="text" size="30" value="' . esc_attr( $username ) . '" />' . __( '(full-width Kana)', 'usces' ) . '</td>
4387 </tr>
4388 </table>';
4389 break;
4390
4391 case 'acting_zeus_conv':
4392 $acting_opts = $this->get_acting_settings();
4393 if ( ( ! isset( $acting_opts['activate'] ) || 'on' !== $acting_opts['activate'] ) ||
4394 ( ! isset( $acting_opts['conv_activate'] ) || 'on' !== $acting_opts['conv_activate'] ) ||
4395 'activate' !== $payment['use'] ) {
4396 return $form;
4397 }
4398
4399 $pay_cvs = ( isset( $_POST['pay_cvs'] ) ) ? filter_input( INPUT_POST, 'pay_cvs' ) : '';
4400 $entry = $usces->cart->get_entry();
4401 $username = ( isset( $_POST['username_conv'] ) ) ? filter_input( INPUT_POST, 'username_conv' ) : $entry['customer']['name3'] . $entry['customer']['name4'];
4402
4403 $form = '
4404 <table class="customer_form" id="' . $this->paymod_id . '_conv">
4405 <tr>
4406 <th scope="row">' . __( 'Convenience store for payment', 'usces' ) . '</th>
4407 <td colspan="2">
4408 <select name="offer[pay_cvs]" id="pay_cvs_zeus">';
4409 foreach ( (array) $acting_opts['pay_cvs'] as $pay_cvs_code ) {
4410 if ( 'D040' === $pay_cvs_code ) {
4411 continue;
4412 }
4413 $form .= '
4414 <option value="' . $pay_cvs_code . '"' . selected( $pay_cvs_code, $pay_cvs, false ) . '>' . usces_get_conv_name( $pay_cvs_code ) . '</option>';
4415 }
4416 $form .= '
4417 </select>
4418 </td>
4419 </tr>
4420 <tr>
4421 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>' . __( 'Full name', 'usces' ) . '</th>
4422 <td colspan="2"><input name="username_conv" id="username_conv" type="text" size="30" value="' . esc_attr( $username ) . '" />' . __( '(full-width Kana)', 'usces' ) . '</td>
4423 </tr>
4424 </table>';
4425 break;
4426
4427 case 'acting_zeus_bnpl':
4428 $acting_opts = $this->get_acting_settings();
4429 if ( ( ! isset( $acting_opts['activate'] ) || 'on' !== $acting_opts['activate'] ) ||
4430 ( ! isset( $acting_opts['bnpl_activate'] ) || 'on' !== $acting_opts['bnpl_activate'] ) ||
4431 'activate' !== $payment['use'] ) {
4432 return $form;
4433 }
4434
4435 $entry = $usces->cart->get_entry();
4436 $tel_mobile = ( isset( $_POST['tel_mobile'] ) ) ? filter_input( INPUT_POST, 'tel_mobile' ) : $entry['customer']['tel'];
4437
4438 $form = '
4439 <table class="customer_form" id="' . $this->paymod_id . '_bnpl">
4440 <tr>
4441 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>携帯電話番号</th>
4442 <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>
4443 </tr>
4444 </table>';
4445 break;
4446 }
4447
4448 return $form;
4449 }
4450
4451 /**
4452 * �
4453 容確認ページ [注文する] ボタン
4454 * usces_filter_confirm_inform
4455 *
4456 * @param string $form Purchase post form.
4457 * @param array $payments Payment data.
4458 * @param string $acting_flg Payment type.
4459 * @param string $rand Welcart transaction key.
4460 * @param string $purchase_disabled Disable purchase button.
4461 * @return string
4462 */
4463 public function confirm_inform( $form, $payments, $acting_flg, $rand, $purchase_disabled ) {
4464 global $usces;
4465
4466 if ( ! in_array( $acting_flg, $this->pay_method, true ) ) {
4467 return $form;
4468 }
4469
4470 $entry = $usces->cart->get_entry();
4471 if ( ! $entry['order']['total_full_price'] ) {
4472 return $form;
4473 }
4474
4475 switch ( $acting_flg ) {
4476 case 'acting_zeus_card':
4477 $acting_opts = $this->get_acting_settings();
4478 $usces->save_order_acting_data( $rand );
4479 usces_save_order_acting_data( $rand );
4480 $mem_id = '';
4481 if ( $usces->is_member_logged_in() ) {
4482 $member = $usces->get_member();
4483 $mem_id = $member['ID'];
4484 }
4485 $zeus_card_option = ( isset( $_POST['zeus_card_option'] ) ) ? filter_input( INPUT_POST, 'zeus_card_option' ) : '';
4486 $zeus_token_value = ( isset( $_POST['zeus_token_value'] ) ) ? filter_input( INPUT_POST, 'zeus_token_value' ) : '';
4487 $zeus_card_name = ( isset( $_POST['zeus_token_return_card_name'] ) ) ? filter_input( INPUT_POST, 'zeus_token_return_card_name' ) : '';
4488 $form = '';
4489 if ( $this->is_activate_card( 'api' ) && 1 === (int) $acting_opts['3dsecur'] ) {
4490 $form .= '<div id="3dscontainer"></div>';
4491 }
4492 $amount = apply_filters( 'zeus_secure_payreq_amount', usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ), $entry );
4493
4494 $form .= '<form name="purchase_form" id="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}">
4495 <input type="hidden" name="card_option" id="card_option" value="' . esc_attr( $zeus_card_option ) . '">
4496 <input type="hidden" name="token_key" id="token_key" value="' . esc_attr( $zeus_token_value ) . '">
4497 <input type="hidden" name="money" value="' . $amount . '">
4498 <input type="hidden" name="telno" value="' . esc_attr( str_replace( '-', '', $entry['customer']['tel'] ) ) . '">
4499 <input type="hidden" name="email" value="' . esc_attr( $entry['customer']['mailaddress1'] ) . '">
4500 <input type="hidden" name="card_name" id="card_name" value="' . esc_attr( $zeus_card_name ) . '">
4501 <input type="hidden" name="sendid" id="sendid" value="' . $mem_id . '">
4502 <input type="hidden" name="sendpoint" id="sendpoint" value="' . $rand . '">';
4503 if ( isset( $entry['order']['cbrand'] ) && isset( $entry['order']['howpay'] ) && WCUtils::is_zero( $entry['order']['howpay'] ) ) {
4504 $div_name = 'div_' . esc_attr( $entry['order']['cbrand'] );
4505 $form .= '<input type="hidden" name="howpay" value="' . esc_attr( $entry['order']['howpay'] ) . '">
4506 <input type="hidden" name="cbrand" value="' . esc_attr( $entry['order']['cbrand'] ) . '">
4507 <input type="hidden" name="div" value="' . esc_attr( $entry['order'][ $div_name ] ) . '">
4508 <input type="hidden" name="div_1" value="' . esc_attr( $entry['order']['div_1'] ) . '">
4509 <input type="hidden" name="div_2" value="' . esc_attr( $entry['order']['div_2'] ) . '">
4510 <input type="hidden" name="div_3" value="' . esc_attr( $entry['order']['div_3'] ) . '">';
4511 }
4512 $form .= '<div class="send">';
4513 if ( $this->is_activate_card( 'api' ) && 1 === (int) $acting_opts['3dsecur'] ) {
4514 $form .= '<div id="zeus-loading" style="display:none"><div id="welcart-loading-text">' . __( 'Processing...', 'usces' ) . '</div></div>';
4515 }
4516 $form .= apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4517 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4518 <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>
4519 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4520 break;
4521
4522 case 'acting_zeus_conv':
4523 $member = $usces->get_member();
4524 $acting_opts = $this->get_acting_settings();
4525 $usces->save_order_acting_data( $rand );
4526 usces_save_order_acting_data( $rand );
4527 $pay_cvs = ( isset( $entry['order']['pay_cvs'] ) ) ? $entry['order']['pay_cvs'] : '';
4528 $username_conv = ( isset( $_POST['username_conv'] ) ) ? filter_input( INPUT_POST, 'username_conv' ) : '';
4529 $form = '<form id="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}">
4530 <input type="hidden" name="act" value="secure_order">
4531 <input type="hidden" name="money" value="' . usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ) . '">
4532 <input type="hidden" name="username" value="' . esc_attr( $username_conv ) . '">
4533 <input type="hidden" name="telno" value="' . esc_attr( str_replace( '-', '', $entry['customer']['tel'] ) ) . '">
4534 <input type="hidden" name="email" value="' . esc_attr( $entry['customer']['mailaddress1'] ) . '">
4535 <input type="hidden" name="pay_cvs" value="' . esc_attr( $pay_cvs ) . '">
4536 <input type="hidden" name="sendid" value="' . $member['ID'] . '">
4537 <input type="hidden" name="sendpoint" value="' . $rand . '">';
4538 $form .= '
4539 <div class="send">
4540 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4541 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4542 <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>
4543 <input type="hidden" name="username_conv" value="' . esc_attr( $username_conv ) . '">
4544 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4545 break;
4546
4547 case 'acting_zeus_bank':
4548 $member = $usces->get_member();
4549 $acting_opts = $this->get_acting_settings();
4550 $usces->save_order_acting_data( $rand );
4551 usces_save_order_acting_data( $rand );
4552 $username_bank = ( isset( $_POST['username_bank'] ) ) ? filter_input( INPUT_POST, 'username_bank' ) : '';
4553 $form = '<form id="purchase_form" action="' . $acting_opts['bank_url'] . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}" accept-charset="Shift_JIS">
4554 <input type="hidden" name="clientip" value="' . esc_attr( $acting_opts['clientip_bank'] ) . '">
4555 <input type="hidden" name="act" value="order">
4556 <input type="hidden" name="money" value="' . usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ) . '">';
4557 if ( isset( $acting_opts['bank_ope'] ) && 'test' === $acting_opts['bank_ope'] ) {
4558 $form .= '<input type="hidden" name="username" value="' . esc_attr( trim( $username_bank ) . '_' . $acting_opts['testid_bank'] ) . '">';
4559 $form .= '<input type="hidden" name="telno" value="99999999999">';
4560 } else {
4561 $form .= '<input type="hidden" name="username" value="' . esc_attr( trim( $username_bank ) ) . '">';
4562 $form .= '<input type="hidden" name="telno" value="' . esc_attr( str_replace( '-', '', $entry['customer']['tel'] ) ) . '">';
4563 }
4564 if ( ! empty( $acting_opts['bank_expired_date'] ) ) {
4565 $form .= '<input type="hidden" name="expired_date" value="' . esc_attr( $acting_opts['bank_expired_date'] ) . '">';
4566 $form .= '<input type="hidden" name="expired_date_of_user" value="' . esc_attr( $acting_opts['bank_expired_date'] ) . '">';
4567 }
4568 $form .= '<input type="hidden" name="email" value="' . esc_attr( $entry['customer']['mailaddress1'] ) . '">
4569 <input type="hidden" name="sendid" value="' . $member['ID'] . '">
4570 <input type="hidden" name="sendpoint" value="' . $rand . '">
4571 <input type="hidden" name="siteurl" value="' . esc_url( get_option( 'home' ) ) . '/?backfrom_zeus_bank=1">
4572 <input type="hidden" name="sitestr" value="「' . esc_attr( get_option( 'blogname' ) ) . '」トップページへ">';
4573 $form .= '<input type="hidden" name="dummy" value="&#65533;" />';
4574 $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>';
4575 $form .= '</form>';
4576 $form .= '<form action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}">
4577 <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>
4578 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4579 break;
4580
4581 case 'acting_zeus_bnpl':
4582 $member = $usces->get_member();
4583 $acting_opts = $this->get_acting_settings();
4584 $usces->save_order_acting_data( $rand );
4585 usces_save_order_acting_data( $rand );
4586 $tel_mobile = ( isset( $_POST['tel_mobile'] ) ) ? filter_input( INPUT_POST, 'tel_mobile' ) : '';
4587 $form = '<form id="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}">
4588 <input type="hidden" name="money" value="' . usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ) . '">
4589 <input type="hidden" name="tel_mobile" value="' . esc_attr( $tel_mobile ) . '">
4590 <input type="hidden" name="sendpoint" value="' . $rand . '">';
4591 $form .= '
4592 <div class="send">
4593 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4594 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4595 <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>
4596 <input type="hidden" name="tel_mobile" value="' . esc_attr( $tel_mobile ) . '">
4597 <input type="hidden" id="fraudbuster" name="fraudbuster" />
4598 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4599 break;
4600 }
4601 return $form;
4602 }
4603
4604 /**
4605 * �
4606 容確認ページ ポイントフォーム
4607 * usces_action_confirm_page_point_inform
4608 */
4609 public function e_point_inform() {
4610 $form = $this->point_inform( '' );
4611 wel_esc_script_e( $form );
4612 }
4613
4614 /**
4615 * �
4616 容確認ページ ポイントフォーム
4617 * usces_filter_confirm_point_inform
4618 *
4619 * @param string $form Input point form.
4620 * @return string
4621 */
4622 public function point_inform( $form ) {
4623 global $usces;
4624
4625 $entry = $usces->cart->get_entry();
4626 $acting_flg = $this->get_acting_flg( $entry['order']['payment_name'] );
4627
4628 switch ( $acting_flg ) {
4629 case 'acting_zeus_card':
4630 $acting_opts = $this->get_acting_settings();
4631 if ( isset( $_POST['zeus_card_option'] ) ) {
4632 $form .= '<input type="hidden" name="zeus_card_option" value="' . esc_attr( filter_input( INPUT_POST, 'zeus_card_option' ) ) . '">';
4633 }
4634 if ( isset( $_POST['zeus_card_option'] ) && 'new' === filter_input( INPUT_POST, 'zeus_card_option' ) ) {
4635 $form .= '<input type="hidden" name="zeus_token_value" value="' . esc_attr( filter_input( INPUT_POST, 'zeus_token_value' ) ) . '">';
4636 $form .= '<input type="hidden" name="zeus_token_return_card_name" value="' . esc_attr( filter_input( INPUT_POST, 'zeus_token_return_card_name' ) ) . '">';
4637 }
4638 break;
4639
4640 case 'acting_zeus_bank':
4641 if ( isset( $_POST['username_bank'] ) ) {
4642 $form .= '<input type="hidden" name="username_bank" value="' . esc_attr( filter_input( INPUT_POST, 'username_bank' ) ) . '">';
4643 }
4644 break;
4645
4646 case 'acting_zeus_conv':
4647 if ( isset( $entry['order']['pay_cvs'] ) ) {
4648 $form .= '<input type="hidden" name="offer[pay_cvs]" value="' . esc_attr( $entry['order']['pay_cvs'] ) . '">';
4649 }
4650 if ( isset( $_POST['username_conv'] ) ) {
4651 $form .= '<input type="hidden" name="username_conv" value="' . esc_attr( filter_input( INPUT_POST, 'username_conv' ) ) . '">';
4652 }
4653 break;
4654
4655 case 'acting_zeus_bnpl':
4656 if ( isset( $_POST['tel_mobile'] ) ) {
4657 $form .= '<input type="hidden" name="tel_mobile" value="' . esc_attr( filter_input( INPUT_POST, 'tel_mobile' ) ) . '">';
4658 }
4659 break;
4660 }
4661 return $form;
4662 }
4663
4664 /**
4665 * Scripts.
4666 * wp_enqueue_scripts
4667 */
4668 public function enqueue_scripts() {
4669 global $usces;
4670
4671 /* �
4672 容確認ページ */
4673 if ( ! is_admin() && 'confirm' === $usces->page && $this->is_validity_acting( 'bnpl' ) ) :
4674 $entry = $usces->cart->get_entry();
4675 $acting_flg = $this->get_acting_flg( $entry['order']['payment_name'] );
4676 if ( 'acting_zeus_bnpl' === $acting_flg ) :
4677 ?>
4678 <script type="text/javascript" src="//fraud-buster.appspot.com/js/fraudbuster.js" ></script>
4679 <?php
4680 endif;
4681 endif;
4682 }
4683
4684 /**
4685 * 支払方法
4686 * usces_fiter_the_payment_method
4687 *
4688 * @param array $payments Payments.
4689 * @return array
4690 */
4691 public function payment_method( $payments ) {
4692 global $usces;
4693
4694 $bnpl_exclusion = false;
4695 $cart = $usces->cart->get_cart();
4696 foreach ( (array) $cart as $cart_row ) {
4697 if ( 'shipped' !== $usces->getItemDivision( $cart_row['post_id'] ) ) {
4698 $bnpl_exclusion = true;
4699 break;
4700 }
4701 }
4702 if ( ! $bnpl_exclusion ) {
4703 if ( usces_have_regular_order() ) {
4704 $bnpl_exclusion = true;
4705 } elseif ( usces_have_continue_charge() ) {
4706 $bnpl_exclusion = true;
4707 }
4708 }
4709
4710 if ( $bnpl_exclusion ) {
4711 foreach ( $payments as $key => $payment ) {
4712 if ( 'acting_zeus_bnpl' === $payment['settlement'] ) {
4713 unset( $payments[ $key ] );
4714 }
4715 }
4716 }
4717
4718 return $payments;
4719 }
4720
4721 /**
4722 * 手数料ラベル
4723 * usces_filter_cod_label
4724 *
4725 * @param string $label Fee label.
4726 * @return string
4727 */
4728 public function set_fee_label( $label ) {
4729 global $usces;
4730
4731 if ( is_admin() ) {
4732 $order_id = ( isset( $_REQUEST['order_id'] ) ) ? wp_unslash( $_REQUEST['order_id'] ) : '';
4733 if ( ! empty( $order_id ) ) {
4734 $payment_name = $this->get_order_payment_name( $order_id );
4735 $payment = usces_get_payments_by_name( $payment_name );
4736 if ( 'acting_zeus_bnpl' === $payment['settlement'] ) {
4737 $label = $payment['name'] . __( 'Fee', 'usces' );
4738 }
4739 }
4740 } else {
4741 $entry = $usces->cart->get_entry();
4742 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
4743 if ( 'acting_zeus_bnpl' === $payment['settlement'] ) {
4744 $label = $payment['name'] . __( 'Fee', 'usces' );
4745 }
4746 }
4747 return $label;
4748 }
4749
4750 /**
4751 * 手数料ラベル
4752 * usces_filter_member_history_cod_label
4753 *
4754 * @param string $label Fee label.
4755 * @param int $order_id Order number.
4756 * @return string
4757 */
4758 public function set_member_history_fee_label( $label, $order_id ) {
4759 $payment_name = $this->get_order_payment_name( $order_id );
4760 $payment = usces_get_payments_by_name( $payment_name );
4761 if ( 'acting_zeus_bnpl' === $payment['settlement'] ) {
4762 $label = $payment['name'] . __( 'Fee', 'usces' );
4763 }
4764 return $label;
4765 }
4766
4767 /**
4768 * 決済手数料
4769 * usces_filter_set_cart_fees_cod
4770 *
4771 * @param float $cod_fee COD fee.
4772 * @param array $usces_entries Entry data.
4773 * @param float $total_items_price Total amount of items.
4774 * @param int $use_point Use point.
4775 * @param float $discount Discount.
4776 * @param float $shipping_charge Shipping charge.
4777 * @param float $amount_by_cod COD.
4778 * @return float
4779 */
4780 public function add_fee( $cod_fee, $usces_entries, $total_items_price, $use_point, $discount, $shipping_charge, $amount_by_cod ) {
4781 global $usces;
4782
4783 $payment = usces_get_payments_by_name( $usces_entries['order']['payment_name'] );
4784 if ( 'acting_zeus_bnpl' !== $payment['settlement'] ) {
4785 return $cod_fee;
4786 }
4787
4788 $acting_opts = $this->get_acting_settings();
4789 $acting = explode( '_', $payment['settlement'] );
4790 $fee = 0;
4791 if ( ! empty( $acting_opts[ $acting[2] . '_fee_type' ] ) ) {
4792 if ( 'fix' === $acting_opts[ $acting[2] . '_fee_type' ] ) {
4793 $fee = (int) $acting_opts[ $acting[2] . '_fee' ];
4794 } else {
4795 $materials = array(
4796 'total_items_price' => $total_items_price,
4797 'discount' => $discount,
4798 'shipping_charge' => $shipping_charge,
4799 'cod_fee' => $cod_fee,
4800 'use_point' => $use_point,
4801 );
4802 $amount_by_fee = $total_items_price - $use_point + $discount;
4803 if ( 'all' === usces_is_fee_subject() ) {
4804 $amount_by_fee += $shipping_charge;
4805 }
4806 $price = $amount_by_fee + $usces->getTax( $amount_by_fee, $materials );
4807 if ( $price <= (int) $acting_opts[ $acting[2] . '_fee_first_amount' ] ) {
4808 $fee = $acting_opts[ $acting[2] . '_fee_first_fee' ];
4809 } elseif ( isset( $acting_opts[ $acting[2] . '_fee_amounts' ] ) && ! empty( $acting_opts[ $acting[2] . '_fee_amounts' ] ) ) {
4810 $last = count( $acting_opts[ $acting[2] . '_fee_amounts' ] ) - 1;
4811 if ( $price > $acting_opts[ $acting[2] . '_fee_amounts' ][ $last ] ) {
4812 $fee = $acting_opts[ $acting[2] . '_fee_end_fee' ];
4813 } else {
4814 foreach ( $acting_opts[ $acting[2] . '_fee_amounts' ] as $key => $value ) {
4815 if ( $price <= $value ) {
4816 $fee = $acting_opts[ $acting[2] . '_fee_fees' ][ $key ];
4817 break;
4818 }
4819 }
4820 }
4821 } else {
4822 $fee = $acting_opts[ $acting[2] . '_fee_end_fee' ];
4823 }
4824 }
4825 }
4826 return $cod_fee + $fee;
4827 }
4828
4829 /**
4830 * 決済手数料チェック
4831 * usces_filter_delivery_check usces_filter_point_check_last
4832 *
4833 * @param string $mes Message.
4834 * @return string
4835 */
4836 public function check_fee_limit( $mes ) {
4837 global $usces;
4838
4839 $member = $usces->get_member();
4840 $usces->set_cart_fees( $member, array() );
4841 $entry = $usces->cart->get_entry();
4842 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
4843 if ( 'acting_zeus_bnpl' !== $payment['settlement'] ) {
4844 return $mes;
4845 }
4846
4847 if ( 2 === (int) $entry['delivery']['delivery_flag'] ) {
4848 $mes .= sprintf( __( "If you specify multiple shipping address, you cannot use '%s' payment method.", 'usces' ), $entry['order']['payment_name'] );
4849 return $mes;
4850 }
4851
4852 $acting_opts = $this->get_acting_settings();
4853 $fee_limit_amount = 0;
4854 if ( ! empty( $acting_opts['bnpl_fee_limit_amount'] ) ) {
4855 $fee_limit_amount = (int) $acting_opts['bnpl_fee_limit_amount'];
4856 }
4857
4858 if ( 0 < $fee_limit_amount && $entry['order']['total_full_price'] > $fee_limit_amount ) {
4859 $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 ) );
4860 }
4861
4862 return $mes;
4863 }
4864
4865 /**
4866 * セッション復帰処理
4867 * usces_pre_purchase
4868 */
4869 public function pre_purchase() {
4870 global $usces;
4871
4872 $cart = $usces->cart->get_cart();
4873 if ( empty( $cart ) ) {
4874 $tracking_id = filter_input( INPUT_GET, 'sendpoint' );
4875 if ( ! empty( $tracking_id ) ) {
4876 usces_restore_order_acting_data( $tracking_id );
4877 }
4878 }
4879 }
4880
4881 /**
4882 * 決済処理
4883 * usces_action_acting_processing
4884 *
4885 * @param string $acting_flg Payment type.
4886 * @param array $post_query Post data.
4887 */
4888 public function acting_processing( $acting_flg, $post_query ) {
4889 global $usces;
4890
4891 if ( ! in_array( $acting_flg, $this->pay_method, true ) ) {
4892 return;
4893 }
4894
4895 $cart = $usces->cart->get_cart();
4896
4897 if ( empty( $cart ) ) {
4898 if ( isset( $_REQUEST['sendpoint'] ) ) {
4899 usces_restore_order_acting_data( wp_unslash( $_REQUEST['sendpoint'] ) );
4900 $cart = $usces->cart->get_cart();
4901 if ( empty( $cart ) ) {
4902 wp_redirect( USCES_CART_URL );
4903 }
4904 } else {
4905 wp_redirect( USCES_CART_URL );
4906 }
4907 } else {
4908 if ( ! wp_verify_nonce( $_REQUEST['_nonce'], $acting_flg ) ) {
4909 wp_redirect( USCES_CART_URL );
4910 }
4911 }
4912
4913 $usces->error_message = $usces->zaiko_check();
4914 if ( '' !== $usces->error_message || 0 === $usces->cart->num_row() ) {
4915 wp_redirect( USCES_CART_URL );
4916 exit();
4917 }
4918
4919 $acting_opts = $this->get_acting_settings();
4920 parse_str( $post_query, $post_data );
4921
4922 /* Secure API */
4923 if ( 'acting_zeus_card' === $acting_flg && 2 === (int) $acting_opts['connection'] ) {
4924
4925 /* 3D Secure */
4926 if ( 1 === (int) $acting_opts['3dsecur'] && ! isset( $post_data['outside'] ) ) {
4927 /* Auth Reqest */
4928 $this->zeus_3dsecure_auth();
4929 } else {
4930 $res = $this->zeus_secure_payreq();
4931 return $res;
4932 }
4933
4934 /* Secure Link */
4935 } elseif ( 'acting_zeus_card' === $acting_flg && 1 === (int) $acting_opts['connection'] ) {
4936
4937 $sendid = ( 'on' === $acting_opts['quickcharge'] && $usces->is_member_logged_in() && isset( $post_data['sendid'] ) ) ? $post_data['sendid'] : '';
4938 $sendpoint = ( isset( $post_data['sendpoint'] ) ) ? $post_data['sendpoint'] : '';
4939
4940 $params = array();
4941 $params['send'] = 'mall';
4942 $params['clientip'] = $acting_opts['clientip'];
4943 if ( 'on' === $acting_opts['quickcharge'] && isset( $post_data['card_option'] ) && 'prev' === $post_data['card_option'] && ! empty( $sendid ) ) {
4944 $params['cardnumber'] = '8888888888888882';
4945 $params['expyy'] = '00';
4946 $params['expmm'] = '00';
4947 } elseif ( isset( $post_data['token_key'] ) ) {
4948 $params['token_key'] = $post_data['token_key'];
4949 }
4950 $params['money'] = $post_data['money'];
4951 $params['telno'] = str_replace( '-', '', $post_data['telno'] );
4952 $params['email'] = $post_data['email'];
4953 $params['sendid'] = $sendid;
4954 $params['sendpoint'] = $sendpoint;
4955 $params['printord'] = 'yes';
4956 $params['return_value'] = 'yes';
4957 if ( 'on' === $acting_opts['howpay'] && isset( $post_data['howpay'] ) && WCUtils::is_zero( $post_data['howpay'] ) ) {
4958 $params['div'] = $post_data['div'];
4959 }
4960
4961 $page = $this->secure_link_batch( $acting_opts['card_url'], $params );
4962 if ( false !== strpos( $page, 'Success_order' ) ) {
4963 usces_ordered_acting_data( $sendpoint, 'propriety' );
4964 $_nonce = ( isset( $post_data['_nonce'] ) ) ? $post_data['_nonce'] : wp_create_nonce( 'acting_zeus_card' );
4965 wp_redirect(
4966 add_query_arg(
4967 array(
4968 'acting' => 'zeus_card',
4969 'acting_return' => 1,
4970 'result' => 1,
4971 '_nonce' => $_nonce,
4972 ),
4973 USCES_CART_URL
4974 )
4975 );
4976 } else {
4977 $err_code = $this->get_err_code( $page );
4978 $data = explode( "\r\n", $page );
4979 $log = array(
4980 'acting' => 'zeus_card',
4981 'key' => $sendpoint,
4982 'result' => $err_code,
4983 'data' => $data,
4984 );
4985 usces_save_order_acting_error( $log );
4986 wp_redirect(
4987 add_query_arg(
4988 array(
4989 'acting' => 'zeus_card',
4990 'acting_return' => 0,
4991 'err_code' => substr( $err_code, -3 ),
4992 ),
4993 USCES_CART_URL
4994 )
4995 );
4996 }
4997 exit();
4998
4999 } elseif ( 'acting_zeus_conv' === $acting_flg ) {
5000
5001 $interface = $this->get_interface( $acting_opts['conv_url'] );
5002
5003 $params = array();
5004 $params['clientip'] = $acting_opts['clientip_conv'];
5005 $params['act'] = $post_data['act'];
5006 $params['money'] = $post_data['money'];
5007 $params['username'] = mb_convert_encoding( $post_data['username'], 'SJIS', 'UTF-8' );
5008 $params['telno'] = str_replace( '-', '', $post_data['telno'] );
5009 $params['email'] = $post_data['email'];
5010 $params['pay_cvs'] = $post_data['pay_cvs'];
5011 $params['sendid'] = $post_data['sendid'];
5012 $params['sendpoint'] = $post_data['sendpoint'];
5013 if ( isset( $acting_opts['conv_ope'] ) && 'test' === $acting_opts['conv_ope'] ) {
5014 $params['testid'] = $acting_opts['testid_conv'];
5015 $params['test_type'] = $acting_opts['test_type_conv'];
5016 }
5017 if ( ! empty( $acting_opts['conv_span'] ) ) {
5018 $params['span'] = $acting_opts['conv_span'];
5019 }
5020 $vars = http_build_query( $params );
5021
5022 $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
5023 $header .= 'Host: ' . $interface['host'] . "\r\n";
5024 $header .= "User-Agent: PHP Script\r\n";
5025 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
5026 $header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
5027 $header .= "Connection: close\r\n\r\n";
5028 $header .= $vars;
5029
5030 $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
5031 if ( ! $fp ) {
5032 $log = array(
5033 'acting' => 'zeus_conv',
5034 'key' => $post_data['sendpoint'],
5035 'result' => 'SSL/TLS ERROR ( ' . $errno . ' )',
5036 'data' => array( $errstr ),
5037 );
5038 usces_save_order_acting_error( $log );
5039 wp_redirect(
5040 add_query_arg(
5041 array(
5042 'acting' => 'zeus_conv',
5043 'acting_return' => '0',
5044 ),
5045 USCES_CART_URL
5046 )
5047 );
5048 exit();
5049 }
5050
5051 if ( $fp ) {
5052 $page = '';
5053 $qstr = '';
5054 fwrite( $fp, $header );
5055 while ( ! feof( $fp ) ) {
5056 $scr = fgets( $fp, 1024 );
5057 $page .= $scr;
5058 if ( false !== strpos( $scr, 'order_no' ) ) {
5059 $qstr .= trim( $scr ) . '&';
5060 }
5061 if ( false !== strpos( $scr, 'pay_no1' ) ) {
5062 $qstr .= trim( $scr ) . '&';
5063 }
5064 if ( false !== strpos( $scr, 'pay_no2' ) ) {
5065 $qstr .= trim( $scr ) . '&';
5066 }
5067 if ( false !== strpos( $scr, 'pay_limit' ) ) {
5068 $qstr .= trim( $scr ) . '&';
5069 }
5070 if ( false !== strpos( $scr, 'pay_url' ) ) {
5071 $qstr .= trim( $scr ) . '&';
5072 }
5073 if ( false !== strpos( $scr, 'error_code' ) ) {
5074 $qstr .= trim( $scr ) . '&';
5075 }
5076 if ( false !== strpos( $scr, 'sendpoint' ) ) {
5077 $qstr .= trim( $scr ) . '&';
5078 }
5079 }
5080 $qstr .= 'pay_cvs=' . $post_data['pay_cvs'] . '&wctid=' . $post_data['sendpoint'];
5081 fclose( $fp );
5082
5083 if ( false !== strpos( $page, 'Success_order' ) ) {
5084 $result_data = array(
5085 'acting' => 'zeus_conv',
5086 'acting_return' => '1',
5087 );
5088 parse_str( $qstr, $data );
5089 $result_data = array_merge( $result_data, $data );
5090 wp_redirect( add_query_arg( $result_data, USCES_CART_URL ) );
5091 exit();
5092
5093 } else {
5094 parse_str( $qstr, $data );
5095 $log = array(
5096 'acting' => 'zeus_conv',
5097 'key' => $post_data['sendpoint'],
5098 'result' => 'CERTIFICATION ERROR',
5099 'data' => $data,
5100 );
5101 usces_save_order_acting_error( $log );
5102 wp_redirect(
5103 add_query_arg(
5104 array(
5105 'acting' => 'zeus_conv',
5106 'acting_return' => '0',
5107 ),
5108 USCES_CART_URL
5109 )
5110 );
5111 exit();
5112 }
5113 }
5114 exit();
5115
5116 } elseif ( 'acting_zeus_bnpl' === $acting_flg ) {
5117
5118 $entry = $usces->cart->get_entry();
5119 $sendpoint = ( isset( $post_data['sendpoint'] ) ) ? $post_data['sendpoint'] : '';
5120
5121 $httpheader = $this->get_header_information();
5122 $deviceinfo = ( ! empty( $post_data['fraudbuster'] ) ) ? $post_data['fraudbuster'] : '';
5123
5124 $data = array();
5125 $data['linkInfo'] = array(
5126 'shopCode' => $acting_opts['clientip_bnpl'],
5127 'linkId' => $acting_opts['bnpl_linkid'],
5128 'linkPassword' => $acting_opts['bnpl_linkpassword'],
5129 );
5130 $data['browserInfo'] = array(
5131 'httpHeader' => $httpheader,
5132 'deviceInfo' => $fraudbuster,
5133 );
5134 $data['customer'] = array(
5135 'shopOrderId' => $sendpoint,
5136 'shopOrderDate' => wp_date( 'Y/m/d' ),
5137 'name' => trim( $entry['customer']['name1'] ) . trim( $entry['customer']['name2'] ),
5138 'kanaName' => '',
5139 'zip' => trim( $entry['customer']['zipcode'] ),
5140 'address' => trim( $entry['customer']['pref'] ) . trim( $entry['customer']['address1'] ) . trim( $entry['customer']['address2'] ) . trim( $entry['customer']['address3'] ),
5141 'companyName' => ( ! empty( $entry['custom_customer']['company'] ) ) ? trim( $entry['custom_customer']['company'] ) : '',
5142 'sectionName' => '',
5143 'tel' => $post_data['tel_mobile'],
5144 'email' => trim( $entry['customer']['mailaddress1'] ),
5145 'billedAmount' => $post_data['money'],
5146 'expand1' => '',
5147 'service' => '2',
5148 );
5149 if ( defined( 'WCEX_MSA' ) && isset( $entry['delivery']['delivery_flag'] ) && 2 === (int) $entry['delivery']['delivery_flag'] ) {
5150 $msacart = ( isset( $_SESSION['msa_cart'] ) ) ? current( $_SESSION['msa_cart'] ) : array();
5151 if ( isset( $msacart['delivery']['destination_id'] ) ) {
5152 $member = $usces->get_member();
5153 $msadelivery = msa_get_destination( $member['ID'], $msacart['delivery']['destination_id'] );
5154 $data['ship'] = array(
5155 'shipName' => trim( $msadelivery['msa_name'] ) . trim( $msadelivery['msa_name2'] ),
5156 'shipKananame' => '',
5157 'shipZip' => trim( mb_convert_kana( $msadelivery['msa_zip'], 'a', 'UTF-8' ) ),
5158 'shipAddress' => trim( $msadelivery['msa_pref'] ) . trim( $msadelivery['msa_address1'] ) . trim( $msadelivery['msa_address2'] ) . trim( $msadelivery['msa_address3'] ),
5159 'shipCompanyName' => '',
5160 'shipSectionName' => '',
5161 'shipTel' => trim( $msadelivery['msa_tel'] ),
5162 );
5163 } else {
5164 $data['ship'] = array(
5165 'shipName' => '',
5166 'shipKananame' => '',
5167 'shipZip' => '',
5168 'shipAddress' => '',
5169 'shipCompanyName' => '',
5170 'shipSectionName' => '',
5171 'shipTel' => '',
5172 );
5173 }
5174 } else {
5175 $data['ship'] = array(
5176 'shipName' => trim( $entry['delivery']['name1'] ) . trim( $entry['delivery']['name2'] ),
5177 'shipKananame' => '',
5178 'shipZip' => trim( $entry['delivery']['zipcode'] ),
5179 'shipAddress' => trim( $entry['delivery']['pref'] ) . trim( $entry['delivery']['address1'] ) . trim( $entry['delivery']['address2'] ) . trim( $entry['delivery']['address3'] ),
5180 'shipCompanyName' => ( ! empty( $entry['custom_delivery']['company'] ) ) ? trim( $entry['custom_delivery']['company'] ) : '',
5181 'shipSectionName' => '',
5182 'shipTel' => trim( $entry['delivery']['tel'] ),
5183 );
5184 }
5185 $details = array();
5186 $cart_count = count( $cart );
5187 for ( $i = 0; $i < $cart_count; $i++ ) {
5188 $cart_row = $cart[ $i ];
5189 $details['detail'] = array(
5190 'goods' => $usces->getItemName( $cart_row['post_id'] ),
5191 'goodsPrice' => usces_crform( $cart_row['price'], false, false, 'return', false ),
5192 'goodsAmount' => $cart_row['quantity'],
5193 'expand2' => $i + 1,
5194 'expand3' => '',
5195 'expand4' => '',
5196 );
5197 }
5198 $data['details'] = $details;
5199
5200 $request = '<?xml version="1.0" encoding="UTF-8"?>';
5201 $request .= '<request>';
5202 $request .= $this->assoc2xml( $data );
5203 $request .= '</request>';
5204
5205 $xml = $this->get_xml_bnpl( $acting_opts['bnpl_transaction_url'], $request );
5206 if ( empty( $xml ) ) {
5207 $log = array(
5208 'acting' => 'zeus_bnpl',
5209 'key' => $sendpoint,
5210 'result' => 'Request Error',
5211 'data' => $request,
5212 );
5213 usces_save_order_acting_error( $log );
5214 wp_redirect(
5215 add_query_arg(
5216 array(
5217 'acting' => 'zeus_bnpl',
5218 'acting_return' => '0',
5219 'status' => 'error',
5220 ),
5221 USCES_CART_URL
5222 )
5223 );
5224 exit();
5225 }
5226
5227 $response = $this->xml2assoc( $xml );
5228 if ( ( isset( $response['response']['result'] ) && 'OK' === $response['response']['result'] ) &&
5229 ( isset( $response['response']['transactionInfo']['autoAuthoriresult'] ) && 'OK' === $response['response']['transactionInfo']['autoAuthoriresult'] ) ) {
5230 $result_data = array(
5231 'acting' => 'zeus_bnpl',
5232 'money' => $post_data['money'],
5233 'response' => $response['response'],
5234 );
5235 $res = $usces->order_processing( $result_data );
5236 if ( 'ordercompletion' === $res ) {
5237 $_nonce = ( isset( $post_data['_nonce'] ) ) ? $post_data['_nonce'] : wp_create_nonce( 'acting_zeus_bnpl' );
5238 wp_redirect(
5239 add_query_arg(
5240 array(
5241 'acting' => 'zeus_bnpl',
5242 'acting_return' => 1,
5243 'result' => 1,
5244 '_nonce' => $_nonce,
5245 ),
5246 USCES_CART_URL
5247 )
5248 );
5249 } else {
5250 $log = array(
5251 'acting' => 'zeus_bnpl',
5252 'key' => $sendpoint,
5253 'result' => 'ORDER DATA REGISTERED ERROR',
5254 'data' => $result_data,
5255 );
5256 usces_save_order_acting_error( $log );
5257 wp_redirect(
5258 add_query_arg(
5259 array(
5260 'acting' => 'zeus_bnpl',
5261 'acting_return' => 0,
5262 'result' => 0,
5263 ),
5264 USCES_CART_URL
5265 )
5266 );
5267 }
5268 exit();
5269 } else {
5270 if ( ( isset( $response['response']['result'] ) && 'OK' === $response['response']['result'] ) &&
5271 ( isset( $response['response']['transactionInfo']['autoAuthoriresult'] ) && 'OK' !== $response['response']['transactionInfo']['autoAuthoriresult'] ) ) {
5272 $log = array(
5273 'acting' => 'zeus_bnpl',
5274 'key' => $sendpoint,
5275 'result' => $response['response']['transactionInfo']['autoAuthoriresult'] . ':自動審査結果NG',
5276 'data' => $response,
5277 );
5278 usces_save_order_acting_error( $log );
5279 wp_redirect(
5280 add_query_arg(
5281 array(
5282 'acting' => 'zeus_bnpl',
5283 'acting_return' => '0',
5284 'status' => $response['response']['transactionInfo']['autoAuthoriresult'],
5285 ),
5286 USCES_CART_URL
5287 )
5288 );
5289 } else {
5290 $log = array(
5291 'acting' => 'zeus_bnpl',
5292 'key' => $sendpoint,
5293 'result' => $response['response']['result'] . ':' . $response['errors']['error']['errorCode'],
5294 'data' => $response,
5295 );
5296 usces_save_order_acting_error( $log );
5297 wp_redirect(
5298 add_query_arg(
5299 array(
5300 'acting' => 'zeus_bnpl',
5301 'acting_return' => '0',
5302 'status' => $response['response']['result'],
5303 'code' => $response['errors']['error']['errorCode'],
5304 ),
5305 USCES_CART_URL
5306 )
5307 );
5308 }
5309 exit();
5310 }
5311 }
5312 }
5313
5314 /**
5315 * 結果通知前処理
5316 * usces_pre_acting_return
5317 */
5318 public function pre_acting_return() {
5319 global $usces;
5320
5321 $tracking_id = filter_input( INPUT_GET, 'wctid' );
5322 if ( empty( $tracking_id ) ) {
5323 $tracking_id = filter_input( INPUT_GET, 'sendpoint' );
5324 }
5325 if ( ! empty( $tracking_id ) ) {
5326 $cart = $usces->cart->get_cart();
5327 if ( empty( $cart ) ) {
5328 usces_restore_order_acting_data( $tracking_id );
5329 }
5330 }
5331 }
5332
5333 /**
5334 * 決済完了ページ制御
5335 * usces_filter_check_acting_return_results
5336 *
5337 * @param array $results Result data.
5338 * @return array
5339 */
5340 public function acting_return( $results ) {
5341 $acting = filter_input( INPUT_GET, 'acting' );
5342 switch ( $acting ) {
5343 case 'zeus_card':
5344 if ( $results['acting_return'] && isset( $results['wctid'] ) && usces_is_trusted_acting_data( $results['wctid'] ) ) {
5345 $results[0] = 1;
5346 } else {
5347 $results[0] = ( isset( $results['acting_return'] ) ) ? $results['acting_return'] : 0;
5348 }
5349 $results['reg_order'] = false;
5350 break;
5351
5352 case 'zeus_conv':
5353 if ( $results['acting_return'] ) {
5354 $results[0] = 1;
5355 } else {
5356 $results[0] = 0;
5357 }
5358 $results['reg_order'] = true;
5359 break;
5360
5361 case 'zeus_bnpl':
5362 $results[0] = $results['acting_return'];
5363 $results['reg_order'] = false;
5364 break;
5365 }
5366
5367 return $results;
5368 }
5369
5370 /**
5371 * 重複オーダー禁止処理
5372 * usces_filter_check_acting_return_duplicate
5373 *
5374 * @param string $trans_id Transaction ID.
5375 * @param array $results Result data.
5376 * @return string
5377 */
5378 public function check_acting_return_duplicate( $trans_id, $results ) {
5379 $result_data = wp_unslash( $_REQUEST );
5380 $acting = ( isset( $result_data['acting'] ) ) ? $result_data['acting'] : '';
5381 switch ( $acting ) {
5382 case 'zeus_card':
5383 if ( isset( $result_data['ordd'] ) ) {
5384 $trans_id = $result_data['ordd'];
5385 } elseif ( isset( $result_data['zeusordd'] ) ) {
5386 $trans_id = $result_data['zeusordd'];
5387 }
5388 break;
5389 case 'zeus_conv':
5390 case 'zeus_bank':
5391 $trans_id = ( isset( $result_data['order_no'] ) ) ? $result_data['order_no'] : '';
5392 break;
5393 case 'zeus_bnpl':
5394 $trans_id = ( isset( $result_data['sendpoint'] ) ) ? $result_data['sendpoint'] : '';
5395 break;
5396 }
5397 return $trans_id;
5398 }
5399
5400 /**
5401 * 受注データ登録
5402 * Called by usces_reg_orderdata() and usces_new_orderdata().
5403 * usces_action_reg_orderdata
5404 *
5405 * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $results ).
5406 */
5407 public function register_orderdata( $args ) {
5408 global $usces;
5409 extract( $args );
5410
5411 $acting_flg = ( isset( $payments['settlement'] ) ) ? $payments['settlement'] : '';
5412 if ( ! in_array( $acting_flg, $this->pay_method, true ) ) {
5413 return;
5414 }
5415
5416 if ( ! $entry['order']['total_full_price'] ) {
5417 return;
5418 }
5419
5420 /* zeus card */
5421 if ( 'acting_zeus_card' === $acting_flg ) {
5422 $acting_opts = $this->get_acting_settings();
5423 /* Secure API */
5424 if ( 2 === (int) $acting_opts['connection'] && ! empty( $results['zeusordd'] ) && ! empty( $results['zeussuffix'] ) ) {
5425 if ( ! isset( $results['acting'] ) ) {
5426 $results['acting'] = 'zeus_card';
5427 }
5428 if ( 'on' === $acting_opts['howpay'] ) {
5429 if ( isset( $entry['order']['howpay'] ) && '0' === $entry['order']['howpay'] ) {
5430 $div_name = 'div_' . $entry['order']['cbrand'];
5431 $results['howpay'] = '0';
5432 $results['div'] = $entry['order'][ $div_name ];
5433 } else {
5434 $results['howpay'] = '1';
5435 $results['div'] = '01';
5436 }
5437 }
5438 $usces->set_order_meta_value( 'acting_zeus_card', usces_serialize( $results ), $order_id );
5439 $usces->set_order_meta_value( 'wc_trans_id', $results['zeusordd'], $order_id );
5440 $usces->set_order_meta_value( 'trans_id', $results['zeusordd'], $order_id );
5441 if ( 'on' === $acting_opts['quickcharge'] && $usces->is_member_logged_in() ) {
5442 $usces->set_member_meta_value( 'zeus_pcid', '8888888888888882' );
5443 $usces->set_member_meta_value( 'zeus_partofcard', $results['zeussuffix'] );
5444 }
5445 if ( isset( $results['auth_code'] ) ) {
5446 $usces->set_order_meta_value( 'auth_code', $results['auth_code'], $order_id );
5447 }
5448
5449 $tracking_id = ( isset( $results['wctid'] ) ) ? $results['wctid'] : '';
5450 if ( empty( $tracking_id ) ) {
5451 $tracking_id = ( isset( $results['sendpoint'] ) ) ? $results['sendpoint'] : '';
5452 }
5453 if ( ! empty( $tracking_id ) ) {
5454 $usces->set_order_meta_value( 'tracking_id', $tracking_id, $order_id );
5455
5456 $order_ref = wel_zeus_get_order_ref( $results['zeusordd'] );
5457 $status = ( empty( $order_ref['status'] ) ) ? 'payment' : $order_ref['status'];
5458 if ( ! isset( $results['money'] ) ) {
5459 $amount = apply_filters( 'zeus_secure_payreq_amount', usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ), $entry );
5460 $results['money'] = $amount;
5461 }
5462 $results = apply_filters( 'usces_filter_zeus_card_register_orderdata_log', $results, $args );
5463 wel_zeus_save_acting_log( $results, 'zeus_card', $status, 'OK', $order_id, $tracking_id );
5464 }
5465
5466 /* Secure Link */
5467 } elseif ( 1 === (int) $acting_opts['connection'] && ! empty( $results['ordd'] ) ) {
5468 if ( 'on' === $acting_opts['howpay'] ) {
5469 if ( isset( $entry['order']['howpay'] ) && '0' === $entry['order']['howpay'] ) {
5470 $div_name = 'div_' . $entry['order']['cbrand'];
5471 $results['howpay'] = '0';
5472 $results['div'] = $entry['order'][ $div_name ];
5473 } else {
5474 $results['howpay'] = '1';
5475 $results['div'] = '01';
5476 }
5477 }
5478 $usces->set_order_meta_value( 'acting_zeus_card', usces_serialize( $results ), $order_id );
5479 $usces->set_order_meta_value( 'wc_trans_id', $results['ordd'], $order_id );
5480 $usces->set_order_meta_value( 'trans_id', $results['ordd'], $order_id );
5481
5482 if ( 'on' === $acting_opts['quickcharge'] && ! empty( $results['sendid'] ) ) {
5483 if ( isset( $results['cardnumber'] ) ) {
5484 $usces->set_member_meta_value( 'zeus_partofcard', $results['cardnumber'], $results['sendid'] );
5485 $usces->set_member_meta_value( 'zeus_pcid', '8888888888888882', $results['sendid'] );
5486 }
5487 }
5488
5489 $tracking_id = ( isset( $results['sendpoint'] ) ) ? $results['sendpoint'] : '';
5490 if ( ! empty( $tracking_id ) ) {
5491 $usces->set_order_meta_value( 'tracking_id', $tracking_id, $order_id );
5492
5493 $order_ref = wel_zeus_get_order_ref( $results['ordd'] );
5494 $status = ( empty( $order_ref['status'] ) ) ? 'payment' : $order_ref['status'];
5495 $results = apply_filters( 'usces_filter_zeus_card_register_orderdata_log', $results, $args );
5496 wel_zeus_save_acting_log( $results, 'zeus_card', $status, 'OK', $order_id, $tracking_id );
5497 }
5498 }
5499
5500 /* zeus_bank */
5501 } elseif ( 'acting_zeus_bank' === $acting_flg && isset( $results['order_no'] ) && isset( $results['tracking_no'] ) ) {
5502 if ( isset( $results['acting_return'] ) ) {
5503 unset( $results['acting_return'] );
5504 unset( $results['0'] );
5505 unset( $results['reg_order'] );
5506 }
5507 $usces->set_order_meta_value( 'acting_' . $results['tracking_no'], usces_serialize( $results ), $order_id );
5508 $usces->set_order_meta_value( 'wc_trans_id', $results['order_no'], $order_id );
5509 $usces->set_order_meta_value( 'trans_id', $results['order_no'], $order_id );
5510
5511 /* zeus conv */
5512 } elseif ( 'acting_zeus_conv' === $acting_flg && ! empty( $results['wctid'] ) ) {
5513 if ( isset( $results['acting_return'] ) ) {
5514 unset( $results['acting_return'] );
5515 unset( $results['0'] );
5516 unset( $results['reg_order'] );
5517 }
5518 $usces->set_order_meta_value( 'acting_' . $results['wctid'], usces_serialize( $results ), $order_id );
5519 if ( ! empty( $results['order_no'] ) ) {
5520 $usces->set_order_meta_value( 'wc_trans_id', $results['order_no'], $order_id );
5521 $usces->set_order_meta_value( 'trans_id', $results['order_no'], $order_id );
5522 }
5523
5524 /* zeus bnpl */
5525 } elseif ( 'acting_zeus_bnpl' === $acting_flg ) {
5526 $response = ( isset( $results['response'] ) ) ? $results['response'] : array();
5527 $tracking_id = ( isset( $response['transactionInfo']['shopOrderId'] ) ) ? $response['transactionInfo']['shopOrderId'] : '';
5528 if ( ! empty( $tracking_id ) ) {
5529 unset( $results['response'] );
5530 $results['shopOrderId'] = $tracking_id;
5531 $results['transactionId'] = $response['transactionInfo']['transactionId'];
5532 $results['autoAuthoriresult'] = $response['transactionInfo']['autoAuthoriresult'];
5533 $usces->set_order_meta_value( 'acting_zeus_bnpl', usces_serialize( $results ), $order_id );
5534 $usces->set_order_meta_value( 'tracking_id', $tracking_id, $order_id );
5535 $usces->set_order_meta_value( 'wc_trans_id', $response['transactionInfo']['transactionId'], $order_id );
5536 $usces->set_order_meta_value( 'trans_id', $response['transactionInfo']['transactionId'], $order_id );
5537 $response['money'] = $results['money'];
5538 wel_zeus_save_acting_log( $response, 'zeus_bnpl', 'transaction', $response['transactionInfo']['autoAuthoriresult'], $order_id, $tracking_id );
5539 }
5540 }
5541 }
5542
5543 /**
5544 * 受注データ登録後処理
5545 * usces_post_reg_orderdata
5546 *
5547 * @param string $order_id Order Number.
5548 * @param array $results Results.
5549 */
5550 public function post_register_orderdata( $order_id, $results ) {
5551 if ( ! empty( $order_id ) && isset( $results['acting'] ) && 'zeus_card' === $results['acting'] ) {
5552 $tracking_id = ( isset( $results['wctid'] ) ) ? $results['wctid'] : '';
5553 if ( empty( $tracking_id ) ) {
5554 $tracking_id = ( isset( $results['sendpoint'] ) ) ? $results['sendpoint'] : '';
5555 }
5556 if ( ! empty( $tracking_id ) ) {
5557 // usces_ordered_acting_data( $_REQUEST['wctid'] ); �
5558 ��
5559 の処理.
5560 usces_delete_ordered_acting_data( $tracking_id );
5561 }
5562 }
5563 }
5564
5565 /**
5566 * 決済エラーメッセージ
5567 * usces_filter_get_error_settlement
5568 *
5569 * @param string $form Payment error message.
5570 * @return string
5571 */
5572 public function error_page_message( $form ) {
5573 $acting = ( isset( $_REQUEST['acting'] ) ) ? wp_unslash( $_REQUEST['acting'] ) : '';
5574 if ( 'zeus_card' === $acting ) {
5575 $form .= '<div class="support_box">';
5576 if ( isset( $_GET['code'] ) ) {
5577 $code = filter_input( INPUT_GET, 'code' );
5578 $form .= '<br />エラーコード:' . esc_html( $code );
5579 if ( in_array( $code, array( '02130514', '02130517', '02130619', '02130620', '02130621', '02130640' ), true ) ) {
5580 $form .= '<br />カード番号が正しくないようです。';
5581 } elseif ( in_array( $code, array( '02130714', '02130717', '02130725', '02130814', '02130817', '02130825' ), true ) ) {
5582 $form .= '<br />カードの有効期限が正しくないようです。';
5583 } elseif ( in_array( $code, array( '02130922' ), true ) ) {
5584 $form .= '<br />カードの有効期限が切れているようです。';
5585 } elseif ( in_array( $code, array( '02131014', '02131017' ), true ) ) {
5586 $form .= '<br />セキュリティコードが正しくないようです。';
5587 } elseif ( in_array( $code, array( '02131117', '02131123', '02131124' ), true ) ) {
5588 $form .= '<br />カードの名義が正しくないようです。';
5589 } elseif ( in_array( $code, array( '02131317', '02131325', '02131310', '02131326' ), true ) ) {
5590 $form .= '<br />指定の支払い回数はご利用いただけません。';
5591 } elseif ( in_array( $code, array( '02131414', '02131417', '02131437' ), true ) ) {
5592 $form .= '<br />お客様�
5593 報の電話番号が正しくないようです。';
5594 } elseif ( in_array( $code, array( '02131527', '02131528', '02131529', '02131537' ), true ) ) {
5595 $form .= '<br />お客様�
5596 報のEメールアドレスが正しくないようです。';
5597 } elseif ( in_array( $code, array( '02100431' ), true ) ) {
5598 $form .= '<br />今回のお申し込みは受け付けられませんでした。ご利用サイトは3Dセキュアの認証が�
5599 要のため、お使いのクレジットカードではお取扱出来ません。';
5600 } else {
5601 $form .= '<br />今回のお申し込みは受け付けられませんでした。';
5602 }
5603 $form .= '<br />
5604 <br />
5605 <a href="' . USCES_CUSTOMER_URL . '">もう一度決済を行う </a><br />';
5606 } else {
5607 if ( isset( $_GET['err_code'] ) ) {
5608 $form .= '<br />エラーコード:' . filter_input( INPUT_GET, 'err_code' );
5609 }
5610 $form .= '<br />
5611 カード番号を再�
5612 �力する場合はこちらをクリックしてください。<br />
5613 <br />
5614 <a href="' . USCES_CUSTOMER_URL . '">もう一度決済を行う </a><br />';
5615 }
5616 $form .= '<br />
5617 株式会社ゼウス カスタマーサポート (24時間365日対応)<br />
5618 電話番号:0570-02-3939 (つながらないときは 03-4334-0500<br />
5619 E-mail:support@cardservice.co.jp
5620 </div>';
5621
5622 } elseif ( 'zeus_conv' === $acting || 'zeus_bank' === $acting ) {
5623 $form .= '<div class="support_box">';
5624 if ( isset( $_GET['code'] ) ) {
5625 $code = filter_input( INPUT_GET, 'code' );
5626 $form .= '<br />エラーコード:' . esc_html( $code );
5627 if ( in_array( $code, array( '800002', '0013' ), true ) ) {
5628 $form .= '<br />このコンビニはお取り扱いできません。詳細に関してはカスタマーサポートまでお問い合わせください。';
5629 } elseif ( in_array( $code, array( '900000', '0011' ), true ) ) {
5630 $form .= '<br />お申し込み�
5631 報が正しく�
5632 �力されていないか、通信時にエラーが発生している可能性がございます。�
5633 �力�
5634 報を再度ご確認いただいた上でお申し込みをいただくか、カスタマーサポートまでお問い合わせください。';
5635 } elseif ( in_array( $code, array( '0008' ), true ) ) {
5636 $form .= '<br />このコンビニはお取り扱いできません。別のコンビニをご選択いただき、再度お申し込みをいただくか、カスタマーサポートまでお問い合わせください。';
5637 } else {
5638 $form .= '<br />詳細に関してはカスタマーサポートまでお問い合わせください。';
5639 }
5640 } else {
5641 if ( 'zeus_conv' === $acting ) {
5642 $form .= '<br />このコンビニはお取り扱いできません。詳細に関してはカスタマーサポートまでお問い合わせください。';
5643 } else {
5644 $form .= '<br />詳細に関してはカスタマーサポートまでお問い合わせください。';
5645 }
5646 }
5647 $form .= '<br /><br />
5648 <a href="' . USCES_CUSTOMER_URL . '">もう一度決済を行う 》</a><br /><br />
5649 株式会社ゼウス カスタマーサポート (24時間365日対応)<br />
5650 電話番号:0570-08-3000 (つながらないときは 03-3498-9888)<br />
5651 E-mail:support@cardservice.co.jp
5652 </div>';
5653
5654 } elseif ( 'zeus_bnpl' === $acting ) {
5655 $form .= '<div class="support_box">';
5656 if ( isset( $_GET['code'] ) ) {
5657 $code = filter_input( INPUT_GET, 'code' );
5658 $form .= '<br />エラーコード:' . esc_html( $code );
5659 }
5660 $form .= '<br /><br />
5661 <a href="' . USCES_CUSTOMER_URL . '">もう一度決済を行う 》</a><br /><br />
5662 株式会社ゼウス カスタマーサポート (24時間365日対応)<br />
5663 電話番号:0570-08-3000 (つながらないときは 03-3498-9888)<br />
5664 E-mail:support@cardservice.co.jp
5665 </div>';
5666 }
5667 return $form;
5668 }
5669
5670 /**
5671 * Set uscesL10n.
5672 * usces_filter_uscesL10n
5673 *
5674 * @param string $l10n uscesL10n.
5675 * @param int $post_id Post ID.
5676 * @return string
5677 */
5678 public function set_uscesL10n( $l10n, $post_id ) {
5679 global $usces;
5680
5681 if ( ! $this->is_validity_acting( 'card' ) ) {
5682 return $l10n;
5683 }
5684
5685 if ( 'delivery' === $usces->page ) {
5686 $acting_opts = $this->get_acting_settings();
5687 $pcid = null;
5688 $partofcard = null;
5689 if ( $usces->is_member_logged_in() ) {
5690 $member = $usces->get_member();
5691 if ( ! isset( $_GET['re-enter'] ) ) {
5692 $pcid = $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] );
5693 $partofcard = $usces->get_member_meta_value( 'zeus_partofcard', $member['ID'] );
5694 }
5695 }
5696 $l10n .= "'zeus_form': 'cart',\n";
5697 $l10n .= "'zeus_security': '" . $acting_opts['security'] . "',\n";
5698 $l10n .= "'zeus_quickcharge': '" . $acting_opts['quickcharge'] . "',\n";
5699 $l10n .= "'zeus_howpay': '" . $acting_opts['howpay'] . "',\n";
5700 $l10n .= "'zeus_thisyear': '" . date_i18n( 'Y' ) . "',\n";
5701 $l10n .= "'zeus_pcid': '" . $pcid . "',\n";
5702 $l10n .= "'zeus_partofcard': '" . $partofcard . "',\n";
5703 if ( ! empty( $pcid ) && ! empty( $partofcard ) ) {
5704 $member_update_settlement = add_query_arg(
5705 array(
5706 'usces_page' => 'member_update_settlement',
5707 're-enter' => 1,
5708 ),
5709 USCES_MEMBER_URL
5710 );
5711 $l10n .= "'zeus_cardupdate_url': '" . urlencode( $member_update_settlement ) . "',\n";
5712 }
5713 $l10n .= "'zeus_card_error': '" . __( 'Credit card information is not appropriate.', 'usces' ) . "',\n";
5714 $l10n .= "'zeus_3ds': '" . $acting_opts['3dsecur'] . "',\n";
5715 } elseif ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
5716 if ( isset( $_GET['usces_page'] ) && ( 'member_register_settlement' === filter_input( INPUT_GET, 'usces_page' ) || 'member_update_settlement' === filter_input( INPUT_GET, 'usces_page' ) ) ) {
5717 $acting_opts = $this->get_acting_settings();
5718 $member = $usces->get_member();
5719 $pcid = $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] );
5720 $partofcard = $usces->get_member_meta_value( 'zeus_partofcard', $member['ID'] );
5721 $l10n .= "'zeus_form': 'member',\n";
5722 $l10n .= "'zeus_security': '" . $acting_opts['security'] . "',\n";
5723 $l10n .= "'zeus_quickcharge': '" . $acting_opts['quickcharge'] . "',\n";
5724 $l10n .= "'zeus_thisyear': '" . date_i18n( 'Y' ) . "',\n";
5725 $l10n .= "'zeus_thismonth': '" . date_i18n( 'm' ) . "',\n";
5726 $l10n .= "'zeus_pcid': '" . $pcid . "',\n";
5727 $l10n .= "'zeus_partofcard': '" . $partofcard . "',\n";
5728 $l10n .= "'zeus_card_error': '" . __( 'Credit card information is not appropriate.', 'usces' ) . "',\n";
5729 $l10n .= "'zeus_3ds': '" . $acting_opts['3dsecur'] . "',\n";
5730 }
5731 }
5732 return $l10n;
5733 }
5734
5735 /**
5736 * Front scripts.
5737 * wp_print_footer_scripts
5738 */
5739 public function footer_scripts() {
5740 global $usces;
5741
5742 if ( ! $this->is_validity_acting( 'card' ) ) {
5743 return;
5744 }
5745
5746 /* 発送・支払方法ページ */
5747 if ( 'delivery' === $usces->page ) :
5748 $acting_opts = $this->get_acting_settings();
5749 if ( 'on' === $acting_opts['card_activate'] ) :
5750 wp_enqueue_style( 'zeus-token-style', USCES_FRONT_PLUGIN_URL . '/css/zeus_token.css', array(), USCES_VERSION );
5751 wp_enqueue_script( 'zeus-token-script', USCES_FRONT_PLUGIN_URL . '/js/zeus_token.js', array(), USCES_VERSION );
5752 wp_enqueue_script( 'usces_cart_zeus', USCES_FRONT_PLUGIN_URL . '/js/cart_zeus.js', array( 'jquery' ), USCES_VERSION, true );
5753 ?>
5754 <script type="text/javascript">
5755 var zeusTokenIpcode = "<?php echo esc_attr( $acting_opts['clientip'] ); ?>";
5756 </script>
5757 <?php
5758 endif;
5759
5760 /* �
5761 容確認ページ */
5762 elseif ( 'confirm' === $usces->page ) :
5763 $entry = $usces->cart->get_entry();
5764 $cart = $usces->cart->get_cart();
5765 if ( empty( $cart ) || empty( $entry['order']['total_full_price'] ) ) {
5766 return;
5767 }
5768
5769 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
5770 if ( 'acting_zeus_card' === $payment['settlement'] && 'activate' === $payment['use'] ) :
5771 $acting_opts = $this->get_acting_settings();
5772 if ( $this->is_activate_card( 'api' ) && 1 === (int) $acting_opts['3dsecur'] ) :
5773 wp_enqueue_script( 'zeus-3ds-script', USCES_FRONT_PLUGIN_URL . '/js/zeus_3ds.js', array(), USCES_VERSION );
5774 wp_enqueue_style( 'usces-loading', USCES_FRONT_PLUGIN_URL . '/css/loading.css', array(), USCES_VERSION );
5775 ob_start();
5776 ?>
5777 <script>
5778 var loading_img = document.getElementById('zeus-loading');
5779 var purchase_button = document.getElementById('purchase_button');
5780 purchase_button.dataset.clicked = '';
5781 purchase_button.addEventListener( 'click', function(event) {
5782 purchase_button.dataset.clicked = 'clicked';
5783 });
5784 var purchase_form = document.getElementById('purchase_form');
5785 purchase_form.addEventListener( 'submit', function(event) {
5786 if( purchase_button.dataset.clicked === 'clicked' ) {
5787 loading_img.style.display = 'block';
5788 event.preventDefault();
5789 let params = new URLSearchParams();
5790 params.append("action","zeus_3dsecure_enrol");
5791 params.append("card_option",document.getElementById("card_option").value);
5792 params.append("token_key",document.getElementById("token_key").value);
5793 params.append("card_name",document.getElementById("card_name").value);
5794 params.append("sendid",document.getElementById("sendid").value);
5795 params.append("sendpoint",document.getElementById("sendpoint").value);
5796 params.append("_nonce","<?php echo esc_attr( wp_create_nonce( 'acting_zeus_card' ) ); ?>");
5797 return fetch( uscesL10n.ajaxurl, {
5798 method:'POST',
5799 cache:'no-cache',
5800 body:params
5801 }).then( function(res) {
5802 return res.json();
5803 }).then( function(data) {
5804 if( 'stock' == data.action && 'error' == data.status ) {
5805 location.href = "<?php echo esc_js( USCES_CART_URL ); ?>";
5806 }
5807 if( 'EnrolReq' == data.action && 'success' == data.status ) {
5808 purchase_button.disabled = true;
5809 try {
5810 setPareqParams(data.MD,data.iframeUrl,data.TermUrl,data.threeDSMehtod,data.iframeUrl);
5811 } catch(error) {
5812 purchase_button.disabled = false;
5813 loading_img.style.display = 'none';
5814 }
5815 } else if( 'EnrolReq' == data.action && 'outside' == data.status ) {
5816 if( null !== data.code ) {
5817 var outside = document.createElement('input');
5818 outside.setAttribute('type','hidden');
5819 outside.setAttribute('name','outside');
5820 outside.setAttribute('value',data.code);
5821 }
5822 var purchase = document.createElement('input');
5823 purchase.setAttribute('type','hidden');
5824 purchase.setAttribute('name','purchase');
5825 purchase.setAttribute('value','purchase');
5826 document.purchase_form.appendChild(outside);
5827 document.purchase_form.appendChild(purchase);
5828 document.purchase_form.submit();
5829 } else {
5830 location.href = "<?php echo esc_js( trailingslashit( USCES_CART_URL ) ); ?>?acting=zeus_card&acting_return=0&status="+data.status+"&code="+data.code;
5831 }
5832 }).catch((reason) => {
5833 loading_img.style.display = 'none';
5834 });
5835 }
5836 });
5837 </script>
5838 <?php
5839 $scripts = ob_get_contents();
5840 ob_end_clean();
5841 $scripts = apply_filters( 'usces_filter_purchase_button_script_zeus', $scripts );
5842 echo $scripts;
5843 endif;
5844 endif;
5845
5846 /* マイページ */
5847 elseif ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) :
5848 if ( isset( $_GET['usces_page'] ) && ( 'member_register_settlement' === filter_input( INPUT_GET, 'usces_page' ) || 'member_update_settlement' === filter_input( INPUT_GET, 'usces_page' ) ) ) :
5849 $acting_opts = $this->get_acting_settings();
5850 wp_enqueue_style( 'zeus-token-style', USCES_FRONT_PLUGIN_URL . '/css/zeus_token.css', array(), USCES_VERSION );
5851 wp_enqueue_script( 'zeus-token-script', USCES_FRONT_PLUGIN_URL . '/js/zeus_token.js', array(), USCES_VERSION );
5852 wp_enqueue_script( 'usces_member_zeus', USCES_FRONT_PLUGIN_URL . '/js/member_zeus.js', array( 'jquery' ), USCES_VERSION, true );
5853 ?>
5854 <script type="text/javascript">
5855 var zeusTokenIpcode = "<?php echo esc_attr( $acting_opts['clientip'] ); ?>";
5856 </script>
5857 <?php
5858 print_google_recaptcha_response( filter_input( INPUT_GET, 'usces_page' ), 'member-card-info', 'member_update_settlement' );
5859 else :
5860 $member = $usces->get_member();
5861 if ( usces_have_member_continue_order( $member['ID'] ) || usces_have_member_regular_order( $member['ID'] ) ) :
5862 ?>
5863 <script type="text/javascript">
5864 jQuery(document).ready(function($) {
5865 $("input[name='deletemember']").css("display","none");
5866 });
5867 </script>
5868 <?php
5869 endif;
5870 endif;
5871 endif;
5872 }
5873
5874 /**
5875 * 利用可能な決済モジュール
5876 * usces_filter_available_payment_method
5877 *
5878 * @param array $payments Payments.
5879 * @return array
5880 */
5881 public function set_available_payment_method( $payments ) {
5882 global $usces;
5883
5884 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
5885 $payment_method = array();
5886 foreach ( (array) $payments as $id => $payment ) {
5887 if ( isset( $payment['settlement'] ) && 'acting_zeus_card' === $payment['settlement'] ) {
5888 $payment_method[ $id ] = $payments[ $id ];
5889 break;
5890 }
5891 }
5892 if ( ! empty( $payment_method ) ) {
5893 $payments = $payment_method;
5894 }
5895 }
5896 return $payments;
5897 }
5898
5899 /**
5900 * クレジットカード登録・変更ページ表示
5901 * usces_filter_template_redirect
5902 */
5903 public function member_update_settlement() {
5904 global $usces;
5905
5906 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
5907 if ( ! usces_is_membersystem_state() || ! usces_is_login() ) {
5908 return;
5909 }
5910
5911 $acting_opts = $this->get_acting_settings();
5912 if ( 'on' !== $acting_opts['quickcharge'] ) {
5913 return;
5914 }
5915
5916 if ( isset( $_REQUEST['usces_page'] ) && 'member_update_settlement' === $_REQUEST['usces_page'] ) {
5917 add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) );
5918 $usces->page = 'member_update_settlement';
5919 $this->member_update_settlement_form();
5920 exit();
5921
5922 } elseif ( isset( $_REQUEST['usces_page'] ) && 'member_register_settlement' === $_REQUEST['usces_page'] && 'on' === $acting_opts['batch'] ) {
5923 add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) );
5924 $usces->page = 'member_register_settlement';
5925 $this->member_update_settlement_form();
5926 exit();
5927 }
5928 }
5929 return false;
5930 }
5931
5932 /**
5933 * クレジットカード登録・変更ページ表示
5934 * usces_filter_states_form_js
5935 *
5936 * @param string $js Scripts.
5937 * @return string
5938 */
5939 public function states_form_js( $js ) {
5940 return '';
5941 }
5942
5943 /**
5944 * クレジットカード登録・変更ページリンク
5945 * usces_action_member_submenu_list
5946 */
5947 public function e_update_settlement() {
5948 global $usces;
5949
5950 $member = $usces->get_member();
5951 $form = $this->update_settlement( '', $member );
5952 echo $form; // no escape.
5953 }
5954
5955 /**
5956 * クレジットカード登録・変更ページリンク
5957 * usces_filter_member_submenu_list
5958 *
5959 * @param string $form HTML Form.
5960 * @param array $member Members data.
5961 * @return string
5962 */
5963 public function update_settlement( $form, $member ) {
5964 global $usces;
5965
5966 $acting_opts = $this->get_acting_settings();
5967 if ( 'on' === $acting_opts['quickcharge'] ) {
5968 $member = $usces->get_member();
5969 $pcid = $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] );
5970 $partofcard = $usces->get_member_meta_value( 'zeus_partofcard', $member['ID'] );
5971 if ( ! empty( $pcid ) && ! empty( $partofcard ) ) {
5972 $update_settlement_url = add_query_arg(
5973 array(
5974 'usces_page' => 'member_update_settlement',
5975 're-enter' => 1,
5976 ),
5977 USCES_MEMBER_URL
5978 );
5979 $form .= '<li class="settlement-update gotoedit"><a href="' . $update_settlement_url . '">' . __( 'Change the credit card is here >>', 'usces' ) . '</a></li>';
5980 } elseif ( 'on' === $acting_opts['batch'] ) {
5981 $register_settlement_url = add_query_arg(
5982 array(
5983 'usces_page' => 'member_register_settlement',
5984 're-enter' => 1,
5985 ),
5986 USCES_MEMBER_URL
5987 );
5988 $form .= '<li class="settlement-register gotoedit"><a href="' . $register_settlement_url . '">' . __( 'Credit card registration is here >>', 'usces' ) . '</a></li>';
5989 }
5990 }
5991 return $form;
5992 }
5993
5994 /**
5995 * クレジットカード登録・変更ページ
5996 */
5997 public function member_update_settlement_form() {
5998 global $usces;
5999
6000 $script = '';
6001 $message = '';
6002 $form = '';
6003 $register = ( 'member_register_settlement' === $usces->page ) ? true : false;
6004
6005 $update_settlement_url = add_query_arg(
6006 array(
6007 'usces_page' => 'member_update_settlement',
6008 'settlement' => 1,
6009 're-enter' => 1,
6010 ),
6011 USCES_MEMBER_URL
6012 );
6013
6014 $member = $usces->get_member();
6015 $acting_opts = $this->get_acting_settings();
6016
6017 if ( isset( $_POST['zeus_card_update'] ) ) {
6018 if ( ! wp_verify_nonce( filter_input( INPUT_POST, 'wc_nonce' ), 'member_update_settlement' ) || empty( $_POST['zeus_token_value'] ) ) {
6019 $usces->error_message .= __( 'failure in update', 'usces' );
6020 } else {
6021 $verify_action = wel_verify_update_settlement( $member['ID'] );
6022 if ( ! $verify_action ) {
6023 $usces->error_message .= '<p>' . __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '</p>';
6024 } else {
6025 $params = array();
6026 $params['send'] = 'mall';
6027 $params['clientip'] = $acting_opts['clientip'];
6028 $params['token_key'] = filter_input( INPUT_POST, 'zeus_token_value' );
6029 $params['cardnumber'] = '8888888888888882';
6030 $params['expyy'] = '00';
6031 $params['expmm'] = '00';
6032 $params['money'] = '0';
6033 $params['telno'] = str_replace( '-', '', $member['tel'] );
6034 $params['email'] = $member['mailaddress1'];
6035 $params['sendid'] = $member['ID'];
6036 $params['sendpoint'] = usces_rand();
6037 $params['pubsec'] = 'yes';
6038 $params['printord'] = '';
6039 $params['return_value'] = 'yes';
6040
6041 $page = $this->secure_link_batch( $acting_opts['card_url'], $params );
6042 if ( false !== strpos( $page, 'Success_order' ) ) {
6043 $usces->error_message = '';
6044 $message = __( 'Successfully updated.', 'usces' );
6045 if ( ! empty( $_POST['zeus_token_masked_card_no'] ) ) {
6046 $partofcard = substr( filter_input( INPUT_POST, 'zeus_token_masked_card_no' ), -4 );
6047 $usces->set_member_meta_value( 'zeus_partofcard', $partofcard );
6048 }
6049 $pcid = $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] );
6050 if ( empty( $pcid ) ) {
6051 $usces->set_member_meta_value( 'zeus_pcid', '8888888888888882' );
6052 }
6053 $this->send_update_settlement_mail();
6054 } else {
6055 $err_code = $this->get_err_code( $page );
6056 $usces->error_message .= __( 'failure in update', 'usces' );
6057 }
6058
6059 if ( '' !== $message ) {
6060 $script .= "
6061 <script type=\"text/javascript\">
6062 jQuery.event.add(window,'load',function() {
6063 alert('" . $message . "');
6064 });
6065 </script>";
6066 }
6067 }
6068 }
6069 }
6070 $error_message = apply_filters( 'usces_filter_member_update_settlement_error_message', $usces->error_message );
6071
6072 ob_start();
6073 get_header();
6074 ?>
6075 <div id="content" class="two-column">
6076 <div class="catbox">
6077 <?php
6078 if ( have_posts() ) :
6079 usces_remove_filter();
6080 ?>
6081 <div class="post" id="wc_member_update_settlement">
6082 <?php if ( $register ) : ?>
6083 <h1 class="member_page_title"><?php esc_html_e( 'Credit card registration', 'usces' ); ?></h1>
6084 <?php else : ?>
6085 <h1 class="member_page_title"><?php esc_html_e( 'Credit card update', 'usces' ); ?></h1>
6086 <?php endif; ?>
6087 <div class="entry">
6088 <div id="memberpages">
6089 <div class="whitebox">
6090 <div id="memberinfo">
6091 <div class="header_explanation">
6092 <?php do_action( 'usces_action_member_update_settlement_page_header' ); ?>
6093 </div>
6094 <div class="error_message"><?php echo wp_kses_post( $error_message ); ?></div>
6095 <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;}">
6096 <input type="hidden" name="acting" value="<?php echo esc_attr( $this->paymod_id ); ?>">
6097 <table class="customer_form" id="<?php echo esc_attr( $this->paymod_id ); ?>">
6098 <tr><th scope="row"><?php esc_html_e( 'Credit card information', 'usces' ); ?></th><td id="zeus_token_card_info_area"></td></tr>
6099 </table>
6100 <div class="send">
6101 <?php if ( $register ) : ?>
6102 <input type="hidden" name="zeus_card_update" value="register" />
6103 <input type="button" id="card-register" class="card-update" value="<?php esc_attr_e( 'Register' ); ?>" />
6104 <?php else : ?>
6105 <input type="hidden" name="zeus_card_update" value="update" />
6106 <input type="button" id="card-update" class="card-update" value="<?php esc_attr_e( 'update it', 'usces' ); ?>" />
6107 <?php endif; ?>
6108 <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 ); ?>'" />
6109 <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() ); ?>'" />
6110 </div>
6111 <?php do_action( 'usces_action_member_update_settlement_page_inform' ); ?>
6112 <?php wp_nonce_field( 'member_update_settlement', 'wc_nonce' ); ?>
6113 </form>
6114 <div class="footer_explanation">
6115 <?php do_action( 'usces_action_member_update_settlement_page_footer' ); ?>
6116 </div>
6117 </div><!-- end of memberinfo -->
6118 </div><!-- end of whitebox -->
6119 </div><!-- end of memberpages -->
6120 </div><!-- end of entry -->
6121 </div><!-- end of post -->
6122 <?php else : ?>
6123 <p><?php esc_html_e( 'Sorry, no posts matched your criteria.', 'usces' ); ?></p>
6124 <?php endif; ?>
6125 </div><!-- end of catbox -->
6126 </div><!-- end of content -->
6127 <?php
6128 if ( '' !== $script ) {
6129 echo $script; // no escape due to script.
6130 }
6131 $sidebar = apply_filters( 'usces_filter_member_update_settlement_page_sidebar', 'cartmember' );
6132 if ( ! empty( $sidebar ) ) {
6133 get_sidebar( $sidebar );
6134 }
6135
6136 get_footer();
6137 $form = ob_get_contents();
6138 ob_end_clean();
6139
6140 echo $form; // no escape.
6141 }
6142
6143 /**
6144 * クレジットカード変更メール
6145 */
6146 public function send_update_settlement_mail() {
6147 global $usces;
6148
6149 $member = $usces->get_member();
6150
6151 $subject = apply_filters( 'usces_filter_send_update_settlement_mail_subject', __( 'Confirmation of credit card update', 'usces' ), $member );
6152 $mail_header = __( 'Your credit card information has been updated on the membership page.', 'usces' ) . "\r\n\r\n";
6153 $mail_footer = get_option( 'blogname' ) . "\r\n";
6154 $name = usces_localized_name( $member['name1'], $member['name2'], 'return' );
6155 $to_name = sprintf( _x( '%s', 'honorific', 'usces' ), $name );
6156
6157 $message = '--------------------------------' . "\r\n";
6158 $message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
6159 $message .= __( 'Name', 'usces' ) . ' : ' . $to_name . "\r\n";
6160 $message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
6161 $message .= '--------------------------------' . "\r\n\r\n";
6162 $message .= __( 'If you have not requested this email, sorry to trouble you, but please contact us.', 'usces' ) . "\r\n\r\n";
6163 $message = apply_filters( 'usces_filter_send_update_settlement_mail_message', $message, $member );
6164 $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";
6165 $message = sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n" . $message;
6166
6167 $send_para = array(
6168 'to_name' => $to_name,
6169 'to_address' => $member['mailaddress1'],
6170 'from_name' => get_option( 'blogname' ),
6171 'from_address' => $usces->options['sender_mail'],
6172 'reply_name' => get_option( 'blogname' ),
6173 'reply_to' => usces_get_first_order_mail(),
6174 'return_path' => $usces->options['sender_mail'],
6175 'subject' => $subject,
6176 'message' => do_shortcode( $message ),
6177 );
6178 usces_send_mail( $send_para );
6179
6180 $admin_message = $mail_header;
6181 $admin_message .= '--------------------------------' . "\r\n";
6182 $admin_message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
6183 $admin_message .= __( 'Name', 'usces' ) . ' : ' . $to_name . "\r\n";
6184 $admin_message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
6185 $admin_message .= '--------------------------------' . "\r\n\r\n";
6186 if ( usces_have_member_continue_order( $member['ID'] ) ) {
6187 $admin_message .= $this->message_continue_order( $member['ID'] );
6188 }
6189 if ( usces_have_member_regular_order( $member['ID'] ) ) {
6190 $admin_message .= $this->message_regular_order( $member['ID'] );
6191 }
6192 $admin_message .=
6193 "\r\n----------------------------------------------------\r\n" .
6194 'REMOTE_ADDR : ' . $_SERVER['REMOTE_ADDR'] .
6195 "\r\n----------------------------------------------------\r\n";
6196
6197 $admin_para = array(
6198 'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
6199 'to_address' => $usces->options['order_mail'],
6200 'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
6201 'from_address' => $usces->options['sender_mail'],
6202 'reply_name' => get_option( 'blogname' ),
6203 'reply_to' => usces_get_first_order_mail(),
6204 'return_path' => $usces->options['sender_mail'],
6205 'subject' => $subject . '( ' . $to_name . ' )',
6206 'message' => do_shortcode( $admin_message ),
6207 );
6208 usces_send_mail( $admin_para );
6209 }
6210
6211 /**
6212 * 契約中の自動継続課金�
6213
6214 *
6215 * @param int $member_id Member ID.
6216 */
6217 public function message_continue_order( $member_id ) {
6218 global $usces, $wpdb;
6219 $message = '';
6220
6221 $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' );
6222 $continue_order = $wpdb->get_results( $query, ARRAY_A );
6223 if ( 0 < count( $continue_order ) ) {
6224 $message .= '--------------------------------' . "\r\n";
6225 $message .= __( 'Auto-continuation charging Information under Contract with a credit card', 'usces' ) . "\r\n";
6226 foreach ( $continue_order as $continue_data ) {
6227 $con_id = $continue_data['con_id'];
6228 $con_order_id = $continue_data['con_order_id'];
6229 $message .= __( 'Order number', 'usces' ) . ' : ' . $con_order_id;
6230 $latest_log = $this->get_acting_latest_log( $con_order_id, 0, 'ALL' );
6231 if ( ! empty( $latest_log ) ) {
6232 $next_charging = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_charging( $con_order_id ) : $continue_data['con_next_contracting'];
6233 $message .= ' ( ' . __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $next_charging ) );
6234 if ( 0 < (int) $continue_data['con_interval'] ) {
6235 $next_contracting = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_contracting( $con_order_id ) : $continue_data['con_next_contracting'];
6236 $message .= ', ' . __( 'Renewal Date', 'dlseller' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $next_contracting ) );
6237 }
6238 $message .= ' )';
6239 if ( isset( $latest_log['result'] ) && 'OK' !== $latest_log['result'] ) {
6240 $message .= ' ' . __( 'Condition', 'dlseller' ) . ' : ' . __( 'Settlement error', 'usces' );
6241 if ( ! empty( $latest_log['tracking_id'] ) ) {
6242 $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $latest_log['tracking_id'] . ' )';
6243 }
6244 }
6245 }
6246 $message .= "\r\n";
6247 }
6248 $message .= '--------------------------------' . "\r\n\r\n";
6249 }
6250 return $message;
6251 }
6252
6253 /**
6254 * 契約中の定期購�
6255 ��
6256
6257 *
6258 * @param int $member_id Member ID.
6259 */
6260 public function message_regular_order( $member_id ) {
6261 global $usces, $wpdb;
6262 $message = '';
6263
6264 $query_order = $wpdb->prepare(
6265 "SELECT r.reg_id, r.reg_payment_name, d.regdet_schedule_date
6266 FROM {$wpdb->prefix}usces_regular_detail AS `d`
6267 RIGHT JOIN {$wpdb->prefix}usces_regular AS `r` ON r.reg_id = d.reg_id
6268 WHERE r.reg_mem_id = %d AND d.regdet_condition = 'continuation'
6269 GROUP BY r.reg_id",
6270 $member_id
6271 );
6272 $regular_order = $wpdb->get_results( $query_order, ARRAY_A );
6273 if ( 0 < count( $regular_order ) ) {
6274 foreach ( $regular_order as $regular_data ) {
6275 $acting_flg = $this->get_acting_flg( $regular_data['reg_payment_name'] );
6276 if ( 'acting_zeus_card' !== $acting_flg ) {
6277 continue;
6278 }
6279 $reg_id = $regular_data['reg_id'];
6280 $query = $wpdb->prepare(
6281 "SELECT o.ID AS `order_id`, meta.meta_value AS `deco_id`, DATE_FORMAT( o.order_date, %s ) AS `order_date`
6282 FROM {$wpdb->prefix}usces_order AS `o`
6283 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta` ON o.ID = meta.order_id AND meta.meta_key = 'dec_order_id'
6284 LEFT JOIN {$wpdb->prefix}usces_regular ON o.ID = `reg_order_id`
6285 WHERE `reg_id` = %d
6286 UNION ALL
6287 SELECT o1.ID AS `order_id`, meta1.meta_value AS `deco_id`, DATE_FORMAT( o1.order_date, %s ) AS `order_date`
6288 FROM {$wpdb->prefix}usces_order AS `o1`
6289 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta1` ON o1.ID = meta1.order_id AND meta1.meta_key = 'dec_order_id'
6290 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta2` ON o1.ID = meta2.order_id AND meta2.meta_key = 'regular_id'
6291 WHERE meta2.meta_value = %d
6292 ORDER BY `order_id` DESC, `order_date` DESC",
6293 '%Y-%m-%d',
6294 $reg_id,
6295 '%Y-%m-%d',
6296 $reg_id
6297 );
6298 $regular_order_data = $wpdb->get_results( $query, ARRAY_A );
6299 if ( 0 < count( $regular_order_data ) ) {
6300 $message .= __( 'Regular ID', 'autodelivery' ) . ' : ' . $reg_id;
6301 $reg_order_id = $regular_order_data[0]['order_id'];
6302 $latest_log = $this->get_acting_latest_log( $reg_order_id, 0, 'ALL' );
6303 if ( isset( $latest_log['result'] ) && 'OK' !== $latest_log['result'] ) {
6304 $message .= ' ' . __( 'Condition', 'autodelivery' ) . ' : ' . __( 'Settlement error', 'usces' );
6305 $trans_id = $usces->get_order_meta_value( 'trans_id', $reg_order_id );
6306 if ( $trans_id ) {
6307 $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $trans_id . ' )';
6308 }
6309 } else {
6310 if ( $this->isdate( $regular_data['regdet_schedule_date'] ) ) {
6311 $message .= ' ( ' . __( 'Scheduled order date', 'autodelivery' ) . ' : ' . date_i18n( __( 'Y/m/d' ), strtotime( $regular_data['regdet_schedule_date'] ) ) . ' )';
6312 }
6313 }
6314 $message .= "\r\n";
6315 }
6316 }
6317 if ( '' !== $message ) {
6318 $message = '--------------------------------' . "\r\n"
6319 . __( 'Subscription Information under Contract with a credit card', 'usces' ) . "\r\n"
6320 . $message
6321 . '--------------------------------' . "\r\n\r\n";
6322 }
6323 }
6324 return $message;
6325 }
6326
6327 /**
6328 * 日付チェック
6329 *
6330 * @param object $date DateTime.
6331 * @return boolean
6332 */
6333 private function isdate( $date ) {
6334 if ( empty( $date ) ) {
6335 return false;
6336 }
6337 try {
6338 new DateTime( $date );
6339 list( $year, $month, $day ) = explode( '-', $date );
6340 $res = checkdate( (int) $month, (int) $day, (int) $year );
6341 return $res;
6342 } catch ( Exception $e ) {
6343 return false;
6344 }
6345 }
6346
6347 /**
6348 * 会員データ削除チェック
6349 * usces_filter_delete_member_check
6350 *
6351 * @param bool $del Deletable.
6352 * @param int $member_id Member ID.
6353 * @return bool
6354 */
6355 public function delete_member_check( $del, $member_id ) {
6356 if ( usces_have_member_continue_order( $member_id ) || usces_have_member_regular_order( $member_id ) ) {
6357 $del = false;
6358 }
6359 return $del;
6360 }
6361
6362 /**
6363 * 利用可能な支払方法(継続課金・定期購�
6364 �)
6365 * dlseller_filter_the_payment_method_restriction
6366 * wcad_filter_the_payment_method_restriction
6367 *
6368 * @param array $payments_restriction Payment method.
6369 * @param string $value Input value.
6370 * @return array
6371 */
6372 public function payment_method_restriction( $payments_restriction, $value ) {
6373 if ( ( usces_have_regular_order() || usces_have_continue_charge() ) && usces_is_login() ) {
6374 $zeus_card = false;
6375 foreach ( (array) $payments_restriction as $key => $payment ) {
6376 if ( isset( $payment['settlement'] ) && 'acting_zeus_card' === $payment['settlement'] ) {
6377 $zeus_card = true;
6378 }
6379 }
6380 if ( ! $zeus_card ) {
6381 $payments = usces_get_system_option( 'usces_payment_method', 'settlement' );
6382 $payments_restriction[] = $payments['acting_zeus_card'];
6383 }
6384 $sort = array();
6385 foreach ( (array) $payments_restriction as $key => $payment ) {
6386 $sort[ $key ] = $payment['sort'];
6387 }
6388 array_multisort( $sort, SORT_ASC, $payments_restriction );
6389 }
6390 return $payments_restriction;
6391 }
6392
6393 /**
6394 * 利用可能な支払方法
6395 * usces_filter_the_continue_payment_method
6396 *
6397 * @param array $payment_method Payment method.
6398 * @return array
6399 */
6400 public function continuation_payment_method( $payment_method ) {
6401 if ( ! array_key_exists( 'acting_zeus_card', $payment_method ) ) {
6402 $payment_method[] = 'acting_zeus_card';
6403 }
6404 return $payment_method;
6405 }
6406
6407 /**
6408 * 「初回引落し日」
6409 * dlseller_filter_first_charging
6410 *
6411 * @param object $time Datetime.
6412 * @param int $post_id Post ID.
6413 * @param array $usces_item Item data.
6414 * @param int $order_id Order number.
6415 * @param array $continue_data Continuation data.
6416 * @return object
6417 */
6418 public function first_charging_date( $time, $post_id, $usces_item, $order_id, $continue_data ) {
6419 if ( 99 === (int) $usces_item['item_chargingday'] ) {
6420 if ( empty( $order_id ) ) {
6421 $today = date_i18n( 'Y-m-d', current_time( 'timestamp' ) );
6422 list( $year, $month, $day ) = explode( '-', $today );
6423 $time = mktime( 0, 0, 0, (int) $month, (int) $day, (int) $year );
6424 }
6425 }
6426 return $time;
6427 }
6428
6429 /**
6430 * 継続課金会員リスト「状�
6431 �」
6432 * dlseller_filter_continue_member_list_condition
6433 *
6434 * @param string $condition Continuation condition.
6435 * @param int $member_id Member ID.
6436 * @param int $order_id Order number.
6437 * @param array $continue_data Continuation data.
6438 * @return string
6439 */
6440 public function continue_member_list_condition( $condition, $member_id, $order_id, $continue_data ) {
6441 if ( isset( $continue_data['acting'] ) && 'acting_zeus_card' === $continue_data['acting'] ) {
6442 $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 ) );
6443 $condition = '<a href="' . $url . '">' . __( 'Detail', 'usces' ) . '</a>';
6444 if ( 'continuation' === $continue_data['status'] ) {
6445 $latest_log = $this->get_acting_latest_log( $order_id, 0, 'ALL' );
6446 if ( isset( $latest_log['result'] ) && ! in_array( $latest_log['result'], $this->payment_normal_results, true ) ) {
6447 $condition .= '<div class="acting-status zeus-error">' . __( 'Settlement error', 'usces' ) . '</div>';
6448 }
6449 }
6450 }
6451 return $condition;
6452 }
6453
6454 /**
6455 * 継続課金会員決済状況ページ表示
6456 * dlseller_action_continue_member_list_page
6457 *
6458 * @param string $continue_action Continuation action.
6459 */
6460 public function continue_member_list_page( $continue_action ) {
6461 if ( 'settlement_zeus_card' === $continue_action ) {
6462 $member_id = filter_input( INPUT_GET, 'member_id' );
6463 $order_id = filter_input( INPUT_GET, 'order_id' );
6464 if ( ! empty( $member_id ) && ! empty( $order_id ) ) {
6465 $this->continue_member_settlement_info_page( $member_id, $order_id );
6466 exit();
6467 }
6468 }
6469 }
6470
6471 /**
6472 * 継続課金会員決済詳細ページ
6473 *
6474 * @param int $member_id Member ID.
6475 * @param int $order_id Order number.
6476 */
6477 public function continue_member_settlement_info_page( $member_id, $order_id ) {
6478 global $usces;
6479
6480 $order_data = $usces->get_order_data( $order_id, 'direct' );
6481 if ( ! $order_data ) {
6482 return;
6483 }
6484
6485 $acting_flg = $this->get_acting_flg( $order_data['order_payment_name'] );
6486 if ( 'acting_zeus_card' !== $acting_flg ) {
6487 return;
6488 }
6489
6490 $continue_data = $this->get_continuation_data( $member_id, $order_id );
6491 if ( 'acting_zeus_card' !== $continue_data['acting'] ) {
6492 return;
6493 }
6494
6495 $con_id = $continue_data['con_id'];
6496 $curent_url = $_SERVER['REQUEST_URI'];
6497
6498 $member_info = $usces->get_member_info( $member_id );
6499 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
6500
6501 $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
6502 if ( ! empty( $contracted_date ) ) {
6503 list( $contracted_year, $contracted_month, $contracted_day ) = explode( '-', $contracted_date );
6504 } else {
6505 $contracted_year = 0;
6506 $contracted_month = 0;
6507 $contracted_day = 0;
6508 }
6509 $charged_date = ( empty( $continue_data['chargedday'] ) ) ? dlseller_next_charging( $order_id ) : $continue_data['chargedday'];
6510 if ( ! empty( $charged_date ) ) {
6511 list( $charged_year, $charged_month, $charged_day ) = explode( '-', $charged_date );
6512 } else {
6513 $charged_year = 0;
6514 $charged_month = 0;
6515 $charged_day = 0;
6516 }
6517 $this_year = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 4 );
6518
6519 $log_data = $this->get_acting_log( $order_id, 0, 'ALL' );
6520 $num = ( $log_data ) ? count( $log_data ) : 1;
6521 ?>
6522 <div class="wrap">
6523 <div class="usces_admin">
6524 <h1>Welcart Management <?php esc_html_e( 'Continuation charging member information', 'dlseller' ); ?></h1>
6525 <p class="version_info">Version <?php echo esc_html( WCEX_DLSELLER_VERSION ); ?></p>
6526 <?php usces_admin_action_status(); ?>
6527 <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>
6528 <div id="datatable">
6529 <div id="tablesearch" class="usces_tablesearch">
6530 <div id="searchBox" style="display:block">
6531 <table class="search_table">
6532 <tr>
6533 <td class="label"><?php esc_html_e( 'Continuation charging information', 'dlseller' ); ?></td>
6534 <td>
6535 <table class="order_info">
6536 <tr>
6537 <th><?php esc_html_e( 'Member ID', 'dlseller' ); ?></th>
6538 <td><?php echo esc_html( $member_id ); ?></td>
6539 <th><?php esc_html_e( 'Contractor name', 'dlseller' ); ?></th>
6540 <td><?php echo esc_html( $name ); ?></td>
6541 </tr>
6542 <tr>
6543 <th><?php esc_html_e( 'Order ID', 'dlseller' ); ?></th>
6544 <td><?php echo esc_html( $order_id ); ?></td>
6545 <th><?php esc_html_e( 'Application Date', 'dlseller' ); ?></th>
6546 <td><?php echo esc_html( $order_data['order_date'] ); ?></td>
6547 </tr>
6548 <tr>
6549 <th><?php esc_html_e( 'Renewal Date', 'dlseller' ); ?></th>
6550 <td>
6551 <?php
6552 echo '<select id="contracted-year">';
6553 echo '<option value="0"' . selected( (int) $contracted_year, 0, false ) . '></option>';
6554 for ( $i = 0; $i <= 10; $i++ ) {
6555 $year = (int) $this_year + $i;
6556 echo '<option value="' . esc_html( $year ) . '"' . selected( (int) $contracted_year, $year, false ) . '>' . esc_html( $year ) . '</option>';
6557 }
6558 echo '</select>-<select id="contracted-month">';
6559 echo '<option value="0"' . selected( (int) $contracted_month, 0, false ) . '></option>';
6560 for ( $i = 1; $i <= 12; $i++ ) {
6561 $month = sprintf( '%02d', $i );
6562 echo '<option value="' . esc_html( $month ) . '"' . selected( (int) $contracted_month, $i, false ) . '>' . esc_html( $month ) . '</option>';
6563 }
6564 echo '</select>-<select id="contracted-day">';
6565 echo '<option value="0"' . selected( (int) $contracted_day, 0, false ) . '></option>';
6566 for ( $i = 1; $i <= 31; $i++ ) {
6567 $day = sprintf( '%02d', $i );
6568 echo '<option value="' . esc_html( $day ) . '"' . selected( (int) $contracted_day, $i, false ) . '>' . esc_html( $day ) . '</option>';
6569 }
6570 echo '</select>';
6571 ?>
6572 </td>
6573 <th><?php esc_html_e( 'Next Withdrawal Date', 'dlseller' ); ?></th>
6574 <td>
6575 <?php
6576 echo '<select id="charged-year">';
6577 echo '<option value="0"' . selected( (int) $charged_year, 0, false ) . '></option>';
6578 echo '<option value="' . esc_html( $this_year ) . '"' . selected( (int) $charged_year, $this_year, false ) . '>' . esc_html( $this_year ) . '</option>';
6579 $next_year = (int) $this_year + 1;
6580 echo '<option value="' . esc_html( $next_year ) . '"' . selected( (int) $charged_year, $next_year, false ) . '>' . esc_html( $next_year ) . '</option>';
6581 echo '</select>-<select id="charged-month">';
6582 echo '<option value="0"' . selected( (int) $charged_month, 0, false ) . '></option>';
6583 for ( $i = 1; $i <= 12; $i++ ) {
6584 $month = sprintf( '%02d', $i );
6585 echo '<option value="' . esc_html( $month ) . '"' . selected( (int) $charged_month, $i, false ) . '>' . esc_html( $month ) . '</option>';
6586 }
6587 echo '</select>-<select id="charged-day">';
6588 echo '<option value="0"' . selected( (int) $charged_day, 0, false ) . '></option>';
6589 for ( $i = 1; $i <= 31; $i++ ) {
6590 $day = sprintf( '%02d', $i );
6591 echo '<option value="' . esc_html( $day ) . '"' . selected( (int) $charged_day, $i, false ) . '>' . esc_html( $day ) . '</option>';
6592 }
6593 echo '</select>';
6594 ?>
6595 </td>
6596 </tr>
6597 <tr>
6598 <th><?php esc_html_e( 'Amount on order', 'usces' ); ?></th>
6599 <td><?php usces_crform( $continue_data['order_price'], false ); ?></td>
6600 <th><?php esc_html_e( 'Transaction amount', 'usces' ); ?></th>
6601 <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>
6602 </tr>
6603 <tr>
6604 <th><?php esc_html_e( 'Status', 'dlseller' ); ?></th>
6605 <td><select id="dlseller-status">
6606 <?php ob_start(); ?>
6607 <?php if ( 'continuation' === $continue_data['status'] ) : ?>
6608 <option value="continuation" selected><?php esc_html_e( 'Continuation', 'dlseller' ); ?></option>
6609 <option value="cancellation"><?php esc_html_e( 'Stop', 'dlseller' ); ?></option>
6610 <?php else : ?>
6611 <option value="cancellation" selected><?php esc_html_e( 'Cancellation', 'dlseller' ); ?></option>
6612 <option value="continuation"><?php esc_html_e( 'Resumption', 'dlseller' ); ?></option>
6613 <?php endif; ?>
6614 <?php
6615 $dlseller_status_options = ob_get_contents();
6616 ob_end_clean();
6617 $dlseller_status_options = apply_filters( 'usces_filter_continuation_charging_status_options', $dlseller_status_options, $continue_data );
6618 wel_esc_script_e( $dlseller_status_options );
6619 ?>
6620 </select></td>
6621 <td colspan="2"><input id="continuation-update" type="button" class="button button-primary" value="<?php esc_attr_e( 'Update' ); ?>" /></td>
6622 </tr>
6623 </table>
6624 <?php do_action( 'usces_action_continuation_charging_information', $continue_data, $member_id, $order_id ); ?>
6625 </td>
6626 </tr>
6627 </table>
6628 </div><!-- searchBox -->
6629 </div><!-- tablesearch -->
6630 <table id="mainDataTable" class="new-table order-new-table">
6631 <thead>
6632 <tr>
6633 <th scope="col">&nbsp;</th>
6634 <th scope="col"><?php esc_html_e( 'Processing date', 'usces' ); ?></th>
6635 <th scope="col">オーダーNo</th>
6636 <th scope="col"><?php esc_html_e( 'Settlement amount', 'usces' ); ?></th>
6637 <th scope="col"><?php esc_html_e( 'Processing classification', 'usces' ); ?></th>
6638 <th scope="col">&nbsp;</th>
6639 </tr>
6640 </thead>
6641 <?php
6642 foreach ( (array) $log_data as $data ) :
6643 $log = usces_unserialize( $data['log'] );
6644 $order_no = $this->get_order_no( $log );
6645 $tracking_id = $data['tracking_id'];
6646 $status = $this->get_acting_status( $order_id, $tracking_id, 'ALL' );
6647 $class = ' card-' . $status;
6648 $status_name = $this->get_status_name( $status );
6649 $amount = usces_crform( $data['amount'], false, true, 'return', true );
6650 ?>
6651 <tbody>
6652 <tr>
6653 <td><?php echo esc_html( $num ); ?></td>
6654 <td><?php echo esc_html( $data['datetime'] ); ?></td>
6655 <td><?php echo esc_html( $order_no ); ?></td>
6656 <td class="amount"><?php echo esc_attr( $amount ); ?></td>
6657 <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>
6658 <td>
6659 <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' ); ?>">
6660 </td>
6661 </tr>
6662 </tbody>
6663 <?php
6664 $num--;
6665 endforeach;
6666 ?>
6667 </table>
6668 </div><!--datatable-->
6669 <input name="member_id" type="hidden" id="member_id" value="<?php echo esc_attr( $member_id ); ?>" />
6670 <input name="order_id" type="hidden" id="order_id" value="<?php echo esc_attr( $order_id ); ?>" />
6671 <input name="con_id" type="hidden" id="con_id" value="<?php echo esc_attr( $con_id ); ?>" />
6672 <input name="usces_referer" type="hidden" id="usces_referer" value="<?php echo esc_url( $curent_url ); ?>" />
6673 <?php wp_nonce_field( 'order_edit', 'wc_nonce' ); ?>
6674 </div><!--usces_admin-->
6675 </div><!--wrap-->
6676 <?php
6677 $order_action = 'edit';
6678 $cart = array();
6679 $action_args = compact( 'order_action', 'order_id', 'cart' );
6680 $this->settlement_dialog( $order_data, $action_args );
6681 include ABSPATH . 'wp-admin/admin-footer.php';
6682 }
6683
6684 /**
6685 * 自動継続課金処理
6686 * dlseller_action_do_continuation_charging
6687 *
6688 * @param string $today Today.
6689 * @param int $member_id Member ID.
6690 * @param int $order_id Order number.
6691 * @param array $continue_data Continuation data.
6692 */
6693 public function auto_continuation_charging( $today, $member_id, $order_id, $continue_data ) {
6694 global $usces;
6695
6696 if ( ! usces_is_membersystem_state() || 0 >= $continue_data['price'] || 'acting_zeus_card' !== $continue_data['acting'] ) {
6697 return;
6698 }
6699
6700 $order_data = $usces->get_order_data( $order_id, 'direct' );
6701 if ( ! $order_data || $usces->is_status( 'cancel', $order_data['order_status'] ) ) {
6702 return;
6703 }
6704
6705 $acting_opts = $this->get_acting_settings();
6706 if ( 'on' !== $acting_opts['quickcharge'] || 'on' !== $acting_opts['batch'] ) {
6707 return;
6708 }
6709
6710 $tracking_id = usces_acting_key();
6711 $amount = usces_crform( $continue_data['price'], false, false, 'return', false );
6712
6713 $params = array();
6714 $params['clientip'] = $acting_opts['clientip'];
6715 $params['cardnumber'] = '9999999999999992';
6716 $params['expyy'] = '00';
6717 $params['expmm'] = '00';
6718 $params['money'] = $amount;
6719 $params['send'] = 'mall';
6720 $params['telno'] = '0000000000';
6721 $params['email'] = $this->get_email( $order_id );
6722 $params['sendid'] = $member_id;
6723 $params['sendpoint'] = $tracking_id;
6724 $params['pubsec'] = 'yes';
6725 $params['printord'] = 'yes';
6726
6727 $page = $this->secure_link_batch( $acting_opts['card_url'], $params );
6728 if ( false !== strpos( $page, 'Success_order' ) ) {
6729 $status = 'OK';
6730 $data = array( 'result' => 'OK' );
6731 $new_order_no = $this->get_order_number( $page );
6732 if ( ! empty( $new_order_no ) ) {
6733 $order_ref = wel_zeus_get_order_ref( $new_order_no );
6734 if ( 'payment' === $order_ref['status'] || 'auth' === $order_ref['status'] ) {
6735 $order_ref = apply_filters( 'usces_filter_zeus_card_auto_continuation_charging_log', $order_ref, $order_id, $tracking_id );
6736 wel_zeus_save_acting_log( $order_ref, 'zeus_card', $order_ref['status'], $status, $order_id, $tracking_id );
6737 $this->auto_settlement_mail( $member_id, $order_id, $data, $continue_data );
6738 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $order_ref );
6739 } else {
6740 if ( ! isset( $params['ordd'] ) ) {
6741 $params['ordd'] = $new_order_no;
6742 }
6743 $params = apply_filters( 'usces_filter_zeus_card_auto_continuation_charging_log', $params, $order_id, $tracking_id );
6744 wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
6745 $this->auto_settlement_mail( $member_id, $order_id, $data, $continue_data );
6746 $order_ref = wel_zeus_get_order_ref( $new_order_no );
6747 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $params );
6748 }
6749 } else {
6750 $params = apply_filters( 'usces_filter_zeus_card_auto_continuation_charging_log', $params, $order_id, $tracking_id );
6751 wel_zeus_save_acting_log( $params, 'zeus_card', 'payment', $status, $order_id, $tracking_id );
6752 $this->auto_settlement_mail( $member_id, $order_id, $data, $continue_data );
6753 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $params );
6754 }
6755 } else {
6756 $status = $this->get_error_results( $page );
6757 if ( empty( $status ) ) {
6758 $status = 'ERROR';
6759 }
6760 $data = explode( "\r\n", $page );
6761 $log = array(
6762 'acting' => 'zeus_card',
6763 'key' => $tracking_id,
6764 'result' => $status,
6765 'data' => $data,
6766 );
6767 usces_save_order_acting_error( $log );
6768 wel_zeus_save_acting_log( $data, 'zeus_card', 'dlseller', $status, $order_id, $tracking_id );
6769 $this->auto_settlement_error_mail( $member_id, $order_id, array( 'result' => $status ), $continue_data );
6770 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $data );
6771 }
6772 }
6773
6774 /**
6775 * 自動継続課金処理メール(正常)
6776 *
6777 * @param int $member_id Member ID.
6778 * @param int $order_id Order number.
6779 * @param array $response_data Response data.
6780 * @param array $continue_data Continuation data.
6781 */
6782 public function auto_settlement_mail( $member_id, $order_id, $response_data, $continue_data ) {
6783 global $usces;
6784
6785 $acting_opts = $this->get_acting_settings();
6786 $order_data = $usces->get_order_data( $order_id, 'direct' );
6787 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data, false );
6788
6789 if ( 'on' === $acting_opts['auto_settlement_mail'] ) {
6790 $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 );
6791 $member_info = $usces->get_member_info( $member_id );
6792 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
6793 $mail_data = usces_mail_data();
6794 $mail_header = '';
6795 if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
6796 $mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
6797 }
6798 $mail_header .= __( 'We will report automated accounting process was carried out as follows.', 'usces' ) . "\r\n\r\n";
6799 $mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
6800 $message = apply_filters( 'usces_filter_zeus_auto_settlement_mail_header', $mail_header, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
6801 apply_filters( 'usces_filter_zeus_auto_settlement_mail_body', $mail_body, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
6802 apply_filters( 'usces_filter_zeus_auto_settlement_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $response_data, $continue_data );
6803 $headers = apply_filters( 'usces_filter_zeus_auto_settlement_mail_headers', '' );
6804 $to_customer = array(
6805 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
6806 'to_address' => $member_info['mem_email'],
6807 'from_name' => get_option( 'blogname' ),
6808 'from_address' => $usces->options['sender_mail'],
6809 'reply_name' => get_option( 'blogname' ),
6810 'reply_to' => usces_get_first_order_mail(),
6811 'return_path' => $usces->options['sender_mail'],
6812 'subject' => $subject,
6813 'message' => do_shortcode( $message ),
6814 'headers' => $headers,
6815 );
6816 usces_send_mail( $to_customer );
6817 }
6818
6819 $ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
6820 $this->continuation_charging_mail['OK'] = $ok + 1;
6821 $this->continuation_charging_mail['mail'][] = $mail_body;
6822 }
6823
6824 /**
6825 * 自動継続課金処理メール(エラー)
6826 *
6827 * @param int $member_id Member ID.
6828 * @param int $order_id Order number.
6829 * @param array $response_data Response data.
6830 * @param array $continue_data Continuation data.
6831 */
6832 public function auto_settlement_error_mail( $member_id, $order_id, $response_data, $continue_data ) {
6833 global $usces;
6834
6835 $acting_opts = $this->get_acting_settings();
6836 $order_data = $usces->get_order_data( $order_id, 'direct' );
6837 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $response_data, $continue_data, false );
6838
6839 if ( 'on' === $acting_opts['auto_settlement_mail'] ) {
6840 $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 );
6841 $member_info = $usces->get_member_info( $member_id );
6842 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
6843 $mail_data = usces_mail_data();
6844 $mail_header = '';
6845 if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
6846 $mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
6847 }
6848 $mail_header .= __( 'We will reported that an error occurred in automated accounting process.', 'usces' ) . "\r\n\r\n";
6849 $mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
6850 $message = apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_header', $mail_header, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
6851 apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_body', $mail_body, $member_id, $order_id, $order_data, $response_data, $continue_data ) .
6852 apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $response_data, $continue_data );
6853 $headers = apply_filters( 'usces_filter_zeus_auto_settlement_error_mail_headers', '' );
6854 $to_customer = array(
6855 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
6856 'to_address' => $member_info['mem_email'],
6857 'from_name' => get_option( 'blogname' ),
6858 'from_address' => $usces->options['sender_mail'],
6859 'reply_name' => get_option( 'blogname' ),
6860 'reply_to' => usces_get_first_order_mail(),
6861 'return_path' => $usces->options['sender_mail'],
6862 'subject' => $subject,
6863 'message' => do_shortcode( $message ),
6864 'headers' => $headers,
6865 );
6866 usces_send_mail( $to_customer );
6867 }
6868
6869 $error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
6870 $this->continuation_charging_mail['NG'] = $error + 1;
6871 $this->continuation_charging_mail['mail'][] = $mail_body;
6872 }
6873
6874 /**
6875 * 自動継続課金処理メール本文
6876 *
6877 * @param int $member_id Member ID.
6878 * @param int $order_id Order number.
6879 * @param array $order_data Order data.
6880 * @param array $data Response data.
6881 * @param array $continue_data Continuation data.
6882 * @param boolean $html HTML mail.
6883 * @return string
6884 */
6885 public function auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data, $html = true ) {
6886 global $usces;
6887
6888 $member_info = $usces->get_member_info( $member_id );
6889 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
6890 $contracted_date = ( isset( $continue_data['contractedday'] ) ) ? $continue_data['contractedday'] : '';
6891 $charged_date = ( isset( $continue_data['chargedday'] ) ) ? $continue_data['chargedday'] : '';
6892
6893 $cart = usces_get_ordercartdata( $order_id );
6894 if ( is_array( $cart ) && 0 < count( $cart ) ) {
6895 $cart_row = current( $cart );
6896 $item_name = $usces->getCartItemName_byOrder( $cart_row );
6897 $options = ( isset( $cart_row['options'] ) ) ? $cart_row['options'] : array();
6898 }
6899
6900 if ( usces_is_html_mail() && $html ) {
6901 $message = '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;"><tbody>';
6902 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6903 $message .= __( 'Order ID', 'dlseller' );
6904 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6905 $message .= $order_id;
6906 $message .= '</td></tr>';
6907
6908 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6909 $message .= __( 'Application Date', 'dlseller' );
6910 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6911 $message .= $order_data['order_date'];
6912 $message .= '</td></tr>';
6913
6914 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6915 $message .= __( 'Member ID', 'dlseller' );
6916 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6917 $message .= $member_id;
6918 $message .= '</td></tr>';
6919
6920 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6921 $message .= __( 'Contractor name', 'dlseller' );
6922 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6923 $message .= sprintf( _x( '%s', 'honorific', 'usces' ), $name );
6924 $message .= '</td></tr>';
6925 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6926 $message .= __( 'Items', 'usces' );
6927 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6928 $message .= $item_name;
6929 if ( is_array( $options ) && 0 < count( $options ) ) {
6930 $optstr = '';
6931 foreach ( $options as $key => $value ) {
6932 if ( ! empty( $key ) ) {
6933 $key = urldecode( $key );
6934 $value = wel_safe_maybe_unserialize( $value );
6935 if ( is_array( $value ) ) {
6936 $c = '';
6937 $optstr .= '( ' . $key . ' : ';
6938 foreach ( $value as $v ) {
6939 $optstr .= $c . rawurldecode( $v );
6940 $c = ', ';
6941 }
6942 $optstr .= ' )<br>';
6943 } else {
6944 $optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . ' )<br>';
6945 }
6946 }
6947 }
6948 $message .= $optstr;
6949 }
6950 $message .= '</td></tr>';
6951
6952 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6953 $message .= __( 'Settlement amount', 'usces' );
6954 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6955 $message .= usces_crform( $continue_data['price'], true, false, 'return' );
6956 $message .= '</td></tr>';
6957 if ( isset( $data['reminder'] ) ) {
6958 if ( ! empty( $charged_date ) ) {
6959 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6960 $message .= __( 'Next Withdrawal Date', 'dlseller' );
6961 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6962 $message .= $charged_date;
6963 $message .= '</td></tr>';
6964 }
6965 if ( ! empty( $contracted_date ) ) {
6966 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6967 $message .= __( 'Renewal Date', 'dlseller' );
6968 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6969 $message .= $contracted_date;
6970 $message .= '</td></tr>';
6971 }
6972 } else {
6973 if ( ! empty( $charged_date ) ) {
6974 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6975 $message .= __( 'Next Withdrawal Date', 'dlseller' );
6976 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6977 $message .= $charged_date;
6978 $message .= '</td></tr>';
6979 }
6980 if ( ! empty( $contracted_date ) ) {
6981 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6982 $message .= __( 'Renewal Date', 'dlseller' );
6983 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6984 $message .= $contracted_date;
6985 $message .= '</td></tr>';
6986 }
6987 if ( isset( $data['result'] ) && in_array( $data['result'], $this->payment_normal_results, true ) ) {
6988 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6989 $message .= __( 'Result', 'usces' );
6990 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6991 $message .= __( 'Normal done', 'usces' );
6992 $message .= '</td></tr>';
6993 } else {
6994 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
6995 $message .= __( 'Result', 'usces' );
6996 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
6997 $message .= __( 'Error', 'usces' );
6998 $message .= '</td></tr>';
6999 }
7000 }
7001 $message .= '</tbody></table>';
7002
7003 } else {
7004 $message = usces_mail_line( 2 ); // --------------------
7005 $message .= __( 'Order ID', 'dlseller' ) . ' : ' . $order_id . "\r\n";
7006 $message .= __( 'Application Date', 'dlseller' ) . ' : ' . $order_data['order_date'] . "\r\n";
7007 $message .= __( 'Member ID', 'dlseller' ) . ' : ' . $member_id . "\r\n";
7008 $message .= __( 'Contractor name', 'dlseller' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
7009
7010 $message .= __( 'Items', 'usces' ) . ' : ' . $item_name . "\r\n";
7011 if ( is_array( $options ) && 0 < count( $options ) ) {
7012 $optstr = '';
7013 foreach ( $options as $key => $value ) {
7014 if ( ! empty( $key ) ) {
7015 $key = urldecode( $key );
7016 $value = wel_safe_maybe_unserialize( $value );
7017 if ( is_array( $value ) ) {
7018 $c = '';
7019 $optstr .= '( ' . $key . ' : ';
7020 foreach ( $value as $v ) {
7021 $optstr .= $c . rawurldecode( $v );
7022 $c = ', ';
7023 }
7024 $optstr .= " )\r\n";
7025 } else {
7026 $optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . " )\r\n";
7027 }
7028 }
7029 }
7030 $message .= $optstr;
7031 }
7032
7033 $message .= __( 'Settlement amount', 'usces' ) . ' : ' . usces_crform( $continue_data['price'], true, false, 'return' ) . "\r\n";
7034 if ( ! empty( $charged_date ) ) {
7035 $message .= __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . $charged_date . "\r\n";
7036 }
7037 if ( ! empty( $contracted_date ) ) {
7038 $message .= __( 'Renewal Date', 'dlseller' ) . ' : ' . $contracted_date . "\r\n";
7039 }
7040 if ( isset( $data['reminder'] ) ) {
7041 } else {
7042 $message .= "\r\n";
7043 if ( isset( $data['result'] ) && in_array( $data['result'], $this->payment_normal_results, true ) ) {
7044 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Normal done', 'usces' ) . "\r\n";
7045 } else {
7046 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Error', 'usces' ) . "\r\n";
7047 }
7048 }
7049 $message .= usces_mail_line( 2 ) . "\r\n"; // --------------------
7050 }
7051 return $message;
7052 }
7053
7054 /**
7055 * 自動継続課金処理
7056 * dlseller_action_do_continuation
7057 *
7058 * @param string $today Today.
7059 * @param array $todays_charging Charged data.
7060 */
7061 public function do_auto_continuation( $today, $todays_charging ) {
7062 global $usces;
7063
7064 if ( empty( $todays_charging ) ) {
7065 return;
7066 }
7067
7068 $ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
7069 $error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
7070 $admin_subject = apply_filters( 'usces_filter_zeus_autobilling_email_admin_subject', __( 'Automatic Continuing Charging Process Result', 'usces' ) . ' ' . $today, $today );
7071 $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' ) );
7072 $admin_message = __( 'Report that automated accounting process has been completed.', 'usces' ) . "\r\n\r\n"
7073 . __( 'Processing date', 'usces' ) . ' : ' . wp_date( 'Y-m-d H:i:s' ) . "\r\n"
7074 . __( 'Normal done', 'usces' ) . ' : ' . $ok . "\r\n"
7075 . __( 'Abnormal done', 'usces' ) . ' : ' . $error . "\r\n\r\n";
7076 foreach ( (array) $this->continuation_charging_mail['mail'] as $mail ) {
7077 $admin_message .= $mail . "\r\n";
7078 }
7079 $admin_message .= $admin_footer . "\r\n";
7080
7081 $to_admin = array(
7082 'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
7083 'to_address' => $usces->options['order_mail'],
7084 'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
7085 'from_address' => $usces->options['sender_mail'],
7086 'reply_name' => get_option( 'blogname' ),
7087 'reply_to' => usces_get_first_order_mail(),
7088 'return_path' => $usces->options['sender_mail'],
7089 'subject' => $admin_subject,
7090 'message' => do_shortcode( $admin_message ),
7091 );
7092 usces_send_mail( $to_admin );
7093 unset( $this->continuation_charging_mail );
7094 }
7095
7096 /**
7097 * 課金日通知メール
7098 * dlseller_filter_reminder_mail_body
7099 *
7100 * @param string $mail_body Message body.
7101 * @param int $order_id Order number.
7102 * @param array $continue_data Continuation data.
7103 * @return string
7104 */
7105 public function reminder_mail_body( $mail_body, $order_id, $continue_data ) {
7106 global $usces;
7107
7108 $member_id = $continue_data['member_id'];
7109 $order_id = $continue_data['order_id'];
7110 $order_data = $usces->get_order_data( $order_id, 'direct' );
7111 $data = array( 'reminder' => 'reminder' );
7112 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data );
7113 return $mail_body;
7114 }
7115
7116 /**
7117 * 契約更新日通知メール
7118 * dlseller_filter_contract_renewal_mail_body
7119 *
7120 * @param string $mail_body Message body.
7121 * @param int $order_id Order number.
7122 * @param array $continue_data Continuation data.
7123 * @return string
7124 */
7125 public function contract_renewal_mail_body( $mail_body, $order_id, $continue_data ) {
7126 global $usces;
7127
7128 $member_id = $continue_data['member_id'];
7129 $order_data = $usces->get_order_data( $order_id, 'direct' );
7130 $data = array( 'reminder' => 'contract_renewal' );
7131 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data );
7132 return $mail_body;
7133 }
7134
7135 /**
7136 * 継続課金会員データ取得
7137 *
7138 * @param int $member_id Member ID.
7139 * @param int $order_id Order number.
7140 * @return array
7141 */
7142 private function get_continuation_data( $member_id, $order_id ) {
7143 global $wpdb;
7144
7145 $query = $wpdb->prepare(
7146 "SELECT
7147 `con_id` AS `con_id`,
7148 `con_acting` AS `acting`,
7149 `con_order_price` AS `order_price`,
7150 `con_price` AS `price`,
7151 `con_next_charging` AS `chargedday`,
7152 `con_next_contracting` AS `contractedday`,
7153 `con_startdate` AS `startdate`,
7154 `con_status` AS `status`
7155 FROM {$wpdb->prefix}usces_continuation
7156 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7157 $order_id,
7158 $member_id
7159 );
7160 $data = $wpdb->get_row( $query, ARRAY_A );
7161 return $data;
7162 }
7163
7164 /**
7165 * 継続課金会員データ更新
7166 *
7167 * @param int $member_id Member ID.
7168 * @param int $order_id Order number.
7169 * @param array $data Continuation data.
7170 * @param boolean $stop Stop continuous billing.
7171 * @return boolean
7172 */
7173 private function update_continuation_data( $member_id, $order_id, $data, $stop = false ) {
7174 global $wpdb;
7175
7176 if ( $stop ) {
7177 $query = $wpdb->prepare(
7178 "UPDATE {$wpdb->prefix}usces_continuation SET
7179 `con_status` = 'cancellation'
7180 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7181 $order_id,
7182 $member_id
7183 );
7184 } else {
7185 $query = $wpdb->prepare(
7186 "UPDATE {$wpdb->prefix}usces_continuation SET
7187 `con_price` = %f,
7188 `con_next_charging` = %s,
7189 `con_next_contracting` = %s,
7190 `con_status` = %s
7191 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7192 $data['price'],
7193 $data['chargedday'],
7194 $data['contractedday'],
7195 $data['status'],
7196 $order_id,
7197 $member_id
7198 );
7199 }
7200 $res = $wpdb->query( $query );
7201 return $res;
7202 }
7203
7204 /**
7205 * 決済オプション取得
7206 *
7207 * @return array
7208 */
7209 public function get_acting_settings() {
7210 global $usces;
7211
7212 $acting_settings = ( isset( $usces->options['acting_settings'][ $this->paymod_id ] ) ) ? $usces->options['acting_settings'][ $this->paymod_id ] : array();
7213 return apply_filters( 'usces_filter_get_acting_settings_zeus', $acting_settings );
7214 }
7215
7216 /**
7217 * Secure API
7218 * 3D Secure Enrol.
7219 */
7220 public function zeus_3dsecure_enrol() {
7221 global $usces;
7222
7223 check_ajax_referer( 'acting_zeus_card', '_nonce' );
7224
7225 // A6 (Layer 3 / uscesid removal): この nopriv admin-ajax は usces_close_session()(admin_init)
7226 // の後に走るため session_status() は PHP_SESSION_NONE。旧実�
7227 JS が付けた `?uscesid=`
7228 // usces_session_start() が復号して買い物客セッションへ切替えていたが、uscesid を廃し、
7229 // 同一オリジンの USCES_KEY cookie から買い物客セッションを再開する(A2 と同一方式).
7230 if ( PHP_SESSION_NONE === session_status() ) {
7231 $usces_options = get_option( 'usces' );
7232 $sess_name = defined( 'USCES_KEY' ) ? USCES_KEY : ( isset( $usces_options['usces_key'] ) ? $usces_options['usces_key'] : '' );
7233 if ( '' !== $sess_name && ! empty( $_COOKIE[ $sess_name ] ) ) {
7234 $sess_id = preg_replace( '/[^A-Za-z0-9,\-]/', '', wp_unslash( $_COOKIE[ $sess_name ] ) );
7235 session_id( $sess_id );
7236 @session_start(); // phpcs:ignore
7237 }
7238 }
7239
7240 $entry = $usces->cart->get_entry();
7241 if ( empty( $entry ) ) {
7242 $result_data = array(
7243 'action' => 'session',
7244 'status' => 'error',
7245 );
7246 wp_send_json( $result_data );
7247 }
7248
7249 $usces->error_message = $usces->zaiko_check();
7250 if ( '' !== $usces->error_message || 0 === (int) $usces->cart->num_row() ) {
7251 $result_data = array(
7252 'action' => 'stock',
7253 'status' => 'error',
7254 );
7255 wp_send_json( $result_data );
7256 }
7257
7258 $acting_opts = $this->get_acting_settings();
7259 $result_data = array();
7260 if ( $this->is_activate_card( 'api' ) && 1 === (int) $acting_opts['3dsecur'] ) {
7261 $sendid = ( 'on' === $acting_opts['quickcharge'] && isset( $_POST['sendid'] ) ) ? filter_input( INPUT_POST, 'sendid' ) : '';
7262 $sendpoint = filter_input( INPUT_POST, 'sendpoint', FILTER_DEFAULT, array( 'options' => array( 'default' => '' ) ) );
7263 $_nonce = filter_input( INPUT_POST, '_nonce', FILTER_DEFAULT, array( 'options' => array( 'default' => wp_create_nonce( 'acting_zeus_card' ) ) ) );
7264 // A6: uscesid ブリッジ廃止。3DS 戻り(TermUrl)のセッションは sendpoint(取引キー)で
7265 // acting_processing() が usces_restore_order_acting_data() 復�
7266 �するため uscesid は不要.
7267
7268 $data = array();
7269 $data['authentication']['clientip'] = $acting_opts['clientip'];
7270 $data['authentication']['key'] = $acting_opts['authkey'];
7271 if ( 'on' === $acting_opts['quickcharge'] && isset( $_POST['card_option'] ) && 'prev' === filter_input( INPUT_POST, 'card_option' ) && ! empty( $sendid ) ) {
7272 $data['card']['history']['key'] = 'sendid';
7273 $data['card']['history']['action'] = 'send_email';
7274 } elseif ( isset( $_POST['token_key'] ) ) {
7275 $data['token_key'] = filter_input( INPUT_POST, 'token_key' );
7276 }
7277 $data['payment']['amount'] = apply_filters( 'zeus_secure_payreq_amount', usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ), $entry );
7278 if ( isset( $entry['order']['cbrand'] ) && isset( $entry['order']['howpay'] ) && WCUtils::is_zero( $entry['order']['howpay'] ) ) {
7279 $div_name = 'div_' . $entry['order']['cbrand'];
7280 $data['payment']['count'] = $entry['order'][ $div_name ];
7281 } else {
7282 $data['payment']['count'] = '01';
7283 }
7284 $data['user']['telno'] = str_replace( '-', '', $entry['customer']['tel'] );
7285 $data['user']['email'] = $entry['customer']['mailaddress1'];
7286 $data['uniq_key']['sendid'] = $sendid;
7287 $data['uniq_key']['sendpoint'] = $sendpoint;
7288 $data['use_3ds2_flag'] = '1';
7289
7290 // リスクベース認証用追加パラメータ.
7291 $data['cardHolderInfo']['cardholderName'] = filter_input( INPUT_POST, 'card_name' );
7292 $data['cardHolderInfo']['email'] = $entry['customer']['mailaddress1'];
7293
7294 $enrol_req = '<?xml version="1.0" encoding="utf-8"?>';
7295 $enrol_req .= '<request service="secure_link_3d" action="enroll">';
7296 $enrol_req .= $this->assoc2xml( $data );
7297 $enrol_req .= '</request>';
7298
7299 $xml = $this->get_xml( $acting_opts['card_secureurl'], $enrol_req );
7300 if ( empty( $xml ) ) {
7301 $log = array(
7302 'acting' => 'zeus_card_API(3D Enrol)',
7303 'key' => $sendpoint,
7304 'result' => 'EnrolRes Error',
7305 'data' => $enrol_req,
7306 );
7307 usces_save_order_acting_error( $log );
7308 $result_data = array(
7309 'action' => 'EnrolReq',
7310 'status' => 'error',
7311 );
7312 } else {
7313 $enrol_res = $this->xml2assoc( $xml );
7314 if ( 'outside' === $enrol_res['response']['result']['status'] ) {
7315 usces_ordered_acting_data( $sendpoint, 'propriety' );
7316 $result_data = array(
7317 'action' => 'EnrolReq',
7318 'status' => $enrol_res['response']['result']['status'],
7319 'xid' => $enrol_res['response']['xid'],
7320 'code' => $enrol_res['response']['result']['code'],
7321 );
7322 } elseif ( 'success' === $enrol_res['response']['result']['status'] ) {
7323 usces_ordered_acting_data( $sendpoint, 'propriety' );
7324 $term_data = array(
7325 'purchase' => '1',
7326 'sendpoint' => $sendpoint,
7327 '_nonce' => $_nonce,
7328 );
7329 $term_url = add_query_arg( $term_data, USCES_CART_URL );
7330 $result_data = array(
7331 'action' => 'EnrolReq',
7332 'status' => $enrol_res['response']['result']['status'],
7333 'MD' => $enrol_res['response']['xid'],
7334 'PaReq' => $enrol_res['response']['redirection']['PaReq'],
7335 'TermUrl' => $term_url,
7336 'threeDSMehtod' => '2',
7337 'iframeUrl' => $enrol_res['response']['iframeUrl'],
7338 );
7339 } else {
7340 $log = array(
7341 'acting' => 'zeus_card_API(3D Enrol)',
7342 'key' => $sendpoint,
7343 'result' => $enrol_res['response']['result']['status'] . ':' . $enrol_res['response']['result']['code'],
7344 'data' => $enrol_res,
7345 );
7346 usces_save_order_acting_error( $log );
7347 $result_data = array(
7348 'action' => 'EnrolReq',
7349 'status' => $enrol_res['response']['result']['status'],
7350 'code' => $enrol_res['response']['result']['code'],
7351 );
7352 }
7353 }
7354 }
7355 wp_send_json( $result_data );
7356 }
7357
7358 /**
7359 * Secure API
7360 * 3D Secure Authentication.
7361 * usces_zeus_3dsecure_auth
7362 * ( call from acting_processing )
7363 */
7364 public function zeus_3dsecure_auth() {
7365 global $usces;
7366
7367 $acting_opts = $this->get_acting_settings();
7368 $sendpoint = filter_input( INPUT_GET, 'sendpoint', FILTER_DEFAULT, array( 'options' => array( 'default' => '' ) ) );
7369 $_nonce = filter_input( INPUT_GET, '_nonce', FILTER_DEFAULT, array( 'options' => array( 'default' => wp_create_nonce( 'acting_zeus_card' ) ) ) );
7370
7371 $request_body = file_get_contents( 'php://input' );
7372 $body = json_decode( $request_body, true );
7373 if ( ! empty( $body['MD'] ) && ! empty( $body['PaRes'] ) && ! empty( $body['status'] ) ) {
7374 if ( 'failure' === $body['status'] || 'invalid' === $body['status'] || 'maintenance' === $body['status'] ) {
7375 $log = array(
7376 'acting' => 'zeus_card_API(3D Auth)',
7377 'key' => $sendpoint,
7378 'result' => 'PaRes Error',
7379 'data' => $body,
7380 );
7381 usces_save_order_acting_error( $log );
7382 wp_redirect(
7383 add_query_arg(
7384 array(
7385 'acting' => 'zeus_card',
7386 'acting_return' => '0',
7387 'status' => $body['status'],
7388 ),
7389 USCES_CART_URL
7390 )
7391 );
7392 exit();
7393 }
7394
7395 $data = array();
7396 $data['xid'] = $body['MD'];
7397 $data['PaRes'] = $body['PaRes'];
7398 $auth_req = '<?xml version="1.0" encoding="utf-8" ?>';
7399 $auth_req .= '<request service="secure_link_3d" action="authentication">';
7400 $auth_req .= $this->assoc2xml( $data );
7401 $auth_req .= '</request>';
7402
7403 $xml = $this->get_xml( $acting_opts['card_secureurl'], $auth_req );
7404 if ( false !== strpos( $xml, 'Invalid' ) ) {
7405 $log = array(
7406 'acting' => 'zeus_card_API(3D Auth)',
7407 'key' => $sendpoint,
7408 'result' => 'AuthReq Error',
7409 'data' => $auth_req,
7410 );
7411 usces_save_order_acting_error( $log );
7412 wp_redirect(
7413 add_query_arg(
7414 array(
7415 'acting' => 'zeus_card',
7416 'acting_return' => '0',
7417 'status' => 'error',
7418 ),
7419 USCES_CART_URL
7420 )
7421 );
7422 exit();
7423 }
7424
7425 $auth_res = $this->xml2assoc( $xml );
7426 if ( 'success' !== $auth_res['response']['result']['status'] ) {
7427 $log = array(
7428 'acting' => 'zeus_card_API(3D Auth)',
7429 'key' => $sendpoint,
7430 'result' => $auth_res['response']['result']['status'] . ':' . $auth_res['response']['result']['code'],
7431 'data' => $auth_res,
7432 );
7433 usces_save_order_acting_error( $log );
7434 wp_redirect(
7435 add_query_arg(
7436 array(
7437 'acting' => 'zeus_card',
7438 'acting_return' => '0',
7439 'status' => $auth_res['response']['result']['status'],
7440 'code' => $auth_res['response']['result']['code'],
7441 ),
7442 USCES_CART_URL
7443 )
7444 );
7445 exit();
7446 }
7447
7448 $data = array();
7449 $data['xid'] = $body['MD'];
7450 $pay_req = '<?xml version="1.0" encoding="utf-8" ?>';
7451 $pay_req .= '<request service="secure_link_3d" action="payment">';
7452 $pay_req .= $this->assoc2xml( $data );
7453 $pay_req .= '</request>';
7454
7455 $xml = $this->get_xml( $acting_opts['card_secureurl'], $pay_req );
7456 if ( empty( $xml ) ) {
7457 $log = array(
7458 'acting' => 'zeus_card_API(3D Auth)',
7459 'key' => $sendpoint,
7460 'result' => 'PayReq Error',
7461 'data' => $pay_req,
7462 );
7463 usces_save_order_acting_error( $log );
7464 wp_redirect(
7465 add_query_arg(
7466 array(
7467 'acting' => 'zeus_card',
7468 'acting_return' => '0',
7469 'status' => 'error',
7470 ),
7471 USCES_CART_URL
7472 )
7473 );
7474 exit();
7475 }
7476
7477 $pay_res = $this->xml2assoc( $xml );
7478 if ( 'success' === $pay_res['response']['result']['status'] ) {
7479 $result_data = array(
7480 'acting' => 'zeus_card',
7481 'acting_return' => '1',
7482 'zeussuffix' => $pay_res['response']['card']['number']['suffix'],
7483 'zeusordd' => $pay_res['response']['order_number'],
7484 'wctid' => $sendpoint,
7485 'auth_code' => $auth_res['response']['result']['code'],
7486 );
7487 $res = $usces->order_processing( $result_data );
7488 if ( 'ordercompletion' === $res ) {
7489 wp_redirect(
7490 add_query_arg(
7491 array(
7492 'acting' => 'zeus_card',
7493 'acting_return' => 1,
7494 'result' => 1,
7495 '_nonce' => $_nonce,
7496 ),
7497 USCES_CART_URL
7498 )
7499 );
7500 exit();
7501 } else {
7502 $log = array(
7503 'acting' => 'zeus_card',
7504 'key' => $sendpoint,
7505 'result' => 'ORDER DATA REGISTERED ERROR',
7506 'data' => $result_data,
7507 );
7508 usces_save_order_acting_error( $log );
7509 wp_redirect(
7510 add_query_arg(
7511 array(
7512 'acting' => 'zeus_card',
7513 'acting_return' => 0,
7514 'result' => 0,
7515 ),
7516 USCES_CART_URL
7517 )
7518 );
7519 exit();
7520 }
7521 } else {
7522 $log = array(
7523 'acting' => 'zeus_card_API(3D Auth)',
7524 'key' => $sendpoint,
7525 'result' => $pay_res['response']['result']['status'] . ':' . $pay_res['response']['result']['code'],
7526 'data' => $pay_res,
7527 );
7528 usces_save_order_acting_error( $log );
7529 wp_redirect(
7530 add_query_arg(
7531 array(
7532 'acting' => 'zeus_card',
7533 'acting_return' => '0',
7534 'status' => $pay_res['response']['result']['status'],
7535 'code' => $pay_res['response']['result']['code'],
7536 ),
7537 USCES_CART_URL
7538 )
7539 );
7540 exit();
7541 }
7542 }
7543 exit();
7544 }
7545
7546 /**
7547 * Secure API
7548 * Payment Request. (3D Secure Not used.)
7549 * usces_zeus_secure_payreq
7550 * ( call from acting_processing )
7551 */
7552 protected function zeus_secure_payreq() {
7553 global $usces;
7554
7555 $acting_opts = $this->get_acting_settings();
7556 $sendid = ( 'on' == $acting_opts['quickcharge'] && isset( $_POST['sendid'] ) ) ? filter_input( INPUT_POST, 'sendid' ) : '';
7557 $sendpoint = ( isset( $_POST['sendpoint'] ) ) ? filter_input( INPUT_POST, 'sendpoint' ) : '';
7558 $outside = ( isset( $_POST['outside'] ) ) ? filter_input( INPUT_POST, 'outside' ) : '';
7559
7560 $data = array();
7561 $data['authentication']['clientip'] = $acting_opts['clientip'];
7562 $data['authentication']['key'] = $acting_opts['authkey'];
7563 if ( 'on' === $acting_opts['quickcharge'] && isset( $_POST['card_option'] ) && 'prev' === filter_input( INPUT_POST, 'card_option' ) && ! empty( $sendid ) ) {
7564 $data['card']['history']['key'] = 'sendid';
7565 $data['card']['history']['action'] = 'send_email';
7566 } elseif ( isset( $_POST['token_key'] ) ) {
7567 $data['token_key'] = filter_input( INPUT_POST, 'token_key' );
7568 }
7569 $data['payment']['amount'] = apply_filters( 'zeus_secure_payreq_amount', filter_input( INPUT_POST, 'money' ), $entry );
7570 if ( isset( $_POST['howpay'] ) && WCUtils::is_zero( filter_input( INPUT_POST, 'howpay' ) ) ) {
7571 $data['payment']['count'] = filter_input( INPUT_POST, 'div' );
7572 } else {
7573 $data['payment']['count'] = '01';
7574 }
7575 $data['user']['telno'] = str_replace( '-', '', filter_input( INPUT_POST, 'telno' ) );
7576 $data['user']['email'] = filter_input( INPUT_POST, 'email' );
7577 $data['uniq_key']['sendid'] = $sendid;
7578 $data['uniq_key']['sendpoint'] = $sendpoint;
7579
7580 $pay_req = '<?xml version="1.0" encoding="utf-8" ?>';
7581 $pay_req .= '<request service="secure_link" action="payment">';
7582 $pay_req .= $this->assoc2xml( $data );
7583 $pay_req .= '</request>';
7584
7585 $xml = $this->get_xml( $acting_opts['card_secureurl'], $pay_req );
7586 if ( empty( $xml ) ) {
7587 $log = array(
7588 'acting' => 'zeus_card_API',
7589 'key' => $sendpoint,
7590 'result' => 'PayReq Error',
7591 'data' => $pay_req,
7592 );
7593 usces_save_order_acting_error( $log );
7594 wp_redirect(
7595 add_query_arg(
7596 array(
7597 'acting' => 'zeus_card',
7598 'acting_return' => '0',
7599 'status' => 'error',
7600 ),
7601 USCES_CART_URL
7602 )
7603 );
7604 exit();
7605 }
7606
7607 usces_ordered_acting_data( $sendpoint, 'propriety' );
7608
7609 $pay_res = $this->xml2assoc( $xml );
7610 if ( 'success' === $pay_res['response']['result']['status'] ) {
7611 $result_data = array(
7612 'acting' => 'zeus_card',
7613 'zeussuffix' => $pay_res['response']['card']['number']['suffix'],
7614 'zeusordd' => $pay_res['response']['order_number'],
7615 'wctid' => $sendpoint,
7616 );
7617 if ( ! empty( $outside ) ) {
7618 $result_data['auth_code'] = $outside;
7619 }
7620 $res = $usces->order_processing( $result_data );
7621 if ( 'ordercompletion' === $res ) {
7622 $_nonce = ( isset( $_POST['_nonce'] ) ) ? filter_input( INPUT_POST, '_nonce' ) : wp_create_nonce( 'acting_zeus_card' );
7623 wp_redirect(
7624 add_query_arg(
7625 array(
7626 'acting' => 'zeus_card',
7627 'acting_return' => 1,
7628 'result' => 1,
7629 '_nonce' => $_nonce,
7630 ),
7631 USCES_CART_URL
7632 )
7633 );
7634 } else {
7635 $log = array(
7636 'acting' => 'zeus_card',
7637 'key' => $sendpoint,
7638 'result' => 'ORDER DATA REGISTERED ERROR',
7639 'data' => $result_data,
7640 );
7641 usces_save_order_acting_error( $log );
7642 wp_redirect(
7643 add_query_arg(
7644 array(
7645 'acting' => 'zeus_card',
7646 'acting_return' => 0,
7647 'result' => 0,
7648 ),
7649 USCES_CART_URL
7650 )
7651 );
7652 }
7653 exit();
7654 } else {
7655 $log = array(
7656 'acting' => 'zeus_card_API',
7657 'key' => $sendpoint,
7658 'result' => $pay_res['response']['result']['status'] . ':' . $pay_res['response']['result']['code'],
7659 'data' => $pay_res,
7660 );
7661 usces_save_order_acting_error( $log );
7662 wp_redirect(
7663 add_query_arg(
7664 array(
7665 'acting' => 'zeus_card',
7666 'acting_return' => '0',
7667 'status' => $pay_res['response']['result']['status'],
7668 'code' => $pay_res['response']['result']['code'],
7669 ),
7670 USCES_CART_URL
7671 )
7672 );
7673 exit();
7674 }
7675 }
7676
7677 /**
7678 * XML to Association.
7679 * usces_xml2assoc
7680 *
7681 * @param string $xml XML data.
7682 * @return array
7683 */
7684 public function xml2assoc( $xml ) {
7685 $arr = array();
7686 if ( ! preg_match_all( '|\<\s*?(\w+).*?\>(.*)\<\/\s*\\1.*?\>|s', $xml, $m ) ) {
7687 return $xml;
7688 }
7689 if ( is_array( $m[1] ) ) {
7690 for ( $i = 0; $i < sizeof( $m[1] ); $i++ ) {
7691 $arr[ $m[1][ $i ] ] = $this->xml2assoc( $m[2][ $i ] );
7692 }
7693 } else {
7694 $arr[ $m[1] ] = $this->xml2assoc( $m[2] );
7695 }
7696 return $arr;
7697 }
7698
7699 /**
7700 * Association to XML.
7701 * usces_assoc2xml
7702 *
7703 * @param array $prm_array Parameters.
7704 * @return string
7705 */
7706 protected function assoc2xml( $prm_array ) {
7707 $xml = '';
7708 if ( is_array( $prm_array ) ) {
7709 $i = 0;
7710 foreach ( $prm_array as $index => $element ) {
7711 if ( is_array( $element ) ) {
7712 $acts = explode( '_', $index, 3 );
7713 if ( is_array( $acts ) && 2 < count( $acts ) && 'history' === $acts[0] && 'action' === $acts[1] ) {
7714 $xml .= '<history action="' . $acts[2] . '">';
7715 $xml .= $this->assoc2xml( $element );
7716 $xml .= '</history>';
7717 } else {
7718 $xml .= '<' . $index . '>';
7719 $xml .= $this->assoc2xml( $element );
7720 $xml .= '</' . $index . '>';
7721 }
7722 } else {
7723 $xml .= '<' . $index . '>' . $element . '</' . $index . '>';
7724 }
7725 $i++;
7726 if ( $i > 500 ) {
7727 break;
7728 }
7729 }
7730 }
7731 return $xml;
7732 }
7733
7734 /**
7735 * Get XML Response.
7736 * usces_get_xml
7737 *
7738 * @param string $url Connect url.
7739 * @param string $params Sending parameters.
7740 * @return string
7741 */
7742 protected function get_xml( $url, $params ) {
7743 $interface = $this->get_interface( $url );
7744
7745 $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
7746 $header .= 'Host: ' . $interface['host'] . "\r\n";
7747 $header .= "User-Agent: PHP Script\r\n";
7748 $header .= "Content-Type: text/xml\r\n";
7749 $header .= 'Content-Length: ' . strlen( $params ) . "\r\n";
7750 $header .= "Connection: close\r\n\r\n";
7751 $header .= $params;
7752
7753 $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
7754 if ( ! $fp ) {
7755 usces_log( 'zeus API : TLS(v1.2) Error', 'acting_transaction.log' );
7756 }
7757
7758 $xml = '';
7759 if ( $fp ) {
7760 fwrite( $fp, $header );
7761 while ( ! feof( $fp ) ) {
7762 $xml .= fgets( $fp, 1024 );
7763 }
7764 fclose( $fp );
7765 }
7766 return $xml;
7767 }
7768
7769 /**
7770 * Get XML Response.
7771 *
7772 * @param string $url Connect url.
7773 * @param string $params Sending parameters.
7774 * @return string
7775 */
7776 protected function get_xml_bnpl( $url, $params ) {
7777 $args = array(
7778 'method' => 'POST',
7779 'headers' => array(
7780 'Content-Type' => 'application/xml; charset=UTF-8',
7781 'Accept' => 'application/xml; charset=UTF-8',
7782 ),
7783 'body' => $params,
7784 );
7785
7786 $xml = '';
7787 $response = wp_remote_post( $url, $args );
7788 if ( ! is_wp_error( $response ) ) {
7789 $xml = wp_remote_retrieve_body( $response );
7790 }
7791 return $xml;
7792 }
7793
7794 /**
7795 * Secure Link Batch.
7796 *
7797 * @param string $url Connect url.
7798 * @param array $params Sending parameters.
7799 * @return string
7800 */
7801 protected function secure_link_batch( $url, $params ) {
7802 $page = '';
7803 $interface = $this->get_interface( $url );
7804 $vars = http_build_query( $params );
7805
7806 $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
7807 $header .= 'Host: ' . $interface['host'] . "\r\n";
7808 $header .= "User-Agent: PHP Script\r\n";
7809 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
7810 $header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
7811 $header .= "Connection: close\r\n\r\n";
7812 $header .= $vars;
7813
7814 $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
7815 if ( $fp ) {
7816 fwrite( $fp, $header );
7817 while ( ! feof( $fp ) ) {
7818 $scr = fgets( $fp, 1024 );
7819 $page .= $scr;
7820 }
7821 fclose( $fp );
7822 }
7823
7824 return $page;
7825 }
7826
7827 /**
7828 * Get clientip.
7829 *
7830 * @param string $acting Acting type.
7831 * @return string
7832 */
7833 protected function get_clientip( $acting ) {
7834 $client_ip = '';
7835 $acting_opts = $this->get_acting_settings();
7836 switch ( $acting ) {
7837 case 'zeus_card':
7838 $client_ip = $acting_opts['clientip'];
7839 break;
7840 case 'zeus_conv':
7841 $client_ip = $acting_opts['clientip_conv'];
7842 break;
7843 case 'zeus_bank':
7844 $client_ip = $acting_opts['clientip_bank'];
7845 break;
7846 }
7847 return $client_ip;
7848 }
7849
7850 /**
7851 * Get order_number.
7852 *
7853 * @param string $page Post data.
7854 * @return string
7855 */
7856 protected function get_order_number( $page ) {
7857 if ( empty( $page ) ) {
7858 return '';
7859 }
7860
7861 $log = explode( "\r\n", $page );
7862 $ordd = '';
7863 foreach ( (array) $log as $line ) {
7864 if ( false !== strpos( $line, 'ordd' ) ) {
7865 list( $status, $ordd ) = explode( '=', $line );
7866 }
7867 }
7868 if ( empty( $ordd ) ) {
7869 foreach ( (array) $log as $idx => $line ) {
7870 if ( false !== strpos( $line, 'Success_order' ) ) {
7871 list( $status, $ordd ) = explode( "\n", $line );
7872 break;
7873 }
7874 }
7875 }
7876 return $ordd;
7877 }
7878
7879 /**
7880 * Get err_code.
7881 *
7882 * @param string $page Post data.
7883 * @return string
7884 */
7885 protected function get_err_code( $page ) {
7886 if ( empty( $page ) ) {
7887 return '';
7888 }
7889
7890 $log = explode( "\r\n", $page );
7891 $err_code = '';
7892 foreach ( (array) $log as $line ) {
7893 if ( false !== strpos( $line, 'err_code' ) ) {
7894 list( $name, $err_code ) = explode( '=', $line );
7895 }
7896 }
7897 return $err_code;
7898 }
7899
7900 /**
7901 * Get err_code.
7902 *
7903 * @param string $page Post data.
7904 * @return string
7905 */
7906 protected function get_error_results( $page ) {
7907 $error_results = '';
7908 if ( ! empty( $page ) ) {
7909 $log = explode( "\r\n", $page );
7910 foreach ( (array) $log as $line ) {
7911 foreach ( $this->payment_error_results as $error ) {
7912 if ( false !== strpos( $line, $error ) ) {
7913 $error_results = $line;
7914 break;
7915 }
7916 }
7917 if ( ! empty( $error_results ) ) {
7918 break;
7919 }
7920 }
7921 }
7922 return $error_results;
7923 }
7924
7925 /**
7926 * Get order_id by meta_data ( conv, bank )
7927 *
7928 * @param int $key Order number.
7929 * @return string
7930 */
7931 protected function get_order_id( $key ) {
7932 global $wpdb;
7933
7934 $query = $wpdb->prepare( "SELECT `order_id` FROM {$wpdb->prefix}usces_order_meta WHERE `meta_key` = %s", 'acting_' . $key );
7935 $order_id = $wpdb->get_var( $query );
7936 return $order_id;
7937 }
7938
7939 /**
7940 * Get order_meta_data ( conv, bank )
7941 *
7942 * @param int $order_id Order number.
7943 * @return array
7944 */
7945 protected function get_order_meta_acting( $order_id ) {
7946 global $wpdb;
7947
7948 $query = $wpdb->prepare( "SELECT `meta_value` FROM {$wpdb->prefix}usces_order_meta WHERE `order_id` = %d AND `meta_key` LIKE %s", $order_id, 'acting_%' );
7949 $meta_value = $wpdb->get_var( $query );
7950 $acting_data = usces_unserialize( $meta_value );
7951 return $acting_data;
7952 }
7953
7954 /**
7955 * Tracking ID 取得
7956 *
7957 * @param int $order_id Order number.
7958 * @return string
7959 */
7960 protected function get_tracking_id( $order_id ) {
7961 global $usces;
7962
7963 $tracking_id = $usces->get_order_meta_value( 'tracking_id', $order_id );
7964 return $tracking_id;
7965 }
7966
7967 /**
7968 * 受注ステータス取得
7969 *
7970 * @param int $order_id Order number.
7971 * @return string
7972 */
7973 protected function get_order_status( $order_id ) {
7974 global $wpdb;
7975
7976 $query = $wpdb->prepare( "SELECT LOCATE( 'receipted', `order_status` ) FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
7977 $order_status = $wpdb->get_var( $query );
7978 return $order_status;
7979 }
7980
7981 /**
7982 * 受注データ支払方法取得
7983 *
7984 * @param int $order_id Order number.
7985 * @return string
7986 */
7987 protected function get_order_payment_name( $order_id ) {
7988 global $wpdb;
7989
7990 $query = $wpdb->prepare( "SELECT `order_payment_name` FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
7991 $order_payment_name = $wpdb->get_var( $query );
7992 return $order_payment_name;
7993 }
7994
7995 /**
7996 * 決済ログ取得
7997 *
7998 * @param int $order_id Order number.
7999 * @param string $tracking_id Tracking ID.
8000 * @param string $result Result.
8001 * @return array
8002 */
8003 public function get_acting_log( $order_id = 0, $tracking_id = 0, $result = 'OK' ) {
8004 global $wpdb;
8005
8006 if ( empty( $order_id ) ) {
8007 if ( 'OK' === $result ) {
8008 $query = $wpdb->prepare(
8009 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `tracking_id` = %s AND `result` IN( %s ) ORDER BY `ID` DESC, `datetime` DESC",
8010 $tracking_id,
8011 implode( "','", $this->payment_normal_results )
8012 );
8013 $query = stripslashes( $query );
8014 } else {
8015 $query = $wpdb->prepare(
8016 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `tracking_id` = %s ORDER BY `ID` DESC, `datetime` DESC",
8017 $tracking_id
8018 );
8019 }
8020 } else {
8021 if ( empty( $tracking_id ) ) {
8022 if ( 'OK' === $result ) {
8023 $query = $wpdb->prepare(
8024 "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",
8025 $order_id,
8026 $order_id,
8027 implode( "','", $this->payment_normal_results )
8028 );
8029 $query = stripslashes( $query );
8030 } else {
8031 $query = $wpdb->prepare(
8032 "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",
8033 $order_id,
8034 $order_id
8035 );
8036 }
8037 } else {
8038 if ( 'OK' === $result ) {
8039 $query = $wpdb->prepare(
8040 "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",
8041 $order_id,
8042 $tracking_id,
8043 implode( "','", $this->payment_normal_results )
8044 );
8045 $query = stripslashes( $query );
8046 } else {
8047 $query = $wpdb->prepare(
8048 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d AND `tracking_id` = %s ORDER BY `ID` DESC, `datetime` DESC",
8049 $order_id,
8050 $tracking_id
8051 );
8052 }
8053 }
8054 }
8055 $log_data = $wpdb->get_results( $query, ARRAY_A );
8056 return $log_data;
8057 }
8058
8059 /**
8060 * 最新処理取得
8061 *
8062 * @param int $order_id Order number.
8063 * @param string $tracking_id Tracking ID.
8064 * @param string $result Result.
8065 * @return array
8066 */
8067 public function get_acting_latest_log( $order_id, $tracking_id, $result = 'OK' ) {
8068 $latest_log = array();
8069 $log_data = $this->get_acting_log( $order_id, $tracking_id, $result );
8070 if ( $log_data ) {
8071 $data = current( $log_data );
8072 $log = usces_unserialize( $data['log'] );
8073 $order_no = $this->get_order_no( $log );
8074 $latest_log['acting'] = $data['acting'];
8075 $latest_log['status'] = $data['status'];
8076 $latest_log['result'] = $data['result'];
8077 $latest_log['log'] = $log;
8078 $latest_log['amount'] = (int) $data['amount'];
8079 $latest_log['order_id'] = $data['order_id'];
8080 $latest_log['order_no'] = $order_no;
8081 $latest_log['tracking_id'] = $data['tracking_id'];
8082 }
8083 return $latest_log;
8084 }
8085
8086 /**
8087 * 決済処理取得
8088 *
8089 * @param int $order_id Order number.
8090 * @param string $tracking_id Tracking ID.
8091 * @param string $result Result.
8092 * @return string
8093 */
8094 private function get_acting_status( $order_id, $tracking_id, $result = 'OK' ) {
8095 $acting_status = '';
8096 $log_data = $this->get_acting_log( $order_id, $tracking_id, $result );
8097 if ( $log_data ) {
8098 foreach ( (array) $log_data as $data ) {
8099 if ( 'change' === $data['status'] ) {
8100 continue;
8101 }
8102 if ( 'TEST' === $data['status'] || 'test' === $data['status'] ) {
8103 $acting_status = 'test';
8104 } elseif ( 'cancel' === $data['status'] || 'sale' === $data['status'] || 'auth' === $data['status'] ) {
8105 $acting_status = $data['status'];
8106 } elseif ( 'autodelivery' === $data['status'] || 'dlseller' === $data['status'] ) {
8107 $acting_status = 'error';
8108 } elseif ( '仮売完了' === $data['result'] ) {
8109 $acting_status = 'auth';
8110 } elseif ( '決済完了' === $data['result'] || 'payment' === $data['status'] ) {
8111 $acting_status = 'payment';
8112 } elseif ( 'transaction' === $data['status'] || 'shippingrequest' === $data['status'] || 'canceltransaction' === $data['status'] ) {
8113 $acting_status = $data['status'] . $data['result'];
8114 }
8115 if ( '' !== $acting_status ) {
8116 break;
8117 }
8118 }
8119 }
8120 return $acting_status;
8121 }
8122
8123 /**
8124 * 処理区分名称取得
8125 *
8126 * @param string $payment_status Payment status code.
8127 * @param string $payment_result Payment result.
8128 * @return string
8129 */
8130 private function get_status_name( $payment_status, $payment_result = '' ) {
8131 $status_name = '';
8132 switch ( $payment_status ) {
8133 case 'TEST':
8134 case 'test':
8135 $status_name = 'テスト決済';
8136 break;
8137 case 'payment':
8138 $status_name = '決済完了';
8139 break;
8140 case 'auth':
8141 $status_name = '仮売完了';
8142 break;
8143 case 'sale':
8144 $status_name = '決済完了';
8145 break;
8146 case 'cancel':
8147 $status_name = '取り消し';
8148 break;
8149 case 'change':
8150 $status_name = '金額変更';
8151 break;
8152 case 'error':
8153 $status_name = 'エラー';
8154 break;
8155 case 'dlseller':
8156 $status_name = '継続課金決済エラー';
8157 break;
8158 case 'autodelivery':
8159 $status_name = '定期購�
8160 �決済エラー';
8161 break;
8162 case 'transaction':
8163 $status_name = '取引登録';
8164 break;
8165 case 'transactionOK':
8166 $status_name = '取引登録完了';
8167 break;
8168 case 'transactionNG':
8169 $status_name = '取引登録エラー';
8170 break;
8171 case 'shippingrequest':
8172 $status_name = '出荷登録';
8173 break;
8174 case 'shippingrequestOK':
8175 $status_name = '出荷登録完了';
8176 break;
8177 case 'shippingrequestNG':
8178 $status_name = '出荷登録エラー';
8179 break;
8180 case 'canceltransaction':
8181 $status_name = '取引キャンセル';
8182 break;
8183 case 'canceltransactionOK':
8184 $status_name = '取引取消完了';
8185 break;
8186 case 'canceltransactionNG':
8187 $status_name = '取引取消エラー';
8188 break;
8189 default:
8190 if ( in_array( $payment_result, $this->payment_normal_results, true ) ) {
8191 if ( 'OK' === $payment_result || 'Success_order' === $payment_result || 'SuccessOK' === $payment_result ) {
8192 $status_name = '決済完了';
8193 } else {
8194 $status_name = $payment_result;
8195 }
8196 } else {
8197 $status_name = ( ! empty( $payment_result ) ) ? $payment_result : '決済完了';
8198 }
8199 $status_name = $payment_status;
8200 }
8201 return $status_name;
8202 }
8203
8204 /**
8205 * オーダーNo 取得
8206 *
8207 * @param array $log Log data.
8208 * @return string
8209 */
8210 private function get_order_no( $log ) {
8211 $order_no = ( isset( $log['ordd'] ) ) ? $log['ordd'] : '';
8212 if ( empty( $order_no ) && isset( $log['zeusordd'] ) ) {
8213 $order_no = $log['zeusordd'];
8214 }
8215 if ( empty( $order_no ) && isset( $log['ordd'] ) ) {
8216 $order_no = $log['ordd'];
8217 }
8218 if ( empty( $order_no ) && isset( $log['order_no'] ) ) {
8219 $order_no = $log['order_no'];
8220 }
8221 if ( empty( $order_no ) && isset( $log['ORDER_NO'] ) ) {
8222 $order_no = $log['ORDER_NO'];
8223 }
8224 if ( empty( $order_no ) && isset( $log['result_order_number'] ) ) {
8225 $order_no = $log['result_order_number'];
8226 }
8227 if ( empty( $order_no ) && isset( $log['response']['data']['ORDER_NO'] ) ) {
8228 $order_no = $log['response']['data']['ORDER_NO'];
8229 }
8230 if ( empty( $order_no ) && isset( $log['response']['result']['result_order_number'] ) ) {
8231 $order_no = $log['response']['result']['result_order_number'];
8232 }
8233 return $order_no;
8234 }
8235
8236 /**
8237 * Email 取得
8238 *
8239 * @param int $order_id Order number.
8240 * @return string
8241 */
8242 private function get_email( $order_id ) {
8243 global $wpdb;
8244
8245 $query = $wpdb->prepare( "SELECT `order_email` FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
8246 $email = $wpdb->get_var( $query );
8247 return $email;
8248 }
8249
8250 /**
8251 * Get interface.
8252 *
8253 * @param string $url URL.
8254 * @return array
8255 */
8256 public function get_interface( $url ) {
8257 $interface = parse_url( $url );
8258 if ( defined( 'ZEUS_SSL_TEST' ) ) {
8259 $interface['host'] = ZEUS_SSL_TEST . $interface['host'];
8260 }
8261 if ( defined( 'ZEUS_TLS_TEST' ) ) {
8262 $interface['host'] = ZEUS_TLS_TEST;
8263 }
8264 return $interface;
8265 }
8266
8267 /**
8268 * Get acting flg.
8269 *
8270 * @param string $payment_name Payment name.
8271 * @return string
8272 */
8273 private function get_acting_flg( $payment_name ) {
8274 $payment = usces_get_payments_by_name( $payment_name );
8275 $acting_flg = ( isset( $payment['settlement'] ) && 'acting' === $payment['settlement'] ) ? $payment['module'] : $payment['settlement'];
8276 return $acting_flg;
8277 }
8278
8279 /**
8280 * Get Header Information.
8281 *
8282 * @return string
8283 */
8284 private function get_header_information() {
8285 // ヘッダー�
8286 報を格納する�
8287 �列.
8288 $header_info = array();
8289
8290 // 1-14の指定されたヘッダーを取得.
8291 $header_info[] = $_SERVER['HTTP_ACCEPT'] ?? '';
8292 $header_info[] = $_SERVER['HTTP_ACCEPT_CHARSET'] ?? '';
8293 $header_info[] = $_SERVER['HTTP_ACCEPT_ENCODING'] ?? '';
8294 $header_info[] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '';
8295 $header_info[] = $_SERVER['HTTP_CLIENT_IP'] ?? '';
8296 $header_info[] = $_SERVER['HTTP_CONNECTION'] ?? '';
8297
8298 // 7) DNTヘッダーの処理(Mozilla系ブラウザの判定).
8299 $user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
8300 if ( strpos( $user_agent, 'Mozilla' ) !== false ) {
8301 $header_info[] = $_SERVER['HTTP_DNT'] ?? '';
8302 } else {
8303 $header_info[] = $_SERVER['HTTP_X_DO_NOT_TRACK'] ?? '';
8304 }
8305
8306 $header_info[] = $_SERVER['HTTP_HOST'] ?? '';
8307 $header_info[] = $_SERVER['HTTP_REFERER'] ?? '';
8308 $header_info[] = $user_agent;
8309 $header_info[] = $_SERVER['HTTP_KEEP_ALIVE'] ?? '';
8310 $header_info[] = $_SERVER['HTTP_UA_CPU'] ?? '';
8311 $header_info[] = $_SERVER['HTTP_VIA'] ?? '';
8312 $header_info[] = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? '';
8313
8314 // 15) その他のヘッダーの処理.
8315 $other_headers = array();
8316 $all_headers = getallheaders(); // �
8317 �ヘッダーを取得.
8318
8319 // 除外するヘッダー名のリスト(大文字小文字を区別しない比較のため小文字で保持).
8320 $exclude_headers = array_map(
8321 'strtolower', [
8322 'Accept', 'Accept-Charset', 'Accept-Encoding', 'Accept-Language',
8323 'Client-IP', 'Connection', 'DNT', 'X-Do-Not-Track', 'Host',
8324 'Referer', 'User-Agent', 'Keep-Alive', 'UA-CPU', 'Via',
8325 'X-Forwarded-For',
8326 ]
8327 );
8328
8329 foreach ( $all_headers as $header => $value ) {
8330 if ( ! in_array( strtolower( $header ), $exclude_headers ) ) {
8331 $other_headers[] = $header . '--' . $value;
8332 }
8333 }
8334 $header_info[] = implode( '::', $other_headers );
8335
8336 // 16) クライアントIPアドレスの取得.
8337 $client_ip = '';
8338 if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
8339 $client_ip = $_SERVER['HTTP_CLIENT_IP'];
8340 } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
8341 $client_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
8342 } else {
8343 $client_ip = $_SERVER['REMOTE_ADDR'] ?? '';
8344 }
8345 $header_info[] = $client_ip;
8346
8347 // 17) 携帯端末識別IDの取得.
8348 $mobile_id = '';
8349 if ( isset( $_SERVER['HTTP_X_DCMGUID'] ) ) { // DoCoMo.
8350 $mobile_id = $_SERVER['HTTP_X_DCMGUID'];
8351 } elseif ( isset( $_SERVER['HTTP_X_UP_SUBNO'] ) ) { // au.
8352 $mobile_id = $_SERVER['HTTP_X_UP_SUBNO'];
8353 } elseif ( isset( $_SERVER['HTTP_X_JPHONE_UID'] ) ) { // SoftBank.
8354 $mobile_id = $_SERVER['HTTP_X_JPHONE_UID'];
8355 }
8356 $header_info[] = $mobile_id;
8357
8358 // �
8359 �ての値をセミコロンとコロンで連結.
8360 return implode( ';:', array_map( function( $value ) {
8361 return trim( $value );
8362 }, $header_info ) );
8363 }
8364
8365 /**
8366 * 手数料名称
8367 *
8368 * @param string $fee_type Fee type.
8369 * @return string
8370 */
8371 protected function get_fee_name( $fee_type ) {
8372 $fee_name = '';
8373 if ( 'fix' === $fee_type ) {
8374 $fee_name = __( 'Fixation', 'usces' );
8375 } elseif ( 'change' === $fee_type ) {
8376 $fee_name = __( 'Variable', 'usces' );
8377 }
8378 return $fee_name;
8379 }
8380 }
8381
8382 /**
8383 * Get order_ref
8384 *
8385 * @param string $order_no Order No.
8386 * @return array
8387 */
8388 function wel_zeus_get_order_ref( $order_no ) {
8389 $order_ref = array();
8390 $zeus_settlement = ZEUS_SETTLEMENT::get_instance();
8391 $acting_opts = $zeus_settlement->get_acting_settings();
8392 $interface = $zeus_settlement->get_interface( $acting_opts['card_order_ref'] );
8393
8394 $params = array();
8395 $params['clientip'] = $acting_opts['clientip'];
8396 $params['zkey'] = $acting_opts['authkey'];
8397 $params['order_no'] = $order_no;
8398 $vars = http_build_query( $params );
8399
8400 $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
8401 $header .= 'Host: ' . $interface['host'] . "\r\n";
8402 $header .= "User-Agent: PHP Script\r\n";
8403 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
8404 $header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
8405 $header .= "Connection: close\r\n\r\n";
8406 $header .= $vars;
8407
8408 $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
8409 if ( $fp ) {
8410 $xml = '';
8411 fwrite( $fp, $header );
8412 while ( ! feof( $fp ) ) {
8413 $scr = fgets( $fp, 1024 );
8414 if ( false !== strpos( $scr, '<' ) ) {
8415 $xml .= mb_convert_encoding( $scr, 'UTF-8', 'sjis-win' );
8416 }
8417 }
8418 fclose( $fp );
8419 $assoc = $zeus_settlement->xml2assoc( $xml );
8420 if ( isset( $assoc['message']['response']['data'] ) ) {
8421 $order_ref = $assoc['message']['response']['data'];
8422 if ( isset( $order_ref['RESULT'] ) ) {
8423 if ( '決済完了' === $order_ref['RESULT'] ) {
8424 $order_ref['status'] = 'payment';
8425 } elseif ( '与信完了' === $order_ref['RESULT'] || '仮売完了' === $order_ref['RESULT'] ) {
8426 $order_ref['status'] = 'auth';
8427 } elseif ( '取り消し' === $order_ref['RESULT'] ) {
8428 $order_ref['status'] = 'cancel';
8429 } else {
8430 $order_ref['status'] = $order_ref['RESULT'];
8431 }
8432 } else {
8433 $order_ref['status'] = '';
8434 }
8435 } else {
8436 $order_ref['status'] = '';
8437 }
8438 }
8439 if ( empty( $order_ref['status'] ) && false !== strpos( $order_no, 'TEST' ) ) {
8440 $order_ref['status'] = 'TEST';
8441 }
8442
8443 return $order_ref;
8444 }
8445
8446 /**
8447 * 決済ログ出力
8448 *
8449 * @param string $log Log data.
8450 * @param string $acting Acting type.
8451 * @param string $status Status.
8452 * @param string $result Result.
8453 * @param int $order_id Order number.
8454 * @param string $tracking_id Tracking ID.
8455 * @return array
8456 */
8457 function wel_zeus_save_acting_log( $log, $acting, $status, $result, $order_id, $tracking_id ) {
8458 global $wpdb;
8459
8460 if ( isset( $log['money'] ) ) {
8461 $amount = $log['money'];
8462 } elseif ( isset( $log['amount'] ) ) {
8463 $amount = $log['amount'];
8464 } elseif ( isset( $log['king'] ) ) {
8465 $amount = $log['king'];
8466 } elseif ( isset( $log['KING'] ) ) {
8467 $amount = $log['KING'];
8468 } else {
8469 $amount = 0;
8470 }
8471 $query = $wpdb->prepare(
8472 "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 )",
8473 wp_date( 'Y-m-d H:i:s' ),
8474 usces_serialize( $log ),
8475 $acting,
8476 $status,
8477 $result,
8478 $amount,
8479 $order_id,
8480 $tracking_id
8481 );
8482 $res = $wpdb->query( $query );
8483 return $res;
8484 }
8485