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

paymentPaygent.class.php in Welcart e-Commerce 2.11.31, at classes/paymentPaygent.class.php

8,826 lines 386.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * ペイジェント決済モジュール
4 *
5 * @package Welcart
6 * @author Collne Inc.
7 * @version 1.0.0
8 * @since 2.2.6
9 */
10
11 require_once USCES_PLUGIN_DIR . '/classes/pageant.config.php';
12 require_once USCES_PLUGIN_DIR . '/classes/paymentPaygent.module.class.php';
13
14 /**
15 * ペイジェント決済モジュール
16 *
17 * @package Welcart
18 * @author Collne Inc.
19 * @version 1.0.0
20 * @since 1.9.20
21 */
22 class PAYGENT_SETTLEMENT {
23
24 /**
25 * Instance of this class.
26 *
27 * @var object
28 */
29 protected static $instance = null;
30
31 /**
32 * 決済代行会社ID
33 *
34 * @var string
35 */
36 protected $paymod_id;
37
38 /**
39 * 決済種別
40 *
41 * @var string
42 */
43 protected $pay_method;
44
45 /**
46 * 決済代行会社略称
47 *
48 * @var string
49 */
50 protected $acting_name;
51
52 /**
53 * 決済代行会社正式名称
54 *
55 * @var string
56 */
57 protected $acting_formal_name;
58
59 /**
60 * 決済代行会社URL
61 *
62 * @var string
63 */
64 protected $acting_company_url;
65
66 /**
67 * 併用不可決済モジュール
68 *
69 * @var array
70 */
71 protected $unavailable_method;
72
73 /**
74 * エラーメッセージ
75 *
76 * @var string
77 */
78 protected $error_mes;
79
80 /**
81 * 自動継続課金処理結果メール
82 *
83 * @var array
84 */
85 protected $continuation_charging_mail;
86
87 /**
88 * コンビニ接続タイプA(企業コード:CVSタイプ)
89 *
90 * @var array
91 */
92 protected $cvs_type_a = array(
93 CODE_SEICOMART => '01',
94 CODE_LOWSON => '02',
95 CODE_MINISTOP => '02',
96 CODE_YAMAZAKI => '02',
97 CODE_SEVENELEVEN => '03',
98 CODE_FAMILYMART => '04',
99 );
100
101 /**
102 * コンビニ接続タイプA(企業コード:コンビニ)
103 *
104 * @var array
105 */
106 protected $cvs_company_a = array(
107 CODE_SEICOMART => 'セイコーマート',
108 CODE_LOWSON => 'ローソン',
109 CODE_MINISTOP => 'ミニストップ',
110 CODE_YAMAZAKI => 'デイリーヤマザキ',
111 CODE_SEVENELEVEN => 'セブンイレブン',
112 CODE_FAMILYMART => 'ファミリーマート',
113 );
114
115 /**
116 * 銀行ネット決済支払期間
117 *
118 * @var array
119 */
120 protected $asp_payment_term = array(
121 '0000030' => '即日購�
122 �後 30分以�
123 ',
124 '0000060' => '即日購�
125 �後 1時間以�
126 ',
127 '0000120' => '即日購�
128 �後 2時間以�
129 ',
130 '0000180' => '即日購�
131 �後 3時間以�
132 ',
133 '0000360' => '即日購�
134 �後 6時間以�
135 ',
136 '0010000' => '購�
137 �後 24時間以�
138 ',
139 '0020000' => '購�
140 �後 2日以�
141 ',
142 '0030000' => '購�
143 �後 3日以�
144 ',
145 '0050000' => '購�
146 �後 5日以�
147 ',
148 '0070000' => '購�
149 �後 7日以�
150 ',
151 '0140000' => '購�
152 �後 14日以�
153 ',
154 );
155
156 /**
157 * Construct.
158 */
159 public function __construct() {
160 $this->paymod_id = 'paygent';
161 $this->pay_method = array(
162 'acting_paygent_card',
163 'acting_paygent_conv',
164 'acting_paygent_atm',
165 'acting_paygent_bank',
166 'acting_paygent_paidy',
167 );
168 $this->acting_name = 'ペイジェント';
169 $this->acting_formal_name = 'ペイジェント';
170 $this->acting_company_url = 'https://www.paygent.co.jp/';
171
172 $this->initialize_data();
173
174 if ( is_admin() ) {
175 add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
176 add_action( 'wp_ajax_check_file_path', array( $this, 'check_file_path' ) );
177 add_action( 'wp_ajax_upload_certificate_file', array( $this, 'upload_certificate_file' ) );
178 add_action( 'usces_action_admin_settlement_update', array( $this, 'settlement_update' ) );
179 add_action( 'usces_action_settlement_tab_title', array( $this, 'settlement_tab_title' ) );
180 add_action( 'usces_action_settlement_tab_body', array( $this, 'settlement_tab_body' ) );
181 }
182
183 if ( $this->is_validity_acting() ) {
184 add_action( 'usces_after_cart_instant', array( $this, 'acting_transaction' ), 11 );
185 add_filter( 'usces_filter_is_complete_settlement', array( $this, 'is_complete_settlement' ), 10, 3 );
186 if ( is_admin() ) {
187 add_action( 'usces_action_admin_ajax', array( $this, 'admin_ajax' ) );
188 add_filter( 'usces_filter_orderlist_detail_value', array( $this, 'orderlist_settlement_status' ), 10, 4 );
189 add_action( 'usces_action_order_edit_form_status_block_middle', array( $this, 'settlement_status' ), 10, 3 );
190 add_action( 'usces_action_order_edit_form_settle_info', array( $this, 'settlement_information' ), 10, 2 );
191 add_action( 'usces_action_endof_order_edit_form', array( $this, 'settlement_dialog' ), 10, 2 );
192 add_filter( 'usces_filter_settle_info_field_meta_keys', array( $this, 'settlement_info_field_meta_keys' ) );
193 add_filter( 'usces_filter_settle_info_field_keys', array( $this, 'settlement_info_field_keys' ), 10, 2 );
194 add_filter( 'usces_filter_settle_info_field_value', array( $this, 'settlement_info_field_value' ), 10, 3 );
195 add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'order_confirm_mail_payment' ), 10, 5 );
196 add_filter( 'usces_filter_get_link_key', array( $this, 'get_link_key' ), 10, 2 );
197 add_action( 'usces_action_revival_order_data', array( $this, 'revival_orderdata' ), 10, 3 );
198 } else {
199 add_filter( 'usces_filter_payment_detail', array( $this, 'payment_detail' ), 10, 2 );
200 add_filter( 'usces_filter_payments_str', array( $this, 'payments_str' ), 10, 2 );
201 add_filter( 'usces_filter_payments_arr', array( $this, 'payments_arr' ), 10, 2 );
202 add_filter( 'usces_filter_confirm_inform', array( $this, 'confirm_inform' ), 10, 5 );
203 add_action( 'usces_action_confirm_page_point_inform', array( $this, 'e_point_inform' ), 10, 5 );
204 add_filter( 'usces_filter_confirm_point_inform', array( $this, 'point_inform' ), 10, 5 );
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' ), 1 );
209 add_action( 'usces_action_acting_processing', array( $this, 'acting_processing' ), 10, 2 );
210 add_filter( 'usces_filter_check_acting_return_results', array( $this, 'acting_return' ) );
211 add_filter( 'usces_filter_check_acting_return_duplicate', array( $this, 'check_acting_return_duplicate' ), 10, 2 );
212 add_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) );
213 add_filter( 'usces_filter_get_error_settlement', array( $this, 'error_page_message' ) );
214 add_filter( 'usces_filter_send_order_mail_payment', array( $this, 'order_mail_payment' ), 10, 6 );
215 }
216
217 if ( $this->is_validity_acting( 'card' ) ) {
218 // if ( $this->is_activate_card( 'module' ) ) {
219 add_action( 'init', array( $this, 'done_3ds_auth' ) );
220 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
221 add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ), 9 );
222 add_filter( 'usces_filter_uscesL10n', array( $this, 'set_uscesL10n' ), 12, 2 );
223 add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
224 add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
225 add_filter( 'usces_filter_save_order_acting_data', array( $this, 'save_order_acting_data' ) );
226 add_filter( 'usces_filter_delete_member_check', array( $this, 'delete_member_check' ), 10, 2 );
227 add_filter( 'usces_filter_delete_member_check_front', array( $this, 'delete_member_check' ), 10, 2 );
228 add_action( 'usces_action_pre_delete_memberdata', array( $this, 'delete_member' ) );
229 // }
230 add_filter( 'usces_filter_template_redirect', array( $this, 'member_update_settlement' ), 1 );
231 add_action( 'usces_action_member_submenu_list', array( $this, 'e_update_settlement' ) );
232 add_filter( 'usces_filter_member_submenu_list', array( $this, 'update_settlement' ), 10, 2 );
233 if ( is_admin() ) {
234 add_action( 'usces_action_admin_member_info', array( $this, 'admin_member_info' ), 10, 3 );
235 add_action( 'usces_action_post_update_memberdata', array( $this, 'admin_update_memberdata' ), 10, 2 );
236 }
237
238 /* WCEX DL Seller */
239 if ( defined( 'WCEX_DLSELLER' ) ) {
240 add_filter( 'usces_filter_the_continue_payment_method', array( $this, 'continuation_payment_method' ) );
241 add_filter( 'dlseller_filter_first_charging', array( $this, 'first_charging_date' ), 9, 5 );
242 add_filter( 'dlseller_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction' ), 10, 2 );
243 add_filter( 'dlseller_filter_continue_member_list_condition', array( $this, 'continue_member_list_condition' ), 10, 4 );
244 add_action( 'dlseller_action_continue_member_list_page', array( $this, 'continue_member_list_page' ) );
245 add_action( 'dlseller_action_do_continuation_charging', array( $this, 'auto_continuation_charging' ), 10, 4 );
246 add_action( 'dlseller_action_do_continuation', array( $this, 'do_auto_continuation' ), 10, 2 );
247 add_filter( 'dlseller_filter_reminder_mail_body', array( $this, 'reminder_mail_body' ), 10, 3 );
248 add_filter( 'dlseller_filter_contract_renewal_mail_body', array( $this, 'contract_renewal_mail_body' ), 10, 3 );
249 }
250
251 /* WCEX Auto Delivery */
252 if ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
253 if ( is_admin() && version_compare( WCEX_AUTO_DELIVERY_VERSION, '1.2.3', '<' ) ) {
254 add_filter( 'wcad_filter_admin_notices', array( $this, 'admin_notices_autodelivery' ), 11 );
255 }
256 add_filter( 'wcad_filter_shippinglist_acting', array( $this, 'set_shippinglist_acting' ) );
257 add_filter( 'wcad_filter_available_regular_payment_method', array( $this, 'available_regular_payment_method' ) );
258 add_filter( 'wcad_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction' ), 10, 2 );
259 add_action( 'wcad_action_reg_auto_orderdata', array( $this, 'register_auto_orderdata' ) );
260 }
261 }
262
263 if ( $this->is_validity_acting( 'conv' ) ) {
264 add_filter( 'usces_filter_noreceipt_status', array( $this, 'noreceipt_status' ) );
265 if ( $this->is_activate_conv( 'module' ) ) {
266 add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ), 9 );
267 add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
268 add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
269 add_filter( 'usces_filter_completion_settlement_message', array( $this, 'completion_settlement_message' ), 10, 2 );
270 }
271 }
272
273 if ( $this->is_validity_acting( 'atm' ) ) {
274 add_filter( 'usces_filter_noreceipt_status', array( $this, 'noreceipt_status' ) );
275 if ( $this->is_activate_atm() ) {
276 add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
277 add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
278 add_filter( 'usces_filter_completion_settlement_message', array( $this, 'completion_settlement_message' ), 10, 2 );
279 }
280 }
281
282 if ( $this->is_validity_acting( 'bank' ) ) {
283 add_filter( 'usces_filter_noreceipt_status', array( $this, 'noreceipt_status' ) );
284 if ( $this->is_activate_bank() ) {
285 add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
286 add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
287 }
288 }
289
290 if ( $this->is_validity_acting( 'paidy' ) ) {
291 if ( $this->is_activate_paidy() ) {
292 add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ), 9 );
293 }
294 }
295 }
296 }
297
298 /**
299 * Return an instance of this class.
300 */
301 public static function get_instance() {
302 if ( is_null( self::$instance ) ) {
303 self::$instance = new self();
304 }
305 return self::$instance;
306 }
307
308 /**
309 * Initialize.
310 */
311 public function initialize_data() {
312 $options = get_option( 'usces', array() );
313 $options['acting_settings']['paygent']['activate'] = ( isset( $options['acting_settings']['paygent']['activate'] ) ) ? $options['acting_settings']['paygent']['activate'] : 'off';
314 $options['acting_settings']['paygent']['seq_merchant_id'] = ( isset( $options['acting_settings']['paygent']['seq_merchant_id'] ) ) ? $options['acting_settings']['paygent']['seq_merchant_id'] : '';
315 $options['acting_settings']['paygent']['connect_id'] = ( isset( $options['acting_settings']['paygent']['connect_id'] ) ) ? $options['acting_settings']['paygent']['connect_id'] : '';
316 $options['acting_settings']['paygent']['connect_password'] = ( isset( $options['acting_settings']['paygent']['connect_password'] ) ) ? $options['acting_settings']['paygent']['connect_password'] : '';
317 $options['acting_settings']['paygent']['telegram_version'] = TELEGRAM_VERSION;
318 $options['acting_settings']['paygent']['hc'] = ( isset( $options['acting_settings']['paygent']['hc'] ) ) ? $options['acting_settings']['paygent']['hc'] : '';
319 $options['acting_settings']['paygent']['conv_hc'] = ( isset( $options['acting_settings']['paygent']['conv_hc'] ) ) ? $options['acting_settings']['paygent']['conv_hc'] : '';
320 $options['acting_settings']['paygent']['ope'] = ( isset( $options['acting_settings']['paygent']['ope'] ) ) ? $options['acting_settings']['paygent']['ope'] : '';
321 $options['acting_settings']['paygent']['card_activate'] = ( isset( $options['acting_settings']['paygent']['card_activate'] ) ) ? $options['acting_settings']['paygent']['card_activate'] : 'off';
322 $options['acting_settings']['paygent']['token_key'] = ( isset( $options['acting_settings']['paygent']['token_key'] ) ) ? $options['acting_settings']['paygent']['token_key'] : '';
323 $options['acting_settings']['paygent']['token_hc'] = ( isset( $options['acting_settings']['paygent']['token_hc'] ) ) ? $options['acting_settings']['paygent']['token_hc'] : '';
324 $options['acting_settings']['paygent']['certificate_path'] = ( isset( $options['acting_settings']['paygent']['certificate_path'] ) ) ? $options['acting_settings']['paygent']['certificate_path'] : '';
325 $options['acting_settings']['paygent']['client_file'] = ( isset( $options['acting_settings']['paygent']['client_file'] ) ) ? $options['acting_settings']['paygent']['client_file'] : '';
326 $options['acting_settings']['paygent']['ca_file'] = ( isset( $options['acting_settings']['paygent']['ca_file'] ) ) ? $options['acting_settings']['paygent']['ca_file'] : '';
327 $options['acting_settings']['paygent']['payment_class'] = ( isset( $options['acting_settings']['paygent']['payment_class'] ) ) ? $options['acting_settings']['paygent']['payment_class'] : '';
328 $options['acting_settings']['paygent']['use_card_conf_number'] = ( isset( $options['acting_settings']['paygent']['use_card_conf_number'] ) ) ? $options['acting_settings']['paygent']['use_card_conf_number'] : '';
329 $options['acting_settings']['paygent']['stock_card_mode'] = ( isset( $options['acting_settings']['paygent']['stock_card_mode'] ) ) ? $options['acting_settings']['paygent']['stock_card_mode'] : '';
330 $options['acting_settings']['paygent']['sales_mode'] = ( isset( $options['acting_settings']['paygent']['sales_mode'] ) ) ? $options['acting_settings']['paygent']['sales_mode'] : '0';
331 $options['acting_settings']['paygent']['sales_mode_dlseller'] = ( isset( $options['acting_settings']['paygent']['sales_mode_dlseller'] ) ) ? $options['acting_settings']['paygent']['sales_mode_dlseller'] : '0';
332 $options['acting_settings']['paygent']['auto_settlement_mail'] = ( isset( $options['acting_settings']['paygent']['auto_settlement_mail'] ) ) ? $options['acting_settings']['paygent']['auto_settlement_mail'] : 'off';
333 $options['acting_settings']['paygent']['threedsecure_ryaku'] = ( isset( $options['acting_settings']['paygent']['threedsecure_ryaku'] ) ) ? $options['acting_settings']['paygent']['threedsecure_ryaku'] : 'off';
334 $options['acting_settings']['paygent']['threedsecure_hc'] = ( isset( $options['acting_settings']['paygent']['threedsecure_hc'] ) ) ? $options['acting_settings']['paygent']['threedsecure_hc'] : '';
335 $options['acting_settings']['paygent']['attempt'] = ( isset( $options['acting_settings']['paygent']['attempt'] ) ) ? $options['acting_settings']['paygent']['attempt'] : 'on';
336 $options['acting_settings']['paygent']['conv_activate'] = ( isset( $options['acting_settings']['paygent']['conv_activate'] ) ) ? $options['acting_settings']['paygent']['conv_activate'] : 'off';
337 $options['acting_settings']['paygent']['payment_term_day'] = ( isset( $options['acting_settings']['paygent']['payment_term_day'] ) ) ? $options['acting_settings']['paygent']['payment_term_day'] : '';
338 $options['acting_settings']['paygent']['payment_term_min'] = ( isset( $options['acting_settings']['paygent']['payment_term_min'] ) ) ? $options['acting_settings']['paygent']['payment_term_min'] : '';
339 $options['acting_settings']['paygent']['sales_type'] = ( isset( $options['acting_settings']['paygent']['sales_type'] ) ) ? $options['acting_settings']['paygent']['sales_type'] : '1';
340 $options['acting_settings']['paygent']['cvs_type'] = ( ! empty( $options['acting_settings']['paygent']['cvs_type'] ) ) ? $options['acting_settings']['paygent']['cvs_type'] : array( '01', '02', '03', '04' );
341 $options['acting_settings']['paygent']['atm_activate'] = ( isset( $options['acting_settings']['paygent']['atm_activate'] ) ) ? $options['acting_settings']['paygent']['atm_activate'] : 'off';
342 $options['acting_settings']['paygent']['payment_limit_date'] = ( isset( $options['acting_settings']['paygent']['payment_limit_date'] ) ) ? $options['acting_settings']['paygent']['payment_limit_date'] : '';
343 $options['acting_settings']['paygent']['bank_activate'] = ( isset( $options['acting_settings']['paygent']['bank_activate'] ) ) ? $options['acting_settings']['paygent']['bank_activate'] : 'off';
344 $options['acting_settings']['paygent']['asp_payment_term'] = ( isset( $options['acting_settings']['paygent']['asp_payment_term'] ) ) ? $options['acting_settings']['paygent']['asp_payment_term'] : '0050000';
345 $options['acting_settings']['paygent']['paidy_activate'] = ( isset( $options['acting_settings']['paygent']['paidy_activate'] ) ) ? $options['acting_settings']['paygent']['paidy_activate'] : 'off';
346 $options['acting_settings']['paygent']['paidy_public_key'] = ( isset( $options['acting_settings']['paygent']['paidy_public_key'] ) ) ? $options['acting_settings']['paygent']['paidy_public_key'] : '';
347 if ( empty( $options['acting_settings']['paygent']['certificate_path'] ) ) {
348 $upload_dir = wp_upload_dir();
349 $dir = $this->create_certificate_path();
350 $options['acting_settings']['paygent']['certificate_path'] = $upload_dir['basedir'] . $dir;
351 }
352 update_option( 'usces', $options );
353
354 $available_settlement = get_option( 'usces_available_settlement' );
355 if ( ! in_array( $this->paymod_id, $available_settlement ) ) {
356 $available_settlement[ $this->paymod_id ] = $this->acting_formal_name;
357 update_option( 'usces_available_settlement', $available_settlement );
358 }
359
360 $this->unavailable_method = array( 'acting_paidy' );
361 }
362
363 /**
364 * 証明書ファイルパス名生成
365 *
366 * @return string
367 */
368 private function create_certificate_path() {
369 $dir = '/p' . substr( str_shuffle( '1234567890abcdefghijklmnopqrstuvwxyz' ), 0, 12 );
370 return $dir;
371 }
372
373 /**
374 * 決済有効判定
375 * 支払方法で使用している場合に true
376 *
377 * @param string $type Module type.
378 * @return boolean
379 */
380 public function is_validity_acting( $type = '' ) {
381 $acting_opts = $this->get_acting_settings();
382 if ( empty( $acting_opts ) ) {
383 return false;
384 }
385
386 $payment_method = usces_get_system_option( 'usces_payment_method', 'sort' );
387 $method = false;
388
389 switch ( $type ) {
390 case 'card':
391 foreach ( $payment_method as $payment ) {
392 if ( 'acting_paygent_card' == $payment['settlement'] && 'activate' == $payment['use'] ) {
393 $method = true;
394 break;
395 }
396 }
397 if ( $method && $this->is_activate_card() ) {
398 return true;
399 } else {
400 return false;
401 }
402 break;
403 case 'conv':
404 foreach ( $payment_method as $payment ) {
405 if ( 'acting_paygent_conv' == $payment['settlement'] && 'activate' == $payment['use'] ) {
406 $method = true;
407 break;
408 }
409 }
410 if ( $method && $this->is_activate_conv() ) {
411 return true;
412 } else {
413 return false;
414 }
415 break;
416 case 'atm':
417 foreach ( $payment_method as $payment ) {
418 if ( 'acting_paygent_atm' == $payment['settlement'] && 'activate' == $payment['use'] ) {
419 $method = true;
420 break;
421 }
422 }
423 if ( $method && $this->is_activate_atm() ) {
424 return true;
425 } else {
426 return false;
427 }
428 break;
429 case 'bank':
430 foreach ( $payment_method as $payment ) {
431 if ( 'acting_paygent_bank' == $payment['settlement'] && 'activate' == $payment['use'] ) {
432 $method = true;
433 break;
434 }
435 }
436 if ( $method && $this->is_activate_bank() ) {
437 return true;
438 } else {
439 return false;
440 }
441 break;
442 case 'paidy':
443 foreach ( $payment_method as $payment ) {
444 if ( 'acting_paygent_paidy' == $payment['settlement'] && 'activate' == $payment['use'] ) {
445 $method = true;
446 break;
447 }
448 }
449 if ( $method && $this->is_activate_paidy() ) {
450 return true;
451 } else {
452 return false;
453 }
454 break;
455 default:
456 if ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) {
457 return true;
458 } else {
459 return false;
460 }
461 }
462 }
463
464 /**
465 * クレジットカード決済有効判定
466 *
467 * @param string $type 'link'|'module'.
468 * @return boolean
469 */
470 public function is_activate_card( $type = '' ) {
471 $acting_opts = $this->get_acting_settings();
472 if ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) {
473 if ( empty( $type ) ) {
474 if ( isset( $acting_opts['card_activate'] ) && ( 'off' != $acting_opts['card_activate'] ) ) {
475 $res = true;
476 } else {
477 $res = false;
478 }
479 } elseif ( 'link' == $type ) {
480 if ( isset( $acting_opts['card_activate'] ) && ( 'on' == $acting_opts['card_activate'] ) ) {
481 $res = true;
482 } else {
483 $res = false;
484 }
485 } elseif ( 'module' == $type ) {
486 if ( isset( $acting_opts['card_activate'] ) && ( 'module' == $acting_opts['card_activate'] ) ) {
487 $res = true;
488 } else {
489 $res = false;
490 }
491 } else {
492 $res = false;
493 }
494 } else {
495 $res = false;
496 }
497 return $res;
498 }
499
500 /**
501 * コンビニ決済有効判定
502 *
503 * @param string $type 'link'|'module'.
504 * @return boolean
505 */
506 public function is_activate_conv( $type = '' ) {
507 $acting_opts = $this->get_acting_settings();
508 if ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) {
509 if ( empty( $type ) ) {
510 if ( isset( $acting_opts['conv_activate'] ) && ( 'off' != $acting_opts['conv_activate'] ) ) {
511 $res = true;
512 } else {
513 $res = false;
514 }
515 } elseif ( 'link' == $type ) {
516 if ( isset( $acting_opts['conv_activate'] ) && ( 'on' == $acting_opts['conv_activate'] ) ) {
517 $res = true;
518 } else {
519 $res = false;
520 }
521 } elseif ( 'module' == $type ) {
522 if ( isset( $acting_opts['conv_activate'] ) && ( 'module' == $acting_opts['conv_activate'] ) ) {
523 $res = true;
524 } else {
525 $res = false;
526 }
527 } else {
528 $res = false;
529 }
530 } else {
531 $res = false;
532 }
533 return $res;
534 }
535
536 /**
537 * ATM決済(Pay-easy)有効判定
538 *
539 * @return boolean
540 */
541 public function is_activate_atm() {
542 $acting_opts = $this->get_acting_settings();
543 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
544 ( isset( $acting_opts['atm_activate'] ) && 'module' == $acting_opts['atm_activate'] ) ) {
545 $res = true;
546 } else {
547 $res = false;
548 }
549 return $res;
550 }
551
552 /**
553 * 銀行ネット決済有効判定
554 *
555 * @return boolean
556 */
557 public function is_activate_bank() {
558 $acting_opts = $this->get_acting_settings();
559 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
560 ( isset( $acting_opts['bank_activate'] ) && 'module' == $acting_opts['bank_activate'] ) ) {
561 $res = true;
562 } else {
563 $res = false;
564 }
565 return $res;
566 }
567
568 /**
569 * Paidy決済有効判定
570 *
571 * @return boolean
572 */
573 public function is_activate_paidy() {
574 $acting_opts = $this->get_acting_settings();
575 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
576 ( isset( $acting_opts['paidy_activate'] ) && 'module' == $acting_opts['paidy_activate'] ) ) {
577 $res = true;
578 } else {
579 $res = false;
580 }
581 return $res;
582 }
583
584 /**
585 * 未�
586 �金ステータス
587 * usces_filter_noreceipt_status
588 *
589 * @param array $noreceipt_status Receive payment notification.
590 * @return array
591 */
592 public function noreceipt_status( $noreceipt_status ) {
593 if ( ! in_array( 'acting_paygent_conv', $noreceipt_status ) || ! in_array( 'acting_paygent_atm', $noreceipt_status ) || ! in_array( 'acting_paygent_bank', $noreceipt_status ) ) {
594 $noreceipt_status[] = 'acting_paygent_conv';
595 $noreceipt_status[] = 'acting_paygent_atm';
596 $noreceipt_status[] = 'acting_paygent_bank';
597 $noreceipt_status = array_unique( $noreceipt_status );
598 update_option( 'usces_noreceipt_status', $noreceipt_status );
599 }
600 return $noreceipt_status;
601 }
602
603 /**
604 * 管理画面スクリプト
605 * admin_print_footer_scripts
606 */
607 public function admin_scripts() {
608 $admin_page = ( isset( $_GET['page'] ) ) ? wp_unslash( $_GET['page'] ) : '';
609 switch ( $admin_page ) :
610 /* クレジット決済設定画面 */
611 case 'usces_settlement':
612 $settlement_selected = get_option( 'usces_settlement_selected' );
613 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) :
614 $acting_opts = $this->get_acting_settings();
615 ?>
616 <script type="text/javascript">
617 jQuery( document ).ready( function( $ ) {
618 var paygent_card_activate = "<?php echo esc_js( $acting_opts['card_activate'] ); ?>";
619 var paygent_card_threedsecure = "<?php echo esc_js( $acting_opts['threedsecure_ryaku'] ); ?>";
620 if ( "on" == paygent_card_activate ) {
621 $( ".paygent_card_form" ).css( "display", "" );
622 $( ".paygent_card_module" ).css( "display", "none" );
623 $( ".paygent_card_threedsecure" ).css( "display", "none" );
624 } else if ( "module" == paygent_card_activate ) {
625 $( ".paygent_card_form" ).css( "display", "" );
626 $( ".paygent_card_module" ).css( "display", "" );
627 if ( "on" == paygent_card_threedsecure ) {
628 $( ".paygent_card_threedsecure" ).css( "display", "" );
629 } else {
630 $( ".paygent_card_threedsecure" ).css( "display", "none" );
631 }
632 } else {
633 $( ".paygent_card_form" ).css( "display", "none" );
634 $( ".paygent_card_module" ).css( "display", "none" );
635 $( ".paygent_card_threedsecure" ).css( "display", "none" );
636 }
637 $( document ).on( "change", ".activate_paygent_card", function() {
638 if ( "on" == $( this ).val() ) {
639 $( ".paygent_card_form" ).css( "display", "" );
640 $( ".paygent_card_module" ).css( "display", "none" );
641 $( ".paygent_card_threedsecure" ).css( "display", "none" );
642 } else if ( "module" == $( this ).val() ) {
643 $( ".paygent_card_form" ).css( "display", "" );
644 $( ".paygent_card_module" ).css( "display", "" );
645 if ( "on" == $( "input[name='threedsecure_ryaku']:checked" ).val() ) {
646 $( ".paygent_card_threedsecure" ).css( "display", "" );
647 } else {
648 $( ".paygent_card_threedsecure" ).css( "display", "none" );
649 }
650 } else {
651 $( ".paygent_card_form" ).css( "display", "none" );
652 $( ".paygent_card_module" ).css( "display", "none" );
653 $( ".paygent_card_threedsecure" ).css( "display", "none" );
654 }
655 });
656 if ( "on" == paygent_card_threedsecure && "module" == paygent_card_activate ) {
657 $( ".paygent_card_threedsecure" ).css( "display", "" );
658 } else {
659 $( ".paygent_card_threedsecure" ).css( "display", "none" );
660 }
661 $( document ).on( "change", ".activate_paygent_card_threedsecure", function() {
662 if ( "module" == $( "input[name='card_activate']:checked" ).val() ) {
663 if ( "on" == $( this ).val() ) {
664 $( ".paygent_card_threedsecure" ).css( "display", "" );
665 } else {
666 $( ".paygent_card_threedsecure" ).css( "display", "none" );
667 }
668 }
669 });
670
671 var paygent_conv_activate = "<?php echo esc_js( $acting_opts['conv_activate'] ); ?>";
672 if ( "on" == paygent_conv_activate ) {
673 $( ".paygent_conv_form" ).css( "display", "" );
674 $( ".paygent_conv_link" ).css( "display", "" );
675 $( ".paygent_conv_module" ).css( "display", "none" );
676 } else if ( "module" == paygent_conv_activate ) {
677 $( ".paygent_conv_form" ).css( "display", "" );
678 $( ".paygent_conv_link" ).css( "display", "none" );
679 $( ".paygent_conv_module" ).css( "display", "" );
680 } else {
681 $( ".paygent_conv_form" ).css( "display", "none" );
682 $( ".paygent_conv_link" ).css( "display", "none" );
683 $( ".paygent_conv_module" ).css( "display", "none" );
684 }
685 $( document ).on( "change", ".activate_paygent_conv", function() {
686 if ( "on" == $( this ).val() ) {
687 $( ".paygent_conv_form" ).css( "display", "" );
688 $( ".paygent_conv_link" ).css( "display", "" );
689 $( ".paygent_conv_module" ).css( "display", "none" );
690 } else if ( "module" == $( this ).val() ) {
691 $( ".paygent_conv_form" ).css( "display", "" );
692 $( ".paygent_conv_link" ).css( "display", "none" );
693 $( ".paygent_conv_module" ).css( "display", "" );
694 } else {
695 $( ".paygent_conv_form" ).css( "display", "none" );
696 $( ".paygent_conv_link" ).css( "display", "none" );
697 $( ".paygent_conv_module" ).css( "display", "none" );
698 }
699 });
700
701 var paygent_atm_activate = "<?php echo esc_js( $acting_opts['atm_activate'] ); ?>";
702 if ( "module" == paygent_atm_activate ) {
703 $( ".paygent_atm_form" ).css( "display", "" );
704 } else {
705 $( ".paygent_atm_form" ).css( "display", "none" );
706 }
707 $( document ).on( "change", ".activate_paygent_atm", function() {
708 if ( "module" == $( this ).val() ) {
709 $( ".paygent_atm_form" ).css( "display", "" );
710 } else {
711 $( ".paygent_atm_form" ).css( "display", "none" );
712 }
713 });
714
715 var paygent_bank_activate = "<?php echo esc_js( $acting_opts['bank_activate'] ); ?>";
716 if ( "module" == paygent_bank_activate ) {
717 $( ".paygent_bank_form" ).css( "display", "" );
718 } else {
719 $( ".paygent_bank_form" ).css( "display", "none" );
720 }
721 $( document ).on( "change", ".activate_paygent_bank", function() {
722 if ( "module" == $( this ).val() ) {
723 $( ".paygent_bank_form" ).css( "display", "" );
724 } else {
725 $( ".paygent_bank_form" ).css( "display", "none" );
726 }
727 });
728
729 var paygent_paidy_activate = "<?php echo esc_js( $acting_opts['paidy_activate'] ); ?>";
730 if ( "module" == paygent_paidy_activate ) {
731 $( ".paygent_paidy_form" ).css( "display", "" );
732 } else {
733 $( ".paygent_paidy_form" ).css( "display", "none" );
734 }
735 $( document ).on( "change", ".activate_paygent_paidy", function() {
736 if ( "module" == $( this ).val() ) {
737 $( ".paygent_paidy_form" ).css( "display", "" );
738 } else {
739 $( ".paygent_paidy_form" ).css( "display", "none" );
740 }
741 });
742
743 $( document ).on( "click", "#change_certificate_path", function() {
744 $( "#certificate_path_paygent" ).prop( "disabled", "" );
745 });
746
747 $( document ).on( "click", "#client_file_upload", function() {
748 $.ajax({
749 url: ajaxurl,
750 type: "POST",
751 cache: false,
752 dataType: "json",
753 data: {
754 action: "check_file_path",
755 path: $( "#certificate_path_paygent" ).val(),
756 file: $( "#client_file_paygent" ).val(),
757 wc_nonce: $( "#wc_nonce" ).val()
758 }
759 }).done( function( retVal, dataType ) {
760 if ( "OK" == retVal.status ) {
761 if ( ! retVal.file_exists ) {
762 $( "#client_file_paygent" ).val( "" );
763 }
764 $( "#upload_filetype" ).val( "client_file" );
765 $( "#upload_file" ).prop( 'accept', ".pem" );
766 $( "#filetype_description" ).html( "拡張子「.pem」のファイルを指定してください。" );
767 $( "#upload_dialog_paygent" ).dialog( "option" , "title" , "クライアント証明書ファイルのアップロード" );
768 $( "#upload_dialog_paygent" ).dialog( "open" );
769 } else {
770 alert( retVal.status );
771 return false;
772 }
773 }).fail( function( retVal ) {
774 });
775 return false;
776 });
777
778 $( document ).on( "click", "#ca_file_upload", function() {
779 $.ajax({
780 url: ajaxurl,
781 type: "POST",
782 cache: false,
783 dataType: "json",
784 data: {
785 action: "check_file_path",
786 path: $( "#certificate_path_paygent" ).val(),
787 file: $( "#ca_file_paygent" ).val(),
788 wc_nonce: $( "#wc_nonce" ).val()
789 }
790 }).done( function( retVal ) {
791 if ( "OK" == retVal.status ) {
792 if ( ! retVal.file_exists ) {
793 $( "#ca_file_paygent" ).val( "" );
794 }
795 $( "#upload_filetype" ).val( "ca_file" );
796 $( "#upload_file" ).prop( 'accept', ".crt" );
797 $( "#filetype_description" ).html( "拡張子「.crt」のファイルを指定してください。" );
798 $( "#upload_dialog_paygent" ).dialog( "option" , "title" , "証明済みのCAファイルのアップロード" );
799 $( "#upload_dialog_paygent" ).dialog( "open" );
800 } else {
801 alert( retVal.status );
802 return false;
803 }
804 }).fail( function( retVal ) {
805 });
806 return false;
807 });
808
809 $( "#upload_dialog_paygent" ).dialog({
810 bgiframe: true,
811 autoOpen: false,
812 height: 240,
813 width: 400,
814 modal: true,
815 buttons: {
816 "<?php esc_html_e( 'Cancel', 'usces' ); ?>": function() {
817 $( this ).dialog( 'close' );
818 }
819 },
820 close: function() {
821 $( "#upload_file" ).val( "" );
822 }
823 });
824
825 $( "#upload_button" ).on( "click", function() {
826 let $upfile = $( 'input[name="upload_file"]' );
827 let fd = new FormData();
828 fd.append( "action", 'upload_certificate_file' );
829 fd.append( "upfile", $upfile.prop( 'files' )[0] );
830 fd.append( "upfile_name", $upfile.prop( 'files' )[0].name );
831 fd.append( "upfile_type", $( "#upload_filetype" ).val() );
832 fd.append( "wc_nonce", $( "#wc_nonce" ).val() );
833 $.ajax({
834 url: ajaxurl,
835 type: "POST",
836 data: fd,
837 processData: false,
838 contentType: false,
839 cache: false,
840 }).done( function( retVal ) {
841 if ( "OK" == retVal.status ) {
842 if ( "client_file" == $( "#upload_filetype" ).val() ) {
843 $( "#client_file_paygent" ).val( $upfile.prop( 'files' )[0].name );
844 } else if ( "ca_file" == $( "#upload_filetype" ).val() ) {
845 $( "#ca_file_paygent" ).val( $upfile.prop( 'files' )[0].name );
846 }
847 $( "#upload_dialog_paygent" ).dialog( 'close' );
848 } else {
849 alert( "アップロードに失敗しました。" );
850 }
851 }).fail( function() {
852 console.log( retVal );
853 });
854 });
855 });
856 </script>
857 <?php
858 endif;
859 break;
860
861 /* 受注編集画面・継続課金会員詳細画面 */
862 case 'usces_orderlist':
863 case 'usces_continue':
864 $order_id = '';
865 $acting_flg = '';
866 if ( ( 'usces_orderlist' == $admin_page && ( isset( $_GET['order_action'] ) && ( 'edit' == wp_unslash( $_GET['order_action'] ) || 'editpost' == wp_unslash( $_GET['order_action'] ) || 'newpost' == wp_unslash( $_GET['order_action'] ) ) ) ) ||
867 ( 'usces_continue' == $admin_page && ( isset( $_GET['continue_action'] ) && 'settlement_paygent_card' == wp_unslash( $_GET['continue_action'] ) ) ) ) {
868 $order_id = ( isset( $_REQUEST['order_id'] ) ) ? wp_unslash( $_REQUEST['order_id'] ) : '';
869 if ( ! empty( $order_id ) ) {
870 $acting_flg = $this->get_order_acting_flg( $order_id );
871 }
872 }
873 if ( in_array( $acting_flg, $this->pay_method ) ) :
874 ?>
875 <script type="text/javascript">
876 jQuery( document ).ready( function( $ ) {
877 adminOrderEdit = {
878 updateSettlementStatus : function( mode ) {
879 $( "#settlement-response" ).html( "" );
880 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
881 $.ajax({
882 url: ajaxurl,
883 type: "POST",
884 cache: false,
885 dataType: "json",
886 data: {
887 action: "usces_admin_ajax",
888 mode: "get_paygent_" + mode,
889 order_id: $( "#order_id" ).val(),
890 trading_id: $( "#trading_id" ).val(),
891 member_id: $( "#member_id" ).val(),
892 wc_nonce: $( "#wc_nonce" ).val()
893 }
894 }).done( function( retVal, dataType ) {
895 if ( retVal.acting_status ) {
896 var num = $( "#order_num" ).val();
897 if ( $( "#settlement-status-" + num ).length ) {
898 $( "#settlement-status-" + num ).html( retVal.acting_status );
899 } else {
900 $( "#settlement-status" ).html( retVal.acting_status );
901 }
902 }
903 if ( retVal.result ) {
904 $( "#settlement-response" ).html( retVal.result );
905 }
906 $( "#settlement-response-loading" ).html( "" );
907 }).fail( function( jqXHR, textStatus, errorThrown ) {
908 console.log( textStatus );
909 console.log( jqXHR.status );
910 console.log( errorThrown.message );
911 $( "#settlement-response-loading" ).html( "" );
912 });
913 return false;
914 },
915 <?php
916 if ( 'acting_paygent_card' == $acting_flg ) :
917 ?>
918 getSettlementCard : function() {
919 $( "#settlement-response" ).html( "" );
920 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
921 var mode = ( "" != $( "#error" ).val() ) ? "error_paygent_card" : "get_paygent_card";
922 $.ajax({
923 url: ajaxurl,
924 type: "POST",
925 cache: false,
926 dataType: "json",
927 data: {
928 action: "usces_admin_ajax",
929 mode: mode,
930 order_id: $( "#order_id" ).val(),
931 trading_id: $( "#trading_id" ).val(),
932 member_id: $( "#member_id" ).val(),
933 wc_nonce: $( "#wc_nonce" ).val()
934 }
935 }).done( function( retVal, dataType ) {
936 if ( retVal.acting_status ) {
937 var num = $( "#order_num" ).val();
938 if ( $( "#settlement-status-" + num ).length ) {
939 $( "#settlement-status-" + num ).html( retVal.acting_status );
940 } else {
941 $( "#settlement-status" ).html( retVal.acting_status );
942 }
943 }
944 if ( retVal.result ) {
945 $( "#settlement-response" ).html( retVal.result );
946 }
947 $( "#settlement-response-loading" ).html( "" );
948 }).fail( function( jqXHR, textStatus, errorThrown ) {
949 console.log( textStatus );
950 console.log( jqXHR.status );
951 console.log( errorThrown.message );
952 $( "#settlement-response-loading" ).html( "" );
953 });
954 return false;
955 },
956 salesSettlementCard : function() {
957 $( "#settlement-response" ).html( "" );
958 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
959 $.ajax({
960 url: ajaxurl,
961 type: "POST",
962 cache: false,
963 dataType: "json",
964 data: {
965 action: "usces_admin_ajax",
966 mode: "sales_paygent_card",
967 order_id: $( "#order_id" ).val(),
968 trading_id: $( "#trading_id" ).val(),
969 member_id: $( "#member_id" ).val(),
970 wc_nonce: $( "#wc_nonce" ).val()
971 }
972 }).done( function( retVal, dataType ) {
973 if ( retVal.acting_status ) {
974 var num = $( "#order_num" ).val();
975 if ( $( "#settlement-status-" + num ).length ) {
976 $( "#settlement-status-" + num ).html( retVal.acting_status );
977 } else {
978 $( "#settlement-status" ).html( retVal.acting_status );
979 }
980 }
981 if ( retVal.result ) {
982 $( "#settlement-response" ).html( retVal.result );
983 }
984 $( "#settlement-response-loading" ).html( "" );
985 }).fail( function( jqXHR, textStatus, errorThrown ) {
986 console.log( textStatus );
987 console.log( jqXHR.status );
988 console.log( errorThrown.message );
989 $( "#settlement-response-loading" ).html( "" );
990 });
991 return false;
992 },
993 cancelSettlementCard : function( mode ) {
994 $( "#settlement-response" ).html( "" );
995 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
996 $.ajax({
997 url: ajaxurl,
998 type: "POST",
999 cache: false,
1000 dataType: "json",
1001 data: {
1002 action: "usces_admin_ajax",
1003 mode: mode + "_cancel_paygent_card",
1004 order_id: $( "#order_id" ).val(),
1005 trading_id: $( "#trading_id" ).val(),
1006 member_id: $( "#member_id" ).val(),
1007 wc_nonce: $( "#wc_nonce" ).val()
1008 }
1009 }).done( function( retVal, dataType ) {
1010 if ( retVal.acting_status ) {
1011 var num = $( "#order_num" ).val();
1012 if ( $( "#settlement-status-" + num ).length ) {
1013 $( "#settlement-status-" + num ).html( retVal.acting_status );
1014 } else {
1015 $( "#settlement-status" ).html( retVal.acting_status );
1016 }
1017 }
1018 if ( retVal.result ) {
1019 $( "#settlement-response" ).html( retVal.result );
1020 }
1021 $( "#settlement-response-loading" ).html( "" );
1022 }).fail( function( jqXHR, textStatus, errorThrown ) {
1023 console.log( textStatus );
1024 console.log( jqXHR.status );
1025 console.log( errorThrown.message );
1026 $( "#settlement-response-loading" ).html( "" );
1027 });
1028 return false;
1029 },
1030 changeSettlementCard : function( mode, amount ) {
1031 $( "#settlement-response" ).html( "" );
1032 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1033 $.ajax({
1034 url: ajaxurl,
1035 type: "POST",
1036 cache: false,
1037 dataType: "json",
1038 data: {
1039 action: "usces_admin_ajax",
1040 mode: mode + "_revise_paygent_card",
1041 order_id: $( "#order_id" ).val(),
1042 trading_id: $( "#trading_id" ).val(),
1043 member_id: $( "#member_id" ).val(),
1044 amount: amount,
1045 wc_nonce: $( "#wc_nonce" ).val()
1046 }
1047 }).done( function( retVal, dataType ) {
1048 if ( retVal.acting_status ) {
1049 var num = $( "#order_num" ).val();
1050 if ( $( "#settlement-status-" + num ).length ) {
1051 $( "#settlement-status-" + num ).html( retVal.acting_status );
1052 } else {
1053 $( "#settlement-status" ).html( retVal.acting_status );
1054 }
1055 }
1056 if ( retVal.result ) {
1057 $( "#settlement-response" ).html( retVal.result );
1058 }
1059 $( "#settlement-response-loading" ).html( "" );
1060 }).fail( function( jqXHR, textStatus, errorThrown ) {
1061 console.log( textStatus );
1062 console.log( jqXHR.status );
1063 console.log( errorThrown.message );
1064 $( "#settlement-response-loading" ).html( "" );
1065 });
1066 return false;
1067 },
1068 authSettlementCard : function( amount ) {
1069 $( "#settlement-response" ).html( "" );
1070 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1071 $.ajax({
1072 url: ajaxurl,
1073 type: "POST",
1074 cache: false,
1075 dataType: "json",
1076 data: {
1077 action: "usces_admin_ajax",
1078 mode: "auth_paygent_card",
1079 order_id: $( "#order_id" ).val(),
1080 trading_id: $( "#trading_id" ).val(),
1081 member_id: $( "#member_id" ).val(),
1082 amount: amount,
1083 wc_nonce: $( "#wc_nonce" ).val()
1084 }
1085 }).done( function( retVal, dataType ) {
1086 if ( retVal.acting_status ) {
1087 var num = $( "#order_num" ).val();
1088 if ( $( "#settlement-status-" + num ).length ) {
1089 $( "#settlement-status-" + num ).html( retVal.acting_status );
1090 } else {
1091 $( "#settlement-status" ).html( retVal.acting_status );
1092 }
1093 }
1094 if ( retVal.result ) {
1095 $( "#settlement-response" ).html( retVal.result );
1096 }
1097 $( "#settlement-response-loading" ).html( "" );
1098 }).fail( function( jqXHR, textStatus, errorThrown ) {
1099 console.log( textStatus );
1100 console.log( jqXHR.status );
1101 console.log( errorThrown.message );
1102 $( "#settlement-response-loading" ).html( "" );
1103 });
1104 return false;
1105 },
1106 <?php
1107 elseif ( 'acting_paygent_conv' == $acting_flg ) :
1108 ?>
1109 getSettlementConv : function() {
1110 $( "#settlement-response" ).html( "" );
1111 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1112 $.ajax({
1113 url: ajaxurl,
1114 type: "POST",
1115 cache: false,
1116 dataType: "json",
1117 data: {
1118 action: "usces_admin_ajax",
1119 mode: "get_paygent_conv",
1120 order_id: $( "#order_id" ).val(),
1121 trading_id: $( "#trading_id" ).val(),
1122 wc_nonce: $( "#wc_nonce" ).val()
1123 }
1124 }).done( function( retVal, dataType ) {
1125 if ( retVal.acting_status ) {
1126 $( "#settlement-status" ).html( retVal.acting_status );
1127 }
1128 if ( retVal.result ) {
1129 $( "#settlement-response" ).html( retVal.result );
1130 }
1131 $( "#settlement-response-loading" ).html( "" );
1132 }).fail( function( jqXHR, textStatus, errorThrown ) {
1133 console.log( textStatus );
1134 console.log( jqXHR.status );
1135 console.log( errorThrown.message );
1136 $( "#settlement-response-loading" ).html( "" );
1137 });
1138 return false;
1139 },
1140 <?php
1141 elseif ( 'acting_paygent_atm' == $acting_flg ) :
1142 ?>
1143 getSettlementAtm : function() {
1144 $( "#settlement-response" ).html( "" );
1145 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1146 $.ajax({
1147 url: ajaxurl,
1148 type: "POST",
1149 cache: false,
1150 dataType: "json",
1151 data: {
1152 action: "usces_admin_ajax",
1153 mode: "get_paygent_atm",
1154 order_id: $( "#order_id" ).val(),
1155 trading_id: $( "#trading_id" ).val(),
1156 wc_nonce: $( "#wc_nonce" ).val()
1157 }
1158 }).done( function( retVal, dataType ) {
1159 if ( retVal.result ) {
1160 $( "#settlement-response" ).html( retVal.result );
1161 }
1162 $( "#settlement-response-loading" ).html( "" );
1163 }).fail( function( jqXHR, textStatus, errorThrown ) {
1164 console.log( textStatus );
1165 console.log( jqXHR.status );
1166 console.log( errorThrown.message );
1167 $( "#settlement-response-loading" ).html( "" );
1168 });
1169 return false;
1170 },
1171 <?php
1172 elseif ( 'acting_paygent_bank' == $acting_flg ) :
1173 ?>
1174 getSettlementBank : function() {
1175 $( "#settlement-response" ).html( "" );
1176 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1177 $.ajax({
1178 url: ajaxurl,
1179 type: "POST",
1180 cache: false,
1181 dataType: "json",
1182 data: {
1183 action: "usces_admin_ajax",
1184 mode: "get_paygent_bank",
1185 order_id: $( "#order_id" ).val(),
1186 trading_id: $( "#trading_id" ).val(),
1187 wc_nonce: $( "#wc_nonce" ).val()
1188 }
1189 }).done( function( retVal, dataType ) {
1190 if ( retVal.acting_status ) {
1191 $( "#settlement-status" ).html( retVal.acting_status );
1192 }
1193 if ( retVal.result ) {
1194 $( "#settlement-response" ).html( retVal.result );
1195 }
1196 $( "#settlement-response-loading" ).html( "" );
1197 }).fail( function( jqXHR, textStatus, errorThrown ) {
1198 console.log( textStatus );
1199 console.log( jqXHR.status );
1200 console.log( errorThrown.message );
1201 $( "#settlement-response-loading" ).html( "" );
1202 });
1203 return false;
1204 },
1205 <?php
1206 elseif ( 'acting_paygent_paidy' == $acting_flg ) :
1207 ?>
1208 getSettlementPaidy : function() {
1209 $( "#settlement-response" ).html( "" );
1210 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1211 $.ajax({
1212 url: ajaxurl,
1213 type: "POST",
1214 cache: false,
1215 dataType: "json",
1216 data: {
1217 action: "usces_admin_ajax",
1218 mode: "get_paygent_paidy",
1219 order_id: $( "#order_id" ).val(),
1220 trading_id: $( "#trading_id" ).val(),
1221 wc_nonce: $( "#wc_nonce" ).val()
1222 }
1223 }).done( function( retVal, dataType ) {
1224 if ( retVal.acting_status ) {
1225 $( "#settlement-status" ).html( retVal.acting_status );
1226 }
1227 if ( retVal.result ) {
1228 $( "#settlement-response" ).html( retVal.result );
1229 }
1230 if ( $( "#refund-settlement" ).length ) {
1231 $( "#refund-settlement" ).prop( "disabled", true );
1232 }
1233 $( "#settlement-response-loading" ).html( "" );
1234 }).fail( function( jqXHR, textStatus, errorThrown ) {
1235 console.log( textStatus );
1236 console.log( jqXHR.status );
1237 console.log( errorThrown.message );
1238 $( "#settlement-response-loading" ).html( "" );
1239 });
1240 return false;
1241 },
1242 cancelSettlementPaidy : function() {
1243 $( "#settlement-response" ).html( "" );
1244 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1245 $.ajax({
1246 url: ajaxurl,
1247 type: "POST",
1248 cache: false,
1249 dataType: "json",
1250 data: {
1251 action: "usces_admin_ajax",
1252 mode: "cancel_paygent_paidy",
1253 order_id: $( "#order_id" ).val(),
1254 trading_id: $( "#trading_id" ).val(),
1255 wc_nonce: $( "#wc_nonce" ).val()
1256 }
1257 }).done( function( retVal, dataType ) {
1258 if ( retVal.acting_status ) {
1259 $( "#settlement-status" ).html( retVal.acting_status );
1260 }
1261 if ( retVal.result ) {
1262 $( "#settlement-response" ).html( retVal.result );
1263 }
1264 if ( $( "#refund-settlement" ).length ) {
1265 $( "#refund-settlement" ).prop( "disabled", true );
1266 }
1267 $( "#settlement-response-loading" ).html( "" );
1268 }).fail( function( jqXHR, textStatus, errorThrown ) {
1269 console.log( textStatus );
1270 console.log( jqXHR.status );
1271 console.log( errorThrown.message );
1272 $( "#settlement-response-loading" ).html( "" );
1273 });
1274 return false;
1275 },
1276 captureSettlementPaidy : function() {
1277 $( "#settlement-response" ).html( "" );
1278 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1279 $.ajax({
1280 url: ajaxurl,
1281 type: "POST",
1282 cache: false,
1283 dataType: "json",
1284 data: {
1285 action: "usces_admin_ajax",
1286 mode: "capture_paygent_paidy",
1287 order_id: $( "#order_id" ).val(),
1288 trading_id: $( "#trading_id" ).val(),
1289 wc_nonce: $( "#wc_nonce" ).val()
1290 }
1291 }).done( function( retVal, dataType ) {
1292 if ( retVal.acting_status ) {
1293 $( "#settlement-status" ).html( retVal.acting_status );
1294 }
1295 if ( retVal.result ) {
1296 $( "#settlement-response" ).html( retVal.result );
1297 }
1298 if ( $( "#refund-settlement" ).length ) {
1299 $( "#refund-settlement" ).prop( "disabled", true );
1300 }
1301 $( "#settlement-response-loading" ).html( "" );
1302 }).fail( function( jqXHR, textStatus, errorThrown ) {
1303 console.log( textStatus );
1304 console.log( jqXHR.status );
1305 console.log( errorThrown.message );
1306 $( "#settlement-response-loading" ).html( "" );
1307 });
1308 return false;
1309 },
1310 refundSettlementPaidy : function( amount ) {
1311 $( "#settlement-response" ).html( "" );
1312 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1313 $.ajax({
1314 url: ajaxurl,
1315 type: "POST",
1316 cache: false,
1317 dataType: "json",
1318 data: {
1319 action: "usces_admin_ajax",
1320 mode: "refund_paygent_paidy",
1321 order_id: $( "#order_id" ).val(),
1322 trading_id: $( "#trading_id" ).val(),
1323 amount: amount,
1324 wc_nonce: $( "#wc_nonce" ).val()
1325 }
1326 }).done( function( retVal, dataType ) {
1327 if ( retVal.acting_status ) {
1328 $( "#settlement-status" ).html( retVal.acting_status );
1329 }
1330 if ( retVal.result ) {
1331 $( "#settlement-response" ).html( retVal.result );
1332 }
1333 if ( $( "#refund-settlement" ).length ) {
1334 $( "#refund-settlement" ).prop( "disabled", true );
1335 }
1336 $( "#settlement-response-loading" ).html( "" );
1337 }).fail( function( jqXHR, textStatus, errorThrown ) {
1338 console.log( textStatus );
1339 console.log( jqXHR.status );
1340 console.log( errorThrown.message );
1341 $( "#settlement-response-loading" ).html( "" );
1342 });
1343 return false;
1344 },
1345 <?php
1346 endif;
1347 ?>
1348 };
1349
1350 $( "#settlement_dialog" ).dialog({
1351 dialogClass: "admin-paygent-dialog",
1352 bgiframe: true,
1353 autoOpen: false,
1354 height: "auto",
1355 width: 800,
1356 resizable: true,
1357 modal: true,
1358 buttons: {
1359 "<?php esc_html_e( 'Close' ); ?>": function() {
1360 $( this ).dialog( "close" );
1361 }
1362 },
1363 open: function() {
1364 <?php
1365 if ( 'acting_paygent_card' == $acting_flg ) :
1366 ?>
1367 adminOrderEdit.getSettlementCard();
1368 <?php
1369 elseif ( 'acting_paygent_conv' == $acting_flg ) :
1370 ?>
1371 adminOrderEdit.getSettlementConv();
1372 <?php
1373 elseif ( 'acting_paygent_atm' == $acting_flg ) :
1374 ?>
1375 adminOrderEdit.getSettlementAtm();
1376 <?php
1377 elseif ( 'acting_paygent_bank' == $acting_flg ) :
1378 ?>
1379 adminOrderEdit.getSettlementBank();
1380 <?php
1381 elseif ( 'acting_paygent_paidy' == $acting_flg ) :
1382 ?>
1383 adminOrderEdit.getSettlementPaidy();
1384 <?php
1385 endif;
1386 ?>
1387 },
1388 close: function() {
1389 }
1390 });
1391
1392 $( document ).on( "click", ".settlement-information", function() {
1393 var trading_id = $( this ).attr( "data-trading_id" );
1394 var order_num = $( this ).attr( "data-num" );
1395 $( "#trading_id" ).val( trading_id );
1396 $( "#order_num" ).val( order_num );
1397 $( "#settlement_dialog" ).dialog( "option", "title", "<?php echo esc_js( $this->acting_formal_name ); ?>" );
1398 $( "#settlement_dialog" ).dialog( "open" );
1399 });
1400
1401 $( document ).on( "click", "#update-status", function() {
1402 var mode = $( this ).attr( "data-mode" );
1403 adminOrderEdit.updateSettlementStatus( mode );
1404 });
1405 <?php
1406 if ( 'acting_paygent_card' == $acting_flg ) :
1407 ?>
1408 $( document ).on( "click", "#sales-settlement", function() {
1409 if ( ! confirm( "売上処理を実行します。よろしいですか?" ) ) {
1410 return;
1411 }
1412 adminOrderEdit.salesSettlementCard();
1413 });
1414
1415 $( document ).on( "click", "#auth-cancel-settlement", function() {
1416 if ( ! confirm( "キャンセル処理を実行します。よろしいですか?" ) ) {
1417 return;
1418 }
1419 adminOrderEdit.cancelSettlementCard( 'auth' );
1420 });
1421
1422 $( document ).on( "click", "#sales-cancel-settlement", function() {
1423 if ( ! confirm( "キャンセル処理を実行します。よろしいですか?" ) ) {
1424 return;
1425 }
1426 adminOrderEdit.cancelSettlementCard( 'sales' );
1427 });
1428
1429 $( document ).on( "click", "#auth-revise-settlement", function() {
1430 var amount_change = parseInt( $( "#amount_change" ).val() ) || 0;
1431 if ( 0 == amount_change ) {
1432 if ( ! confirm( "キャンセル処理を実行します。よろしいですか?" ) ) {
1433 return;
1434 }
1435 adminOrderEdit.cancelSettlementCard( 'auth' );
1436 } else {
1437 if ( ! confirm( "決済金額を" + amount_change + "円に変更します。よろしいですか?" ) ) {
1438 return;
1439 }
1440 adminOrderEdit.changeSettlementCard( 'auth', amount_change );
1441 }
1442 });
1443
1444 $( document ).on( "click", "#sales-revise-settlement", function() {
1445 var amount_change = parseInt( $( "#amount_change" ).val() ) || 0;
1446 if ( 0 == amount_change ) {
1447 if ( ! confirm( "キャンセル処理を実行します。よろしいですか?" ) ) {
1448 return;
1449 }
1450 adminOrderEdit.cancelSettlementCard( 'auth' );
1451 } else {
1452 if ( ! confirm( "決済金額を" + amount_change + "円に変更します。よろしいですか?" ) ) {
1453 return;
1454 }
1455 adminOrderEdit.changeSettlementCard( 'sales', amount_change );
1456 }
1457 });
1458
1459 $( document ).on( "click", "#auth-settlement", function() {
1460 var amount = parseInt( $( "#amount_change" ).val() ) || 0;
1461 if ( 0 < amount ) {
1462 if ( ! confirm( "新規オーソリを実行します。よろしいですか?" ) ) {
1463 return;
1464 }
1465 adminOrderEdit.authSettlementCard( amount );
1466 }
1467 });
1468 <?php
1469 elseif ( 'acting_paygent_paidy' == $acting_flg ) :
1470 ?>
1471 $( document ).on( "click", "#paidy-capture-settlement", function() {
1472 if ( ! confirm( "売上処理を実行します。よろしいですか?" ) ) {
1473 return;
1474 }
1475 adminOrderEdit.captureSettlementPaidy();
1476 });
1477
1478 $( document ).on( "click", "#paidy-cancel-settlement", function() {
1479 if ( ! confirm( "キャンセル処理を実行します。よろしいですか?" ) ) {
1480 return;
1481 }
1482 adminOrderEdit.cancelSettlementPaidy();
1483 });
1484
1485 $( document ).on( "click", "#paidy-refund-settlement", function() {
1486 var amount_original = parseInt( $( "#amount_original" ).val() ) || 0;
1487 var amount_change = parseInt( $( "#amount_change" ).val() ) || 0;
1488 if ( amount_change == amount_original ) {
1489 return;
1490 }
1491 if ( amount_change > amount_original ) {
1492 alert( "決済金額を�
1493 える金額は返金できません。" );
1494 return;
1495 }
1496 if ( 0 == amount_change ) {
1497 if ( ! confirm( "�
1498 �額返金処理を実行します。よろしいですか?" ) ) {
1499 return;
1500 }
1501 adminOrderEdit.refundSettlementPaidy( amount_original );
1502 } else {
1503 var amount = amount_original - amount_change;
1504 if ( ! confirm( amount + "円の返金処理を実行します。よろしいですか?" ) ) {
1505 return;
1506 }
1507 adminOrderEdit.refundSettlementPaidy( amount );
1508 }
1509 });
1510 <?php
1511 endif;
1512 ?>
1513 $( document ).on( "keydown", ".settlement-amount", function( e ) {
1514 var halfVal = $( this ).val().replace( /[!-~]/g,
1515 function( tmpStr ) {
1516 return String.fromCharCode( tmpStr.charCodeAt(0) - 0xFEE0 );
1517 }
1518 );
1519 $( this ).val( halfVal.replace( /[^0-9]/g, '' ) );
1520 });
1521 $( document ).on( "keyup", ".settlement-amount", function() {
1522 this.value = this.value.replace( /[^0-9]+/i, '' );
1523 this.value = Number( this.value ) || 0;
1524 });
1525 $( document ).on( "blur", ".settlement-amount", function() {
1526 this.value = this.value.replace( /[^0-9]+/i, '' );
1527 });
1528 <?php if ( 'usces_continue' == $admin_page ) : ?>
1529 adminContinuation = {
1530 update : function() {
1531 $.ajax({
1532 url: ajaxurl,
1533 type: "POST",
1534 cache: false,
1535 dataType: 'json',
1536 data: {
1537 action: "usces_admin_ajax",
1538 mode: "continuation_update",
1539 member_id: $( "#member_id" ).val(),
1540 order_id: $( "#order_id" ).val(),
1541 contracted_year: $( "#contracted-year option:selected" ).val(),
1542 contracted_month: $( "#contracted-month option:selected" ).val(),
1543 contracted_day: $( "#contracted-day option:selected" ).val(),
1544 charged_year: $( "#charged-year option:selected" ).val(),
1545 charged_month: $( "#charged-month option:selected" ).val(),
1546 charged_day: $( "#charged-day option:selected" ).val(),
1547 price: $( "#price" ).val(),
1548 status: $( "#dlseller-status" ).val(),
1549 wc_nonce: $( "#wc_nonce" ).val()
1550 }
1551 }).done( function( retVal, dataType ) {
1552 if ( "OK" == retVal.status ) {
1553 adminOperation.setActionStatus( "success", "<?php esc_html_e( 'The update was completed.', 'usces' ); ?>" );
1554 } else {
1555 var message = ( retVal.message != "" ) ? retVal.message : "<?php esc_html_e( 'failure in update', 'usces' ); ?>";
1556 adminOperation.setActionStatus( "error", message );
1557 }
1558 }).fail( function( jqXHR, textStatus, errorThrown ) {
1559 console.log( textStatus );
1560 console.log( jqXHR.status );
1561 console.log( errorThrown.message );
1562 adminOperation.setActionStatus( "error", "<?php esc_html_e( 'failure in update', 'usces' ); ?>" );
1563 });
1564 return false;
1565 }
1566 };
1567
1568 $( document ).on( "click", "#continuation-update", function() {
1569 var status = $( "#dlseller-status option:selected" ).val();
1570 if ( "continuation" == status ) {
1571 var year = $( "#charged-year option:selected" ).val();
1572 var month = $( "#charged-month option:selected" ).val();
1573 var day = $( "#charged-day option:selected" ).val();
1574 if ( 0 == year || 0 == month || 0 == day ) {
1575 alert( "<?php esc_html_e( 'Data have deficiency.', 'usces' ); ?>" );
1576 $( "#charged-year" ).focus();
1577 return;
1578 }
1579 if ( "" == $( "#price" ).val() || 0 == parseFloat( $( "#price" ).val() ) ) {
1580 alert( "<?php printf( __( 'Input the %s', 'usces' ), esc_html__( 'Amount', 'dlseller' ) ); ?>" );
1581 $( "#price" ).focus();
1582 return;
1583 }
1584 }
1585 if ( ! confirm( "<?php esc_html_e( 'Are you sure you want to update the settings?', 'usces' ); ?>" ) ) {
1586 return;
1587 }
1588 adminContinuation.update();
1589 });
1590 <?php endif; ?>
1591 });
1592 </script>
1593 <?php
1594 endif;
1595 break;
1596 endswitch;
1597 }
1598
1599 /**
1600 * Certificate file path check.
1601 */
1602 public function check_file_path() {
1603 if ( ! current_user_can( 'wel_manage_setting' ) ) {
1604 wp_send_json_error( array( 'message' => 'Forbidden' ), 403 );
1605 }
1606 check_admin_referer( 'admin_settlement', 'wc_nonce' );
1607 $post_data = wp_unslash( $_POST );
1608 $certificate_path = ( isset( $post_data['path'] ) ) ? rtrim( $post_data['path'], '/' ) : '';
1609 $invalid_wrappers = array( 'phar://', 'php://', 'data://', 'zip://', 'rar://' );
1610 foreach ( $invalid_wrappers as $wrapper ) {
1611 if ( strpos( $certificate_path, $wrapper ) === 0 ) {
1612 $data['status'] = '無効なファイルパスです';
1613 wp_send_json( $data );
1614 return;
1615 }
1616 }
1617 if ( empty( $certificate_path ) ) {
1618 $data['status'] = '証明書ファイルパスが指定されていません';
1619 } else {
1620 if ( ! is_dir( $certificate_path ) ) {
1621 wp_mkdir_p( $certificate_path );
1622 }
1623 if ( ! empty( $post_data['file'] ) ) {
1624 $full_path = $certificate_path . '/' . $post_data['file'];
1625 foreach ( $invalid_wrappers as $wrapper ) {
1626 if ( strpos( $full_path, $wrapper ) !== false ) {
1627 $data['status'] = '無効なファイルパスです';
1628 wp_send_json( $data );
1629 return;
1630 }
1631 }
1632 if ( file_exists( $full_path ) ) {
1633 $data['file_exists'] = 1;
1634 }
1635 }
1636 $data['status'] = ( is_writable( $certificate_path ) ) ? 'OK' : '証明書ファイルパスのディレクトリに書き込み権限がありません';
1637 }
1638 wp_send_json( $data );
1639 }
1640
1641 /**
1642 * Upload paygent certificate file.
1643 */
1644 public function upload_certificate_file() {
1645 if ( ! current_user_can( 'wel_manage_setting' ) ) {
1646 wp_send_json_error( array( 'message' => 'Forbidden' ), 403 );
1647 }
1648 check_admin_referer( 'admin_settlement', 'wc_nonce' );
1649 $upfile = $_FILES['upfile'];
1650 $acting_opts = $this->get_acting_settings();
1651 $data = array( 'status' => '' );
1652 $filename = $upfile['name'];
1653 if ( strrpos( $filename, '.' ) === false ) {
1654 $data['status'] = 'NG';
1655 wp_send_json( $data );
1656 return;
1657 }
1658 $ext = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) );
1659 $type = ( isset( $_POST['upfile_type'] ) ) ? ( $_POST['upfile_type'] ) : '';
1660 if ( 'client_file' === $type ) {
1661 if ( 'pem' !== $ext ) {
1662 $data['status'] = 'NG';
1663 }
1664 } elseif ( 'ca_file' === $type ) {
1665 if ( 'crt' !== $ext ) {
1666 $data['status'] = 'NG';
1667 }
1668 } else {
1669 $data['status'] = 'NG';
1670 }
1671 if ( 'NG' != $data['status'] ) {
1672 if ( 0 < $upfile['error'] ) {
1673 $data['status'] = $upfile['error'];
1674 } else {
1675 $filename = sanitize_file_name( $upfile['name'] );
1676 $res = move_uploaded_file( $upfile['tmp_name'], $acting_opts['certificate_path'] . '/' . $filename );
1677 if ( $res ) {
1678 $data['status'] = 'OK';
1679 } else {
1680 $data['status'] = 'NG';
1681 }
1682 }
1683 }
1684 wp_send_json( $data );
1685 }
1686
1687 /**
1688 * 決済オプション登録・更新
1689 * usces_action_admin_settlement_update
1690 */
1691 public function settlement_update() {
1692 global $usces;
1693
1694 if ( $this->paymod_id != wp_unslash( $_POST['acting'] ) ) {
1695 return;
1696 }
1697
1698 $this->error_mes = '';
1699 $payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
1700 $options = get_option( 'usces', array() );
1701 $certificate_path = $options['acting_settings']['paygent']['certificate_path'];
1702 $post_data = wp_unslash( $_POST );
1703
1704 unset( $options['acting_settings']['paygent'] );
1705 $options['acting_settings']['paygent']['seq_merchant_id'] = ( isset( $post_data['seq_merchant_id'] ) ) ? trim( $post_data['seq_merchant_id'] ) : '';
1706 $options['acting_settings']['paygent']['connect_id'] = ( isset( $post_data['connect_id'] ) ) ? trim( $post_data['connect_id'] ) : '';
1707 $options['acting_settings']['paygent']['connect_password'] = ( isset( $post_data['connect_password'] ) ) ? trim( $post_data['connect_password'] ) : '';
1708 $options['acting_settings']['paygent']['telegram_version'] = TELEGRAM_VERSION;
1709 $options['acting_settings']['paygent']['hc'] = ( isset( $post_data['hc'] ) ) ? trim( $post_data['hc'] ) : '';
1710 $options['acting_settings']['paygent']['conv_hc'] = ( isset( $post_data['conv_hc'] ) ) ? trim( $post_data['conv_hc'] ) : '';
1711 $options['acting_settings']['paygent']['ope'] = ( isset( $post_data['ope'] ) ) ? $post_data['ope'] : '';
1712 $options['acting_settings']['paygent']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : 'off';
1713 $options['acting_settings']['paygent']['token_key'] = ( isset( $post_data['token_key'] ) ) ? trim( $post_data['token_key'] ) : '';
1714 $options['acting_settings']['paygent']['token_hc'] = ( isset( $post_data['token_hc'] ) ) ? trim( $post_data['token_hc'] ) : '';
1715 $options['acting_settings']['paygent']['client_file'] = ( isset( $post_data['client_file'] ) ) ? trim( $post_data['client_file'] ) : '';
1716 $options['acting_settings']['paygent']['ca_file'] = ( isset( $post_data['ca_file'] ) ) ? trim( $post_data['ca_file'] ) : '';
1717 $options['acting_settings']['paygent']['payment_class'] = ( isset( $post_data['payment_class'] ) ) ? $post_data['payment_class'] : '0';
1718 $options['acting_settings']['paygent']['use_card_conf_number'] = ( isset( $post_data['use_card_conf_number'] ) ) ? $post_data['use_card_conf_number'] : 'off';
1719 $options['acting_settings']['paygent']['stock_card_mode'] = ( isset( $post_data['stock_card_mode'] ) ) ? $post_data['stock_card_mode'] : 'off';
1720 $options['acting_settings']['paygent']['sales_mode'] = ( isset( $post_data['sales_mode'] ) ) ? $post_data['sales_mode'] : '0';
1721 $options['acting_settings']['paygent']['sales_mode_dlseller'] = ( isset( $post_data['sales_mode_dlseller'] ) ) ? $post_data['sales_mode_dlseller'] : '0';
1722 $options['acting_settings']['paygent']['auto_settlement_mail'] = ( isset( $post_data['auto_settlement_mail'] ) ) ? $post_data['auto_settlement_mail'] : 'off';
1723 $options['acting_settings']['paygent']['threedsecure_ryaku'] = ( isset( $post_data['threedsecure_ryaku'] ) ) ? $post_data['threedsecure_ryaku'] : 'off';
1724 $options['acting_settings']['paygent']['threedsecure_hc'] = ( isset( $post_data['threedsecure_hc'] ) ) ? trim( $post_data['threedsecure_hc'] ) : '';
1725 $options['acting_settings']['paygent']['attempt'] = ( isset( $post_data['attempt'] ) ) ? $post_data['attempt'] : 'on';
1726 $options['acting_settings']['paygent']['conv_activate'] = ( isset( $post_data['conv_activate'] ) ) ? $post_data['conv_activate'] : 'off';
1727 $options['acting_settings']['paygent']['payment_term_day'] = ( isset( $post_data['payment_term_day'] ) ) ? $post_data['payment_term_day'] : '5';
1728 $options['acting_settings']['paygent']['payment_term_min'] = ( isset( $post_data['payment_term_min'] ) ) ? $post_data['payment_term_min'] : '';
1729 $options['acting_settings']['paygent']['sales_type'] = ( isset( $post_data['sales_type'] ) ) ? $post_data['sales_type'] : '1';
1730 $options['acting_settings']['paygent']['cvs_type'] = ( isset( $post_data['cvs_type'] ) ) ? $post_data['cvs_type'] : array( '01', '02', '03', '04' );
1731 $options['acting_settings']['paygent']['atm_activate'] = ( isset( $post_data['atm_activate'] ) ) ? $post_data['atm_activate'] : 'off';
1732 $options['acting_settings']['paygent']['payment_limit_date'] = ( isset( $post_data['payment_limit_date'] ) ) ? $post_data['payment_limit_date'] : '';
1733 $options['acting_settings']['paygent']['bank_activate'] = ( isset( $post_data['bank_activate'] ) ) ? $post_data['bank_activate'] : 'off';
1734 $options['acting_settings']['paygent']['asp_payment_term'] = ( isset( $post_data['asp_payment_term'] ) ) ? $post_data['asp_payment_term'] : '0050000';
1735 $options['acting_settings']['paygent']['paidy_activate'] = ( isset( $post_data['paidy_activate'] ) ) ? $post_data['paidy_activate'] : 'off';
1736 $options['acting_settings']['paygent']['paidy_public_key'] = ( isset( $post_data['paidy_public_key'] ) ) ? $post_data['paidy_public_key'] : '';
1737 if ( ! isset( $post_data['certificate_path'] ) || WCUtils::is_blank( $post_data['certificate_path'] ) ) {
1738 $certificate_path_before = ( isset( $post_data['certificate_path_before'] ) ) ? $post_data['certificate_path_before'] : '';
1739 if ( empty( $certificate_path ) || $certificate_path_before != $certificate_path ) {
1740 $upload_dir = wp_upload_dir();
1741 $dir = $this->create_certificate_path();
1742 $options['acting_settings']['paygent']['certificate_path'] = $upload_dir['basedir'] . $dir;
1743 } else {
1744 $options['acting_settings']['paygent']['certificate_path'] = $certificate_path;
1745 }
1746 } else {
1747 $options['acting_settings']['paygent']['certificate_path'] = rtrim( trim( $post_data['certificate_path'] ), '/' );
1748 }
1749
1750 if ( WCUtils::is_blank( $options['acting_settings']['paygent']['seq_merchant_id'] ) ) {
1751 $this->error_mes .= '※マーチャントIDを�
1752 �力してください<br />';
1753 }
1754 if ( 'on' == $options['acting_settings']['paygent']['card_activate'] || 'on' == $options['acting_settings']['paygent']['conv_activate'] ) {
1755 if ( WCUtils::is_blank( $options['acting_settings']['paygent']['hc'] ) ) {
1756 $this->error_mes .= '※ハッシュ値生成キーを�
1757 �力してください<br />';
1758 }
1759 } elseif ( 'module' == $options['acting_settings']['paygent']['card_activate'] || 'module' == $options['acting_settings']['paygent']['conv_activate'] ) {
1760 if ( '' == $options['acting_settings']['paygent']['connect_id'] ) {
1761 $this->error_mes .= '※接続IDを�
1762 �力してください<br />';
1763 }
1764 if ( '' == $options['acting_settings']['paygent']['connect_password'] ) {
1765 $this->error_mes .= '※接続パスワードを�
1766 �力してください<br />';
1767 }
1768 if ( '' != $options['acting_settings']['paygent']['client_file'] ) {
1769 if ( ! file_exists( $options['acting_settings']['paygent']['certificate_path'] . '/' . $options['acting_settings']['paygent']['client_file'] ) ) {
1770 $this->error_mes .= '※クライアント証明書ファイルがアップロードされていません<br />';
1771 }
1772 }
1773 if ( '' != $options['acting_settings']['paygent']['ca_file'] ) {
1774 if ( ! file_exists( $options['acting_settings']['paygent']['certificate_path'] . '/' . $options['acting_settings']['paygent']['ca_file'] ) ) {
1775 $this->error_mes .= '※CAファイルがアップロードされていません<br />';
1776 }
1777 }
1778 }
1779 if ( WCUtils::is_blank( $options['acting_settings']['paygent']['ope'] ) ) {
1780 $this->error_mes .= '※稼働環境を選択してください<br />';
1781 }
1782 if ( WCUtils::is_blank( $options['acting_settings']['paygent']['conv_hc'] ) ) {
1783 $this->error_mes .= '※差分通知ハッシュ値生成キーを�
1784 �力してください<br />';
1785 }
1786 if ( 'on' == $options['acting_settings']['paygent']['conv_activate'] ) {
1787 if ( '' == $options['acting_settings']['paygent']['payment_term_day'] && '' == $options['acting_settings']['paygent']['payment_term_min'] ) {
1788 } elseif ( '' != $options['acting_settings']['paygent']['payment_term_day'] && '' != $options['acting_settings']['paygent']['payment_term_min'] ) {
1789 $this->error_mes .= '※「支払期間(日指定)」と「支払期間(分指定)」の両方を指定することはできません<br />';
1790 } elseif ( '' != $options['acting_settings']['paygent']['payment_term_day'] ) {
1791 $term_day = (int) $options['acting_settings']['paygent']['payment_term_day'];
1792 if ( 2 > $term_day || 60 < $term_day ) {
1793 $this->error_mes .= '※「支払期間(日指定)」が指定できる範囲を�
1794 えています<br />';
1795 }
1796 } elseif ( '' != $options['acting_settings']['paygent']['payment_term_min'] ) {
1797 $term_min = (int) $options['acting_settings']['paygent']['payment_term_min'];
1798 if ( 5 > $term_min || 2880 < $term_min ) {
1799 $this->error_mes .= '※「支払期間(分指定)」が指定できる範囲を�
1800 えています<br />';
1801 }
1802 }
1803 } elseif ( 'module' == $options['acting_settings']['paygent']['conv_activate'] ) {
1804 if ( empty( $options['acting_settings']['paygent']['cvs_type'] ) ) {
1805 $this->error_mes .= '※申込コンビニを選択してください<br />';
1806 }
1807 }
1808
1809 if ( 'module' == $options['acting_settings']['paygent']['paidy_activate'] ) {
1810 if ( WCUtils::is_blank( $options['acting_settings']['paygent']['paidy_public_key'] ) ) {
1811 $this->error_mes .= '※パブリックキーを�
1812 �力してください<br />';
1813 }
1814 }
1815
1816 if ( '' == $this->error_mes ) {
1817 $usces->action_status = 'success';
1818 $usces->action_message = __( 'Options are updated.', 'usces' );
1819 $toactive = array();
1820 if ( 'on' == $options['acting_settings']['paygent']['card_activate'] || 'module' == $options['acting_settings']['paygent']['card_activate'] ) {
1821 $usces->payment_structure['acting_paygent_card'] = 'カード決済(' . $this->acting_name . '';
1822 if ( '' == $options['acting_settings']['paygent']['payment_class'] ) {
1823 $options['acting_settings']['paygent']['payment_class'] = '0';
1824 }
1825 if ( '' == $options['acting_settings']['paygent']['use_card_conf_number'] ) {
1826 $options['acting_settings']['paygent']['use_card_conf_number'] = 'off';
1827 }
1828 if ( '' == $options['acting_settings']['paygent']['stock_card_mode'] ) {
1829 $options['acting_settings']['paygent']['stock_card_mode'] = 'off';
1830 }
1831 if ( '' == $options['acting_settings']['paygent']['threedsecure_ryaku'] ) {
1832 $options['acting_settings']['paygent']['threedsecure_ryaku'] = 'off';
1833 }
1834 foreach ( $payment_method as $settlement => $payment ) {
1835 if ( 'acting_paygent_card' == $settlement && 'deactivate' == $payment['use'] ) {
1836 $toactive[] = $payment['name'];
1837 }
1838 }
1839 } else {
1840 unset( $usces->payment_structure['acting_paygent_card'] );
1841 }
1842 if ( 'on' == $options['acting_settings']['paygent']['conv_activate'] || 'module' == $options['acting_settings']['paygent']['conv_activate'] ) {
1843 $usces->payment_structure['acting_paygent_conv'] = 'コンビニ決済(' . $this->acting_name . '';
1844 if ( '' == $options['acting_settings']['paygent']['payment_term_day'] && '' == $options['acting_settings']['paygent']['payment_term_min'] ) {
1845 $options['acting_settings']['paygent']['payment_term_day'] = 5;
1846 }
1847 foreach ( $payment_method as $settlement => $payment ) {
1848 if ( 'acting_paygent_conv' == $settlement && 'deactivate' == $payment['use'] ) {
1849 $toactive[] = $payment['name'];
1850 }
1851 }
1852 } else {
1853 unset( $usces->payment_structure['acting_paygent_conv'] );
1854 }
1855 if ( 'module' == $options['acting_settings']['paygent']['atm_activate'] ) {
1856 $usces->payment_structure['acting_paygent_atm'] = 'ATM決済(' . $this->acting_name . '';
1857 foreach ( $payment_method as $settlement => $payment ) {
1858 if ( 'acting_paygent_atm' == $settlement && 'deactivate' == $payment['use'] ) {
1859 $toactive[] = $payment['name'];
1860 }
1861 }
1862 } else {
1863 unset( $usces->payment_structure['acting_paygent_atm'] );
1864 }
1865 if ( 'module' == $options['acting_settings']['paygent']['bank_activate'] ) {
1866 $usces->payment_structure['acting_paygent_bank'] = '銀行ネット決済(' . $this->acting_name . '';
1867 foreach ( $payment_method as $settlement => $payment ) {
1868 if ( 'acting_paygent_bank' == $settlement && 'deactivate' == $payment['use'] ) {
1869 $toactive[] = $payment['name'];
1870 }
1871 }
1872 } else {
1873 unset( $usces->payment_structure['acting_paygent_bank'] );
1874 }
1875 if ( 'module' == $options['acting_settings']['paygent']['paidy_activate'] ) {
1876 $usces->payment_structure['acting_paygent_paidy'] = 'Paidy(' . $this->acting_name . '';
1877 foreach ( $payment_method as $settlement => $payment ) {
1878 if ( 'acting_paygent_paidy' == $settlement && 'deactivate' == $payment['use'] ) {
1879 $toactive[] = $payment['name'];
1880 }
1881 }
1882 } else {
1883 unset( $usces->payment_structure['acting_paygent_paidy'] );
1884 }
1885 if ( ( 'on' == $options['acting_settings']['paygent']['card_activate'] || 'module' == $options['acting_settings']['paygent']['card_activate'] ) ||
1886 ( 'on' == $options['acting_settings']['paygent']['conv_activate'] || 'module' == $options['acting_settings']['paygent']['conv_activate'] ) ||
1887 'module' == $options['acting_settings']['paygent']['atm_activate'] ||
1888 'module' == $options['acting_settings']['paygent']['bank_activate'] ||
1889 'module' == $options['acting_settings']['paygent']['paidy_activate'] ) {
1890 $options['acting_settings']['paygent']['activate'] = 'on';
1891 if ( 'public' == $options['acting_settings']['paygent']['ope'] ) {
1892 $options['acting_settings']['paygent']['send_url'] = 'https://link.paygent.co.jp/v/u/request';
1893 $options['acting_settings']['paygent']['token_url'] = 'https://token.paygent.co.jp/js/PaygentToken.js';
1894 } else {
1895 $options['acting_settings']['paygent']['send_url'] = 'https://sandbox.paygent.co.jp/v/u/request';
1896 $options['acting_settings']['paygent']['token_url'] = 'https://sandbox.paygent.co.jp/js/PaygentToken.js';
1897 }
1898 usces_admin_orderlist_show_wc_trans_id();
1899 if ( 0 < count( $toactive ) ) {
1900 $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' );
1901 }
1902 } else {
1903 $options['acting_settings']['paygent']['activate'] = 'off';
1904 unset( $usces->payment_structure['acting_paygent_card'] );
1905 unset( $usces->payment_structure['acting_paygent_conv'] );
1906 unset( $usces->payment_structure['acting_paygent_atm'] );
1907 unset( $usces->payment_structure['acting_paygent_bank'] );
1908 unset( $usces->payment_structure['acting_paygent_paidy'] );
1909 }
1910 $deactivate = array();
1911 foreach ( $payment_method as $settlement => $payment ) {
1912 if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
1913 if ( 'deactivate' != $payment['use'] ) {
1914 $payment['use'] = 'deactivate';
1915 $deactivate[] = $payment['name'];
1916 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
1917 }
1918 }
1919 }
1920 if ( 0 < count( $deactivate ) ) {
1921 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
1922 $usces->action_message .= $deactivate_message;
1923 }
1924 } else {
1925 $usces->action_status = 'error';
1926 $usces->action_message = __( 'Data have deficiency.', 'usces' );
1927 $options['acting_settings']['paygent']['activate'] = 'off';
1928 unset( $usces->payment_structure['acting_paygent_card'] );
1929 unset( $usces->payment_structure['acting_paygent_conv'] );
1930 unset( $usces->payment_structure['acting_paygent_atm'] );
1931 unset( $usces->payment_structure['acting_paygent_bank'] );
1932 unset( $usces->payment_structure['acting_paygent_paidy'] );
1933 $deactivate = array();
1934 foreach ( $payment_method as $settlement => $payment ) {
1935 if ( in_array( $settlement, $this->pay_method ) ) {
1936 if ( 'deactivate' != $payment['use'] ) {
1937 $payment['use'] = 'deactivate';
1938 $deactivate[] = $payment['name'];
1939 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
1940 }
1941 }
1942 }
1943 if ( 0 < count( $deactivate ) ) {
1944 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
1945 $usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
1946 }
1947 }
1948
1949 ksort( $usces->payment_structure );
1950 update_option( 'usces', $options );
1951 update_option( 'usces_payment_structure', $usces->payment_structure );
1952 }
1953
1954 /**
1955 * クレジット決済設定画面タブ
1956 * usces_action_settlement_tab_title
1957 */
1958 public function settlement_tab_title() {
1959 $settlement_selected = get_option( 'usces_settlement_selected' );
1960 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) {
1961 echo '<li><a href="#uscestabs_' . esc_html( $this->paymod_id ) . '">' . esc_html( $this->acting_name ) . '</a></li>';
1962 }
1963 }
1964
1965 /**
1966 * クレジット決済設定画面フォーム
1967 * usces_action_settlement_tab_body
1968 */
1969 public function settlement_tab_body() {
1970 global $usces;
1971
1972 $acting_opts = $this->get_acting_settings();
1973 $settlement_selected = get_option( 'usces_settlement_selected' );
1974 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) :
1975 $seq_merchant_id = ( isset( $acting_opts['seq_merchant_id'] ) ) ? $acting_opts['seq_merchant_id'] : '';
1976 $connect_id = ( isset( $acting_opts['connect_id'] ) ) ? $acting_opts['connect_id'] : '';
1977 $connect_password = ( isset( $acting_opts['connect_password'] ) ) ? $acting_opts['connect_password'] : '';
1978 $hc = ( isset( $acting_opts['hc'] ) ) ? $acting_opts['hc'] : '';
1979 $conv_hc = ( isset( $acting_opts['conv_hc'] ) ) ? $acting_opts['conv_hc'] : '';
1980 $ope_test = '';
1981 $ope_public = '';
1982 if ( isset( $acting_opts['ope'] ) && 'public' == $acting_opts['ope'] ) {
1983 $ope_public = ' checked="checked"';
1984 } else {
1985 $ope_test = ' checked="checked"'; /* default */
1986 }
1987 $card_activate_link = '';
1988 $card_activate_module = '';
1989 $card_activate_off = '';
1990 if ( isset( $acting_opts['card_activate'] ) && 'on' == $acting_opts['card_activate'] ) {
1991 $card_activate_link = ' checked="checked"';
1992 } elseif ( isset( $acting_opts['card_activate'] ) && 'module' == $acting_opts['card_activate'] ) {
1993 $card_activate_module = ' checked="checked"';
1994 } else {
1995 $card_activate_off = ' checked="checked"';
1996 }
1997 $token_key = ( isset( $acting_opts['token_key'] ) ) ? $acting_opts['token_key'] : '';
1998 $token_hc = ( isset( $acting_opts['token_hc'] ) ) ? $acting_opts['token_hc'] : '';
1999 $certificate_path = ( isset( $acting_opts['certificate_path'] ) ) ? $acting_opts['certificate_path'] : '';
2000 $client_file = ( isset( $acting_opts['client_file'] ) ) ? $acting_opts['client_file'] : '';
2001 $ca_file = ( isset( $acting_opts['ca_file'] ) ) ? $acting_opts['ca_file'] : '';
2002 $client_file_disabled = '';
2003 $ca_file_disabled = '';
2004 $payment_class_0 = '';
2005 $payment_class_1 = '';
2006 $payment_class_2 = '';
2007 if ( isset( $acting_opts['payment_class'] ) && '1' == $acting_opts['payment_class'] ) {
2008 $payment_class_1 = ' checked="checked"';
2009 } elseif ( isset( $acting_opts['payment_class'] ) && '2' == $acting_opts['payment_class'] ) {
2010 $payment_class_2 = ' checked="checked"';
2011 } else {
2012 $payment_class_0 = ' checked="checked"'; /* default */
2013 }
2014 $use_card_conf_number_on = '';
2015 $use_card_conf_number_off = '';
2016 if ( isset( $acting_opts['use_card_conf_number'] ) && 'on' == $acting_opts['use_card_conf_number'] ) {
2017 $use_card_conf_number_on = ' checked="checked"';
2018 } else {
2019 $use_card_conf_number_off = ' checked="checked"';
2020 }
2021 $stock_card_mode_on = '';
2022 $stock_card_mode_off = '';
2023 if ( isset( $acting_opts['stock_card_mode'] ) && 'on' == $acting_opts['stock_card_mode'] ) {
2024 $stock_card_mode_on = ' checked="checked"';
2025 } else {
2026 $stock_card_mode_off = ' checked="checked"';
2027 }
2028 $stock_card_mode_msg = '';
2029 if ( defined( 'WCEX_DLSELLER' ) ) {
2030 $stock_card_mode_msg = '自動継続課金をご利用の場合は「利用する」を選択してください。';
2031 } elseif ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
2032 $stock_card_mode_msg = '定期購�
2033 �をご利用の場合は「利用する」を選択してください。';
2034 }
2035 $sales_mode_on = '';
2036 $sales_mode_off = '';
2037 if ( isset( $acting_opts['sales_mode'] ) && '1' == $acting_opts['sales_mode'] ) {
2038 $sales_mode_on = ' checked="checked"';
2039 } else {
2040 $sales_mode_off = ' checked="checked"';
2041 }
2042 $sales_mode_dlseller_on = '';
2043 $sales_mode_dlseller_off = '';
2044 if ( isset( $acting_opts['sales_mode_dlseller'] ) && '1' == $acting_opts['sales_mode_dlseller'] ) {
2045 $sales_mode_dlseller_on = ' checked="checked"';
2046 } else {
2047 $sales_mode_dlseller_off = ' checked="checked"';
2048 }
2049 $auto_settlement_mail_on = '';
2050 $auto_settlement_mail_off = '';
2051 if ( isset( $acting_opts['auto_settlement_mail'] ) && 'on' == $acting_opts['auto_settlement_mail'] ) {
2052 $auto_settlement_mail_on = ' checked="checked"';
2053 } else {
2054 $auto_settlement_mail_off = ' checked="checked"';
2055 }
2056 $threedsecure_on = '';
2057 $threedsecure_off = '';
2058 if ( isset( $acting_opts['threedsecure_ryaku'] ) && 'on' == $acting_opts['threedsecure_ryaku'] ) {
2059 $threedsecure_on = ' checked="checked"';
2060 } else {
2061 $threedsecure_off = ' checked="checked"';
2062 }
2063 $threedsecure_hc = ( isset( $acting_opts['threedsecure_hc'] ) ) ? $acting_opts['threedsecure_hc'] : '';
2064 $attempt_on = '';
2065 $attempt_off = '';
2066 if ( isset( $acting_opts['attempt'] ) && 'on' == $acting_opts['attempt'] ) {
2067 $attempt_on = ' checked="checked"';
2068 } else {
2069 $attempt_off = ' checked="checked"';
2070 }
2071 $conv_activate_link = '';
2072 $conv_activate_module = '';
2073 $conv_activate_off = '';
2074 if ( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) {
2075 $conv_activate_link = ' checked="checked"';
2076 } elseif ( isset( $acting_opts['conv_activate'] ) && 'module' == $acting_opts['conv_activate'] ) {
2077 $conv_activate_module = ' checked="checked"';
2078 } else {
2079 $conv_activate_off = ' checked="checked"';
2080 }
2081 $payment_term_day = ( isset( $acting_opts['payment_term_day'] ) ) ? $acting_opts['payment_term_day'] : '5';
2082 $payment_term_min = ( isset( $acting_opts['payment_term_min'] ) ) ? $acting_opts['payment_term_min'] : '';
2083 $sales_type_1 = '';
2084 $sales_type_3 = '';
2085 if ( isset( $acting_opts['sales_type'] ) && '3' == $acting_opts['sales_type'] ) {
2086 $sales_type_3 = ' checked="checked"';
2087 } else {
2088 $sales_type_1 = ' checked="checked"';
2089 }
2090 $cvs_type_01 = '';
2091 $cvs_type_02 = '';
2092 $cvs_type_03 = '';
2093 $cvs_type_04 = '';
2094 if ( isset( $acting_opts['cvs_type'] ) ) {
2095 if ( in_array( '01', $acting_opts['cvs_type'] ) ) {
2096 $cvs_type_01 = ' checked="checked"';
2097 }
2098 if ( in_array( '02', $acting_opts['cvs_type'] ) ) {
2099 $cvs_type_02 = ' checked="checked"';
2100 }
2101 if ( in_array( '03', $acting_opts['cvs_type'] ) ) {
2102 $cvs_type_03 = ' checked="checked"';
2103 }
2104 if ( in_array( '04', $acting_opts['cvs_type'] ) ) {
2105 $cvs_type_04 = ' checked="checked"';
2106 }
2107 }
2108 $atm_activate_link = '';
2109 $atm_activate_module = '';
2110 $atm_activate_off = '';
2111 if ( isset( $acting_opts['atm_activate'] ) && 'module' == $acting_opts['atm_activate'] ) {
2112 $atm_activate_module = ' checked="checked"';
2113 } else {
2114 $atm_activate_off = ' checked="checked"';
2115 }
2116 $payment_limit_date = ( isset( $acting_opts['payment_limit_date'] ) ) ? $acting_opts['payment_limit_date'] : '';
2117 $bank_activate_link = '';
2118 $bank_activate_module = '';
2119 $bank_activate_off = '';
2120 if ( isset( $acting_opts['bank_activate'] ) && 'module' == $acting_opts['bank_activate'] ) {
2121 $bank_activate_module = ' checked="checked"';
2122 } else {
2123 $bank_activate_off = ' checked="checked"';
2124 }
2125 $asp_payment_term = ( isset( $acting_opts['asp_payment_term'] ) ) ? $acting_opts['asp_payment_term'] : '0050000';
2126 $paidy_activate_module = '';
2127 $paidy_activate_off = '';
2128 if ( isset( $acting_opts['paidy_activate'] ) && 'module' == $acting_opts['paidy_activate'] ) {
2129 $paidy_activate_module = ' checked="checked"';
2130 } else {
2131 $paidy_activate_off = ' checked="checked"';
2132 }
2133 $paidy_public_key = ( isset( $acting_opts['paidy_public_key'] ) ) ? $acting_opts['paidy_public_key'] : '';
2134 ?>
2135 <div id="uscestabs_paygent">
2136 <div class="settlement_service"><span class="service_title"><?php echo esc_html( $this->acting_formal_name ); ?></span></div>
2137 <?php if ( isset( $_POST['acting'] ) && $this->paymod_id == wp_unslash( $_POST['acting'] ) ) : ?>
2138 <?php if ( '' != $this->error_mes ) : ?>
2139 <div class="error_message"><?php wel_esc_script_e( $this->error_mes ); ?></div>
2140 <?php elseif ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) : ?>
2141 <div class="message">十分にテストを行ってから運用してください。</div>
2142 <?php endif; ?>
2143 <?php endif; ?>
2144 <form action="" method="post" name="paygent_form" id="paygent_form">
2145 <table class="settle_table">
2146 <tr>
2147 <th><a class="explanation-label" id="label_ex_seq_merchant_id_paygent">マーチャントID</a></th>
2148 <td><input name="seq_merchant_id" type="text" id="seq_merchant_id_paygent" value="<?php echo esc_attr( $seq_merchant_id ); ?>" class="regular-text" /></td>
2149 </tr>
2150 <tr id="ex_seq_merchant_id_paygent" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行されるマーチャントID(半角数字)。マーチャントID は試験環境と本番環境で異なります。</td></tr>
2151 <tr>
2152 <th><a class="explanation-label" id="label_ex_connect_id_paygent">接続ID</a></th>
2153 <td><input name="connect_id" type="text" id="connect_id_paygent" value="<?php echo esc_attr( $connect_id ); ?>" class="regular-text" /></td>
2154 </tr>
2155 <tr id="ex_connect_id_paygent" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行される接続ID(半角英数字)。モジュールタイプで利用するときは�
2156 須です。</td></tr>
2157 <tr>
2158 <th><a class="explanation-label" id="label_ex_connect_password_paygent">接続パスワード</a></th>
2159 <td><input name="connect_password" type="text" id="connect_password_paygent" value="<?php echo esc_attr( $connect_password ); ?>" class="regular-text" /></td>
2160 </tr>
2161 <tr id="ex_connect_password_paygent" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行される接続パスワード(半角英数字)。モジュールタイプで利用するときは�
2162 須です。</td></tr>
2163 <tr>
2164 <th><a class="explanation-label" id="label_ex_hc_paygent">リンクタイプハッシュ生成キー</a></th>
2165 <td><input name="hc" type="text" id="hc_paygent" value="<?php echo esc_attr( $hc ); ?>" class="regular-text" /></td>
2166 </tr>
2167 <tr id="ex_hc_paygent" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行されるリンクタイプハッシュ生成キー(半角英数字)。リンクタイプで利用するときは�
2168 須です。</td></tr>
2169 <tr>
2170 <th><a class="explanation-label" id="label_ex_conv_hc_paygent">差分通知<br />ハッシュ値生成キー</a></th>
2171 <td><input name="conv_hc" type="text" id="conv_hc_paygent" value="<?php echo esc_attr( $conv_hc ); ?>" class="regular-text" /></td>
2172 </tr>
2173 <tr id="ex_conv_hc_paygent" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行される差分通知ハッシュ値生成キー(半角英数字)。別途「差分通知オプション」のお申し込みが�
2174 要です。</td></tr>
2175 <tr>
2176 <th><a class="explanation-label" id="label_ex_ope_paygent">稼働環境</a></th>
2177 <td><label><input name="ope" type="radio" id="ope_paygent_test" value="test"<?php echo esc_html( $ope_test ); ?> /><span>テスト環境</span></label><br />
2178 <label><input name="ope" type="radio" id="ope_paygent_public" value="public"<?php echo esc_html( $ope_public ); ?> /><span>本番環境</span></label>
2179 </td>
2180 </tr>
2181 <tr id="ex_ope_paygent" class="explanation"><td colspan="2">動作環境を切り替えます。</td></tr>
2182 </table>
2183 <table class="settle_table">
2184 <tr>
2185 <th><a class="explanation-label" id="label_ex_card_activate_paygent">クレジットカード決済</a></th>
2186 <td><label><input name="card_activate" type="radio" class="activate_paygent_card" id="card_activate_paygent_link" value="on"<?php echo esc_html( $card_activate_link ); ?> /><span>リンクタイプで利用する</span></label><br />
2187 <label><input name="card_activate" type="radio" class="activate_paygent_card" id="card_activate_paygent_module" value="module"<?php echo esc_html( $card_activate_module ); ?> /><span>モジュールタイプで利用する</span></label><br />
2188 <label><input name="card_activate" type="radio" class="activate_paygent_card" id="card_activate_paygent_off" value="off"<?php echo esc_html( $card_activate_off ); ?> /><span>利用しない</span></label>
2189 </td>
2190 </tr>
2191 <tr id="ex_card_activate_paygent" class="explanation"><td colspan="2">モジュールタイプで利用する場合は、申込サービスタイプは「リンク+モジュール」、モジュール使用は「同意済」になっている�
2192 要があります。</td></tr>
2193 <tr class="paygent_card_form">
2194 <th><a class="explanation-label" id="label_ex_certificate_path_paygent">証明書ファイルパス</a></th>
2195 <td><input name="certificate_path" type="text" id="certificate_path_paygent" value="<?php echo esc_attr( $certificate_path ); ?>" class="regular-text" disabled="disabled" /><br />
2196 <input type="button" class="button" value="変更する" id="change_certificate_path" />
2197 <input name="certificate_path_before" type="hidden" value="<?php echo esc_attr( $certificate_path ); ?>" />
2198 </td>
2199 </tr>
2200 <tr id="ex_certificate_path_paygent" class="explanation paygent_card_form"><td colspan="2">モジュールタイプで利用するときは�
2201 須です。</td></tr>
2202 <tr class="paygent_card_form">
2203 <th><a class="explanation-label" id="label_ex_client_file_paygent">クライアント証明書ファイル</a></th>
2204 <td><input name="client_file" type="text" id="client_file_paygent" value="<?php echo esc_attr( $client_file ); ?>" class="regular-text"<?php echo esc_html( $client_file_disabled ); ?> /><br />
2205 <input type="button" class="button" value="アップロード" id="client_file_upload"<?php echo esc_html( $client_file_disabled ); ?> /><span id="client_file_upload_result"></span>
2206 </td>
2207 </tr>
2208 <tr id="ex_client_file_paygent" class="explanation paygent_card_form"><td colspan="2">モジュールタイプで利用するときは�
2209 須です。クライアント証明書ファイルは試験環境と本番環境で異なります。アップロードができない場合は wp-content/uploads/ フォルダのパーミッションを確認してください。</td></tr>
2210 <tr class="paygent_card_form">
2211 <th><a class="explanation-label" id="label_ex_ca_file_paygent">CAファイル</a></th>
2212 <td><input name="ca_file" type="text" id="ca_file_paygent" value="<?php echo esc_attr( $ca_file ); ?>" class="regular-text"<?php echo esc_html( $ca_file_disabled ); ?> /><br />
2213 <input type="button" class="button" value="アップロード" id="ca_file_upload"<?php echo esc_html( $ca_file_disabled ); ?> /><span id="ca_file_upload_result"></span>
2214 </td>
2215 </tr>
2216 <tr id="ex_ca_file_paygent" class="explanation paygent_card_form"><td colspan="2">モジュールタイプで利用するときは�
2217 須です。アップロードができない場合は wp-content/uploads/ フォルダのパーミッションを確認してください。</td></tr>
2218 <tr class="paygent_card_form paygent_card_module">
2219 <th><a class="explanation-label" id="label_ex_token_key_paygent">トークン生成鍵</a></th>
2220 <td><input name="token_key" type="text" id="token_key_paygent" value="<?php echo esc_attr( $token_key ); ?>" class="regular-text" /></td>
2221 </tr>
2222 <tr id="ex_token_key_paygent" class="explanation paygent_card_form paygent_card_module"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行されるトークン生成鍵(半角英数字)。モジュールタイプで利用するときは�
2223 須です。トークン生成鍵は試験環境と本番環境で異なります。</td></tr>
2224 <tr class="paygent_card_form paygent_card_module">
2225 <th><a class="explanation-label" id="label_ex_token_hc_paygent">トークン受取ハッシュ鍵</a></th>
2226 <td><input name="token_hc" type="text" id="token_hc_paygent" value="<?php echo esc_attr( $token_hc ); ?>" class="regular-text" /></td>
2227 </tr>
2228 <tr id="ex_token_hc_paygent" class="explanation paygent_card_form paygent_card_module"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行されるトークン受取ハッシュ鍵(半角英数字)。モジュールタイプで利用するときは�
2229 須です。</td></tr>
2230 <tr class="paygent_card_form">
2231 <th><a class="explanation-label" id="label_ex_payment_class_paygent">支払区分</a></th>
2232 <td><label><input name="payment_class" type="radio" id="payment_class_paygent_0" value="0"<?php echo esc_html( $payment_class_0 ); ?> /><span>1回払いのみ</span></label><br />
2233 <label><input name="payment_class" type="radio" id="payment_class_paygent_2" value="1"<?php echo esc_html( $payment_class_1 ); ?> /><span>�
2234 �て</span></label><br />
2235 <label><input name="payment_class" type="radio" id="payment_class_paygent_2" value="2"<?php echo esc_html( $payment_class_2 ); ?> /><span>ボーナス一括以外�
2236 �て</span></label>
2237 </td>
2238 </tr>
2239 <tr id="ex_payment_class_paygent" class="explanation paygent_card_form"><td colspan="2">ユーザーに支払を許可するカード支払方法の区分です。加盟店審査を経て加盟店様ごとに設定された支払可能回数から、購�
2240 ��
2241 に提示する支払回数をさらに絞り込みたい場合に使用してください。</td></tr>
2242 <tr class="paygent_card_form">
2243 <th><a class="explanation-label" id="label_ex_use_card_conf_number_paygent">カード確認番号<br />利用フラグ</a></th>
2244 <td><label><input name="use_card_conf_number" type="radio" id="use_card_conf_number_paygent_on" value="on"<?php echo esc_html( $use_card_conf_number_on ); ?> /><span>利用する</span></label><br />
2245 <label><input name="use_card_conf_number" type="radio" id="use_card_conf_number_paygent_off" value="off"<?php echo esc_html( $use_card_conf_number_off ); ?> /><span>利用しない</span></label>
2246 </td>
2247 </tr>
2248 <tr id="ex_use_card_conf_number_paygent" class="explanation paygent_card_form"><td colspan="2">確認番号の�
2249 �力を�
2250 須とするかどうかを指定します。確認番号が実際に使用されるかどうかは、カードを発行したイシュアーに依存します。</td></tr>
2251 <tr class="paygent_card_form">
2252 <th><a class="explanation-label" id="label_ex_stock_card_mode_paygent">カード�
2253 報お預りモード</a></th>
2254 <td><label><input name="stock_card_mode" type="radio" id="stock_card_mode_paygent_on" value="on"<?php echo esc_html( $stock_card_mode_on ); ?> /><span>利用する</span></label><br />
2255 <label><input name="stock_card_mode" type="radio" id="stock_card_mode_paygent_off" value="off"<?php echo esc_html( $stock_card_mode_off ); ?> /><span>利用しない</span></label>
2256 </td>
2257 </tr>
2258 <tr id="ex_stock_card_mode_paygent" class="explanation paygent_card_form"><td colspan="2">会員は購�
2259 �の際に登録済みのカードで支払うことができます。カード番号はペイジェントのシステムに保存されます。利用する場合は、基本設定の「会員システム」を「利用する」に設定してください。<?php echo esc_html( $stock_card_mode_msg ); ?></td></tr>
2260 <tr class="paygent_card_form paygent_card_module">
2261 <th><a class="explanation-label" id="label_ex_sales_mode_paygent">同時売上モード</a></th>
2262 <td><label><input name="sales_mode" type="radio" id="sales_mode_paygent_on" value="1"<?php echo esc_html( $sales_mode_on ); ?> /><span>売上</span></label><br />
2263 <label><input name="sales_mode" type="radio" id="sales_mode_paygent_off" value="0"<?php echo esc_html( $sales_mode_off ); ?> /><span>オーソリのみ</span></label>
2264 </td>
2265 </tr>
2266 <tr id="ex_sales_mode_paygent" class="explanation paygent_card_form paygent_card_module"><td colspan="2">決済時にオーソリ(与信)のみ実施するか、オーソリ後売上処理を実施するかを指定します。</td></tr>
2267 <?php if ( defined( 'WCEX_DLSELLER' ) ) : ?>
2268 <tr class="paygent_card_form paygent_card_module">
2269 <th><a class="explanation-label" id="label_ex_sales_mode_dlseller_paygent">自動継続課金同時売上モード</a></th>
2270 <td><label><input name="sales_mode_dlseller" type="radio" id="sales_mode_dlseller_paygent_on" value="1"<?php echo esc_html( $sales_mode_dlseller_on ); ?> /><span>売上</span></label><br />
2271 <label><input name="sales_mode_dlseller" type="radio" id="sales_mode_dlseller_paygent_off" value="0"<?php echo esc_html( $sales_mode_dlseller_off ); ?> /><span>オーソリのみ</span></label>
2272 </td>
2273 </tr>
2274 <tr id="ex_sales_mode_dlseller_paygent" class="explanation paygent_card_form paygent_card_module"><td colspan="2">自動継続課金(要 WCEX DLSeller)時の同時売上モード。</td></tr>
2275 <tr class="paygent_card_form paygent_card_module">
2276 <th><a class="explanation-label" id="label_ex_auto_settlement_mail_paygent">自動継続課金完了メール</a></th>
2277 <td><label><input name="auto_settlement_mail" type="radio" id="auto_settlement_mail_paygent_on" value="on"<?php echo esc_html( $auto_settlement_mail_on ); ?> /><span><?php esc_html_e( 'Send', 'usces' ); ?></span></label><br />
2278 <label><input name="auto_settlement_mail" type="radio" id="auto_settlement_mail_paygent_off" value="off"<?php echo esc_html( $auto_settlement_mail_off ); ?> /><span><?php esc_html_e( "Don't send", 'usces' ); ?></span></label>
2279 </td>
2280 </tr>
2281 <tr id="ex_auto_settlement_mail_paygent" class="explanation paygent_card_form paygent_card_module"><td colspan="2"><?php _e( 'Send billing completion mail to the member on which automatic continuing charging processing (required WCEX DLSeller) is executed.', 'usces' ); ?></td></tr>
2282 <?php endif; ?>
2283 <tr class="paygent_card_form">
2284 <th><a class="explanation-label" id="label_ex_threedsecure_paygent">3Dセキュア</a></th>
2285 <td><label><input name="threedsecure_ryaku" type="radio" class="activate_paygent_card_threedsecure" id="threedsecure_paygent_on" value="on"<?php echo esc_html( $threedsecure_on ); ?> /><span>契約</span></label><br />
2286 <label><input name="threedsecure_ryaku" type="radio" class="activate_paygent_card_threedsecure" id="threedsecure_paygent_off" value="off"<?php echo esc_html( $threedsecure_off ); ?> /><span>未契約/利用しない</span></label>
2287 </td>
2288 </tr>
2289 <tr id="ex_threedsecure_paygent" class="explanation paygent_card_form"><td colspan="2">3Dセキュアの契約をした場合のみ「契約」を選択してください。</td></tr>
2290 <tr class="paygent_card_form paygent_card_threedsecure">
2291 <th><a class="explanation-label" id="label_ex_threedsecure_hc_paygent">3Dセキュア結果受付ハッシュ鍵</a></th>
2292 <td><input name="threedsecure_hc" type="text" id="threedsecure_hc_paygent" value="<?php echo esc_attr( $threedsecure_hc ); ?>" class="regular-text" /></td>
2293 </tr>
2294 <tr id="ex_threedsecure_hc_paygent" class="explanation paygent_card_form paygent_card_threedsecure"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行される3Dセキュア結果受付ハッシュ鍵(半角英数字)。3Dセキュアを利用するときは�
2295 須です。</td></tr>
2296 <tr class="paygent_card_form paygent_card_threedsecure">
2297 <th><a class="explanation-label" id="label_ex_attempt_paygent">チャージバックリスク回避</a></th>
2298 <td><label><input name="attempt" type="radio" id="attempt_paygent_on" value="on"<?php echo esc_html( $attempt_on ); ?> /><span>優�
2299 �する</span></label><br />
2300 <label><input name="attempt" type="radio" id="attempt_paygent_off" value="off"<?php echo esc_html( $attempt_off ); ?> /><span>優�
2301 �しない</span></label>
2302 </td>
2303 </tr>
2304 <tr id="ex_attempt_paygent" class="explanation paygent_card_form paygent_card_threedsecure"><td colspan="2">「優�
2305 �する」を選択すると、チャージバックリスクが加盟店にある場合の3Dセキュア認証を認証エラー(決済エラー)とします。</td></tr>
2306 </table>
2307 <table class="settle_table">
2308 <tr>
2309 <th><a class="explanation-label" id="label_ex_conv_activate_paygent">コンビニ決済(番号方式)</a></th>
2310 <td><label><input name="conv_activate" type="radio" class="activate_paygent_conv" id="conv_activate_paygent_link" value="on"<?php echo esc_html( $conv_activate_link ); ?> /><span>リンクタイプで利用する</span></label><br />
2311 <label><input name="conv_activate" type="radio" class="activate_paygent_conv" id="conv_activate_paygent_module" value="module"<?php echo esc_html( $conv_activate_module ); ?> /><span>モジュールタイプで利用する</span></label><br />
2312 <label><input name="conv_activate" type="radio" class="activate_paygent_conv" id="conv_activate_paygent_off" value="off"<?php echo esc_html( $conv_activate_off ); ?> /><span>利用しない</span></label>
2313 </td>
2314 </tr>
2315 <tr id="ex_conv_activate_paygent" class="explanation"><td colspan="2">モジュールタイプで利用する場合は、申込サービスタイプは「リンク+モジュール」、モジュール使用は「同意済」になっている�
2316 要があります。</td></tr>
2317 <tr class="paygent_conv_form">
2318 <th><a class="explanation-label" id="label_ex_payment_term_day_paygent">支払期間(日指定)</a></th>
2319 <td><input name="payment_term_day" type="text" id="payment_term_day_paygent" value="<?php echo esc_attr( $payment_term_day ); ?>" class="small-text" /></td>
2320 </tr>
2321 <tr id="ex_payment_term_day_paygent" class="explanation paygent_conv_form"><td colspan="2">支払うことのできる期限を日で指定します。指定できる範囲は2以上60以下です。(半角数字)</td></tr>
2322 <tr class="paygent_conv_form paygent_conv_link">
2323 <th><a class="explanation-label" id="label_ex_payment_term_min_paygent">支払期間(分指定)</a></th>
2324 <td><input name="payment_term_min" type="text" id="payment_term_min_paygent" value="<?php echo esc_attr( $payment_term_min ); ?>" class="small-text" /></td>
2325 </tr>
2326 <tr id="ex_payment_term_min_paygent" class="explanation paygent_conv_form paygent_conv_link"><td colspan="2">支払うことのできる期限を分で指定します。指定できる範囲は5以上2880以下です。(半角数字)</td></tr>
2327 <tr class="paygent_conv_form paygent_conv_module">
2328 <th><a class="explanation-label" id="label_ex_sales_type_paygent">支払種別</a></th>
2329 <td><label><input name="sales_type" type="radio" class="sales_type_paygent" id="sales_type_paygent_1" value="1"<?php echo esc_html( $sales_type_1 ); ?> /><span>前払い</span></label><br />
2330 <label><input name="sales_type" type="radio" class="sales_type_paygent" id="sales_type_paygent_3" value="3"<?php echo esc_html( $sales_type_3 ); ?> /><span>後払い</span></label>
2331 </td>
2332 </tr>
2333 <tr id="ex_sales_type_paygent" class="explanation paygent_conv_form paygent_conv_module"><td colspan="2">前払いか後払いかを表す種別です。</td></tr>
2334 <tr class="paygent_conv_form paygent_conv_module">
2335 <th rowspan="7"><a class="explanation-label" id="label_ex_cvs_type_paygent">申込コンビニ</a></th>
2336 <td><label><input name="cvs_type[]" type="checkbox" id="cvs_type_01" value="01"<?php echo esc_html( $cvs_type_01 ); ?> /><span>セイコーマート</span></label></td>
2337 </tr>
2338 <tr class="paygent_conv_form paygent_conv_module">
2339 <td><label><input name="cvs_type[]" type="checkbox" id="cvs_type_02" value="02"<?php echo esc_html( $cvs_type_02 ); ?> /><span>ローソン/ミニストップ/デイリーヤマザキ</span></label></td>
2340 </tr>
2341 <tr class="paygent_conv_form paygent_conv_module">
2342 <td><label><input name="cvs_type[]" type="checkbox" id="cvs_type_03" value="03"<?php echo esc_html( $cvs_type_03 ); ?> /><span>セブンイレブン</span></label></td>
2343 </tr>
2344 <tr class="paygent_conv_form paygent_conv_module">
2345 <td><label><input name="cvs_type[]" type="checkbox" id="cvs_type_04" value="04"<?php echo esc_html( $cvs_type_04 ); ?> /><span>ファミリーマート</span></label></td>
2346 </tr>
2347 <tr id="ex_cvs_type_paygent" class="explanation paygent_conv_form paygent_conv_module"><td colspan="2">契約時にご利用のお申込みをいただいたコンビニを選択します。</td></tr>
2348 </table>
2349 <table class="settle_table">
2350 <tr>
2351 <th><a class="explanation-label" id="label_ex_atm_activate_paygent">ATM決済(ペイジー)</a></th>
2352 <td>
2353 <label><input name="atm_activate" type="radio" class="activate_paygent_atm" id="atm_activate_paygent_module" value="module"<?php echo esc_html( $atm_activate_module ); ?> /><span>利用する</span></label><br />
2354 <label><input name="atm_activate" type="radio" class="activate_paygent_atm" id="atm_activate_paygent_off" value="off"<?php echo esc_html( $atm_activate_off ); ?> /><span>利用しない</span></label>
2355 </td>
2356 </tr>
2357 <tr id="ex_atm_activate_paygent" class="explanation"><td colspan="2">モジュールタイプになります。利用する場合は、申込サービスタイプは「リンク+モジュール」、モジュール使用は「同意済」になっている�
2358 要があります。</td></tr>
2359 <tr class="paygent_atm_form">
2360 <th><a class="explanation-label" id="label_ex_payment_limit_date_paygent">支払期限日</a></th>
2361 <td><input name="payment_limit_date" type="text" id="payment_limit_date_paygent" value="<?php echo esc_attr( $payment_limit_date ); ?>" class="small-text" /></td>
2362 </tr>
2363 <tr id="ex_payment_limit_date_paygent" class="explanation paygent_atm_form"><td colspan="2">取引発生日時から0日~60日より設定します。設定がない場合は、システムデフォルト値 30日が設定されます。0日とは当日中を指します。(半角数字)</td></tr>
2364 </table>
2365 <table class="settle_table">
2366 <tr>
2367 <th><a class="explanation-label" id="label_ex_bank_activate_paygent">銀行ネット決済(ネットバンキング)</a></th>
2368 <td>
2369 <label><input name="bank_activate" type="radio" class="activate_paygent_bank" id="bank_activate_paygent_module" value="module"<?php echo esc_html( $bank_activate_module ); ?> /><span>利用する</span></label><br />
2370 <label><input name="bank_activate" type="radio" class="activate_paygent_bank" id="bank_activate_paygent_off" value="off"<?php echo esc_html( $bank_activate_off ); ?> /><span>利用しない</span></label>
2371 </td>
2372 </tr>
2373 <tr id="ex_bank_activate_paygent" class="explanation"><td colspan="2">モジュールタイプになります。利用する場合は、申込サービスタイプは「リンク+モジュール」、モジュール使用は「同意済」になっている�
2374 要があります。</td></tr>
2375 <tr class="paygent_bank_form">
2376 <th><a class="explanation-label" id="label_ex_asp_payment_term_paygent">支払期間</a></th>
2377 <td><select name="asp_payment_term">
2378 <?php
2379 foreach ( $this->asp_payment_term as $term => $value ) {
2380 $selected = ( $asp_payment_term == $term ) ? ' selected="selected"' : '';
2381 echo '<option value="' . esc_attr( $term ) . '"' . $selected . '>' . esc_html( $value ) . '</option>';
2382 }
2383 ?>
2384 </select>
2385 </td>
2386 </tr>
2387 <tr id="ex_asp_payment_term_paygent" class="explanation paygent_bank_form"><td colspan="2">ASP画面有効期限を設定します。すぐに支払ってもらいたい場合は30分程度を指定してください。一般的には長くて7日程度です。デフォルト値は5日です。</td></tr>
2388 </table>
2389 <table class="settle_table">
2390 <tr>
2391 <th><a class="explanation-label" id="label_ex_paidy_activate_paygent">Paidy</a></th>
2392 <td><label><input name="paidy_activate" type="radio" class="activate_paygent_paidy" id="paidy_activate_paygent_module" value="module"<?php echo esc_html( $paidy_activate_module ); ?> /><span>利用する</span></label><br />
2393 <label><input name="paidy_activate" type="radio" class="activate_paygent_paidy" id="paidy_activate_paygent_off" value="off"<?php echo esc_html( $paidy_activate_off ); ?> /><span>利用しない</span></label>
2394 </td>
2395 </tr>
2396 <tr id="ex_paidy_activate_paygent" class="explanation"><td colspan="2">モジュールタイプになります。利用する場合は、申込サービスタイプは「リンク+モジュール」、モジュール使用は「同意済」になっている�
2397 要があります。</td></tr>
2398 <tr class="paygent_paidy_form">
2399 <th><a class="explanation-label" id="label_ex_paidy_public_key_paygent">パブリックキー</a></th>
2400 <td><input name="paidy_public_key" type="text" id="paidy_public_key_paygent" value="<?php echo esc_attr( $paidy_public_key ); ?>" class="regular-text" /></td>
2401 </tr>
2402 <tr id="ex_paidy_public_key_paygent" class="explanation paygent_paidy_form"><td colspan="2">Paidy 加盟店管理画面の設定より「パブリックキー」を取得してください。(半角数字)</td></tr>
2403 </table>
2404 <input name="acting" type="hidden" value="paygent" />
2405 <input name="usces_option_update" type="submit" class="button button-primary" value="<?php echo esc_attr( $this->acting_name ); ?>の設定を更新する" />
2406 <?php wp_nonce_field( 'admin_settlement', 'wc_nonce' ); ?>
2407 </form>
2408 <div id="upload_dialog_paygent" class="upload_dialog_paygent">
2409 <form action="<?php echo esc_url( USCES_ADMIN_URL ); ?>" method="post" enctype="multipart/form-data" name="upload_form_paygent" id="upload_form_paygent">
2410 <p id="filetype_description"></p>
2411 <fieldset>
2412 <input type="file" name="upload_file" id="upload_file" />
2413 </fieldset>
2414 <input type="button" id="upload_button" class="button" value="アップロード" />
2415 <input type="hidden" id="upload_filetype" value="" />
2416 </form>
2417 </div>
2418 <div class="settle_exp">
2419 <p><strong><?php echo esc_attr( $this->acting_formal_name ); ?></strong></p>
2420 <a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank"><?php echo esc_attr( $this->acting_name ); ?>の詳細はこちら </a>
2421 <p>この決済は「外部リンク型(リンクタイプ)」と「非通過型(モジュールタイプ)」が選択できます。</p>
2422 <p>リンクタイプでもペイジェントの決済システムと Welcart の決済データの連携機能を利用したい場合は、「クライアント証明書ファイル」と「CAファイル」をサーバーに設置する�
2423 要があります。また、ペイジェントの申込サービスタイプは「リンク+モジュール」モジュール使用は「同意済」になっている�
2424 要があります。詳細は「ペイジェント決済導�
2425 �マニュアル」を参�
2426 �してください。</p>
2427 <p>決済通知ステータスの申請は「任意」となっていますが、以下のように申請してください。リンクタイプで利用する場合は※印のステータス通知は�
2428 須となります。<br />
2429 【クレジット決済】<br />
2430  ■ 申込済※<br />
2431  ■ オーソリNG<br />
2432  ■ 3Dセキュア中断(3Dセキュア契約時のみ)<br />
2433  ■ オーソリOK<br />
2434  ■ オーソリ取消済<br />
2435  ■ オーソリ期限切<br />
2436  ■ 消込済<br />
2437  ■ 消込済(売上取消期限切)<br />
2438  ■ 売上取消済<br />
2439 【コンビニ決済】<br />
2440  ■ 申込済※<br />
2441  ■ 支払期限切<br />
2442  ■ 消込済※<br />
2443  ■ 速報検知済※<br />
2444  ■ 速報取消済<br />
2445 【ATM決済】<br />
2446  ■ 支払期限切<br />
2447  ■ 消込済※<br />
2448 【銀行ネット決済】<br />
2449  ■ 申込中断<br />
2450  ■ 消込済※<br />
2451 【Paidy】<br />
2452  ■ オーソリNG<br />
2453  ■ オーソリOK<br />
2454  ■ オーソリ取消済<br />
2455  ■ オーソリ期限切<br />
2456  ■ 消込済<br />
2457  ■ 消込済(売上取消期限切)<br />
2458  ■ 売上取消済<br />
2459 </p>
2460 </div>
2461 </div><!--uscestabs_paygent-->
2462 <?php
2463 endif;
2464 }
2465
2466 /**
2467 * 結果通知処理
2468 * usces_after_cart_instant
2469 */
2470 public function acting_transaction() {
2471 global $usces;
2472
2473 if ( isset( $_POST['trading_id'] ) && isset( $_POST['payment_status'] ) && ! isset( $_POST['purchase'] ) ) {
2474 $post_data = Paygent_Module::encording_response_kana( wp_unslash( $_POST ) );
2475 $acting_opts = $this->get_acting_settings();
2476 $original_string = trim( $post_data['payment_notice_id'] ) . trim( $post_data['payment_id'] ) . trim( $post_data['trading_id'] ) . trim( $post_data['payment_type'] ) . trim( $post_data['payment_amount'] ) . trim( $acting_opts['conv_hc'] );
2477 $hased_string = hash( 'sha256', $original_string );
2478 if ( isset( $post_data['hc'] ) && $hased_string === $post_data['hc'] ) {
2479 $payment_type = ( isset( $post_data['payment_type'] ) ) ? $post_data['payment_type'] : '';
2480 $payment_status = $post_data['payment_status'];
2481 switch ( $payment_type ) {
2482 /* カード決済 */
2483 case PAYMENT_TYPE_CREDIT:
2484 switch ( $payment_status ) {
2485 case STATUS_REQUESTED: /* 申込済 */
2486 if ( ! empty( $post_data['trading_id'] ) ) {
2487 $order_id = $this->get_order_id( $post_data['trading_id'] );
2488 if ( ! $order_id ) {
2489 if ( $this->is_activate_card( 'link' ) ) {
2490 $order_data = usces_restore_order_acting_data( $post_data['trading_id'] );
2491 if ( $order_data ) {
2492 $res = $usces->order_processing( $post_data );
2493 if ( 'ordercompletion' == $res ) {
2494 if ( 'on' == $acting_opts['stock_card_mode'] ) {
2495 if ( isset( $post_data['customer_id'] ) && isset( $post_data['customer_card_id'] ) ) {
2496 $usces->set_member_meta_value( 'paygent_customer_card_id', $post_data['customer_card_id'], $post_data['customer_id'] );
2497 }
2498 }
2499 $usces->cart->crear_cart();
2500 } else {
2501 $log = array(
2502 'acting' => 'paygent_card',
2503 'key' => $post_data['trading_id'],
2504 'result' => 'ORDER DATA REGISTERED ERROR',
2505 'data' => $post_data,
2506 );
2507 usces_save_order_acting_error( $log );
2508 }
2509 $order_id = $this->get_order_id( $post_data['trading_id'] );
2510 if ( $order_id ) {
2511 $post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
2512 $this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2513 }
2514 }
2515 }
2516 } else {
2517 $post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
2518 $this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2519 }
2520 }
2521 break;
2522 case STATUS_AUTHORIZE_NG: /* オーソリNG */
2523 case STATUS_AUTHORIZE_OK: /* オーソリOK */
2524 case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
2525 case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
2526 case STATUS_CLEARED: /* 消込済 */
2527 case STATUS_CLEARED_SALES_CANCEL_INVALIDITY: /* 消込済(売上取消期限切) */
2528 case STATUS_SALES_CANCELED: /* 売上取消済 */
2529 case STATUS_3DSECURE_INTERRUPTION: /* 3Dセキュア中断 */
2530 case STATUS_3DSECURE_CERTIFICATION: /* 3Dセキュア認証 */
2531 $order_id = $this->get_order_id( $post_data['trading_id'] );
2532 if ( $order_id ) {
2533 $post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
2534 $this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2535 }
2536 break;
2537 case STATUS_SALES_CANCELING: /* 売上取消中 */
2538 case STATUS_SALES_CANCELING_TALLY: /* 売上取消集計中 */
2539 $order_id = $this->get_order_id( $post_data['trading_id'] );
2540 if ( $order_id ) {
2541 $post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
2542 $this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_ERROR, $order_id, $post_data['trading_id'] );
2543 }
2544 break;
2545 }
2546 break;
2547
2548 /* コンビニ決済 */
2549 case PAYMENT_TYPE_CONVENI_NUM:
2550 switch ( $payment_status ) {
2551 case STATUS_REQUESTED: /* 申込済 */
2552 if ( ! empty( $post_data['trading_id'] ) ) {
2553 $order_id = $this->get_order_id( $post_data['trading_id'] );
2554 if ( ! $order_id ) {
2555 if ( $this->is_activate_conv( 'link' ) ) {
2556 $order_data = usces_restore_order_acting_data( $post_data['trading_id'] );
2557 if ( $order_data ) {
2558 $res = $usces->order_processing( $post_data );
2559 if ( 'ordercompletion' == $res ) {
2560 $usces->cart->crear_cart();
2561 } else {
2562 $log = array(
2563 'acting' => 'paygent_conv',
2564 'key' => $post_data['trading_id'],
2565 'result' => 'ORDER DATA REGISTERED ERROR',
2566 'data' => $post_data,
2567 );
2568 usces_save_order_acting_error( $log );
2569 }
2570 $order_id = $this->get_order_id( $post_data['trading_id'] );
2571 if ( $order_id ) {
2572 $this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2573 }
2574 }
2575 }
2576 } else {
2577 $this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2578 }
2579 }
2580 break;
2581 case STATUS_PRELIMINARY_DETECTED: /* 速報検地済 */
2582 case STATUS_CLEARED: /* 消込済 */
2583 $order_id = $this->get_order_id( $post_data['trading_id'] );
2584 if ( $order_id ) {
2585 $this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2586 $order_status = $this->get_order_status( $order_id );
2587 if ( 0 == $order_status ) {
2588 $res = usces_change_order_receipt( $order_id, 'receipted' );
2589 if ( false === $res ) {
2590 $log = array(
2591 'acting' => 'paygent_conv',
2592 'key' => $post_data['trading_id'],
2593 'result' => 'ORDER DATA UPDATE ERROR',
2594 'data' => $post_data,
2595 );
2596 usces_save_order_acting_error( $log );
2597 } else {
2598 usces_action_acting_getpoint( $order_id );
2599 $usces->set_order_meta_value( 'acting_paygent_conv', usces_serialize( $post_data ), $order_id );
2600 if ( STATUS_CLEARED === $payment_status ) {
2601 do_action( 'usces_action_paygent_conv_payment_completion', $post_data, $order_id );
2602 }
2603 }
2604 }
2605 }
2606 break;
2607 case STATUS_PRELIMINARY_CANCELED: /* 速報取消済 */
2608 $order_id = $this->get_order_id( $post_data['trading_id'] );
2609 if ( $order_id ) {
2610 $this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2611 $order_status = $this->get_order_status( $order_id );
2612 if ( 0 < $order_status ) {
2613 $res = usces_change_order_receipt( $order_id, 'noreceipt' );
2614 if ( false === $res ) {
2615 $log = array(
2616 'acting' => 'paygent_conv',
2617 'key' => $post_data['trading_id'],
2618 'result' => 'ORDER DATA UPDATE ERROR',
2619 'data' => $post_data,
2620 );
2621 usces_save_order_acting_error( $log );
2622 } else {
2623 usces_action_acting_getpoint( $order_id, false );
2624 }
2625 }
2626 }
2627 break;
2628 case STATUS_PAYMENT_EXPIRED: /* 支払期限切 */
2629 $order_id = $this->get_order_id( $post_data['trading_id'] );
2630 if ( $order_id ) {
2631 $this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2632 }
2633 break;
2634 }
2635 break;
2636
2637 /* ATM決済 */
2638 case PAYMENT_TYPE_ATM:
2639 switch ( $payment_status ) {
2640 case STATUS_PAYMENT_EXPIRED: /* 支払期限切 */
2641 $order_id = $this->get_order_id( $post_data['trading_id'] );
2642 if ( $order_id ) {
2643 $this->save_acting_log( $post_data, 'paygent_atm', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2644 }
2645 break;
2646 case STATUS_CLEARED: /* 消込済 */
2647 $order_id = $this->get_order_id( $post_data['trading_id'] );
2648 if ( $order_id ) {
2649 $this->save_acting_log( $post_data, 'paygent_atm', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2650 $order_status = $this->get_order_status( $order_id );
2651 if ( 0 == $order_status ) {
2652 $res = usces_change_order_receipt( $order_id, 'receipted' );
2653 if ( false === $res ) {
2654 $log = array(
2655 'acting' => 'paygent_atm',
2656 'key' => $post_data['trading_id'],
2657 'result' => 'ORDER DATA UPDATE ERROR',
2658 'data' => $post_data,
2659 );
2660 usces_save_order_acting_error( $log );
2661 } else {
2662 usces_action_acting_getpoint( $order_id );
2663 $usces->set_order_meta_value( 'acting_paygent_atm', usces_serialize( $post_data ), $order_id );
2664 do_action( 'usces_action_paygent_atm_payment_completion', $post_data, $order_id );
2665 }
2666 }
2667 }
2668 break;
2669 }
2670 break;
2671
2672 /* 銀行ネット決済 */
2673 case PAYMENT_TYPE_BANK:
2674 switch ( $payment_status ) {
2675 case STATUS_REGISTRATION_SUSPENDED: /* 申込中断 */
2676 $order_id = $this->get_order_id( $post_data['trading_id'] );
2677 if ( $order_id ) {
2678 $this->save_acting_log( $post_data, 'paygent_bank', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2679 }
2680 break;
2681 case STATUS_CLEARED: /* 消込済 */
2682 $order_id = $this->get_order_id( $post_data['trading_id'] );
2683 if ( $order_id ) {
2684 $this->save_acting_log( $post_data, 'paygent_bank', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2685 $order_status = $this->get_order_status( $order_id );
2686 if ( 0 == $order_status ) {
2687 $res = usces_change_order_receipt( $order_id, 'receipted' );
2688 if ( false === $res ) {
2689 $log = array(
2690 'acting' => 'paygent_bank',
2691 'key' => $post_data['trading_id'],
2692 'result' => 'ORDER DATA UPDATE ERROR',
2693 'data' => $post_data,
2694 );
2695 usces_save_order_acting_error( $log );
2696 } else {
2697 usces_action_acting_getpoint( $order_id );
2698 $usces->set_order_meta_value( 'acting_paygent_bank', usces_serialize( $post_data ), $order_id );
2699 do_action( 'usces_action_paygent_bank_payment_completion', $post_data, $order_id );
2700 }
2701 }
2702 }
2703 break;
2704 }
2705 break;
2706
2707 /* Paidy */
2708 case PAYMENT_TYPE_PAIDY:
2709 switch ( $payment_status ) {
2710 case STATUS_AUTHORIZE_NG: /* オーソリNG */
2711 case STATUS_AUTHORIZE_OK: /* オーソリOK */
2712 case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
2713 case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
2714 case STATUS_CLEARED: /* 消込済 */
2715 case STATUS_CLEARED_SALES_CANCEL_INVALIDITY: /* 消込済(売上取消期限切) */
2716 case STATUS_SALES_CANCELED: /* 売上取消済 */
2717 $order_id = $this->get_order_id( $post_data['trading_id'] );
2718 if ( $order_id ) {
2719 $this->save_acting_log( $post_data, 'paygent_paidy', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2720 }
2721 break;
2722 }
2723 break;
2724 }
2725 }
2726 die( 'result=0' );
2727 }
2728 }
2729
2730 /**
2731 * ポイント即時付与
2732 * usces_filter_is_complete_settlement
2733 *
2734 * @param boolean $complete Complete the payment.
2735 * @param string $payment_name Payment name.
2736 * @param string $status Payment status.
2737 * @return boolean
2738 */
2739 public function is_complete_settlement( $complete, $payment_name, $status ) {
2740 $payment = usces_get_payments_by_name( $payment_name );
2741 if ( isset( $payment['settlement'] ) && ( 'acting_paygent_card' == $payment['settlement'] || 'acting_paygent_paidy' == $payment['settlement'] ) ) {
2742 $complete = true;
2743 }
2744 return $complete;
2745 }
2746
2747 /**
2748 * 管理画面決済処理
2749 * usces_action_admin_ajax
2750 */
2751 public function admin_ajax() {
2752 global $usces;
2753
2754 $post_data = wp_unslash( $_POST );
2755 $mode = sanitize_title( $post_data['mode'] );
2756 $data = array();
2757
2758 switch ( $mode ) {
2759 /* クレジットカード参�
2760 � */
2761 case 'get_paygent_card':
2762 check_admin_referer( 'order_edit', 'wc_nonce' );
2763 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2764 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2765 $member_id = ( isset( $post_data['member_id'] ) ) ? $post_data['member_id'] : '';
2766 if ( empty( $order_id ) || empty( $trading_id ) ) {
2767 $data['status'] = 'reference_error';
2768 wp_send_json( $data );
2769 break;
2770 }
2771
2772 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2773 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2774 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id, $member_id );
2775 wp_send_json( $data );
2776 break;
2777
2778 /* クレジットカード売上処理 */
2779 case 'sales_paygent_card':
2780 check_admin_referer( 'order_edit', 'wc_nonce' );
2781 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2782 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2783 if ( empty( $order_id ) || empty( $trading_id ) ) {
2784 $data['status'] = 'reference_error';
2785 wp_send_json( $data );
2786 break;
2787 }
2788
2789 $result = '';
2790 $status = '';
2791
2792 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2793 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2794 $telegram_kind = PAYGENT_CARD_COMMIT;
2795 $settlement = $this->settlement_request( $telegram_kind, $trading_id, $payment_id );
2796 $settlement = apply_filters( 'usces_filter_paygent_card_acting_sales_log', $settlement, $order_id, $trading_id );
2797 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
2798 $this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
2799 $status = 'payment_error';
2800 $status_name = $this->get_status_name( $status );
2801 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
2802 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
2803 �更新" /></div>';
2804 $result .= $this->settlement_history( $order_id, $trading_id );
2805 $data['result'] = $result;
2806 $data['status'] = $status;
2807 } else {
2808 $this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
2809 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
2810 }
2811 $this->save_admin_log( $order_id, $trading_id );
2812 wp_send_json( $data );
2813 break;
2814
2815 /* クレジットカードオーソリ取消 */
2816 case 'auth_cancel_paygent_card':
2817 check_admin_referer( 'order_edit', 'wc_nonce' );
2818 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2819 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2820 if ( empty( $order_id ) || empty( $trading_id ) ) {
2821 $data['status'] = 'reference_error';
2822 wp_send_json( $data );
2823 break;
2824 }
2825
2826 $result = '';
2827 $status = '';
2828
2829 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2830 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2831 $telegram_kind = PAYGENT_AUTH_CANCEL;
2832 $settlement = $this->settlement_request( $telegram_kind, $trading_id, $payment_id );
2833 $settlement = apply_filters( 'usces_filter_paygent_card_acting_auth_cancel_log', $settlement, $order_id, $trading_id );
2834 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
2835 $this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
2836 $status = 'payment_error';
2837 $status_name = $this->get_status_name( $status );
2838 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
2839 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
2840 �更新" /></div>';
2841 $result .= $this->settlement_history( $order_id, $trading_id );
2842 $data['result'] = $result;
2843 $data['status'] = $status;
2844 } else {
2845 $this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
2846 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
2847 }
2848 $this->save_admin_log( $order_id, $trading_id );
2849 wp_send_json( $data );
2850 break;
2851
2852 /* クレジットカードオーソリ変更 */
2853 case 'auth_revise_paygent_card':
2854 check_admin_referer( 'order_edit', 'wc_nonce' );
2855 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2856 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2857 $amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
2858 if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
2859 $data['status'] = 'reference_error';
2860 wp_send_json( $data );
2861 break;
2862 }
2863
2864 $result = '';
2865 $status = '';
2866
2867 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2868 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2869 $telegram_kind = PAYGENT_CARD_COMMIT_AUTH_REVISE;
2870 $settlement = $this->settlement_request_revise( $telegram_kind, $trading_id, $payment_id, $amount );
2871 $settlement = apply_filters( 'usces_filter_paygent_card_acting_auth_revise_log', $settlement, $order_id, $trading_id );
2872 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
2873 $this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
2874 $status = 'payment_error';
2875 $status_name = $this->get_status_name( $status );
2876 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
2877 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
2878 �更新" /></div>';
2879 $result .= $this->settlement_history( $order_id, $trading_id );
2880 $data['result'] = $result;
2881 $data['status'] = $status;
2882 } else {
2883 $this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
2884 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
2885 }
2886 $this->save_admin_log( $order_id, $trading_id );
2887 wp_send_json( $data );
2888 break;
2889
2890 /* クレジットカード売上取消(キャンセル処理) */
2891 case 'sales_cancel_paygent_card':
2892 check_admin_referer( 'order_edit', 'wc_nonce' );
2893 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2894 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2895 if ( empty( $order_id ) || empty( $trading_id ) ) {
2896 $data['status'] = 'reference_error';
2897 wp_send_json( $data );
2898 break;
2899 }
2900
2901 $result = '';
2902 $status = '';
2903
2904 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2905 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2906 $telegram_kind = PAYGENT_CARD_COMMIT_CANCEL;
2907 $settlement = $this->settlement_request( $telegram_kind, $trading_id, $payment_id );
2908 $settlement = apply_filters( 'usces_filter_paygent_card_acting_sales_cancel_log', $settlement, $order_id, $trading_id );
2909 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
2910 $this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
2911 $status = 'payment_error';
2912 $status_name = $this->get_status_name( $status );
2913 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
2914 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
2915 �更新" /></div>';
2916 $result .= $this->settlement_history( $order_id, $trading_id );
2917 $data['result'] = $result;
2918 $data['status'] = $status;
2919 } else {
2920 $this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
2921 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
2922 }
2923 $this->save_admin_log( $order_id, $trading_id );
2924 wp_send_json( $data );
2925 break;
2926
2927 /* クレジットカード売上金額変更(売上変更) */
2928 case 'sales_revise_paygent_card':
2929 check_admin_referer( 'order_edit', 'wc_nonce' );
2930 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2931 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2932 $amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
2933 if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
2934 $data['status'] = 'reference_error';
2935 wp_send_json( $data );
2936 break;
2937 }
2938
2939 $result = '';
2940 $status = '';
2941
2942 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2943 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2944 $telegram_kind = PAYGENT_CARD_COMMIT_REVISE;
2945 $settlement = $this->settlement_request_revise( $telegram_kind, $trading_id, $payment_id, $amount );
2946 $settlement = apply_filters( 'usces_filter_paygent_card_acting_sales_revise_log', $settlement, $order_id, $trading_id );
2947 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
2948 $this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
2949 $status = 'payment_error';
2950 $status_name = $this->get_status_name( $status );
2951 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
2952 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
2953 �更新" /></div>';
2954 $result .= $this->settlement_history( $order_id, $trading_id );
2955 $data['result'] = $result;
2956 $data['status'] = $status;
2957 } else {
2958 $this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
2959 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
2960 }
2961 $this->save_admin_log( $order_id, $trading_id );
2962 wp_send_json( $data );
2963 break;
2964
2965 /* クレジットカード新規オーソリ */
2966 case 'auth_paygent_card':
2967 check_admin_referer( 'order_edit', 'wc_nonce' );
2968 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2969 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2970 $member_id = ( isset( $post_data['member_id'] ) ) ? $post_data['member_id'] : '';
2971 $amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
2972 if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
2973 $data['status'] = 'reference_error';
2974 wp_send_json( $data );
2975 break;
2976 }
2977
2978 $result = '';
2979 $status = '';
2980
2981 // $trading_id = usces_acting_key();
2982 $customer = $this->customer_ref( $member_id );
2983 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id && isset( $customer['customer_card_id'] ) ) {
2984 $telegram_kind = PAYGENT_CREDIT;
2985
2986 $pm = Paygent_Module::get_instance();
2987 $pm->init();
2988 $pm->req_put( 'trading_id', $trading_id );
2989 $pm->req_put( 'payment_amount', $amount );
2990 $pm->req_put( 'payment_class', '10' );
2991 $pm->req_put( '3dsecure_ryaku', '1' );
2992 $pm->req_put( 'stock_card_mode', '1' );
2993 $pm->req_put( 'customer_id', $member_id );
2994 $pm->req_put( 'customer_card_id', $customer['customer_card_id'] );
2995 $pm->req_put( 'sales_mode', '0' ); /* Auth */
2996
2997 $result_post = $pm->post( $telegram_kind );
2998 $result_status = $pm->get_result_status();
2999 if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
3000 $response_data = array(
3001 'result' => $result_post,
3002 'result_status' => $result_status,
3003 'response_code' => $pm->get_response_code(),
3004 'response_detail' => $pm->get_response_detail(),
3005 'result_message' => $pm->get_result_message(),
3006 );
3007 $this->save_acting_log( $response_data, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3008 $status = 'payment_error';
3009 $status_name = $this->get_status_name( $status );
3010 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3011 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3012 �更新" /></div>';
3013 $result .= $this->settlement_history( $order_id, $trading_id );
3014 $data['result'] = $result;
3015 $data['status'] = $status;
3016 } else {
3017 $response_data = $pm->get_response_data();
3018 if ( ! isset( $response_data['payment_type'] ) ) {
3019 $response_data['payment_type'] = PAYMENT_TYPE_CREDIT;
3020 }
3021 $this->save_acting_log( $response_data, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3022 $usces->set_order_meta_value( 'acting_paygent_card', usces_serialize( $response_data ), $order_id );
3023 $payment_id = ( isset( $response_data['payment_id'] ) ) ? $response_data['payment_id'] : '';
3024 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
3025 }
3026 $this->save_admin_log( $order_id, $trading_id );
3027 } else {
3028 if ( ! isset( $customer['payment_type'] ) ) {
3029 $customer['payment_type'] = PAYMENT_TYPE_CREDIT;
3030 }
3031 $this->save_acting_log( $customer, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3032 $status = 'payment_error';
3033 $status_name = $this->get_status_name( $status );
3034 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3035 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3036 �更新" /></div>';
3037 $result .= $this->settlement_history( $order_id, $trading_id );
3038 $data['result'] = $result;
3039 $data['status'] = $status;
3040 $this->save_admin_log( $order_id, $trading_id );
3041 }
3042 wp_send_json( $data );
3043 break;
3044
3045 /* コンビニ参�
3046 � */
3047 case 'get_paygent_conv':
3048 check_admin_referer( 'order_edit', 'wc_nonce' );
3049 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3050 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3051 if ( empty( $order_id ) || empty( $trading_id ) ) {
3052 $data['status'] = 'reference_error';
3053 wp_send_json( $data );
3054 break;
3055 }
3056
3057 $result = '';
3058 $status = '';
3059
3060 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3061 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3062 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
3063 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
3064 $status = 'reference_error';
3065 $status_name = $this->get_status_name( $status );
3066 $result .= '<div class="paygent-settlement-admin conv-error">' . $status_name . '</div>';
3067 } else {
3068 $payment_status = ( isset( $settlement_ref['payment_status'] ) ) ? $settlement_ref['payment_status'] : '';
3069 $status = $this->get_status( $payment_status );
3070 $class = ' conv-' . $status;
3071 $status_name = $this->get_status_name( $payment_status );
3072 $result .= '<div class="paygent-settlement-admin' . $class . '">' . $status_name . '</div>';
3073 }
3074 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="conv" value="状�
3075 �更新" /></div>';
3076 $result .= $this->settlement_history( $order_id, $trading_id );
3077 $data['result'] = $result;
3078 $data['status'] = $status;
3079 wp_send_json( $data );
3080 break;
3081
3082 /* ATM参�
3083 � */
3084 case 'get_paygent_atm':
3085 check_admin_referer( 'order_edit', 'wc_nonce' );
3086 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3087 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3088 if ( empty( $order_id ) || empty( $trading_id ) ) {
3089 $data['status'] = 'reference_error';
3090 wp_send_json( $data );
3091 break;
3092 }
3093
3094 $result = '';
3095 $status = '';
3096
3097 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3098 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3099 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
3100 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
3101 $status = 'reference_error';
3102 $status_name = $this->get_status_name( $status );
3103 $result .= '<div class="paygent-settlement-admin atm-error">' . $status_name . '</div>';
3104 } else {
3105 $payment_status = ( isset( $settlement_ref['payment_status'] ) ) ? $settlement_ref['payment_status'] : '';
3106 $status = $this->get_status( $payment_status );
3107 $class = ' atm-' . $status;
3108 $status_name = $this->get_status_name( $payment_status );
3109 $result .= '<div class="paygent-settlement-admin' . $class . '">' . $status_name . '</div>';
3110 }
3111 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="atm" value="状�
3112 �更新" /></div>';
3113 $result .= $this->settlement_history( $order_id, $trading_id );
3114 $data['result'] = $result;
3115 $data['status'] = $status;
3116 wp_send_json( $data );
3117 break;
3118
3119 /* 銀行ネット決済参�
3120 � */
3121 case 'get_paygent_bank':
3122 check_admin_referer( 'order_edit', 'wc_nonce' );
3123 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3124 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3125 if ( empty( $order_id ) || empty( $trading_id ) ) {
3126 $data['status'] = 'reference_error';
3127 wp_send_json( $data );
3128 break;
3129 }
3130
3131 $result = '';
3132 $status = '';
3133 $acting_status = '';
3134
3135 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3136 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3137 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
3138 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
3139 if ( 'bank_applying' == $latest_log['status'] ) {
3140 $status = 'bank_applying';
3141 $status_name = $this->get_status_name( $status );
3142 $result .= '<div class="paygent-settlement-admin bank-applying">' . $status_name . '</div>';
3143 } else {
3144 $status = 'reference_error';
3145 $status_name = $this->get_status_name( $status );
3146 $result .= '<div class="paygent-settlement-admin bank-error">' . $status_name . '</div>';
3147 }
3148 } else {
3149 $payment_status = ( isset( $settlement_ref['payment_status'] ) ) ? $settlement_ref['payment_status'] : '';
3150 $status = $this->get_status( $payment_status );
3151 $class = ' bank-' . $status;
3152 $status_name = $this->get_status_name( $payment_status );
3153 $result .= '<div class="paygent-settlement-admin' . $class . '">' . $status_name . '</div>';
3154 if ( 'bank_applying' == $latest_log['status'] && STATUS_REQUESTED == $payment_status ) {
3155 $this->save_acting_log( $settlement_ref, 'paygent_bank', $payment_status, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3156 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
3157 }
3158 }
3159 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="bank" value="状�
3160 �更新" /></div>';
3161 $result .= $this->settlement_history( $order_id, $trading_id );
3162 $data['result'] = $result;
3163 $data['status'] = $status;
3164 $data['acting_status'] = $acting_status;
3165 wp_send_json( $data );
3166 break;
3167
3168 /* Paidy 参�
3169 � */
3170 case 'get_paygent_paidy':
3171 check_admin_referer( 'order_edit', 'wc_nonce' );
3172 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3173 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3174 if ( empty( $order_id ) || empty( $trading_id ) ) {
3175 $data['status'] = 'reference_error';
3176 wp_send_json( $data );
3177 break;
3178 }
3179
3180 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3181 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3182 $data = $this->settlement_reference_paidy( $order_id, $trading_id, $payment_id );
3183 wp_send_json( $data );
3184 break;
3185
3186 /* Paidy オーソリキャンセル */
3187 case 'cancel_paygent_paidy':
3188 check_admin_referer( 'order_edit', 'wc_nonce' );
3189 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3190 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3191 if ( empty( $order_id ) || empty( $trading_id ) ) {
3192 $data['status'] = 'reference_error';
3193 wp_send_json( $data );
3194 break;
3195 }
3196
3197 $result = '';
3198 $status = '';
3199
3200 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3201 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3202 $telegram_kind = PAYGENT_PAIDY_AUTH_CANCEL;
3203 $settlement = $this->settlement_request_paidy( $telegram_kind, $trading_id, $payment_id );
3204 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
3205 $this->save_acting_log( $settlement, 'paygent_paidy', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3206 $status = 'payment_error';
3207 $status_name = $this->get_status_name( $status );
3208 $result .= '<div class="paygent-settlement-admin paidy-error">' . $status_name . '</div>';
3209 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3210 �更新" /></div>';
3211 $result .= $this->settlement_history( $order_id, $trading_id );
3212 $data['result'] = $result;
3213 $data['status'] = $status;
3214 } else {
3215 $this->save_acting_log( $settlement, 'paygent_paidy', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3216 $data = $this->settlement_reference_paidy( $order_id, $trading_id );
3217 }
3218 wp_send_json( $data );
3219 break;
3220
3221 /* Paidy 売上 */
3222 case 'capture_paygent_paidy':
3223 check_admin_referer( 'order_edit', 'wc_nonce' );
3224 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3225 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3226 if ( empty( $order_id ) || empty( $trading_id ) ) {
3227 $data['status'] = 'reference_error';
3228 wp_send_json( $data );
3229 break;
3230 }
3231
3232 $result = '';
3233 $status = '';
3234
3235 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3236 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3237 $telegram_kind = PAYGENT_PAIDY_CAPTURE;
3238 $settlement = $this->settlement_request_paidy( $telegram_kind, $trading_id, $payment_id );
3239 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
3240 $this->save_acting_log( $settlement, 'paygent_paidy', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3241 $status = 'payment_error';
3242 $status_name = $this->get_status_name( $status );
3243 $result .= '<div class="paygent-settlement-admin paidy-error">' . $status_name . '</div>';
3244 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3245 �更新" /></div>';
3246 $result .= $this->settlement_history( $order_id, $trading_id );
3247 $data['result'] = $result;
3248 $data['status'] = $status;
3249 } else {
3250 $this->save_acting_log( $settlement, 'paygent_paidy', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3251 $data = $this->settlement_reference_paidy( $order_id, $trading_id );
3252 }
3253 wp_send_json( $data );
3254 break;
3255
3256 /* Paidy 返金 */
3257 case 'refund_paygent_paidy':
3258 check_admin_referer( 'order_edit', 'wc_nonce' );
3259 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3260 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3261 $amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
3262 if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
3263 $data['status'] = 'reference_error';
3264 wp_send_json( $data );
3265 break;
3266 }
3267
3268 $result = '';
3269 $status = '';
3270
3271 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3272 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3273 $telegram_kind = PAYGENT_PAIDY_REFUND;
3274 $settlement = $this->settlement_request_paidy_refund( $telegram_kind, $trading_id, $amount, $payment_id );
3275 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
3276 $this->save_acting_log( $settlement, 'paygent_paidy', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3277 $status = 'payment_error';
3278 $status_name = $this->get_status_name( $status );
3279 $result .= '<div class="paygent-settlement-admin paidy-error">' . $status_name . '</div>';
3280 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3281 �更新" /></div>';
3282 $result .= $this->settlement_history( $order_id, $trading_id );
3283 $data['result'] = $result;
3284 $data['status'] = $status;
3285 } else {
3286 $this->save_acting_log( $settlement, 'paygent_paidy', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3287 $data = $this->settlement_reference_paidy( $order_id, $trading_id );
3288 }
3289 wp_send_json( $data );
3290 break;
3291
3292 /* 継続課金�
3293 報更新 */
3294 case 'continuation_update':
3295 check_admin_referer( 'order_edit', 'wc_nonce' );
3296 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3297 $member_id = ( isset( $post_data['member_id'] ) ) ? $post_data['member_id'] : '';
3298 $contracted_year = ( isset( $post_data['contracted_year'] ) ) ? $post_data['contracted_year'] : '';
3299 $contracted_month = ( isset( $post_data['contracted_month'] ) ) ? $post_data['contracted_month'] : '';
3300 $contracted_day = ( isset( $post_data['contracted_day'] ) ) ? $post_data['contracted_day'] : '';
3301 $charged_year = ( isset( $post_data['charged_year'] ) ) ? $post_data['charged_year'] : '';
3302 $charged_month = ( isset( $post_data['charged_month'] ) ) ? $post_data['charged_month'] : '';
3303 $charged_day = ( isset( $post_data['charged_day'] ) ) ? $post_data['charged_day'] : '';
3304 $price = ( isset( $post_data['price'] ) ) ? $post_data['price'] : 0;
3305 $status = ( isset( $post_data['status'] ) ) ? $post_data['status'] : '';
3306
3307 $continue_data = $this->get_continuation_data( $member_id, $order_id );
3308 if ( ! $continue_data ) {
3309 $data['status'] = 'NG';
3310 wp_send_json( $data );
3311 break;
3312 }
3313
3314 /* 継続中→停止 */
3315 if ( 'continuation' == $continue_data['status'] && 'cancellation' == $status ) {
3316 $this->update_continuation_data( $member_id, $order_id, $continue_data, true );
3317 } else {
3318 if ( ! empty( $contracted_year ) && ! empty( $contracted_month ) && ! empty( $contracted_day ) ) {
3319 $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
3320 if ( $contracted_date ) {
3321 $new_contracted_date = $contracted_year . '-' . $contracted_month . '-' . $contracted_day;
3322 if ( ! $this->isdate( $new_contracted_date ) ) {
3323 $data['status'] = 'NG';
3324 $data['message'] = __( 'Next contract renewal date is incorrect.', 'dlseller' );
3325 wp_send_json( $data );
3326 }
3327 }
3328 } else {
3329 $new_contracted_date = '';
3330 }
3331 $new_charged_date = $charged_year . '-' . $charged_month . '-' . $charged_day;
3332 if ( ! $this->isdate( $new_charged_date ) ) {
3333 $data['status'] = 'NG';
3334 $data['message'] = __( 'Next settlement date is incorrect.', 'dlseller' );
3335 wp_send_json( $data );
3336 }
3337 $tomorrow = date_i18n( 'Y-m-d', strtotime( '+1 day' ) );
3338 if ( $new_charged_date < $tomorrow ) {
3339 $data['status'] = 'NG';
3340 $data['message'] = sprintf( __( 'The next settlement date must be after %s.', 'dlseller' ), $tomorrow );
3341 wp_send_json( $data );
3342 }
3343 $continue_data['contractedday'] = $new_contracted_date;
3344 $continue_data['chargedday'] = $new_charged_date;
3345 $continue_data['price'] = usces_crform( $price, false, false, 'return', false );
3346 $continue_data['status'] = $status;
3347 $this->update_continuation_data( $member_id, $order_id, $continue_data );
3348 }
3349 $data['status'] = 'OK';
3350 wp_send_json( $data );
3351 break;
3352 }
3353 }
3354
3355 /**
3356 * クレジットカード決済履歴
3357 *
3358 * @param int $order_id Order number.
3359 * @param string $trading_id Trading ID.
3360 * @param string $payment_id Payment ID.
3361 * @param int $member_id Member ID.
3362 * @return array
3363 */
3364 private function settlement_reference_card( $order_id, $trading_id, $payment_id, $member_id = '' ) {
3365 global $usces;
3366
3367 $data = array();
3368 $result = '';
3369 $status = '';
3370 $acting_status = '';
3371
3372 if ( empty( $payment_id ) ) {
3373 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id, RESULT_STATUS_ALL );
3374 if ( isset( $latest_log['status'] ) && ( 'payment_error' == $latest_log['status'] || 'customer_error' == $latest_log['status'] ) ) {
3375 $customer = $this->customer_ref( $member_id );
3376 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id ) {
3377 $order_data = $usces->get_order_data( $order_id, 'direct' );
3378 $amount = $order_data['order_item_total_price'] - $order_data['order_usedpoint'] + $order_data['order_discount'] + $order_data['order_shipping_charge'] + $order_data['order_cod_fee'] + $order_data['order_tax'];
3379 $result .= '<table class="settlement-admin-table">';
3380 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3381 $result .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3382 $result .= '</tr></table>';
3383 $result .= '<div class="paygent-settlement-admin-button">';
3384 $result .= '<input id="auth-settlement" type="button" class="button" value="新規オーソリ" />';
3385 $result .= '<input id="update-status" type="button" class="button" data-mode="card" value="状�
3386 �更新" />';
3387 $result .= '</div>';
3388 } else {
3389 $status = 'error';
3390 $result .= '<div class="paygent-settlement-admin card-error">' . __( 'Credit card information not registered', 'usces' ) . '</div>';
3391 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3392 �更新" /></div>';
3393 }
3394 } else {
3395 $status = 'error';
3396 $status_name = $this->get_status_name( $status );
3397 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3398 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3399 �更新" /></div>';
3400 }
3401 } else {
3402 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
3403 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
3404 $status = 'reference_error';
3405 $status_name = $this->get_status_name( $status );
3406 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3407 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3408 �更新" /></div>';
3409 } elseif ( isset( $settlement_ref['payment_status'] ) ) {
3410 $payment_status = $settlement_ref['payment_status'];
3411 $status = $this->get_status( $payment_status );
3412 $class = ' card-' . $status;
3413 $status_name = $this->get_status_name( $payment_status );
3414 $amount = $settlement_ref['payment_amount'];
3415 $result .= '<div class="paygent-settlement-admin' . $class . '">' . $status_name . '</div>';
3416 switch ( $payment_status ) {
3417 case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
3418 case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
3419 $result .= '<table class="settlement-admin-table">';
3420 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3421 $result .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3422 $result .= '</tr></table>';
3423 $result .= '<div class="paygent-settlement-admin-button">';
3424 $result .= '<input id="auth-settlement" type="button" class="button" value="新規オーソリ" />';
3425 $result .= '<input id="update-status" type="button" class="button" data-mode="card" value="状�
3426 �更新" />';
3427 $result .= '</div>';
3428 break;
3429 case STATUS_AUTHORIZE_OK: /* オーソリOK */
3430 $result .= '<table class="settlement-admin-table">';
3431 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3432 $result .= '<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>';
3433 $result .= '</tr></table>';
3434 $result .= '<div class="paygent-settlement-admin-button">';
3435 $result .= '<input id="sales-settlement" type="button" class="button" value="売上処理" />';
3436 $result .= '<input id="auth-revise-settlement" type="button" class="button" value="金額変更" />';
3437 $result .= '<input id="auth-cancel-settlement" type="button" class="button" value="キャンセル処理" />';
3438 $result .= '<input id="update-status" type="button" class="button" data-mode="card" value="状�
3439 �更新" />';
3440 $result .= '</div>';
3441 break;
3442 case STATUS_AUTHORIZE_CANCELING: /* オーソリ取消中 */
3443 $result .= '<table class="settlement-admin-table">';
3444 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3445 $result .= '<td><input type="tel" class="settlement-amount" value="' . intval( $amount ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3446 $result .= '</tr></table>';
3447 $result .= '<div class="paygent-settlement-admin-button">';
3448 $result .= '<input id="auth-cancel-settlement" type="button" class="button" value="キャンセル処理" />';
3449 $result .= '</div>';
3450 break;
3451 case STATUS_SALES_REQUEST_PENDING: /* 売上要求中 */
3452 $result .= '<table class="settlement-admin-table">';
3453 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3454 $result .= '<td><input type="tel" class="settlement-amount" value="' . intval( $amount ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3455 $result .= '</tr></table>';
3456 $result .= '<div class="paygent-settlement-admin-button">';
3457 $result .= '<input id="sales-settlement" type="button" class="button" value="売上処理" />';
3458 $result .= '</div>';
3459 break;
3460 case STATUS_CLEARED: /* 消込済 */
3461 $result .= '<table class="settlement-admin-table">';
3462 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3463 $result .= '<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>';
3464 $result .= '</tr></table>';
3465 $result .= '<div class="paygent-settlement-admin-button">';
3466 $result .= '<input id="sales-revise-settlement" type="button" class="button" value="金額変更" />';
3467 $result .= '<input id="sales-cancel-settlement" type="button" class="button" value="キャンセル処理" />';
3468 $result .= '<input id="update-status" type="button" class="button" data-mode="card" value="状�
3469 �更新" />';
3470 $result .= '</div>';
3471 break;
3472 case STATUS_SALES_CANCELING: /* 売上取消中 */
3473 case STATUS_SALES_CANCELING_TALLY: /* 売上取消集計中 */
3474 $result .= '<table class="settlement-admin-table">';
3475 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3476 $result .= '<td><input type="tel" class="settlement-amount" value="' . intval( $amount ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3477 $result .= '</tr></table>';
3478 $result .= '<div class="paygent-settlement-admin-button">';
3479 $result .= '<input id="sales-cancel-settlement" type="button" class="button" value="キャンセル処理" />';
3480 $result .= '</div>';
3481 break;
3482 default:
3483 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3484 �更新" /></div>';
3485 }
3486 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
3487 } else {
3488 $status = 'error';
3489 $status_name = $this->get_status_name( $status );
3490 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3491 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3492 �更新" /></div>';
3493 }
3494 }
3495 $result .= $this->settlement_history( $order_id, $trading_id );
3496 $data['result'] = $result;
3497 $data['status'] = $status;
3498 $data['acting_status'] = $acting_status;
3499 return $data;
3500 }
3501
3502 /**
3503 * Paidy 決済履歴
3504 *
3505 * @param int $order_id Order number.
3506 * @param string $trading_id Trading ID.
3507 * @param string $payment_id Payment ID.
3508 * @return array
3509 */
3510 private function settlement_reference_paidy( $order_id, $trading_id, $payment_id = '' ) {
3511 $data = array();
3512 $result = '';
3513 $status = '';
3514 $acting_status = '';
3515 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
3516 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
3517 $status = 'reference_error';
3518 $status_name = $this->get_status_name( $status );
3519 $result .= '<div class="paygent-settlement-admin paidy-error">' . $status_name . '</div>';
3520 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3521 �更新" /></div>';
3522 } elseif ( isset( $settlement_ref['payment_status'] ) ) {
3523 $payment_status = $settlement_ref['payment_status'];
3524 $status = $this->get_status( $payment_status );
3525 $class = ' paidy-' . $status;
3526 $status_name = $this->get_status_name( $payment_status );
3527 $amount = $settlement_ref['payment_amount'];
3528 $result .= '<div class="paygent-settlement-admin' . $class . '">' . $status_name . '</div>';
3529 switch ( $payment_status ) {
3530 case STATUS_AUTHORIZE_OK: /* オーソリOK */
3531 $result .= '<table class="settlement-admin-table">';
3532 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3533 $result .= '<td><input type="tel" class="settlement-amount" value="' . intval( $amount ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3534 $result .= '</tr></table>';
3535 $result .= '<div class="paygent-settlement-admin-button">';
3536 $result .= '<input id="paidy-capture-settlement" type="button" class="button" value="売上処理" />';
3537 $result .= '<input id="paidy-cancel-settlement" type="button" class="button" value="オーソリキャンセル処理" />';
3538 $result .= '<input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3539 �更新" />';
3540 $result .= '</div>';
3541 break;
3542 case STATUS_CLEARED: /* 消込済 */
3543 $result .= '<table class="settlement-admin-table">';
3544 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3545 $result .= '<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>';
3546 $result .= '</tr></table>';
3547 $result .= '<div class="paygent-settlement-admin-button">';
3548 $result .= '<input id="paidy-refund-settlement" type="button" class="button" value="返金処理" />';
3549 $result .= '<input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3550 �更新" />';
3551 $result .= '</div>';
3552 break;
3553 default:
3554 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3555 �更新" /></div>';
3556 }
3557 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
3558 } else {
3559 $status = 'error';
3560 $status_name = $this->get_status_name( $status );
3561 $result .= '<div class="paygent-settlement-admin paidy-error">' . $status_name . '</div>';
3562 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3563 �更新" /></div>';
3564 }
3565 $result .= $this->settlement_history( $order_id, $trading_id );
3566 $data['result'] = $result;
3567 $data['status'] = $status;
3568 $data['acting_status'] = $acting_status;
3569 return $data;
3570 }
3571
3572 /**
3573 * 決済履歴
3574 *
3575 * @param int $order_id Order number.
3576 * @param string $trading_id Trading ID.
3577 * @return string
3578 */
3579 private function settlement_history( $order_id, $trading_id ) {
3580 $history = '';
3581 $log_data = $this->get_acting_log( $order_id, $trading_id, RESULT_STATUS_ALL );
3582 if ( $log_data ) {
3583 $num = count( $log_data );
3584 $history = '<table class="settlement-history">';
3585 $history .= '<thead class="settlement-history-head">';
3586 $history .= '<tr><th></th><th>' . __( 'Processing date', 'usces' ) . '</th><th>決済ID</th><th>マーチャント取引ID</th><th>' . __( 'Processing classification', 'usces' ) . '</th><th>' . __( 'Amount', 'usces' ) . '</th><th>' . __( 'Result', 'usces' ) . '</th></tr>';
3587 $history .= '</thead>';
3588 $history .= '<tbody class="settlement-history-body">';
3589 foreach ( (array) $log_data as $data ) {
3590 $log = usces_unserialize( $data['log'] );
3591 $payment_id = ( isset( $log['payment_id'] ) ) ? $log['payment_id'] : '';
3592 if ( empty( $payment_id ) && isset( $log['paidy_id'] ) ) {
3593 $payment_id = $log['paidy_id'];
3594 }
3595 $status_name = ( isset( $data['status'] ) ) ? $this->get_status_name( $data['status'] ) : '';
3596 $err_code = '';
3597 $class = '';
3598 if ( 2 == strlen( $data['status'] ) || 0 < $data['amount'] ) {
3599 $amount = usces_crform( $data['amount'], false, true, 'return', true );
3600 } else {
3601 $amount = '';
3602 }
3603 if ( RESULT_STATUS_NORMAL != $data['result'] ) {
3604 $err_code = ( isset( $log['result_message'] ) ) ? $log['result_message'] : '';
3605 $class = ' error';
3606 }
3607 $history .= '<tr>';
3608 $history .= '<td class="num">' . $num . '</td>';
3609 $history .= '<td class="datetime">' . $data['datetime'] . '</td>';
3610 $history .= '<td class="transactionid">' . $payment_id . '</td>';
3611 $history .= '<td class="tradingid">' . $trading_id . '</td>';
3612 $history .= '<td class="status">' . $status_name . '</td>';
3613 $history .= '<td class="amount">' . $amount . '</td>';
3614 $history .= '<td class="result' . $class . '">' . $err_code . '</td>';
3615 $history .= '</tr>';
3616 $num--;
3617 }
3618 $history .= '</tbody>';
3619 $history .= '</table>';
3620 }
3621 return $history;
3622 }
3623
3624 /**
3625 * 決済状況
3626 * usces_filter_orderlist_detail_value
3627 *
3628 * @param string $detail HTML.
3629 * @param string $value Settlement info key.
3630 * @param string $key Settlement info value.
3631 * @param int $order_id Order number.
3632 * @return array
3633 */
3634 public function orderlist_settlement_status( $detail, $value, $key, $order_id ) {
3635 global $usces;
3636
3637 if ( 'wc_trans_id' != $key || empty( $value ) ) {
3638 return $detail;
3639 }
3640
3641 $acting_flg = $this->get_order_acting_flg( $order_id );
3642 if ( in_array( $acting_flg, $this->pay_method ) ) {
3643 $class = '';
3644 $status_name = '';
3645 $trading_id = $this->get_trading_id( $order_id );
3646 $payment_status = $this->get_payment_status( $order_id, $trading_id );
3647 if ( ! empty( $payment_status ) ) {
3648 switch ( $acting_flg ) {
3649 case 'acting_paygent_card':
3650 $class = ' card-' . $this->get_status( $payment_status );
3651 $status_name = $this->get_status_name( $payment_status );
3652 break;
3653 case 'acting_paygent_conv':
3654 $class = ' conv-' . $this->get_status( $payment_status );
3655 $status_name = $this->get_status_name( $payment_status );
3656 break;
3657 case 'acting_paygent_atm':
3658 $class = ' atm-' . $this->get_status( $payment_status );
3659 $status_name = $this->get_status_name( $payment_status );
3660 break;
3661 case 'acting_paygent_bank':
3662 $class = ' bank-' . $this->get_status( $payment_status );
3663 $status_name = $this->get_status_name( $payment_status );
3664 break;
3665 case 'acting_paygent_paidy':
3666 $class = ' paidy-' . $this->get_status( $payment_status );
3667 $status_name = $this->get_status_name( $payment_status );
3668 break;
3669 }
3670 }
3671 if ( ! empty( $class ) && ! empty( $status_name ) ) {
3672 $detail = '<td>' . esc_html( $value ) . '<span class="acting-status' . esc_html( $class ) . '">' . esc_html( $status_name ) . '</span></td>';
3673 }
3674 }
3675 return $detail;
3676 }
3677
3678 /**
3679 * 受注編集画面【ステータス】
3680 * usces_action_order_edit_form_status_block_middle
3681 *
3682 * @param array $data Order data.
3683 * @param array $cscs_meta Custom field data.
3684 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3685 */
3686 public function settlement_status( $data, $cscs_meta, $action_args ) {
3687 global $usces;
3688 extract( $action_args );
3689
3690 if ( 'new' != $order_action && ! empty( $order_id ) ) {
3691 $payment = usces_get_payments_by_name( $data['order_payment_name'] );
3692 $acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
3693 if ( in_array( $acting_flg, $this->pay_method ) ) {
3694 $trading_id = $this->get_trading_id( $order_id );
3695 $payment_status = $this->get_payment_status( $order_id, $trading_id );
3696 if ( ! empty( $payment_status ) ) {
3697 $class = '';
3698 $status_name = '';
3699 switch ( $acting_flg ) {
3700 case 'acting_paygent_card':
3701 $class = ' card-' . $this->get_status( $payment_status );
3702 $status_name = $this->get_status_name( $payment_status );
3703 break;
3704 case 'acting_paygent_conv':
3705 $class = ' conv-' . $this->get_status( $payment_status );
3706 $status_name = $this->get_status_name( $payment_status );
3707 break;
3708 case 'acting_paygent_atm':
3709 $class = ' atm-' . $this->get_status( $payment_status );
3710 $status_name = $this->get_status_name( $payment_status );
3711 break;
3712 case 'acting_paygent_bank':
3713 $class = ' bank-' . $this->get_status( $payment_status );
3714 $status_name = $this->get_status_name( $payment_status );
3715 break;
3716 case 'acting_paygent_paidy':
3717 $class = ' paidy-' . $this->get_status( $payment_status );
3718 $status_name = $this->get_status_name( $payment_status );
3719 break;
3720 }
3721 if ( ! empty( $status_name ) ) {
3722 echo '
3723 <tr>
3724 <td class="label status">' . esc_html__( 'Settlement status', 'usces' ) . '</td>
3725 <td class="col1 status"><span id="settlement-status"><span class="acting-status' . esc_attr( $class ) . '">' . esc_html( $status_name ) . '</span></span></td>
3726 </tr>';
3727 }
3728 }
3729 }
3730 }
3731 }
3732
3733 /**
3734 * 受注編集画面【支払�
3735 報】
3736 * usces_action_order_edit_form_settle_info
3737 *
3738 * @param array $data Order data.
3739 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3740 */
3741 public function settlement_information( $data, $action_args ) {
3742 global $usces;
3743 extract( $action_args );
3744
3745 if ( 'new' != $order_action && ! empty( $order_id ) ) {
3746 $payment = usces_get_payments_by_name( $data['order_payment_name'] );
3747 if ( isset( $payment['settlement'] ) && in_array( $payment['settlement'], $this->pay_method ) ) {
3748 $acting_data = usces_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
3749 $trading_id = ( isset( $acting_data['trading_id'] ) ) ? $acting_data['trading_id'] : '9999999999';
3750 if ( ! empty( $trading_id ) ) {
3751 echo '<input type="button" class="button settlement-information" id="settlement-information-' . esc_html( $trading_id ) . '" data-trading_id="' . esc_attr( $trading_id ) . '" data-num="1" value="' . esc_attr__( 'Settlement info', 'usces' ) . '">';
3752 }
3753 }
3754 }
3755 }
3756
3757 /**
3758 * 決済�
3759 報ダイアログ
3760 * usces_action_endof_order_edit_form
3761 *
3762 * @param array $data Order data.
3763 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3764 */
3765 public function settlement_dialog( $data, $action_args ) {
3766 global $usces;
3767 extract( $action_args );
3768
3769 if ( 'new' != $order_action && ! empty( $order_id ) ) :
3770 $payment = usces_get_payments_by_name( $data['order_payment_name'] );
3771 if ( isset( $payment['settlement'] ) && in_array( $payment['settlement'], $this->pay_method ) ) :
3772 ?>
3773 <div id="settlement_dialog" title="">
3774 <div id="settlement-response-loading"></div>
3775 <fieldset>
3776 <div id="settlement-response"></div>
3777 <input type="hidden" id="order_num">
3778 <input type="hidden" id="trading_id">
3779 <input type="hidden" id="acting" value="<?php echo esc_attr( $payment['settlement'] ); ?>">
3780 <input type="hidden" id="error">
3781 </fieldset>
3782 </div>
3783 <?php
3784 endif;
3785 endif;
3786 }
3787
3788 /**
3789 * 受注データから取得する決済�
3790 報のキー
3791 * usces_filter_settle_info_field_meta_keys
3792 *
3793 * @param array $keys Settlement information key.
3794 * @return array
3795 */
3796 public function settlement_info_field_meta_keys( $keys ) {
3797 $keys = array_merge( $keys, array( 'payment_type', 'trading_id', 'split_count' ) );
3798 return $keys;
3799 }
3800
3801 /**
3802 * 受注編集画面に表示する決済�
3803 報のキー
3804 * usces_filter_settle_info_field_keys
3805 *
3806 * @param array $keys Settlement information keys.
3807 * @param array $fields Settlement information fields.
3808 * @return array
3809 */
3810 public function settlement_info_field_keys( $keys, $fields ) {
3811 if ( isset( $fields['payment_type'] ) ) {
3812 switch ( $fields['payment_type'] ) {
3813 case PAYMENT_TYPE_CREDIT:
3814 $keys = array( 'trading_id', 'payment_type', 'split_count' );
3815 break;
3816 case PAYMENT_TYPE_CONVENI_NUM:
3817 case PAYMENT_TYPE_ATM:
3818 case PAYMENT_TYPE_BANK:
3819 $keys = array( 'trading_id', 'payment_type', 'payment_date', 'payment_limit_date' );
3820 break;
3821 case PAYMENT_TYPE_PAIDY:
3822 $keys = array( 'trading_id', 'payment_type' );
3823 break;
3824 }
3825 }
3826 return $keys;
3827 }
3828
3829 /**
3830 * 受注編集画面に表示する決済�
3831 報の値整形
3832 * usces_filter_settle_info_field_value
3833 *
3834 * @param string $value Settlement information value.
3835 * @param string $key Settlement information key.
3836 * @param string $acting Acting type.
3837 * @return string
3838 */
3839 public function settlement_info_field_value( $value, $key, $acting ) {
3840 switch ( $key ) {
3841 case 'payment_type':
3842 switch ( $value ) {
3843 case PAYMENT_TYPE_CREDIT:
3844 $value = $this->acting_name . ' カード決済';
3845 break;
3846 case PAYMENT_TYPE_CONVENI_NUM:
3847 $value = $this->acting_name . ' コンビニ決済';
3848 break;
3849 case PAYMENT_TYPE_ATM:
3850 $value = $this->acting_name . ' ATM決済';
3851 break;
3852 case PAYMENT_TYPE_BANK:
3853 $value = $this->acting_name . ' 銀行ネット決済';
3854 break;
3855 case PAYMENT_TYPE_PAIDY:
3856 $value = $this->acting_name . ' Paidy';
3857 break;
3858 }
3859 break;
3860
3861 case 'split_count':
3862 switch ( $value ) {
3863 case '01':
3864 $value = __( 'One time payment', 'usces' );
3865 break;
3866 case '02':
3867 case '03':
3868 case '05':
3869 case '06':
3870 case '10':
3871 case '12':
3872 case '15':
3873 case '18':
3874 case '20':
3875 case '24':
3876 $times = (int) $value;
3877 $value = $times . __( '-time payment', 'usces' );
3878 break;
3879 case '23':
3880 $value = __( 'Bonus lump-sum payment', 'usces' );
3881 break;
3882 case '80':
3883 $value = __( 'Libor Funding pay', 'usces' );
3884 break;
3885 }
3886 }
3887 return $value;
3888 }
3889
3890 /**
3891 * 管理画面送信メール
3892 * usces_filter_order_confirm_mail_payment
3893 *
3894 * @param string $msg_payment Payment information message.
3895 * @param int $order_id Order number.
3896 * @param array $payment Payment data.
3897 * @param array $cart Cart data.
3898 * @param array $order_data Order data.
3899 * @return string
3900 */
3901 public function order_confirm_mail_payment( $msg_payment, $order_id, $payment, $cart, $order_data ) {
3902 global $usces;
3903
3904 switch ( $payment['settlement'] ) {
3905 case 'acting_paygent_card':
3906 $acting_opts = $this->get_acting_settings();
3907 if ( 0 !== (int) $acting_opts['payment_class'] ) {
3908 $trading_id = $this->get_trading_id( $order_id );
3909 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3910 if ( isset( $latest_log['log']['split_count'] ) && isset( $latest_log['log']['payment_class'] ) ) {
3911 switch ( $latest_log['log']['payment_class'] ) {
3912 case '10':
3913 $split_count = __( '(', 'usces' ) . __( 'One time payment', 'usces' ) . __( ')', 'usces' );
3914 break;
3915 case '23':
3916 $split_count = __( '(', 'usces' ) . __( 'Bonus lump-sum payment', 'usces' ) . __( ')', 'usces' );
3917 break;
3918 case '80':
3919 $split_count = __( '(', 'usces' ) . __( 'Libor Funding pay', 'usces' ) . __( ')', 'usces' );
3920 break;
3921 default:
3922 $times = (int) $latest_log['log']['split_count'];
3923 if ( 0 < $times ) {
3924 $split_count = __( '(', 'usces' ) . $times . __( '-time payment', 'usces' ) . __( ')', 'usces' );
3925 }
3926 }
3927 if ( ! empty( $split_count ) ) {
3928 if ( usces_is_html_mail() ) {
3929 $msg_payment = '<tr><td colspan="2" style="padding: 0 0 25px 0;">';
3930 $msg_payment .= $payment['name'] . $split_count;
3931 $msg_payment .= '</td></tr>';
3932 } else {
3933 $msg_payment = __( '** Payment method **', 'usces' ) . "\r\n";
3934 $msg_payment .= usces_mail_line( 1, $order_data['order_email'] );
3935 $msg_payment .= $payment['name'] . $split_count;
3936 $msg_payment .= "\r\n\r\n";
3937 }
3938 }
3939 }
3940 }
3941 break;
3942 case 'acting_paygent_conv':
3943 $mode = ( isset( $_POST['mode'] ) ) ? wp_unslash( $_POST['mode'] ) : '';
3944 if ( 'orderConfirmMail' == $mode || 'changeConfirmMail' == $mode ) {
3945 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_paygent_conv', $order_id ) );
3946 $usable_cvs_company_id = ( isset( $acting_data['usable_cvs_company_id'] ) ) ? $acting_data['usable_cvs_company_id'] : '';
3947 $receipt_number = ( isset( $acting_data['receipt_number'] ) ) ? $acting_data['receipt_number'] : '';
3948 if ( usces_is_html_mail() ) {
3949 $msg_payment = '<tr><td colspan="2" style="padding: 0 0 25px 0;">';
3950 $msg_payment .= $payment['name'] . '<br><br>';
3951 $lb = '<br>';
3952 } else {
3953 $lb = "\r\n";
3954 }
3955 if ( ! empty( $receipt_number ) ) {
3956 if ( false !== strpos( $usable_cvs_company_id, CODE_SEICOMART ) ) {
3957 $msg_payment .= $this->cvs_company_a[ CODE_SEICOMART ] . 'でのお支払い' . $lb;
3958 $msg_payment .= '受付番号:' . $receipt_number . $lb;
3959 }
3960 if ( false !== strpos( $usable_cvs_company_id, CODE_SEVENELEVEN ) ) {
3961 $msg_payment .= $this->cvs_company_a[ CODE_SEVENELEVEN ] . 'でのお支払い' . $lb;
3962 $msg_payment .= '払込票番号:' . $receipt_number . $lb;
3963 }
3964 if ( false !== strpos( $usable_cvs_company_id, CODE_LOWSON ) ) {
3965 $msg_payment .= $this->cvs_company_a[ CODE_LOWSON ] . 'でのお支払い' . $lb;
3966 $msg_payment .= 'お客様番号:' . $receipt_number . $lb;
3967 $msg_payment .= '確認番号:' . CONVENI_CONFIRMATION_NUMBER . $lb;
3968 }
3969 if ( false !== strpos( $usable_cvs_company_id, CODE_MINISTOP ) ) {
3970 $msg_payment .= $this->cvs_company_a[ CODE_MINISTOP ] . 'でのお支払い' . $lb;
3971 $msg_payment .= 'お客様番号:' . $receipt_number . $lb;
3972 $msg_payment .= '確認番号:' . CONVENI_CONFIRMATION_NUMBER . $lb;
3973 }
3974 if ( false !== strpos( $usable_cvs_company_id, CODE_FAMILYMART ) ) {
3975 $msg_payment .= $this->cvs_company_a[ CODE_FAMILYMART ] . 'でのお支払い' . $lb;
3976 $msg_payment .= '収納番号:' . $receipt_number . $lb;
3977 }
3978 if ( false !== strpos( $usable_cvs_company_id, CODE_YAMAZAKI ) ) {
3979 $msg_payment .= $this->cvs_company_a[ CODE_YAMAZAKI ] . 'でのお支払い' . $lb;
3980 $msg_payment .= '決済番号:' . $receipt_number . $lb;
3981 }
3982 }
3983 if ( ! empty( $acting_data['receipt_print_url'] ) ) {
3984 $receipt_print_url = ( usces_is_html_mail() ) ? '<a href="' . esc_url( $acting_data['receipt_print_url'] ) . '">' . esc_url( $acting_data['receipt_print_url'] ) . '<a>' : $acting_data['receipt_print_url'];
3985 if ( false !== strpos( $usable_cvs_company_id, CODE_SEICOMART ) || false !== strpos( $usable_cvs_company_id, CODE_SEVENELEVEN ) ) {
3986 $msg_payment .= '払込票URL:' . $receipt_print_url . $lb;
3987 } else {
3988 $msg_payment .= '支払参�
3989 �URL:' . $receipt_print_url . $lb;
3990 }
3991 }
3992 if ( ! empty( $acting_data['payment_limit_date'] ) ) {
3993 $msg_payment .= 'お支払い期限日:' . date( __( 'Y/m/d' ), strtotime( $acting_data['payment_limit_date'] ) ) . $lb;
3994 }
3995 if ( usces_is_html_mail() ) {
3996 $msg_payment .= '</td></tr>';
3997 }
3998 }
3999 break;
4000 case 'acting_paygent_atm':
4001 $mode = ( isset( $_POST['mode'] ) ) ? wp_unslash( $_POST['mode'] ) : '';
4002 if ( 'orderConfirmMail' == $mode || 'changeConfirmMail' == $mode ) {
4003 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_paygent_atm', $order_id ) );
4004 $lb = ( usces_is_html_mail() ) ? '<br>' : "\r\n";
4005 if ( isset( $acting_data['pay_center_number'] ) ) {
4006 $msg_payment .= '収納機関番号:' . $acting_data['pay_center_number'] . $lb;
4007 }
4008 if ( isset( $acting_data['customer_number'] ) ) {
4009 $msg_payment .= 'お客様番号:' . $acting_data['customer_number'] . $lb;
4010 }
4011 if ( isset( $acting_data['conf_number'] ) ) {
4012 $msg_payment .= '確認番号:' . $acting_data['conf_number'] . $lb;
4013 }
4014 if ( isset( $acting_data['payment_limit_date'] ) ) {
4015 $msg_payment .= 'お支払い期限日:' . date( __( 'Y/m/d' ), strtotime( $acting_data['payment_limit_date'] ) ) . $lb;
4016 }
4017 }
4018 break;
4019 case 'acting_paygent_bank':
4020 break;
4021 case 'acting_paygent_paidy':
4022 break;
4023 }
4024 return $msg_payment;
4025 }
4026
4027 /**
4028 * 決済リンクキー
4029 * usces_filter_get_link_key
4030 *
4031 * @param string $linkkey Settlement link key.
4032 * @param array $results Response data.
4033 * @return string
4034 */
4035 public function get_link_key( $linkkey, $results ) {
4036 if ( isset( $results['trading_id'] ) ) {
4037 $linkkey = $results['trading_id'];
4038 }
4039 return $linkkey;
4040 }
4041
4042 /**
4043 * 受注データ復旧処理
4044 * usces_action_revival_order_data
4045 *
4046 * @param int $order_id Order number.
4047 * @param string $log_key Link key.
4048 * @param string $acting_flg Payment type.
4049 */
4050 public function revival_orderdata( $order_id, $log_key, $acting_flg ) {
4051 global $usces;
4052
4053 switch ( $acting_flg ) {
4054 case 'acting_paygent_card':
4055 $data = array(
4056 'trading_id' => $log_key,
4057 'payment_type' => PAYMENT_TYPE_CREDIT,
4058 );
4059 $usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
4060 $usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
4061 break;
4062 case 'acting_paygent_conv':
4063 $data = array(
4064 'trading_id' => $log_key,
4065 'payment_type' => PAYMENT_TYPE_CONVENI_NUM,
4066 );
4067 $usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
4068 $usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
4069 break;
4070 case 'acting_paygent_atm':
4071 $data = array(
4072 'trading_id' => $log_key,
4073 'payment_type' => PAYMENT_TYPE_ATM,
4074 );
4075 $usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
4076 $usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
4077 break;
4078 case 'acting_paygent_bank':
4079 $data = array(
4080 'trading_id' => $log_key,
4081 'payment_type' => PAYMENT_TYPE_BANK,
4082 );
4083 $usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
4084 $usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
4085 break;
4086 case 'acting_paygent_paidy':
4087 $data = array(
4088 'trading_id' => $log_key,
4089 'payment_type' => PAYMENT_TYPE_PAIDY,
4090 );
4091 $usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
4092 $usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
4093 break;
4094 }
4095 }
4096
4097 /**
4098 * 支払方法説明
4099 * usces_filter_payment_detail
4100 *
4101 * @param string $str Payment method description.
4102 * @param array $entry Entry data.
4103 * @return string
4104 */
4105 public function payment_detail( $str, $entry ) {
4106 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
4107 if ( isset( $payment['settlement'] ) && 'acting_paygent_card' == $payment['settlement'] ) {
4108 $acting_opts = $this->get_acting_settings();
4109 if ( 0 !== (int) $acting_opts['payment_class'] ) {
4110 $split_count = ( isset( $_POST['split_count'] ) ) ? wp_unslash( $_POST['split_count'] ) : '01';
4111 switch ( $split_count ) {
4112 case '01':
4113 $str = __( '(', 'usces' ) . __( 'One time payment', 'usces' ) . __( ')', 'usces' );
4114 break;
4115 case '02':
4116 case '03':
4117 case '05':
4118 case '06':
4119 case '10':
4120 case '12':
4121 case '15':
4122 case '18':
4123 case '20':
4124 case '24':
4125 $times = (int) $split_count;
4126 $str = __( '(', 'usces' ) . $times . __( '-time payment', 'usces' ) . __( ')', 'usces' );
4127 break;
4128 case '23':
4129 $str = __( '(', 'usces' ) . __( 'Bonus lump-sum payment', 'usces' ) . __( ')', 'usces' );
4130 break;
4131 case '80':
4132 $str = __( '(', 'usces' ) . __( 'Libor Funding pay', 'usces' ) . __( ')', 'usces' );
4133 break;
4134 default:
4135 $str = __( '(', 'usces' ) . __( 'One time payment', 'usces' ) . __( ')', 'usces' );
4136 }
4137 }
4138 } elseif ( isset( $payment['settlement'] ) && 'acting_paygent_conv' == $payment['settlement'] ) {
4139 $acting_opts = $this->get_acting_settings();
4140 $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['payment_term_day'] ) . __( ')', 'usces' );
4141 $str = apply_filters( 'usces_filter_paygent_payment_limit_conv', $payment_detail, $acting_opts['payment_term_day'] );
4142 } elseif ( isset( $payment['settlement'] ) && 'acting_paygent_atm' == $payment['settlement'] ) {
4143 $acting_opts = $this->get_acting_settings();
4144 $payment_limit_date = ( WCUtils::is_blank( $acting_opts['payment_limit_date'] ) ) ? 30 : (int) $acting_opts['payment_limit_date'];
4145 if ( 0 < $payment_limit_date ) {
4146 $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $payment_limit_date ) . __( ')', 'usces' );
4147 } else {
4148 $payment_detail = __( '(', 'usces' ) . '本日中にお支払いを完了してください。' . __( ')', 'usces' );
4149 }
4150 $str = apply_filters( 'usces_filter_paygent_payment_limit_atm', $payment_detail, $acting_opts['payment_limit_date'] );
4151 } elseif ( isset( $payment['settlement'] ) && 'acting_paygent_bank' == $payment['settlement'] ) {
4152 $acting_opts = $this->get_acting_settings();
4153 $asp_payment_term = $this->asp_payment_term[ $acting_opts['asp_payment_term'] ];
4154 $payment_detail = __( '(', 'usces' ) . sprintf( '%sにお支払いを完了してください。', $asp_payment_term ) . __( ')', 'usces' );
4155 $str = apply_filters( 'usces_filter_paygent_payment_limit_bank', $payment_detail, $acting_opts['asp_payment_term'] );
4156 }
4157 return $str;
4158 }
4159
4160 /**
4161 * 支払方法 JavaScript 用決済名追加
4162 * usces_filter_payments_str
4163 *
4164 * @param string $payments_str Payments.
4165 * @param array $payment Selected payment.
4166 * @return string
4167 */
4168 public function payments_str( $payments_str, $payment ) {
4169 switch ( $payment['settlement'] ) {
4170 case 'acting_paygent_card':
4171 if ( $this->is_activate_card( 'module' ) ) {
4172 $payments_str .= "'" . $payment['name'] . "': 'paygent_card_form', ";
4173 }
4174 break;
4175 case 'acting_paygent_conv':
4176 if ( $this->is_activate_conv( 'module' ) ) {
4177 $payments_str .= "'" . $payment['name'] . "': 'paygent_conv_form', ";
4178 }
4179 break;
4180 case 'acting_paygent_atm':
4181 if ( $this->is_activate_atm() ) {
4182 $payments_str .= "'" . $payment['name'] . "': 'paygent_atm_form', ";
4183 }
4184 break;
4185 case 'acting_paygent_bank':
4186 if ( $this->is_activate_bank() ) {
4187 $payments_str .= "'" . $payment['name'] . "': 'paygent_bank_form', ";
4188 }
4189 break;
4190 }
4191 return $payments_str;
4192 }
4193
4194 /**
4195 * 支払方法 JavaScript 用決済追加
4196 * usces_filter_payments_arr
4197 *
4198 * @param array $payments_arr Payments.
4199 * @param array $payment Selected payment.
4200 * @return array
4201 */
4202 public function payments_arr( $payments_arr, $payment ) {
4203 switch ( $payment['settlement'] ) {
4204 case 'acting_paygent_card':
4205 if ( $this->is_activate_card( 'module' ) ) {
4206 $payments_arr[] = 'paygent_card_form';
4207 }
4208 break;
4209 case 'acting_paygent_conv':
4210 if ( $this->is_activate_conv( 'module' ) ) {
4211 $payments_arr[] = 'paygent_conv_form';
4212 }
4213 break;
4214 case 'acting_paygent_atm':
4215 if ( $this->is_activate_atm() ) {
4216 $payments_arr[] = 'paygent_atm_form';
4217 }
4218 break;
4219 case 'acting_paygent_bank':
4220 if ( $this->is_activate_bank() ) {
4221 $payments_arr[] = 'paygent_bank_form';
4222 }
4223 break;
4224 }
4225 return $payments_arr;
4226 }
4227
4228 /**
4229 * �
4230 容確認ページ [注文する] ボタン
4231 * usces_filter_confirm_inform
4232 *
4233 * @param string $form Purchase post form.
4234 * @param array $payments Payment data.
4235 * @param string $acting_flg Payment type.
4236 * @param string $rand Welcart transaction key.
4237 * @param string $purchase_disabled Disable purchase button.
4238 * @return string
4239 */
4240 public function confirm_inform( $form, $payments, $acting_flg, $rand, $purchase_disabled ) {
4241 global $usces;
4242
4243 if ( ! in_array( $acting_flg, $this->pay_method ) ) {
4244 return $form;
4245 }
4246
4247 $entry = $usces->cart->get_entry();
4248 $cart = $usces->cart->get_cart();
4249 if ( ! $entry || ! $cart ) {
4250 return $form;
4251 }
4252 if ( ! $entry['order']['total_full_price'] ) {
4253 return $form;
4254 }
4255
4256 $acting_opts = $this->get_acting_settings();
4257
4258 switch ( $acting_flg ) {
4259 /* カード決済 */
4260 case 'acting_paygent_card':
4261 usces_save_order_acting_data( $rand );
4262 if ( 'module' == $acting_opts['card_activate'] ) {
4263 $token = ( isset( $_POST['token'] ) ) ? wp_unslash( $_POST['token'] ) : '';
4264 $masked_card_number = ( isset( $_POST['masked_card_number'] ) ) ? wp_unslash( $_POST['masked_card_number'] ) : '';
4265 $valid_until = ( isset( $_POST['valid_until'] ) ) ? wp_unslash( $_POST['valid_until'] ) : '';
4266 $fingerprint = ( isset( $_POST['fingerprint'] ) ) ? wp_unslash( $_POST['fingerprint'] ) : '';
4267 $hc = ( isset( $_POST['hc'] ) ) ? wp_unslash( $_POST['hc'] ) : '';
4268 $stock_card = ( isset( $_POST['stock_card'] ) ) ? wp_unslash( $_POST['stock_card'] ) : '';
4269 $stock_card_mode = ( isset( $_POST['stock_card_mode'] ) ) ? wp_unslash( $_POST['stock_card_mode'] ) : '';
4270 $split_count = ( isset( $_POST['split_count'] ) ) ? wp_unslash( $_POST['split_count'] ) : '';
4271
4272 $form = '<form id="purchase_form" action="' . esc_url( USCES_CART_URL ) . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4273 <input type="hidden" name="token" value="' . esc_attr( $token ) . '">
4274 <input type="hidden" name="masked_card_number" value="' . esc_attr( $masked_card_number ) . '">
4275 <input type="hidden" name="valid_until" value="' . esc_attr( $valid_until ) . '">
4276 <input type="hidden" name="fingerprint" value="' . esc_attr( $fingerprint ) . '">
4277 <input type="hidden" name="hc" value="' . esc_attr( $hc ) . '">
4278 <input type="hidden" name="trading_id" value="' . esc_attr( $rand ) . '">';
4279 if ( ! empty( $stock_card ) ) {
4280 $form .= '<input type="hidden" name="stock_card" value="' . esc_attr( $stock_card ) . '">';
4281 }
4282 if ( ! empty( $stock_card_mode ) ) {
4283 $form .= '<input type="hidden" name="stock_card_mode" value="' . esc_attr( $stock_card_mode ) . '">';
4284 }
4285 if ( ! empty( $split_count ) ) {
4286 $form .= '<input type="hidden" name="split_count" value="' . esc_attr( $split_count ) . '">';
4287 }
4288 $form .= '<div class="send">
4289 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4290 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4291 <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>
4292 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4293 } else {
4294 $form = '<form id="purchase_form" name="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}">
4295 <input type="hidden" name="trading_id" value="' . $rand . '">
4296 <input type="hidden" name="payment_type" value="' . PAYMENT_TYPE_CREDIT . '">
4297 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">
4298 <div class="send">
4299 <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', '' ) . $purchase_disabled . ' />
4300 </div>
4301 </form>';
4302 $form .= '<form action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13){return false;}">
4303 <div class="send">
4304 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4305 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4306 </div>';
4307 }
4308 break;
4309
4310 /* コンビニ決済 */
4311 case 'acting_paygent_conv':
4312 usces_save_order_acting_data( $rand );
4313 if ( 'module' == $acting_opts['conv_activate'] ) {
4314 $cvs_company_id = ( isset( $_POST['cvs_company_id'] ) ) ? wp_unslash( $_POST['cvs_company_id'] ) : '';
4315 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4316 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4317 $customer_tel = ( isset( $_POST['customer_tel'] ) ) ? wp_unslash( $_POST['customer_tel'] ) : '';
4318
4319 $form = '<form id="purchase_form" action="' . esc_url( USCES_CART_URL ) . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4320 <input type="hidden" name="cvs_company_id" value="' . esc_attr( $cvs_company_id ) . '">
4321 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4322 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4323 <input type="hidden" name="customer_tel" value="' . esc_attr( $customer_tel ) . '">
4324 <input type="hidden" name="trading_id" value="' . esc_attr( $rand ) . '">';
4325 $form .= '<div class="send">
4326 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4327 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4328 <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>
4329 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4330 } else {
4331 $form = '<form id="purchase_form" name="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4332 <input type="hidden" name="trading_id" value="' . $rand . '">
4333 <input type="hidden" name="payment_type" value="' . PAYMENT_TYPE_CONVENI_NUM . '">
4334 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">
4335 <div class="send">
4336 <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', '' ) . $purchase_disabled . ' />
4337 </div>
4338 </form>';
4339 $form .= '<form action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13){return false;}">
4340 <div class="send">
4341 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4342 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4343 </div>';
4344 }
4345 break;
4346
4347 /* ATM決済 */
4348 case 'acting_paygent_atm':
4349 usces_save_order_acting_data( $rand );
4350 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4351 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4352 $customer_family_name_kana = ( isset( $_POST['customer_family_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_family_name_kana'] ) ) : '';
4353 $customer_name_kana = ( isset( $_POST['customer_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_name_kana'] ) ) : '';
4354
4355 $form = '<form id="purchase_form" action="' . esc_url( USCES_CART_URL ) . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4356 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4357 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4358 <input type="hidden" name="customer_family_name_kana" value="' . esc_attr( $customer_family_name_kana ) . '">
4359 <input type="hidden" name="customer_name_kana" value="' . esc_attr( $customer_name_kana ) . '">
4360 <input type="hidden" name="trading_id" value="' . esc_attr( $rand ) . '">';
4361 $form .= '<div class="send">
4362 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4363 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4364 <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>
4365 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4366 break;
4367
4368 /* 銀行ネット決済 */
4369 case 'acting_paygent_bank':
4370 usces_save_order_acting_data( $rand );
4371 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4372 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4373 $customer_family_name_kana = ( isset( $_POST['customer_family_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_family_name_kana'] ) ) : '';
4374 $customer_name_kana = ( isset( $_POST['customer_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_name_kana'] ) ) : '';
4375
4376 $form = '<form id="purchase_form" action="' . esc_url( USCES_CART_URL ) . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4377 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4378 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4379 <input type="hidden" name="customer_family_name_kana" value="' . esc_attr( $customer_family_name_kana ) . '">
4380 <input type="hidden" name="customer_name_kana" value="' . esc_attr( $customer_name_kana ) . '">
4381 <input type="hidden" name="trading_id" value="' . esc_attr( $rand ) . '">';
4382 $form .= '<div class="send">
4383 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4384 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4385 <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>
4386 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4387 break;
4388
4389 /* Paidy */
4390 case 'acting_paygent_paidy':
4391 usces_save_order_acting_data( $rand );
4392 $form = '<form name="purchase_form" action="' . esc_url( USCES_CART_URL ) . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4393 <input type="hidden" name="purchase" value="' . esc_attr( $acting_flg ) . '">
4394 <input type="hidden" name="trading_id" value="' . esc_attr( $rand ) . '">
4395 <input type="hidden" name="paidy_id">
4396 <input type="hidden" name="paidy_created_at">
4397 <input type="hidden" name="paidy_status">
4398 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">
4399 <div class="send paidy-send"><input type="button" id="paidy-checkout-button" onclick="paidyPay()" value="Paidyでお支払い" /></div>
4400 </form>
4401 <form action="' . USCES_CART_URL . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4402 <div class="send">
4403 ' . apply_filters( 'usces_filter_confirm_before_backbutton', '', $payments, $acting_flg, $rand ) . '
4404 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', '' ) . ' />
4405 </div>';
4406 break;
4407 }
4408 return $form;
4409 }
4410
4411 /**
4412 * �
4413 容確認ページ ポイントフォーム
4414 * usces_action_confirm_page_point_inform
4415 */
4416 public function e_point_inform() {
4417 $form = $this->point_inform( '' );
4418 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4419 echo $form;
4420 }
4421
4422 /**
4423 * �
4424 容確認ページ ポイントフォーム
4425 * usces_filter_confirm_point_inform
4426 *
4427 * @param string $form Input point form.
4428 * @return string
4429 */
4430 public function point_inform( $form ) {
4431 global $usces;
4432
4433 $entry = $usces->cart->get_entry();
4434 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
4435 $acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
4436 switch ( $acting_flg ) {
4437 case 'acting_paygent_card':
4438 if ( 'module' == $this->get_service_type( 'card' ) ) {
4439 $token = ( isset( $_POST['token'] ) ) ? wp_unslash( $_POST['token'] ) : '';
4440 $masked_card_number = ( isset( $_POST['masked_card_number'] ) ) ? wp_unslash( $_POST['masked_card_number'] ) : '';
4441 $valid_until = ( isset( $_POST['valid_until'] ) ) ? wp_unslash( $_POST['valid_until'] ) : '';
4442 $fingerprint = ( isset( $_POST['fingerprint'] ) ) ? wp_unslash( $_POST['fingerprint'] ) : '';
4443 $hc = ( isset( $_POST['hc'] ) ) ? wp_unslash( $_POST['hc'] ) : '';
4444 $stock_card = ( isset( $_POST['stock_card'] ) ) ? wp_unslash( $_POST['stock_card'] ) : '';
4445 $stock_card_mode = ( isset( $_POST['stock_card_mode'] ) ) ? wp_unslash( $_POST['stock_card_mode'] ) : '';
4446 $split_count = ( isset( $_POST['split_count'] ) ) ? wp_unslash( $_POST['split_count'] ) : '';
4447
4448 $form .= '
4449 <input type="hidden" name="token" value="' . esc_attr( $token ) . '">
4450 <input type="hidden" name="masked_card_number" value="' . esc_attr( $masked_card_number ) . '">
4451 <input type="hidden" name="valid_until" value="' . esc_attr( $valid_until ) . '">
4452 <input type="hidden" name="fingerprint" value="' . esc_attr( $fingerprint ) . '">
4453 <input type="hidden" name="hc" value="' . esc_attr( $hc ) . '">';
4454 if ( ! empty( $stock_card ) ) {
4455 $form .= '<input type="hidden" name="stock_card" value="' . esc_attr( $stock_card ) . '">';
4456 }
4457 if ( ! empty( $stock_card_mode ) ) {
4458 $form .= '<input type="hidden" name="stock_card_mode" value="' . esc_attr( $stock_card_mode ) . '">';
4459 }
4460 if ( ! empty( $split_count ) ) {
4461 $form .= '<input type="hidden" name="split_count" value="' . esc_attr( $split_count ) . '">';
4462 }
4463 }
4464 break;
4465
4466 case 'acting_paygent_conv':
4467 if ( 'module' == $this->get_service_type( 'conv' ) ) {
4468 $cvs_company_id = ( isset( $_POST['cvs_company_id'] ) ) ? wp_unslash( $_POST['cvs_company_id'] ) : '';
4469 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4470 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4471 $customer_tel = ( isset( $_POST['customer_tel'] ) ) ? wp_unslash( $_POST['customer_tel'] ) : '';
4472
4473 $form .= '
4474 <input type="hidden" name="cvs_company_id" value="' . esc_attr( $cvs_company_id ) . '">
4475 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4476 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4477 <input type="hidden" name="customer_tel" value="' . esc_attr( $customer_tel ) . '">';
4478 }
4479 break;
4480
4481 case 'acting_paygent_atm':
4482 if ( 'module' == $this->get_service_type( 'atm' ) ) {
4483 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4484 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4485 $customer_family_name_kana = ( isset( $_POST['customer_family_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_family_name_kana'] ) ) : '';
4486 $customer_name_kana = ( isset( $_POST['customer_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_name_kana'] ) ) : '';
4487
4488 $form .= '
4489 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4490 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4491 <input type="hidden" name="customer_family_name_kana" value="' . esc_attr( $customer_family_name_kana ) . '">
4492 <input type="hidden" name="customer_name_kana" value="' . esc_attr( $customer_name_kana ) . '">';
4493 }
4494 break;
4495
4496 case 'acting_paygent_bank':
4497 if ( 'module' == $this->get_service_type( 'bank' ) ) {
4498 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4499 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4500 $customer_family_name_kana = ( isset( $_POST['customer_family_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_family_name_kana'] ) ) : '';
4501 $customer_name_kana = ( isset( $_POST['customer_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_name_kana'] ) ) : '';
4502
4503 $form .= '
4504 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4505 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4506 <input type="hidden" name="customer_family_name_kana" value="' . esc_attr( $customer_family_name_kana ) . '">
4507 <input type="hidden" name="customer_name_kana" value="' . esc_attr( $customer_name_kana ) . '">';
4508 }
4509 break;
4510 }
4511 return $form;
4512 }
4513
4514 /**
4515 * セッション復帰処理
4516 * usces_pre_purchase
4517 */
4518 public function pre_purchase() {
4519 $acting_opts = $this->get_acting_settings();
4520 if ( 'on' == $acting_opts['threedsecure_ryaku'] && isset( $_POST['from3ds'] ) && isset( $_POST['trading_id'] ) ) {
4521 usces_restore_order_acting_data( wp_unslash( $_POST['trading_id'] ) );
4522 }
4523 }
4524
4525 /**
4526 * 決済処理
4527 * usces_action_acting_processing
4528 *
4529 * @param string $acting_flg Payment type.
4530 * @param array $post_query Post data.
4531 */
4532 public function acting_processing( $acting_flg, $post_query ) {
4533 global $usces;
4534
4535 if ( ! in_array( $acting_flg, $this->pay_method ) ) {
4536 return;
4537 }
4538
4539 $entry = $usces->cart->get_entry();
4540 $cart = $usces->cart->get_cart();
4541 if ( ! $entry || ! $cart ) {
4542 wp_redirect( USCES_CART_URL );
4543 exit();
4544 }
4545 if ( isset( $_REQUEST['_nonce'] ) && ! wp_verify_nonce( $_REQUEST['_nonce'], $acting_flg ) ) {
4546 wp_redirect( USCES_CART_URL );
4547 exit();
4548 }
4549
4550 $acting_opts = $this->get_acting_settings();
4551 parse_str( $post_query, $post_data );
4552
4553 $acting = substr( $acting_flg, 7 );
4554 $member = $usces->get_member();
4555 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
4556 $service_type = '';
4557 $payment_type = '';
4558
4559 switch ( $acting_flg ) {
4560 case 'acting_paygent_card':
4561 $service_type = $this->get_service_type( 'card' );
4562 $payment_type = PAYMENT_TYPE_CREDIT;
4563 break;
4564 case 'acting_paygent_conv':
4565 $service_type = $this->get_service_type( 'conv' );
4566 $payment_type = PAYMENT_TYPE_CONVENI_NUM;
4567 break;
4568 case 'acting_paygent_atm':
4569 $service_type = $this->get_service_type( 'atm' );
4570 $payment_type = PAYMENT_TYPE_ATM;
4571 break;
4572 case 'acting_paygent_bank':
4573 $service_type = $this->get_service_type( 'bank' );
4574 $payment_type = PAYMENT_TYPE_BANK;
4575 break;
4576 case 'acting_paygent_paidy':
4577 $service_type = $this->get_service_type( 'paidy' );
4578 $payment_type = PAYMENT_TYPE_PAIDY;
4579 break;
4580 }
4581
4582 if ( 'link' == $service_type ) {
4583 $hash_key = $acting_opts['hc'];
4584 $fix_params = '';
4585 $id = $entry['order']['total_full_price'];
4586 $inform_url = USCES_CART_URL;
4587 $seq_merchant_id = $acting_opts['seq_merchant_id'];
4588 $payment_term_day = $acting_opts['payment_term_day'];
4589 $payment_term_min = $acting_opts['payment_term_min'];
4590 $payment_class = $acting_opts['payment_class'];
4591 $use_card_conf_number = ( 'on' == $acting_opts['use_card_conf_number'] ) ? '1' : '0';
4592 if ( 'on' == $acting_opts['stock_card_mode'] && ! empty( $member['ID'] ) ) {
4593 if ( usces_have_regular_order() || usces_have_continue_charge() ) {
4594 $stock_card_mode = '2';
4595 } else {
4596 $stock_card_mode = '1';
4597 }
4598 $customer_id = $member['ID'];
4599 } else {
4600 $stock_card_mode = '';
4601 $customer_id = '';
4602 }
4603 $threedsecure_ryaku = ( 'on' == $acting_opts['threedsecure_ryaku'] ) ? '0' : '1';
4604
4605 $merchant_name = mb_convert_kana( $usces->options['company_name'], 'RNASKV', 'UTF-8' );
4606 $banner_url = '';
4607 $return_url = USCES_CART_URL . $usces->delim . 'acting=' . $acting . '&acting_return=1&trading_id=' . $trading_id;
4608 $stop_return_url = USCES_CART_URL . $usces->delim . 'acting=' . $acting . '&confirm=1';
4609 $customer_family_name = trim( $entry['customer']['name1'] );
4610 $customer_name = trim( $entry['customer']['name2'] );
4611 $customer_family_name_kana = trim( mb_convert_kana( $entry['customer']['name3'], 'rnaskh', 'UTF-8' ) );
4612 $customer_name_kana = trim( mb_convert_kana( $entry['customer']['name4'], 'rnaskh', 'UTF-8' ) );
4613 $customer_tel = str_replace( '-', '', mb_convert_kana( $entry['customer']['tel'], 'a', 'UTF-8' ) );
4614
4615 /* Create hash hex string */
4616 $org_str =
4617 $trading_id .
4618 $payment_type .
4619 $fix_params .
4620 $id .
4621 $inform_url .
4622 $seq_merchant_id .
4623 $payment_term_day .
4624 $payment_term_min .
4625 $payment_class .
4626 $use_card_conf_number .
4627 $customer_id .
4628 $threedsecure_ryaku .
4629 $hash_key;
4630 $hash_str = hash( 'sha256', $org_str );
4631 $appendix = ( 'ja' == usces_get_local_language() ) ? '0' : '1';
4632
4633 $url = $acting_opts['send_url'];
4634 $send_data = array(
4635 'trading_id' => $trading_id,
4636 'payment_type' => $payment_type,
4637 'fix_params' => $fix_params,
4638 'id' => $id,
4639 'inform_url' => $inform_url,
4640 'seq_merchant_id' => $seq_merchant_id,
4641 'merchant_name' => $merchant_name,
4642 'payment_term_day' => $payment_term_day,
4643 'payment_term_min' => $payment_term_min,
4644 'banner_url' => $banner_url,
4645 'return_url' => $return_url,
4646 'stop_return_url' => $stop_return_url,
4647 'customer_family_name' => $customer_family_name,
4648 'customer_name' => $customer_name,
4649 'customer_family_name_kana' => $customer_family_name_kana,
4650 'customer_name_kana' => $customer_name_kana,
4651 'customer_tel' => $customer_tel,
4652 'payment_class' => $payment_class,
4653 'use_card_conf_number' => $use_card_conf_number,
4654 'stock_card_mode' => $stock_card_mode,
4655 'customer_id' => $customer_id,
4656 'threedsecure_ryaku' => $threedsecure_ryaku,
4657 'appendix' => $appendix,
4658 'hc' => $hash_str,
4659
4660 /* btob mode ON */
4661 'isbtob' => '1',
4662
4663 /* お支払い完了画面非表示区分 */
4664 'finish_disable' => '1',
4665 );
4666
4667 $interface = parse_url( $url );
4668 $vars = http_build_query( $send_data );
4669
4670 $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
4671 $header .= 'Host: ' . $interface['host'] . "\r\n";
4672 $header .= "User-Agent: PHP Script\r\n";
4673 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
4674 $header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
4675 $header .= "Connection: close\r\n\r\n";
4676 $header .= $vars;
4677 $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
4678 if ( ! $fp ) {
4679 // usces_log( $acting . ' : TLS(v1.2) Error', 'acting_transaction.log' );
4680 $log = array(
4681 'acting' => $acting,
4682 'key' => $trading_id,
4683 'result' => 'SSL/TLS ERROR (' . $errno . ')',
4684 'data' => array( $errstr ),
4685 );
4686 usces_save_order_acting_error( $log );
4687 wp_redirect(
4688 add_query_arg(
4689 array(
4690 'acting' => $acting,
4691 'acting_return' => 0,
4692 ),
4693 USCES_CART_URL
4694 )
4695 );
4696 exit();
4697 }
4698 if ( $fp ) {
4699 $data = array();
4700 $response = array();
4701 fwrite( $fp, $header );
4702 while ( ! feof( $fp ) ) {
4703 $line = fgets( $fp, 1024 );
4704 if ( false !== strpos( $line, 'result' ) ) {
4705 $item = explode( '=', $line, 2 );
4706 $data['result'] = trim( $item[1] );
4707 }
4708 if ( false !== strpos( $line, 'response_code' ) ) {
4709 $item = explode( '=', $line, 2 );
4710 $data['response_code'] = trim( $item[1] );
4711 }
4712 if ( false !== strpos( $line, 'response_detail' ) ) {
4713 $item = explode( '=', $line, 2 );
4714 $data['response_detail'] = trim( $item[1] );
4715 }
4716 if ( false !== strpos( $line, 'url' ) ) {
4717 $item = explode( '=', $line, 2 );
4718 $data['url'] = trim( $item[1] );
4719 }
4720 if ( false !== strpos( $line, 'trading_id' ) ) {
4721 $item = explode( '=', $line, 2 );
4722 $data['trading_id'] = trim( $item[1] );
4723 }
4724 if ( false !== strpos( $line, 'payment_type' ) ) {
4725 $item = explode( '=', $line, 2 );
4726 $data['payment_type'] = trim( $item[1] );
4727 }
4728 if ( false !== strpos( $line, 'limit_date' ) ) {
4729 $item = explode( '=', $line, 2 );
4730 $data['limit_date'] = trim( $item[1] );
4731 }
4732 if ( false !== strpos( $line, 'trade_generation_date' ) ) {
4733 $item = explode( '=', $line, 2 );
4734 $data['trade_generation_date'] = trim( $item[1] );
4735 }
4736 $response[] = $line;
4737 }
4738 fclose( $fp );
4739
4740 if ( 0 == $data['result'] && ! empty( $data['url'] ) ) {
4741 wp_redirect( $data['url'] );
4742 exit();
4743 } else {
4744 $log = array(
4745 'acting' => $acting,
4746 'key' => $trading_id,
4747 'result' => 'RESPONSE ERROR',
4748 'data' => $response,
4749 );
4750 usces_save_order_acting_error( $log );
4751 wp_redirect(
4752 add_query_arg(
4753 array(
4754 'acting' => $acting,
4755 'acting_return' => 0,
4756 ),
4757 USCES_CART_URL
4758 )
4759 );
4760 }
4761 exit();
4762 }
4763 } elseif ( 'module' == $service_type ) {
4764 $pm = Paygent_Module::get_instance();
4765 switch ( $payment_type ) {
4766 /* カード決済 */
4767 case PAYMENT_TYPE_CREDIT:
4768 $telegram_kind = PAYGENT_CREDIT;
4769 $token = $post_data['token'];
4770 $stock_card_mode = 0;
4771 $customer_card_id = '';
4772
4773 if ( 'on' == $acting_opts['threedsecure_ryaku'] ) {
4774 /* 3Dセキュア認証の結果を受ける */
4775 if ( isset( $post_data['from3ds'] ) ) {
4776 if ( 'on' == $acting_opts['attempt'] && ! empty( $post_data['attempt_kbn'] ) ) {
4777 $log = array(
4778 'acting' => 'paygent_card(3ds_attempt)',
4779 'key' => $trading_id,
4780 'result' => '3DS ATTEMPT',
4781 'data' => $post_data,
4782 );
4783 usces_save_order_acting_error( $log );
4784 wp_redirect(
4785 add_query_arg(
4786 array(
4787 'acting' => 'paygent_card',
4788 'acting_return' => 0,
4789 'retry' => 1,
4790 ),
4791 USCES_CART_URL
4792 )
4793 );
4794 exit();
4795 }
4796 } else {
4797 /* 3Dセキュア認証画面へリダイレクト */
4798 $this->certification_3ds( $post_data, $member['ID'] );
4799 }
4800 }
4801
4802 if ( 'on' == $acting_opts['stock_card_mode'] && ! empty( $member['ID'] ) ) {
4803 if ( isset( $post_data['stock_card'] ) ) {
4804 if ( 'stock' == $post_data['stock_card'] ) {
4805 $stock_card_mode = 1;
4806 $customer_card_id = $usces->get_member_meta_value( 'paygent_customer_card_id', $member['ID'] );
4807 } else {
4808 if ( isset( $post_data['stock_card_mode'] ) && 'change' == $post_data['stock_card_mode'] ) {
4809 $stock_card_mode = 1;
4810
4811 /* カード変更 */
4812 $customer = $this->customer_card_upd( $member['ID'], $token );
4813 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
4814 $log = array(
4815 'acting' => $acting,
4816 'key' => $trading_id,
4817 'result' => $customer['response_code'],
4818 'data' => $customer,
4819 );
4820 usces_save_order_acting_error( $log );
4821 wp_redirect(
4822 add_query_arg(
4823 array(
4824 'acting' => $acting,
4825 'acting_return' => 0,
4826 'retry' => 1,
4827 ),
4828 USCES_CART_URL
4829 )
4830 );
4831 exit();
4832 }
4833 if ( isset( $customer['customer_card_id'] ) ) {
4834 $customer_card_id = $customer['customer_card_id'];
4835 $token = '';
4836 }
4837 }
4838 }
4839 } else {
4840 if ( isset( $post_data['stock_card_mode'] ) && 'save' == $post_data['stock_card_mode'] ) {
4841 $stock_card_mode = 1;
4842
4843 /* カード登録 */
4844 $customer = $this->customer_card_add( $member['ID'], $token );
4845 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
4846 $log = array(
4847 'acting' => $acting,
4848 'key' => $trading_id,
4849 'result' => $customer['response_code'],
4850 'data' => $customer,
4851 );
4852 usces_save_order_acting_error( $log );
4853 wp_redirect(
4854 add_query_arg(
4855 array(
4856 'acting' => $acting,
4857 'acting_return' => 0,
4858 'retry' => 1,
4859 ),
4860 USCES_CART_URL
4861 )
4862 );
4863 exit();
4864 }
4865 if ( isset( $customer['customer_card_id'] ) ) {
4866 $customer_card_id = $customer['customer_card_id'];
4867 $token = '';
4868 }
4869 }
4870 }
4871 }
4872
4873 $pm->init();
4874 $pm->req_put( 'trading_id', $trading_id );
4875 $pm->req_put( 'payment_amount', $entry['order']['total_full_price'] );
4876 if ( 0 === (int) $acting_opts['payment_class'] || '01' == $post_data['split_count'] ) {
4877 $pm->req_put( 'payment_class', '10' );
4878 } elseif ( '23' == $post_data['split_count'] || '80' == $post_data['split_count'] ) {
4879 $pm->req_put( 'payment_class', $post_data['split_count'] );
4880 } else {
4881 $pm->req_put( 'payment_class', '61' );
4882 $pm->req_put( 'split_count', $post_data['split_count'] );
4883 }
4884 if ( 'on' == $acting_opts['threedsecure_ryaku'] && isset( $post_data['3ds_auth_id'] ) ) {
4885 $pm->req_put( '3dsecure_use_type', '2' );
4886 $pm->req_put( 'http_accept', $_SERVER['HTTP_ACCEPT'] );
4887 $pm->req_put( 'http_user_agent', $_SERVER['HTTP_USER_AGENT'] );
4888 $pm->req_put( 'term_url', USCES_CART_URL );
4889 $pm->req_put( '3ds_auth_id', $post_data['3ds_auth_id'] );
4890 } else {
4891 $pm->req_put( '3dsecure_ryaku', '1' );
4892 }
4893 if ( 1 === (int) $stock_card_mode && ! empty( $customer_card_id ) ) {
4894 $pm->req_put( 'stock_card_mode', '1' );
4895 $pm->req_put( 'customer_id', $member['ID'] );
4896 $pm->req_put( 'customer_card_id', $customer_card_id );
4897 if ( ! empty( $token ) && 'on' == $acting_opts['use_card_conf_number'] ) {
4898 $pm->req_put( 'card_token', $token );
4899 $pm->req_put( 'security_code_token', '1' );
4900 $pm->req_put( 'security_code_use', '1' );
4901 }
4902 } else {
4903 $pm->req_put( 'card_token', $token );
4904 if ( 'on' == $acting_opts['use_card_conf_number'] ) {
4905 $pm->req_put( 'security_code_use', '1' );
4906 }
4907 }
4908 $pm->req_put( 'sales_mode', $acting_opts['sales_mode'] );
4909 break;
4910
4911 /* コンビニ決済 */
4912 case PAYMENT_TYPE_CONVENI_NUM:
4913 $telegram_kind = PAYGENT_CONVENI_NUM;
4914 $customer_family_name = trim( $post_data['customer_family_name'] );
4915 $customer_name = trim( $post_data['customer_name'] );
4916 $customer_tel = str_replace( '-', '', mb_convert_kana( $post_data['customer_tel'], 'a', 'UTF-8' ) );
4917 $pm->init();
4918 $pm->req_put( 'trading_id', $trading_id );
4919 $pm->req_put( 'payment_amount', $entry['order']['total_full_price'] );
4920 $pm->req_put( 'customer_family_name', $customer_family_name );
4921 $pm->req_put( 'customer_name', $customer_name );
4922 $pm->req_put( 'customer_tel', $customer_tel );
4923 $pm->req_put( 'payment_limit_date', $acting_opts['payment_term_day'] );
4924 $pm->req_put( 'cvs_company_id', $post_data['cvs_company_id'] );
4925 $pm->req_put( 'sales_type', $acting_opts['sales_type'] );
4926 break;
4927
4928 /* ATM決済 */
4929 case PAYMENT_TYPE_ATM:
4930 $telegram_kind = PAYGENT_ATM;
4931 $customer_family_name = trim( $post_data['customer_family_name'] );
4932 $customer_name = trim( $post_data['customer_name'] );
4933 $customer_family_name_kana = trim( $post_data['customer_family_name_kana'] );
4934 $customer_name_kana = trim( $post_data['customer_name_kana'] );
4935 $payment_detail = apply_filters( 'usces_filter_paygent_atm_payment_detail', 'お支払い一式' );
4936 $payment_detail_kana = apply_filters( 'usces_filter_paygent_atm_payment_detail_kana', 'オシハライイツシキ' );
4937 $pm->init();
4938 $pm->req_put( 'trading_id', $trading_id );
4939 $pm->req_put( 'payment_amount', $entry['order']['total_full_price'] );
4940 $pm->req_put( 'customer_family_name', $customer_family_name );
4941 $pm->req_put( 'customer_name', $customer_name );
4942 $pm->req_put( 'customer_family_name_kana', $customer_family_name_kana );
4943 $pm->req_put( 'customer_name_kana', $customer_name_kana );
4944 $pm->req_put( 'payment_detail', $payment_detail );
4945 $pm->req_put( 'payment_detail_kana', $payment_detail_kana );
4946 if ( ! WCUtils::is_blank( $acting_opts['payment_limit_date'] ) ) {
4947 $pm->req_put( 'payment_limit_date', (int) $acting_opts['payment_limit_date'] );
4948 }
4949 break;
4950
4951 /* 銀行ネット決済 */
4952 case PAYMENT_TYPE_BANK:
4953 $telegram_kind = PAYGENT_BANK_ASP;
4954 $customer_family_name = trim( $post_data['customer_family_name'] );
4955 $customer_name = trim( $post_data['customer_name'] );
4956 $customer_family_name_kana = trim( $post_data['customer_family_name_kana'] );
4957 $customer_name_kana = trim( $post_data['customer_name_kana'] );
4958 $claim_kanji = apply_filters( 'usces_filter_paygent_bank_claim_kanji', 'お支払い一式' );
4959 $claim_kana = apply_filters( 'usces_filter_paygent_bank_claim_kana', 'オシハライイツシキ' );
4960 $pm->init();
4961 $pm->req_put( 'trading_id', $trading_id );
4962 $pm->req_put( 'amount', $entry['order']['total_full_price'] );
4963 $pm->req_put( 'customer_family_name', $customer_family_name );
4964 $pm->req_put( 'customer_name', $customer_name );
4965 $pm->req_put( 'customer_family_name_kana', $customer_family_name_kana );
4966 $pm->req_put( 'customer_name_kana', $customer_name_kana );
4967 $pm->req_put( 'claim_kanji', $claim_kanji );
4968 $pm->req_put( 'claim_kana', $claim_kana );
4969 $return_arg = array(
4970 'acting' => $acting,
4971 'acting_return' => 1,
4972 );
4973 $pm->req_put( 'return_url', add_query_arg( $return_arg, USCES_CART_URL ) );
4974 // if ( isset( $acting_opts['asp_payment_term'] ) && '' !== $acting_opts['asp_payment_term'] ) {
4975 $pm->req_put( 'asp_payment_term', $acting_opts['asp_payment_term'] );
4976 // }
4977 $stop_return_arg = array(
4978 'acting' => $acting,
4979 'confirm' => 1,
4980 );
4981 $pm->req_put( 'stop_return_url', add_query_arg( $stop_return_arg, USCES_CART_URL ) );
4982 break;
4983
4984 /* Paidy */
4985 case PAYMENT_TYPE_PAIDY:
4986 if ( isset( $post_data['paidy_id'] ) && isset( $post_data['paidy_created_at'] ) && isset( $post_data['paidy_status'] ) && 'authorized' == $post_data['paidy_status'] ) {
4987 $telegram_kind = PAYGENT_PAIDY_REF;
4988 $pm->init();
4989 $pm->req_put( 'paidy_payment_id', $post_data['paidy_id'] );
4990 // $api_retrieve_url = 'https://api.paidy.com/payments/' . $post_data['paidy_id'];
4991 // $params = array(
4992 // 'method' => 'GET',
4993 // 'headers' => array(
4994 // 'Content-Type' => 'application/json;charset=utf-8',
4995 // 'Authorization' => 'Bearer ' . $acting_opts['paidy_secret_key'],
4996 // 'Paidy-Version' => '2018-04-10',
4997 // ),
4998 // );
4999 // $response = wp_remote_get( $api_retrieve_url, $params );
5000 // $response_data = json_decode( wp_remote_retrieve_body( $response ), true );
5001 } else {
5002 $log = array(
5003 'acting' => $acting,
5004 'key' => $trading_id,
5005 'result' => 'PAIDY AUTHORIZE ERROR',
5006 'data' => $post_data,
5007 );
5008 usces_save_order_acting_error( $log );
5009 wp_redirect(
5010 add_query_arg(
5011 array(
5012 'acting' => $acting,
5013 'acting_return' => 0,
5014 'result' => 0,
5015 ),
5016 USCES_CART_URL
5017 )
5018 );
5019 exit();
5020 }
5021 break;
5022 }
5023
5024 if ( ! empty( $payment_type ) && ! empty( $telegram_kind ) ) {
5025 $result_post = $pm->post( $telegram_kind );
5026 $result_status = $pm->get_result_status();
5027 if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
5028 $response_data = array(
5029 'result' => $result_post,
5030 'result_status' => $result_status,
5031 'response_code' => $pm->get_response_code(),
5032 'response_detail' => $pm->get_response_detail(),
5033 'result_message' => $pm->get_result_message(),
5034 );
5035 $response_code = ( true !== $result_post ) ? $result_post : $pm->get_response_code();
5036 $log = array(
5037 'acting' => $acting,
5038 'key' => $trading_id,
5039 'result' => $response_code,
5040 'data' => $response_data,
5041 );
5042 usces_save_order_acting_error( $log );
5043 wp_redirect(
5044 add_query_arg(
5045 array(
5046 'acting' => $acting,
5047 'acting_return' => 0,
5048 'retry' => 1,
5049 ),
5050 USCES_CART_URL
5051 )
5052 );
5053 exit();
5054 }
5055 $response_data = $pm->get_response_data();
5056 if ( ! isset( $response_data['payment_type'] ) ) {
5057 $response_data['payment_type'] = $payment_type;
5058 }
5059 if ( ! isset( $response_data['trading_id'] ) ) {
5060 $response_data['trading_id'] = $trading_id;
5061 }
5062 $res = $usces->order_processing( $response_data );
5063 if ( 'ordercompletion' != $res ) {
5064 $log = array(
5065 'acting' => $acting,
5066 'key' => $trading_id,
5067 'result' => 'ORDER DATA REGISTERED ERROR',
5068 'data' => $response_data,
5069 );
5070 usces_save_order_acting_error( $log );
5071 wp_redirect(
5072 add_query_arg(
5073 array(
5074 'acting' => $acting,
5075 'acting_return' => 0,
5076 'result' => 0,
5077 ),
5078 USCES_CART_URL
5079 )
5080 );
5081 exit();
5082 }
5083 if ( PAYMENT_TYPE_BANK == $payment_type && isset( $response_data['asp_url'] ) ) {
5084 $usces->cart->clear_cart(); /* Order OK. */
5085 wp_redirect( $response_data['asp_url'] );
5086 } else {
5087 wp_redirect(
5088 add_query_arg(
5089 array(
5090 'acting' => $acting,
5091 'acting_return' => 1,
5092 'result' => 1,
5093 ),
5094 USCES_CART_URL
5095 )
5096 );
5097 }
5098 exit();
5099 }
5100 }
5101 }
5102
5103 /**
5104 * 決済完了ページ制御
5105 * usces_filter_check_acting_return_results
5106 *
5107 * @param array $results Result data.
5108 * @return array
5109 */
5110 public function acting_return( $results ) {
5111 $acting = ( isset( $_GET['acting'] ) ) ? wp_unslash( $_GET['acting'] ) : '';
5112 switch ( $acting ) {
5113 case 'paygent_card':
5114 case 'paygent_conv':
5115 case 'paygent_atm':
5116 case 'paygent_bank':
5117 case 'paygent_paidy':
5118 $results = wp_unslash( $_GET );
5119 $results[0] = wp_unslash( $_GET['acting_return'] );
5120 $results['reg_order'] = false;
5121 break;
5122 }
5123 return $results;
5124 }
5125
5126 /**
5127 * 重複オーダー禁止処理
5128 * usces_filter_check_acting_return_duplicate
5129 *
5130 * @param string $trans_id Transaction ID.
5131 * @param array $results Result data.
5132 * @return string
5133 */
5134 public function check_acting_return_duplicate( $trans_id, $results ) {
5135 $acting = ( isset( $_GET['acting'] ) ) ? wp_unslash( $_GET['acting'] ) : '';
5136 switch ( $acting ) {
5137 case 'paygent_card':
5138 case 'paygent_conv':
5139 case 'paygent_atm':
5140 case 'paygent_bank':
5141 case 'paygent_paidy':
5142 break;
5143 }
5144 return $trans_id;
5145 }
5146
5147 /**
5148 * 受注データ登録
5149 * Called by usces_reg_orderdata() and usces_new_orderdata().
5150 * usces_action_reg_orderdata
5151 *
5152 * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $results ).
5153 */
5154 public function register_orderdata( $args ) {
5155 global $usces;
5156 extract( $args );
5157
5158 $acting_flg = ( isset( $payments['settlement'] ) ) ? $payments['settlement'] : '';
5159 if ( ! in_array( $acting_flg, $this->pay_method ) ) {
5160 return;
5161 }
5162 if ( ! $entry['order']['total_full_price'] ) {
5163 return;
5164 }
5165
5166 if ( isset( $_REQUEST['payment_type'] ) ) {
5167 $payment_type = wp_unslash( $_REQUEST['payment_type'] );
5168 } elseif ( isset( $results['payment_type'] ) ) {
5169 $payment_type = $results['payment_type'];
5170 } else {
5171 $payment_type = '';
5172 }
5173 if ( ! empty( $payment_type ) ) {
5174 if ( isset( $results['acting_return'] ) ) {
5175 unset( $results['acting_return'] );
5176 unset( $results['page_id'] );
5177 unset( $results['0'] );
5178 unset( $results['reg_order'] );
5179 }
5180 $trading_id = ( isset( $results['trading_id'] ) ) ? $results['trading_id'] : '';
5181 $usces->set_order_meta_value( $acting_flg, usces_serialize( $results ), $order_id );
5182 $usces->set_order_meta_value( 'trading_id', $trading_id, $order_id );
5183 $usces->set_order_meta_value( 'wc_trans_id', $trading_id, $order_id );
5184
5185 switch ( $payment_type ) {
5186 case PAYMENT_TYPE_ATM:
5187 $payment_id = ( isset( $results['payment_id'] ) ) ? $results['payment_id'] : '';
5188 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
5189 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
5190 $this->save_acting_log( $settlement_ref, 'paygent_atm', 'reference_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
5191 } else {
5192 $this->save_acting_log( $settlement_ref, 'paygent_atm', $settlement_ref['payment_status'], RESULT_STATUS_NORMAL, $order_id, $trading_id );
5193 }
5194 break;
5195 case PAYMENT_TYPE_BANK:
5196 $this->save_acting_log( $results, 'paygent_bank', 'bank_applying', RESULT_STATUS_NORMAL, $order_id, $trading_id );
5197 break;
5198 }
5199 }
5200 }
5201
5202 /**
5203 * 決済エラーメッセージ
5204 * usces_filter_get_error_settlement
5205 *
5206 * @param string $form Payment error message.
5207 * @return string
5208 */
5209 public function error_page_message( $form ) {
5210 $acting = ( isset( $_GET['acting'] ) ) ? wp_unslash( $_GET['acting'] ) : '';
5211 if ( 'paygent_card' == $acting ) {
5212 if ( isset( $_GET['retry'] ) ) {
5213 $retry_url = add_query_arg(
5214 array(
5215 'backDelivery' => 'paygent_card',
5216 're-enter' => 1,
5217 ),
5218 USCES_CUSTOMER_URL
5219 );
5220 $form .= '<div class="support_box">クレジットカード�
5221 報に誤りがあります。<br />カード番号を再�
5222 �力する場合は、こちらをクリックしてください。<br /><br />';
5223 $form .= '<p class="return_settlement"><a href="' . $retry_url . '">カード番号の再�
5224 �力</a></p>';
5225 $form .= '</div>';
5226 }
5227 }
5228 return $form;
5229 }
5230
5231 /**
5232 * サンキューメール
5233 * usces_filter_send_order_mail_payment
5234 *
5235 * @param string $msg_payment Payment method message.
5236 * @param int $order_id Order number.
5237 * @param array $payment Payment data.
5238 * @param array $cart Cart data.
5239 * @param array $entry Entry data.
5240 * @param array $data Order data.
5241 * @return string
5242 */
5243 public function order_mail_payment( $msg_payment, $order_id, $payment, $cart, $entry, $data ) {
5244 global $usces;
5245
5246 switch ( $payment['settlement'] ) {
5247 case 'acting_paygent_card':
5248 break;
5249 case 'acting_paygent_conv':
5250 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_paygent_conv', $order_id ) );
5251 $usable_cvs_company_id = ( isset( $acting_data['usable_cvs_company_id'] ) ) ? $acting_data['usable_cvs_company_id'] : '';
5252 $receipt_number = ( isset( $acting_data['receipt_number'] ) ) ? $acting_data['receipt_number'] : '';
5253 $lb = ( usces_is_html_mail() ) ? '<br>' : "\r\n";
5254 if ( ! empty( $receipt_number ) ) {
5255 if ( false !== strpos( $usable_cvs_company_id, CODE_SEICOMART ) ) {
5256 $msg_payment .= $this->cvs_company_a[ CODE_SEICOMART ] . 'でのお支払い' . $lb;
5257 $msg_payment .= '受付番号:' . $receipt_number . $lb;
5258 }
5259 if ( false !== strpos( $usable_cvs_company_id, CODE_SEVENELEVEN ) ) {
5260 $msg_payment .= $this->cvs_company_a[ CODE_SEVENELEVEN ] . 'でのお支払い' . $lb;
5261 $msg_payment .= '払込票番号:' . $receipt_number . $lb;
5262 }
5263 if ( false !== strpos( $usable_cvs_company_id, CODE_LOWSON ) ) {
5264 $msg_payment .= $this->cvs_company_a[ CODE_LOWSON ] . 'でのお支払い' . $lb;
5265 $msg_payment .= 'お客様番号:' . $receipt_number . $lb;
5266 $msg_payment .= '確認番号:' . CONVENI_CONFIRMATION_NUMBER . $lb;
5267 }
5268 if ( false !== strpos( $usable_cvs_company_id, CODE_MINISTOP ) ) {
5269 $msg_payment .= $this->cvs_company_a[ CODE_MINISTOP ] . 'でのお支払い' . $lb;
5270 $msg_payment .= 'お客様番号:' . $receipt_number . $lb;
5271 $msg_payment .= '確認番号:' . CONVENI_CONFIRMATION_NUMBER . $lb;
5272 }
5273 if ( false !== strpos( $usable_cvs_company_id, CODE_FAMILYMART ) ) {
5274 $msg_payment .= $this->cvs_company_a[ CODE_FAMILYMART ] . 'でのお支払い' . $lb;
5275 $msg_payment .= '収納番号:' . $receipt_number . $lb;
5276 }
5277 if ( false !== strpos( $usable_cvs_company_id, CODE_YAMAZAKI ) ) {
5278 $msg_payment .= $this->cvs_company_a[ CODE_YAMAZAKI ] . 'でのお支払い' . $lb;
5279 $msg_payment .= '決済番号:' . $receipt_number . $lb;
5280 }
5281 }
5282 if ( ! empty( $acting_data['receipt_print_url'] ) ) {
5283 $receipt_print_url = ( usces_is_html_mail() ) ? '<a href="' . esc_url( $acting_data['receipt_print_url'] ) . '">' . esc_url( $acting_data['receipt_print_url'] ) . '<a>' : $acting_data['receipt_print_url'];
5284 if ( false !== strpos( $usable_cvs_company_id, CODE_SEICOMART ) || false !== strpos( $usable_cvs_company_id, CODE_SEVENELEVEN ) ) {
5285 $msg_payment .= '払込票URL:' . $receipt_print_url . $lb;
5286 } else {
5287 $msg_payment .= '支払参�
5288 �URL:' . $receipt_print_url . $lb;
5289 }
5290 }
5291 if ( ! empty( $acting_data['payment_limit_date'] ) ) {
5292 $msg_payment .= 'お支払い期限日:' . date( __( 'Y/m/d' ), strtotime( $acting_data['payment_limit_date'] ) ) . $lb;
5293 }
5294 break;
5295 case 'acting_paygent_atm':
5296 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_paygent_atm', $order_id ) );
5297 $lb = ( usces_is_html_mail() ) ? '<br>' : "\r\n";
5298 if ( isset( $acting_data['pay_center_number'] ) ) {
5299 $msg_payment .= '収納機関番号:' . $acting_data['pay_center_number'] . $lb;
5300 }
5301 if ( isset( $acting_data['customer_number'] ) ) {
5302 $msg_payment .= 'お客様番号:' . $acting_data['customer_number'] . $lb;
5303 }
5304 if ( isset( $acting_data['conf_number'] ) ) {
5305 $msg_payment .= '確認番号:' . $acting_data['conf_number'] . $lb;
5306 }
5307 if ( ! empty( $acting_data['payment_limit_date'] ) ) {
5308 $msg_payment .= 'お支払い期限日:' . date( __( 'Y/m/d' ), strtotime( $acting_data['payment_limit_date'] ) ) . $lb;
5309 }
5310 break;
5311 case 'acting_paygent_bank':
5312 break;
5313 case 'acting_paygent_paidy':
5314 break;
5315 }
5316 return $msg_payment;
5317 }
5318
5319 /**
5320 * Redirect from 3DS authentication to purchase.
5321 * init
5322 */
5323 public function done_3ds_auth() {
5324 if ( ! $this->is_activate_card( 'module' ) ) {
5325 return;
5326 }
5327 if ( ! isset( $_GET['result'] ) || ! isset( $_GET['3ds_auth_id'] ) || ! isset( $_GET['done_3ds_auth'] ) ) {
5328 return;
5329 }
5330
5331 $acting_opts = $this->get_acting_settings();
5332 $trading_id = trim( $_GET['done_3ds_auth'] );
5333 $original_string = trim( $_GET['result'] ) . trim( $_GET['3ds_auth_id'] );
5334 if ( isset( $_GET['attempt_kbn'] ) ) {
5335 $original_string .= trim( $_GET['attempt_kbn'] );
5336 }
5337 $original_string .= trim( $acting_opts['threedsecure_hc'] );
5338 $hased_string = hash( 'sha256', $original_string );
5339
5340 /* Hash check */
5341 if ( $hased_string !== $_GET['hc'] ) {
5342 $log = array(
5343 'acting' => 'paygent_card(3ds_process)',
5344 'key' => $trading_id,
5345 'result' => '3DS ERROR',
5346 'data' => $_GET,
5347 );
5348 usces_save_order_acting_error( $log );
5349 wp_redirect(
5350 add_query_arg(
5351 array(
5352 'acting' => 'paygent_card',
5353 'acting_return' => 0,
5354 'retry' => 1,
5355 ),
5356 USCES_CART_URL
5357 )
5358 );
5359 exit();
5360 }
5361
5362 /* Get session data */
5363 $post_data = $this->get_post_data( $trading_id );
5364 if ( $post_data ) {
5365 $this->delete_post_data( $trading_id );
5366 ?>
5367 <!DOCTYPE html>
5368 <html lang="ja">
5369 <head>
5370 <title></title>
5371 </head>
5372 <body onload="javascript:document.forms['redirectForm'].submit();">
5373 <form action="<?php echo esc_url( USCES_CART_URL ); ?>" method="post" id="redirectForm">
5374 <?php
5375 foreach ( (array) $post_data as $key => $value ) {
5376 echo '<input type="hidden" name="' . $key . '" value="' . $value . '" />' . "\n";
5377 }
5378 if ( isset( $_GET['result'] ) ) {
5379 echo '<input type="hidden" name="result" value="' . $_GET['result'] . '" />' . "\n";
5380 }
5381 if ( isset( $_GET['3ds_auth_id'] ) ) {
5382 echo '<input type="hidden" name="3ds_auth_id" value="' . $_GET['3ds_auth_id'] . '" />' . "\n";
5383 }
5384 if ( isset( $_GET['3dsecure_ds_transaction_id'] ) ) {
5385 echo '<input type="hidden" name="3dsecure_ds_transaction_id" value="' . $_GET['3dsecure_ds_transaction_id'] . '" />' . "\n";
5386 }
5387 if ( isset( $_GET['attempt_kbn'] ) ) {
5388 echo '<input type="hidden" name="attempt_kbn" value="' . $_GET['attempt_kbn'] . '" />' . "\n";
5389 }
5390 ?>
5391 <input type="hidden" name="purchase" value="purchase" />
5392 <input type="hidden" name="from3ds" value="1" />
5393 <div class="wait_message" style="text-align: center; margin-top: 100px;"><?php esc_html_e( __( 'Hold on for a while, please.', 'usces' ) ); ?></div>
5394 </form>
5395 </body>
5396 </html>
5397 <?php
5398 } else {
5399 $log = array(
5400 'acting' => 'paygent_card(3ds_process)',
5401 'key' => $trading_id,
5402 'result' => 'SESSION ERROR',
5403 'data' => $_GET,
5404 );
5405 usces_save_order_acting_error( $log );
5406 wp_redirect(
5407 add_query_arg(
5408 array(
5409 'acting' => 'paygent_card',
5410 'acting_return' => 0,
5411 'retry' => 1,
5412 ),
5413 USCES_CART_URL
5414 )
5415 );
5416 }
5417 exit();
5418 }
5419
5420 /**
5421 * Redirect to 3DS authentication.
5422 *
5423 * @param array $post_data Post data.
5424 * @param int $member_id Member ID.
5425 */
5426 public function certification_3ds( $post_data, $member_id ) {
5427 global $usces;
5428
5429 $entry = $usces->cart->get_entry();
5430 if ( ! $entry ) {
5431 wp_redirect( USCES_CART_URL );
5432 exit();
5433 }
5434
5435 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
5436 $this->save_post_data( $trading_id, $post_data );
5437
5438 $acting_opts = $this->get_acting_settings();
5439 $card_set_method = 'token';
5440 if ( 'on' == $acting_opts['stock_card_mode'] && ! empty( $member_id ) ) {
5441 if ( isset( $post_data['stock_card'] ) && 'stock' == $post_data['stock_card'] ) {
5442 $card_set_method = 'customer';
5443 }
5444 }
5445
5446 $merchant_name = mb_convert_kana( $usces->options['company_name'], 'RNASKV', 'UTF-8' );
5447 $term_url = add_query_arg( 'done_3ds_auth', $trading_id, USCES_CART_URL );
5448
5449 $pm = Paygent_Module::get_instance();
5450 $pm->init();
5451 $pm->req_put( 'term_url', $term_url );
5452 $pm->req_put( 'authentication_type', '01' );
5453 $pm->req_put( 'merchant_name', $merchant_name );
5454 $pm->req_put( 'payment_amount', $entry['order']['total_full_price'] );
5455 $pm->req_put( 'card_set_method', $card_set_method );
5456 if ( 'customer' == $card_set_method ) {
5457 $customer_card_id = $usces->get_member_meta_value( 'paygent_customer_card_id', $member_id );
5458 $pm->req_put( 'customer_id', $member_id );
5459 $pm->req_put( 'customer_card_id', $customer_card_id );
5460 } else {
5461 $pm->req_put( 'card_token', $post_data['token'] );
5462 }
5463 $result_post = $pm->post( PAYGENT_CARD_3DS2 );
5464 $result_status = $pm->get_result_status();
5465 if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
5466 $response_data = array(
5467 'result' => $result_post,
5468 'result_status' => $result_status,
5469 'response_code' => $pm->get_response_code(),
5470 'response_detail' => $pm->get_response_detail(),
5471 'result_message' => $pm->get_result_message(),
5472 );
5473 $response_code = ( true !== $result_post ) ? $result_post : $pm->get_response_code();
5474 $log = array(
5475 'acting' => $acting,
5476 'key' => $trading_id,
5477 'result' => $response_code,
5478 'data' => $response_data,
5479 );
5480 usces_save_order_acting_error( $log );
5481 wp_redirect(
5482 add_query_arg(
5483 array(
5484 'acting' => $acting,
5485 'acting_return' => 0,
5486 'retry' => 1,
5487 ),
5488 USCES_CART_URL
5489 )
5490 );
5491 exit();
5492 }
5493
5494 $response_data = $pm->get_response_data();
5495 if ( isset( $response_data['out_acs_html'] ) ) {
5496 echo( $response_data['out_acs_html'] );
5497 } else {
5498 $log = array(
5499 'acting' => $acting,
5500 'key' => $trading_id,
5501 'result' => '3DS OUT ACS ERROR',
5502 'data' => $response_data,
5503 );
5504 usces_save_order_acting_error( $log );
5505 wp_redirect(
5506 add_query_arg(
5507 array(
5508 'acting' => $acting,
5509 'acting_return' => 0,
5510 'retry' => 1,
5511 ),
5512 USCES_CART_URL
5513 )
5514 );
5515 }
5516 exit();
5517 }
5518
5519 /**
5520 * Scripts.
5521 * wp_enqueue_scripts
5522 */
5523 public function enqueue_scripts() {
5524 global $usces;
5525
5526 /* 発送・支払方法ページ、クレジットカード�
5527 報更新ページ */
5528 if ( ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'delivery' == $usces->page ) ||
5529 ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) && ( isset( $_GET['usces_page'] ) && ( 'member_register_settlement' == wp_unslash( $_GET['usces_page'] ) || 'member_update_settlement' == wp_unslash( $_GET['usces_page'] ) ) ) ) ) :
5530 // if ( $this->is_activate_card( 'module' ) ) :
5531 $acting_opts = $this->get_acting_settings();
5532 ?>
5533 <script type="text/javascript" src="<?php echo esc_url( $acting_opts['token_url'] ); ?>" charset="UTF-8"></script>
5534 <?php
5535 // endif;
5536 endif;
5537 }
5538
5539 /**
5540 * Front scripts.
5541 * wp_print_footer_scripts
5542 */
5543 public function footer_scripts() {
5544 global $usces;
5545
5546 if ( $this->is_validity_acting( 'card' ) || $this->is_validity_acting( 'conv' ) ) {
5547 /* 発送・支払方法ページ */
5548 if ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'delivery' == $usces->page ) {
5549 if ( $this->is_activate_card( 'module' ) || $this->is_activate_conv( 'module' ) ) {
5550 $acting_opts = $this->get_acting_settings();
5551 wp_register_style( 'paygent-token-style', USCES_FRONT_PLUGIN_URL . '/css/paygent_token.css' );
5552 wp_enqueue_style( 'paygent-token-style' );
5553 wp_register_script( 'usces_cart_paygent', USCES_FRONT_PLUGIN_URL . '/js/cart_paygent.js', array( 'jquery' ), USCES_VERSION, true );
5554 $paygent_params = array();
5555 if ( $this->is_activate_card( 'module' ) ) {
5556 $paygent_params['card_service_type'] = $this->get_service_type( 'card' );
5557 $paygent_params['seq_merchant_id'] = $acting_opts['seq_merchant_id'];
5558 $paygent_params['token_key'] = $acting_opts['token_key'];
5559 $paygent_params['use_card_conf_number'] = $acting_opts['use_card_conf_number'];
5560 $paygent_params['message']['error_token'] = __( 'Credit card information is not appropriate.', 'usces' );
5561 $paygent_params['message']['error_card_number'] = __( 'Credit card information is not appropriate.', 'usces' );
5562 $paygent_params['message']['error_card_expire'] = __( 'Credit card information is not appropriate.', 'usces' );
5563 $paygent_params['message']['error_card_cvc'] = __( 'Credit card information is not appropriate.', 'usces' );
5564 }
5565 if ( $this->is_activate_conv( 'module' ) ) {
5566 $paygent_params['conv_service_type'] = $this->get_service_type( 'conv' );
5567 $paygent_params['message']['error_customer_family_name'] = '利用�
5568 名(姓)を�
5569 �力してください。';
5570 $paygent_params['message']['error_customer_name'] = '利用�
5571 名(名)を�
5572 �力してください。';
5573 $paygent_params['message']['error_customer_tel'] = '利用�
5574 電話番号を�
5575 �力してください。';
5576 }
5577 wp_localize_script( 'usces_cart_paygent', 'paygent_params', $paygent_params );
5578 wp_enqueue_script( 'usces_cart_paygent' );
5579 }
5580 }
5581 }
5582
5583 if ( $this->is_validity_acting( 'card' ) ) :
5584 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) :
5585 /* クレジットカード�
5586 報更新ページ */
5587 if ( isset( $_GET['usces_page'] ) && ( 'member_register_settlement' == wp_unslash( $_GET['usces_page'] ) || 'member_update_settlement' == wp_unslash( $_GET['usces_page'] ) ) ) :
5588 $acting_opts = $this->get_acting_settings();
5589 wp_register_style( 'paygent-token-style', USCES_FRONT_PLUGIN_URL . '/css/paygent_token.css' );
5590 wp_enqueue_style( 'paygent-token-style' );
5591 wp_register_script( 'usces_member_paygent', USCES_FRONT_PLUGIN_URL . '/js/member_paygent.js', array( 'jquery' ), USCES_VERSION, true );
5592 $paygent_params = array();
5593 $paygent_params['seq_merchant_id'] = $acting_opts['seq_merchant_id'];
5594 $paygent_params['token_key'] = $acting_opts['token_key'];
5595 $paygent_params['use_card_conf_number'] = $acting_opts['use_card_conf_number'];
5596 $paygent_params['message'] = array(
5597 'error_token' => __( 'Credit card information is not appropriate.', 'usces' ),
5598 'error_card_number' => __( 'Credit card information is not appropriate.', 'usces' ),
5599 'error_card_expire' => __( 'Credit card information is not appropriate.', 'usces' ),
5600 'error_card_cvc' => __( 'Credit card information is not appropriate.', 'usces' ),
5601 'confirm_deletion' => __( 'Are you sure delete credit card registration?', 'usces' ),
5602 );
5603 wp_localize_script( 'usces_member_paygent', 'paygent_params', $paygent_params );
5604 wp_enqueue_script( 'usces_member_paygent' );
5605 print_google_recaptcha_response( wp_unslash( $_GET['usces_page'] ), 'member-card-info', 'member_update_settlement' );
5606 else :
5607 $member = $usces->get_member();
5608 if ( usces_have_member_continue_order( $member['ID'] ) || usces_have_member_regular_order( $member['ID'] ) ) :
5609 ?>
5610 <script type="text/javascript">
5611 jQuery( document ).ready( function( $ ) {
5612 $( "input[name='deletemember']" ).css( "display", "none" );
5613 });
5614 </script>
5615 <?php
5616 endif;
5617 endif;
5618 endif;
5619 endif;
5620
5621 if ( $this->is_validity_acting( 'paidy' ) ) :
5622 /* �
5623 容確認ページ */
5624 if ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'confirm' == $usces->page ) :
5625 $entry = $usces->cart->get_entry();
5626 $cart = $usces->cart->get_cart();
5627 if ( empty( $entry['order']['total_full_price'] ) ) {
5628 return;
5629 }
5630 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
5631 if ( isset( $payment['settlement'] ) && 'acting_paygent_paidy' == $payment['settlement'] ) {
5632 } else {
5633 return;
5634 }
5635
5636 $continue = ( defined( 'WCEX_DLSELLER' ) ) ? usces_have_continue_charge( $cart ) : false;
5637 $regular = ( defined( 'WCEX_AUTO_DELIVERY' ) ) ? usces_have_regular_order() : false;
5638 if ( $continue || $regular ) {
5639 return;
5640 }
5641
5642 $acting_opts = $this->get_acting_settings();
5643 if ( usces_is_login() ) {
5644 $member = $usces->get_member();
5645 $age = ceil( ( strtotime( date_i18n( 'Y-m-d H:i:s' ) ) - strtotime( $member['registered'] ) ) / ( 60 * 60 * 24 ) );
5646 $member_data = $this->get_buyer_data( $member['ID'] );
5647 $buyer_data = '"user_id": "' . $member['ID'] . '",' . "\n";
5648 $buyer_data .= "\t\t\t" . '"age": ' . $age . ',' . "\n";
5649 $buyer_data .= "\t\t\t" . '"ltv": ' . $member_data['ltv'] . ',' . "\n";
5650 $buyer_data .= "\t\t\t" . '"order_count": ' . $member_data['order_count'] . ',' . "\n";
5651 $buyer_data .= "\t\t\t" . '"last_order_amount": ' . $member_data['last_order_amount'] . ',' . "\n";
5652 $buyer_data .= "\t\t\t" . '"last_order_at": ' . $member_data['last_order_at'] . ',' . "\n";
5653 $number_of_points = '"number_of_points": "' . $member['point'] . '"' . "\n";
5654 } else {
5655 $buyer_data = '"age": null,' . "\n";
5656 $buyer_data .= "\t\t\t" . '"ltv": null,' . "\n";
5657 $buyer_data .= "\t\t\t" . '"order_count": null,' . "\n";
5658 $buyer_data .= "\t\t\t" . '"last_order_amount": null,' . "\n";
5659 $buyer_data .= "\t\t\t" . '"last_order_at": null,' . "\n";
5660 $number_of_points = '';
5661 }
5662 $amount = usces_crform( $entry['order']['total_full_price'], false, false, 'return', false );
5663 if ( isset( $acting_opts['ope'] ) && 'public' == $acting_opts['ope'] ) {
5664 $email = trim( $entry['customer']['mailaddress1'] );
5665 if ( ! empty( $entry['customer']['tel'] ) ) {
5666 $phone = '"phone": "' . str_replace( '-', '', mb_convert_kana( $entry['customer']['tel'], 'a', 'UTF-8' ) ) . '"' . "\n";
5667 } else {
5668 $phone = '';
5669 }
5670 } else {
5671 $email = 'successful.payment@paidy.com';
5672 $phone = '"phone": "08000000001"' . "\n";
5673 }
5674 $name1 = $entry['customer']['name1'] . ' ' . $entry['customer']['name2'];
5675 if ( ! empty( $entry['customer']['name3'] ) ) {
5676 $name2 = '"name2": "' . $entry['customer']['name3'] . ' ' . $entry['customer']['name4'] . '",' . "\n";
5677 } else {
5678 $name2 = '';
5679 }
5680 $line1 = '';
5681 $line2 = '';
5682 $city = '';
5683 $state = '';
5684 $zip = '';
5685 $additional_shipping_addresses = '';
5686 if ( usces_is_login() && defined( 'WCEX_MSA' ) && isset( $entry['delivery']['delivery_flag'] ) && 2 == $entry['delivery']['delivery_flag'] ) {
5687 $msacart = $usces->msacart->get_cart();
5688 $count_msa = ( is_array( $msacart ) ) ? count( $msacart ) : 0;
5689 if ( 0 < $count_msa ) {
5690 krsort( $msacart );
5691 $idx_msa = 0;
5692 foreach ( $msacart as $group_id => $group ) {
5693 $delivery = $group['delivery'];
5694 $destination_info = msa_get_destination( $usces->current_member['id'], $delivery['destination_id'] );
5695 if ( 7 == strlen( trim( $destination_info['msa_zip'] ) ) ) {
5696 $msa_zip = substr( trim( $destination_info['msa_zip'] ), 0, 3 ) . '-' . substr( trim( $destination_info['msa_zip'] ), 3 );
5697 } else {
5698 $msa_zip = trim( $destination_info['msa_zip'] );
5699 }
5700 if ( 0 == $idx_msa ) {
5701 $line1 = trim( $destination_info['msa_address3'] );
5702 $line2 = trim( $destination_info['msa_address2'] );
5703 $city = trim( $destination_info['msa_address1'] );
5704 $state = trim( $destination_info['msa_pref'] );
5705 $zip = $msa_zip;
5706 } elseif ( 1 == $idx_msa ) {
5707 $additional_shipping_addresses .= '"additional_shipping_addresses": [{' . "\n";
5708 $additional_shipping_addresses .= "\t\t\t\t" . '"line1": "' . trim( $destination_info['msa_address3'] ) . '",' . "\n";
5709 $additional_shipping_addresses .= "\t\t\t\t" . '"line2": "' . trim( $destination_info['msa_address2'] ) . '",' . "\n";
5710 $additional_shipping_addresses .= "\t\t\t\t" . '"city": "' . trim( $destination_info['msa_address1'] ) . '",' . "\n";
5711 $additional_shipping_addresses .= "\t\t\t\t" . '"state": "' . trim( $destination_info['msa_pref'] ) . '",' . "\n";
5712 $additional_shipping_addresses .= "\t\t\t\t" . '"zip": "' . $msa_zip . '"' . "\n";
5713 $additional_shipping_addresses .= "\t\t\t" . '}';
5714 } else {
5715 $additional_shipping_addresses .= ',' . "\n\t\t\t" . '{' . "\n";
5716 $additional_shipping_addresses .= "\t\t\t\t" . '"line1": "' . trim( $destination_info['msa_address3'] ) . '",' . "\n";
5717 $additional_shipping_addresses .= "\t\t\t\t" . '"line2": "' . trim( $destination_info['msa_address2'] ) . '",' . "\n";
5718 $additional_shipping_addresses .= "\t\t\t\t" . '"city": "' . trim( $destination_info['msa_address1'] ) . '",' . "\n";
5719 $additional_shipping_addresses .= "\t\t\t\t" . '"state": "' . trim( $destination_info['msa_pref'] ) . '",' . "\n";
5720 $additional_shipping_addresses .= "\t\t\t\t" . '"zip": "' . $msa_zip . '"' . "\n";
5721 $additional_shipping_addresses .= "\t\t\t" . '}';
5722 }
5723 $idx_msa++;
5724 }
5725 $additional_shipping_addresses .= '],' . "\n";
5726 }
5727 } else {
5728 $line1 = trim( $entry['delivery']['address3'] );
5729 $line2 = trim( $entry['delivery']['address2'] );
5730 $city = trim( $entry['delivery']['address1'] );
5731 $state = trim( $entry['delivery']['pref'] );
5732 if ( 7 == strlen( trim( $entry['delivery']['zipcode'] ) ) ) {
5733 $zip = substr( trim( $entry['delivery']['zipcode'] ), 0, 3 ) . '-' . substr( trim( $entry['delivery']['zipcode'] ), 3 );
5734 } else {
5735 $zip = trim( $entry['delivery']['zipcode'] );
5736 }
5737 }
5738 $items = '';
5739 foreach ( $cart as $cart_row ) {
5740 $items .= "\n\t\t\t\t" . '{' . "\n";
5741 $items .= "\t\t\t\t\t" . '"id": "' . $usces->getItemCode( $cart_row['post_id'] ) . '",' . "\n";
5742 $items .= "\t\t\t\t\t" . '"quantity": ' . $cart_row['quantity'] . ',' . "\n";
5743 $items .= "\t\t\t\t\t" . '"title": "' . $usces->getItemName( $cart_row['post_id'] ) . '",' . "\n";
5744 $items .= "\t\t\t\t\t" . '"unit_price": ' . $cart_row['price'] . "\n";
5745 $items .= "\t\t\t\t" . '},';
5746 }
5747 if ( isset( $entry['order']['discount'] ) && 0 != $entry['order']['discount'] ) {
5748 $items .= "\n\t\t\t\t" . '{' . "\n";
5749 $items .= "\t\t\t\t\t" . '"quantity": 1,' . "\n";
5750 $items .= "\t\t\t\t\t" . '"title": "' . apply_filters( 'usces_confirm_discount_label', __( 'Campaign discount', 'usces' ) ) . '",' . "\n";
5751 $items .= "\t\t\t\t\t" . '"unit_price": ' . $entry['order']['discount'] . "\n";
5752 $items .= "\t\t\t\t" . '},';
5753 }
5754 if ( usces_is_member_system() && usces_is_member_system_point() && ! empty( $entry['order']['usedpoint'] ) ) {
5755 $items .= "\n\t\t\t\t" . '{' . "\n";
5756 $items .= "\t\t\t\t\t" . '"quantity": 1,' . "\n";
5757 $items .= "\t\t\t\t\t" . '"title": "' . __( 'Used points', 'usces' ) . '",' . "\n";
5758 $items .= "\t\t\t\t\t" . '"unit_price": ' . ( $entry['order']['usedpoint'] * -1 ) . "\n";
5759 $items .= "\t\t\t\t" . '},';
5760 }
5761 if ( ! empty( $entry['order']['cod_fee'] ) ) {
5762 $items .= "\n\t\t\t\t" . '{' . "\n";
5763 $items .= "\t\t\t\t\t" . '"quantity": 1,' . "\n";
5764 $items .= "\t\t\t\t\t" . '"title": "' . apply_filters( 'usces_filter_paidy_fee_label', 'Paidy手数料' ) . '",' . "\n";
5765 $items .= "\t\t\t\t\t" . '"unit_price": ' . $entry['order']['cod_fee'] . "\n";
5766 $items .= "\t\t\t\t" . '},';
5767 }
5768 $items = rtrim( $items, ',' ) . "\n";
5769 if ( 0 != $entry['order']['shipping_charge'] ) {
5770 $shipping = $entry['order']['shipping_charge'];
5771 } else {
5772 $shipping = '0';
5773 }
5774 if ( isset( $entry['order']['tax'] ) && 'exclude' == usces_get_tax_mode() ) {
5775 $tax = $entry['order']['tax'] . "\n";
5776 } else {
5777 $tax = '0' . "\n";
5778 }
5779 ?>
5780 <script type="text/javascript" src="https://apps.paidy.com/"></script>
5781 <script type="text/javascript">
5782 var config = {
5783 "api_key": "<?php echo esc_html( $acting_opts['paidy_public_key'] ); ?>",
5784 "closed": function( callbackData ) {
5785 if ( 'closed' == callbackData.status ) {
5786 document.getElementById( "paidy-checkout-button" ).style.pointerEvents = "auto";
5787 } else {
5788 var purchase_form = document.forms.purchase_form;
5789 purchase_form.paidy_id.value = callbackData.id;
5790 purchase_form.paidy_created_at.value = callbackData.created_at;
5791 purchase_form.paidy_status.value = callbackData.status;
5792 purchase_form.submit();
5793 }
5794 }
5795 };
5796 var paidyHandler = Paidy.configure( config );
5797 function paidyPay() {
5798 document.getElementById( "paidy-checkout-button" ).style.pointerEvents = "none";
5799 var rand = document.getElementsByName( "trading_id" )[0].value;
5800 var payload = {
5801 "amount": <?php echo esc_js( $amount ); ?>,
5802 "currency": "JPY",
5803 "store_name": "<?php echo esc_html( get_option( 'blogname' ) ); ?>",
5804 "buyer": {
5805 "email": "<?php echo esc_js( $email ); ?>",
5806 "name1": "<?php echo esc_js( $name1 ); ?>",
5807 <?php wel_esc_script_e( $name2 ); ?>
5808 <?php wel_esc_script_e( $phone ); ?>
5809 },
5810 "buyer_data": {
5811 <?php wel_esc_script_e( $buyer_data ); ?>
5812 <?php wel_esc_script_e( $additional_shipping_addresses ); ?>
5813 <?php wel_esc_script_e( $number_of_points ); ?>
5814 },
5815 "order": {
5816 "items": [
5817 <?php wel_esc_script_e( $items ); ?>
5818 ],
5819 "order_ref": rand,
5820 "shipping": <?php wel_esc_script_e( $shipping ); ?>,
5821 "tax": <?php wel_esc_script_e( $tax ); ?>
5822 },
5823 "shipping_address": {
5824 "line1": "<?php echo esc_js( $line1 ); ?>",
5825 "line2": "<?php echo esc_js( $line2 ); ?>",
5826 "city": "<?php echo esc_js( $city ); ?>",
5827 "state": "<?php echo esc_js( $state ); ?>",
5828 "zip": "<?php echo esc_js( $zip ); ?>"
5829 }
5830 };
5831 paidyHandler.launch( payload );
5832 };
5833 </script>
5834 <?php
5835 endif;
5836 endif;
5837 }
5838
5839 /**
5840 * Paidy Checkout Buyer data オブジェクト
5841 *
5842 * @param int $member_id Post ID.
5843 * @return array
5844 */
5845 private function get_buyer_data( $member_id ) {
5846 global $wpdb;
5847
5848 $ltv = 0;
5849 $order_count = 0;
5850 $last_order_amount = 0;
5851 $last_order_at = 0;
5852
5853 $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}usces_order WHERE `mem_id` = %d ORDER BY `order_date` DESC", $member_id );
5854 $results = $wpdb->get_results( $query, ARRAY_A );
5855 if ( 0 < count( $results ) ) {
5856 foreach ( $results as $order ) {
5857 if ( false === strpos( $order['order_status'], 'cancel' ) && false === strpos( $order['order_status'], 'estimate' ) ) {
5858 $payment = usces_get_payments_by_name( $order['order_payment_name'] );
5859 if ( isset( $payment['settlement'] ) && 'acting_paygent_paidy' != $payment['settlement'] ) {
5860 $total_price = $order['order_item_total_price'] - $order['order_usedpoint'] + $order['order_discount'] + $order['order_shipping_charge'] + $order['order_cod_fee'] + $order['order_tax'];
5861 if ( 0 === $order_count ) {
5862 $last_order_amount = $total_price;
5863 $last_order_at = ceil( ( strtotime( date_i18n( 'Y-m-d H:i:s' ) ) - strtotime( $order['order_date'] ) ) / ( 60 * 60 * 24 ) );
5864 }
5865 $ltv += $total_price;
5866 $order_count++;
5867 }
5868 }
5869 }
5870 }
5871 $member_data = array(
5872 'ID' => $member_id,
5873 'ltv' => $ltv,
5874 'order_count' => $order_count,
5875 'last_order_amount' => $last_order_amount,
5876 'last_order_at' => $last_order_at,
5877 );
5878
5879 return $member_data;
5880 }
5881
5882 /**
5883 * Set uscesL10n.
5884 * usces_filter_uscesL10n
5885 *
5886 * @param string $l10n uscesL10n.
5887 * @param int $post_id Post ID.
5888 * @return string
5889 */
5890 public function set_uscesL10n( $l10n, $post_id ) {
5891 global $usces;
5892
5893 if ( ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'delivery' == $usces->page ) ||
5894 ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) && ( isset( $_GET['usces_page'] ) && ( 'member_register_settlement' == wp_unslash( $_GET['usces_page'] ) || 'member_update_settlement' == wp_unslash( $_GET['usces_page'] ) ) ) ) ) {
5895 if ( $this->is_activate_card( 'module' ) ) {
5896 $front_ajaxurl = USCES_SSL_URL;
5897 if ( '/' != substr( $front_ajaxurl, -1 ) ) {
5898 $front_ajaxurl .= '/';
5899 }
5900 $front_ajaxurl .= 'index.php';
5901 $l10n .= "'front_ajaxurl': '" . $front_ajaxurl . "',\n";
5902 }
5903 }
5904 return $l10n;
5905 }
5906
5907 /**
5908 * 支払方法チェック
5909 * usces_filter_delivery_check
5910 *
5911 * @param string $mes Validation check message.
5912 * @return string
5913 */
5914 public function delivery_check( $mes ) {
5915 if ( ! isset( $_POST['offer']['payment_name'] ) ) {
5916 return $mes;
5917 }
5918
5919 if ( ! empty( $mes ) ) {
5920 return $mes;
5921 }
5922
5923 $payment = usces_get_payments_by_name( $_POST['offer']['payment_name'] );
5924 $acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
5925 switch ( $acting_flg ) {
5926 case 'acting_paygent_card':
5927 if ( $this->is_activate_card( 'module' ) ) {
5928 if ( isset( $_POST['stock_card'] ) && 'stock' == wp_unslash( $_POST['stock_card'] ) ) {
5929 $acting_opts = $this->get_acting_settings();
5930 if ( 'on' == $acting_opts['use_card_conf_number'] ) {
5931 if ( isset( $_POST['token'] ) && empty( $_POST['token'] ) ) {
5932 $mes .= __( 'Please enter the card information correctly.', 'usces' ) . '<br />';
5933 }
5934 }
5935 } else {
5936 if ( isset( $_POST['token'] ) && empty( $_POST['token'] ) ) {
5937 $mes .= __( 'Please enter the card information correctly.', 'usces' ) . '<br />';
5938 } else {
5939 if ( ! wel_check_credit_security() ) {
5940 $mes .= __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '<br />';
5941 }
5942 }
5943 }
5944 }
5945 break;
5946
5947 case 'acting_paygent_conv':
5948 if ( $this->is_activate_conv( 'module' ) ) {
5949 if ( isset( $_POST['customer_family_name'] ) && empty( $_POST['customer_family_name'] ) ) {
5950 $mes .= '利用�
5951 名(姓)を�
5952 �力してください。<br />';
5953 }
5954 if ( isset( $_POST['customer_name'] ) && empty( $_POST['customer_name'] ) ) {
5955 $mes .= '利用�
5956 名(名)を�
5957 �力してください。<br />';
5958 }
5959 if ( isset( $_POST['customer_tel'] ) && empty( $_POST['customer_tel'] ) ) {
5960 $mes .= '利用�
5961 電話番号を�
5962 �力してください。<br />';
5963 }
5964 }
5965 break;
5966
5967 case 'acting_paygent_atm':
5968 break;
5969
5970 case 'acting_paygent_bank':
5971 break;
5972 }
5973 return $mes;
5974 }
5975
5976 /**
5977 * 支払方法ページ用�
5978 �力フォーム
5979 * usces_filter_delivery_secure_form_loop
5980 *
5981 * @param string $nouse Empty.
5982 * @param array $payment Payment data.
5983 * @return string
5984 */
5985 public function delivery_secure_form_loop( $nouse, $payment ) {
5986 global $usces;
5987
5988 $form = '';
5989 switch ( $payment['settlement'] ) {
5990 case 'acting_paygent_card':
5991 if ( 'activate' != $payment['use'] || ! $this->is_activate_card( 'module' ) ) {
5992 return $form;
5993 }
5994
5995 $acting_opts = $this->get_acting_settings();
5996 $re_enter = ( isset( $_REQUEST['re_enter'] ) && false !== strpos( $_REQUEST['re_enter'], 'paygent_card' ) ) ? true : false;
5997
5998 $customer_id = '';
5999 if ( usces_is_login() ) {
6000 $usces->get_current_member();
6001 $customer_id = $usces->current_member['id'];
6002 }
6003
6004 $customer = array();
6005 if ( 'on' == $acting_opts['stock_card_mode'] ) {
6006 if ( ! empty( $customer_id ) ) {
6007 $customer = $this->customer_ref( $customer_id );
6008 }
6009 }
6010 $split_count = ( isset( $_POST['split_count'] ) ) ? wp_unslash( $_POST['split_count'] ) : '01';
6011 $card_area_class = 'paygent_card_area';
6012
6013 $form .= '
6014 <table class="customer_form" id="paygent_card_form">
6015 <tr>
6016 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>' . __( 'Credit card information', 'usces' ) . '</th>
6017 <td>';
6018 if ( 'on' == $acting_opts['stock_card_mode'] && ! empty( $customer['card_number'] ) ) {
6019 $card_area_class = 'paygent_new_card_area';
6020 $cardlast4 = substr( $customer['card_number'], -4 );
6021 $split_type = $this->split_type( $customer['card_brand'] );
6022 $form .= '
6023 <p><label><input type="radio" name="stock_card" class="stock_card" id="stock_card_use" value="stock"><span>登録済みのクレジットカードを使う</span></label></p>
6024 <div class="paygent_registerd_card_area">
6025 <div>登録済みのカード番号下4桁<span class="cardlast4">' . $cardlast4 . '</span></div>
6026 <input type="hidden" id="split_type" value="' . $split_type . '" />
6027 </div>
6028 <p><label><input type="radio" name="stock_card" class="stock_card" id="stock_card_new" value="new"><span>新しいクレジットカードを使う</span></label></p>';
6029 }
6030 $form .= '<div class="' . $card_area_class . '">
6031 <dl>
6032 <dt>' . __( 'card number', 'usces' ) . '</dt>
6033 <dd><input type="tel" class="card_number" id="card_number" maxlength="16" value=""></dd>';
6034 if ( 'on' == $acting_opts['stock_card_mode'] ) {
6035 if ( ! empty( $customer['card_number'] ) ) {
6036 if ( usces_have_regular_order() || usces_have_continue_charge() ) {
6037 $form .= '<input type="hidden" name="stock_card_mode" value="change">';
6038 } else {
6039 $form .= '<dd><label><input type="checkbox" name="stock_card_mode" id="stock_card_mode" value="change"><span id="stock_card_mode_label">登録済のカードを変更して購�
6040 �する</span></label></dd>';
6041 }
6042 } else {
6043 if ( usces_have_regular_order() || usces_have_continue_charge() ) {
6044 $form .= '<input type="hidden" name="stock_card_mode" value="save">';
6045 } else {
6046 $form .= '<dd><label><input type="checkbox" name="stock_card_mode" id="stock_card_mode" value="save"><span id="stock_card_mode_label">クレジットカードを登録して購�
6047 �する</span></label></dd>';
6048 }
6049 }
6050 }
6051 $cardno_attention = apply_filters( 'usces_filter_cardno_attention', '<dd><div class="attention">' . __( '* Please do not enter symbols or letters other than numbers such as space (blank), hyphen (-) between numbers.', 'usces' ) . '</div></dd>' );
6052 $form .= $cardno_attention;
6053 $form .= '<dt>' . __( 'Card expiration', 'usces' ) . '</dt>
6054 <dd><select class="expire_month" id="expire_month">
6055 <option value="">--</option>';
6056 for ( $i = 1; $i <= 12; $i++ ) {
6057 $form .= '<option value="' . sprintf( '%02d', $i ) . '">' . sprintf( '%02d', $i ) . '</option>';
6058 }
6059 $form .= '</select>' . __( 'month', 'usces' ) . '&nbsp;
6060 <select class="expire_year" id="expire_year">
6061 <option value="">--</option>';
6062 for ( $i = 0; $i <= 15; $i++ ) {
6063 $year = date_i18n( 'Y' ) + $i;
6064 $year = substr( $year, -2 );
6065 $form .= '
6066 <option value="' . $year . '">' . $year . '</option>';
6067 }
6068 $form .= '</select>' . __( 'year', 'usces' ) . '</dd>
6069 </dl>
6070 </div>';
6071 if ( 'on' == $acting_opts['use_card_conf_number'] ) {
6072 $form .= '<div class="paygent_card_split_count_area">
6073 <dl><dt>' . __( 'security code', 'usces' ) . '</dt>
6074 <dd><input type="tel" class="cvc" id="cvc" maxlength="4" value=""></dd>';
6075 $cvc_attention = apply_filters( 'usces_filter_seccd_attention', '' );
6076 $form .= $cvc_attention;
6077 $form .= '
6078 </dl>
6079 </div>';
6080 }
6081
6082 $form_split_count = '';
6083 if ( ( usces_have_regular_order() || usces_have_continue_charge() ) && usces_is_login() ) {
6084 $form_split_count .= '<input type="hidden" name="split_count" value="01" />';
6085 } else {
6086 if ( 0 === (int) $acting_opts['payment_class'] ) {
6087 $form_split_count .= '<input type="hidden" name="split_count" value="01" />';
6088 } elseif ( 1 <= (int) $acting_opts['payment_class'] ) {
6089 $form_split_count = '<div class="paygent_card_split_count_area">
6090 <dl><dt>分割回数</dt>
6091 <dd>';
6092 $form_split_count .= '
6093 <select name="split_count" id="split_count_default" >
6094 <option value="01"' . ( ( '01' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'One time payment', 'usces' ) . '</option>
6095 </select>';
6096 $form_split_count .= '
6097 <select name="split_count" id="split_count_4535" style="display:none;" disabled="disabled" >
6098 <option value="01"' . ( ( '01' == $split_count ) ? ' selected="selected"' : '' ) . '>1' . __( '-time payment', 'usces' ) . '</option>
6099 <option value="02"' . ( ( '02' == $split_count ) ? ' selected="selected"' : '' ) . '>2' . __( '-time payment', 'usces' ) . '</option>
6100 <option value="03"' . ( ( '03' == $split_count ) ? ' selected="selected"' : '' ) . '>3' . __( '-time payment', 'usces' ) . '</option>
6101 <option value="05"' . ( ( '05' == $split_count ) ? ' selected="selected"' : '' ) . '>5' . __( '-time payment', 'usces' ) . '</option>
6102 <option value="06"' . ( ( '06' == $split_count ) ? ' selected="selected"' : '' ) . '>6' . __( '-time payment', 'usces' ) . '</option>
6103 <option value="10"' . ( ( '10' == $split_count ) ? ' selected="selected"' : '' ) . '>10' . __( '-time payment', 'usces' ) . '</option>
6104 <option value="12"' . ( ( '12' == $split_count ) ? ' selected="selected"' : '' ) . '>12' . __( '-time payment', 'usces' ) . '</option>
6105 <option value="15"' . ( ( '15' == $split_count ) ? ' selected="selected"' : '' ) . '>15' . __( '-time payment', 'usces' ) . '</option>
6106 <option value="18"' . ( ( '18' == $split_count ) ? ' selected="selected"' : '' ) . '>18' . __( '-time payment', 'usces' ) . '</option>
6107 <option value="20"' . ( ( '20' == $split_count ) ? ' selected="selected"' : '' ) . '>20' . __( '-time payment', 'usces' ) . '</option>
6108 <option value="24"' . ( ( '24' == $split_count ) ? ' selected="selected"' : '' ) . '>24' . __( '-time payment', 'usces' ) . '</option>
6109 <option value="80"' . ( ( '80' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'Libor Funding pay', 'usces' ) . '</option>';
6110 if ( 1 == (int) $acting_opts['payment_class'] ) {
6111 $form_split_count .= '
6112 <option value="23"' . ( ( '23' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'Bonus lump-sum payment', 'usces' ) . '</option>';
6113 }
6114 $form_split_count .= '
6115 </select>';
6116 $form_split_count .= '
6117 <select name="split_count" id="split_count_37" style="display:none;" disabled="disabled" >
6118 <option value="01"' . ( ( '01' == $split_count ) ? ' selected="selected"' : '' ) . '>1' . __( '-time payment', 'usces' ) . '</option>
6119 <option value="03"' . ( ( '03' == $split_count ) ? ' selected="selected"' : '' ) . '>3' . __( '-time payment', 'usces' ) . '</option>
6120 <option value="05"' . ( ( '05' == $split_count ) ? ' selected="selected"' : '' ) . '>5' . __( '-time payment', 'usces' ) . '</option>
6121 <option value="06"' . ( ( '06' == $split_count ) ? ' selected="selected"' : '' ) . '>6' . __( '-time payment', 'usces' ) . '</option>
6122 <option value="10"' . ( ( '10' == $split_count ) ? ' selected="selected"' : '' ) . '>10' . __( '-time payment', 'usces' ) . '</option>
6123 <option value="12"' . ( ( '12' == $split_count ) ? ' selected="selected"' : '' ) . '>12' . __( '-time payment', 'usces' ) . '</option>
6124 <option value="15"' . ( ( '15' == $split_count ) ? ' selected="selected"' : '' ) . '>15' . __( '-time payment', 'usces' ) . '</option>
6125 <option value="18"' . ( ( '18' == $split_count ) ? ' selected="selected"' : '' ) . '>18' . __( '-time payment', 'usces' ) . '</option>
6126 <option value="20"' . ( ( '20' == $split_count ) ? ' selected="selected"' : '' ) . '>20' . __( '-time payment', 'usces' ) . '</option>
6127 <option value="24"' . ( ( '24' == $split_count ) ? ' selected="selected"' : '' ) . '>24' . __( '-time payment', 'usces' ) . '</option>';
6128 if ( 1 == (int) $acting_opts['payment_class'] ) {
6129 $form_split_count .= '
6130 <option value="23"' . ( ( '23' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'Bonus lump-sum payment', 'usces' ) . '</option>';
6131 }
6132 $form_split_count .= '
6133 </select>';
6134 $form_split_count .= '
6135 <select name="split_count" id="split_count_36" style="display:none;" disabled="disabled" >
6136 <option value="01"' . ( ( '01' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'One time payment', 'usces' ) . '</option>
6137 <option value="80"' . ( ( '80' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'Libor Funding pay', 'usces' ) . '</option>';
6138 if ( 1 == (int) $acting_opts['payment_class'] ) {
6139 $form_split_count .= '
6140 <option value="23"' . ( ( '23' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'Bonus lump-sum payment', 'usces' ) . '</option>';
6141 }
6142 $form_split_count .= '
6143 </select>';
6144 $form_split_count .= '
6145 </dd>
6146 </dl>
6147 </div>';
6148 }
6149 }
6150 $form .= apply_filters( 'usces_filter_paygent_card_split_count', $form_split_count );
6151 $form .= '
6152 <input type="hidden" name="acting" value="paygent_card" />
6153 <input type="hidden" name="confirm" value="confirm" />
6154 <input type="hidden" name="token" id="token" value="" />
6155 <input type="hidden" name="masked_card_number" id="masked_card_number" value="" />
6156 <input type="hidden" name="valid_until" id="valid_until" value="" />
6157 <input type="hidden" name="fingerprint" id="fingerprint" value="" />
6158 <input type="hidden" name="hc" id="hc" value="" />';
6159 $form .= '
6160 </td></tr>
6161 </table>';
6162 break;
6163
6164 case 'acting_paygent_conv':
6165 if ( 'activate' != $payment['use'] || ! $this->is_activate_conv( 'module' ) ) {
6166 return $form;
6167 }
6168
6169 $acting_opts = $this->get_acting_settings();
6170 $entry = $usces->cart->get_entry();
6171 $cvs_company_id = ( isset( $_POST['cvs_company_id'] ) ) ? $_POST['cvs_company_id'] : '';
6172 $name1 = ( isset( $_POST['customer_family_name'] ) ) ? $_POST['customer_family_name'] : trim( $entry['customer']['name1'] );
6173 $name2 = ( isset( $_POST['customer_name'] ) ) ? $_POST['customer_name'] : trim( $entry['customer']['name2'] );
6174 $tel = ( isset( $_POST['customer_tel'] ) ) ? $_POST['customer_tel'] : trim( $entry['customer']['tel'] );
6175 $tel = str_replace( '-', '', mb_convert_kana( $tel, 'a', 'UTF-8' ) );
6176
6177 $form .= '
6178 <table class="customer_form" id="paygent_conv_form">
6179 <tr>
6180 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>' . __( 'Convenience store for payment', 'usces' ) . '</th>
6181 <td colspan="2">
6182 <select name="cvs_company_id" id="cvs_company_id">';
6183 foreach ( $this->cvs_company_a as $cvs_cd => $cvs_company ) {
6184 $cvs_type = $this->cvs_type_a[ $cvs_cd ];
6185 if ( ! in_array( $cvs_type, $acting_opts['cvs_type'] ) ) {
6186 continue;
6187 }
6188 $selected = ( $cvs_company_id == $cvs_cd ) ? ' selected="selected"' : '';
6189 $form .= '
6190 <option value="' . esc_attr( $cvs_cd ) . '"' . $selected . '>' . esc_attr( $cvs_company ) . '</option>';
6191 }
6192 $form .= '
6193 </select>
6194 </td>
6195 </tr>
6196 <tr>
6197 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>利用�
6198 名</th>
6199 <td>姓<input name="customer_family_name" class="customer_name" id="customer_family_name" type="text" value="' . esc_attr( $name1 ) . '" /></td>
6200 <td>名<input name="customer_name" class="customer_name" id="customer_name" type="text" value="' . esc_attr( $name2 ) . '" />(�
6201 �角)</td>
6202 </tr>
6203 <tr>
6204 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>利用�
6205 電話番号</th>
6206 <td colspan="2"><input name="customer_tel" id="customer_tel" type="tel" value="' . esc_attr( $tel ) . '" /></td>
6207 </tr>
6208 </table>';
6209 break;
6210
6211 case 'acting_paygent_atm':
6212 if ( 'activate' != $payment['use'] || ! $this->is_activate_atm() ) {
6213 return $form;
6214 }
6215
6216 $acting_opts = $this->get_acting_settings();
6217 $entry = $usces->cart->get_entry();
6218 $name1 = ( isset( $_POST['customer_family_name'] ) ) ? $_POST['customer_family_name'] : trim( $entry['customer']['name1'] );
6219 $name2 = ( isset( $_POST['customer_name'] ) ) ? $_POST['customer_name'] : trim( $entry['customer']['name2'] );
6220 $name3 = ( isset( $_POST['customer_family_name_kana'] ) ) ? $_POST['customer_family_name_kana'] : String_Utitily::convert_katakana_zen2han( trim( $entry['customer']['name3'] ) );
6221 $name4 = ( isset( $_POST['customer_name_kana'] ) ) ? $_POST['customer_name_kana'] : String_Utitily::convert_katakana_zen2han( trim( $entry['customer']['name4'] ) );
6222
6223 $form .= '
6224 <table class="customer_form" id="paygent_atm_form">
6225 <tr>
6226 <th scope="row">利用�
6227 名</th>
6228 <td>姓<input name="customer_family_name" class="customer_name" id="customer_family_name" type="text" value="' . esc_attr( $name1 ) . '" /></td>
6229 <td>名<input name="customer_name" class="customer_name" id="customer_name" type="text" value="' . esc_attr( $name2 ) . '" />(�
6230 �角)</td>
6231 </tr>
6232 <tr>
6233 <th scope="row">利用�
6234 名カ�
6235 </th>
6236 <td>セイ<input name="customer_family_name_kana" class="customer_name" id="customer_family_name_kana" type="text" value="' . esc_attr( $name3 ) . '" /></td>
6237 <td>メイ<input name="customer_name_kana" class="customer_name" id="customer_name_kana" type="text" value="' . esc_attr( $name4 ) . '" />(半角カ�
6238 )</td>
6239 </tr>
6240 </table>';
6241 break;
6242
6243 case 'acting_paygent_bank':
6244 if ( 'activate' != $payment['use'] || ! $this->is_activate_bank() ) {
6245 return $form;
6246 }
6247
6248 $acting_opts = $this->get_acting_settings();
6249 $entry = $usces->cart->get_entry();
6250 $name1 = ( isset( $_POST['customer_family_name'] ) ) ? $_POST['customer_family_name'] : trim( $entry['customer']['name1'] );
6251 $name2 = ( isset( $_POST['customer_name'] ) ) ? $_POST['customer_name'] : trim( $entry['customer']['name2'] );
6252 $name3 = ( isset( $_POST['customer_family_name_kana'] ) ) ? $_POST['customer_family_name_kana'] : String_Utitily::convert_katakana_zen2han( trim( $entry['customer']['name3'] ) );
6253 $name4 = ( isset( $_POST['customer_name_kana'] ) ) ? $_POST['customer_name_kana'] : String_Utitily::convert_katakana_zen2han( trim( $entry['customer']['name4'] ) );
6254
6255 $form .= '
6256 <table class="customer_form" id="paygent_bank_form">
6257 <tr>
6258 <th scope="row">利用�
6259 名</th>
6260 <td>姓<input name="customer_family_name" class="customer_name" id="customer_family_name" type="text" value="' . esc_attr( $name1 ) . '" /></td>
6261 <td>名<input name="customer_name" class="customer_name" id="customer_name" type="text" value="' . esc_attr( $name2 ) . '" />(�
6262 �角)</td>
6263 </tr>
6264 <tr>
6265 <th scope="row">利用�
6266 名カ�
6267 </th>
6268 <td>セイ<input name="customer_family_name_kana" class="customer_name" id="customer_family_name_kana" type="text" value="' . esc_attr( $name3 ) . '" /></td>
6269 <td>メイ<input name="customer_name_kana" class="customer_name" id="customer_name_kana" type="text" value="' . esc_attr( $name4 ) . '" />(半角カ�
6270 )</td>
6271 </tr>
6272 </table>';
6273 break;
6274 }
6275 return $form;
6276 }
6277
6278 /**
6279 * お預かりカードの分割可能回数
6280 *
6281 * @param string $card_brand Card brand.
6282 * @return string
6283 */
6284 private function split_type( $card_brand ) {
6285 switch ( $card_brand ) {
6286 case 'VISA':
6287 case 'JCB':
6288 case 'MASTER':
6289 $split_type = '4535';
6290 break;
6291 case 'DINERS':
6292 $split_type = '36';
6293 break;
6294 case 'AMEX':
6295 $split_type = '37';
6296 break;
6297 default:
6298 $split_type = 'default';
6299 }
6300 return $split_type;
6301 }
6302
6303 /**
6304 * 購�
6305 �完了メッセージ
6306 * usces_filter_completion_settlement_message
6307 *
6308 * @param string $form Purchase complete message.
6309 * @param array $entry Entry data.
6310 * @return string
6311 */
6312 public function completion_settlement_message( $form, $entry ) {
6313 $acting = ( isset( $_GET['acting'] ) ) ? wp_unslash( $_GET['acting'] ) : '';
6314 if ( 'paygent_conv' == $acting || 'paygent_atm' == $acting ) {
6315 $form .= '<div class="completion-settlement-message"><span class="bold">' . $this->acting_formal_name . esc_html( $entry['order']['payment_name'] ) . '</span>';
6316 $form .= '<p>' . sprintf( __( "Information on payment will be mailed to %s.", 'usces' ), esc_html( $entry['customer']['mailaddress1'] ) ) . '</p>';
6317 $form .= '</div>';
6318 }
6319 return $form;
6320 }
6321
6322 /**
6323 * Temporary storage of session data.
6324 * usces_filter_save_order_acting_data
6325 *
6326 * @param array $data Session data.
6327 * @return array
6328 */
6329 public function save_order_acting_data( $data ) {
6330 if ( isset( $_POST['_nonce'] ) ) {
6331 $data['_nonce'] = wp_unslash( $_POST['_nonce'] );
6332 }
6333 return $data;
6334 }
6335
6336 /**
6337 * 会員データ削除チェック
6338 * usces_filter_delete_member_check
6339 *
6340 * @param boolean $deletable Deletable.
6341 * @param int $member_id Member ID.
6342 * @return boolean
6343 */
6344 public function delete_member_check( $deletable, $member_id ) {
6345 $customer = $this->customer_ref( $member_id );
6346 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id ) {
6347 if ( usces_have_member_continue_order( $member_id ) || usces_have_member_regular_order( $member_id ) ) {
6348 $deletable = false;
6349 }
6350 }
6351 return $deletable;
6352 }
6353
6354 /**
6355 * 会員データ削除
6356 * usces_action_pre_delete_memberdata
6357 *
6358 * @param string $member_id Member ID.
6359 */
6360 public function delete_member( $member_id ) {
6361 $this->customer_card_del( $member_id );
6362 }
6363
6364 /**
6365 * クレジットカード登録・変更ページ表示
6366 * usces_filter_template_redirect
6367 */
6368 public function member_update_settlement() {
6369 global $usces;
6370
6371 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
6372 if ( ! usces_is_membersystem_state() || ! usces_is_login() ) {
6373 return;
6374 }
6375 $acting_opts = $this->get_acting_settings();
6376 if ( 'on' != $acting_opts['stock_card_mode'] ) {
6377 return;
6378 }
6379 if ( isset( $_REQUEST['usces_page'] ) && 'member_update_settlement' == $_REQUEST['usces_page'] ) {
6380 add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) );
6381 $usces->page = 'member_update_settlement';
6382 $this->member_update_settlement_form();
6383 exit();
6384 } elseif ( isset( $_REQUEST['usces_page'] ) && 'member_register_settlement' == $_REQUEST['usces_page'] ) {
6385 add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) );
6386 $usces->page = 'member_register_settlement';
6387 $this->member_update_settlement_form();
6388 exit();
6389 }
6390 }
6391 return false;
6392 }
6393
6394 /**
6395 * クレジットカード登録・変更ページ表示
6396 * usces_filter_states_form_js
6397 *
6398 * @param string $js Scripts.
6399 * @return string
6400 */
6401 public function states_form_js( $js ) {
6402 return '';
6403 }
6404
6405 /**
6406 * クレジットカード登録・変更ページリンク
6407 * usces_action_member_submenu_list
6408 */
6409 public function e_update_settlement() {
6410 global $usces;
6411
6412 $member = $usces->get_member();
6413 $form = $this->update_settlement( '', $member );
6414 echo $form; // no escape.
6415 }
6416
6417 /**
6418 * クレジットカード登録・変更ページリンク
6419 * usces_filter_member_submenu_list
6420 *
6421 * @param string $form Submenu area of the member page.
6422 * @param array $member Member information.
6423 * @return string
6424 */
6425 public function update_settlement( $form, $member ) {
6426 $acting_opts = $this->get_acting_settings();
6427 if ( isset( $acting_opts['card_activate'] ) && 'off' != $acting_opts['card_activate'] && 'on' == $acting_opts['stock_card_mode'] && ! empty( $member['ID'] ) ) {
6428 $customer = $this->customer_ref( $member['ID'] );
6429 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member['ID'] ) {
6430 $update_settlement_url = add_query_arg(
6431 array(
6432 'usces_page' => 'member_update_settlement',
6433 're-enter' => 1,
6434 ),
6435 USCES_MEMBER_URL
6436 );
6437 $form .= '<li><a href="' . $update_settlement_url . '">' . __( 'Change the credit card is here >>', 'usces' ) . '</a></li>';
6438 } else {
6439 $register_settlement_url = add_query_arg(
6440 array(
6441 'usces_page' => 'member_register_settlement',
6442 're-enter' => 1,
6443 ),
6444 USCES_MEMBER_URL
6445 );
6446 $form .= '<li><a href="' . $register_settlement_url . '">' . __( 'Credit card registration is here >>', 'usces' ) . '</a></li>';
6447 }
6448 }
6449 return $form;
6450 }
6451
6452 /**
6453 * クレジットカード登録・変更ページ
6454 */
6455 public function member_update_settlement_form() {
6456 global $usces;
6457
6458 $member = $usces->get_member();
6459 $acting_opts = $this->get_acting_settings();
6460
6461 $form = '';
6462 $script = '';
6463 $done_message = '';
6464 $update_settlement_url = add_query_arg(
6465 array(
6466 'usces_page' => $usces->page,
6467 'settlement' => 1,
6468 're-enter' => 1,
6469 ),
6470 USCES_MEMBER_URL
6471 );
6472 $register = ( 'member_register_settlement' == $usces->page ) ? true : false;
6473 $deleted = false;
6474
6475 $cardlast4 = '';
6476 $expyy = '';
6477 $expmm = '';
6478
6479 $update = ( isset( $_POST['update'] ) ) ? $_POST['update'] : '';
6480 if ( 'register' == $update ) {
6481 check_admin_referer( 'member_update_settlement', 'wc_nonce' );
6482 $verify_action = wel_verify_update_settlement( $member['ID'] );
6483 if ( ! $verify_action ) {
6484 $usces->error_message .= '<p>' . __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '</p>';
6485 $register = false;
6486 } else {
6487 $token = ( isset( $_POST['token'] ) ) ? trim( $_POST['token'] ) : '';
6488 $customer = $this->customer_card_add( $member['ID'], $token );
6489 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
6490 $usces->error_message .= '<p>' . __( 'Credit card information is not appropriate.', 'usces' ) . '</p>';
6491 $done_message = __( 'Registration failed.', 'usces' );
6492 } else {
6493 $done_message = __( 'Successfully registered.', 'usces' );
6494 $register = false;
6495 }
6496 }
6497 } elseif ( 'update' == $update ) {
6498 check_admin_referer( 'member_update_settlement', 'wc_nonce' );
6499 $verify_action = wel_verify_update_settlement( $member['ID'] );
6500 if ( ! $verify_action ) {
6501 $usces->error_message .= '<p>' . __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '</p>';
6502 $register = false;
6503 } else {
6504 $token = ( isset( $_POST['token'] ) ) ? trim( $_POST['token'] ) : '';
6505 $customer = $this->customer_card_upd( $member['ID'], $token );
6506 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
6507 $usces->error_message .= '<p>' . __( 'Credit card information is not appropriate.', 'usces' ) . '</p>';
6508 $done_message = __( 'Update failed.', 'usces' );
6509 $register = true; /* 登録画面 */
6510 } else {
6511 $this->send_update_settlement_mail();
6512 $done_message = __( 'Successfully updated.', 'usces' );
6513 }
6514 }
6515 } elseif ( 'delete' == $update ) {
6516 check_admin_referer( 'member_update_settlement', 'wc_nonce' );
6517 $customer = $this->customer_card_del( $member['ID'] );
6518 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
6519 $usces->error_message .= '<p>' . __( 'Credit card information is not appropriate.', 'usces' ) . '</p>';
6520 $done_message = __( 'Deletion failed.', 'usces' );
6521 } else {
6522 $done_message = __( 'Successfully deleted.', 'usces' );
6523 $register = true;
6524 }
6525 }
6526
6527 $customer = $this->customer_ref( $member['ID'] );
6528 if ( ! empty( $customer ) && isset( $customer['card_number'] ) && isset( $customer['card_valid_term'] ) ) {
6529 $cardlast4 = substr( $customer['card_number'], -4 );
6530 $expyy = substr( $customer['card_valid_term'], 2, 2 );
6531 $expmm = substr( $customer['card_valid_term'], 0, 2 );
6532 }
6533 $form .= '<input name="acting" type="hidden" value="' . $this->paymod_id . '" />
6534 <table class="customer_form" id="' . $this->paymod_id . '">';
6535 if ( ! empty( $cardlast4 ) ) {
6536 $form .= '
6537 <tr>
6538 <th scope="row">' . __( 'The last four digits of your card number', 'usces' ) . '</th>
6539 <td colspan="2"><p>' . $cardlast4 . '</p></td>
6540 </tr>';
6541 }
6542 $cardno_attention = apply_filters( 'usces_filter_cardno_attention', __( '(Single-byte numbers only)', 'usces' ) . '<div class="attention">' . __( '* Please do not enter symbols or letters other than numbers such as space (blank), hyphen (-) between numbers.', 'usces' ) . '</div>' );
6543 $form .= '
6544 <tr>
6545 <th scope="row">' . __( 'card number', 'usces' ) . '</th>
6546 <td colspan="2"><input type="tel" class="card_number" id="card_number" maxlength="16" value="">' . $cardno_attention . '</td>
6547 </tr>';
6548 $form .= '
6549 <tr>
6550 <th scope="row">' . __( 'Card expiration', 'usces' ) . '</th>
6551 <td colspan="2">
6552 <select class="expire_month" id="expire_month">
6553 <option value=""' . ( empty( $expmm ) ? ' selected="selected"' : '' ) . '>--</option>';
6554 for ( $i = 1; $i <= 12; $i++ ) {
6555 $form .= '
6556 <option value="' . sprintf( '%02d', $i ) . '"' . ( ( $i == (int) $expmm ) ? ' selected="selected"' : '' ) . '>' . sprintf( '%2d', $i ) . '</option>';
6557 }
6558 $form .= '
6559 </select>' . __( 'month', 'usces' ) . '&nbsp;
6560 <select class="expire_year" id="expire_year">
6561 <option value=""' . ( empty( $expyy ) ? ' selected="selected"' : '' ) . '>--</option>';
6562 for ( $i = 0; $i < 15; $i++ ) {
6563 $year = date_i18n( 'Y' ) + $i;
6564 $year = substr( $year, -2 );
6565 $selected = ( $year == $expyy ) ? ' selected="selected"' : '';
6566 $form .= '
6567 <option value="' . $year . '"' . $selected . '>' . $year . '</option>';
6568 }
6569 $form .= '
6570 </select>' . __( 'year', 'usces' ) . '
6571 </td>
6572 </tr>';
6573 if ( 'on' == $acting_opts['use_card_conf_number'] ) {
6574 $seccd_attention = apply_filters( 'usces_filter_seccd_attention', __( '(Single-byte numbers only)', 'usces' ) );
6575 $form .= '
6576 <tr>
6577 <th scope="row">' . __( 'security code', 'usces' ) . '</th>
6578 <td colspan="2"><input type="tel" class="cvc" id="cvc" maxlength="4" value="">' . $seccd_attention . '</td>
6579 </tr>';
6580 }
6581 $form .= '
6582 </table>';
6583
6584 if ( '' != $done_message ) {
6585 $script .= '
6586 <script type="text/javascript">
6587 jQuery.event.add( window, "load", function() {
6588 alert( "' . $done_message . '" );
6589 });
6590 </script>';
6591 }
6592 $error_message = apply_filters( 'usces_filter_member_update_settlement_error_message', $usces->error_message );
6593
6594 ob_start();
6595 get_header();
6596 if ( '' != $script ) {
6597 echo $script; // no escape due to script.
6598 }
6599 ?>
6600 <div id="content" class="two-column">
6601 <div class="catbox">
6602 <?php
6603 if ( have_posts() ) :
6604 usces_remove_filter();
6605 ?>
6606 <div class="post" id="wc_member_update_settlement">
6607 <?php if ( $register ) : ?>
6608 <h1 class="member_page_title"><?php esc_html_e( 'Credit card registration', 'usces' ); ?></h1>
6609 <?php else : ?>
6610 <h1 class="member_page_title"><?php esc_html_e( 'Credit card update', 'usces' ); ?></h1>
6611 <?php endif; ?>
6612 <div class="entry">
6613 <div id="memberpages">
6614 <div class="whitebox">
6615 <div id="memberinfo">
6616 <div class="header_explanation"></div>
6617 <div class="error_message"><?php wel_esc_script_e( $error_message ); ?></div>
6618 <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;}">
6619 <?php wel_esc_script_e( $form ); ?>
6620 <div class="send">
6621 <input type="hidden" name="update" value="" />
6622 <input type="hidden" name="token" id="token" value="" />
6623 <input type="hidden" name="masked_card_number" id="masked_card_number" value="" />
6624 <input type="hidden" name="valid_until" id="valid_until" value="" />
6625 <input type="hidden" name="fingerprint" id="fingerprint" value="" />
6626 <input type="hidden" name="hc" id="hc" value="" />
6627 <?php if ( $register ) : ?>
6628 <input type="button" id="card-register" class="card-update" data-update_mode="register" value="<?php esc_attr_e( 'Register', 'usces' ); ?>" />
6629 <?php else : ?>
6630 <input type="button" id="card-update" class="card-update" data-update_mode="update" value="<?php esc_attr_e( 'Update', 'usces' ); ?>" />
6631 <?php if ( ! usces_have_member_continue_order( $member['ID'] ) && ! usces_have_member_regular_order( $member['ID'] ) ) : ?>
6632 <input type="button" id="card-delete" class="card-delete" data-update_mode="delete" value="<?php esc_attr_e( 'Delete', 'usces' ); ?>" />
6633 <?php endif; ?>
6634 <?php endif; ?>
6635 <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 ); ?>'" />
6636 <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() ); ?>'" />
6637 </div>
6638 <?php wp_nonce_field( 'member_update_settlement', 'wc_nonce' ); ?>
6639 </form>
6640 <div class="footer_explanation"></div>
6641 </div><!-- end of memberinfo -->
6642 </div><!-- end of whitebox -->
6643 </div><!-- end of memberpages -->
6644 </div><!-- end of entry -->
6645 </div><!-- end of post -->
6646 <?php else : ?>
6647 <p><?php esc_html_e( 'Sorry, no posts matched your criteria.', 'usces' ); ?></p>
6648 <?php endif; ?>
6649 </div><!-- end of catbox -->
6650 </div><!-- end of content -->
6651 <?php
6652 $sidebar = apply_filters( 'usces_filter_member_update_settlement_page_sidebar', 'cartmember' );
6653 if ( ! empty( $sidebar ) ) {
6654 get_sidebar( $sidebar );
6655 }
6656 get_footer();
6657 $contents = ob_get_contents();
6658 ob_end_clean();
6659 echo $contents; // no escape.
6660 }
6661
6662 /**
6663 * クレジットカード変更メール
6664 */
6665 public function send_update_settlement_mail() {
6666 global $usces;
6667
6668 $member = $usces->get_member();
6669
6670 $subject = apply_filters( 'usces_filter_send_update_settlement_mail_subject', __( 'Confirmation of credit card update', 'usces' ), $member );
6671 $mail_header = __( 'Your credit card information has been updated on the membership page.', 'usces' ) . "\r\n\r\n";
6672 $mail_footer = get_option( 'blogname' ) . "\r\n";
6673 $name = usces_localized_name( $member['name1'], $member['name2'], 'return' );
6674
6675 $message = '--------------------------------' . "\r\n";
6676 $message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
6677 $message .= __( 'Name', 'usces' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
6678 $message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
6679 $message .= '--------------------------------' . "\r\n\r\n";
6680 $message .= __( 'If you have not requested this email, sorry to trouble you, but please contact us.', 'usces' ) . "\r\n\r\n";
6681 $message = apply_filters( 'usces_filter_send_update_settlement_mail_message', $message, $member );
6682 $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";
6683 $message = sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n" . $message;
6684
6685 $send_para = array(
6686 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
6687 'to_address' => $member['mailaddress1'],
6688 'from_name' => get_option( 'blogname' ),
6689 'from_address' => $usces->options['sender_mail'],
6690 'reply_name' => get_option( 'blogname' ),
6691 'reply_to' => usces_get_first_order_mail(),
6692 'return_path' => $usces->options['sender_mail'],
6693 'subject' => $subject,
6694 'message' => do_shortcode( $message ),
6695 );
6696 usces_send_mail( $send_para );
6697
6698 $admin_message = $mail_header;
6699 $admin_message .= '--------------------------------' . "\r\n";
6700 $admin_message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
6701 $admin_message .= __( 'Name', 'usces' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
6702 $admin_message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
6703 $admin_message .= '--------------------------------' . "\r\n\r\n";
6704 if ( usces_have_member_continue_order( $member['ID'] ) ) {
6705 $admin_message .= $this->message_continue_order( $member['ID'] );
6706 }
6707 if ( usces_have_member_regular_order( $member['ID'] ) ) {
6708 $admin_message .= $this->message_regular_order( $member['ID'] );
6709 }
6710 $admin_message .=
6711 "\r\n----------------------------------------------------\r\n" .
6712 'REMOTE_ADDR : ' . $_SERVER['REMOTE_ADDR'] .
6713 "\r\n----------------------------------------------------\r\n";
6714
6715 $admin_para = array(
6716 'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
6717 'to_address' => $usces->options['order_mail'],
6718 'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
6719 'from_address' => $usces->options['sender_mail'],
6720 'reply_name' => get_option( 'blogname' ),
6721 'reply_to' => usces_get_first_order_mail(),
6722 'return_path' => $usces->options['sender_mail'],
6723 'subject' => $subject . '( ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . ' )',
6724 'message' => do_shortcode( $admin_message ),
6725 );
6726 usces_send_mail( $admin_para );
6727 }
6728
6729 /**
6730 * 契約中の自動継続課金�
6731
6732 *
6733 * @param int $member_id Member ID.
6734 */
6735 public function message_continue_order( $member_id ) {
6736 global $usces, $wpdb;
6737 $message = '';
6738
6739 $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' );
6740 $continue_order = $wpdb->get_results( $query, ARRAY_A );
6741 if ( 0 < count( $continue_order ) ) {
6742 $message .= '--------------------------------' . "\r\n";
6743 $message .= __( 'Auto-continuation charging Information under Contract with a credit card', 'usces' ) . "\r\n";
6744 foreach ( $continue_order as $continue_data ) {
6745 $con_id = $continue_data['con_id'];
6746 $con_order_id = $continue_data['con_order_id'];
6747 $message .= __( 'Order number', 'usces' ) . ' : ' . $con_order_id;
6748 $latest_log = $this->get_acting_latest_log( $con_order_id, 0, RESULT_STATUS_ALL );
6749 if ( ! empty( $latest_log ) ) {
6750 $next_charging = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_charging( $con_order_id ) : $continue_data['con_next_contracting'];
6751 $message .= ' ( ' . __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . date( __( 'Y/m/d' ), strtotime( $next_charging ) );
6752 if ( 0 < (int) $continue_data['con_interval'] ) {
6753 $next_contracting = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_contracting( $con_order_id ) : $continue_data['con_next_contracting'];
6754 $message .= ', ' . __( 'Renewal Date', 'dlseller' ) . ' : ' . date( __( 'Y/m/d' ), strtotime( $next_contracting ) );
6755 }
6756 $message .= ' )';
6757 if ( isset( $latest_log['result'] ) && RESULT_STATUS_NORMAL != $latest_log['result'] ) {
6758 $message .= ' ' . __( 'Condition', 'dlseller' ) . ' : ' . __( 'Settlement error', 'usces' );
6759 if ( ! empty( $latest_log['trading_id'] ) ) {
6760 $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $latest_log['trading_id'] . ' )';
6761 }
6762 }
6763 }
6764 $message .= "\r\n";
6765 }
6766 $message .= '--------------------------------' . "\r\n\r\n";
6767 }
6768 return $message;
6769 }
6770
6771 /**
6772 * 契約中の定期購�
6773 ��
6774
6775 *
6776 * @param int $member_id Member ID.
6777 */
6778 public function message_regular_order( $member_id ) {
6779 global $usces, $wpdb;
6780 $message = '';
6781
6782 $query_order = $wpdb->prepare(
6783 "SELECT r.reg_id, r.reg_payment_name, d.regdet_schedule_date
6784 FROM {$wpdb->prefix}usces_regular_detail AS `d`
6785 RIGHT JOIN {$wpdb->prefix}usces_regular AS `r` ON r.reg_id = d.reg_id
6786 WHERE r.reg_mem_id = %d AND d.regdet_condition = 'continuation'
6787 GROUP BY r.reg_id",
6788 $member_id
6789 );
6790 $regular_order = $wpdb->get_results( $query_order, ARRAY_A );
6791 if ( 0 < count( $regular_order ) ) {
6792 foreach ( $regular_order as $regular_data ) {
6793 $payment = $usces->getPayments( $regular_data['reg_payment_name'] );
6794 if ( isset( $payment['settlement'] ) && 'acting_paygent_card' != $payment['settlement'] ) {
6795 continue;
6796 }
6797 $reg_id = $regular_data['reg_id'];
6798 $query = $wpdb->prepare(
6799 "SELECT o.ID AS `order_id`, meta.meta_value AS `deco_id`, DATE_FORMAT( o.order_date, %s ) AS `order_date`
6800 FROM {$wpdb->prefix}usces_order AS `o`
6801 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta` ON o.ID = meta.order_id AND meta.meta_key = 'dec_order_id'
6802 LEFT JOIN {$wpdb->prefix}usces_regular ON o.ID = `reg_order_id`
6803 WHERE `reg_id` = %d
6804 UNION ALL
6805 SELECT o1.ID AS `order_id`, meta1.meta_value AS `deco_id`, DATE_FORMAT( o1.order_date, %s ) AS `order_date`
6806 FROM {$wpdb->prefix}usces_order AS `o1`
6807 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta1` ON o1.ID = meta1.order_id AND meta1.meta_key = 'dec_order_id'
6808 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta2` ON o1.ID = meta2.order_id AND meta2.meta_key = 'regular_id'
6809 WHERE meta2.meta_value = %d
6810 ORDER BY `order_id` DESC, `order_date` DESC",
6811 '%Y-%m-%d',
6812 $reg_id,
6813 '%Y-%m-%d',
6814 $reg_id
6815 );
6816 $regular_order_data = $wpdb->get_results( $query, ARRAY_A );
6817 if ( 0 < count( $regular_order_data ) ) {
6818 $message .= __( 'Regular ID', 'autodelivery' ) . ' : ' . $reg_id;
6819 $reg_order_id = $regular_order_data[0]['order_id'];
6820 $latest_log = $this->get_acting_latest_log( $reg_order_id, 0, RESULT_STATUS_ALL );
6821 if ( isset( $latest_log['result'] ) && RESULT_STATUS_NORMAL != $latest_log['result'] ) {
6822 $message .= ' ' . __( 'Condition', 'autodelivery' ) . ' : ' . __( 'Settlement error', 'usces' );
6823 $trading_id = $usces->get_order_meta_value( 'trading_id', $reg_order_id );
6824 if ( $trading_id ) {
6825 $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $trading_id . ' )';
6826 }
6827 } else {
6828 if ( $this->isdate( $regular_data['regdet_schedule_date'] ) ) {
6829 $message .= ' ( ' . __( 'Scheduled order date', 'autodelivery' ) . ' : ' . date( __( 'Y/m/d' ), strtotime( $regular_data['regdet_schedule_date'] ) ) . ' )';
6830 }
6831 }
6832 $message .= "\r\n";
6833 }
6834 }
6835 if ( '' != $message ) {
6836 $message = '--------------------------------' . "\r\n"
6837 . __( 'Subscription Information under Contract with a credit card', 'usces' ) . "\r\n"
6838 . $message
6839 . '--------------------------------' . "\r\n\r\n";
6840 }
6841 }
6842 return $message;
6843 }
6844
6845 /**
6846 * 日付チェック
6847 *
6848 * @param object $date DateTime.
6849 * @return boolean
6850 */
6851 private function isdate( $date ) {
6852 if ( empty( $date ) ) {
6853 return false;
6854 }
6855 try {
6856 new DateTime( $date );
6857 list( $year, $month, $day ) = explode( '-', $date );
6858 $res = checkdate( (int) $month, (int) $day, (int) $year );
6859 return $res;
6860 } catch ( Exception $e ) {
6861 return false;
6862 }
6863 }
6864
6865 /**
6866 * 会員データ編集画面 カード�
6867 報登録�
6868
6869 * usces_action_admin_member_info
6870 *
6871 * @param array $member Member data.
6872 * @param array $member_metas Member meta data.
6873 * @param array $usces_member_history Member's history order data.
6874 */
6875 public function admin_member_info( $member, $member_metas, $usces_member_history ) {
6876 if ( 0 < count( $usces_member_history ) ) :
6877 $acting_opts = $this->get_acting_settings();
6878 if ( isset( $acting_opts['card_activate'] ) && 'off' != $acting_opts['card_activate'] && 'on' == $acting_opts['stock_card_mode'] ) :
6879 $customer = $this->customer_ref( $member['ID'] );
6880 if ( ! empty( $customer ) && isset( $customer['card_number'] ) && isset( $customer['card_valid_term'] ) ) :
6881 $cardlast4 = substr( $customer['card_number'], -4 );
6882 $expyy = substr( $customer['card_valid_term'], 2, 2 );
6883 $expmm = substr( $customer['card_valid_term'], 0, 2 );
6884 ?>
6885 <tr>
6886 <td class="label"><?php esc_html_e( 'Lower 4 digits', 'usces' ); ?></td>
6887 <td><div class="rod_left shortm"><?php echo esc_html( $cardlast4 ); ?></div></td>
6888 </tr>
6889 <tr>
6890 <td class="label"><?php esc_html_e( 'Expiration date', 'usces' ); ?></td>
6891 <td><div class="rod_left shortm"><?php echo esc_html( $expmm . '/' . $expyy ); ?></div></td>
6892 </tr>
6893 <tr>
6894 <td class="label">カード�
6895 </td>
6896 <td><div class="rod_left shortm"><?php esc_html_e( 'Registered', 'usces' ); ?></div></td>
6897 </tr>
6898 <?php
6899 if ( ! usces_have_member_continue_order( $member['ID'] ) && ! usces_have_member_regular_order( $member['ID'] ) ) :
6900 ?>
6901 <tr>
6902 <td class="label"><input type="checkbox" name="paygent_stock_card_mode" id="paygent-stock_card_mode-release" value="release"></td>
6903 <td><label for="paygent-stock_card_mode-release">カード�
6904 報の登録を解除する</label></td>
6905 </tr>
6906 <?php
6907 endif;
6908 endif;
6909 endif;
6910 endif;
6911 }
6912
6913 /**
6914 * 会員データ編集画面 カード�
6915 報登録解除
6916 * usces_action_post_update_memberdata
6917 *
6918 * @param int $member_id Member ID.
6919 * @param boolean $res Result.
6920 */
6921 public function admin_update_memberdata( $member_id, $res ) {
6922 if ( ! $this->is_activate_card() || false === $res ) {
6923 return;
6924 }
6925 if ( isset( $_POST['paygent_stock_card_mode'] ) && 'release' == $_POST['paygent_stock_card_mode'] ) {
6926 $this->customer_card_del( $member_id );
6927 }
6928 }
6929
6930 /**
6931 * 利用可能な支払方法(継続課金・定期購�
6932 �)
6933 * dlseller_filter_the_payment_method_restriction
6934 * wcad_filter_the_payment_method_restriction
6935 *
6936 * @param array $payments_restriction Payment method.
6937 * @param string $value Input value.
6938 * @return array
6939 */
6940 public function payment_method_restriction( $payments_restriction, $value ) {
6941 if ( ( usces_have_regular_order() || usces_have_continue_charge() ) && usces_is_login() ) {
6942 $paygent_card = false;
6943 foreach ( (array) $payments_restriction as $key => $payment ) {
6944 if ( isset( $payment['settlement'] ) && 'acting_paygent_card' == $payment['settlement'] ) {
6945 $paygent_card = true;
6946 }
6947 }
6948 if ( ! $paygent_card ) {
6949 $payments = usces_get_system_option( 'usces_payment_method', 'settlement' );
6950 $payments_restriction[] = $payments['acting_paygent_card'];
6951 }
6952 $sort = array();
6953 foreach ( (array) $payments_restriction as $key => $payment ) {
6954 $sort[ $key ] = $payment['sort'];
6955 }
6956 array_multisort( $sort, SORT_ASC, $payments_restriction );
6957 }
6958 return $payments_restriction;
6959 }
6960
6961 /**
6962 * 利用可能な支払方法
6963 * usces_filter_the_continue_payment_method
6964 *
6965 * @param array $payment_method Payment method.
6966 * @return array
6967 */
6968 public function continuation_payment_method( $payment_method ) {
6969 if ( ! array_key_exists( 'acting_paygent_card', $payment_method ) ) {
6970 $payment_method[] = 'acting_paygent_card';
6971 }
6972 return $payment_method;
6973 }
6974
6975 /**
6976 * 「初回引落し日」
6977 * dlseller_filter_first_charging
6978 *
6979 * @param object $time Datetime.
6980 * @param int $post_id Post ID.
6981 * @param array $usces_item Item data.
6982 * @param int $order_id Order number.
6983 * @param array $continue_data Continuation data.
6984 * @return object
6985 */
6986 public function first_charging_date( $time, $post_id, $usces_item, $order_id, $continue_data ) {
6987 if ( 99 === (int) $usces_item['item_chargingday'] ) {
6988 if ( empty( $order_id ) ) {
6989 $today = date_i18n( 'Y-m-d', current_time( 'timestamp' ) );
6990 list( $year, $month, $day ) = explode( '-', $today );
6991 $time = mktime( 0, 0, 0, (int) $month, (int) $day, (int) $year );
6992 }
6993 }
6994 return $time;
6995 }
6996
6997 /**
6998 * 継続課金会員リスト「状�
6999 �」
7000 * dlseller_filter_continue_member_list_condition
7001 *
7002 * @param string $condition Continuation condition.
7003 * @param int $member_id Member ID.
7004 * @param int $order_id Order number.
7005 * @param array $continue_data Continuation data.
7006 * @return string
7007 */
7008 public function continue_member_list_condition( $condition, $member_id, $order_id, $continue_data ) {
7009 global $usces;
7010
7011 if ( isset( $continue_data['acting'] ) && 'acting_paygent_card' == $continue_data['acting'] ) {
7012 $url = admin_url( 'admin.php?page=usces_continue&continue_action=settlement_paygent_card&member_id=' . esc_attr( $member_id ) . '&order_id=' . esc_attr( $order_id ) );
7013 $condition = '<a href="' . $url . '">' . __( 'Detail', 'usces' ) . '</a>';
7014 if ( 'continuation' == $continue_data['status'] ) {
7015 $latest_log = $this->get_acting_latest_log( $order_id, 0, RESULT_STATUS_ALL );
7016 if ( isset( $latest_log['result'] ) && RESULT_STATUS_NORMAL != $latest_log['result'] ) {
7017 $condition .= '<div class="acting-status paygent-error">' . __( 'Settlement error', 'usces' ) . '</div>';
7018 }
7019 }
7020 }
7021 return $condition;
7022 }
7023
7024 /**
7025 * 継続課金会員決済状況ページ表示
7026 * dlseller_action_continue_member_list_page
7027 *
7028 * @param string $continue_action Continuation action.
7029 */
7030 public function continue_member_list_page( $continue_action ) {
7031 if ( 'settlement_paygent_card' == $continue_action ) {
7032 $member_id = ( isset( $_GET['member_id'] ) ) ? wp_unslash( $_GET['member_id'] ) : '';
7033 $order_id = ( isset( $_GET['order_id'] ) ) ? wp_unslash( $_GET['order_id'] ) : '';
7034 if ( ! empty( $member_id ) && ! empty( $order_id ) ) {
7035 $this->continue_member_settlement_info_page( $member_id, $order_id );
7036 exit();
7037 }
7038 }
7039 }
7040
7041 /**
7042 * 継続課金会員決済詳細ページ
7043 *
7044 * @param int $member_id Member ID.
7045 * @param int $order_id Order number.
7046 */
7047 public function continue_member_settlement_info_page( $member_id, $order_id ) {
7048 global $usces;
7049
7050 $order_data = $usces->get_order_data( $order_id, 'direct' );
7051 if ( ! $order_data ) {
7052 return;
7053 }
7054
7055 $payment = $usces->getPayments( $order_data['order_payment_name'] );
7056 if ( isset( $payment['settlement'] ) && 'acting_paygent_card' != $payment['settlement'] ) {
7057 return;
7058 }
7059
7060 $continue_data = $this->get_continuation_data( $member_id, $order_id );
7061 if ( 'acting_paygent_card' != $continue_data['acting'] ) {
7062 return;
7063 }
7064
7065 $con_id = $continue_data['con_id'];
7066 $curent_url = esc_url( $_SERVER['REQUEST_URI'] );
7067
7068 $member_info = $usces->get_member_info( $member_id );
7069 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
7070
7071 $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
7072 if ( ! empty( $contracted_date ) ) {
7073 list( $contracted_year, $contracted_month, $contracted_day ) = explode( '-', $contracted_date );
7074 } else {
7075 $contracted_year = 0;
7076 $contracted_month = 0;
7077 $contracted_day = 0;
7078 }
7079 $charged_date = ( empty( $continue_data['chargedday'] ) ) ? dlseller_next_charging( $order_id ) : $continue_data['chargedday'];
7080 if ( ! empty( $charged_date ) ) {
7081 list( $charged_year, $charged_month, $charged_day ) = explode( '-', $charged_date );
7082 } else {
7083 $charged_year = 0;
7084 $charged_month = 0;
7085 $charged_day = 0;
7086 }
7087 $this_year = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 4 );
7088
7089 $log_data = $this->get_acting_log( $order_id, 0, RESULT_STATUS_ALL );
7090 $num = ( $log_data ) ? count( $log_data ) : 1;
7091 ?>
7092 <div class="wrap">
7093 <div class="usces_admin">
7094 <h1>Welcart Management <?php esc_html_e( 'Continuation charging member information', 'dlseller' ); ?></h1>
7095 <p class="version_info">Version <?php echo esc_html( WCEX_DLSELLER_VERSION ); ?></p>
7096 <?php usces_admin_action_status(); ?>
7097 <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>
7098 <div id="datatable">
7099 <div id="tablesearch" class="usces_tablesearch">
7100 <div id="searchBox" style="display:block">
7101 <table class="search_table">
7102 <tr>
7103 <td class="label"><?php esc_html_e( 'Continuation charging information', 'dlseller' ); ?></td>
7104 <td>
7105 <table class="order_info">
7106 <tr>
7107 <th><?php esc_html_e( 'Member ID', 'dlseller' ); ?></th>
7108 <td><?php echo esc_html( $member_id ); ?></td>
7109 <th><?php esc_html_e( 'Contractor name', 'dlseller' ); ?></th>
7110 <td><?php echo esc_html( $name ); ?></td>
7111 </tr>
7112 <tr>
7113 <th><?php esc_html_e( 'Order ID', 'dlseller' ); ?></th>
7114 <td><?php echo esc_html( $order_id ); ?></td>
7115 <th><?php esc_html_e( 'Application Date', 'dlseller' ); ?></th>
7116 <td><?php echo esc_html( $order_data['order_date'] ); ?></td>
7117 </tr>
7118 <tr>
7119 <th><?php esc_html_e( 'Renewal Date', 'dlseller' ); ?></th>
7120 <td>
7121 <?php
7122 echo '<select id="contracted-year">';
7123 if ( 0 == (int) $contracted_year ) {
7124 echo '<option value="0" selected="selected"></option>';
7125 } else {
7126 echo '<option value="0"></option>';
7127 }
7128 for ( $i = 0; $i <= 10; $i++ ) {
7129 $year = (int) $this_year + $i;
7130 if ( (int) $contracted_year == $year ) {
7131 echo "<option value=\"{$year}\" selected=\"selected\">{$year}</option>";
7132 } else {
7133 echo "<option value=\"{$year}\">{$year}</option>";
7134 }
7135 }
7136 echo '</select>-<select id="contracted-month">';
7137 if ( 0 == (int) $contracted_month ) {
7138 echo '<option value="0" selected="selected"></option>';
7139 } else {
7140 echo '<option value="0"></option>';
7141 }
7142 for ( $i = 1; $i <= 12; $i++ ) {
7143 $month = sprintf( '%02d', $i );
7144 if ( (int) $contracted_month == $i ) {
7145 echo "<option value=\"{$month}\" selected=\"selected\">{$month}</option>";
7146 } else {
7147 echo "<option value=\"{$month}\">{$month}</option>";
7148 }
7149 }
7150 echo '</select>-<select id="contracted-day">';
7151 if ( 0 == (int) $contracted_day ) {
7152 echo '<option value="0" selected="selected"></option>';
7153 } else {
7154 echo '<option value="0"></option>';
7155 }
7156 for ( $i = 1; $i <= 31; $i++ ) {
7157 $day = sprintf( '%02d', $i );
7158 if ( (int) $contracted_day == $i ) {
7159 echo "<option value=\"{$day}\" selected=\"selected\">{$day}</option>";
7160 } else {
7161 echo "<option value=\"{$day}\">{$day}</option>";
7162 }
7163 }
7164 echo '</select>';
7165 ?>
7166 </td>
7167 <th><?php _e( 'Next Withdrawal Date', 'dlseller' ); ?></th>
7168 <td>
7169 <?php
7170 echo '<select id="charged-year">';
7171 if ( 0 == (int) $charged_year ) {
7172 echo '<option value="0" selected="selected"></option>';
7173 } else {
7174 echo '<option value="0"></option>';
7175 }
7176 if ( $charged_year == $this_year ) {
7177 echo "<option value=\"{$this_year}\" selected=\"selected\">{$this_year}</option>";
7178 } else {
7179 echo "<option value=\"{$this_year}\">{$this_year}</option>";
7180 }
7181 $next_year = (int) $this_year + 1;
7182 if ( $charged_year == $next_year ) {
7183 echo "<option value=\"{$next_year}\" selected=\"selected\">{$next_year}</option>";
7184 } else {
7185 echo "<option value=\"{$next_year}\">{$next_year}</option>";
7186 }
7187 echo '</select>-<select id="charged-month">';
7188 if ( 0 == $charged_month ) {
7189 echo '<option value="0" selected="selected"></option>';
7190 } else {
7191 echo '<option value="0"></option>';
7192 }
7193 for ( $i = 1; $i <= 12; $i++ ) {
7194 $month = sprintf( '%02d', $i );
7195 if ( (int) $charged_month == $i ) {
7196 echo "<option value=\"{$month}\" selected=\"selected\">{$month}</option>";
7197 } else {
7198 echo "<option value=\"{$month}\">{$month}</option>";
7199 }
7200 }
7201 echo '</select>-<select id="charged-day">';
7202 if ( 0 == $charged_day ) {
7203 echo '<option value="0" selected="selected"></option>';
7204 } else {
7205 echo '<option value="0"></option>';
7206 }
7207 for ( $i = 1; $i <= 31; $i++ ) {
7208 $day = sprintf( '%02d', $i );
7209 if ( (int) $charged_day == $i ) {
7210 echo "<option value=\"{$day}\" selected=\"selected\">{$day}</option>";
7211 } else {
7212 echo "<option value=\"{$day}\">{$day}</option>";
7213 }
7214 }
7215 echo '</select>';
7216 ?>
7217 </td>
7218 </tr>
7219 <tr>
7220 <th><?php esc_html_e( 'Amount on order', 'usces' ); ?></th>
7221 <td><?php usces_crform( $continue_data['order_price'], false ); ?></td>
7222 <th><?php esc_html_e( 'Transaction amount', 'usces' ); ?></th>
7223 <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>
7224 </tr>
7225 <tr>
7226 <th><?php esc_html_e( 'Status', 'dlseller' ); ?></th>
7227 <td><select id="dlseller-status">
7228 <?php ob_start(); ?>
7229 <?php if ( 'continuation' == $continue_data['status'] ) : ?>
7230 <option value="continuation" selected="selected"><?php esc_html_e( 'Continuation', 'dlseller' ); ?></option>
7231 <option value="cancellation"><?php esc_html_e( 'Stop', 'dlseller' ); ?></option>
7232 <?php else : ?>
7233 <option value="cancellation" selected="selected"><?php esc_html_e( 'Cancellation', 'dlseller' ); ?></option>
7234 <option value="continuation"><?php esc_html_e( 'Resumption', 'dlseller' ); ?></option>
7235 <?php endif; ?>
7236 <?php
7237 $dlseller_status_options = ob_get_contents();
7238 ob_end_clean();
7239 $dlseller_status_options = apply_filters( 'usces_filter_continuation_charging_status_options', $dlseller_status_options, $continue_data );
7240 wel_esc_script_e( $dlseller_status_options );
7241 ?>
7242 </select></td>
7243 <td colspan="2"><input id="continuation-update" type="button" class="button button-primary" value="<?php _e( 'Update' ); ?>" /></td>
7244 </tr>
7245 </table>
7246 <?php do_action( 'usces_action_continuation_charging_information', $continue_data, $member_id, $order_id ); ?>
7247 </td>
7248 </tr>
7249 </table>
7250 </div><!-- searchBox -->
7251 </div><!-- tablesearch -->
7252 <table id="mainDataTable" class="new-table order-new-table">
7253 <thead>
7254 <tr>
7255 <th scope="col">&nbsp;</th>
7256 <th scope="col"><?php esc_html_e( 'Processing date', 'usces' ); ?></th>
7257 <th scope="col"><?php esc_html_e( 'Transaction ID', 'usces' ); ?></th>
7258 <th scope="col"><?php esc_html_e( 'Settlement amount', 'usces' ); ?></th>
7259 <th scope="col"><?php esc_html_e( 'Processing classification', 'usces' ); ?></th>
7260 <th scope="col">&nbsp;</th>
7261 </tr>
7262 </thead>
7263 <?php
7264 $trading_id = '';
7265 foreach ( (array) $log_data as $data ) :
7266 if ( isset( $data['tracking_id'] ) ) :
7267 if ( $trading_id == $data['tracking_id'] ) :
7268 continue;
7269 endif;
7270 $trading_id = $data['tracking_id'];
7271 endif;
7272 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id, RESULT_STATUS_ALL );
7273 if ( $latest_log ) :
7274 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
7275 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
7276 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) :
7277 $status = 'reference_error';
7278 $class = ' card-error';
7279 $status_name = $this->get_status_name( $status );
7280 $amount = usces_crform( $latest_log['amount'], false, true, 'return', true );
7281 else :
7282 $payment_status = $settlement_ref['payment_status'];
7283 $status = $this->get_status( $payment_status );
7284 $class = ' card-' . $status;
7285 $status_name = $this->get_status_name( $payment_status );
7286 $amount = usces_crform( $settlement_ref['payment_amount'], false, true, 'return', true );
7287 endif;
7288 ?>
7289 <tbody>
7290 <tr>
7291 <td><?php echo esc_html( $num ); ?></td>
7292 <td><?php echo esc_html( $data['datetime'] ); ?></td>
7293 <td><?php echo esc_html( $trading_id ); ?></td>
7294 <td class="amount"><?php echo esc_attr( $amount ); ?></td>
7295 <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>
7296 <td>
7297 <input type="button" class="button settlement-information" id="settlement-information-<?php echo esc_attr( $trading_id ); ?>" data-trading_id="<?php echo esc_attr( $trading_id ); ?>" data-num="<?php echo esc_attr( $num ); ?>" value="<?php esc_attr_e( 'Settlement info', 'usces' ); ?>">
7298 </td>
7299 </tr>
7300 </tbody>
7301 <?php
7302 $num--;
7303 endif;
7304 endforeach;
7305 ?>
7306 </table>
7307 </div><!--datatable-->
7308 <input name="member_id" type="hidden" id="member_id" value="<?php echo esc_attr( $member_id ); ?>" />
7309 <input name="order_id" type="hidden" id="order_id" value="<?php echo esc_attr( $order_id ); ?>" />
7310 <input name="con_id" type="hidden" id="con_id" value="<?php echo esc_attr( $con_id ); ?>" />
7311 <input name="usces_referer" type="hidden" id="usces_referer" value="<?php echo urlencode( $curent_url ); ?>" />
7312 <?php wp_nonce_field( 'order_edit', 'wc_nonce' ); ?>
7313 </div><!--usces_admin-->
7314 </div><!--wrap-->
7315 <?php
7316 $order_action = 'edit';
7317 $cart = array();
7318 $action_args = compact( 'order_action', 'order_id', 'cart' );
7319 $this->settlement_dialog( $order_data, $action_args );
7320 include ABSPATH . 'wp-admin/admin-footer.php';
7321 }
7322
7323 /**
7324 * 自動継続課金処理
7325 * dlseller_action_do_continuation_charging
7326 *
7327 * @param string $today Today.
7328 * @param int $member_id Member ID.
7329 * @param int $order_id Order number.
7330 * @param array $continue_data Continuation data.
7331 */
7332 public function auto_continuation_charging( $today, $member_id, $order_id, $continue_data ) {
7333 global $usces;
7334
7335 $acting_opts = $this->get_acting_settings();
7336 if ( ! usces_is_membersystem_state() || 'on' != $acting_opts['stock_card_mode'] ) {
7337 return;
7338 }
7339
7340 if ( 0 >= $continue_data['price'] ) {
7341 return;
7342 }
7343
7344 if ( 'acting_paygent_card' != $continue_data['acting'] ) {
7345 return;
7346 }
7347
7348 $order_data = $usces->get_order_data( $order_id, 'direct' );
7349 if ( ! $order_data || $usces->is_status( 'cancel', $order_data['order_status'] ) ) {
7350 return;
7351 }
7352
7353 $trading_id = usces_acting_key();
7354 $customer = $this->customer_ref( $member_id );
7355 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id && isset( $customer['customer_card_id'] ) ) {
7356 $telegram_kind = PAYGENT_CREDIT;
7357 $amount = usces_crform( $continue_data['price'], false, false, 'return', false );
7358
7359 $pm = Paygent_Module::get_instance();
7360 $pm->init();
7361 $pm->req_put( 'trading_id', $trading_id );
7362 $pm->req_put( 'payment_amount', $amount );
7363 $pm->req_put( 'payment_class', '10' );
7364 $pm->req_put( '3dsecure_ryaku', '1' );
7365 $pm->req_put( 'stock_card_mode', '1' );
7366 $pm->req_put( 'customer_id', $member_id );
7367 $pm->req_put( 'customer_card_id', $customer['customer_card_id'] );
7368 $pm->req_put( 'sales_mode', $acting_opts['sales_mode_dlseller'] );
7369
7370 $result_post = $pm->post( $telegram_kind );
7371 $result_status = $pm->get_result_status();
7372 if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
7373 $response_data = array(
7374 'result' => $result_post,
7375 'result_status' => $result_status,
7376 'response_code' => $pm->get_response_code(),
7377 'response_detail' => $pm->get_response_detail(),
7378 'result_message' => $pm->get_result_message(),
7379 );
7380 $response_code = ( true !== $result_post ) ? $result_post : $pm->get_response_code();
7381 $log = array(
7382 'acting' => 'paygent_card',
7383 'key' => $trading_id,
7384 'result' => $response_code,
7385 'data' => $response_data,
7386 );
7387 usces_save_order_acting_error( $log );
7388 $this->save_acting_log( $response_data, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
7389 $this->auto_settlement_error_mail( $member_id, $order_id, $response_data, $continue_data );
7390 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $response_data );
7391 } else {
7392 $response_data = $pm->get_response_data();
7393 $payment_id = ( isset( $response_data['payment_id'] ) ) ? $response_data['payment_id'] : '';
7394 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
7395 $settlement_ref = apply_filters( 'usces_filter_paygent_card_auto_continuation_charging_log', $settlement_ref, $order_id, $trading_id );
7396 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
7397 $this->save_acting_log( $settlement_ref, 'paygent_card', 'reference_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
7398 } else {
7399 $this->save_acting_log( $settlement_ref, 'paygent_card', $settlement_ref['payment_status'], RESULT_STATUS_NORMAL, $order_id, $trading_id );
7400 }
7401 $this->auto_settlement_mail( $member_id, $order_id, $settlement_ref, $continue_data );
7402 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $settlement_ref );
7403 }
7404 } else {
7405 $result = ( isset( $customer['result'] ) ) ? $customer['result'] : 'error';
7406 $log = array(
7407 'acting' => 'paygent_card(member_process)',
7408 'key' => $member_id,
7409 'result' => $result,
7410 'data' => $customer,
7411 );
7412 usces_save_order_acting_error( $log );
7413 if ( ! isset( $customer['payment_type'] ) ) {
7414 $customer['payment_type'] = PAYMENT_TYPE_CREDIT;
7415 }
7416 $this->save_acting_log( $customer, 'paygent_card', 'customer_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
7417 $this->auto_settlement_error_mail( $member_id, $order_id, $customer, $continue_data );
7418 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $customer );
7419 }
7420 }
7421
7422 /**
7423 * 自動継続課金処理メール(正常)
7424 *
7425 * @param int $member_id Member ID.
7426 * @param int $order_id Order number.
7427 * @param array $data Response data.
7428 * @param array $continue_data Continuation data.
7429 */
7430 public function auto_settlement_mail( $member_id, $order_id, $data, $continue_data ) {
7431 global $usces;
7432
7433 $acting_opts = $this->get_acting_settings();
7434 $order_data = $usces->get_order_data( $order_id, 'direct' );
7435 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data, false );
7436
7437 if ( 'on' == $acting_opts['auto_settlement_mail'] ) {
7438 $subject = apply_filters( 'usces_filter_paygent_auto_settlement_mail_subject', __( 'Announcement of automatic continuing charging process', 'usces' ), $member_id, $order_id, $order_data, $data, $continue_data );
7439 $member_info = $usces->get_member_info( $member_id );
7440 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
7441 $mail_data = usces_mail_data();
7442 $mail_header = '';
7443 if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
7444 $mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
7445 }
7446 $mail_header .= __( 'We will report automated accounting process was carried out as follows.', 'usces' ) . "\r\n\r\n";
7447 $mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
7448 $message = apply_filters( 'usces_filter_paygent_auto_settlement_mail_header', $mail_header, $member_id, $order_id, $order_data, $data, $continue_data ) .
7449 apply_filters( 'usces_filter_paygent_auto_settlement_mail_body', $mail_body, $member_id, $order_id, $order_data, $data, $continue_data ) .
7450 apply_filters( 'usces_filter_paygent_auto_settlement_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $data, $continue_data );
7451 $headers = apply_filters( 'usces_filter_paygent_auto_settlement_mail_headers', '' );
7452 $to_customer = array(
7453 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
7454 'to_address' => $member_info['mem_email'],
7455 'from_name' => get_option( 'blogname' ),
7456 'from_address' => $usces->options['sender_mail'],
7457 'reply_name' => get_option( 'blogname' ),
7458 'reply_to' => usces_get_first_order_mail(),
7459 'return_path' => $usces->options['sender_mail'],
7460 'subject' => $subject,
7461 'message' => do_shortcode( $message ),
7462 'headers' => $headers,
7463 );
7464 usces_send_mail( $to_customer );
7465 }
7466
7467 $ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
7468 $this->continuation_charging_mail['OK'] = $ok + 1;
7469 $this->continuation_charging_mail['mail'][] = $mail_body;
7470 }
7471
7472 /**
7473 * 自動継続課金処理メール(エラー)
7474 *
7475 * @param int $member_id Member ID.
7476 * @param int $order_id Order number.
7477 * @param array $data Response data.
7478 * @param array $continue_data Continuation data.
7479 */
7480 public function auto_settlement_error_mail( $member_id, $order_id, $data, $continue_data ) {
7481 global $usces;
7482
7483 $acting_opts = $this->get_acting_settings();
7484 $order_data = $usces->get_order_data( $order_id, 'direct' );
7485 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data, false );
7486
7487 if ( 'on' == $acting_opts['auto_settlement_mail'] ) {
7488 $subject = apply_filters( 'usces_filter_paygent_auto_settlement_error_mail_subject', __( 'Announcement of automatic continuing charging process', 'usces' ), $member_id, $order_id, $order_data, $data, $continue_data );
7489 $member_info = $usces->get_member_info( $member_id );
7490 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
7491 $mail_data = usces_mail_data();
7492 $mail_header = '';
7493 if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
7494 $mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
7495 }
7496 $mail_header .= __( 'We will reported that an error occurred in automated accounting process.', 'usces' ) . "\r\n\r\n";
7497 $mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
7498 $message = apply_filters( 'usces_filter_paygent_auto_settlement_error_mail_header', $mail_header, $member_id, $order_id, $order_data, $data, $continue_data ) .
7499 apply_filters( 'usces_filter_paygent_auto_settlement_error_mail_body', $mail_body, $member_id, $order_id, $order_data, $data, $continue_data ) .
7500 apply_filters( 'usces_filter_paygent_auto_settlement_error_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $data, $continue_data );
7501 $headers = apply_filters( 'usces_filter_paygent_auto_settlement_error_mail_headers', '' );
7502 $to_customer = array(
7503 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
7504 'to_address' => $member_info['mem_email'],
7505 'from_name' => get_option( 'blogname' ),
7506 'from_address' => $usces->options['sender_mail'],
7507 'reply_name' => get_option( 'blogname' ),
7508 'reply_to' => usces_get_first_order_mail(),
7509 'return_path' => $usces->options['sender_mail'],
7510 'subject' => $subject,
7511 'message' => do_shortcode( $message ),
7512 'headers' => $headers,
7513 );
7514 usces_send_mail( $to_customer );
7515 }
7516
7517 $error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
7518 $this->continuation_charging_mail['NG'] = $error + 1;
7519 $this->continuation_charging_mail['mail'][] = $mail_body;
7520 }
7521
7522 /**
7523 * 自動継続課金処理メール本文
7524 *
7525 * @param int $member_id Member ID.
7526 * @param int $order_id Order number.
7527 * @param array $order_data Order data.
7528 * @param array $data Response data.
7529 * @param array $continue_data Continuation data.
7530 * @param boolean $html
7531 * @return string
7532 */
7533 public function auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data, $html = true ) {
7534 global $usces;
7535
7536 $member_info = $usces->get_member_info( $member_id );
7537 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
7538 $contracted_date = ( isset( $continue_data['contractedday'] ) ) ? $continue_data['contractedday'] : '';
7539 $charged_date = ( isset( $continue_data['chargedday'] ) ) ? $continue_data['chargedday'] : '';
7540
7541 $cart = usces_get_ordercartdata( $order_id );
7542 if ( is_array( $cart ) && 0 < count( $cart ) ) {
7543 $cart_row = current( $cart );
7544 $item_name = $usces->getCartItemName_byOrder( $cart_row );
7545 $options = ( isset( $cart_row['options'] ) ) ? $cart_row['options'] : array();
7546 }
7547
7548 if ( usces_is_html_mail() && $html ) {
7549 $message = '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;"><tbody>';
7550 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7551 $message .= __( 'Order ID', 'dlseller' );
7552 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7553 $message .= $order_id;
7554 $message .= '</td></tr>';
7555
7556 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7557 $message .= __( 'Application Date', 'dlseller' );
7558 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7559 $message .= $order_data['order_date'];
7560 $message .= '</td></tr>';
7561
7562 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7563 $message .= __( 'Member ID', 'dlseller' );
7564 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7565 $message .= $member_id;
7566 $message .= '</td></tr>';
7567
7568 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7569 $message .= __( 'Contractor name', 'dlseller' );
7570 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7571 $message .= sprintf( _x( '%s', 'honorific', 'usces' ), $name );
7572 $message .= '</td></tr>';
7573 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7574 $message .= __( 'Items', 'usces' );
7575 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7576 $message .= $item_name;
7577 if ( is_array( $options ) && 0 < count( $options ) ) {
7578 $optstr = '';
7579 foreach ( $options as $key => $value ) {
7580 if ( ! empty( $key ) ) {
7581 $key = urldecode( $key );
7582 $value = maybe_unserialize( $value );
7583 if ( is_array( $value ) ) {
7584 $c = '';
7585 $optstr .= '( ' . $key . ' : ';
7586 foreach ( $value as $v ) {
7587 $optstr .= $c . rawurldecode( $v );
7588 $c = ', ';
7589 }
7590 $optstr .= ' )<br>';
7591 } else {
7592 $optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . ' )<br>';
7593 }
7594 }
7595 }
7596 $message .= $optstr;
7597 }
7598 $message .= '</td></tr>';
7599
7600 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7601 $message .= __( 'Settlement amount', 'usces' );
7602 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7603 $message .= usces_crform( $continue_data['price'], true, false, 'return' );
7604 $message .= '</td></tr>';
7605 if ( isset( $data['reminder'] ) ) {
7606 if ( ! empty( $charged_date ) ) {
7607 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7608 $message .= __( 'Next Withdrawal Date', 'dlseller' );
7609 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7610 $message .= $charged_date;
7611 $message .= '</td></tr>';
7612 }
7613 if ( ! empty( $contracted_date ) ) {
7614 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7615 $message .= __( 'Renewal Date', 'dlseller' );
7616 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7617 $message .= $contracted_date;
7618 $message .= '</td></tr>';
7619 }
7620 } else {
7621 if ( ! empty( $charged_date ) ) {
7622 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7623 $message .= __( 'Next Withdrawal Date', 'dlseller' );
7624 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7625 $message .= $charged_date;
7626 $message .= '</td></tr>';
7627 }
7628 if ( ! empty( $contracted_date ) ) {
7629 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7630 $message .= __( 'Renewal Date', 'dlseller' );
7631 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7632 $message .= $contracted_date;
7633 $message .= '</td></tr>';
7634 }
7635
7636 if ( isset( $data['result_status'] ) && RESULT_STATUS_ERROR == $data['result_status'] ) {
7637 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7638 $message .= __( 'Result', 'usces' );
7639 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7640 $message .= __( 'Error', 'usces' );
7641 $message .= '</td></tr>';
7642 } else {
7643 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7644 $message .= __( 'Result', 'usces' );
7645 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7646 $message .= __( 'Normal done', 'usces' );
7647 $message .= '</td></tr>';
7648 }
7649 }
7650 $message .= '</tbody></table>';
7651
7652 } else {
7653 $message = usces_mail_line( 2 ); // --------------------
7654 $message .= __( 'Order ID', 'dlseller' ) . ' : ' . $order_id . "\r\n";
7655 $message .= __( 'Application Date', 'dlseller' ) . ' : ' . $order_data['order_date'] . "\r\n";
7656 $message .= __( 'Member ID', 'dlseller' ) . ' : ' . $member_id . "\r\n";
7657 $message .= __( 'Contractor name', 'dlseller' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
7658
7659 $message .= __( 'Items', 'usces' ) . ' : ' . $item_name . "\r\n";
7660 if ( is_array( $options ) && 0 < count( $options ) ) {
7661 $optstr = '';
7662 foreach ( $options as $key => $value ) {
7663 if ( ! empty( $key ) ) {
7664 $key = urldecode( $key );
7665 $value = maybe_unserialize( $value );
7666 if ( is_array( $value ) ) {
7667 $c = '';
7668 $optstr .= '( ' . $key . ' : ';
7669 foreach ( $value as $v ) {
7670 $optstr .= $c . rawurldecode( $v );
7671 $c = ', ';
7672 }
7673 $optstr .= " )\r\n";
7674 } else {
7675 $optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . " )\r\n";
7676 }
7677 }
7678 }
7679 $message .= $optstr;
7680 }
7681
7682 $message .= __( 'Settlement amount', 'usces' ) . ' : ' . usces_crform( $continue_data['price'], true, false, 'return' ) . "\r\n";
7683 if ( ! empty( $charged_date ) ) {
7684 $message .= __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . $charged_date . "\r\n";
7685 }
7686 if ( ! empty( $contracted_date ) ) {
7687 $message .= __( 'Renewal Date', 'dlseller' ) . ' : ' . $contracted_date . "\r\n";
7688 }
7689 if ( isset( $data['reminder'] ) ) {
7690 } else {
7691 $message .= "\r\n";
7692 if ( isset( $data['result_status'] ) && RESULT_STATUS_ERROR == $data['result_status'] ) {
7693 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Error', 'usces' ) . "\r\n";
7694 if ( isset( $data['res_err_code'] ) ) {
7695 $message .= 'res_err_code : ' . $data['res_err_code'] . "\r\n";
7696 }
7697 } else {
7698 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Normal done', 'usces' ) . "\r\n";
7699 }
7700 }
7701 $message .= usces_mail_line( 2 ) . "\r\n"; // --------------------
7702 }
7703 return $message;
7704 }
7705
7706 /**
7707 * 自動継続課金処理
7708 * dlseller_action_do_continuation
7709 *
7710 * @param string $today Today.
7711 * @param array $todays_charging Charged data.
7712 */
7713 public function do_auto_continuation( $today, $todays_charging ) {
7714 global $usces;
7715
7716 if ( empty( $todays_charging ) ) {
7717 return;
7718 }
7719
7720 $ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
7721 $error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
7722 $admin_subject = apply_filters( 'usces_filter_paygent_autobilling_email_admin_subject', __( 'Automatic Continuing Charging Process Result', 'usces' ) . ' ' . $today, $today );
7723 $admin_footer = apply_filters( 'usces_filter_paygent_autobilling_email_admin_mail_footer', __( 'For details, please check on the administration panel > Continuous charge member list > Continuous charge member information.', 'usces' ) );
7724 $admin_message = __( 'Report that automated accounting process has been completed.', 'usces' ) . "\r\n\r\n"
7725 . __( 'Processing date', 'usces' ) . ' : ' . date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "\r\n"
7726 . __( 'Normal done', 'usces' ) . ' : ' . $ok . "\r\n"
7727 . __( 'Abnormal done', 'usces' ) . ' : ' . $error . "\r\n\r\n";
7728 foreach ( (array) $this->continuation_charging_mail['mail'] as $mail ) {
7729 $admin_message .= $mail . "\r\n";
7730 }
7731 $admin_message .= $admin_footer . "\r\n";
7732
7733 $to_admin = array(
7734 'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
7735 'to_address' => $usces->options['order_mail'],
7736 'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
7737 'from_address' => $usces->options['sender_mail'],
7738 'reply_name' => get_option( 'blogname' ),
7739 'reply_to' => usces_get_first_order_mail(),
7740 'return_path' => $usces->options['sender_mail'],
7741 'subject' => $admin_subject,
7742 'message' => do_shortcode( $admin_message ),
7743 );
7744 usces_send_mail( $to_admin );
7745 unset( $this->continuation_charging_mail );
7746 }
7747
7748 /**
7749 * 課金日通知メール
7750 * dlseller_filter_reminder_mail_body
7751 *
7752 * @param string $mail_body Message body.
7753 * @param int $order_id Order number.
7754 * @param array $continue_data Continuation data.
7755 * @return string
7756 */
7757 public function reminder_mail_body( $mail_body, $order_id, $continue_data ) {
7758 global $usces;
7759
7760 $member_id = $continue_data['member_id'];
7761 $order_id = $continue_data['order_id'];
7762 $order_data = $usces->get_order_data( $order_id, 'direct' );
7763 $data = array( 'reminder' => 'reminder' );
7764 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data );
7765 return $mail_body;
7766 }
7767
7768 /**
7769 * 契約更新日通知メール
7770 * dlseller_filter_contract_renewal_mail_body
7771 *
7772 * @param string $mail_body Message body.
7773 * @param int $order_id Order number.
7774 * @param array $continue_data Continuation data.
7775 * @return string
7776 */
7777 public function contract_renewal_mail_body( $mail_body, $order_id, $continue_data ) {
7778 global $usces;
7779
7780 $member_id = $continue_data['member_id'];
7781 $order_data = $usces->get_order_data( $order_id, 'direct' );
7782 $data = array( 'reminder' => 'contract_renewal' );
7783 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data );
7784 return $mail_body;
7785 }
7786
7787 /**
7788 * 継続課金会員データ取得
7789 *
7790 * @param int $member_id Member ID.
7791 * @param int $order_id Order number.
7792 * @return array
7793 */
7794 private function get_continuation_data( $member_id, $order_id ) {
7795 global $wpdb;
7796
7797 $query = $wpdb->prepare(
7798 "SELECT
7799 `con_id` AS `con_id`,
7800 `con_acting` AS `acting`,
7801 `con_order_price` AS `order_price`,
7802 `con_price` AS `price`,
7803 `con_next_charging` AS `chargedday`,
7804 `con_next_contracting` AS `contractedday`,
7805 `con_startdate` AS `startdate`,
7806 `con_status` AS `status`
7807 FROM {$wpdb->prefix}usces_continuation
7808 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7809 $order_id,
7810 $member_id
7811 );
7812 $data = $wpdb->get_row( $query, ARRAY_A );
7813 return $data;
7814 }
7815
7816 /**
7817 * 継続課金会員データ更新
7818 *
7819 * @param int $member_id Member ID.
7820 * @param int $order_id Order number.
7821 * @param array $data Continuation data.
7822 * @param boolean $stop Stop continuous billing.
7823 * @return boolean
7824 */
7825 private function update_continuation_data( $member_id, $order_id, $data, $stop = false ) {
7826 global $wpdb;
7827
7828 if ( $stop ) {
7829 $query = $wpdb->prepare(
7830 "UPDATE {$wpdb->prefix}usces_continuation SET
7831 `con_status` = 'cancellation'
7832 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7833 $order_id,
7834 $member_id
7835 );
7836 } else {
7837 $query = $wpdb->prepare(
7838 "UPDATE {$wpdb->prefix}usces_continuation SET
7839 `con_price` = %f,
7840 `con_next_charging` = %s,
7841 `con_next_contracting` = %s,
7842 `con_status` = %s
7843 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7844 $data['price'],
7845 $data['chargedday'],
7846 $data['contractedday'],
7847 $data['status'],
7848 $order_id,
7849 $member_id
7850 );
7851 }
7852 $res = $wpdb->query( $query );
7853 return $res;
7854 }
7855
7856 /**
7857 * 管理画面メッセージ
7858 * wcad_filter_admin_notices
7859 *
7860 * @param string $msg Admin notice message.
7861 * @return string
7862 */
7863 public function admin_notices_autodelivery( $msg ) {
7864 global $usces;
7865
7866 $acting_opts = $this->get_acting_settings();
7867 if ( isset( $acting_opts['card_activate'] ) && 'off' != $acting_opts['card_activate'] && 'on' == $acting_opts['stock_card_mode'] ) {
7868 $msg = '';
7869 } else {
7870 $msg = '<div class="error"><p>「クレジット決済設定」にて、ペイジェントのカード�
7871 報お預りモードを「利用する」に設定してください。</p></div>';
7872 }
7873 return $msg;
7874 }
7875
7876 /**
7877 * 発送�
7878 �リスト利用可能決済
7879 * wcad_filter_shippinglist_acting
7880 *
7881 * @param string $acting Payment method.
7882 * @return string
7883 */
7884 public function set_shippinglist_acting( $acting ) {
7885 $acting = 'acting_paygent_card';
7886 return $acting;
7887 }
7888
7889 /**
7890 * 管理画面利用可能決済メッセージ
7891 * wcad_filter_available_regular_payment_method
7892 *
7893 * @param array $payment_method Payment method.
7894 * @return array
7895 */
7896 public function available_regular_payment_method( $payment_method ) {
7897 $payment_method[] = 'acting_paygent_card';
7898 return $payment_method;
7899 }
7900
7901 /**
7902 * 定期購�
7903 �決済処理
7904 * wcad_action_reg_auto_orderdata
7905 *
7906 * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $total_amount, $reg_id ).
7907 */
7908 public function register_auto_orderdata( $args ) {
7909 global $usces;
7910 extract( $args );
7911
7912 $acting_opts = $this->get_acting_settings();
7913 if ( ! usces_is_membersystem_state() || 'on' != $acting_opts['stock_card_mode'] ) {
7914 return;
7915 }
7916
7917 if ( 0 >= $total_amount ) {
7918 return;
7919 }
7920
7921 $acting_flg = ( isset( $payments['settlement'] ) ) ? $payments['settlement'] : '';
7922 if ( 'acting_paygent_card' != $acting_flg ) {
7923 return;
7924 }
7925
7926 $settltment_errmsg = '';
7927
7928 $trading_id = usces_acting_key();
7929 $customer = $this->customer_ref( $member_id );
7930 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id && isset( $customer['customer_card_id'] ) ) {
7931 $telegram_kind = PAYGENT_CREDIT;
7932 $amount = usces_crform( $total_amount, false, false, 'return', false );
7933
7934 $pm = Paygent_Module::get_instance();
7935 $pm->init();
7936 $pm->req_put( 'trading_id', $trading_id );
7937 $pm->req_put( 'payment_amount', $amount );
7938 $pm->req_put( 'payment_class', '10' );
7939 $pm->req_put( '3dsecure_ryaku', '1' );
7940 $pm->req_put( 'stock_card_mode', '1' );
7941 $pm->req_put( 'customer_id', $member_id );
7942 $pm->req_put( 'customer_card_id', $customer['customer_card_id'] );
7943 $pm->req_put( 'sales_mode', $acting_opts['sales_mode'] );
7944
7945 $result_post = $pm->post( $telegram_kind );
7946 $result_status = $pm->get_result_status();
7947 if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
7948 $settltment_errmsg = __( '[Regular purchase] Settlement was not completed.', 'autodelivery' );
7949 $response_data = array(
7950 'result' => $result_post,
7951 'result_status' => $result_status,
7952 'response_code' => $pm->get_response_code(),
7953 'response_detail' => $pm->get_response_detail(),
7954 'result_message' => $pm->get_result_message(),
7955 );
7956 $response_code = ( true !== $result_post ) ? $result_post : $pm->get_response_code();
7957 $log = array(
7958 'acting' => 'paygent_card',
7959 'key' => $trading_id,
7960 'result' => $response_code,
7961 'data' => $response_data,
7962 );
7963 usces_save_order_acting_error( $log );
7964 $this->save_acting_log( $response_data, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
7965 do_action( 'usces_action_register_auto_orderdata', $args, $response_data );
7966 } else {
7967 $response_data = $pm->get_response_data();
7968 $payment_id = ( isset( $response_data['payment_id'] ) ) ? $response_data['payment_id'] : '';
7969 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
7970 $usces->set_order_meta_value( $acting_flg, usces_serialize( $settlement_ref ), $order_id );
7971 $usces->set_order_meta_value( 'trading_id', $trading_id, $order_id );
7972 $usces->set_order_meta_value( 'wc_trans_id', $trading_id, $order_id );
7973 do_action( 'usces_action_register_auto_orderdata', $args, $settlement_ref );
7974 }
7975 } else {
7976 $settltment_errmsg = __( '[Regular purchase] Member information acquisition error.', 'autodelivery' );
7977 $result = ( isset( $customer['result'] ) ) ? $customer['result'] : 'error';
7978 $log = array(
7979 'acting' => 'paygent_card(member_process)',
7980 'key' => $member_id,
7981 'result' => $result,
7982 'data' => $customer,
7983 );
7984 usces_save_order_acting_error( $log );
7985 if ( ! isset( $customer['payment_type'] ) ) {
7986 $customer['payment_type'] = PAYMENT_TYPE_CREDIT;
7987 }
7988 $this->save_acting_log( $customer, 'paygent_card', 'customer_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
7989 do_action( 'usces_action_register_auto_orderdata', $args, $customer );
7990 }
7991 if ( '' != $settltment_errmsg ) {
7992 $settlement = array(
7993 'settltment_status' => __( 'Failure', 'autodelivery' ),
7994 'settltment_errmsg' => $settltment_errmsg,
7995 'trading_id' => $trading_id,
7996 );
7997 $usces->set_order_meta_value( $acting_flg, usces_serialize( $settlement ), $order_id );
7998 $usces->set_order_meta_value( 'trading_id', $trading_id, $order_id );
7999 $usces->set_order_meta_value( 'wc_trans_id', $trading_id, $order_id );
8000 wcad_settlement_error_mail( $order_id, $settltment_errmsg );
8001 }
8002 }
8003
8004 /**
8005 * Save session data.
8006 *
8007 * @param string $trading_id Trading ID.
8008 * @param array $post_data Post data.
8009 * @return boolean
8010 */
8011 private function save_post_data( $trading_id, $post_data ) {
8012 global $wpdb;
8013
8014 $query = $wpdb->prepare(
8015 "INSERT INTO {$wpdb->prefix}usces_log ( `datetime`, `log`, `log_type`, `log_key` ) VALUES ( %s, %s, %s, %s )",
8016 current_time( 'mysql' ),
8017 usces_serialize( $post_data ),
8018 'acting_post_data',
8019 $trading_id
8020 );
8021 $res = $wpdb->query( $query );
8022 return $res;
8023 }
8024
8025 /**
8026 * Get session data.
8027 *
8028 * @param string $trading_id Trading ID.
8029 * @return array
8030 */
8031 private function get_post_data( $trading_id ) {
8032 global $wpdb;
8033
8034 $query = $wpdb->prepare( "SELECT `log` FROM {$wpdb->prefix}usces_log WHERE `log_type` = %s AND `log_key` = %s", 'acting_post_data', $trading_id );
8035 $data = $wpdb->get_var( $query );
8036 return usces_unserialize( $data );
8037 }
8038
8039 /**
8040 * Delete session data.
8041 *
8042 * @param string $trading_id Trading ID.
8043 */
8044 private function delete_post_data( $trading_id ) {
8045 global $wpdb;
8046
8047 $query = $wpdb->prepare( "DELETE FROM {$wpdb->prefix}usces_log WHERE `log_type` = %s AND `log_key` = %s", 'acting_post_data', $trading_id );
8048 $wpdb->query( $query );
8049 }
8050
8051 /**
8052 * サービスタイプ取得
8053 *
8054 * @param string $acting Acting type.
8055 * @return string
8056 */
8057 private function get_service_type( $acting ) {
8058 $service_type = '';
8059 $acting_opts = $this->get_acting_settings();
8060 $activation = $acting_opts[ $acting . '_activate' ];
8061 if ( 'on' == $activation ) {
8062 $service_type = 'link';
8063 } elseif ( 'module' == $activation ) {
8064 $service_type = 'module';
8065 }
8066 return $service_type;
8067 }
8068
8069 /**
8070 * 決済オプション取得
8071 *
8072 * @return array
8073 */
8074 protected function get_acting_settings() {
8075 global $usces;
8076
8077 $acting_settings = ( isset( $usces->options['acting_settings'][ $this->paymod_id ] ) ) ? $usces->options['acting_settings'][ $this->paymod_id ] : array();
8078 return $acting_settings;
8079 }
8080
8081 /**
8082 * 受注ID 取得
8083 *
8084 * @param string $trading_id Trading ID.
8085 * @return int
8086 */
8087 protected function get_order_id( $trading_id ) {
8088 global $wpdb;
8089
8090 $query = $wpdb->prepare( "SELECT `order_id` FROM {$wpdb->prefix}usces_order_meta WHERE `meta_key` = %s AND `meta_value` = %s", 'trading_id', $trading_id );
8091 $order_id = $wpdb->get_var( $query );
8092 return $order_id;
8093 }
8094
8095 /**
8096 * マーチャント取引ID 取得
8097 *
8098 * @param int $order_id Order number.
8099 * @return string
8100 */
8101 protected function get_trading_id( $order_id ) {
8102 global $usces;
8103
8104 $trading_id = $usces->get_order_meta_value( 'trading_id', $order_id );
8105 return $trading_id;
8106 }
8107
8108 /**
8109 * 受注ステータス取得
8110 *
8111 * @param int $order_id Order number.
8112 * @return string
8113 */
8114 protected function get_order_status( $order_id ) {
8115 global $wpdb;
8116
8117 $query = $wpdb->prepare( "SELECT LOCATE( 'receipted', `order_status` ) FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
8118 $order_status = $wpdb->get_var( $query );
8119 return $order_status;
8120 }
8121
8122 /**
8123 * 受注データ支払方法取得
8124 *
8125 * @param int $order_id Order number.
8126 * @return string
8127 */
8128 protected function get_order_acting_flg( $order_id ) {
8129 global $wpdb;
8130
8131 $query = $wpdb->prepare( "SELECT `order_payment_name` FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
8132 $order_payment_name = $wpdb->get_var( $query );
8133 $payment = usces_get_payments_by_name( $order_payment_name );
8134 $acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
8135 return $acting_flg;
8136 }
8137
8138 /**
8139 * 決済ログ取得
8140 *
8141 * @param int $order_id Order number.
8142 * @param string $trading_id Trading ID.
8143 * @param string $result Result.
8144 * @return array
8145 */
8146 public function get_acting_log( $order_id = 0, $trading_id = 0, $result = RESULT_STATUS_NORMAL ) {
8147 global $wpdb;
8148
8149 if ( empty( $order_id ) ) {
8150 if ( RESULT_STATUS_NORMAL == $result ) {
8151 $query = $wpdb->prepare(
8152 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `tracking_id` = %s AND `result` = %s ORDER BY `datetime` DESC, `ID` DESC",
8153 $trading_id,
8154 RESULT_STATUS_NORMAL
8155 );
8156 } else {
8157 $query = $wpdb->prepare(
8158 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `tracking_id` = %s ORDER BY `datetime` DESC, `ID` DESC",
8159 $trading_id
8160 );
8161 }
8162 } else {
8163 if ( empty( $trading_id ) ) {
8164 if ( RESULT_STATUS_NORMAL == $result ) {
8165 $query = $wpdb->prepare(
8166 "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` = %s ORDER BY `datetime` DESC, `ID` DESC",
8167 $order_id,
8168 $order_id,
8169 RESULT_STATUS_NORMAL
8170 );
8171 } else {
8172 $query = $wpdb->prepare(
8173 "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 `datetime` DESC, `ID` DESC",
8174 $order_id,
8175 $order_id
8176 );
8177 }
8178 } else {
8179 if ( RESULT_STATUS_NORMAL == $result ) {
8180 $query = $wpdb->prepare(
8181 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d AND `tracking_id` = %s AND `result` = %s ORDER BY `datetime` DESC, `ID` DESC",
8182 $order_id,
8183 $trading_id,
8184 RESULT_STATUS_NORMAL
8185 );
8186 } else {
8187 $query = $wpdb->prepare(
8188 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d AND `tracking_id` = %s ORDER BY `datetime` DESC, `ID` DESC",
8189 $order_id,
8190 $trading_id
8191 );
8192 }
8193 }
8194 }
8195 $log_data = $wpdb->get_results( $query, ARRAY_A );
8196 return $log_data;
8197 }
8198
8199 /**
8200 * 決済ログ出力
8201 *
8202 * @param string $log Log data.
8203 * @param string $acting Acting type.
8204 * @param string $status Status.
8205 * @param string $result Result.
8206 * @param int $order_id Order number.
8207 * @param string $trading_id Trading ID.
8208 * @return array
8209 */
8210 private function save_acting_log( $log, $acting, $status, $result, $order_id, $trading_id ) {
8211 global $wpdb;
8212
8213 if ( isset( $log['payment_amount'] ) ) {
8214 $amount = $log['payment_amount'];
8215 } elseif ( isset( $log['reduced_amount'] ) ) {
8216 $amount = $log['reduced_amount'];
8217 } elseif ( isset( $log['amount'] ) ) {
8218 $amount = $log['amount'];
8219 } else {
8220 $amount = 0;
8221 }
8222 if ( ! empty( $log['payment_date'] ) ) {
8223 $datetime = date( 'Y-m-d H:i:s', strtotime( $log['payment_date'] ) );
8224 } elseif ( ! empty( $log['payment_init_date'] ) ) {
8225 $datetime = date( 'Y-m-d H:i:s', strtotime( $log['payment_init_date'] ) );
8226 } else {
8227 $datetime = current_time( 'mysql' );
8228 }
8229 $query = $wpdb->prepare(
8230 "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 )",
8231 $datetime,
8232 usces_serialize( $log ),
8233 $acting,
8234 $status,
8235 $result,
8236 $amount,
8237 $order_id,
8238 $trading_id
8239 );
8240 $res = $wpdb->query( $query );
8241 return $res;
8242 }
8243
8244 /**
8245 * 最新処理取得
8246 *
8247 * @param int $order_id Order number.
8248 * @param string $trading_id Trading ID.
8249 * @param string $result Result.
8250 * @return array
8251 */
8252 public function get_acting_latest_log( $order_id, $trading_id, $result = RESULT_STATUS_NORMAL ) {
8253 $latest_log = array();
8254 $log_data = $this->get_acting_log( $order_id, $trading_id, $result );
8255 if ( $log_data ) {
8256 $data = current( $log_data );
8257 $log = usces_unserialize( $data['log'] );
8258 if ( isset( $log['payment_id'] ) ) {
8259 $payment_id = $log['payment_id'];
8260 } else {
8261 $payment_id = '';
8262 }
8263 $latest_log['acting'] = $data['acting'];
8264 $latest_log['status'] = $data['status'];
8265 $latest_log['result'] = $data['result'];
8266 $latest_log['log'] = $log;
8267 $latest_log['amount'] = $data['amount'];
8268 $latest_log['order_id'] = $data['order_id'];
8269 $latest_log['payment_id'] = $payment_id;
8270 $latest_log['trading_id'] = $data['tracking_id'];
8271 }
8272 return $latest_log;
8273 }
8274
8275 /**
8276 * 決済ステータス取得
8277 *
8278 * @param int $order_id Order number.
8279 * @param string $trading_id Trading ID.
8280 * @return string
8281 */
8282 private function get_payment_status( $order_id, $trading_id ) {
8283 global $wpdb;
8284
8285 $payment_status = '';
8286 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id, RESULT_STATUS_ALL );
8287 if ( isset( $latest_log['status'] ) ) {
8288 $payment_status = $latest_log['status'];
8289 }
8290 return $payment_status;
8291 }
8292
8293 /**
8294 * 処理区分名称取得
8295 *
8296 * @param string $payment_status Payment status code.
8297 * @return string
8298 */
8299 private function get_status_name( $payment_status ) {
8300 $status_name = '';
8301 switch ( $payment_status ) {
8302 case STATUS_REQUESTED: /* 申込済 */
8303 $status_name = '申込済';
8304 break;
8305 case STATUS_AUTHORIZE_NG: /* オーソリNG */
8306 $status_name = 'オーソリNG';
8307 break;
8308 case STATUS_PAYMENT_EXPIRED: /* 支払期限切 */
8309 $status_name = '支払期限切';
8310 break;
8311 case STATUS_3DSECURE_INTERRUPTION: /* 3Dセキュア中断 */
8312 $status_name = '3Dセキュア中断';
8313 break;
8314 case STATUS_3DSECURE_CERTIFICATION: /* 3Dセキュア認証 */
8315 $status_name = '3Dセキュア認証';
8316 break;
8317 case STATUS_REGISTRATION_SUSPENDED: /* 申込中断 */
8318 $status_name = '申込中断';
8319 break;
8320 case STATUS_PAYMENT_INVALIDITY_NO_CLEAR: /* 支払期限切(消込対象外) */
8321 $status_name = '支払期限切(消込対象外)';
8322 break;
8323 case STATUS_AUTHORIZE_OK: /* オーソリOK */
8324 $status_name = 'オーソリOK';
8325 break;
8326 case STATUS_AUTHORIZE_COMPLETED: /* オーソリ完了 */
8327 $status_name = 'オーソリ完了';
8328 break;
8329 case STATUS_SALES_REQUEST_PENDING: /* 売上要求中 */
8330 $status_name = '売上要求中';
8331 break;
8332 case STATUS_AUTHORIZE_CANCELING: /* オーソリ取消中 */
8333 $status_name = 'オーソリ取消中';
8334 break;
8335 case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
8336 $status_name = 'オーソリ取消済';
8337 break;
8338 case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
8339 $status_name = 'オーソリ期限切';
8340 break;
8341 case STATUS_CLEARED: /* 消込済 */
8342 $status_name = '消込済';
8343 break;
8344 case STATUS_CLEARED_SALES_CANCEL_INVALIDITY: /* 消込済(売上取消期限切) */
8345 $status_name = '消込済(売上取消期限切)';
8346 break;
8347 case STATUS_SALES_CANCELING: /* 売上取消中 */
8348 $status_name = '売上取消中';
8349 break;
8350 case STATUS_PRELIMINARY_DETECTED: /* 速報検地済 */
8351 $status_name = '速報検地済';
8352 break;
8353 case STATUS_COMPLETE_CLEARED: /* 消込完了 */
8354 $status_name = '消込完了';
8355 break;
8356 case STATUS_SALES_CANCELING_TALLY: /* 売上取消集計中 */
8357 $status_name = '売上取消集計中';
8358 break;
8359 case STATUS_SALES_CANCELED: /* 売上取消済 */
8360 $status_name = '売上取消済';
8361 break;
8362 case STATUS_PRELIMINARY_CANCELED: /* 速報取消済 */
8363 $status_name = '速報取消済';
8364 break;
8365 case STATUS_COMPLETE_CANCELED: /* 取消完了 */
8366 $status_name = '取消完了';
8367 break;
8368 case PAYGENT_CREDIT: /* カード決済オーソリ */
8369 $status_name = 'カード決済オーソリ';
8370 break;
8371 case PAYGENT_AUTH_CANCEL: /* カード決済オーソリキャンセル */
8372 $status_name = 'カード決済オーソリキャンセル';
8373 break;
8374 case PAYGENT_CARD_COMMIT: /* カード決済売上 */
8375 $status_name = 'カード決済売上';
8376 break;
8377 case PAYGENT_CARD_COMMIT_CANCEL: /* カード決済売上キャンセル */
8378 $status_name = 'カード決済売上キャンセル';
8379 break;
8380 case PAYGENT_CARD_COMMIT_AUTH_REVISE: /* カード決済補正オーソリ */
8381 $status_name = 'カード決済補正オーソリ';
8382 break;
8383 case PAYGENT_CARD_COMMIT_REVISE: /* カード決済補正売上 */
8384 $status_name = 'カード決済補正売上';
8385 break;
8386 case PAYGENT_PAIDY_AUTH_CANCEL: /* Paidy オーソリキャンセル */
8387 $status_name = 'Paidyオーソリキャンセル';
8388 break;
8389 case PAYGENT_PAIDY_CAPTURE: /* Paidy 売上 */
8390 $status_name = 'Paidy売上';
8391 break;
8392 case PAYGENT_PAIDY_REFUND: /* Paidy 返金 */
8393 $status_name = 'Paidy返金';
8394 break;
8395 case 'bank_applying': /* 銀行ネット決済ASP */
8396 $status_name = '申込中';
8397 break;
8398 case 'reference_error': /* 決済履歴取得不可 */
8399 $status_name = '決済履歴取得不可';
8400 break;
8401 case 'payment_error': /* 決済エラー */
8402 $status_name = '決済エラー';
8403 break;
8404 case 'customer_error': /* 会員�
8405 報エラー */
8406 $status_name = '会員�
8407 報エラー';
8408 break;
8409 case 'error': /* その他エラー */
8410 $status_name = 'エラー';
8411 break;
8412 default:
8413 $status_name = $payment_status;
8414 }
8415 return $status_name;
8416 }
8417
8418 /**
8419 * 処理区分取得
8420 *
8421 * @param string $payment_status Payment status code.
8422 * @return string
8423 */
8424 private function get_status( $payment_status ) {
8425 $status = '';
8426 switch ( $payment_status ) {
8427 case STATUS_REQUESTED: /* 申込済 */
8428 $status = 'requested';
8429 break;
8430 case STATUS_AUTHORIZE_NG: /* オーソリNG */
8431 $status = 'authorize-ng';
8432 break;
8433 case STATUS_PAYMENT_EXPIRED: /* 支払期限切 */
8434 $status = 'payment-expired';
8435 break;
8436 case STATUS_3DSECURE_INTERRUPTION: /* 3Dセキュア中断 */
8437 $status = '3dsecure-interruption';
8438 break;
8439 case STATUS_3DSECURE_CERTIFICATION: /* 3Dセキュア認証 */
8440 $status = '3dsecure-certification';
8441 break;
8442 case STATUS_REGISTRATION_SUSPENDED: /* 申込中断 */
8443 $status = 'registration-suspended';
8444 break;
8445 case STATUS_PAYMENT_INVALIDITY_NO_CLEAR: /* 支払期限切(消込対象外) */
8446 $status = 'payment-invalidity-no-clear';
8447 break;
8448 case STATUS_AUTHORIZE_OK: /* オーソリOK */
8449 $status = 'authorize-ok';
8450 break;
8451 case STATUS_AUTHORIZE_COMPLETED: /* オーソリ完了 */
8452 $status = 'authorize-completed';
8453 break;
8454 case STATUS_SALES_REQUEST_PENDING: /* 売上要求中 */
8455 $status = 'sales-request-pending';
8456 break;
8457 case STATUS_AUTHORIZE_CANCELING: /* オーソリ取消中 */
8458 $status = 'authorize-canceling';
8459 break;
8460 case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
8461 $status = 'authorize-canceled';
8462 break;
8463 case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
8464 $status = 'authorize-expired';
8465 break;
8466 case STATUS_CLEARED: /* 消込済 */
8467 $status = 'cleared';
8468 break;
8469 case STATUS_CLEARED_SALES_CANCEL_INVALIDITY: /* 消込済(売上取消期限切) */
8470 $status = 'cleared-sales-cancel-invalidity';
8471 break;
8472 case STATUS_SALES_CANCELING: /* 売上取消中 */
8473 $status = 'being-sales-canceling';
8474 break;
8475 case STATUS_PRELIMINARY_DETECTED: /* 速報検地済 */
8476 $status = 'preliminary-detected';
8477 break;
8478 case STATUS_COMPLETE_CLEARED: /* 消込完了 */
8479 $status = 'complete-cleared';
8480 break;
8481 case STATUS_SALES_CANCELING_TALLY: /* 売上取消集計中 */
8482 $status = 'being-sales-canceling-tally';
8483 break;
8484 case STATUS_SALES_CANCELED: /* 売上取消済 */
8485 $status = 'sales-canceled';
8486 break;
8487 case STATUS_PRELIMINARY_CANCELED: /* 速報取消済 */
8488 $status = 'preliminary-canceled';
8489 break;
8490 case STATUS_COMPLETE_CANCELED: /* 取消完了 */
8491 $status = 'complete-canceled';
8492 break;
8493 case 'bank_applying': /* 銀行ネット決済ASP */
8494 $status = 'applying';
8495 break;
8496 case 'reference_error': /* 決済履歴取得不可 */
8497 $status = 'reference-error';
8498 break;
8499 case 'payment_error': /* 決済エラー */
8500 $status = 'payment-error';
8501 break;
8502 case 'customer_error': /* 会員�
8503 報エラー */
8504 $status = 'customer-error';
8505 break;
8506 case 'error': /* その他エラー */
8507 $status = 'error';
8508 break;
8509 default:
8510 $status = $payment_status;
8511 }
8512 return $status;
8513 }
8514
8515 /**
8516 * 決済結果参�
8517
8518 *
8519 * @param int $order_id Order number.
8520 * @param string $trading_id マーチャント取引ID.
8521 * @param string $payment_id 決済ID.
8522 * @return array
8523 */
8524 private function settlement_ref( $order_id, $trading_id, $payment_id = '' ) {
8525 $settlement = array();
8526
8527 $pm = Paygent_Module::get_instance();
8528 $pm->init();
8529 $pm->req_put( 'trading_id', $trading_id );
8530 if ( ! empty( $payment_id ) ) {
8531 $pm->req_put( 'payment_id', $payment_id );
8532 }
8533 $result = $pm->post( PAYGENT_REF );
8534 $result_status = $pm->get_result_status();
8535 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8536 $settlement['result'] = $result;
8537 $settlement['result_status'] = RESULT_STATUS_ERROR;
8538 $settlement['response_code'] = $pm->get_response_code();
8539 $settlement['response_detail'] = $pm->get_response_detail();
8540 $settlement['result_message'] = $pm->get_result_message();
8541 } else {
8542 $settlement = $pm->get_response_data();
8543 }
8544 return $settlement;
8545 }
8546
8547 /**
8548 * 決済要求
8549 *
8550 * @param string $telegram_kind 電文種別ID.
8551 * @param string $trading_id マーチャント取引ID.
8552 * @param string $payment_id 決済ID.
8553 * @return array
8554 */
8555 private function settlement_request( $telegram_kind, $trading_id, $payment_id ) {
8556 $settlement = array();
8557
8558 $pm = Paygent_Module::get_instance();
8559 $pm->init();
8560 $pm->req_put( 'trading_id', $trading_id );
8561 $pm->req_put( 'payment_id', $payment_id );
8562 $result = $pm->post( $telegram_kind );
8563 $result_status = $pm->get_result_status();
8564 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8565 $settlement['result'] = $result;
8566 $settlement['result_status'] = RESULT_STATUS_ERROR;
8567 $settlement['response_code'] = $pm->get_response_code();
8568 $settlement['response_detail'] = $pm->get_response_detail();
8569 $settlement['result_message'] = $pm->get_result_message();
8570 } else {
8571 $settlement = $pm->get_response_data();
8572 }
8573 return $settlement;
8574 }
8575
8576 /**
8577 * 決済金額補正要求
8578 *
8579 * @param string $telegram_kind 電文種別ID.
8580 * @param string $trading_id マーチャント取引ID.
8581 * @param string $payment_id 決済ID.
8582 * @param float $amount 決済金額.
8583 * @return array
8584 */
8585 private function settlement_request_revise( $telegram_kind, $trading_id, $payment_id, $amount ) {
8586 $settlement = array();
8587
8588 $pm = Paygent_Module::get_instance();
8589 $pm->init();
8590 $pm->req_put( 'trading_id', $trading_id );
8591 $pm->req_put( 'payment_id', $payment_id );
8592 $pm->req_put( 'payment_amount', $amount );
8593 $pm->req_put( 'reduction_flag', '0' );
8594 $result = $pm->post( $telegram_kind );
8595 $result_status = $pm->get_result_status();
8596 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8597 $settlement['result'] = $result;
8598 $settlement['result_status'] = RESULT_STATUS_ERROR;
8599 $settlement['response_code'] = $pm->get_response_code();
8600 $settlement['response_detail'] = $pm->get_response_detail();
8601 $settlement['result_message'] = $pm->get_result_message();
8602 } else {
8603 $settlement = $pm->get_response_data();
8604 }
8605 return $settlement;
8606 }
8607
8608 /**
8609 * Paidy 要求
8610 *
8611 * @param string $telegram_kind 電文種別ID.
8612 * @param string $trading_id マーチャント取引ID.
8613 * @param string $payment_id 決済ID.
8614 * @return array
8615 */
8616 private function settlement_request_paidy( $telegram_kind, $trading_id, $payment_id = '' ) {
8617 $settlement = array();
8618
8619 $pm = Paygent_Module::get_instance();
8620 $pm->init();
8621 $pm->req_put( 'trading_id', $trading_id );
8622 if ( ! empty( $payment_id ) ) {
8623 $pm->req_put( 'payment_id', $payment_id );
8624 }
8625 $result = $pm->post( $telegram_kind );
8626 $result_status = $pm->get_result_status();
8627 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8628 $settlement['result'] = $result;
8629 $settlement['result_status'] = RESULT_STATUS_ERROR;
8630 $settlement['response_code'] = $pm->get_response_code();
8631 $settlement['response_detail'] = $pm->get_response_detail();
8632 $settlement['result_message'] = $pm->get_result_message();
8633 } else {
8634 $settlement = $pm->get_response_data();
8635 }
8636 return $settlement;
8637 }
8638
8639 /**
8640 * Paidy 返金要求
8641 *
8642 * @param string $telegram_kind 電文種別ID.
8643 * @param string $trading_id マーチャント取引ID.
8644 * @param float $amount 決済金額.
8645 * @param string $payment_id 決済ID.
8646 * @return array
8647 */
8648 private function settlement_request_paidy_refund( $telegram_kind, $trading_id, $amount, $payment_id = '' ) {
8649 $settlement = array();
8650
8651 $pm = Paygent_Module::get_instance();
8652 $pm->init();
8653 $pm->req_put( 'trading_id', $trading_id );
8654 if ( ! empty( $payment_id ) ) {
8655 $pm->req_put( 'payment_id', $payment_id );
8656 }
8657 $pm->req_put( 'amount', $amount );
8658 $result = $pm->post( $telegram_kind );
8659 $result_status = $pm->get_result_status();
8660 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8661 $settlement['result'] = $result;
8662 $settlement['result_status'] = RESULT_STATUS_ERROR;
8663 $settlement['response_code'] = $pm->get_response_code();
8664 $settlement['response_detail'] = $pm->get_response_detail();
8665 $settlement['result_message'] = $pm->get_result_message();
8666 } else {
8667 $settlement = $pm->get_response_data();
8668 }
8669 return $settlement;
8670 }
8671
8672 /**
8673 * 会員�
8674 報取得
8675 *
8676 * @param int $member_id Member ID.
8677 * @return array
8678 */
8679 private function customer_ref( $member_id ) {
8680 global $usces;
8681
8682 $customer = array();
8683 $customer_card_id = $usces->get_member_meta_value( 'paygent_customer_card_id', $member_id );
8684 if ( empty( $customer_card_id ) ) {
8685 return $customer;
8686 }
8687
8688 $pm = Paygent_Module::get_instance();
8689 $pm->init();
8690 $pm->req_put( 'customer_id', $member_id );
8691 $pm->req_put( 'customer_card_id', $customer_card_id );
8692 $result = $pm->post( PAYGENT_CARD_STOCK_GET );
8693 $result_status = $pm->get_result_status();
8694 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8695 $customer['result'] = $result;
8696 $customer['result_status'] = RESULT_STATUS_ERROR;
8697 $customer['response_code'] = $pm->get_response_code();
8698 $customer['response_detail'] = $pm->get_response_detail();
8699 $customer['result_message'] = $pm->get_result_message();
8700 } else {
8701 $customer = $pm->get_response_data();
8702 }
8703 return $customer;
8704 }
8705
8706 /**
8707 * 会員カード�
8708 報登録
8709 *
8710 * @param int $member_id Member ID.
8711 * @param string $token Card Token.
8712 * @return array
8713 */
8714 private function customer_card_add( $member_id, $token ) {
8715 global $usces;
8716
8717 $customer = array();
8718 $acting_opts = $this->get_acting_settings();
8719
8720 $pm = Paygent_Module::get_instance();
8721 $pm->init();
8722 $pm->req_put( 'customer_id', $member_id );
8723 $pm->req_put( 'valid_check_flg', 1 );
8724 $pm->req_put( 'card_token', $token );
8725 if ( 'on' == $acting_opts['use_card_conf_number'] ) {
8726 $pm->req_put( 'security_code_use', 1 );
8727 }
8728 $result = $pm->post( PAYGENT_CARD_STOCK_SET );
8729 $result_status = $pm->get_result_status();
8730 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8731 $customer['result'] = $result;
8732 $customer['result_status'] = RESULT_STATUS_ERROR;
8733 $customer['response_code'] = $pm->get_response_code();
8734 $customer['response_detail'] = $pm->get_response_detail();
8735 $customer['result_message'] = $pm->get_result_message();
8736 } else {
8737 $customer = $pm->get_response_data();
8738 if ( isset( $customer['customer_card_id'] ) ) {
8739 $usces->set_member_meta_value( 'paygent_customer_card_id', $customer['customer_card_id'], $member_id );
8740 }
8741 }
8742 return $customer;
8743 }
8744
8745 /**
8746 * 会員カード�
8747 報更新
8748 *
8749 * @param int $member_id Member ID.
8750 * @param string $token Card Token.
8751 * @return array
8752 */
8753 private function customer_card_upd( $member_id, $token ) {
8754 $customer = $this->customer_card_del( $member_id );
8755 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
8756 return $customer;
8757 }
8758 $customer = $this->customer_card_add( $member_id, $token );
8759 return $customer;
8760 }
8761
8762 /**
8763 * 会員カード�
8764 報削除
8765 *
8766 * @param int $member_id Member ID.
8767 * @return array
8768 */
8769 private function customer_card_del( $member_id ) {
8770 global $usces;
8771
8772 $customer = array();
8773 $customer_card_id = $usces->get_member_meta_value( 'paygent_customer_card_id', $member_id );
8774
8775 $pm = Paygent_Module::get_instance();
8776 $pm->init();
8777 $pm->req_put( 'customer_id', $member_id );
8778 $pm->req_put( 'customer_card_id', $customer_card_id );
8779 $result = $pm->post( PAYGENT_CARD_STOCK_DEL );
8780 $result_status = $pm->get_result_status();
8781 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8782 $customer['result'] = $result;
8783 $customer['result_status'] = RESULT_STATUS_ERROR;
8784 $customer['response_code'] = $pm->get_response_code();
8785 $customer['response_detail'] = $pm->get_response_detail();
8786 $customer['result_message'] = $pm->get_result_message();
8787 } else {
8788 $usces->del_member_meta( 'paygent_customer_card_id', $member_id );
8789 $customer = $pm->get_response_data();
8790 }
8791 return $customer;
8792 }
8793
8794 /**
8795 * Save admin log.
8796 *
8797 * @since 2.7.4
8798 * @see admin_ajax()
8799 * @param integer $order_id The order id.
8800 * @param string $trading_id The trading id.
8801 * @return void
8802 */
8803 private function save_admin_log( $order_id, $trading_id ) {
8804 $latest_log = array();
8805 $log_data = $this->get_acting_log( $order_id, $trading_id );
8806 if ( $log_data ) {
8807 $data = current( $log_data );
8808 $log = usces_unserialize( $data['log'] );
8809
8810 $payment_id = ( isset( $log['payment_id'] ) ) ? $log['payment_id'] : 'no value';
8811
8812 $latest_log['datetime'] = $data['datetime'];
8813 $latest_log['acting'] = $data['acting'];
8814 $latest_log['status'] = $this->get_status_name( $data['status'] );
8815 $latest_log['result'] = $data['result'];
8816 $latest_log['log'] = $log;
8817 $latest_log['amount'] = $data['amount'];
8818 $latest_log['order_id'] = $data['order_id'];
8819 $latest_log['payment_id'] = $payment_id;
8820 $latest_log['trading_id'] = $data['tracking_id'];
8821 }
8822
8823 Logger::log( $order_id, 'orderedit', 'update', array( 'paygent_card' => $latest_log ) );
8824 }
8825 }
8826