PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
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.12.4, at classes/paymentPaygent.class.php

8,907 lines 389.7 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 �開遮断ファイルを設置する
376 *
377 * 秘密鍵を含む証明書が HTTP で�
378 �信される領域に保存されている場合に備え、
379 * ディレクトリ名の推測困難性だけに頼らず Web サーバー側でも遮断する.
380 * 効果があるのは .htaccess を読む Apache のみ. nginx では無効.
381 *
382 * 証明書が実際に置かれているディレクトリのときにのみ設置する.
383 * 証明書ファイルパスは管理画面で任意のディレクトリに変更できるため、
384 * 証明書と無関係なディレクトリには触れないようにする.
385 *
386 * 呼び出し�
387 �はディレクトリ作成時・証明書アップロード時・管理画面の読み込み時の3箇所.
388 *
389 * @param string $dir Certificate directory path.
390 * @return bool True if the directory has the blocking file.
391 */
392 private function protect_certificate_dir( $dir ) {
393 if ( WCUtils::is_blank( $dir ) || ! is_dir( $dir ) ) {
394 return false;
395 }
396
397 $htaccess = $dir . '/.htaccess';
398 if ( file_exists( $htaccess ) ) {
399 return true;
400 }
401
402 if ( ! is_writable( $dir ) || ! $this->has_certificate_file( $dir ) ) {
403 return false;
404 }
405
406 $content = "<IfModule mod_authz_core.c>\n\tRequire all denied\n</IfModule>\n";
407 $content .= "<IfModule !mod_authz_core.c>\n\tOrder deny,allow\n\tDeny from all\n</IfModule>\n";
408
409 return ( false !== file_put_contents( $htaccess, $content ) );
410 }
411
412 /**
413 * 証明書が置かれているディレクトリかを判定する
414 *
415 * クライアント証明書(.pem)かCAファイル(.crt)が1つでもあれば true.
416 * 拡張子はアップロード時の検証と揃えてある.
417 * 証明書が無いディレクトリでは決済設定画面の表示ごとにこの判定が走るため、
418 * ファイル名を�
419 �列に溜めずに1件ずつ調べ、見つかった時点で打ち切る.
420 *
421 * @param string $dir Certificate directory path.
422 * @return bool True if the directory holds a certificate file.
423 */
424 private function has_certificate_file( $dir ) {
425 $handle = opendir( $dir );
426 if ( false === $handle ) {
427 return false;
428 }
429
430 $extensions = array( 'pem', 'crt' );
431 $found = false;
432
433 while ( false !== ( $entry = readdir( $handle ) ) ) {
434 if ( in_array( strtolower( pathinfo( $entry, PATHINFO_EXTENSION ) ), $extensions, true ) ) {
435 $found = true;
436 break;
437 }
438 }
439 closedir( $handle );
440
441 return $found;
442 }
443
444 /**
445 * 決済有効判定
446 * 支払方法で使用している場合に true
447 *
448 * @param string $type Module type.
449 * @return boolean
450 */
451 public function is_validity_acting( $type = '' ) {
452 $acting_opts = $this->get_acting_settings();
453 if ( empty( $acting_opts ) ) {
454 return false;
455 }
456
457 $payment_method = usces_get_system_option( 'usces_payment_method', 'sort' );
458 $method = false;
459
460 switch ( $type ) {
461 case 'card':
462 foreach ( $payment_method as $payment ) {
463 if ( 'acting_paygent_card' == $payment['settlement'] && 'activate' == $payment['use'] ) {
464 $method = true;
465 break;
466 }
467 }
468 if ( $method && $this->is_activate_card() ) {
469 return true;
470 } else {
471 return false;
472 }
473 break;
474 case 'conv':
475 foreach ( $payment_method as $payment ) {
476 if ( 'acting_paygent_conv' == $payment['settlement'] && 'activate' == $payment['use'] ) {
477 $method = true;
478 break;
479 }
480 }
481 if ( $method && $this->is_activate_conv() ) {
482 return true;
483 } else {
484 return false;
485 }
486 break;
487 case 'atm':
488 foreach ( $payment_method as $payment ) {
489 if ( 'acting_paygent_atm' == $payment['settlement'] && 'activate' == $payment['use'] ) {
490 $method = true;
491 break;
492 }
493 }
494 if ( $method && $this->is_activate_atm() ) {
495 return true;
496 } else {
497 return false;
498 }
499 break;
500 case 'bank':
501 foreach ( $payment_method as $payment ) {
502 if ( 'acting_paygent_bank' == $payment['settlement'] && 'activate' == $payment['use'] ) {
503 $method = true;
504 break;
505 }
506 }
507 if ( $method && $this->is_activate_bank() ) {
508 return true;
509 } else {
510 return false;
511 }
512 break;
513 case 'paidy':
514 foreach ( $payment_method as $payment ) {
515 if ( 'acting_paygent_paidy' == $payment['settlement'] && 'activate' == $payment['use'] ) {
516 $method = true;
517 break;
518 }
519 }
520 if ( $method && $this->is_activate_paidy() ) {
521 return true;
522 } else {
523 return false;
524 }
525 break;
526 default:
527 if ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) {
528 return true;
529 } else {
530 return false;
531 }
532 }
533 }
534
535 /**
536 * クレジットカード決済有効判定
537 *
538 * @param string $type 'link'|'module'.
539 * @return boolean
540 */
541 public function is_activate_card( $type = '' ) {
542 $acting_opts = $this->get_acting_settings();
543 if ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) {
544 if ( empty( $type ) ) {
545 if ( isset( $acting_opts['card_activate'] ) && ( 'off' != $acting_opts['card_activate'] ) ) {
546 $res = true;
547 } else {
548 $res = false;
549 }
550 } elseif ( 'link' == $type ) {
551 if ( isset( $acting_opts['card_activate'] ) && ( 'on' == $acting_opts['card_activate'] ) ) {
552 $res = true;
553 } else {
554 $res = false;
555 }
556 } elseif ( 'module' == $type ) {
557 if ( isset( $acting_opts['card_activate'] ) && ( 'module' == $acting_opts['card_activate'] ) ) {
558 $res = true;
559 } else {
560 $res = false;
561 }
562 } else {
563 $res = false;
564 }
565 } else {
566 $res = false;
567 }
568 return $res;
569 }
570
571 /**
572 * コンビニ決済有効判定
573 *
574 * @param string $type 'link'|'module'.
575 * @return boolean
576 */
577 public function is_activate_conv( $type = '' ) {
578 $acting_opts = $this->get_acting_settings();
579 if ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) {
580 if ( empty( $type ) ) {
581 if ( isset( $acting_opts['conv_activate'] ) && ( 'off' != $acting_opts['conv_activate'] ) ) {
582 $res = true;
583 } else {
584 $res = false;
585 }
586 } elseif ( 'link' == $type ) {
587 if ( isset( $acting_opts['conv_activate'] ) && ( 'on' == $acting_opts['conv_activate'] ) ) {
588 $res = true;
589 } else {
590 $res = false;
591 }
592 } elseif ( 'module' == $type ) {
593 if ( isset( $acting_opts['conv_activate'] ) && ( 'module' == $acting_opts['conv_activate'] ) ) {
594 $res = true;
595 } else {
596 $res = false;
597 }
598 } else {
599 $res = false;
600 }
601 } else {
602 $res = false;
603 }
604 return $res;
605 }
606
607 /**
608 * ATM決済(Pay-easy)有効判定
609 *
610 * @return boolean
611 */
612 public function is_activate_atm() {
613 $acting_opts = $this->get_acting_settings();
614 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
615 ( isset( $acting_opts['atm_activate'] ) && 'module' == $acting_opts['atm_activate'] ) ) {
616 $res = true;
617 } else {
618 $res = false;
619 }
620 return $res;
621 }
622
623 /**
624 * 銀行ネット決済有効判定
625 *
626 * @return boolean
627 */
628 public function is_activate_bank() {
629 $acting_opts = $this->get_acting_settings();
630 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
631 ( isset( $acting_opts['bank_activate'] ) && 'module' == $acting_opts['bank_activate'] ) ) {
632 $res = true;
633 } else {
634 $res = false;
635 }
636 return $res;
637 }
638
639 /**
640 * Paidy決済有効判定
641 *
642 * @return boolean
643 */
644 public function is_activate_paidy() {
645 $acting_opts = $this->get_acting_settings();
646 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
647 ( isset( $acting_opts['paidy_activate'] ) && 'module' == $acting_opts['paidy_activate'] ) ) {
648 $res = true;
649 } else {
650 $res = false;
651 }
652 return $res;
653 }
654
655 /**
656 * 未�
657 �金ステータス
658 * usces_filter_noreceipt_status
659 *
660 * @param array $noreceipt_status Receive payment notification.
661 * @return array
662 */
663 public function noreceipt_status( $noreceipt_status ) {
664 if ( ! in_array( 'acting_paygent_conv', $noreceipt_status ) || ! in_array( 'acting_paygent_atm', $noreceipt_status ) || ! in_array( 'acting_paygent_bank', $noreceipt_status ) ) {
665 $noreceipt_status[] = 'acting_paygent_conv';
666 $noreceipt_status[] = 'acting_paygent_atm';
667 $noreceipt_status[] = 'acting_paygent_bank';
668 $noreceipt_status = array_unique( $noreceipt_status );
669 update_option( 'usces_noreceipt_status', $noreceipt_status );
670 }
671 return $noreceipt_status;
672 }
673
674 /**
675 * 管理画面スクリプト
676 * admin_print_footer_scripts
677 */
678 public function admin_scripts() {
679 $admin_page = ( isset( $_GET['page'] ) ) ? wp_unslash( $_GET['page'] ) : '';
680 switch ( $admin_page ) :
681 /* クレジット決済設定画面 */
682 case 'usces_settlement':
683 $settlement_selected = get_option( 'usces_settlement_selected' );
684 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) :
685 $acting_opts = $this->get_acting_settings();
686 ?>
687 <script type="text/javascript">
688 jQuery( document ).ready( function( $ ) {
689 var paygent_card_activate = "<?php echo esc_js( $acting_opts['card_activate'] ); ?>";
690 var paygent_card_threedsecure = "<?php echo esc_js( $acting_opts['threedsecure_ryaku'] ); ?>";
691 if ( "on" == paygent_card_activate ) {
692 $( ".paygent_card_form" ).css( "display", "" );
693 $( ".paygent_card_module" ).css( "display", "none" );
694 $( ".paygent_card_threedsecure" ).css( "display", "none" );
695 } else if ( "module" == paygent_card_activate ) {
696 $( ".paygent_card_form" ).css( "display", "" );
697 $( ".paygent_card_module" ).css( "display", "" );
698 if ( "on" == paygent_card_threedsecure ) {
699 $( ".paygent_card_threedsecure" ).css( "display", "" );
700 } else {
701 $( ".paygent_card_threedsecure" ).css( "display", "none" );
702 }
703 } else {
704 $( ".paygent_card_form" ).css( "display", "none" );
705 $( ".paygent_card_module" ).css( "display", "none" );
706 $( ".paygent_card_threedsecure" ).css( "display", "none" );
707 }
708 $( document ).on( "change", ".activate_paygent_card", function() {
709 if ( "on" == $( this ).val() ) {
710 $( ".paygent_card_form" ).css( "display", "" );
711 $( ".paygent_card_module" ).css( "display", "none" );
712 $( ".paygent_card_threedsecure" ).css( "display", "none" );
713 } else if ( "module" == $( this ).val() ) {
714 $( ".paygent_card_form" ).css( "display", "" );
715 $( ".paygent_card_module" ).css( "display", "" );
716 if ( "on" == $( "input[name='threedsecure_ryaku']:checked" ).val() ) {
717 $( ".paygent_card_threedsecure" ).css( "display", "" );
718 } else {
719 $( ".paygent_card_threedsecure" ).css( "display", "none" );
720 }
721 } else {
722 $( ".paygent_card_form" ).css( "display", "none" );
723 $( ".paygent_card_module" ).css( "display", "none" );
724 $( ".paygent_card_threedsecure" ).css( "display", "none" );
725 }
726 });
727 if ( "on" == paygent_card_threedsecure && "module" == paygent_card_activate ) {
728 $( ".paygent_card_threedsecure" ).css( "display", "" );
729 } else {
730 $( ".paygent_card_threedsecure" ).css( "display", "none" );
731 }
732 $( document ).on( "change", ".activate_paygent_card_threedsecure", function() {
733 if ( "module" == $( "input[name='card_activate']:checked" ).val() ) {
734 if ( "on" == $( this ).val() ) {
735 $( ".paygent_card_threedsecure" ).css( "display", "" );
736 } else {
737 $( ".paygent_card_threedsecure" ).css( "display", "none" );
738 }
739 }
740 });
741
742 var paygent_conv_activate = "<?php echo esc_js( $acting_opts['conv_activate'] ); ?>";
743 if ( "on" == paygent_conv_activate ) {
744 $( ".paygent_conv_form" ).css( "display", "" );
745 $( ".paygent_conv_link" ).css( "display", "" );
746 $( ".paygent_conv_module" ).css( "display", "none" );
747 } else if ( "module" == paygent_conv_activate ) {
748 $( ".paygent_conv_form" ).css( "display", "" );
749 $( ".paygent_conv_link" ).css( "display", "none" );
750 $( ".paygent_conv_module" ).css( "display", "" );
751 } else {
752 $( ".paygent_conv_form" ).css( "display", "none" );
753 $( ".paygent_conv_link" ).css( "display", "none" );
754 $( ".paygent_conv_module" ).css( "display", "none" );
755 }
756 $( document ).on( "change", ".activate_paygent_conv", function() {
757 if ( "on" == $( this ).val() ) {
758 $( ".paygent_conv_form" ).css( "display", "" );
759 $( ".paygent_conv_link" ).css( "display", "" );
760 $( ".paygent_conv_module" ).css( "display", "none" );
761 } else if ( "module" == $( this ).val() ) {
762 $( ".paygent_conv_form" ).css( "display", "" );
763 $( ".paygent_conv_link" ).css( "display", "none" );
764 $( ".paygent_conv_module" ).css( "display", "" );
765 } else {
766 $( ".paygent_conv_form" ).css( "display", "none" );
767 $( ".paygent_conv_link" ).css( "display", "none" );
768 $( ".paygent_conv_module" ).css( "display", "none" );
769 }
770 });
771
772 var paygent_atm_activate = "<?php echo esc_js( $acting_opts['atm_activate'] ); ?>";
773 if ( "module" == paygent_atm_activate ) {
774 $( ".paygent_atm_form" ).css( "display", "" );
775 } else {
776 $( ".paygent_atm_form" ).css( "display", "none" );
777 }
778 $( document ).on( "change", ".activate_paygent_atm", function() {
779 if ( "module" == $( this ).val() ) {
780 $( ".paygent_atm_form" ).css( "display", "" );
781 } else {
782 $( ".paygent_atm_form" ).css( "display", "none" );
783 }
784 });
785
786 var paygent_bank_activate = "<?php echo esc_js( $acting_opts['bank_activate'] ); ?>";
787 if ( "module" == paygent_bank_activate ) {
788 $( ".paygent_bank_form" ).css( "display", "" );
789 } else {
790 $( ".paygent_bank_form" ).css( "display", "none" );
791 }
792 $( document ).on( "change", ".activate_paygent_bank", function() {
793 if ( "module" == $( this ).val() ) {
794 $( ".paygent_bank_form" ).css( "display", "" );
795 } else {
796 $( ".paygent_bank_form" ).css( "display", "none" );
797 }
798 });
799
800 var paygent_paidy_activate = "<?php echo esc_js( $acting_opts['paidy_activate'] ); ?>";
801 if ( "module" == paygent_paidy_activate ) {
802 $( ".paygent_paidy_form" ).css( "display", "" );
803 } else {
804 $( ".paygent_paidy_form" ).css( "display", "none" );
805 }
806 $( document ).on( "change", ".activate_paygent_paidy", function() {
807 if ( "module" == $( this ).val() ) {
808 $( ".paygent_paidy_form" ).css( "display", "" );
809 } else {
810 $( ".paygent_paidy_form" ).css( "display", "none" );
811 }
812 });
813
814 $( document ).on( "click", "#change_certificate_path", function() {
815 $( "#certificate_path_paygent" ).prop( "disabled", "" );
816 });
817
818 $( document ).on( "click", "#client_file_upload", function() {
819 $.ajax({
820 url: ajaxurl,
821 type: "POST",
822 cache: false,
823 dataType: "json",
824 data: {
825 action: "check_file_path",
826 path: $( "#certificate_path_paygent" ).val(),
827 file: $( "#client_file_paygent" ).val(),
828 wc_nonce: $( "#wc_nonce" ).val()
829 }
830 }).done( function( retVal, dataType ) {
831 if ( "OK" == retVal.status ) {
832 if ( ! retVal.file_exists ) {
833 $( "#client_file_paygent" ).val( "" );
834 }
835 $( "#upload_filetype" ).val( "client_file" );
836 $( "#upload_file" ).prop( 'accept', ".pem" );
837 $( "#filetype_description" ).html( "拡張子「.pem」のファイルを指定してください。" );
838 $( "#upload_dialog_paygent" ).dialog( "option" , "title" , "クライアント証明書ファイルのアップロード" );
839 $( "#upload_dialog_paygent" ).dialog( "open" );
840 } else {
841 alert( retVal.status );
842 return false;
843 }
844 }).fail( function( retVal ) {
845 });
846 return false;
847 });
848
849 $( document ).on( "click", "#ca_file_upload", function() {
850 $.ajax({
851 url: ajaxurl,
852 type: "POST",
853 cache: false,
854 dataType: "json",
855 data: {
856 action: "check_file_path",
857 path: $( "#certificate_path_paygent" ).val(),
858 file: $( "#ca_file_paygent" ).val(),
859 wc_nonce: $( "#wc_nonce" ).val()
860 }
861 }).done( function( retVal ) {
862 if ( "OK" == retVal.status ) {
863 if ( ! retVal.file_exists ) {
864 $( "#ca_file_paygent" ).val( "" );
865 }
866 $( "#upload_filetype" ).val( "ca_file" );
867 $( "#upload_file" ).prop( 'accept', ".crt" );
868 $( "#filetype_description" ).html( "拡張子「.crt」のファイルを指定してください。" );
869 $( "#upload_dialog_paygent" ).dialog( "option" , "title" , "証明済みのCAファイルのアップロード" );
870 $( "#upload_dialog_paygent" ).dialog( "open" );
871 } else {
872 alert( retVal.status );
873 return false;
874 }
875 }).fail( function( retVal ) {
876 });
877 return false;
878 });
879
880 $( "#upload_dialog_paygent" ).dialog({
881 bgiframe: true,
882 autoOpen: false,
883 height: 240,
884 width: 400,
885 modal: true,
886 buttons: {
887 "<?php esc_html_e( 'Cancel', 'usces' ); ?>": function() {
888 $( this ).dialog( 'close' );
889 }
890 },
891 close: function() {
892 $( "#upload_file" ).val( "" );
893 }
894 });
895
896 $( "#upload_button" ).on( "click", function() {
897 let $upfile = $( 'input[name="upload_file"]' );
898 let fd = new FormData();
899 fd.append( "action", 'upload_certificate_file' );
900 fd.append( "upfile", $upfile.prop( 'files' )[0] );
901 fd.append( "upfile_name", $upfile.prop( 'files' )[0].name );
902 fd.append( "upfile_type", $( "#upload_filetype" ).val() );
903 fd.append( "wc_nonce", $( "#wc_nonce" ).val() );
904 $.ajax({
905 url: ajaxurl,
906 type: "POST",
907 data: fd,
908 processData: false,
909 contentType: false,
910 cache: false,
911 }).done( function( retVal ) {
912 if ( "OK" == retVal.status ) {
913 if ( "client_file" == $( "#upload_filetype" ).val() ) {
914 $( "#client_file_paygent" ).val( $upfile.prop( 'files' )[0].name );
915 } else if ( "ca_file" == $( "#upload_filetype" ).val() ) {
916 $( "#ca_file_paygent" ).val( $upfile.prop( 'files' )[0].name );
917 }
918 $( "#upload_dialog_paygent" ).dialog( 'close' );
919 } else {
920 alert( "アップロードに失敗しました。" );
921 }
922 }).fail( function() {
923 console.log( retVal );
924 });
925 });
926 });
927 </script>
928 <?php
929 endif;
930 break;
931
932 /* 受注編集画面・継続課金会員詳細画面 */
933 case 'usces_orderlist':
934 case 'usces_continue':
935 $order_id = '';
936 $acting_flg = '';
937 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'] ) ) ) ) ||
938 ( 'usces_continue' == $admin_page && ( isset( $_GET['continue_action'] ) && 'settlement_paygent_card' == wp_unslash( $_GET['continue_action'] ) ) ) ) {
939 $order_id = ( isset( $_REQUEST['order_id'] ) ) ? wp_unslash( $_REQUEST['order_id'] ) : '';
940 if ( ! empty( $order_id ) ) {
941 $acting_flg = $this->get_order_acting_flg( $order_id );
942 }
943 }
944 if ( in_array( $acting_flg, $this->pay_method ) ) :
945 ?>
946 <script type="text/javascript">
947 jQuery( document ).ready( function( $ ) {
948 adminOrderEdit = {
949 updateSettlementStatus : function( mode ) {
950 $( "#settlement-response" ).html( "" );
951 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
952 $.ajax({
953 url: ajaxurl,
954 type: "POST",
955 cache: false,
956 dataType: "json",
957 data: {
958 action: "usces_admin_ajax",
959 mode: "get_paygent_" + mode,
960 order_id: $( "#order_id" ).val(),
961 trading_id: $( "#trading_id" ).val(),
962 member_id: $( "#member_id" ).val(),
963 wc_nonce: $( "#wc_nonce" ).val()
964 }
965 }).done( function( retVal, dataType ) {
966 if ( retVal.acting_status ) {
967 var num = $( "#order_num" ).val();
968 if ( $( "#settlement-status-" + num ).length ) {
969 $( "#settlement-status-" + num ).html( retVal.acting_status );
970 } else {
971 $( "#settlement-status" ).html( retVal.acting_status );
972 }
973 }
974 if ( retVal.result ) {
975 $( "#settlement-response" ).html( retVal.result );
976 }
977 $( "#settlement-response-loading" ).html( "" );
978 }).fail( function( jqXHR, textStatus, errorThrown ) {
979 console.log( textStatus );
980 console.log( jqXHR.status );
981 console.log( errorThrown.message );
982 $( "#settlement-response-loading" ).html( "" );
983 });
984 return false;
985 },
986 <?php
987 if ( 'acting_paygent_card' == $acting_flg ) :
988 ?>
989 getSettlementCard : function() {
990 $( "#settlement-response" ).html( "" );
991 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
992 var mode = ( "" != $( "#error" ).val() ) ? "error_paygent_card" : "get_paygent_card";
993 $.ajax({
994 url: ajaxurl,
995 type: "POST",
996 cache: false,
997 dataType: "json",
998 data: {
999 action: "usces_admin_ajax",
1000 mode: mode,
1001 order_id: $( "#order_id" ).val(),
1002 trading_id: $( "#trading_id" ).val(),
1003 member_id: $( "#member_id" ).val(),
1004 wc_nonce: $( "#wc_nonce" ).val()
1005 }
1006 }).done( function( retVal, dataType ) {
1007 if ( retVal.acting_status ) {
1008 var num = $( "#order_num" ).val();
1009 if ( $( "#settlement-status-" + num ).length ) {
1010 $( "#settlement-status-" + num ).html( retVal.acting_status );
1011 } else {
1012 $( "#settlement-status" ).html( retVal.acting_status );
1013 }
1014 }
1015 if ( retVal.result ) {
1016 $( "#settlement-response" ).html( retVal.result );
1017 }
1018 $( "#settlement-response-loading" ).html( "" );
1019 }).fail( function( jqXHR, textStatus, errorThrown ) {
1020 console.log( textStatus );
1021 console.log( jqXHR.status );
1022 console.log( errorThrown.message );
1023 $( "#settlement-response-loading" ).html( "" );
1024 });
1025 return false;
1026 },
1027 salesSettlementCard : function() {
1028 $( "#settlement-response" ).html( "" );
1029 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1030 $.ajax({
1031 url: ajaxurl,
1032 type: "POST",
1033 cache: false,
1034 dataType: "json",
1035 data: {
1036 action: "usces_admin_ajax",
1037 mode: "sales_paygent_card",
1038 order_id: $( "#order_id" ).val(),
1039 trading_id: $( "#trading_id" ).val(),
1040 member_id: $( "#member_id" ).val(),
1041 wc_nonce: $( "#wc_nonce" ).val()
1042 }
1043 }).done( function( retVal, dataType ) {
1044 if ( retVal.acting_status ) {
1045 var num = $( "#order_num" ).val();
1046 if ( $( "#settlement-status-" + num ).length ) {
1047 $( "#settlement-status-" + num ).html( retVal.acting_status );
1048 } else {
1049 $( "#settlement-status" ).html( retVal.acting_status );
1050 }
1051 }
1052 if ( retVal.result ) {
1053 $( "#settlement-response" ).html( retVal.result );
1054 }
1055 $( "#settlement-response-loading" ).html( "" );
1056 }).fail( function( jqXHR, textStatus, errorThrown ) {
1057 console.log( textStatus );
1058 console.log( jqXHR.status );
1059 console.log( errorThrown.message );
1060 $( "#settlement-response-loading" ).html( "" );
1061 });
1062 return false;
1063 },
1064 cancelSettlementCard : function( mode ) {
1065 $( "#settlement-response" ).html( "" );
1066 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1067 $.ajax({
1068 url: ajaxurl,
1069 type: "POST",
1070 cache: false,
1071 dataType: "json",
1072 data: {
1073 action: "usces_admin_ajax",
1074 mode: mode + "_cancel_paygent_card",
1075 order_id: $( "#order_id" ).val(),
1076 trading_id: $( "#trading_id" ).val(),
1077 member_id: $( "#member_id" ).val(),
1078 wc_nonce: $( "#wc_nonce" ).val()
1079 }
1080 }).done( function( retVal, dataType ) {
1081 if ( retVal.acting_status ) {
1082 var num = $( "#order_num" ).val();
1083 if ( $( "#settlement-status-" + num ).length ) {
1084 $( "#settlement-status-" + num ).html( retVal.acting_status );
1085 } else {
1086 $( "#settlement-status" ).html( retVal.acting_status );
1087 }
1088 }
1089 if ( retVal.result ) {
1090 $( "#settlement-response" ).html( retVal.result );
1091 }
1092 $( "#settlement-response-loading" ).html( "" );
1093 }).fail( function( jqXHR, textStatus, errorThrown ) {
1094 console.log( textStatus );
1095 console.log( jqXHR.status );
1096 console.log( errorThrown.message );
1097 $( "#settlement-response-loading" ).html( "" );
1098 });
1099 return false;
1100 },
1101 changeSettlementCard : function( mode, amount ) {
1102 $( "#settlement-response" ).html( "" );
1103 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1104 $.ajax({
1105 url: ajaxurl,
1106 type: "POST",
1107 cache: false,
1108 dataType: "json",
1109 data: {
1110 action: "usces_admin_ajax",
1111 mode: mode + "_revise_paygent_card",
1112 order_id: $( "#order_id" ).val(),
1113 trading_id: $( "#trading_id" ).val(),
1114 member_id: $( "#member_id" ).val(),
1115 amount: amount,
1116 wc_nonce: $( "#wc_nonce" ).val()
1117 }
1118 }).done( function( retVal, dataType ) {
1119 if ( retVal.acting_status ) {
1120 var num = $( "#order_num" ).val();
1121 if ( $( "#settlement-status-" + num ).length ) {
1122 $( "#settlement-status-" + num ).html( retVal.acting_status );
1123 } else {
1124 $( "#settlement-status" ).html( retVal.acting_status );
1125 }
1126 }
1127 if ( retVal.result ) {
1128 $( "#settlement-response" ).html( retVal.result );
1129 }
1130 $( "#settlement-response-loading" ).html( "" );
1131 }).fail( function( jqXHR, textStatus, errorThrown ) {
1132 console.log( textStatus );
1133 console.log( jqXHR.status );
1134 console.log( errorThrown.message );
1135 $( "#settlement-response-loading" ).html( "" );
1136 });
1137 return false;
1138 },
1139 authSettlementCard : function( amount ) {
1140 $( "#settlement-response" ).html( "" );
1141 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1142 $.ajax({
1143 url: ajaxurl,
1144 type: "POST",
1145 cache: false,
1146 dataType: "json",
1147 data: {
1148 action: "usces_admin_ajax",
1149 mode: "auth_paygent_card",
1150 order_id: $( "#order_id" ).val(),
1151 trading_id: $( "#trading_id" ).val(),
1152 member_id: $( "#member_id" ).val(),
1153 amount: amount,
1154 wc_nonce: $( "#wc_nonce" ).val()
1155 }
1156 }).done( function( retVal, dataType ) {
1157 if ( retVal.acting_status ) {
1158 var num = $( "#order_num" ).val();
1159 if ( $( "#settlement-status-" + num ).length ) {
1160 $( "#settlement-status-" + num ).html( retVal.acting_status );
1161 } else {
1162 $( "#settlement-status" ).html( retVal.acting_status );
1163 }
1164 }
1165 if ( retVal.result ) {
1166 $( "#settlement-response" ).html( retVal.result );
1167 }
1168 $( "#settlement-response-loading" ).html( "" );
1169 }).fail( function( jqXHR, textStatus, errorThrown ) {
1170 console.log( textStatus );
1171 console.log( jqXHR.status );
1172 console.log( errorThrown.message );
1173 $( "#settlement-response-loading" ).html( "" );
1174 });
1175 return false;
1176 },
1177 <?php
1178 elseif ( 'acting_paygent_conv' == $acting_flg ) :
1179 ?>
1180 getSettlementConv : function() {
1181 $( "#settlement-response" ).html( "" );
1182 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1183 $.ajax({
1184 url: ajaxurl,
1185 type: "POST",
1186 cache: false,
1187 dataType: "json",
1188 data: {
1189 action: "usces_admin_ajax",
1190 mode: "get_paygent_conv",
1191 order_id: $( "#order_id" ).val(),
1192 trading_id: $( "#trading_id" ).val(),
1193 wc_nonce: $( "#wc_nonce" ).val()
1194 }
1195 }).done( function( retVal, dataType ) {
1196 if ( retVal.acting_status ) {
1197 $( "#settlement-status" ).html( retVal.acting_status );
1198 }
1199 if ( retVal.result ) {
1200 $( "#settlement-response" ).html( retVal.result );
1201 }
1202 $( "#settlement-response-loading" ).html( "" );
1203 }).fail( function( jqXHR, textStatus, errorThrown ) {
1204 console.log( textStatus );
1205 console.log( jqXHR.status );
1206 console.log( errorThrown.message );
1207 $( "#settlement-response-loading" ).html( "" );
1208 });
1209 return false;
1210 },
1211 <?php
1212 elseif ( 'acting_paygent_atm' == $acting_flg ) :
1213 ?>
1214 getSettlementAtm : function() {
1215 $( "#settlement-response" ).html( "" );
1216 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1217 $.ajax({
1218 url: ajaxurl,
1219 type: "POST",
1220 cache: false,
1221 dataType: "json",
1222 data: {
1223 action: "usces_admin_ajax",
1224 mode: "get_paygent_atm",
1225 order_id: $( "#order_id" ).val(),
1226 trading_id: $( "#trading_id" ).val(),
1227 wc_nonce: $( "#wc_nonce" ).val()
1228 }
1229 }).done( function( retVal, dataType ) {
1230 if ( retVal.result ) {
1231 $( "#settlement-response" ).html( retVal.result );
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 <?php
1243 elseif ( 'acting_paygent_bank' == $acting_flg ) :
1244 ?>
1245 getSettlementBank : function() {
1246 $( "#settlement-response" ).html( "" );
1247 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1248 $.ajax({
1249 url: ajaxurl,
1250 type: "POST",
1251 cache: false,
1252 dataType: "json",
1253 data: {
1254 action: "usces_admin_ajax",
1255 mode: "get_paygent_bank",
1256 order_id: $( "#order_id" ).val(),
1257 trading_id: $( "#trading_id" ).val(),
1258 wc_nonce: $( "#wc_nonce" ).val()
1259 }
1260 }).done( function( retVal, dataType ) {
1261 if ( retVal.acting_status ) {
1262 $( "#settlement-status" ).html( retVal.acting_status );
1263 }
1264 if ( retVal.result ) {
1265 $( "#settlement-response" ).html( retVal.result );
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 <?php
1277 elseif ( 'acting_paygent_paidy' == $acting_flg ) :
1278 ?>
1279 getSettlementPaidy : function() {
1280 $( "#settlement-response" ).html( "" );
1281 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1282 $.ajax({
1283 url: ajaxurl,
1284 type: "POST",
1285 cache: false,
1286 dataType: "json",
1287 data: {
1288 action: "usces_admin_ajax",
1289 mode: "get_paygent_paidy",
1290 order_id: $( "#order_id" ).val(),
1291 trading_id: $( "#trading_id" ).val(),
1292 wc_nonce: $( "#wc_nonce" ).val()
1293 }
1294 }).done( function( retVal, dataType ) {
1295 if ( retVal.acting_status ) {
1296 $( "#settlement-status" ).html( retVal.acting_status );
1297 }
1298 if ( retVal.result ) {
1299 $( "#settlement-response" ).html( retVal.result );
1300 }
1301 if ( $( "#refund-settlement" ).length ) {
1302 $( "#refund-settlement" ).prop( "disabled", true );
1303 }
1304 $( "#settlement-response-loading" ).html( "" );
1305 }).fail( function( jqXHR, textStatus, errorThrown ) {
1306 console.log( textStatus );
1307 console.log( jqXHR.status );
1308 console.log( errorThrown.message );
1309 $( "#settlement-response-loading" ).html( "" );
1310 });
1311 return false;
1312 },
1313 cancelSettlementPaidy : function() {
1314 $( "#settlement-response" ).html( "" );
1315 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1316 $.ajax({
1317 url: ajaxurl,
1318 type: "POST",
1319 cache: false,
1320 dataType: "json",
1321 data: {
1322 action: "usces_admin_ajax",
1323 mode: "cancel_paygent_paidy",
1324 order_id: $( "#order_id" ).val(),
1325 trading_id: $( "#trading_id" ).val(),
1326 wc_nonce: $( "#wc_nonce" ).val()
1327 }
1328 }).done( function( retVal, dataType ) {
1329 if ( retVal.acting_status ) {
1330 $( "#settlement-status" ).html( retVal.acting_status );
1331 }
1332 if ( retVal.result ) {
1333 $( "#settlement-response" ).html( retVal.result );
1334 }
1335 if ( $( "#refund-settlement" ).length ) {
1336 $( "#refund-settlement" ).prop( "disabled", true );
1337 }
1338 $( "#settlement-response-loading" ).html( "" );
1339 }).fail( function( jqXHR, textStatus, errorThrown ) {
1340 console.log( textStatus );
1341 console.log( jqXHR.status );
1342 console.log( errorThrown.message );
1343 $( "#settlement-response-loading" ).html( "" );
1344 });
1345 return false;
1346 },
1347 captureSettlementPaidy : function() {
1348 $( "#settlement-response" ).html( "" );
1349 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1350 $.ajax({
1351 url: ajaxurl,
1352 type: "POST",
1353 cache: false,
1354 dataType: "json",
1355 data: {
1356 action: "usces_admin_ajax",
1357 mode: "capture_paygent_paidy",
1358 order_id: $( "#order_id" ).val(),
1359 trading_id: $( "#trading_id" ).val(),
1360 wc_nonce: $( "#wc_nonce" ).val()
1361 }
1362 }).done( function( retVal, dataType ) {
1363 if ( retVal.acting_status ) {
1364 $( "#settlement-status" ).html( retVal.acting_status );
1365 }
1366 if ( retVal.result ) {
1367 $( "#settlement-response" ).html( retVal.result );
1368 }
1369 if ( $( "#refund-settlement" ).length ) {
1370 $( "#refund-settlement" ).prop( "disabled", true );
1371 }
1372 $( "#settlement-response-loading" ).html( "" );
1373 }).fail( function( jqXHR, textStatus, errorThrown ) {
1374 console.log( textStatus );
1375 console.log( jqXHR.status );
1376 console.log( errorThrown.message );
1377 $( "#settlement-response-loading" ).html( "" );
1378 });
1379 return false;
1380 },
1381 refundSettlementPaidy : function( amount ) {
1382 $( "#settlement-response" ).html( "" );
1383 $( "#settlement-response-loading" ).html( '<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />' );
1384 $.ajax({
1385 url: ajaxurl,
1386 type: "POST",
1387 cache: false,
1388 dataType: "json",
1389 data: {
1390 action: "usces_admin_ajax",
1391 mode: "refund_paygent_paidy",
1392 order_id: $( "#order_id" ).val(),
1393 trading_id: $( "#trading_id" ).val(),
1394 amount: amount,
1395 wc_nonce: $( "#wc_nonce" ).val()
1396 }
1397 }).done( function( retVal, dataType ) {
1398 if ( retVal.acting_status ) {
1399 $( "#settlement-status" ).html( retVal.acting_status );
1400 }
1401 if ( retVal.result ) {
1402 $( "#settlement-response" ).html( retVal.result );
1403 }
1404 if ( $( "#refund-settlement" ).length ) {
1405 $( "#refund-settlement" ).prop( "disabled", true );
1406 }
1407 $( "#settlement-response-loading" ).html( "" );
1408 }).fail( function( jqXHR, textStatus, errorThrown ) {
1409 console.log( textStatus );
1410 console.log( jqXHR.status );
1411 console.log( errorThrown.message );
1412 $( "#settlement-response-loading" ).html( "" );
1413 });
1414 return false;
1415 },
1416 <?php
1417 endif;
1418 ?>
1419 };
1420
1421 $( "#settlement_dialog" ).dialog({
1422 dialogClass: "admin-paygent-dialog",
1423 bgiframe: true,
1424 autoOpen: false,
1425 height: "auto",
1426 width: 800,
1427 resizable: true,
1428 modal: true,
1429 buttons: {
1430 "<?php esc_html_e( 'Close' ); ?>": function() {
1431 $( this ).dialog( "close" );
1432 }
1433 },
1434 open: function() {
1435 <?php
1436 if ( 'acting_paygent_card' == $acting_flg ) :
1437 ?>
1438 adminOrderEdit.getSettlementCard();
1439 <?php
1440 elseif ( 'acting_paygent_conv' == $acting_flg ) :
1441 ?>
1442 adminOrderEdit.getSettlementConv();
1443 <?php
1444 elseif ( 'acting_paygent_atm' == $acting_flg ) :
1445 ?>
1446 adminOrderEdit.getSettlementAtm();
1447 <?php
1448 elseif ( 'acting_paygent_bank' == $acting_flg ) :
1449 ?>
1450 adminOrderEdit.getSettlementBank();
1451 <?php
1452 elseif ( 'acting_paygent_paidy' == $acting_flg ) :
1453 ?>
1454 adminOrderEdit.getSettlementPaidy();
1455 <?php
1456 endif;
1457 ?>
1458 },
1459 close: function() {
1460 }
1461 });
1462
1463 $( document ).on( "click", ".settlement-information", function() {
1464 var trading_id = $( this ).attr( "data-trading_id" );
1465 var order_num = $( this ).attr( "data-num" );
1466 $( "#trading_id" ).val( trading_id );
1467 $( "#order_num" ).val( order_num );
1468 $( "#settlement_dialog" ).dialog( "option", "title", "<?php echo esc_js( $this->acting_formal_name ); ?>" );
1469 $( "#settlement_dialog" ).dialog( "open" );
1470 });
1471
1472 $( document ).on( "click", "#update-status", function() {
1473 var mode = $( this ).attr( "data-mode" );
1474 adminOrderEdit.updateSettlementStatus( mode );
1475 });
1476 <?php
1477 if ( 'acting_paygent_card' == $acting_flg ) :
1478 ?>
1479 $( document ).on( "click", "#sales-settlement", function() {
1480 if ( ! confirm( "売上処理を実行します。よろしいですか?" ) ) {
1481 return;
1482 }
1483 adminOrderEdit.salesSettlementCard();
1484 });
1485
1486 $( document ).on( "click", "#auth-cancel-settlement", function() {
1487 if ( ! confirm( "キャンセル処理を実行します。よろしいですか?" ) ) {
1488 return;
1489 }
1490 adminOrderEdit.cancelSettlementCard( 'auth' );
1491 });
1492
1493 $( document ).on( "click", "#sales-cancel-settlement", function() {
1494 if ( ! confirm( "キャンセル処理を実行します。よろしいですか?" ) ) {
1495 return;
1496 }
1497 adminOrderEdit.cancelSettlementCard( 'sales' );
1498 });
1499
1500 $( document ).on( "click", "#auth-revise-settlement", function() {
1501 var amount_change = parseInt( $( "#amount_change" ).val() ) || 0;
1502 if ( 0 == amount_change ) {
1503 if ( ! confirm( "キャンセル処理を実行します。よろしいですか?" ) ) {
1504 return;
1505 }
1506 adminOrderEdit.cancelSettlementCard( 'auth' );
1507 } else {
1508 if ( ! confirm( "決済金額を" + amount_change + "円に変更します。よろしいですか?" ) ) {
1509 return;
1510 }
1511 adminOrderEdit.changeSettlementCard( 'auth', amount_change );
1512 }
1513 });
1514
1515 $( document ).on( "click", "#sales-revise-settlement", function() {
1516 var amount_change = parseInt( $( "#amount_change" ).val() ) || 0;
1517 if ( 0 == amount_change ) {
1518 if ( ! confirm( "キャンセル処理を実行します。よろしいですか?" ) ) {
1519 return;
1520 }
1521 adminOrderEdit.cancelSettlementCard( 'auth' );
1522 } else {
1523 if ( ! confirm( "決済金額を" + amount_change + "円に変更します。よろしいですか?" ) ) {
1524 return;
1525 }
1526 adminOrderEdit.changeSettlementCard( 'sales', amount_change );
1527 }
1528 });
1529
1530 $( document ).on( "click", "#auth-settlement", function() {
1531 var amount = parseInt( $( "#amount_change" ).val() ) || 0;
1532 if ( 0 < amount ) {
1533 if ( ! confirm( "新規オーソリを実行します。よろしいですか?" ) ) {
1534 return;
1535 }
1536 adminOrderEdit.authSettlementCard( amount );
1537 }
1538 });
1539 <?php
1540 elseif ( 'acting_paygent_paidy' == $acting_flg ) :
1541 ?>
1542 $( document ).on( "click", "#paidy-capture-settlement", function() {
1543 if ( ! confirm( "売上処理を実行します。よろしいですか?" ) ) {
1544 return;
1545 }
1546 adminOrderEdit.captureSettlementPaidy();
1547 });
1548
1549 $( document ).on( "click", "#paidy-cancel-settlement", function() {
1550 if ( ! confirm( "キャンセル処理を実行します。よろしいですか?" ) ) {
1551 return;
1552 }
1553 adminOrderEdit.cancelSettlementPaidy();
1554 });
1555
1556 $( document ).on( "click", "#paidy-refund-settlement", function() {
1557 var amount_original = parseInt( $( "#amount_original" ).val() ) || 0;
1558 var amount_change = parseInt( $( "#amount_change" ).val() ) || 0;
1559 if ( amount_change == amount_original ) {
1560 return;
1561 }
1562 if ( amount_change > amount_original ) {
1563 alert( "決済金額を�
1564 える金額は返金できません。" );
1565 return;
1566 }
1567 if ( 0 == amount_change ) {
1568 if ( ! confirm( "�
1569 �額返金処理を実行します。よろしいですか?" ) ) {
1570 return;
1571 }
1572 adminOrderEdit.refundSettlementPaidy( amount_original );
1573 } else {
1574 var amount = amount_original - amount_change;
1575 if ( ! confirm( amount + "円の返金処理を実行します。よろしいですか?" ) ) {
1576 return;
1577 }
1578 adminOrderEdit.refundSettlementPaidy( amount );
1579 }
1580 });
1581 <?php
1582 endif;
1583 ?>
1584 $( document ).on( "keydown", ".settlement-amount", function( e ) {
1585 var halfVal = $( this ).val().replace( /[!-~]/g,
1586 function( tmpStr ) {
1587 return String.fromCharCode( tmpStr.charCodeAt(0) - 0xFEE0 );
1588 }
1589 );
1590 $( this ).val( halfVal.replace( /[^0-9]/g, '' ) );
1591 });
1592 $( document ).on( "keyup", ".settlement-amount", function() {
1593 this.value = this.value.replace( /[^0-9]+/i, '' );
1594 this.value = Number( this.value ) || 0;
1595 });
1596 $( document ).on( "blur", ".settlement-amount", function() {
1597 this.value = this.value.replace( /[^0-9]+/i, '' );
1598 });
1599 <?php if ( 'usces_continue' == $admin_page ) : ?>
1600 adminContinuation = {
1601 update : function() {
1602 $.ajax({
1603 url: ajaxurl,
1604 type: "POST",
1605 cache: false,
1606 dataType: 'json',
1607 data: {
1608 action: "usces_admin_ajax",
1609 mode: "continuation_update",
1610 member_id: $( "#member_id" ).val(),
1611 order_id: $( "#order_id" ).val(),
1612 contracted_year: $( "#contracted-year option:selected" ).val(),
1613 contracted_month: $( "#contracted-month option:selected" ).val(),
1614 contracted_day: $( "#contracted-day option:selected" ).val(),
1615 charged_year: $( "#charged-year option:selected" ).val(),
1616 charged_month: $( "#charged-month option:selected" ).val(),
1617 charged_day: $( "#charged-day option:selected" ).val(),
1618 price: $( "#price" ).val(),
1619 status: $( "#dlseller-status" ).val(),
1620 wc_nonce: $( "#wc_nonce" ).val()
1621 }
1622 }).done( function( retVal, dataType ) {
1623 if ( "OK" == retVal.status ) {
1624 adminOperation.setActionStatus( "success", "<?php esc_html_e( 'The update was completed.', 'usces' ); ?>" );
1625 } else {
1626 var message = ( retVal.message != "" ) ? retVal.message : "<?php esc_html_e( 'failure in update', 'usces' ); ?>";
1627 adminOperation.setActionStatus( "error", message );
1628 }
1629 }).fail( function( jqXHR, textStatus, errorThrown ) {
1630 console.log( textStatus );
1631 console.log( jqXHR.status );
1632 console.log( errorThrown.message );
1633 adminOperation.setActionStatus( "error", "<?php esc_html_e( 'failure in update', 'usces' ); ?>" );
1634 });
1635 return false;
1636 }
1637 };
1638
1639 $( document ).on( "click", "#continuation-update", function() {
1640 var status = $( "#dlseller-status option:selected" ).val();
1641 if ( "continuation" == status ) {
1642 var year = $( "#charged-year option:selected" ).val();
1643 var month = $( "#charged-month option:selected" ).val();
1644 var day = $( "#charged-day option:selected" ).val();
1645 if ( 0 == year || 0 == month || 0 == day ) {
1646 alert( "<?php esc_html_e( 'Data have deficiency.', 'usces' ); ?>" );
1647 $( "#charged-year" ).focus();
1648 return;
1649 }
1650 if ( "" == $( "#price" ).val() || 0 == parseFloat( $( "#price" ).val() ) ) {
1651 alert( "<?php printf( __( 'Input the %s', 'usces' ), esc_html__( 'Amount', 'dlseller' ) ); ?>" );
1652 $( "#price" ).focus();
1653 return;
1654 }
1655 }
1656 if ( ! confirm( "<?php esc_html_e( 'Are you sure you want to update the settings?', 'usces' ); ?>" ) ) {
1657 return;
1658 }
1659 adminContinuation.update();
1660 });
1661 <?php endif; ?>
1662 });
1663 </script>
1664 <?php
1665 endif;
1666 break;
1667 endswitch;
1668 }
1669
1670 /**
1671 * Certificate file path check.
1672 */
1673 public function check_file_path() {
1674 if ( ! current_user_can( 'wel_manage_setting' ) ) {
1675 wp_send_json_error( array( 'message' => 'Forbidden' ), 403 );
1676 }
1677 check_admin_referer( 'admin_settlement', 'wc_nonce' );
1678 $post_data = wp_unslash( $_POST );
1679 $certificate_path = ( isset( $post_data['path'] ) ) ? rtrim( $post_data['path'], '/' ) : '';
1680 $invalid_wrappers = array( 'phar://', 'php://', 'data://', 'zip://', 'rar://' );
1681 foreach ( $invalid_wrappers as $wrapper ) {
1682 if ( strpos( $certificate_path, $wrapper ) === 0 ) {
1683 $data['status'] = '無効なファイルパスです';
1684 wp_send_json( $data );
1685 return;
1686 }
1687 }
1688 if ( empty( $certificate_path ) ) {
1689 $data['status'] = '証明書ファイルパスが指定されていません';
1690 } else {
1691 if ( ! is_dir( $certificate_path ) ) {
1692 wp_mkdir_p( $certificate_path );
1693 }
1694 $this->protect_certificate_dir( $certificate_path );
1695 if ( ! empty( $post_data['file'] ) ) {
1696 $full_path = $certificate_path . '/' . $post_data['file'];
1697 foreach ( $invalid_wrappers as $wrapper ) {
1698 if ( strpos( $full_path, $wrapper ) !== false ) {
1699 $data['status'] = '無効なファイルパスです';
1700 wp_send_json( $data );
1701 return;
1702 }
1703 }
1704 if ( file_exists( $full_path ) ) {
1705 $data['file_exists'] = 1;
1706 }
1707 }
1708 $data['status'] = ( is_writable( $certificate_path ) ) ? 'OK' : '証明書ファイルパスのディレクトリに書き込み権限がありません';
1709 }
1710 wp_send_json( $data );
1711 }
1712
1713 /**
1714 * Upload paygent certificate file.
1715 */
1716 public function upload_certificate_file() {
1717 if ( ! current_user_can( 'wel_manage_setting' ) ) {
1718 wp_send_json_error( array( 'message' => 'Forbidden' ), 403 );
1719 }
1720 check_admin_referer( 'admin_settlement', 'wc_nonce' );
1721 $upfile = $_FILES['upfile'];
1722 $acting_opts = $this->get_acting_settings();
1723 $data = array( 'status' => '' );
1724 $filename = $upfile['name'];
1725 if ( strrpos( $filename, '.' ) === false ) {
1726 $data['status'] = 'NG';
1727 wp_send_json( $data );
1728 return;
1729 }
1730 $ext = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) );
1731 $type = ( isset( $_POST['upfile_type'] ) ) ? ( $_POST['upfile_type'] ) : '';
1732 if ( 'client_file' === $type ) {
1733 if ( 'pem' !== $ext ) {
1734 $data['status'] = 'NG';
1735 }
1736 } elseif ( 'ca_file' === $type ) {
1737 if ( 'crt' !== $ext ) {
1738 $data['status'] = 'NG';
1739 }
1740 } else {
1741 $data['status'] = 'NG';
1742 }
1743 if ( 'NG' != $data['status'] ) {
1744 if ( 0 < $upfile['error'] ) {
1745 $data['status'] = $upfile['error'];
1746 } else {
1747 $this->protect_certificate_dir( $acting_opts['certificate_path'] );
1748 $filename = sanitize_file_name( $upfile['name'] );
1749 $res = move_uploaded_file( $upfile['tmp_name'], $acting_opts['certificate_path'] . '/' . $filename );
1750 if ( $res ) {
1751 $data['status'] = 'OK';
1752 } else {
1753 $data['status'] = 'NG';
1754 }
1755 }
1756 }
1757 wp_send_json( $data );
1758 }
1759
1760 /**
1761 * 決済オプション登録・更新
1762 * usces_action_admin_settlement_update
1763 */
1764 public function settlement_update() {
1765 global $usces;
1766
1767 if ( $this->paymod_id != wp_unslash( $_POST['acting'] ) ) {
1768 return;
1769 }
1770
1771 $this->error_mes = '';
1772 $payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
1773 $options = get_option( 'usces', array() );
1774 $certificate_path = $options['acting_settings']['paygent']['certificate_path'];
1775 $post_data = wp_unslash( $_POST );
1776
1777 unset( $options['acting_settings']['paygent'] );
1778 $options['acting_settings']['paygent']['seq_merchant_id'] = ( isset( $post_data['seq_merchant_id'] ) ) ? trim( $post_data['seq_merchant_id'] ) : '';
1779 $options['acting_settings']['paygent']['connect_id'] = ( isset( $post_data['connect_id'] ) ) ? trim( $post_data['connect_id'] ) : '';
1780 $options['acting_settings']['paygent']['connect_password'] = ( isset( $post_data['connect_password'] ) ) ? trim( $post_data['connect_password'] ) : '';
1781 $options['acting_settings']['paygent']['telegram_version'] = TELEGRAM_VERSION;
1782 $options['acting_settings']['paygent']['hc'] = ( isset( $post_data['hc'] ) ) ? trim( $post_data['hc'] ) : '';
1783 $options['acting_settings']['paygent']['conv_hc'] = ( isset( $post_data['conv_hc'] ) ) ? trim( $post_data['conv_hc'] ) : '';
1784 $options['acting_settings']['paygent']['ope'] = ( isset( $post_data['ope'] ) ) ? $post_data['ope'] : '';
1785 $options['acting_settings']['paygent']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : 'off';
1786 $options['acting_settings']['paygent']['token_key'] = ( isset( $post_data['token_key'] ) ) ? trim( $post_data['token_key'] ) : '';
1787 $options['acting_settings']['paygent']['token_hc'] = ( isset( $post_data['token_hc'] ) ) ? trim( $post_data['token_hc'] ) : '';
1788 $options['acting_settings']['paygent']['client_file'] = ( isset( $post_data['client_file'] ) ) ? trim( $post_data['client_file'] ) : '';
1789 $options['acting_settings']['paygent']['ca_file'] = ( isset( $post_data['ca_file'] ) ) ? trim( $post_data['ca_file'] ) : '';
1790 $options['acting_settings']['paygent']['payment_class'] = ( isset( $post_data['payment_class'] ) ) ? $post_data['payment_class'] : '0';
1791 $options['acting_settings']['paygent']['use_card_conf_number'] = ( isset( $post_data['use_card_conf_number'] ) ) ? $post_data['use_card_conf_number'] : 'off';
1792 $options['acting_settings']['paygent']['stock_card_mode'] = ( isset( $post_data['stock_card_mode'] ) ) ? $post_data['stock_card_mode'] : 'off';
1793 $options['acting_settings']['paygent']['sales_mode'] = ( isset( $post_data['sales_mode'] ) ) ? $post_data['sales_mode'] : '0';
1794 $options['acting_settings']['paygent']['sales_mode_dlseller'] = ( isset( $post_data['sales_mode_dlseller'] ) ) ? $post_data['sales_mode_dlseller'] : '0';
1795 $options['acting_settings']['paygent']['auto_settlement_mail'] = ( isset( $post_data['auto_settlement_mail'] ) ) ? $post_data['auto_settlement_mail'] : 'off';
1796 $options['acting_settings']['paygent']['threedsecure_ryaku'] = ( isset( $post_data['threedsecure_ryaku'] ) ) ? $post_data['threedsecure_ryaku'] : 'off';
1797 $options['acting_settings']['paygent']['threedsecure_hc'] = ( isset( $post_data['threedsecure_hc'] ) ) ? trim( $post_data['threedsecure_hc'] ) : '';
1798 $options['acting_settings']['paygent']['attempt'] = ( isset( $post_data['attempt'] ) ) ? $post_data['attempt'] : 'on';
1799 $options['acting_settings']['paygent']['conv_activate'] = ( isset( $post_data['conv_activate'] ) ) ? $post_data['conv_activate'] : 'off';
1800 $options['acting_settings']['paygent']['payment_term_day'] = ( isset( $post_data['payment_term_day'] ) ) ? $post_data['payment_term_day'] : '5';
1801 $options['acting_settings']['paygent']['payment_term_min'] = ( isset( $post_data['payment_term_min'] ) ) ? $post_data['payment_term_min'] : '';
1802 $options['acting_settings']['paygent']['sales_type'] = ( isset( $post_data['sales_type'] ) ) ? $post_data['sales_type'] : '1';
1803 $options['acting_settings']['paygent']['cvs_type'] = ( isset( $post_data['cvs_type'] ) ) ? $post_data['cvs_type'] : array( '01', '02', '03', '04' );
1804 $options['acting_settings']['paygent']['atm_activate'] = ( isset( $post_data['atm_activate'] ) ) ? $post_data['atm_activate'] : 'off';
1805 $options['acting_settings']['paygent']['payment_limit_date'] = ( isset( $post_data['payment_limit_date'] ) ) ? $post_data['payment_limit_date'] : '';
1806 $options['acting_settings']['paygent']['bank_activate'] = ( isset( $post_data['bank_activate'] ) ) ? $post_data['bank_activate'] : 'off';
1807 $options['acting_settings']['paygent']['asp_payment_term'] = ( isset( $post_data['asp_payment_term'] ) ) ? $post_data['asp_payment_term'] : '0050000';
1808 $options['acting_settings']['paygent']['paidy_activate'] = ( isset( $post_data['paidy_activate'] ) ) ? $post_data['paidy_activate'] : 'off';
1809 $options['acting_settings']['paygent']['paidy_public_key'] = ( isset( $post_data['paidy_public_key'] ) ) ? $post_data['paidy_public_key'] : '';
1810 if ( ! isset( $post_data['certificate_path'] ) || WCUtils::is_blank( $post_data['certificate_path'] ) ) {
1811 $certificate_path_before = ( isset( $post_data['certificate_path_before'] ) ) ? $post_data['certificate_path_before'] : '';
1812 if ( empty( $certificate_path ) || $certificate_path_before != $certificate_path ) {
1813 $upload_dir = wp_upload_dir();
1814 $dir = $this->create_certificate_path();
1815 $options['acting_settings']['paygent']['certificate_path'] = $upload_dir['basedir'] . $dir;
1816 } else {
1817 $options['acting_settings']['paygent']['certificate_path'] = $certificate_path;
1818 }
1819 } else {
1820 $options['acting_settings']['paygent']['certificate_path'] = rtrim( trim( $post_data['certificate_path'] ), '/' );
1821 }
1822
1823 if ( WCUtils::is_blank( $options['acting_settings']['paygent']['seq_merchant_id'] ) ) {
1824 $this->error_mes .= '※マーチャントIDを�
1825 �力してください<br />';
1826 }
1827 if ( 'on' == $options['acting_settings']['paygent']['card_activate'] || 'on' == $options['acting_settings']['paygent']['conv_activate'] ) {
1828 if ( WCUtils::is_blank( $options['acting_settings']['paygent']['hc'] ) ) {
1829 $this->error_mes .= '※ハッシュ値生成キーを�
1830 �力してください<br />';
1831 }
1832 } elseif ( 'module' == $options['acting_settings']['paygent']['card_activate'] || 'module' == $options['acting_settings']['paygent']['conv_activate'] ) {
1833 if ( '' == $options['acting_settings']['paygent']['connect_id'] ) {
1834 $this->error_mes .= '※接続IDを�
1835 �力してください<br />';
1836 }
1837 if ( '' == $options['acting_settings']['paygent']['connect_password'] ) {
1838 $this->error_mes .= '※接続パスワードを�
1839 �力してください<br />';
1840 }
1841 if ( '' != $options['acting_settings']['paygent']['client_file'] ) {
1842 if ( ! file_exists( $options['acting_settings']['paygent']['certificate_path'] . '/' . $options['acting_settings']['paygent']['client_file'] ) ) {
1843 $this->error_mes .= '※クライアント証明書ファイルがアップロードされていません<br />';
1844 }
1845 }
1846 if ( '' != $options['acting_settings']['paygent']['ca_file'] ) {
1847 if ( ! file_exists( $options['acting_settings']['paygent']['certificate_path'] . '/' . $options['acting_settings']['paygent']['ca_file'] ) ) {
1848 $this->error_mes .= '※CAファイルがアップロードされていません<br />';
1849 }
1850 }
1851 }
1852 if ( WCUtils::is_blank( $options['acting_settings']['paygent']['ope'] ) ) {
1853 $this->error_mes .= '※稼働環境を選択してください<br />';
1854 }
1855 if ( WCUtils::is_blank( $options['acting_settings']['paygent']['conv_hc'] ) ) {
1856 $this->error_mes .= '※差分通知ハッシュ値生成キーを�
1857 �力してください<br />';
1858 }
1859 if ( 'on' == $options['acting_settings']['paygent']['conv_activate'] ) {
1860 if ( '' == $options['acting_settings']['paygent']['payment_term_day'] && '' == $options['acting_settings']['paygent']['payment_term_min'] ) {
1861 } elseif ( '' != $options['acting_settings']['paygent']['payment_term_day'] && '' != $options['acting_settings']['paygent']['payment_term_min'] ) {
1862 $this->error_mes .= '※「支払期間(日指定)」と「支払期間(分指定)」の両方を指定することはできません<br />';
1863 } elseif ( '' != $options['acting_settings']['paygent']['payment_term_day'] ) {
1864 $term_day = (int) $options['acting_settings']['paygent']['payment_term_day'];
1865 if ( 2 > $term_day || 60 < $term_day ) {
1866 $this->error_mes .= '※「支払期間(日指定)」が指定できる範囲を�
1867 えています<br />';
1868 }
1869 } elseif ( '' != $options['acting_settings']['paygent']['payment_term_min'] ) {
1870 $term_min = (int) $options['acting_settings']['paygent']['payment_term_min'];
1871 if ( 5 > $term_min || 2880 < $term_min ) {
1872 $this->error_mes .= '※「支払期間(分指定)」が指定できる範囲を�
1873 えています<br />';
1874 }
1875 }
1876 } elseif ( 'module' == $options['acting_settings']['paygent']['conv_activate'] ) {
1877 if ( empty( $options['acting_settings']['paygent']['cvs_type'] ) ) {
1878 $this->error_mes .= '※申込コンビニを選択してください<br />';
1879 }
1880 }
1881
1882 if ( 'module' == $options['acting_settings']['paygent']['paidy_activate'] ) {
1883 if ( WCUtils::is_blank( $options['acting_settings']['paygent']['paidy_public_key'] ) ) {
1884 $this->error_mes .= '※パブリックキーを�
1885 �力してください<br />';
1886 }
1887 }
1888
1889 if ( '' == $this->error_mes ) {
1890 $usces->action_status = 'success';
1891 $usces->action_message = __( 'Options are updated.', 'usces' );
1892 $toactive = array();
1893 if ( 'on' == $options['acting_settings']['paygent']['card_activate'] || 'module' == $options['acting_settings']['paygent']['card_activate'] ) {
1894 $usces->payment_structure['acting_paygent_card'] = 'カード決済(' . $this->acting_name . '';
1895 if ( '' == $options['acting_settings']['paygent']['payment_class'] ) {
1896 $options['acting_settings']['paygent']['payment_class'] = '0';
1897 }
1898 if ( '' == $options['acting_settings']['paygent']['use_card_conf_number'] ) {
1899 $options['acting_settings']['paygent']['use_card_conf_number'] = 'off';
1900 }
1901 if ( '' == $options['acting_settings']['paygent']['stock_card_mode'] ) {
1902 $options['acting_settings']['paygent']['stock_card_mode'] = 'off';
1903 }
1904 if ( '' == $options['acting_settings']['paygent']['threedsecure_ryaku'] ) {
1905 $options['acting_settings']['paygent']['threedsecure_ryaku'] = 'off';
1906 }
1907 foreach ( $payment_method as $settlement => $payment ) {
1908 if ( 'acting_paygent_card' == $settlement && 'deactivate' == $payment['use'] ) {
1909 $toactive[] = $payment['name'];
1910 }
1911 }
1912 } else {
1913 unset( $usces->payment_structure['acting_paygent_card'] );
1914 }
1915 if ( 'on' == $options['acting_settings']['paygent']['conv_activate'] || 'module' == $options['acting_settings']['paygent']['conv_activate'] ) {
1916 $usces->payment_structure['acting_paygent_conv'] = 'コンビニ決済(' . $this->acting_name . '';
1917 if ( '' == $options['acting_settings']['paygent']['payment_term_day'] && '' == $options['acting_settings']['paygent']['payment_term_min'] ) {
1918 $options['acting_settings']['paygent']['payment_term_day'] = 5;
1919 }
1920 foreach ( $payment_method as $settlement => $payment ) {
1921 if ( 'acting_paygent_conv' == $settlement && 'deactivate' == $payment['use'] ) {
1922 $toactive[] = $payment['name'];
1923 }
1924 }
1925 } else {
1926 unset( $usces->payment_structure['acting_paygent_conv'] );
1927 }
1928 if ( 'module' == $options['acting_settings']['paygent']['atm_activate'] ) {
1929 $usces->payment_structure['acting_paygent_atm'] = 'ATM決済(' . $this->acting_name . '';
1930 foreach ( $payment_method as $settlement => $payment ) {
1931 if ( 'acting_paygent_atm' == $settlement && 'deactivate' == $payment['use'] ) {
1932 $toactive[] = $payment['name'];
1933 }
1934 }
1935 } else {
1936 unset( $usces->payment_structure['acting_paygent_atm'] );
1937 }
1938 if ( 'module' == $options['acting_settings']['paygent']['bank_activate'] ) {
1939 $usces->payment_structure['acting_paygent_bank'] = '銀行ネット決済(' . $this->acting_name . '';
1940 foreach ( $payment_method as $settlement => $payment ) {
1941 if ( 'acting_paygent_bank' == $settlement && 'deactivate' == $payment['use'] ) {
1942 $toactive[] = $payment['name'];
1943 }
1944 }
1945 } else {
1946 unset( $usces->payment_structure['acting_paygent_bank'] );
1947 }
1948 if ( 'module' == $options['acting_settings']['paygent']['paidy_activate'] ) {
1949 $usces->payment_structure['acting_paygent_paidy'] = 'Paidy(' . $this->acting_name . '';
1950 foreach ( $payment_method as $settlement => $payment ) {
1951 if ( 'acting_paygent_paidy' == $settlement && 'deactivate' == $payment['use'] ) {
1952 $toactive[] = $payment['name'];
1953 }
1954 }
1955 } else {
1956 unset( $usces->payment_structure['acting_paygent_paidy'] );
1957 }
1958 if ( ( 'on' == $options['acting_settings']['paygent']['card_activate'] || 'module' == $options['acting_settings']['paygent']['card_activate'] ) ||
1959 ( 'on' == $options['acting_settings']['paygent']['conv_activate'] || 'module' == $options['acting_settings']['paygent']['conv_activate'] ) ||
1960 'module' == $options['acting_settings']['paygent']['atm_activate'] ||
1961 'module' == $options['acting_settings']['paygent']['bank_activate'] ||
1962 'module' == $options['acting_settings']['paygent']['paidy_activate'] ) {
1963 $options['acting_settings']['paygent']['activate'] = 'on';
1964 if ( 'public' == $options['acting_settings']['paygent']['ope'] ) {
1965 $options['acting_settings']['paygent']['send_url'] = 'https://link.paygent.co.jp/v/u/request';
1966 $options['acting_settings']['paygent']['token_url'] = 'https://token.paygent.co.jp/js/PaygentToken.js';
1967 } else {
1968 $options['acting_settings']['paygent']['send_url'] = 'https://sandbox.paygent.co.jp/v/u/request';
1969 $options['acting_settings']['paygent']['token_url'] = 'https://sandbox.paygent.co.jp/js/PaygentToken.js';
1970 }
1971 usces_admin_orderlist_show_wc_trans_id();
1972 if ( 0 < count( $toactive ) ) {
1973 $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' );
1974 }
1975 } else {
1976 $options['acting_settings']['paygent']['activate'] = 'off';
1977 unset( $usces->payment_structure['acting_paygent_card'] );
1978 unset( $usces->payment_structure['acting_paygent_conv'] );
1979 unset( $usces->payment_structure['acting_paygent_atm'] );
1980 unset( $usces->payment_structure['acting_paygent_bank'] );
1981 unset( $usces->payment_structure['acting_paygent_paidy'] );
1982 }
1983 $deactivate = array();
1984 foreach ( $payment_method as $settlement => $payment ) {
1985 if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
1986 if ( 'deactivate' != $payment['use'] ) {
1987 $payment['use'] = 'deactivate';
1988 $deactivate[] = $payment['name'];
1989 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
1990 }
1991 }
1992 }
1993 if ( 0 < count( $deactivate ) ) {
1994 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
1995 $usces->action_message .= $deactivate_message;
1996 }
1997 } else {
1998 $usces->action_status = 'error';
1999 $usces->action_message = __( 'Data have deficiency.', 'usces' );
2000 $options['acting_settings']['paygent']['activate'] = 'off';
2001 unset( $usces->payment_structure['acting_paygent_card'] );
2002 unset( $usces->payment_structure['acting_paygent_conv'] );
2003 unset( $usces->payment_structure['acting_paygent_atm'] );
2004 unset( $usces->payment_structure['acting_paygent_bank'] );
2005 unset( $usces->payment_structure['acting_paygent_paidy'] );
2006 $deactivate = array();
2007 foreach ( $payment_method as $settlement => $payment ) {
2008 if ( in_array( $settlement, $this->pay_method ) ) {
2009 if ( 'deactivate' != $payment['use'] ) {
2010 $payment['use'] = 'deactivate';
2011 $deactivate[] = $payment['name'];
2012 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
2013 }
2014 }
2015 }
2016 if ( 0 < count( $deactivate ) ) {
2017 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
2018 $usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
2019 }
2020 }
2021
2022 ksort( $usces->payment_structure );
2023 update_option( 'usces', $options );
2024 update_option( 'usces_payment_structure', $usces->payment_structure );
2025 }
2026
2027 /**
2028 * クレジット決済設定画面タブ
2029 * usces_action_settlement_tab_title
2030 */
2031 public function settlement_tab_title() {
2032 $settlement_selected = get_option( 'usces_settlement_selected' );
2033 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) {
2034 echo '<li><a href="#uscestabs_' . esc_html( $this->paymod_id ) . '">' . esc_html( $this->acting_name ) . '</a></li>';
2035 }
2036 }
2037
2038 /**
2039 * クレジット決済設定画面フォーム
2040 * usces_action_settlement_tab_body
2041 */
2042 public function settlement_tab_body() {
2043 global $usces;
2044
2045 $acting_opts = $this->get_acting_settings();
2046 $settlement_selected = get_option( 'usces_settlement_selected' );
2047 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) :
2048 /* 証明書ディレクトリの遮断ファイルを点検する. */
2049 $this->protect_certificate_dir( ( isset( $acting_opts['certificate_path'] ) ) ? $acting_opts['certificate_path'] : '' );
2050
2051 $seq_merchant_id = ( isset( $acting_opts['seq_merchant_id'] ) ) ? $acting_opts['seq_merchant_id'] : '';
2052 $connect_id = ( isset( $acting_opts['connect_id'] ) ) ? $acting_opts['connect_id'] : '';
2053 $connect_password = ( isset( $acting_opts['connect_password'] ) ) ? $acting_opts['connect_password'] : '';
2054 $hc = ( isset( $acting_opts['hc'] ) ) ? $acting_opts['hc'] : '';
2055 $conv_hc = ( isset( $acting_opts['conv_hc'] ) ) ? $acting_opts['conv_hc'] : '';
2056 $ope_test = '';
2057 $ope_public = '';
2058 if ( isset( $acting_opts['ope'] ) && 'public' == $acting_opts['ope'] ) {
2059 $ope_public = ' checked="checked"';
2060 } else {
2061 $ope_test = ' checked="checked"'; /* default */
2062 }
2063 $card_activate_link = '';
2064 $card_activate_module = '';
2065 $card_activate_off = '';
2066 if ( isset( $acting_opts['card_activate'] ) && 'on' == $acting_opts['card_activate'] ) {
2067 $card_activate_link = ' checked="checked"';
2068 } elseif ( isset( $acting_opts['card_activate'] ) && 'module' == $acting_opts['card_activate'] ) {
2069 $card_activate_module = ' checked="checked"';
2070 } else {
2071 $card_activate_off = ' checked="checked"';
2072 }
2073 $token_key = ( isset( $acting_opts['token_key'] ) ) ? $acting_opts['token_key'] : '';
2074 $token_hc = ( isset( $acting_opts['token_hc'] ) ) ? $acting_opts['token_hc'] : '';
2075 $certificate_path = ( isset( $acting_opts['certificate_path'] ) ) ? $acting_opts['certificate_path'] : '';
2076 $client_file = ( isset( $acting_opts['client_file'] ) ) ? $acting_opts['client_file'] : '';
2077 $ca_file = ( isset( $acting_opts['ca_file'] ) ) ? $acting_opts['ca_file'] : '';
2078 $client_file_disabled = '';
2079 $ca_file_disabled = '';
2080 $payment_class_0 = '';
2081 $payment_class_1 = '';
2082 $payment_class_2 = '';
2083 if ( isset( $acting_opts['payment_class'] ) && '1' == $acting_opts['payment_class'] ) {
2084 $payment_class_1 = ' checked="checked"';
2085 } elseif ( isset( $acting_opts['payment_class'] ) && '2' == $acting_opts['payment_class'] ) {
2086 $payment_class_2 = ' checked="checked"';
2087 } else {
2088 $payment_class_0 = ' checked="checked"'; /* default */
2089 }
2090 $use_card_conf_number_on = '';
2091 $use_card_conf_number_off = '';
2092 if ( isset( $acting_opts['use_card_conf_number'] ) && 'on' == $acting_opts['use_card_conf_number'] ) {
2093 $use_card_conf_number_on = ' checked="checked"';
2094 } else {
2095 $use_card_conf_number_off = ' checked="checked"';
2096 }
2097 $stock_card_mode_on = '';
2098 $stock_card_mode_off = '';
2099 if ( isset( $acting_opts['stock_card_mode'] ) && 'on' == $acting_opts['stock_card_mode'] ) {
2100 $stock_card_mode_on = ' checked="checked"';
2101 } else {
2102 $stock_card_mode_off = ' checked="checked"';
2103 }
2104 $stock_card_mode_msg = '';
2105 if ( defined( 'WCEX_DLSELLER' ) ) {
2106 $stock_card_mode_msg = '自動継続課金をご利用の場合は「利用する」を選択してください。';
2107 } elseif ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
2108 $stock_card_mode_msg = '定期購�
2109 �をご利用の場合は「利用する」を選択してください。';
2110 }
2111 $sales_mode_on = '';
2112 $sales_mode_off = '';
2113 if ( isset( $acting_opts['sales_mode'] ) && '1' == $acting_opts['sales_mode'] ) {
2114 $sales_mode_on = ' checked="checked"';
2115 } else {
2116 $sales_mode_off = ' checked="checked"';
2117 }
2118 $sales_mode_dlseller_on = '';
2119 $sales_mode_dlseller_off = '';
2120 if ( isset( $acting_opts['sales_mode_dlseller'] ) && '1' == $acting_opts['sales_mode_dlseller'] ) {
2121 $sales_mode_dlseller_on = ' checked="checked"';
2122 } else {
2123 $sales_mode_dlseller_off = ' checked="checked"';
2124 }
2125 $auto_settlement_mail_on = '';
2126 $auto_settlement_mail_off = '';
2127 if ( isset( $acting_opts['auto_settlement_mail'] ) && 'on' == $acting_opts['auto_settlement_mail'] ) {
2128 $auto_settlement_mail_on = ' checked="checked"';
2129 } else {
2130 $auto_settlement_mail_off = ' checked="checked"';
2131 }
2132 $threedsecure_on = '';
2133 $threedsecure_off = '';
2134 if ( isset( $acting_opts['threedsecure_ryaku'] ) && 'on' == $acting_opts['threedsecure_ryaku'] ) {
2135 $threedsecure_on = ' checked="checked"';
2136 } else {
2137 $threedsecure_off = ' checked="checked"';
2138 }
2139 $threedsecure_hc = ( isset( $acting_opts['threedsecure_hc'] ) ) ? $acting_opts['threedsecure_hc'] : '';
2140 $attempt_on = '';
2141 $attempt_off = '';
2142 if ( isset( $acting_opts['attempt'] ) && 'on' == $acting_opts['attempt'] ) {
2143 $attempt_on = ' checked="checked"';
2144 } else {
2145 $attempt_off = ' checked="checked"';
2146 }
2147 $conv_activate_link = '';
2148 $conv_activate_module = '';
2149 $conv_activate_off = '';
2150 if ( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) {
2151 $conv_activate_link = ' checked="checked"';
2152 } elseif ( isset( $acting_opts['conv_activate'] ) && 'module' == $acting_opts['conv_activate'] ) {
2153 $conv_activate_module = ' checked="checked"';
2154 } else {
2155 $conv_activate_off = ' checked="checked"';
2156 }
2157 $payment_term_day = ( isset( $acting_opts['payment_term_day'] ) ) ? $acting_opts['payment_term_day'] : '5';
2158 $payment_term_min = ( isset( $acting_opts['payment_term_min'] ) ) ? $acting_opts['payment_term_min'] : '';
2159 $sales_type_1 = '';
2160 $sales_type_3 = '';
2161 if ( isset( $acting_opts['sales_type'] ) && '3' == $acting_opts['sales_type'] ) {
2162 $sales_type_3 = ' checked="checked"';
2163 } else {
2164 $sales_type_1 = ' checked="checked"';
2165 }
2166 $cvs_type_01 = '';
2167 $cvs_type_02 = '';
2168 $cvs_type_03 = '';
2169 $cvs_type_04 = '';
2170 if ( isset( $acting_opts['cvs_type'] ) ) {
2171 if ( in_array( '01', $acting_opts['cvs_type'] ) ) {
2172 $cvs_type_01 = ' checked="checked"';
2173 }
2174 if ( in_array( '02', $acting_opts['cvs_type'] ) ) {
2175 $cvs_type_02 = ' checked="checked"';
2176 }
2177 if ( in_array( '03', $acting_opts['cvs_type'] ) ) {
2178 $cvs_type_03 = ' checked="checked"';
2179 }
2180 if ( in_array( '04', $acting_opts['cvs_type'] ) ) {
2181 $cvs_type_04 = ' checked="checked"';
2182 }
2183 }
2184 $atm_activate_link = '';
2185 $atm_activate_module = '';
2186 $atm_activate_off = '';
2187 if ( isset( $acting_opts['atm_activate'] ) && 'module' == $acting_opts['atm_activate'] ) {
2188 $atm_activate_module = ' checked="checked"';
2189 } else {
2190 $atm_activate_off = ' checked="checked"';
2191 }
2192 $payment_limit_date = ( isset( $acting_opts['payment_limit_date'] ) ) ? $acting_opts['payment_limit_date'] : '';
2193 $bank_activate_link = '';
2194 $bank_activate_module = '';
2195 $bank_activate_off = '';
2196 if ( isset( $acting_opts['bank_activate'] ) && 'module' == $acting_opts['bank_activate'] ) {
2197 $bank_activate_module = ' checked="checked"';
2198 } else {
2199 $bank_activate_off = ' checked="checked"';
2200 }
2201 $asp_payment_term = ( isset( $acting_opts['asp_payment_term'] ) ) ? $acting_opts['asp_payment_term'] : '0050000';
2202 $paidy_activate_module = '';
2203 $paidy_activate_off = '';
2204 if ( isset( $acting_opts['paidy_activate'] ) && 'module' == $acting_opts['paidy_activate'] ) {
2205 $paidy_activate_module = ' checked="checked"';
2206 } else {
2207 $paidy_activate_off = ' checked="checked"';
2208 }
2209 $paidy_public_key = ( isset( $acting_opts['paidy_public_key'] ) ) ? $acting_opts['paidy_public_key'] : '';
2210 ?>
2211 <div id="uscestabs_paygent">
2212 <div class="settlement_service"><span class="service_title"><?php echo esc_html( $this->acting_formal_name ); ?></span></div>
2213 <?php if ( isset( $_POST['acting'] ) && $this->paymod_id == wp_unslash( $_POST['acting'] ) ) : ?>
2214 <?php if ( '' != $this->error_mes ) : ?>
2215 <div class="error_message"><?php wel_esc_script_e( $this->error_mes ); ?></div>
2216 <?php elseif ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) : ?>
2217 <div class="message">十分にテストを行ってから運用してください。</div>
2218 <?php endif; ?>
2219 <?php endif; ?>
2220 <form action="" method="post" name="paygent_form" id="paygent_form">
2221 <table class="settle_table">
2222 <tr>
2223 <th><a class="explanation-label" id="label_ex_seq_merchant_id_paygent">マーチャントID</a></th>
2224 <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>
2225 </tr>
2226 <tr id="ex_seq_merchant_id_paygent" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行されるマーチャントID(半角数字)。マーチャントID は試験環境と本番環境で異なります。</td></tr>
2227 <tr>
2228 <th><a class="explanation-label" id="label_ex_connect_id_paygent">接続ID</a></th>
2229 <td><input name="connect_id" type="text" id="connect_id_paygent" value="<?php echo esc_attr( $connect_id ); ?>" class="regular-text" /></td>
2230 </tr>
2231 <tr id="ex_connect_id_paygent" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行される接続ID(半角英数字)。モジュールタイプで利用するときは�
2232 須です。</td></tr>
2233 <tr>
2234 <th><a class="explanation-label" id="label_ex_connect_password_paygent">接続パスワード</a></th>
2235 <td><input name="connect_password" type="text" id="connect_password_paygent" value="<?php echo esc_attr( $connect_password ); ?>" class="regular-text" /></td>
2236 </tr>
2237 <tr id="ex_connect_password_paygent" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行される接続パスワード(半角英数字)。モジュールタイプで利用するときは�
2238 須です。</td></tr>
2239 <tr>
2240 <th><a class="explanation-label" id="label_ex_hc_paygent">リンクタイプハッシュ生成キー</a></th>
2241 <td><input name="hc" type="text" id="hc_paygent" value="<?php echo esc_attr( $hc ); ?>" class="regular-text" /></td>
2242 </tr>
2243 <tr id="ex_hc_paygent" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行されるリンクタイプハッシュ生成キー(半角英数字)。リンクタイプで利用するときは�
2244 須です。</td></tr>
2245 <tr>
2246 <th><a class="explanation-label" id="label_ex_conv_hc_paygent">差分通知<br />ハッシュ値生成キー</a></th>
2247 <td><input name="conv_hc" type="text" id="conv_hc_paygent" value="<?php echo esc_attr( $conv_hc ); ?>" class="regular-text" /></td>
2248 </tr>
2249 <tr id="ex_conv_hc_paygent" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行される差分通知ハッシュ値生成キー(半角英数字)。別途「差分通知オプション」のお申し込みが�
2250 要です。</td></tr>
2251 <tr>
2252 <th><a class="explanation-label" id="label_ex_ope_paygent">稼働環境</a></th>
2253 <td><label><input name="ope" type="radio" id="ope_paygent_test" value="test"<?php echo esc_html( $ope_test ); ?> /><span>テスト環境</span></label><br />
2254 <label><input name="ope" type="radio" id="ope_paygent_public" value="public"<?php echo esc_html( $ope_public ); ?> /><span>本番環境</span></label>
2255 </td>
2256 </tr>
2257 <tr id="ex_ope_paygent" class="explanation"><td colspan="2">動作環境を切り替えます。</td></tr>
2258 </table>
2259 <table class="settle_table">
2260 <tr>
2261 <th><a class="explanation-label" id="label_ex_card_activate_paygent">クレジットカード決済</a></th>
2262 <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 />
2263 <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 />
2264 <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>
2265 </td>
2266 </tr>
2267 <tr id="ex_card_activate_paygent" class="explanation"><td colspan="2">モジュールタイプで利用する場合は、申込サービスタイプは「リンク+モジュール」、モジュール使用は「同意済」になっている�
2268 要があります。</td></tr>
2269 <tr class="paygent_card_form">
2270 <th><a class="explanation-label" id="label_ex_certificate_path_paygent">証明書ファイルパス</a></th>
2271 <td><input name="certificate_path" type="text" id="certificate_path_paygent" value="<?php echo esc_attr( $certificate_path ); ?>" class="regular-text" disabled="disabled" /><br />
2272 <input type="button" class="button" value="変更する" id="change_certificate_path" />
2273 <input name="certificate_path_before" type="hidden" value="<?php echo esc_attr( $certificate_path ); ?>" />
2274 </td>
2275 </tr>
2276 <tr id="ex_certificate_path_paygent" class="explanation paygent_card_form"><td colspan="2">証明書を保存するフォルダです。モジュールタイプで利用するときは�
2277 須です。通常は初期値のままで問題ありません。変更する場合は、証明書だけを�
2278 �れる専用のフォルダを指定してください。画像などが�
2279 �っているフォルダを指定すると、それらが表示されなくなります。</td></tr>
2280 <tr class="paygent_card_form">
2281 <th><a class="explanation-label" id="label_ex_client_file_paygent">クライアント証明書ファイル</a></th>
2282 <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 />
2283 <input type="button" class="button" value="アップロード" id="client_file_upload"<?php echo esc_html( $client_file_disabled ); ?> /><span id="client_file_upload_result"></span>
2284 </td>
2285 </tr>
2286 <tr id="ex_client_file_paygent" class="explanation paygent_card_form"><td colspan="2">モジュールタイプで利用するときは�
2287 須です。クライアント証明書ファイルは試験環境と本番環境で異なります。アップロードができない場合は、証明書ファイルパスのフォルダの書き込み権限を確認してください。</td></tr>
2288 <tr class="paygent_card_form">
2289 <th><a class="explanation-label" id="label_ex_ca_file_paygent">CAファイル</a></th>
2290 <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 />
2291 <input type="button" class="button" value="アップロード" id="ca_file_upload"<?php echo esc_html( $ca_file_disabled ); ?> /><span id="ca_file_upload_result"></span>
2292 </td>
2293 </tr>
2294 <tr id="ex_ca_file_paygent" class="explanation paygent_card_form"><td colspan="2">モジュールタイプで利用するときは�
2295 須です。アップロードができない場合は、証明書ファイルパスのフォルダの書き込み権限を確認してください。</td></tr>
2296 <tr class="paygent_card_form paygent_card_module">
2297 <th><a class="explanation-label" id="label_ex_token_key_paygent">トークン生成鍵</a></th>
2298 <td><input name="token_key" type="text" id="token_key_paygent" value="<?php echo esc_attr( $token_key ); ?>" class="regular-text" /></td>
2299 </tr>
2300 <tr id="ex_token_key_paygent" class="explanation paygent_card_form paygent_card_module"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行されるトークン生成鍵(半角英数字)。モジュールタイプで利用するときは�
2301 須です。トークン生成鍵は試験環境と本番環境で異なります。</td></tr>
2302 <tr class="paygent_card_form paygent_card_module">
2303 <th><a class="explanation-label" id="label_ex_token_hc_paygent">トークン受取ハッシュ鍵</a></th>
2304 <td><input name="token_hc" type="text" id="token_hc_paygent" value="<?php echo esc_attr( $token_hc ); ?>" class="regular-text" /></td>
2305 </tr>
2306 <tr id="ex_token_hc_paygent" class="explanation paygent_card_form paygent_card_module"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行されるトークン受取ハッシュ鍵(半角英数字)。モジュールタイプで利用するときは�
2307 須です。</td></tr>
2308 <tr class="paygent_card_form">
2309 <th><a class="explanation-label" id="label_ex_payment_class_paygent">支払区分</a></th>
2310 <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 />
2311 <label><input name="payment_class" type="radio" id="payment_class_paygent_2" value="1"<?php echo esc_html( $payment_class_1 ); ?> /><span>�
2312 �て</span></label><br />
2313 <label><input name="payment_class" type="radio" id="payment_class_paygent_2" value="2"<?php echo esc_html( $payment_class_2 ); ?> /><span>ボーナス一括以外�
2314 �て</span></label>
2315 </td>
2316 </tr>
2317 <tr id="ex_payment_class_paygent" class="explanation paygent_card_form"><td colspan="2">ユーザーに支払を許可するカード支払方法の区分です。加盟店審査を経て加盟店様ごとに設定された支払可能回数から、購�
2318 ��
2319 に提示する支払回数をさらに絞り込みたい場合に使用してください。</td></tr>
2320 <tr class="paygent_card_form">
2321 <th><a class="explanation-label" id="label_ex_use_card_conf_number_paygent">カード確認番号<br />利用フラグ</a></th>
2322 <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 />
2323 <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>
2324 </td>
2325 </tr>
2326 <tr id="ex_use_card_conf_number_paygent" class="explanation paygent_card_form"><td colspan="2">確認番号の�
2327 �力を�
2328 須とするかどうかを指定します。確認番号が実際に使用されるかどうかは、カードを発行したイシュアーに依存します。</td></tr>
2329 <tr class="paygent_card_form">
2330 <th><a class="explanation-label" id="label_ex_stock_card_mode_paygent">カード�
2331 報お預りモード</a></th>
2332 <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 />
2333 <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>
2334 </td>
2335 </tr>
2336 <tr id="ex_stock_card_mode_paygent" class="explanation paygent_card_form"><td colspan="2">会員は購�
2337 �の際に登録済みのカードで支払うことができます。カード番号はペイジェントのシステムに保存されます。利用する場合は、基本設定の「会員システム」を「利用する」に設定してください。<?php echo esc_html( $stock_card_mode_msg ); ?></td></tr>
2338 <tr class="paygent_card_form paygent_card_module">
2339 <th><a class="explanation-label" id="label_ex_sales_mode_paygent">同時売上モード</a></th>
2340 <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 />
2341 <label><input name="sales_mode" type="radio" id="sales_mode_paygent_off" value="0"<?php echo esc_html( $sales_mode_off ); ?> /><span>オーソリのみ</span></label>
2342 </td>
2343 </tr>
2344 <tr id="ex_sales_mode_paygent" class="explanation paygent_card_form paygent_card_module"><td colspan="2">決済時にオーソリ(与信)のみ実施するか、オーソリ後売上処理を実施するかを指定します。</td></tr>
2345 <?php if ( defined( 'WCEX_DLSELLER' ) ) : ?>
2346 <tr class="paygent_card_form paygent_card_module">
2347 <th><a class="explanation-label" id="label_ex_sales_mode_dlseller_paygent">自動継続課金同時売上モード</a></th>
2348 <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 />
2349 <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>
2350 </td>
2351 </tr>
2352 <tr id="ex_sales_mode_dlseller_paygent" class="explanation paygent_card_form paygent_card_module"><td colspan="2">自動継続課金(要 WCEX DLSeller)時の同時売上モード。</td></tr>
2353 <tr class="paygent_card_form paygent_card_module">
2354 <th><a class="explanation-label" id="label_ex_auto_settlement_mail_paygent">自動継続課金完了メール</a></th>
2355 <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 />
2356 <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>
2357 </td>
2358 </tr>
2359 <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>
2360 <?php endif; ?>
2361 <tr class="paygent_card_form">
2362 <th><a class="explanation-label" id="label_ex_threedsecure_paygent">3Dセキュア</a></th>
2363 <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 />
2364 <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>
2365 </td>
2366 </tr>
2367 <tr id="ex_threedsecure_paygent" class="explanation paygent_card_form"><td colspan="2">3Dセキュアの契約をした場合のみ「契約」を選択してください。</td></tr>
2368 <tr class="paygent_card_form paygent_card_threedsecure">
2369 <th><a class="explanation-label" id="label_ex_threedsecure_hc_paygent">3Dセキュア結果受付ハッシュ鍵</a></th>
2370 <td><input name="threedsecure_hc" type="text" id="threedsecure_hc_paygent" value="<?php echo esc_attr( $threedsecure_hc ); ?>" class="regular-text" /></td>
2371 </tr>
2372 <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セキュアを利用するときは�
2373 須です。</td></tr>
2374 <tr class="paygent_card_form paygent_card_threedsecure">
2375 <th><a class="explanation-label" id="label_ex_attempt_paygent">チャージバックリスク回避</a></th>
2376 <td><label><input name="attempt" type="radio" id="attempt_paygent_on" value="on"<?php echo esc_html( $attempt_on ); ?> /><span>優�
2377 �する</span></label><br />
2378 <label><input name="attempt" type="radio" id="attempt_paygent_off" value="off"<?php echo esc_html( $attempt_off ); ?> /><span>優�
2379 �しない</span></label>
2380 </td>
2381 </tr>
2382 <tr id="ex_attempt_paygent" class="explanation paygent_card_form paygent_card_threedsecure"><td colspan="2">「優�
2383 �する」を選択すると、チャージバックリスクが加盟店にある場合の3Dセキュア認証を認証エラー(決済エラー)とします。</td></tr>
2384 </table>
2385 <table class="settle_table">
2386 <tr>
2387 <th><a class="explanation-label" id="label_ex_conv_activate_paygent">コンビニ決済(番号方式)</a></th>
2388 <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 />
2389 <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 />
2390 <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>
2391 </td>
2392 </tr>
2393 <tr id="ex_conv_activate_paygent" class="explanation"><td colspan="2">モジュールタイプで利用する場合は、申込サービスタイプは「リンク+モジュール」、モジュール使用は「同意済」になっている�
2394 要があります。</td></tr>
2395 <tr class="paygent_conv_form">
2396 <th><a class="explanation-label" id="label_ex_payment_term_day_paygent">支払期間(日指定)</a></th>
2397 <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>
2398 </tr>
2399 <tr id="ex_payment_term_day_paygent" class="explanation paygent_conv_form"><td colspan="2">支払うことのできる期限を日で指定します。指定できる範囲は2以上60以下です。(半角数字)</td></tr>
2400 <tr class="paygent_conv_form paygent_conv_link">
2401 <th><a class="explanation-label" id="label_ex_payment_term_min_paygent">支払期間(分指定)</a></th>
2402 <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>
2403 </tr>
2404 <tr id="ex_payment_term_min_paygent" class="explanation paygent_conv_form paygent_conv_link"><td colspan="2">支払うことのできる期限を分で指定します。指定できる範囲は5以上2880以下です。(半角数字)</td></tr>
2405 <tr class="paygent_conv_form paygent_conv_module">
2406 <th><a class="explanation-label" id="label_ex_sales_type_paygent">支払種別</a></th>
2407 <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 />
2408 <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>
2409 </td>
2410 </tr>
2411 <tr id="ex_sales_type_paygent" class="explanation paygent_conv_form paygent_conv_module"><td colspan="2">前払いか後払いかを表す種別です。</td></tr>
2412 <tr class="paygent_conv_form paygent_conv_module">
2413 <th rowspan="7"><a class="explanation-label" id="label_ex_cvs_type_paygent">申込コンビニ</a></th>
2414 <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>
2415 </tr>
2416 <tr class="paygent_conv_form paygent_conv_module">
2417 <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>
2418 </tr>
2419 <tr class="paygent_conv_form paygent_conv_module">
2420 <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>
2421 </tr>
2422 <tr class="paygent_conv_form paygent_conv_module">
2423 <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>
2424 </tr>
2425 <tr id="ex_cvs_type_paygent" class="explanation paygent_conv_form paygent_conv_module"><td colspan="2">契約時にご利用のお申込みをいただいたコンビニを選択します。</td></tr>
2426 </table>
2427 <table class="settle_table">
2428 <tr>
2429 <th><a class="explanation-label" id="label_ex_atm_activate_paygent">ATM決済(ペイジー)</a></th>
2430 <td>
2431 <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 />
2432 <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>
2433 </td>
2434 </tr>
2435 <tr id="ex_atm_activate_paygent" class="explanation"><td colspan="2">モジュールタイプになります。利用する場合は、申込サービスタイプは「リンク+モジュール」、モジュール使用は「同意済」になっている�
2436 要があります。</td></tr>
2437 <tr class="paygent_atm_form">
2438 <th><a class="explanation-label" id="label_ex_payment_limit_date_paygent">支払期限日</a></th>
2439 <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>
2440 </tr>
2441 <tr id="ex_payment_limit_date_paygent" class="explanation paygent_atm_form"><td colspan="2">取引発生日時から0日~60日より設定します。設定がない場合は、システムデフォルト値 30日が設定されます。0日とは当日中を指します。(半角数字)</td></tr>
2442 </table>
2443 <table class="settle_table">
2444 <tr>
2445 <th><a class="explanation-label" id="label_ex_bank_activate_paygent">銀行ネット決済(ネットバンキング)</a></th>
2446 <td>
2447 <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 />
2448 <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>
2449 </td>
2450 </tr>
2451 <tr id="ex_bank_activate_paygent" class="explanation"><td colspan="2">モジュールタイプになります。利用する場合は、申込サービスタイプは「リンク+モジュール」、モジュール使用は「同意済」になっている�
2452 要があります。</td></tr>
2453 <tr class="paygent_bank_form">
2454 <th><a class="explanation-label" id="label_ex_asp_payment_term_paygent">支払期間</a></th>
2455 <td><select name="asp_payment_term">
2456 <?php
2457 foreach ( $this->asp_payment_term as $term => $value ) {
2458 $selected = ( $asp_payment_term == $term ) ? ' selected="selected"' : '';
2459 echo '<option value="' . esc_attr( $term ) . '"' . $selected . '>' . esc_html( $value ) . '</option>';
2460 }
2461 ?>
2462 </select>
2463 </td>
2464 </tr>
2465 <tr id="ex_asp_payment_term_paygent" class="explanation paygent_bank_form"><td colspan="2">ASP画面有効期限を設定します。すぐに支払ってもらいたい場合は30分程度を指定してください。一般的には長くて7日程度です。デフォルト値は5日です。</td></tr>
2466 </table>
2467 <table class="settle_table">
2468 <tr>
2469 <th><a class="explanation-label" id="label_ex_paidy_activate_paygent">Paidy</a></th>
2470 <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 />
2471 <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>
2472 </td>
2473 </tr>
2474 <tr id="ex_paidy_activate_paygent" class="explanation"><td colspan="2">モジュールタイプになります。利用する場合は、申込サービスタイプは「リンク+モジュール」、モジュール使用は「同意済」になっている�
2475 要があります。</td></tr>
2476 <tr class="paygent_paidy_form">
2477 <th><a class="explanation-label" id="label_ex_paidy_public_key_paygent">パブリックキー</a></th>
2478 <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>
2479 </tr>
2480 <tr id="ex_paidy_public_key_paygent" class="explanation paygent_paidy_form"><td colspan="2">Paidy 加盟店管理画面の設定より「パブリックキー」を取得してください。(半角数字)</td></tr>
2481 </table>
2482 <input name="acting" type="hidden" value="paygent" />
2483 <input name="usces_option_update" type="submit" class="button button-primary" value="<?php echo esc_attr( $this->acting_name ); ?>の設定を更新する" />
2484 <?php wp_nonce_field( 'admin_settlement', 'wc_nonce' ); ?>
2485 </form>
2486 <div id="upload_dialog_paygent" class="upload_dialog_paygent">
2487 <form action="<?php echo esc_url( USCES_ADMIN_URL ); ?>" method="post" enctype="multipart/form-data" name="upload_form_paygent" id="upload_form_paygent">
2488 <p id="filetype_description"></p>
2489 <fieldset>
2490 <input type="file" name="upload_file" id="upload_file" />
2491 </fieldset>
2492 <input type="button" id="upload_button" class="button" value="アップロード" />
2493 <input type="hidden" id="upload_filetype" value="" />
2494 </form>
2495 </div>
2496 <div class="settle_exp">
2497 <p><strong><?php echo esc_attr( $this->acting_formal_name ); ?></strong></p>
2498 <a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank"><?php echo esc_attr( $this->acting_name ); ?>の詳細はこちら </a>
2499 <p>この決済は「外部リンク型(リンクタイプ)」と「非通過型(モジュールタイプ)」が選択できます。</p>
2500 <p>リンクタイプでもペイジェントの決済システムと Welcart の決済データの連携機能を利用したい場合は、「クライアント証明書ファイル」と「CAファイル」をサーバーに設置する�
2501 要があります。また、ペイジェントの申込サービスタイプは「リンク+モジュール」モジュール使用は「同意済」になっている�
2502 要があります。詳細は「ペイジェント決済導�
2503 �マニュアル」を参�
2504 �してください。</p>
2505 <p>決済通知ステータスの申請は「任意」となっていますが、以下のように申請してください。リンクタイプで利用する場合は※印のステータス通知は�
2506 須となります。<br />
2507 【クレジット決済】<br />
2508  ■ 申込済※<br />
2509  ■ オーソリNG<br />
2510  ■ 3Dセキュア中断(3Dセキュア契約時のみ)<br />
2511  ■ オーソリOK<br />
2512  ■ オーソリ取消済<br />
2513  ■ オーソリ期限切<br />
2514  ■ 消込済<br />
2515  ■ 消込済(売上取消期限切)<br />
2516  ■ 売上取消済<br />
2517 【コンビニ決済】<br />
2518  ■ 申込済※<br />
2519  ■ 支払期限切<br />
2520  ■ 消込済※<br />
2521  ■ 速報検知済※<br />
2522  ■ 速報取消済<br />
2523 【ATM決済】<br />
2524  ■ 支払期限切<br />
2525  ■ 消込済※<br />
2526 【銀行ネット決済】<br />
2527  ■ 申込中断<br />
2528  ■ 消込済※<br />
2529 【Paidy】<br />
2530  ■ オーソリNG<br />
2531  ■ オーソリOK<br />
2532  ■ オーソリ取消済<br />
2533  ■ オーソリ期限切<br />
2534  ■ 消込済<br />
2535  ■ 消込済(売上取消期限切)<br />
2536  ■ 売上取消済<br />
2537 </p>
2538 </div>
2539 </div><!--uscestabs_paygent-->
2540 <?php
2541 endif;
2542 }
2543
2544 /**
2545 * 結果通知処理
2546 * usces_after_cart_instant
2547 */
2548 public function acting_transaction() {
2549 global $usces;
2550
2551 if ( isset( $_POST['trading_id'] ) && isset( $_POST['payment_status'] ) && ! isset( $_POST['purchase'] ) ) {
2552 $post_data = Paygent_Module::encording_response_kana( wp_unslash( $_POST ) );
2553 $acting_opts = $this->get_acting_settings();
2554 $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'] );
2555 $hased_string = hash( 'sha256', $original_string );
2556 if ( isset( $post_data['hc'] ) && $hased_string === $post_data['hc'] ) {
2557 $payment_type = ( isset( $post_data['payment_type'] ) ) ? $post_data['payment_type'] : '';
2558 $payment_status = $post_data['payment_status'];
2559 switch ( $payment_type ) {
2560 /* カード決済 */
2561 case PAYMENT_TYPE_CREDIT:
2562 switch ( $payment_status ) {
2563 case STATUS_REQUESTED: /* 申込済 */
2564 if ( ! empty( $post_data['trading_id'] ) ) {
2565 $order_id = $this->get_order_id( $post_data['trading_id'] );
2566 if ( ! $order_id ) {
2567 if ( $this->is_activate_card( 'link' ) ) {
2568 $order_data = usces_restore_order_acting_data( $post_data['trading_id'] );
2569 if ( $order_data ) {
2570 $res = $usces->order_processing( $post_data );
2571 if ( 'ordercompletion' == $res ) {
2572 if ( 'on' == $acting_opts['stock_card_mode'] ) {
2573 if ( isset( $post_data['customer_id'] ) && isset( $post_data['customer_card_id'] ) ) {
2574 $usces->set_member_meta_value( 'paygent_customer_card_id', $post_data['customer_card_id'], $post_data['customer_id'] );
2575 }
2576 }
2577 $usces->cart->crear_cart();
2578 } else {
2579 $log = array(
2580 'acting' => 'paygent_card',
2581 'key' => $post_data['trading_id'],
2582 'result' => 'ORDER DATA REGISTERED ERROR',
2583 'data' => $post_data,
2584 );
2585 usces_save_order_acting_error( $log );
2586 }
2587 $order_id = $this->get_order_id( $post_data['trading_id'] );
2588 if ( $order_id ) {
2589 $post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
2590 $this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2591 }
2592 }
2593 }
2594 } else {
2595 $post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
2596 $this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2597 }
2598 }
2599 break;
2600 case STATUS_AUTHORIZE_NG: /* オーソリNG */
2601 case STATUS_AUTHORIZE_OK: /* オーソリOK */
2602 case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
2603 case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
2604 case STATUS_CLEARED: /* 消込済 */
2605 case STATUS_CLEARED_SALES_CANCEL_INVALIDITY: /* 消込済(売上取消期限切) */
2606 case STATUS_SALES_CANCELED: /* 売上取消済 */
2607 case STATUS_3DSECURE_INTERRUPTION: /* 3Dセキュア中断 */
2608 case STATUS_3DSECURE_CERTIFICATION: /* 3Dセキュア認証 */
2609 $order_id = $this->get_order_id( $post_data['trading_id'] );
2610 if ( $order_id ) {
2611 $post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
2612 $this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2613 }
2614 break;
2615 case STATUS_SALES_CANCELING: /* 売上取消中 */
2616 case STATUS_SALES_CANCELING_TALLY: /* 売上取消集計中 */
2617 $order_id = $this->get_order_id( $post_data['trading_id'] );
2618 if ( $order_id ) {
2619 $post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
2620 $this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_ERROR, $order_id, $post_data['trading_id'] );
2621 }
2622 break;
2623 }
2624 break;
2625
2626 /* コンビニ決済 */
2627 case PAYMENT_TYPE_CONVENI_NUM:
2628 switch ( $payment_status ) {
2629 case STATUS_REQUESTED: /* 申込済 */
2630 if ( ! empty( $post_data['trading_id'] ) ) {
2631 $order_id = $this->get_order_id( $post_data['trading_id'] );
2632 if ( ! $order_id ) {
2633 if ( $this->is_activate_conv( 'link' ) ) {
2634 $order_data = usces_restore_order_acting_data( $post_data['trading_id'] );
2635 if ( $order_data ) {
2636 $res = $usces->order_processing( $post_data );
2637 if ( 'ordercompletion' == $res ) {
2638 $usces->cart->crear_cart();
2639 } else {
2640 $log = array(
2641 'acting' => 'paygent_conv',
2642 'key' => $post_data['trading_id'],
2643 'result' => 'ORDER DATA REGISTERED ERROR',
2644 'data' => $post_data,
2645 );
2646 usces_save_order_acting_error( $log );
2647 }
2648 $order_id = $this->get_order_id( $post_data['trading_id'] );
2649 if ( $order_id ) {
2650 $this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2651 }
2652 }
2653 }
2654 } else {
2655 $this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2656 }
2657 }
2658 break;
2659 case STATUS_PRELIMINARY_DETECTED: /* 速報検地済 */
2660 case STATUS_CLEARED: /* 消込済 */
2661 $order_id = $this->get_order_id( $post_data['trading_id'] );
2662 if ( $order_id ) {
2663 $this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2664 $order_status = $this->get_order_status( $order_id );
2665 if ( 0 == $order_status ) {
2666 $res = usces_change_order_receipt( $order_id, 'receipted' );
2667 if ( false === $res ) {
2668 $log = array(
2669 'acting' => 'paygent_conv',
2670 'key' => $post_data['trading_id'],
2671 'result' => 'ORDER DATA UPDATE ERROR',
2672 'data' => $post_data,
2673 );
2674 usces_save_order_acting_error( $log );
2675 } else {
2676 usces_action_acting_getpoint( $order_id );
2677 $usces->set_order_meta_value( 'acting_paygent_conv', usces_serialize( $post_data ), $order_id );
2678 if ( STATUS_CLEARED === $payment_status ) {
2679 do_action( 'usces_action_paygent_conv_payment_completion', $post_data, $order_id );
2680 }
2681 }
2682 }
2683 }
2684 break;
2685 case STATUS_PRELIMINARY_CANCELED: /* 速報取消済 */
2686 $order_id = $this->get_order_id( $post_data['trading_id'] );
2687 if ( $order_id ) {
2688 $this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2689 $order_status = $this->get_order_status( $order_id );
2690 if ( 0 < $order_status ) {
2691 $res = usces_change_order_receipt( $order_id, 'noreceipt' );
2692 if ( false === $res ) {
2693 $log = array(
2694 'acting' => 'paygent_conv',
2695 'key' => $post_data['trading_id'],
2696 'result' => 'ORDER DATA UPDATE ERROR',
2697 'data' => $post_data,
2698 );
2699 usces_save_order_acting_error( $log );
2700 } else {
2701 usces_action_acting_getpoint( $order_id, false );
2702 }
2703 }
2704 }
2705 break;
2706 case STATUS_PAYMENT_EXPIRED: /* 支払期限切 */
2707 $order_id = $this->get_order_id( $post_data['trading_id'] );
2708 if ( $order_id ) {
2709 $this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2710 }
2711 break;
2712 }
2713 break;
2714
2715 /* ATM決済 */
2716 case PAYMENT_TYPE_ATM:
2717 switch ( $payment_status ) {
2718 case STATUS_PAYMENT_EXPIRED: /* 支払期限切 */
2719 $order_id = $this->get_order_id( $post_data['trading_id'] );
2720 if ( $order_id ) {
2721 $this->save_acting_log( $post_data, 'paygent_atm', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2722 }
2723 break;
2724 case STATUS_CLEARED: /* 消込済 */
2725 $order_id = $this->get_order_id( $post_data['trading_id'] );
2726 if ( $order_id ) {
2727 $this->save_acting_log( $post_data, 'paygent_atm', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2728 $order_status = $this->get_order_status( $order_id );
2729 if ( 0 == $order_status ) {
2730 $res = usces_change_order_receipt( $order_id, 'receipted' );
2731 if ( false === $res ) {
2732 $log = array(
2733 'acting' => 'paygent_atm',
2734 'key' => $post_data['trading_id'],
2735 'result' => 'ORDER DATA UPDATE ERROR',
2736 'data' => $post_data,
2737 );
2738 usces_save_order_acting_error( $log );
2739 } else {
2740 usces_action_acting_getpoint( $order_id );
2741 $usces->set_order_meta_value( 'acting_paygent_atm', usces_serialize( $post_data ), $order_id );
2742 do_action( 'usces_action_paygent_atm_payment_completion', $post_data, $order_id );
2743 }
2744 }
2745 }
2746 break;
2747 }
2748 break;
2749
2750 /* 銀行ネット決済 */
2751 case PAYMENT_TYPE_BANK:
2752 switch ( $payment_status ) {
2753 case STATUS_REGISTRATION_SUSPENDED: /* 申込中断 */
2754 $order_id = $this->get_order_id( $post_data['trading_id'] );
2755 if ( $order_id ) {
2756 $this->save_acting_log( $post_data, 'paygent_bank', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2757 }
2758 break;
2759 case STATUS_CLEARED: /* 消込済 */
2760 $order_id = $this->get_order_id( $post_data['trading_id'] );
2761 if ( $order_id ) {
2762 $this->save_acting_log( $post_data, 'paygent_bank', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2763 $order_status = $this->get_order_status( $order_id );
2764 if ( 0 == $order_status ) {
2765 $res = usces_change_order_receipt( $order_id, 'receipted' );
2766 if ( false === $res ) {
2767 $log = array(
2768 'acting' => 'paygent_bank',
2769 'key' => $post_data['trading_id'],
2770 'result' => 'ORDER DATA UPDATE ERROR',
2771 'data' => $post_data,
2772 );
2773 usces_save_order_acting_error( $log );
2774 } else {
2775 usces_action_acting_getpoint( $order_id );
2776 $usces->set_order_meta_value( 'acting_paygent_bank', usces_serialize( $post_data ), $order_id );
2777 do_action( 'usces_action_paygent_bank_payment_completion', $post_data, $order_id );
2778 }
2779 }
2780 }
2781 break;
2782 }
2783 break;
2784
2785 /* Paidy */
2786 case PAYMENT_TYPE_PAIDY:
2787 switch ( $payment_status ) {
2788 case STATUS_AUTHORIZE_NG: /* オーソリNG */
2789 case STATUS_AUTHORIZE_OK: /* オーソリOK */
2790 case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
2791 case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
2792 case STATUS_CLEARED: /* 消込済 */
2793 case STATUS_CLEARED_SALES_CANCEL_INVALIDITY: /* 消込済(売上取消期限切) */
2794 case STATUS_SALES_CANCELED: /* 売上取消済 */
2795 $order_id = $this->get_order_id( $post_data['trading_id'] );
2796 if ( $order_id ) {
2797 $this->save_acting_log( $post_data, 'paygent_paidy', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
2798 }
2799 break;
2800 }
2801 break;
2802 }
2803 }
2804 die( 'result=0' );
2805 }
2806 }
2807
2808 /**
2809 * ポイント即時付与
2810 * usces_filter_is_complete_settlement
2811 *
2812 * @param boolean $complete Complete the payment.
2813 * @param string $payment_name Payment name.
2814 * @param string $status Payment status.
2815 * @return boolean
2816 */
2817 public function is_complete_settlement( $complete, $payment_name, $status ) {
2818 $payment = usces_get_payments_by_name( $payment_name );
2819 if ( isset( $payment['settlement'] ) && ( 'acting_paygent_card' == $payment['settlement'] || 'acting_paygent_paidy' == $payment['settlement'] ) ) {
2820 $complete = true;
2821 }
2822 return $complete;
2823 }
2824
2825 /**
2826 * 管理画面決済処理
2827 * usces_action_admin_ajax
2828 */
2829 public function admin_ajax() {
2830 global $usces;
2831
2832 $post_data = wp_unslash( $_POST );
2833 $mode = sanitize_title( $post_data['mode'] );
2834 $data = array();
2835
2836 switch ( $mode ) {
2837 /* クレジットカード参�
2838 � */
2839 case 'get_paygent_card':
2840 check_admin_referer( 'order_edit', 'wc_nonce' );
2841 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2842 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2843 $member_id = ( isset( $post_data['member_id'] ) ) ? $post_data['member_id'] : '';
2844 if ( empty( $order_id ) || empty( $trading_id ) ) {
2845 $data['status'] = 'reference_error';
2846 wp_send_json( $data );
2847 break;
2848 }
2849
2850 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2851 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2852 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id, $member_id );
2853 wp_send_json( $data );
2854 break;
2855
2856 /* クレジットカード売上処理 */
2857 case 'sales_paygent_card':
2858 check_admin_referer( 'order_edit', 'wc_nonce' );
2859 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2860 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2861 if ( empty( $order_id ) || empty( $trading_id ) ) {
2862 $data['status'] = 'reference_error';
2863 wp_send_json( $data );
2864 break;
2865 }
2866
2867 $result = '';
2868 $status = '';
2869
2870 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2871 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2872 $telegram_kind = PAYGENT_CARD_COMMIT;
2873 $settlement = $this->settlement_request( $telegram_kind, $trading_id, $payment_id );
2874 $settlement = apply_filters( 'usces_filter_paygent_card_acting_sales_log', $settlement, $order_id, $trading_id );
2875 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
2876 $this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
2877 $status = 'payment_error';
2878 $status_name = $this->get_status_name( $status );
2879 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
2880 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
2881 �更新" /></div>';
2882 $result .= $this->settlement_history( $order_id, $trading_id );
2883 $data['result'] = $result;
2884 $data['status'] = $status;
2885 } else {
2886 $this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
2887 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
2888 }
2889 $this->save_admin_log( $order_id, $trading_id );
2890 wp_send_json( $data );
2891 break;
2892
2893 /* クレジットカードオーソリ取消 */
2894 case 'auth_cancel_paygent_card':
2895 check_admin_referer( 'order_edit', 'wc_nonce' );
2896 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2897 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2898 if ( empty( $order_id ) || empty( $trading_id ) ) {
2899 $data['status'] = 'reference_error';
2900 wp_send_json( $data );
2901 break;
2902 }
2903
2904 $result = '';
2905 $status = '';
2906
2907 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2908 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2909 $telegram_kind = PAYGENT_AUTH_CANCEL;
2910 $settlement = $this->settlement_request( $telegram_kind, $trading_id, $payment_id );
2911 $settlement = apply_filters( 'usces_filter_paygent_card_acting_auth_cancel_log', $settlement, $order_id, $trading_id );
2912 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
2913 $this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
2914 $status = 'payment_error';
2915 $status_name = $this->get_status_name( $status );
2916 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
2917 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
2918 �更新" /></div>';
2919 $result .= $this->settlement_history( $order_id, $trading_id );
2920 $data['result'] = $result;
2921 $data['status'] = $status;
2922 } else {
2923 $this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
2924 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
2925 }
2926 $this->save_admin_log( $order_id, $trading_id );
2927 wp_send_json( $data );
2928 break;
2929
2930 /* クレジットカードオーソリ変更 */
2931 case 'auth_revise_paygent_card':
2932 check_admin_referer( 'order_edit', 'wc_nonce' );
2933 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2934 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2935 $amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
2936 if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
2937 $data['status'] = 'reference_error';
2938 wp_send_json( $data );
2939 break;
2940 }
2941
2942 $result = '';
2943 $status = '';
2944
2945 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2946 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2947 $telegram_kind = PAYGENT_CARD_COMMIT_AUTH_REVISE;
2948 $settlement = $this->settlement_request_revise( $telegram_kind, $trading_id, $payment_id, $amount );
2949 $settlement = apply_filters( 'usces_filter_paygent_card_acting_auth_revise_log', $settlement, $order_id, $trading_id );
2950 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
2951 $this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
2952 $status = 'payment_error';
2953 $status_name = $this->get_status_name( $status );
2954 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
2955 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
2956 �更新" /></div>';
2957 $result .= $this->settlement_history( $order_id, $trading_id );
2958 $data['result'] = $result;
2959 $data['status'] = $status;
2960 } else {
2961 $this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
2962 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
2963 }
2964 $this->save_admin_log( $order_id, $trading_id );
2965 wp_send_json( $data );
2966 break;
2967
2968 /* クレジットカード売上取消(キャンセル処理) */
2969 case 'sales_cancel_paygent_card':
2970 check_admin_referer( 'order_edit', 'wc_nonce' );
2971 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
2972 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
2973 if ( empty( $order_id ) || empty( $trading_id ) ) {
2974 $data['status'] = 'reference_error';
2975 wp_send_json( $data );
2976 break;
2977 }
2978
2979 $result = '';
2980 $status = '';
2981
2982 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
2983 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
2984 $telegram_kind = PAYGENT_CARD_COMMIT_CANCEL;
2985 $settlement = $this->settlement_request( $telegram_kind, $trading_id, $payment_id );
2986 $settlement = apply_filters( 'usces_filter_paygent_card_acting_sales_cancel_log', $settlement, $order_id, $trading_id );
2987 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
2988 $this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
2989 $status = 'payment_error';
2990 $status_name = $this->get_status_name( $status );
2991 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
2992 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
2993 �更新" /></div>';
2994 $result .= $this->settlement_history( $order_id, $trading_id );
2995 $data['result'] = $result;
2996 $data['status'] = $status;
2997 } else {
2998 $this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
2999 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
3000 }
3001 $this->save_admin_log( $order_id, $trading_id );
3002 wp_send_json( $data );
3003 break;
3004
3005 /* クレジットカード売上金額変更(売上変更) */
3006 case 'sales_revise_paygent_card':
3007 check_admin_referer( 'order_edit', 'wc_nonce' );
3008 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3009 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3010 $amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
3011 if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
3012 $data['status'] = 'reference_error';
3013 wp_send_json( $data );
3014 break;
3015 }
3016
3017 $result = '';
3018 $status = '';
3019
3020 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3021 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3022 $telegram_kind = PAYGENT_CARD_COMMIT_REVISE;
3023 $settlement = $this->settlement_request_revise( $telegram_kind, $trading_id, $payment_id, $amount );
3024 $settlement = apply_filters( 'usces_filter_paygent_card_acting_sales_revise_log', $settlement, $order_id, $trading_id );
3025 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
3026 $this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3027 $status = 'payment_error';
3028 $status_name = $this->get_status_name( $status );
3029 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3030 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3031 �更新" /></div>';
3032 $result .= $this->settlement_history( $order_id, $trading_id );
3033 $data['result'] = $result;
3034 $data['status'] = $status;
3035 } else {
3036 $this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3037 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
3038 }
3039 $this->save_admin_log( $order_id, $trading_id );
3040 wp_send_json( $data );
3041 break;
3042
3043 /* クレジットカード新規オーソリ */
3044 case 'auth_paygent_card':
3045 check_admin_referer( 'order_edit', 'wc_nonce' );
3046 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3047 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3048 $member_id = ( isset( $post_data['member_id'] ) ) ? $post_data['member_id'] : '';
3049 $amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
3050 if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
3051 $data['status'] = 'reference_error';
3052 wp_send_json( $data );
3053 break;
3054 }
3055
3056 $result = '';
3057 $status = '';
3058
3059 // $trading_id = usces_acting_key();
3060 $customer = $this->customer_ref( $member_id );
3061 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id && isset( $customer['customer_card_id'] ) ) {
3062 $telegram_kind = PAYGENT_CREDIT;
3063
3064 $pm = Paygent_Module::get_instance();
3065 $pm->init();
3066 $pm->req_put( 'trading_id', $trading_id );
3067 $pm->req_put( 'payment_amount', $amount );
3068 $pm->req_put( 'payment_class', '10' );
3069 $pm->req_put( '3dsecure_ryaku', '1' );
3070 $pm->req_put( 'stock_card_mode', '1' );
3071 $pm->req_put( 'customer_id', $member_id );
3072 $pm->req_put( 'customer_card_id', $customer['customer_card_id'] );
3073 $pm->req_put( 'sales_mode', '0' ); /* Auth */
3074
3075 $result_post = $pm->post( $telegram_kind );
3076 $result_status = $pm->get_result_status();
3077 if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
3078 $response_data = array(
3079 'result' => $result_post,
3080 'result_status' => $result_status,
3081 'response_code' => $pm->get_response_code(),
3082 'response_detail' => $pm->get_response_detail(),
3083 'result_message' => $pm->get_result_message(),
3084 );
3085 $this->save_acting_log( $response_data, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3086 $status = 'payment_error';
3087 $status_name = $this->get_status_name( $status );
3088 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3089 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3090 �更新" /></div>';
3091 $result .= $this->settlement_history( $order_id, $trading_id );
3092 $data['result'] = $result;
3093 $data['status'] = $status;
3094 } else {
3095 $response_data = $pm->get_response_data();
3096 if ( ! isset( $response_data['payment_type'] ) ) {
3097 $response_data['payment_type'] = PAYMENT_TYPE_CREDIT;
3098 }
3099 $this->save_acting_log( $response_data, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3100 $usces->set_order_meta_value( 'acting_paygent_card', usces_serialize( $response_data ), $order_id );
3101 $payment_id = ( isset( $response_data['payment_id'] ) ) ? $response_data['payment_id'] : '';
3102 $data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
3103 }
3104 $this->save_admin_log( $order_id, $trading_id );
3105 } else {
3106 if ( ! isset( $customer['payment_type'] ) ) {
3107 $customer['payment_type'] = PAYMENT_TYPE_CREDIT;
3108 }
3109 $this->save_acting_log( $customer, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3110 $status = 'payment_error';
3111 $status_name = $this->get_status_name( $status );
3112 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3113 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3114 �更新" /></div>';
3115 $result .= $this->settlement_history( $order_id, $trading_id );
3116 $data['result'] = $result;
3117 $data['status'] = $status;
3118 $this->save_admin_log( $order_id, $trading_id );
3119 }
3120 wp_send_json( $data );
3121 break;
3122
3123 /* コンビニ参�
3124 � */
3125 case 'get_paygent_conv':
3126 check_admin_referer( 'order_edit', 'wc_nonce' );
3127 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3128 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3129 if ( empty( $order_id ) || empty( $trading_id ) ) {
3130 $data['status'] = 'reference_error';
3131 wp_send_json( $data );
3132 break;
3133 }
3134
3135 $result = '';
3136 $status = '';
3137
3138 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3139 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3140 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
3141 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
3142 $status = 'reference_error';
3143 $status_name = $this->get_status_name( $status );
3144 $result .= '<div class="paygent-settlement-admin conv-error">' . $status_name . '</div>';
3145 } else {
3146 $payment_status = ( isset( $settlement_ref['payment_status'] ) ) ? $settlement_ref['payment_status'] : '';
3147 $status = $this->get_status( $payment_status );
3148 $class = ' conv-' . $status;
3149 $status_name = $this->get_status_name( $payment_status );
3150 $result .= '<div class="paygent-settlement-admin' . $class . '">' . $status_name . '</div>';
3151 }
3152 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="conv" value="状�
3153 �更新" /></div>';
3154 $result .= $this->settlement_history( $order_id, $trading_id );
3155 $data['result'] = $result;
3156 $data['status'] = $status;
3157 wp_send_json( $data );
3158 break;
3159
3160 /* ATM参�
3161 � */
3162 case 'get_paygent_atm':
3163 check_admin_referer( 'order_edit', 'wc_nonce' );
3164 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3165 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3166 if ( empty( $order_id ) || empty( $trading_id ) ) {
3167 $data['status'] = 'reference_error';
3168 wp_send_json( $data );
3169 break;
3170 }
3171
3172 $result = '';
3173 $status = '';
3174
3175 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3176 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3177 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
3178 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
3179 $status = 'reference_error';
3180 $status_name = $this->get_status_name( $status );
3181 $result .= '<div class="paygent-settlement-admin atm-error">' . $status_name . '</div>';
3182 } else {
3183 $payment_status = ( isset( $settlement_ref['payment_status'] ) ) ? $settlement_ref['payment_status'] : '';
3184 $status = $this->get_status( $payment_status );
3185 $class = ' atm-' . $status;
3186 $status_name = $this->get_status_name( $payment_status );
3187 $result .= '<div class="paygent-settlement-admin' . $class . '">' . $status_name . '</div>';
3188 }
3189 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="atm" value="状�
3190 �更新" /></div>';
3191 $result .= $this->settlement_history( $order_id, $trading_id );
3192 $data['result'] = $result;
3193 $data['status'] = $status;
3194 wp_send_json( $data );
3195 break;
3196
3197 /* 銀行ネット決済参�
3198 � */
3199 case 'get_paygent_bank':
3200 check_admin_referer( 'order_edit', 'wc_nonce' );
3201 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3202 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3203 if ( empty( $order_id ) || empty( $trading_id ) ) {
3204 $data['status'] = 'reference_error';
3205 wp_send_json( $data );
3206 break;
3207 }
3208
3209 $result = '';
3210 $status = '';
3211 $acting_status = '';
3212
3213 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3214 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3215 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
3216 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
3217 if ( 'bank_applying' == $latest_log['status'] ) {
3218 $status = 'bank_applying';
3219 $status_name = $this->get_status_name( $status );
3220 $result .= '<div class="paygent-settlement-admin bank-applying">' . $status_name . '</div>';
3221 } else {
3222 $status = 'reference_error';
3223 $status_name = $this->get_status_name( $status );
3224 $result .= '<div class="paygent-settlement-admin bank-error">' . $status_name . '</div>';
3225 }
3226 } else {
3227 $payment_status = ( isset( $settlement_ref['payment_status'] ) ) ? $settlement_ref['payment_status'] : '';
3228 $status = $this->get_status( $payment_status );
3229 $class = ' bank-' . $status;
3230 $status_name = $this->get_status_name( $payment_status );
3231 $result .= '<div class="paygent-settlement-admin' . $class . '">' . $status_name . '</div>';
3232 if ( 'bank_applying' == $latest_log['status'] && STATUS_REQUESTED == $payment_status ) {
3233 $this->save_acting_log( $settlement_ref, 'paygent_bank', $payment_status, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3234 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
3235 }
3236 }
3237 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="bank" value="状�
3238 �更新" /></div>';
3239 $result .= $this->settlement_history( $order_id, $trading_id );
3240 $data['result'] = $result;
3241 $data['status'] = $status;
3242 $data['acting_status'] = $acting_status;
3243 wp_send_json( $data );
3244 break;
3245
3246 /* Paidy 参�
3247 � */
3248 case 'get_paygent_paidy':
3249 check_admin_referer( 'order_edit', 'wc_nonce' );
3250 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3251 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3252 if ( empty( $order_id ) || empty( $trading_id ) ) {
3253 $data['status'] = 'reference_error';
3254 wp_send_json( $data );
3255 break;
3256 }
3257
3258 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3259 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3260 $data = $this->settlement_reference_paidy( $order_id, $trading_id, $payment_id );
3261 wp_send_json( $data );
3262 break;
3263
3264 /* Paidy オーソリキャンセル */
3265 case 'cancel_paygent_paidy':
3266 check_admin_referer( 'order_edit', 'wc_nonce' );
3267 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3268 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3269 if ( empty( $order_id ) || empty( $trading_id ) ) {
3270 $data['status'] = 'reference_error';
3271 wp_send_json( $data );
3272 break;
3273 }
3274
3275 $result = '';
3276 $status = '';
3277
3278 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3279 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3280 $telegram_kind = PAYGENT_PAIDY_AUTH_CANCEL;
3281 $settlement = $this->settlement_request_paidy( $telegram_kind, $trading_id, $payment_id );
3282 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
3283 $this->save_acting_log( $settlement, 'paygent_paidy', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3284 $status = 'payment_error';
3285 $status_name = $this->get_status_name( $status );
3286 $result .= '<div class="paygent-settlement-admin paidy-error">' . $status_name . '</div>';
3287 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3288 �更新" /></div>';
3289 $result .= $this->settlement_history( $order_id, $trading_id );
3290 $data['result'] = $result;
3291 $data['status'] = $status;
3292 } else {
3293 $this->save_acting_log( $settlement, 'paygent_paidy', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3294 $data = $this->settlement_reference_paidy( $order_id, $trading_id );
3295 }
3296 wp_send_json( $data );
3297 break;
3298
3299 /* Paidy 売上 */
3300 case 'capture_paygent_paidy':
3301 check_admin_referer( 'order_edit', 'wc_nonce' );
3302 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3303 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3304 if ( empty( $order_id ) || empty( $trading_id ) ) {
3305 $data['status'] = 'reference_error';
3306 wp_send_json( $data );
3307 break;
3308 }
3309
3310 $result = '';
3311 $status = '';
3312
3313 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3314 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3315 $telegram_kind = PAYGENT_PAIDY_CAPTURE;
3316 $settlement = $this->settlement_request_paidy( $telegram_kind, $trading_id, $payment_id );
3317 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
3318 $this->save_acting_log( $settlement, 'paygent_paidy', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3319 $status = 'payment_error';
3320 $status_name = $this->get_status_name( $status );
3321 $result .= '<div class="paygent-settlement-admin paidy-error">' . $status_name . '</div>';
3322 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3323 �更新" /></div>';
3324 $result .= $this->settlement_history( $order_id, $trading_id );
3325 $data['result'] = $result;
3326 $data['status'] = $status;
3327 } else {
3328 $this->save_acting_log( $settlement, 'paygent_paidy', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3329 $data = $this->settlement_reference_paidy( $order_id, $trading_id );
3330 }
3331 wp_send_json( $data );
3332 break;
3333
3334 /* Paidy 返金 */
3335 case 'refund_paygent_paidy':
3336 check_admin_referer( 'order_edit', 'wc_nonce' );
3337 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3338 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
3339 $amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
3340 if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
3341 $data['status'] = 'reference_error';
3342 wp_send_json( $data );
3343 break;
3344 }
3345
3346 $result = '';
3347 $status = '';
3348
3349 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3350 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
3351 $telegram_kind = PAYGENT_PAIDY_REFUND;
3352 $settlement = $this->settlement_request_paidy_refund( $telegram_kind, $trading_id, $amount, $payment_id );
3353 if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
3354 $this->save_acting_log( $settlement, 'paygent_paidy', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
3355 $status = 'payment_error';
3356 $status_name = $this->get_status_name( $status );
3357 $result .= '<div class="paygent-settlement-admin paidy-error">' . $status_name . '</div>';
3358 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3359 �更新" /></div>';
3360 $result .= $this->settlement_history( $order_id, $trading_id );
3361 $data['result'] = $result;
3362 $data['status'] = $status;
3363 } else {
3364 $this->save_acting_log( $settlement, 'paygent_paidy', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
3365 $data = $this->settlement_reference_paidy( $order_id, $trading_id );
3366 }
3367 wp_send_json( $data );
3368 break;
3369
3370 /* 継続課金�
3371 報更新 */
3372 case 'continuation_update':
3373 check_admin_referer( 'order_edit', 'wc_nonce' );
3374 $order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
3375 $member_id = ( isset( $post_data['member_id'] ) ) ? $post_data['member_id'] : '';
3376 $contracted_year = ( isset( $post_data['contracted_year'] ) ) ? $post_data['contracted_year'] : '';
3377 $contracted_month = ( isset( $post_data['contracted_month'] ) ) ? $post_data['contracted_month'] : '';
3378 $contracted_day = ( isset( $post_data['contracted_day'] ) ) ? $post_data['contracted_day'] : '';
3379 $charged_year = ( isset( $post_data['charged_year'] ) ) ? $post_data['charged_year'] : '';
3380 $charged_month = ( isset( $post_data['charged_month'] ) ) ? $post_data['charged_month'] : '';
3381 $charged_day = ( isset( $post_data['charged_day'] ) ) ? $post_data['charged_day'] : '';
3382 $price = ( isset( $post_data['price'] ) ) ? $post_data['price'] : 0;
3383 $status = ( isset( $post_data['status'] ) ) ? $post_data['status'] : '';
3384
3385 $continue_data = $this->get_continuation_data( $member_id, $order_id );
3386 if ( ! $continue_data ) {
3387 $data['status'] = 'NG';
3388 wp_send_json( $data );
3389 break;
3390 }
3391
3392 /* 継続中→停止 */
3393 if ( 'continuation' == $continue_data['status'] && 'cancellation' == $status ) {
3394 $this->update_continuation_data( $member_id, $order_id, $continue_data, true );
3395 } else {
3396 if ( ! empty( $contracted_year ) && ! empty( $contracted_month ) && ! empty( $contracted_day ) ) {
3397 $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
3398 if ( $contracted_date ) {
3399 $new_contracted_date = $contracted_year . '-' . $contracted_month . '-' . $contracted_day;
3400 if ( ! $this->isdate( $new_contracted_date ) ) {
3401 $data['status'] = 'NG';
3402 $data['message'] = __( 'Next contract renewal date is incorrect.', 'dlseller' );
3403 wp_send_json( $data );
3404 }
3405 }
3406 } else {
3407 $new_contracted_date = '';
3408 }
3409 $new_charged_date = $charged_year . '-' . $charged_month . '-' . $charged_day;
3410 if ( ! $this->isdate( $new_charged_date ) ) {
3411 $data['status'] = 'NG';
3412 $data['message'] = __( 'Next settlement date is incorrect.', 'dlseller' );
3413 wp_send_json( $data );
3414 }
3415 $tomorrow = date_i18n( 'Y-m-d', strtotime( '+1 day' ) );
3416 if ( $new_charged_date < $tomorrow ) {
3417 $data['status'] = 'NG';
3418 $data['message'] = sprintf( __( 'The next settlement date must be after %s.', 'dlseller' ), $tomorrow );
3419 wp_send_json( $data );
3420 }
3421 $continue_data['contractedday'] = $new_contracted_date;
3422 $continue_data['chargedday'] = $new_charged_date;
3423 $continue_data['price'] = usces_crform( $price, false, false, 'return', false );
3424 $continue_data['status'] = $status;
3425 $this->update_continuation_data( $member_id, $order_id, $continue_data );
3426 }
3427 $data['status'] = 'OK';
3428 wp_send_json( $data );
3429 break;
3430 }
3431 }
3432
3433 /**
3434 * クレジットカード決済履歴
3435 *
3436 * @param int $order_id Order number.
3437 * @param string $trading_id Trading ID.
3438 * @param string $payment_id Payment ID.
3439 * @param int $member_id Member ID.
3440 * @return array
3441 */
3442 private function settlement_reference_card( $order_id, $trading_id, $payment_id, $member_id = '' ) {
3443 global $usces;
3444
3445 $data = array();
3446 $result = '';
3447 $status = '';
3448 $acting_status = '';
3449
3450 if ( empty( $payment_id ) ) {
3451 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id, RESULT_STATUS_ALL );
3452 if ( isset( $latest_log['status'] ) && ( 'payment_error' == $latest_log['status'] || 'customer_error' == $latest_log['status'] ) ) {
3453 $customer = $this->customer_ref( $member_id );
3454 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id ) {
3455 $order_data = $usces->get_order_data( $order_id, 'direct' );
3456 $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'];
3457 $result .= '<table class="settlement-admin-table">';
3458 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3459 $result .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3460 $result .= '</tr></table>';
3461 $result .= '<div class="paygent-settlement-admin-button">';
3462 $result .= '<input id="auth-settlement" type="button" class="button" value="新規オーソリ" />';
3463 $result .= '<input id="update-status" type="button" class="button" data-mode="card" value="状�
3464 �更新" />';
3465 $result .= '</div>';
3466 } else {
3467 $status = 'error';
3468 $result .= '<div class="paygent-settlement-admin card-error">' . __( 'Credit card information not registered', 'usces' ) . '</div>';
3469 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3470 �更新" /></div>';
3471 }
3472 } else {
3473 $status = 'error';
3474 $status_name = $this->get_status_name( $status );
3475 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3476 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3477 �更新" /></div>';
3478 }
3479 } else {
3480 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
3481 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
3482 $status = 'reference_error';
3483 $status_name = $this->get_status_name( $status );
3484 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3485 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3486 �更新" /></div>';
3487 } elseif ( isset( $settlement_ref['payment_status'] ) ) {
3488 $payment_status = $settlement_ref['payment_status'];
3489 $status = $this->get_status( $payment_status );
3490 $class = ' card-' . $status;
3491 $status_name = $this->get_status_name( $payment_status );
3492 $amount = $settlement_ref['payment_amount'];
3493 $result .= '<div class="paygent-settlement-admin' . $class . '">' . $status_name . '</div>';
3494 switch ( $payment_status ) {
3495 case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
3496 case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
3497 $result .= '<table class="settlement-admin-table">';
3498 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3499 $result .= '<td><input type="tel" class="settlement-amount" id="amount_change" value="' . intval( $amount ) . '" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3500 $result .= '</tr></table>';
3501 $result .= '<div class="paygent-settlement-admin-button">';
3502 $result .= '<input id="auth-settlement" type="button" class="button" value="新規オーソリ" />';
3503 $result .= '<input id="update-status" type="button" class="button" data-mode="card" value="状�
3504 �更新" />';
3505 $result .= '</div>';
3506 break;
3507 case STATUS_AUTHORIZE_OK: /* オーソリOK */
3508 $result .= '<table class="settlement-admin-table">';
3509 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3510 $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>';
3511 $result .= '</tr></table>';
3512 $result .= '<div class="paygent-settlement-admin-button">';
3513 $result .= '<input id="sales-settlement" type="button" class="button" value="売上処理" />';
3514 $result .= '<input id="auth-revise-settlement" type="button" class="button" value="金額変更" />';
3515 $result .= '<input id="auth-cancel-settlement" type="button" class="button" value="キャンセル処理" />';
3516 $result .= '<input id="update-status" type="button" class="button" data-mode="card" value="状�
3517 �更新" />';
3518 $result .= '</div>';
3519 break;
3520 case STATUS_AUTHORIZE_CANCELING: /* オーソリ取消中 */
3521 $result .= '<table class="settlement-admin-table">';
3522 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3523 $result .= '<td><input type="tel" class="settlement-amount" value="' . intval( $amount ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3524 $result .= '</tr></table>';
3525 $result .= '<div class="paygent-settlement-admin-button">';
3526 $result .= '<input id="auth-cancel-settlement" type="button" class="button" value="キャンセル処理" />';
3527 $result .= '</div>';
3528 break;
3529 case STATUS_SALES_REQUEST_PENDING: /* 売上要求中 */
3530 $result .= '<table class="settlement-admin-table">';
3531 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3532 $result .= '<td><input type="tel" class="settlement-amount" value="' . intval( $amount ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3533 $result .= '</tr></table>';
3534 $result .= '<div class="paygent-settlement-admin-button">';
3535 $result .= '<input id="sales-settlement" type="button" class="button" value="売上処理" />';
3536 $result .= '</div>';
3537 break;
3538 case STATUS_CLEARED: /* 消込済 */
3539 $result .= '<table class="settlement-admin-table">';
3540 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3541 $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>';
3542 $result .= '</tr></table>';
3543 $result .= '<div class="paygent-settlement-admin-button">';
3544 $result .= '<input id="sales-revise-settlement" type="button" class="button" value="金額変更" />';
3545 $result .= '<input id="sales-cancel-settlement" type="button" class="button" value="キャンセル処理" />';
3546 $result .= '<input id="update-status" type="button" class="button" data-mode="card" value="状�
3547 �更新" />';
3548 $result .= '</div>';
3549 break;
3550 case STATUS_SALES_CANCELING: /* 売上取消中 */
3551 case STATUS_SALES_CANCELING_TALLY: /* 売上取消集計中 */
3552 $result .= '<table class="settlement-admin-table">';
3553 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3554 $result .= '<td><input type="tel" class="settlement-amount" value="' . intval( $amount ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3555 $result .= '</tr></table>';
3556 $result .= '<div class="paygent-settlement-admin-button">';
3557 $result .= '<input id="sales-cancel-settlement" type="button" class="button" value="キャンセル処理" />';
3558 $result .= '</div>';
3559 break;
3560 default:
3561 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3562 �更新" /></div>';
3563 }
3564 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
3565 } else {
3566 $status = 'error';
3567 $status_name = $this->get_status_name( $status );
3568 $result .= '<div class="paygent-settlement-admin card-error">' . $status_name . '</div>';
3569 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="card" value="状�
3570 �更新" /></div>';
3571 }
3572 }
3573 $result .= $this->settlement_history( $order_id, $trading_id );
3574 $data['result'] = $result;
3575 $data['status'] = $status;
3576 $data['acting_status'] = $acting_status;
3577 return $data;
3578 }
3579
3580 /**
3581 * Paidy 決済履歴
3582 *
3583 * @param int $order_id Order number.
3584 * @param string $trading_id Trading ID.
3585 * @param string $payment_id Payment ID.
3586 * @return array
3587 */
3588 private function settlement_reference_paidy( $order_id, $trading_id, $payment_id = '' ) {
3589 $data = array();
3590 $result = '';
3591 $status = '';
3592 $acting_status = '';
3593 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
3594 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
3595 $status = 'reference_error';
3596 $status_name = $this->get_status_name( $status );
3597 $result .= '<div class="paygent-settlement-admin paidy-error">' . $status_name . '</div>';
3598 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3599 �更新" /></div>';
3600 } elseif ( isset( $settlement_ref['payment_status'] ) ) {
3601 $payment_status = $settlement_ref['payment_status'];
3602 $status = $this->get_status( $payment_status );
3603 $class = ' paidy-' . $status;
3604 $status_name = $this->get_status_name( $payment_status );
3605 $amount = $settlement_ref['payment_amount'];
3606 $result .= '<div class="paygent-settlement-admin' . $class . '">' . $status_name . '</div>';
3607 switch ( $payment_status ) {
3608 case STATUS_AUTHORIZE_OK: /* オーソリOK */
3609 $result .= '<table class="settlement-admin-table">';
3610 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3611 $result .= '<td><input type="tel" class="settlement-amount" value="' . intval( $amount ) . '" disabled="disabled" />' . __( usces_crcode( 'return' ), 'usces' ) . '</td>';
3612 $result .= '</tr></table>';
3613 $result .= '<div class="paygent-settlement-admin-button">';
3614 $result .= '<input id="paidy-capture-settlement" type="button" class="button" value="売上処理" />';
3615 $result .= '<input id="paidy-cancel-settlement" type="button" class="button" value="オーソリキャンセル処理" />';
3616 $result .= '<input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3617 �更新" />';
3618 $result .= '</div>';
3619 break;
3620 case STATUS_CLEARED: /* 消込済 */
3621 $result .= '<table class="settlement-admin-table">';
3622 $result .= '<tr><th>' . __( 'Settlement amount', 'usces' ) . '</th>';
3623 $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>';
3624 $result .= '</tr></table>';
3625 $result .= '<div class="paygent-settlement-admin-button">';
3626 $result .= '<input id="paidy-refund-settlement" type="button" class="button" value="返金処理" />';
3627 $result .= '<input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3628 �更新" />';
3629 $result .= '</div>';
3630 break;
3631 default:
3632 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3633 �更新" /></div>';
3634 }
3635 $acting_status = '<span class="acting-status' . $class . '">' . $status_name . '</span>';
3636 } else {
3637 $status = 'error';
3638 $status_name = $this->get_status_name( $status );
3639 $result .= '<div class="paygent-settlement-admin paidy-error">' . $status_name . '</div>';
3640 $result .= '<div class="paygent-settlement-admin-button"><input id="update-status" type="button" class="button" data-mode="paidy" value="状�
3641 �更新" /></div>';
3642 }
3643 $result .= $this->settlement_history( $order_id, $trading_id );
3644 $data['result'] = $result;
3645 $data['status'] = $status;
3646 $data['acting_status'] = $acting_status;
3647 return $data;
3648 }
3649
3650 /**
3651 * 決済履歴
3652 *
3653 * @param int $order_id Order number.
3654 * @param string $trading_id Trading ID.
3655 * @return string
3656 */
3657 private function settlement_history( $order_id, $trading_id ) {
3658 $history = '';
3659 $log_data = $this->get_acting_log( $order_id, $trading_id, RESULT_STATUS_ALL );
3660 if ( $log_data ) {
3661 $num = count( $log_data );
3662 $history = '<table class="settlement-history">';
3663 $history .= '<thead class="settlement-history-head">';
3664 $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>';
3665 $history .= '</thead>';
3666 $history .= '<tbody class="settlement-history-body">';
3667 foreach ( (array) $log_data as $data ) {
3668 $log = usces_unserialize( $data['log'] );
3669 $payment_id = ( isset( $log['payment_id'] ) ) ? $log['payment_id'] : '';
3670 if ( empty( $payment_id ) && isset( $log['paidy_id'] ) ) {
3671 $payment_id = $log['paidy_id'];
3672 }
3673 $status_name = ( isset( $data['status'] ) ) ? $this->get_status_name( $data['status'] ) : '';
3674 $err_code = '';
3675 $class = '';
3676 if ( 2 == strlen( $data['status'] ) || 0 < $data['amount'] ) {
3677 $amount = usces_crform( $data['amount'], false, true, 'return', true );
3678 } else {
3679 $amount = '';
3680 }
3681 if ( RESULT_STATUS_NORMAL != $data['result'] ) {
3682 $err_code = ( isset( $log['result_message'] ) ) ? $log['result_message'] : '';
3683 $class = ' error';
3684 }
3685 $history .= '<tr>';
3686 $history .= '<td class="num">' . $num . '</td>';
3687 $history .= '<td class="datetime">' . $data['datetime'] . '</td>';
3688 $history .= '<td class="transactionid">' . $payment_id . '</td>';
3689 $history .= '<td class="tradingid">' . $trading_id . '</td>';
3690 $history .= '<td class="status">' . $status_name . '</td>';
3691 $history .= '<td class="amount">' . $amount . '</td>';
3692 $history .= '<td class="result' . $class . '">' . $err_code . '</td>';
3693 $history .= '</tr>';
3694 $num--;
3695 }
3696 $history .= '</tbody>';
3697 $history .= '</table>';
3698 }
3699 return $history;
3700 }
3701
3702 /**
3703 * 決済状況
3704 * usces_filter_orderlist_detail_value
3705 *
3706 * @param string $detail HTML.
3707 * @param string $value Settlement info key.
3708 * @param string $key Settlement info value.
3709 * @param int $order_id Order number.
3710 * @return array
3711 */
3712 public function orderlist_settlement_status( $detail, $value, $key, $order_id ) {
3713 global $usces;
3714
3715 if ( 'wc_trans_id' != $key || empty( $value ) ) {
3716 return $detail;
3717 }
3718
3719 $acting_flg = $this->get_order_acting_flg( $order_id );
3720 if ( in_array( $acting_flg, $this->pay_method ) ) {
3721 $class = '';
3722 $status_name = '';
3723 $trading_id = $this->get_trading_id( $order_id );
3724 $payment_status = $this->get_payment_status( $order_id, $trading_id );
3725 if ( ! empty( $payment_status ) ) {
3726 switch ( $acting_flg ) {
3727 case 'acting_paygent_card':
3728 $class = ' card-' . $this->get_status( $payment_status );
3729 $status_name = $this->get_status_name( $payment_status );
3730 break;
3731 case 'acting_paygent_conv':
3732 $class = ' conv-' . $this->get_status( $payment_status );
3733 $status_name = $this->get_status_name( $payment_status );
3734 break;
3735 case 'acting_paygent_atm':
3736 $class = ' atm-' . $this->get_status( $payment_status );
3737 $status_name = $this->get_status_name( $payment_status );
3738 break;
3739 case 'acting_paygent_bank':
3740 $class = ' bank-' . $this->get_status( $payment_status );
3741 $status_name = $this->get_status_name( $payment_status );
3742 break;
3743 case 'acting_paygent_paidy':
3744 $class = ' paidy-' . $this->get_status( $payment_status );
3745 $status_name = $this->get_status_name( $payment_status );
3746 break;
3747 }
3748 }
3749 if ( ! empty( $class ) && ! empty( $status_name ) ) {
3750 $detail = '<td>' . esc_html( $value ) . '<span class="acting-status' . esc_html( $class ) . '">' . esc_html( $status_name ) . '</span></td>';
3751 }
3752 }
3753 return $detail;
3754 }
3755
3756 /**
3757 * 受注編集画面【ステータス】
3758 * usces_action_order_edit_form_status_block_middle
3759 *
3760 * @param array $data Order data.
3761 * @param array $cscs_meta Custom field data.
3762 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3763 */
3764 public function settlement_status( $data, $cscs_meta, $action_args ) {
3765 global $usces;
3766 extract( $action_args );
3767
3768 if ( 'new' != $order_action && ! empty( $order_id ) ) {
3769 $payment = usces_get_payments_by_name( $data['order_payment_name'] );
3770 $acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
3771 if ( in_array( $acting_flg, $this->pay_method ) ) {
3772 $trading_id = $this->get_trading_id( $order_id );
3773 $payment_status = $this->get_payment_status( $order_id, $trading_id );
3774 if ( ! empty( $payment_status ) ) {
3775 $class = '';
3776 $status_name = '';
3777 switch ( $acting_flg ) {
3778 case 'acting_paygent_card':
3779 $class = ' card-' . $this->get_status( $payment_status );
3780 $status_name = $this->get_status_name( $payment_status );
3781 break;
3782 case 'acting_paygent_conv':
3783 $class = ' conv-' . $this->get_status( $payment_status );
3784 $status_name = $this->get_status_name( $payment_status );
3785 break;
3786 case 'acting_paygent_atm':
3787 $class = ' atm-' . $this->get_status( $payment_status );
3788 $status_name = $this->get_status_name( $payment_status );
3789 break;
3790 case 'acting_paygent_bank':
3791 $class = ' bank-' . $this->get_status( $payment_status );
3792 $status_name = $this->get_status_name( $payment_status );
3793 break;
3794 case 'acting_paygent_paidy':
3795 $class = ' paidy-' . $this->get_status( $payment_status );
3796 $status_name = $this->get_status_name( $payment_status );
3797 break;
3798 }
3799 if ( ! empty( $status_name ) ) {
3800 echo '
3801 <tr>
3802 <td class="label status">' . esc_html__( 'Settlement status', 'usces' ) . '</td>
3803 <td class="col1 status"><span id="settlement-status"><span class="acting-status' . esc_attr( $class ) . '">' . esc_html( $status_name ) . '</span></span></td>
3804 </tr>';
3805 }
3806 }
3807 }
3808 }
3809 }
3810
3811 /**
3812 * 受注編集画面【支払�
3813 報】
3814 * usces_action_order_edit_form_settle_info
3815 *
3816 * @param array $data Order data.
3817 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3818 */
3819 public function settlement_information( $data, $action_args ) {
3820 global $usces;
3821 extract( $action_args );
3822
3823 if ( 'new' != $order_action && ! empty( $order_id ) ) {
3824 $payment = usces_get_payments_by_name( $data['order_payment_name'] );
3825 if ( isset( $payment['settlement'] ) && in_array( $payment['settlement'], $this->pay_method ) ) {
3826 $acting_data = usces_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
3827 $trading_id = ( isset( $acting_data['trading_id'] ) ) ? $acting_data['trading_id'] : '9999999999';
3828 if ( ! empty( $trading_id ) ) {
3829 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' ) . '">';
3830 }
3831 }
3832 }
3833 }
3834
3835 /**
3836 * 決済�
3837 報ダイアログ
3838 * usces_action_endof_order_edit_form
3839 *
3840 * @param array $data Order data.
3841 * @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
3842 */
3843 public function settlement_dialog( $data, $action_args ) {
3844 global $usces;
3845 extract( $action_args );
3846
3847 if ( 'new' != $order_action && ! empty( $order_id ) ) :
3848 $payment = usces_get_payments_by_name( $data['order_payment_name'] );
3849 if ( isset( $payment['settlement'] ) && in_array( $payment['settlement'], $this->pay_method ) ) :
3850 ?>
3851 <div id="settlement_dialog" title="">
3852 <div id="settlement-response-loading"></div>
3853 <fieldset>
3854 <div id="settlement-response"></div>
3855 <input type="hidden" id="order_num">
3856 <input type="hidden" id="trading_id">
3857 <input type="hidden" id="acting" value="<?php echo esc_attr( $payment['settlement'] ); ?>">
3858 <input type="hidden" id="error">
3859 </fieldset>
3860 </div>
3861 <?php
3862 endif;
3863 endif;
3864 }
3865
3866 /**
3867 * 受注データから取得する決済�
3868 報のキー
3869 * usces_filter_settle_info_field_meta_keys
3870 *
3871 * @param array $keys Settlement information key.
3872 * @return array
3873 */
3874 public function settlement_info_field_meta_keys( $keys ) {
3875 $keys = array_merge( $keys, array( 'payment_type', 'trading_id', 'split_count' ) );
3876 return $keys;
3877 }
3878
3879 /**
3880 * 受注編集画面に表示する決済�
3881 報のキー
3882 * usces_filter_settle_info_field_keys
3883 *
3884 * @param array $keys Settlement information keys.
3885 * @param array $fields Settlement information fields.
3886 * @return array
3887 */
3888 public function settlement_info_field_keys( $keys, $fields ) {
3889 if ( isset( $fields['payment_type'] ) ) {
3890 switch ( $fields['payment_type'] ) {
3891 case PAYMENT_TYPE_CREDIT:
3892 $keys = array( 'trading_id', 'payment_type', 'split_count' );
3893 break;
3894 case PAYMENT_TYPE_CONVENI_NUM:
3895 case PAYMENT_TYPE_ATM:
3896 case PAYMENT_TYPE_BANK:
3897 $keys = array( 'trading_id', 'payment_type', 'payment_date', 'payment_limit_date' );
3898 break;
3899 case PAYMENT_TYPE_PAIDY:
3900 $keys = array( 'trading_id', 'payment_type' );
3901 break;
3902 }
3903 }
3904 return $keys;
3905 }
3906
3907 /**
3908 * 受注編集画面に表示する決済�
3909 報の値整形
3910 * usces_filter_settle_info_field_value
3911 *
3912 * @param string $value Settlement information value.
3913 * @param string $key Settlement information key.
3914 * @param string $acting Acting type.
3915 * @return string
3916 */
3917 public function settlement_info_field_value( $value, $key, $acting ) {
3918 switch ( $key ) {
3919 case 'payment_type':
3920 switch ( $value ) {
3921 case PAYMENT_TYPE_CREDIT:
3922 $value = $this->acting_name . ' カード決済';
3923 break;
3924 case PAYMENT_TYPE_CONVENI_NUM:
3925 $value = $this->acting_name . ' コンビニ決済';
3926 break;
3927 case PAYMENT_TYPE_ATM:
3928 $value = $this->acting_name . ' ATM決済';
3929 break;
3930 case PAYMENT_TYPE_BANK:
3931 $value = $this->acting_name . ' 銀行ネット決済';
3932 break;
3933 case PAYMENT_TYPE_PAIDY:
3934 $value = $this->acting_name . ' Paidy';
3935 break;
3936 }
3937 break;
3938
3939 case 'split_count':
3940 switch ( $value ) {
3941 case '01':
3942 $value = __( 'One time payment', 'usces' );
3943 break;
3944 case '02':
3945 case '03':
3946 case '05':
3947 case '06':
3948 case '10':
3949 case '12':
3950 case '15':
3951 case '18':
3952 case '20':
3953 case '24':
3954 $times = (int) $value;
3955 $value = $times . __( '-time payment', 'usces' );
3956 break;
3957 case '23':
3958 $value = __( 'Bonus lump-sum payment', 'usces' );
3959 break;
3960 case '80':
3961 $value = __( 'Libor Funding pay', 'usces' );
3962 break;
3963 }
3964 }
3965 return $value;
3966 }
3967
3968 /**
3969 * 管理画面送信メール
3970 * usces_filter_order_confirm_mail_payment
3971 *
3972 * @param string $msg_payment Payment information message.
3973 * @param int $order_id Order number.
3974 * @param array $payment Payment data.
3975 * @param array $cart Cart data.
3976 * @param array $order_data Order data.
3977 * @return string
3978 */
3979 public function order_confirm_mail_payment( $msg_payment, $order_id, $payment, $cart, $order_data ) {
3980 global $usces;
3981
3982 switch ( $payment['settlement'] ) {
3983 case 'acting_paygent_card':
3984 $acting_opts = $this->get_acting_settings();
3985 if ( 0 !== (int) $acting_opts['payment_class'] ) {
3986 $trading_id = $this->get_trading_id( $order_id );
3987 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
3988 if ( isset( $latest_log['log']['split_count'] ) && isset( $latest_log['log']['payment_class'] ) ) {
3989 switch ( $latest_log['log']['payment_class'] ) {
3990 case '10':
3991 $split_count = __( '(', 'usces' ) . __( 'One time payment', 'usces' ) . __( ')', 'usces' );
3992 break;
3993 case '23':
3994 $split_count = __( '(', 'usces' ) . __( 'Bonus lump-sum payment', 'usces' ) . __( ')', 'usces' );
3995 break;
3996 case '80':
3997 $split_count = __( '(', 'usces' ) . __( 'Libor Funding pay', 'usces' ) . __( ')', 'usces' );
3998 break;
3999 default:
4000 $times = (int) $latest_log['log']['split_count'];
4001 if ( 0 < $times ) {
4002 $split_count = __( '(', 'usces' ) . $times . __( '-time payment', 'usces' ) . __( ')', 'usces' );
4003 }
4004 }
4005 if ( ! empty( $split_count ) ) {
4006 if ( usces_is_html_mail() ) {
4007 $msg_payment = '<tr><td colspan="2" style="padding: 0 0 25px 0;">';
4008 $msg_payment .= $payment['name'] . $split_count;
4009 $msg_payment .= '</td></tr>';
4010 } else {
4011 $msg_payment = __( '** Payment method **', 'usces' ) . "\r\n";
4012 $msg_payment .= usces_mail_line( 1, $order_data['order_email'] );
4013 $msg_payment .= $payment['name'] . $split_count;
4014 $msg_payment .= "\r\n\r\n";
4015 }
4016 }
4017 }
4018 }
4019 break;
4020 case 'acting_paygent_conv':
4021 $mode = ( isset( $_POST['mode'] ) ) ? wp_unslash( $_POST['mode'] ) : '';
4022 if ( 'orderConfirmMail' == $mode || 'changeConfirmMail' == $mode ) {
4023 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_paygent_conv', $order_id ) );
4024 $usable_cvs_company_id = ( isset( $acting_data['usable_cvs_company_id'] ) ) ? $acting_data['usable_cvs_company_id'] : '';
4025 $receipt_number = ( isset( $acting_data['receipt_number'] ) ) ? $acting_data['receipt_number'] : '';
4026 if ( usces_is_html_mail() ) {
4027 $msg_payment = '<tr><td colspan="2" style="padding: 0 0 25px 0;">';
4028 $msg_payment .= $payment['name'] . '<br><br>';
4029 $lb = '<br>';
4030 } else {
4031 $lb = "\r\n";
4032 }
4033 if ( ! empty( $receipt_number ) ) {
4034 if ( false !== strpos( $usable_cvs_company_id, CODE_SEICOMART ) ) {
4035 $msg_payment .= $this->cvs_company_a[ CODE_SEICOMART ] . 'でのお支払い' . $lb;
4036 $msg_payment .= '受付番号:' . $receipt_number . $lb;
4037 }
4038 if ( false !== strpos( $usable_cvs_company_id, CODE_SEVENELEVEN ) ) {
4039 $msg_payment .= $this->cvs_company_a[ CODE_SEVENELEVEN ] . 'でのお支払い' . $lb;
4040 $msg_payment .= '払込票番号:' . $receipt_number . $lb;
4041 }
4042 if ( false !== strpos( $usable_cvs_company_id, CODE_LOWSON ) ) {
4043 $msg_payment .= $this->cvs_company_a[ CODE_LOWSON ] . 'でのお支払い' . $lb;
4044 $msg_payment .= 'お客様番号:' . $receipt_number . $lb;
4045 $msg_payment .= '確認番号:' . CONVENI_CONFIRMATION_NUMBER . $lb;
4046 }
4047 if ( false !== strpos( $usable_cvs_company_id, CODE_MINISTOP ) ) {
4048 $msg_payment .= $this->cvs_company_a[ CODE_MINISTOP ] . 'でのお支払い' . $lb;
4049 $msg_payment .= 'お客様番号:' . $receipt_number . $lb;
4050 $msg_payment .= '確認番号:' . CONVENI_CONFIRMATION_NUMBER . $lb;
4051 }
4052 if ( false !== strpos( $usable_cvs_company_id, CODE_FAMILYMART ) ) {
4053 $msg_payment .= $this->cvs_company_a[ CODE_FAMILYMART ] . 'でのお支払い' . $lb;
4054 $msg_payment .= '収納番号:' . $receipt_number . $lb;
4055 }
4056 if ( false !== strpos( $usable_cvs_company_id, CODE_YAMAZAKI ) ) {
4057 $msg_payment .= $this->cvs_company_a[ CODE_YAMAZAKI ] . 'でのお支払い' . $lb;
4058 $msg_payment .= '決済番号:' . $receipt_number . $lb;
4059 }
4060 }
4061 if ( ! empty( $acting_data['receipt_print_url'] ) ) {
4062 $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'];
4063 if ( false !== strpos( $usable_cvs_company_id, CODE_SEICOMART ) || false !== strpos( $usable_cvs_company_id, CODE_SEVENELEVEN ) ) {
4064 $msg_payment .= '払込票URL:' . $receipt_print_url . $lb;
4065 } else {
4066 $msg_payment .= '支払参�
4067 �URL:' . $receipt_print_url . $lb;
4068 }
4069 }
4070 if ( ! empty( $acting_data['payment_limit_date'] ) ) {
4071 $msg_payment .= 'お支払い期限日:' . date( __( 'Y/m/d' ), strtotime( $acting_data['payment_limit_date'] ) ) . $lb;
4072 }
4073 if ( usces_is_html_mail() ) {
4074 $msg_payment .= '</td></tr>';
4075 }
4076 }
4077 break;
4078 case 'acting_paygent_atm':
4079 $mode = ( isset( $_POST['mode'] ) ) ? wp_unslash( $_POST['mode'] ) : '';
4080 if ( 'orderConfirmMail' == $mode || 'changeConfirmMail' == $mode ) {
4081 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_paygent_atm', $order_id ) );
4082 $lb = ( usces_is_html_mail() ) ? '<br>' : "\r\n";
4083 if ( isset( $acting_data['pay_center_number'] ) ) {
4084 $msg_payment .= '収納機関番号:' . $acting_data['pay_center_number'] . $lb;
4085 }
4086 if ( isset( $acting_data['customer_number'] ) ) {
4087 $msg_payment .= 'お客様番号:' . $acting_data['customer_number'] . $lb;
4088 }
4089 if ( isset( $acting_data['conf_number'] ) ) {
4090 $msg_payment .= '確認番号:' . $acting_data['conf_number'] . $lb;
4091 }
4092 if ( isset( $acting_data['payment_limit_date'] ) ) {
4093 $msg_payment .= 'お支払い期限日:' . date( __( 'Y/m/d' ), strtotime( $acting_data['payment_limit_date'] ) ) . $lb;
4094 }
4095 }
4096 break;
4097 case 'acting_paygent_bank':
4098 break;
4099 case 'acting_paygent_paidy':
4100 break;
4101 }
4102 return $msg_payment;
4103 }
4104
4105 /**
4106 * 決済リンクキー
4107 * usces_filter_get_link_key
4108 *
4109 * @param string $linkkey Settlement link key.
4110 * @param array $results Response data.
4111 * @return string
4112 */
4113 public function get_link_key( $linkkey, $results ) {
4114 if ( isset( $results['trading_id'] ) ) {
4115 $linkkey = $results['trading_id'];
4116 }
4117 return $linkkey;
4118 }
4119
4120 /**
4121 * 受注データ復旧処理
4122 * usces_action_revival_order_data
4123 *
4124 * @param int $order_id Order number.
4125 * @param string $log_key Link key.
4126 * @param string $acting_flg Payment type.
4127 */
4128 public function revival_orderdata( $order_id, $log_key, $acting_flg ) {
4129 global $usces;
4130
4131 switch ( $acting_flg ) {
4132 case 'acting_paygent_card':
4133 $data = array(
4134 'trading_id' => $log_key,
4135 'payment_type' => PAYMENT_TYPE_CREDIT,
4136 );
4137 $usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
4138 $usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
4139 break;
4140 case 'acting_paygent_conv':
4141 $data = array(
4142 'trading_id' => $log_key,
4143 'payment_type' => PAYMENT_TYPE_CONVENI_NUM,
4144 );
4145 $usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
4146 $usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
4147 break;
4148 case 'acting_paygent_atm':
4149 $data = array(
4150 'trading_id' => $log_key,
4151 'payment_type' => PAYMENT_TYPE_ATM,
4152 );
4153 $usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
4154 $usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
4155 break;
4156 case 'acting_paygent_bank':
4157 $data = array(
4158 'trading_id' => $log_key,
4159 'payment_type' => PAYMENT_TYPE_BANK,
4160 );
4161 $usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
4162 $usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
4163 break;
4164 case 'acting_paygent_paidy':
4165 $data = array(
4166 'trading_id' => $log_key,
4167 'payment_type' => PAYMENT_TYPE_PAIDY,
4168 );
4169 $usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
4170 $usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
4171 break;
4172 }
4173 }
4174
4175 /**
4176 * 支払方法説明
4177 * usces_filter_payment_detail
4178 *
4179 * @param string $str Payment method description.
4180 * @param array $entry Entry data.
4181 * @return string
4182 */
4183 public function payment_detail( $str, $entry ) {
4184 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
4185 if ( isset( $payment['settlement'] ) && 'acting_paygent_card' == $payment['settlement'] ) {
4186 $acting_opts = $this->get_acting_settings();
4187 if ( 0 !== (int) $acting_opts['payment_class'] ) {
4188 $split_count = ( isset( $_POST['split_count'] ) ) ? wp_unslash( $_POST['split_count'] ) : '01';
4189 switch ( $split_count ) {
4190 case '01':
4191 $str = __( '(', 'usces' ) . __( 'One time payment', 'usces' ) . __( ')', 'usces' );
4192 break;
4193 case '02':
4194 case '03':
4195 case '05':
4196 case '06':
4197 case '10':
4198 case '12':
4199 case '15':
4200 case '18':
4201 case '20':
4202 case '24':
4203 $times = (int) $split_count;
4204 $str = __( '(', 'usces' ) . $times . __( '-time payment', 'usces' ) . __( ')', 'usces' );
4205 break;
4206 case '23':
4207 $str = __( '(', 'usces' ) . __( 'Bonus lump-sum payment', 'usces' ) . __( ')', 'usces' );
4208 break;
4209 case '80':
4210 $str = __( '(', 'usces' ) . __( 'Libor Funding pay', 'usces' ) . __( ')', 'usces' );
4211 break;
4212 default:
4213 $str = __( '(', 'usces' ) . __( 'One time payment', 'usces' ) . __( ')', 'usces' );
4214 }
4215 }
4216 } elseif ( isset( $payment['settlement'] ) && 'acting_paygent_conv' == $payment['settlement'] ) {
4217 $acting_opts = $this->get_acting_settings();
4218 $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['payment_term_day'] ) . __( ')', 'usces' );
4219 $str = apply_filters( 'usces_filter_paygent_payment_limit_conv', $payment_detail, $acting_opts['payment_term_day'] );
4220 } elseif ( isset( $payment['settlement'] ) && 'acting_paygent_atm' == $payment['settlement'] ) {
4221 $acting_opts = $this->get_acting_settings();
4222 $payment_limit_date = ( WCUtils::is_blank( $acting_opts['payment_limit_date'] ) ) ? 30 : (int) $acting_opts['payment_limit_date'];
4223 if ( 0 < $payment_limit_date ) {
4224 $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $payment_limit_date ) . __( ')', 'usces' );
4225 } else {
4226 $payment_detail = __( '(', 'usces' ) . '本日中にお支払いを完了してください。' . __( ')', 'usces' );
4227 }
4228 $str = apply_filters( 'usces_filter_paygent_payment_limit_atm', $payment_detail, $acting_opts['payment_limit_date'] );
4229 } elseif ( isset( $payment['settlement'] ) && 'acting_paygent_bank' == $payment['settlement'] ) {
4230 $acting_opts = $this->get_acting_settings();
4231 $asp_payment_term = $this->asp_payment_term[ $acting_opts['asp_payment_term'] ];
4232 $payment_detail = __( '(', 'usces' ) . sprintf( '%sにお支払いを完了してください。', $asp_payment_term ) . __( ')', 'usces' );
4233 $str = apply_filters( 'usces_filter_paygent_payment_limit_bank', $payment_detail, $acting_opts['asp_payment_term'] );
4234 }
4235 return $str;
4236 }
4237
4238 /**
4239 * 支払方法 JavaScript 用決済名追加
4240 * usces_filter_payments_str
4241 *
4242 * @param string $payments_str Payments.
4243 * @param array $payment Selected payment.
4244 * @return string
4245 */
4246 public function payments_str( $payments_str, $payment ) {
4247 switch ( $payment['settlement'] ) {
4248 case 'acting_paygent_card':
4249 if ( $this->is_activate_card( 'module' ) ) {
4250 $payments_str .= "'" . $payment['name'] . "': 'paygent_card_form', ";
4251 }
4252 break;
4253 case 'acting_paygent_conv':
4254 if ( $this->is_activate_conv( 'module' ) ) {
4255 $payments_str .= "'" . $payment['name'] . "': 'paygent_conv_form', ";
4256 }
4257 break;
4258 case 'acting_paygent_atm':
4259 if ( $this->is_activate_atm() ) {
4260 $payments_str .= "'" . $payment['name'] . "': 'paygent_atm_form', ";
4261 }
4262 break;
4263 case 'acting_paygent_bank':
4264 if ( $this->is_activate_bank() ) {
4265 $payments_str .= "'" . $payment['name'] . "': 'paygent_bank_form', ";
4266 }
4267 break;
4268 }
4269 return $payments_str;
4270 }
4271
4272 /**
4273 * 支払方法 JavaScript 用決済追加
4274 * usces_filter_payments_arr
4275 *
4276 * @param array $payments_arr Payments.
4277 * @param array $payment Selected payment.
4278 * @return array
4279 */
4280 public function payments_arr( $payments_arr, $payment ) {
4281 switch ( $payment['settlement'] ) {
4282 case 'acting_paygent_card':
4283 if ( $this->is_activate_card( 'module' ) ) {
4284 $payments_arr[] = 'paygent_card_form';
4285 }
4286 break;
4287 case 'acting_paygent_conv':
4288 if ( $this->is_activate_conv( 'module' ) ) {
4289 $payments_arr[] = 'paygent_conv_form';
4290 }
4291 break;
4292 case 'acting_paygent_atm':
4293 if ( $this->is_activate_atm() ) {
4294 $payments_arr[] = 'paygent_atm_form';
4295 }
4296 break;
4297 case 'acting_paygent_bank':
4298 if ( $this->is_activate_bank() ) {
4299 $payments_arr[] = 'paygent_bank_form';
4300 }
4301 break;
4302 }
4303 return $payments_arr;
4304 }
4305
4306 /**
4307 * �
4308 容確認ページ [注文する] ボタン
4309 * usces_filter_confirm_inform
4310 *
4311 * @param string $form Purchase post form.
4312 * @param array $payments Payment data.
4313 * @param string $acting_flg Payment type.
4314 * @param string $rand Welcart transaction key.
4315 * @param string $purchase_disabled Disable purchase button.
4316 * @return string
4317 */
4318 public function confirm_inform( $form, $payments, $acting_flg, $rand, $purchase_disabled ) {
4319 global $usces;
4320
4321 if ( ! in_array( $acting_flg, $this->pay_method ) ) {
4322 return $form;
4323 }
4324
4325 $entry = $usces->cart->get_entry();
4326 $cart = $usces->cart->get_cart();
4327 if ( ! $entry || ! $cart ) {
4328 return $form;
4329 }
4330 if ( ! $entry['order']['total_full_price'] ) {
4331 return $form;
4332 }
4333
4334 $acting_opts = $this->get_acting_settings();
4335
4336 switch ( $acting_flg ) {
4337 /* カード決済 */
4338 case 'acting_paygent_card':
4339 usces_save_order_acting_data( $rand );
4340 if ( 'module' == $acting_opts['card_activate'] ) {
4341 $token = ( isset( $_POST['token'] ) ) ? wp_unslash( $_POST['token'] ) : '';
4342 $masked_card_number = ( isset( $_POST['masked_card_number'] ) ) ? wp_unslash( $_POST['masked_card_number'] ) : '';
4343 $valid_until = ( isset( $_POST['valid_until'] ) ) ? wp_unslash( $_POST['valid_until'] ) : '';
4344 $fingerprint = ( isset( $_POST['fingerprint'] ) ) ? wp_unslash( $_POST['fingerprint'] ) : '';
4345 $hc = ( isset( $_POST['hc'] ) ) ? wp_unslash( $_POST['hc'] ) : '';
4346 $stock_card = ( isset( $_POST['stock_card'] ) ) ? wp_unslash( $_POST['stock_card'] ) : '';
4347 $stock_card_mode = ( isset( $_POST['stock_card_mode'] ) ) ? wp_unslash( $_POST['stock_card_mode'] ) : '';
4348 $split_count = ( isset( $_POST['split_count'] ) ) ? wp_unslash( $_POST['split_count'] ) : '';
4349
4350 $form = '<form id="purchase_form" action="' . esc_url( USCES_CART_URL ) . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4351 <input type="hidden" name="token" value="' . esc_attr( $token ) . '">
4352 <input type="hidden" name="masked_card_number" value="' . esc_attr( $masked_card_number ) . '">
4353 <input type="hidden" name="valid_until" value="' . esc_attr( $valid_until ) . '">
4354 <input type="hidden" name="fingerprint" value="' . esc_attr( $fingerprint ) . '">
4355 <input type="hidden" name="hc" value="' . esc_attr( $hc ) . '">
4356 <input type="hidden" name="trading_id" value="' . esc_attr( $rand ) . '">';
4357 if ( ! empty( $stock_card ) ) {
4358 $form .= '<input type="hidden" name="stock_card" value="' . esc_attr( $stock_card ) . '">';
4359 }
4360 if ( ! empty( $stock_card_mode ) ) {
4361 $form .= '<input type="hidden" name="stock_card_mode" value="' . esc_attr( $stock_card_mode ) . '">';
4362 }
4363 if ( ! empty( $split_count ) ) {
4364 $form .= '<input type="hidden" name="split_count" value="' . esc_attr( $split_count ) . '">';
4365 }
4366 $form .= '<div class="send">
4367 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4368 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4369 <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>
4370 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4371 } else {
4372 $form = '<form id="purchase_form" name="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13) {return false;}">
4373 <input type="hidden" name="trading_id" value="' . $rand . '">
4374 <input type="hidden" name="payment_type" value="' . PAYMENT_TYPE_CREDIT . '">
4375 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">
4376 <div class="send">
4377 <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 . ' />
4378 </div>
4379 </form>';
4380 $form .= '<form action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13){return false;}">
4381 <div class="send">
4382 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4383 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4384 </div>';
4385 }
4386 break;
4387
4388 /* コンビニ決済 */
4389 case 'acting_paygent_conv':
4390 usces_save_order_acting_data( $rand );
4391 if ( 'module' == $acting_opts['conv_activate'] ) {
4392 $cvs_company_id = ( isset( $_POST['cvs_company_id'] ) ) ? wp_unslash( $_POST['cvs_company_id'] ) : '';
4393 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4394 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4395 $customer_tel = ( isset( $_POST['customer_tel'] ) ) ? wp_unslash( $_POST['customer_tel'] ) : '';
4396
4397 $form = '<form id="purchase_form" action="' . esc_url( USCES_CART_URL ) . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4398 <input type="hidden" name="cvs_company_id" value="' . esc_attr( $cvs_company_id ) . '">
4399 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4400 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4401 <input type="hidden" name="customer_tel" value="' . esc_attr( $customer_tel ) . '">
4402 <input type="hidden" name="trading_id" value="' . esc_attr( $rand ) . '">';
4403 $form .= '<div class="send">
4404 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4405 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4406 <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>
4407 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4408 } else {
4409 $form = '<form id="purchase_form" name="purchase_form" action="' . USCES_CART_URL . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4410 <input type="hidden" name="trading_id" value="' . $rand . '">
4411 <input type="hidden" name="payment_type" value="' . PAYMENT_TYPE_CONVENI_NUM . '">
4412 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">
4413 <div class="send">
4414 <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 . ' />
4415 </div>
4416 </form>';
4417 $form .= '<form action="' . USCES_CART_URL . '" method="post" onKeyDown="if (event.keyCode == 13){return false;}">
4418 <div class="send">
4419 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4420 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4421 </div>';
4422 }
4423 break;
4424
4425 /* ATM決済 */
4426 case 'acting_paygent_atm':
4427 usces_save_order_acting_data( $rand );
4428 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4429 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4430 $customer_family_name_kana = ( isset( $_POST['customer_family_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_family_name_kana'] ) ) : '';
4431 $customer_name_kana = ( isset( $_POST['customer_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_name_kana'] ) ) : '';
4432
4433 $form = '<form id="purchase_form" action="' . esc_url( USCES_CART_URL ) . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4434 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4435 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4436 <input type="hidden" name="customer_family_name_kana" value="' . esc_attr( $customer_family_name_kana ) . '">
4437 <input type="hidden" name="customer_name_kana" value="' . esc_attr( $customer_name_kana ) . '">
4438 <input type="hidden" name="trading_id" value="' . esc_attr( $rand ) . '">';
4439 $form .= '<div class="send">
4440 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4441 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4442 <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>
4443 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4444 break;
4445
4446 /* 銀行ネット決済 */
4447 case 'acting_paygent_bank':
4448 usces_save_order_acting_data( $rand );
4449 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4450 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4451 $customer_family_name_kana = ( isset( $_POST['customer_family_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_family_name_kana'] ) ) : '';
4452 $customer_name_kana = ( isset( $_POST['customer_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_name_kana'] ) ) : '';
4453
4454 $form = '<form id="purchase_form" action="' . esc_url( USCES_CART_URL ) . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4455 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4456 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4457 <input type="hidden" name="customer_family_name_kana" value="' . esc_attr( $customer_family_name_kana ) . '">
4458 <input type="hidden" name="customer_name_kana" value="' . esc_attr( $customer_name_kana ) . '">
4459 <input type="hidden" name="trading_id" value="' . esc_attr( $rand ) . '">';
4460 $form .= '<div class="send">
4461 ' . apply_filters( 'usces_filter_confirm_before_backbutton', null, $payments, $acting_flg, $rand ) . '
4462 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', null ) . ' />
4463 <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>
4464 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">';
4465 break;
4466
4467 /* Paidy */
4468 case 'acting_paygent_paidy':
4469 usces_save_order_acting_data( $rand );
4470 $form = '<form name="purchase_form" action="' . esc_url( USCES_CART_URL ) . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4471 <input type="hidden" name="purchase" value="' . esc_attr( $acting_flg ) . '">
4472 <input type="hidden" name="trading_id" value="' . esc_attr( $rand ) . '">
4473 <input type="hidden" name="paidy_id">
4474 <input type="hidden" name="paidy_created_at">
4475 <input type="hidden" name="paidy_status">
4476 <input type="hidden" name="_nonce" value="' . wp_create_nonce( $acting_flg ) . '">
4477 <div class="send paidy-send"><input type="button" id="paidy-checkout-button" onclick="paidyPay()" value="Paidyでお支払い" /></div>
4478 </form>
4479 <form action="' . USCES_CART_URL . '" method="post" onKeyDown="if(event.keyCode == 13){return false;}">
4480 <div class="send">
4481 ' . apply_filters( 'usces_filter_confirm_before_backbutton', '', $payments, $acting_flg, $rand ) . '
4482 <input name="backDelivery" type="submit" id="back_button" class="back_to_delivery_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_confirm_prebutton', '' ) . ' />
4483 </div>';
4484 break;
4485 }
4486 return $form;
4487 }
4488
4489 /**
4490 * �
4491 容確認ページ ポイントフォーム
4492 * usces_action_confirm_page_point_inform
4493 */
4494 public function e_point_inform() {
4495 $form = $this->point_inform( '' );
4496 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4497 echo $form;
4498 }
4499
4500 /**
4501 * �
4502 容確認ページ ポイントフォーム
4503 * usces_filter_confirm_point_inform
4504 *
4505 * @param string $form Input point form.
4506 * @return string
4507 */
4508 public function point_inform( $form ) {
4509 global $usces;
4510
4511 $entry = $usces->cart->get_entry();
4512 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
4513 $acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
4514 switch ( $acting_flg ) {
4515 case 'acting_paygent_card':
4516 if ( 'module' == $this->get_service_type( 'card' ) ) {
4517 $token = ( isset( $_POST['token'] ) ) ? wp_unslash( $_POST['token'] ) : '';
4518 $masked_card_number = ( isset( $_POST['masked_card_number'] ) ) ? wp_unslash( $_POST['masked_card_number'] ) : '';
4519 $valid_until = ( isset( $_POST['valid_until'] ) ) ? wp_unslash( $_POST['valid_until'] ) : '';
4520 $fingerprint = ( isset( $_POST['fingerprint'] ) ) ? wp_unslash( $_POST['fingerprint'] ) : '';
4521 $hc = ( isset( $_POST['hc'] ) ) ? wp_unslash( $_POST['hc'] ) : '';
4522 $stock_card = ( isset( $_POST['stock_card'] ) ) ? wp_unslash( $_POST['stock_card'] ) : '';
4523 $stock_card_mode = ( isset( $_POST['stock_card_mode'] ) ) ? wp_unslash( $_POST['stock_card_mode'] ) : '';
4524 $split_count = ( isset( $_POST['split_count'] ) ) ? wp_unslash( $_POST['split_count'] ) : '';
4525
4526 $form .= '
4527 <input type="hidden" name="token" value="' . esc_attr( $token ) . '">
4528 <input type="hidden" name="masked_card_number" value="' . esc_attr( $masked_card_number ) . '">
4529 <input type="hidden" name="valid_until" value="' . esc_attr( $valid_until ) . '">
4530 <input type="hidden" name="fingerprint" value="' . esc_attr( $fingerprint ) . '">
4531 <input type="hidden" name="hc" value="' . esc_attr( $hc ) . '">';
4532 if ( ! empty( $stock_card ) ) {
4533 $form .= '<input type="hidden" name="stock_card" value="' . esc_attr( $stock_card ) . '">';
4534 }
4535 if ( ! empty( $stock_card_mode ) ) {
4536 $form .= '<input type="hidden" name="stock_card_mode" value="' . esc_attr( $stock_card_mode ) . '">';
4537 }
4538 if ( ! empty( $split_count ) ) {
4539 $form .= '<input type="hidden" name="split_count" value="' . esc_attr( $split_count ) . '">';
4540 }
4541 }
4542 break;
4543
4544 case 'acting_paygent_conv':
4545 if ( 'module' == $this->get_service_type( 'conv' ) ) {
4546 $cvs_company_id = ( isset( $_POST['cvs_company_id'] ) ) ? wp_unslash( $_POST['cvs_company_id'] ) : '';
4547 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4548 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4549 $customer_tel = ( isset( $_POST['customer_tel'] ) ) ? wp_unslash( $_POST['customer_tel'] ) : '';
4550
4551 $form .= '
4552 <input type="hidden" name="cvs_company_id" value="' . esc_attr( $cvs_company_id ) . '">
4553 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4554 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4555 <input type="hidden" name="customer_tel" value="' . esc_attr( $customer_tel ) . '">';
4556 }
4557 break;
4558
4559 case 'acting_paygent_atm':
4560 if ( 'module' == $this->get_service_type( 'atm' ) ) {
4561 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4562 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4563 $customer_family_name_kana = ( isset( $_POST['customer_family_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_family_name_kana'] ) ) : '';
4564 $customer_name_kana = ( isset( $_POST['customer_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_name_kana'] ) ) : '';
4565
4566 $form .= '
4567 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4568 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4569 <input type="hidden" name="customer_family_name_kana" value="' . esc_attr( $customer_family_name_kana ) . '">
4570 <input type="hidden" name="customer_name_kana" value="' . esc_attr( $customer_name_kana ) . '">';
4571 }
4572 break;
4573
4574 case 'acting_paygent_bank':
4575 if ( 'module' == $this->get_service_type( 'bank' ) ) {
4576 $customer_family_name = ( isset( $_POST['customer_family_name'] ) ) ? wp_unslash( $_POST['customer_family_name'] ) : '';
4577 $customer_name = ( isset( $_POST['customer_name'] ) ) ? wp_unslash( $_POST['customer_name'] ) : '';
4578 $customer_family_name_kana = ( isset( $_POST['customer_family_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_family_name_kana'] ) ) : '';
4579 $customer_name_kana = ( isset( $_POST['customer_name_kana'] ) ) ? String_Utitily::convert_katakana_zen2han( wp_unslash( $_POST['customer_name_kana'] ) ) : '';
4580
4581 $form .= '
4582 <input type="hidden" name="customer_family_name" value="' . esc_attr( $customer_family_name ) . '">
4583 <input type="hidden" name="customer_name" value="' . esc_attr( $customer_name ) . '">
4584 <input type="hidden" name="customer_family_name_kana" value="' . esc_attr( $customer_family_name_kana ) . '">
4585 <input type="hidden" name="customer_name_kana" value="' . esc_attr( $customer_name_kana ) . '">';
4586 }
4587 break;
4588 }
4589 return $form;
4590 }
4591
4592 /**
4593 * セッション復帰処理
4594 * usces_pre_purchase
4595 */
4596 public function pre_purchase() {
4597 $acting_opts = $this->get_acting_settings();
4598 if ( 'on' == $acting_opts['threedsecure_ryaku'] && isset( $_POST['from3ds'] ) && isset( $_POST['trading_id'] ) ) {
4599 usces_restore_order_acting_data( wp_unslash( $_POST['trading_id'] ) );
4600 }
4601 }
4602
4603 /**
4604 * 決済処理
4605 * usces_action_acting_processing
4606 *
4607 * @param string $acting_flg Payment type.
4608 * @param array $post_query Post data.
4609 */
4610 public function acting_processing( $acting_flg, $post_query ) {
4611 global $usces;
4612
4613 if ( ! in_array( $acting_flg, $this->pay_method ) ) {
4614 return;
4615 }
4616
4617 $entry = $usces->cart->get_entry();
4618 $cart = $usces->cart->get_cart();
4619 if ( ! $entry || ! $cart ) {
4620 wp_redirect( USCES_CART_URL );
4621 exit();
4622 }
4623 if ( isset( $_REQUEST['_nonce'] ) && ! wp_verify_nonce( $_REQUEST['_nonce'], $acting_flg ) ) {
4624 wp_redirect( USCES_CART_URL );
4625 exit();
4626 }
4627
4628 $acting_opts = $this->get_acting_settings();
4629 parse_str( $post_query, $post_data );
4630
4631 $acting = substr( $acting_flg, 7 );
4632 $member = $usces->get_member();
4633 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
4634 $service_type = '';
4635 $payment_type = '';
4636
4637 switch ( $acting_flg ) {
4638 case 'acting_paygent_card':
4639 $service_type = $this->get_service_type( 'card' );
4640 $payment_type = PAYMENT_TYPE_CREDIT;
4641 break;
4642 case 'acting_paygent_conv':
4643 $service_type = $this->get_service_type( 'conv' );
4644 $payment_type = PAYMENT_TYPE_CONVENI_NUM;
4645 break;
4646 case 'acting_paygent_atm':
4647 $service_type = $this->get_service_type( 'atm' );
4648 $payment_type = PAYMENT_TYPE_ATM;
4649 break;
4650 case 'acting_paygent_bank':
4651 $service_type = $this->get_service_type( 'bank' );
4652 $payment_type = PAYMENT_TYPE_BANK;
4653 break;
4654 case 'acting_paygent_paidy':
4655 $service_type = $this->get_service_type( 'paidy' );
4656 $payment_type = PAYMENT_TYPE_PAIDY;
4657 break;
4658 }
4659
4660 if ( 'link' == $service_type ) {
4661 $hash_key = $acting_opts['hc'];
4662 $fix_params = '';
4663 $id = $entry['order']['total_full_price'];
4664 $inform_url = USCES_CART_URL;
4665 $seq_merchant_id = $acting_opts['seq_merchant_id'];
4666 $payment_term_day = $acting_opts['payment_term_day'];
4667 $payment_term_min = $acting_opts['payment_term_min'];
4668 $payment_class = $acting_opts['payment_class'];
4669 $use_card_conf_number = ( 'on' == $acting_opts['use_card_conf_number'] ) ? '1' : '0';
4670 if ( 'on' == $acting_opts['stock_card_mode'] && ! empty( $member['ID'] ) ) {
4671 if ( usces_have_regular_order() || usces_have_continue_charge() ) {
4672 $stock_card_mode = '2';
4673 } else {
4674 $stock_card_mode = '1';
4675 }
4676 $customer_id = $member['ID'];
4677 } else {
4678 $stock_card_mode = '';
4679 $customer_id = '';
4680 }
4681 $threedsecure_ryaku = ( 'on' == $acting_opts['threedsecure_ryaku'] ) ? '0' : '1';
4682
4683 $merchant_name = mb_convert_kana( $usces->options['company_name'], 'RNASKV', 'UTF-8' );
4684 $banner_url = '';
4685 $return_url = USCES_CART_URL . $usces->delim . 'acting=' . $acting . '&acting_return=1&trading_id=' . $trading_id;
4686 $stop_return_url = USCES_CART_URL . $usces->delim . 'acting=' . $acting . '&confirm=1';
4687 $customer_family_name = trim( $entry['customer']['name1'] );
4688 $customer_name = trim( $entry['customer']['name2'] );
4689 $customer_family_name_kana = trim( mb_convert_kana( $entry['customer']['name3'], 'rnaskh', 'UTF-8' ) );
4690 $customer_name_kana = trim( mb_convert_kana( $entry['customer']['name4'], 'rnaskh', 'UTF-8' ) );
4691 $customer_tel = str_replace( '-', '', mb_convert_kana( $entry['customer']['tel'], 'a', 'UTF-8' ) );
4692
4693 /* Create hash hex string */
4694 $org_str =
4695 $trading_id .
4696 $payment_type .
4697 $fix_params .
4698 $id .
4699 $inform_url .
4700 $seq_merchant_id .
4701 $payment_term_day .
4702 $payment_term_min .
4703 $payment_class .
4704 $use_card_conf_number .
4705 $customer_id .
4706 $threedsecure_ryaku .
4707 $hash_key;
4708 $hash_str = hash( 'sha256', $org_str );
4709 $appendix = ( 'ja' == usces_get_local_language() ) ? '0' : '1';
4710
4711 $url = $acting_opts['send_url'];
4712 $send_data = array(
4713 'trading_id' => $trading_id,
4714 'payment_type' => $payment_type,
4715 'fix_params' => $fix_params,
4716 'id' => $id,
4717 'inform_url' => $inform_url,
4718 'seq_merchant_id' => $seq_merchant_id,
4719 'merchant_name' => $merchant_name,
4720 'payment_term_day' => $payment_term_day,
4721 'payment_term_min' => $payment_term_min,
4722 'banner_url' => $banner_url,
4723 'return_url' => $return_url,
4724 'stop_return_url' => $stop_return_url,
4725 'customer_family_name' => $customer_family_name,
4726 'customer_name' => $customer_name,
4727 'customer_family_name_kana' => $customer_family_name_kana,
4728 'customer_name_kana' => $customer_name_kana,
4729 'customer_tel' => $customer_tel,
4730 'payment_class' => $payment_class,
4731 'use_card_conf_number' => $use_card_conf_number,
4732 'stock_card_mode' => $stock_card_mode,
4733 'customer_id' => $customer_id,
4734 'threedsecure_ryaku' => $threedsecure_ryaku,
4735 'appendix' => $appendix,
4736 'hc' => $hash_str,
4737
4738 /* btob mode ON */
4739 'isbtob' => '1',
4740
4741 /* お支払い完了画面非表示区分 */
4742 'finish_disable' => '1',
4743 );
4744
4745 $interface = parse_url( $url );
4746 $vars = http_build_query( $send_data );
4747
4748 $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
4749 $header .= 'Host: ' . $interface['host'] . "\r\n";
4750 $header .= "User-Agent: PHP Script\r\n";
4751 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
4752 $header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
4753 $header .= "Connection: close\r\n\r\n";
4754 $header .= $vars;
4755 $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
4756 if ( ! $fp ) {
4757 // usces_log( $acting . ' : TLS(v1.2) Error', 'acting_transaction.log' );
4758 $log = array(
4759 'acting' => $acting,
4760 'key' => $trading_id,
4761 'result' => 'SSL/TLS ERROR (' . $errno . ')',
4762 'data' => array( $errstr ),
4763 );
4764 usces_save_order_acting_error( $log );
4765 wp_redirect(
4766 add_query_arg(
4767 array(
4768 'acting' => $acting,
4769 'acting_return' => 0,
4770 ),
4771 USCES_CART_URL
4772 )
4773 );
4774 exit();
4775 }
4776 if ( $fp ) {
4777 $data = array();
4778 $response = array();
4779 fwrite( $fp, $header );
4780 while ( ! feof( $fp ) ) {
4781 $line = fgets( $fp, 1024 );
4782 if ( false !== strpos( $line, 'result' ) ) {
4783 $item = explode( '=', $line, 2 );
4784 $data['result'] = trim( $item[1] );
4785 }
4786 if ( false !== strpos( $line, 'response_code' ) ) {
4787 $item = explode( '=', $line, 2 );
4788 $data['response_code'] = trim( $item[1] );
4789 }
4790 if ( false !== strpos( $line, 'response_detail' ) ) {
4791 $item = explode( '=', $line, 2 );
4792 $data['response_detail'] = trim( $item[1] );
4793 }
4794 if ( false !== strpos( $line, 'url' ) ) {
4795 $item = explode( '=', $line, 2 );
4796 $data['url'] = trim( $item[1] );
4797 }
4798 if ( false !== strpos( $line, 'trading_id' ) ) {
4799 $item = explode( '=', $line, 2 );
4800 $data['trading_id'] = trim( $item[1] );
4801 }
4802 if ( false !== strpos( $line, 'payment_type' ) ) {
4803 $item = explode( '=', $line, 2 );
4804 $data['payment_type'] = trim( $item[1] );
4805 }
4806 if ( false !== strpos( $line, 'limit_date' ) ) {
4807 $item = explode( '=', $line, 2 );
4808 $data['limit_date'] = trim( $item[1] );
4809 }
4810 if ( false !== strpos( $line, 'trade_generation_date' ) ) {
4811 $item = explode( '=', $line, 2 );
4812 $data['trade_generation_date'] = trim( $item[1] );
4813 }
4814 $response[] = $line;
4815 }
4816 fclose( $fp );
4817
4818 if ( 0 == $data['result'] && ! empty( $data['url'] ) ) {
4819 wp_redirect( $data['url'] );
4820 exit();
4821 } else {
4822 $log = array(
4823 'acting' => $acting,
4824 'key' => $trading_id,
4825 'result' => 'RESPONSE ERROR',
4826 'data' => $response,
4827 );
4828 usces_save_order_acting_error( $log );
4829 wp_redirect(
4830 add_query_arg(
4831 array(
4832 'acting' => $acting,
4833 'acting_return' => 0,
4834 ),
4835 USCES_CART_URL
4836 )
4837 );
4838 }
4839 exit();
4840 }
4841 } elseif ( 'module' == $service_type ) {
4842 $pm = Paygent_Module::get_instance();
4843 switch ( $payment_type ) {
4844 /* カード決済 */
4845 case PAYMENT_TYPE_CREDIT:
4846 $telegram_kind = PAYGENT_CREDIT;
4847 $token = $post_data['token'];
4848 $stock_card_mode = 0;
4849 $customer_card_id = '';
4850
4851 if ( 'on' == $acting_opts['threedsecure_ryaku'] ) {
4852 /* 3Dセキュア認証の結果を受ける */
4853 if ( isset( $post_data['from3ds'] ) ) {
4854 if ( 'on' == $acting_opts['attempt'] && ! empty( $post_data['attempt_kbn'] ) ) {
4855 $log = array(
4856 'acting' => 'paygent_card(3ds_attempt)',
4857 'key' => $trading_id,
4858 'result' => '3DS ATTEMPT',
4859 'data' => $post_data,
4860 );
4861 usces_save_order_acting_error( $log );
4862 wp_redirect(
4863 add_query_arg(
4864 array(
4865 'acting' => 'paygent_card',
4866 'acting_return' => 0,
4867 'retry' => 1,
4868 ),
4869 USCES_CART_URL
4870 )
4871 );
4872 exit();
4873 }
4874 } else {
4875 /* 3Dセキュア認証画面へリダイレクト */
4876 $this->certification_3ds( $post_data, $member['ID'] );
4877 }
4878 }
4879
4880 if ( 'on' == $acting_opts['stock_card_mode'] && ! empty( $member['ID'] ) ) {
4881 if ( isset( $post_data['stock_card'] ) ) {
4882 if ( 'stock' == $post_data['stock_card'] ) {
4883 $stock_card_mode = 1;
4884 $customer_card_id = $usces->get_member_meta_value( 'paygent_customer_card_id', $member['ID'] );
4885 } else {
4886 if ( isset( $post_data['stock_card_mode'] ) && 'change' == $post_data['stock_card_mode'] ) {
4887 $stock_card_mode = 1;
4888
4889 /* カード変更 */
4890 $customer = $this->customer_card_upd( $member['ID'], $token );
4891 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
4892 $log = array(
4893 'acting' => $acting,
4894 'key' => $trading_id,
4895 'result' => $customer['response_code'],
4896 'data' => $customer,
4897 );
4898 usces_save_order_acting_error( $log );
4899 wp_redirect(
4900 add_query_arg(
4901 array(
4902 'acting' => $acting,
4903 'acting_return' => 0,
4904 'retry' => 1,
4905 ),
4906 USCES_CART_URL
4907 )
4908 );
4909 exit();
4910 }
4911 if ( isset( $customer['customer_card_id'] ) ) {
4912 $customer_card_id = $customer['customer_card_id'];
4913 $token = '';
4914 }
4915 }
4916 }
4917 } else {
4918 if ( isset( $post_data['stock_card_mode'] ) && 'save' == $post_data['stock_card_mode'] ) {
4919 $stock_card_mode = 1;
4920
4921 /* カード登録 */
4922 $customer = $this->customer_card_add( $member['ID'], $token );
4923 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
4924 $log = array(
4925 'acting' => $acting,
4926 'key' => $trading_id,
4927 'result' => $customer['response_code'],
4928 'data' => $customer,
4929 );
4930 usces_save_order_acting_error( $log );
4931 wp_redirect(
4932 add_query_arg(
4933 array(
4934 'acting' => $acting,
4935 'acting_return' => 0,
4936 'retry' => 1,
4937 ),
4938 USCES_CART_URL
4939 )
4940 );
4941 exit();
4942 }
4943 if ( isset( $customer['customer_card_id'] ) ) {
4944 $customer_card_id = $customer['customer_card_id'];
4945 $token = '';
4946 }
4947 }
4948 }
4949 }
4950
4951 $pm->init();
4952 $pm->req_put( 'trading_id', $trading_id );
4953 $pm->req_put( 'payment_amount', $entry['order']['total_full_price'] );
4954 if ( 0 === (int) $acting_opts['payment_class'] || '01' == $post_data['split_count'] ) {
4955 $pm->req_put( 'payment_class', '10' );
4956 } elseif ( '23' == $post_data['split_count'] || '80' == $post_data['split_count'] ) {
4957 $pm->req_put( 'payment_class', $post_data['split_count'] );
4958 } else {
4959 $pm->req_put( 'payment_class', '61' );
4960 $pm->req_put( 'split_count', $post_data['split_count'] );
4961 }
4962 if ( 'on' == $acting_opts['threedsecure_ryaku'] && isset( $post_data['3ds_auth_id'] ) ) {
4963 $pm->req_put( '3dsecure_use_type', '2' );
4964 $pm->req_put( 'http_accept', $_SERVER['HTTP_ACCEPT'] );
4965 $pm->req_put( 'http_user_agent', $_SERVER['HTTP_USER_AGENT'] );
4966 $pm->req_put( 'term_url', USCES_CART_URL );
4967 $pm->req_put( '3ds_auth_id', $post_data['3ds_auth_id'] );
4968 } else {
4969 $pm->req_put( '3dsecure_ryaku', '1' );
4970 }
4971 if ( 1 === (int) $stock_card_mode && ! empty( $customer_card_id ) ) {
4972 $pm->req_put( 'stock_card_mode', '1' );
4973 $pm->req_put( 'customer_id', $member['ID'] );
4974 $pm->req_put( 'customer_card_id', $customer_card_id );
4975 if ( ! empty( $token ) && 'on' == $acting_opts['use_card_conf_number'] ) {
4976 $pm->req_put( 'card_token', $token );
4977 $pm->req_put( 'security_code_token', '1' );
4978 $pm->req_put( 'security_code_use', '1' );
4979 }
4980 } else {
4981 $pm->req_put( 'card_token', $token );
4982 if ( 'on' == $acting_opts['use_card_conf_number'] ) {
4983 $pm->req_put( 'security_code_use', '1' );
4984 }
4985 }
4986 $pm->req_put( 'sales_mode', $acting_opts['sales_mode'] );
4987 break;
4988
4989 /* コンビニ決済 */
4990 case PAYMENT_TYPE_CONVENI_NUM:
4991 $telegram_kind = PAYGENT_CONVENI_NUM;
4992 $customer_family_name = trim( $post_data['customer_family_name'] );
4993 $customer_name = trim( $post_data['customer_name'] );
4994 $customer_tel = str_replace( '-', '', mb_convert_kana( $post_data['customer_tel'], 'a', 'UTF-8' ) );
4995 $pm->init();
4996 $pm->req_put( 'trading_id', $trading_id );
4997 $pm->req_put( 'payment_amount', $entry['order']['total_full_price'] );
4998 $pm->req_put( 'customer_family_name', $customer_family_name );
4999 $pm->req_put( 'customer_name', $customer_name );
5000 $pm->req_put( 'customer_tel', $customer_tel );
5001 $pm->req_put( 'payment_limit_date', $acting_opts['payment_term_day'] );
5002 $pm->req_put( 'cvs_company_id', $post_data['cvs_company_id'] );
5003 $pm->req_put( 'sales_type', $acting_opts['sales_type'] );
5004 break;
5005
5006 /* ATM決済 */
5007 case PAYMENT_TYPE_ATM:
5008 $telegram_kind = PAYGENT_ATM;
5009 $customer_family_name = trim( $post_data['customer_family_name'] );
5010 $customer_name = trim( $post_data['customer_name'] );
5011 $customer_family_name_kana = trim( $post_data['customer_family_name_kana'] );
5012 $customer_name_kana = trim( $post_data['customer_name_kana'] );
5013 $payment_detail = apply_filters( 'usces_filter_paygent_atm_payment_detail', 'お支払い一式' );
5014 $payment_detail_kana = apply_filters( 'usces_filter_paygent_atm_payment_detail_kana', 'オシハライイツシキ' );
5015 $pm->init();
5016 $pm->req_put( 'trading_id', $trading_id );
5017 $pm->req_put( 'payment_amount', $entry['order']['total_full_price'] );
5018 $pm->req_put( 'customer_family_name', $customer_family_name );
5019 $pm->req_put( 'customer_name', $customer_name );
5020 $pm->req_put( 'customer_family_name_kana', $customer_family_name_kana );
5021 $pm->req_put( 'customer_name_kana', $customer_name_kana );
5022 $pm->req_put( 'payment_detail', $payment_detail );
5023 $pm->req_put( 'payment_detail_kana', $payment_detail_kana );
5024 if ( ! WCUtils::is_blank( $acting_opts['payment_limit_date'] ) ) {
5025 $pm->req_put( 'payment_limit_date', (int) $acting_opts['payment_limit_date'] );
5026 }
5027 break;
5028
5029 /* 銀行ネット決済 */
5030 case PAYMENT_TYPE_BANK:
5031 $telegram_kind = PAYGENT_BANK_ASP;
5032 $customer_family_name = trim( $post_data['customer_family_name'] );
5033 $customer_name = trim( $post_data['customer_name'] );
5034 $customer_family_name_kana = trim( $post_data['customer_family_name_kana'] );
5035 $customer_name_kana = trim( $post_data['customer_name_kana'] );
5036 $claim_kanji = apply_filters( 'usces_filter_paygent_bank_claim_kanji', 'お支払い一式' );
5037 $claim_kana = apply_filters( 'usces_filter_paygent_bank_claim_kana', 'オシハライイツシキ' );
5038 $pm->init();
5039 $pm->req_put( 'trading_id', $trading_id );
5040 $pm->req_put( 'amount', $entry['order']['total_full_price'] );
5041 $pm->req_put( 'customer_family_name', $customer_family_name );
5042 $pm->req_put( 'customer_name', $customer_name );
5043 $pm->req_put( 'customer_family_name_kana', $customer_family_name_kana );
5044 $pm->req_put( 'customer_name_kana', $customer_name_kana );
5045 $pm->req_put( 'claim_kanji', $claim_kanji );
5046 $pm->req_put( 'claim_kana', $claim_kana );
5047 $return_arg = array(
5048 'acting' => $acting,
5049 'acting_return' => 1,
5050 );
5051 $pm->req_put( 'return_url', add_query_arg( $return_arg, USCES_CART_URL ) );
5052 // if ( isset( $acting_opts['asp_payment_term'] ) && '' !== $acting_opts['asp_payment_term'] ) {
5053 $pm->req_put( 'asp_payment_term', $acting_opts['asp_payment_term'] );
5054 // }
5055 $stop_return_arg = array(
5056 'acting' => $acting,
5057 'confirm' => 1,
5058 );
5059 $pm->req_put( 'stop_return_url', add_query_arg( $stop_return_arg, USCES_CART_URL ) );
5060 break;
5061
5062 /* Paidy */
5063 case PAYMENT_TYPE_PAIDY:
5064 if ( isset( $post_data['paidy_id'] ) && isset( $post_data['paidy_created_at'] ) && isset( $post_data['paidy_status'] ) && 'authorized' == $post_data['paidy_status'] ) {
5065 $telegram_kind = PAYGENT_PAIDY_REF;
5066 $pm->init();
5067 $pm->req_put( 'paidy_payment_id', $post_data['paidy_id'] );
5068 // $api_retrieve_url = 'https://api.paidy.com/payments/' . $post_data['paidy_id'];
5069 // $params = array(
5070 // 'method' => 'GET',
5071 // 'headers' => array(
5072 // 'Content-Type' => 'application/json;charset=utf-8',
5073 // 'Authorization' => 'Bearer ' . $acting_opts['paidy_secret_key'],
5074 // 'Paidy-Version' => '2018-04-10',
5075 // ),
5076 // );
5077 // $response = wp_remote_get( $api_retrieve_url, $params );
5078 // $response_data = json_decode( wp_remote_retrieve_body( $response ), true );
5079 } else {
5080 $log = array(
5081 'acting' => $acting,
5082 'key' => $trading_id,
5083 'result' => 'PAIDY AUTHORIZE ERROR',
5084 'data' => $post_data,
5085 );
5086 usces_save_order_acting_error( $log );
5087 wp_redirect(
5088 add_query_arg(
5089 array(
5090 'acting' => $acting,
5091 'acting_return' => 0,
5092 'result' => 0,
5093 ),
5094 USCES_CART_URL
5095 )
5096 );
5097 exit();
5098 }
5099 break;
5100 }
5101
5102 if ( ! empty( $payment_type ) && ! empty( $telegram_kind ) ) {
5103 $result_post = $pm->post( $telegram_kind );
5104 $result_status = $pm->get_result_status();
5105 if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
5106 $response_data = array(
5107 'result' => $result_post,
5108 'result_status' => $result_status,
5109 'response_code' => $pm->get_response_code(),
5110 'response_detail' => $pm->get_response_detail(),
5111 'result_message' => $pm->get_result_message(),
5112 );
5113 $response_code = ( true !== $result_post ) ? $result_post : $pm->get_response_code();
5114 $log = array(
5115 'acting' => $acting,
5116 'key' => $trading_id,
5117 'result' => $response_code,
5118 'data' => $response_data,
5119 );
5120 usces_save_order_acting_error( $log );
5121 wp_redirect(
5122 add_query_arg(
5123 array(
5124 'acting' => $acting,
5125 'acting_return' => 0,
5126 'retry' => 1,
5127 ),
5128 USCES_CART_URL
5129 )
5130 );
5131 exit();
5132 }
5133 $response_data = $pm->get_response_data();
5134 if ( ! isset( $response_data['payment_type'] ) ) {
5135 $response_data['payment_type'] = $payment_type;
5136 }
5137 if ( ! isset( $response_data['trading_id'] ) ) {
5138 $response_data['trading_id'] = $trading_id;
5139 }
5140 $res = $usces->order_processing( $response_data );
5141 if ( 'ordercompletion' != $res ) {
5142 $log = array(
5143 'acting' => $acting,
5144 'key' => $trading_id,
5145 'result' => 'ORDER DATA REGISTERED ERROR',
5146 'data' => $response_data,
5147 );
5148 usces_save_order_acting_error( $log );
5149 wp_redirect(
5150 add_query_arg(
5151 array(
5152 'acting' => $acting,
5153 'acting_return' => 0,
5154 'result' => 0,
5155 ),
5156 USCES_CART_URL
5157 )
5158 );
5159 exit();
5160 }
5161 if ( PAYMENT_TYPE_BANK == $payment_type && isset( $response_data['asp_url'] ) ) {
5162 $usces->cart->clear_cart(); /* Order OK. */
5163 wp_redirect( $response_data['asp_url'] );
5164 } else {
5165 wp_redirect(
5166 add_query_arg(
5167 array(
5168 'acting' => $acting,
5169 'acting_return' => 1,
5170 'result' => 1,
5171 ),
5172 USCES_CART_URL
5173 )
5174 );
5175 }
5176 exit();
5177 }
5178 }
5179 }
5180
5181 /**
5182 * 決済完了ページ制御
5183 * usces_filter_check_acting_return_results
5184 *
5185 * @param array $results Result data.
5186 * @return array
5187 */
5188 public function acting_return( $results ) {
5189 $acting = ( isset( $_GET['acting'] ) ) ? wp_unslash( $_GET['acting'] ) : '';
5190 switch ( $acting ) {
5191 case 'paygent_card':
5192 case 'paygent_conv':
5193 case 'paygent_atm':
5194 case 'paygent_bank':
5195 case 'paygent_paidy':
5196 $results = wp_unslash( $_GET );
5197 $results[0] = wp_unslash( $_GET['acting_return'] );
5198 $results['reg_order'] = false;
5199 break;
5200 }
5201 return $results;
5202 }
5203
5204 /**
5205 * 重複オーダー禁止処理
5206 * usces_filter_check_acting_return_duplicate
5207 *
5208 * @param string $trans_id Transaction ID.
5209 * @param array $results Result data.
5210 * @return string
5211 */
5212 public function check_acting_return_duplicate( $trans_id, $results ) {
5213 $acting = ( isset( $_GET['acting'] ) ) ? wp_unslash( $_GET['acting'] ) : '';
5214 switch ( $acting ) {
5215 case 'paygent_card':
5216 case 'paygent_conv':
5217 case 'paygent_atm':
5218 case 'paygent_bank':
5219 case 'paygent_paidy':
5220 break;
5221 }
5222 return $trans_id;
5223 }
5224
5225 /**
5226 * 受注データ登録
5227 * Called by usces_reg_orderdata() and usces_new_orderdata().
5228 * usces_action_reg_orderdata
5229 *
5230 * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $results ).
5231 */
5232 public function register_orderdata( $args ) {
5233 global $usces;
5234 extract( $args );
5235
5236 $acting_flg = ( isset( $payments['settlement'] ) ) ? $payments['settlement'] : '';
5237 if ( ! in_array( $acting_flg, $this->pay_method ) ) {
5238 return;
5239 }
5240 if ( ! $entry['order']['total_full_price'] ) {
5241 return;
5242 }
5243
5244 if ( isset( $_REQUEST['payment_type'] ) ) {
5245 $payment_type = wp_unslash( $_REQUEST['payment_type'] );
5246 } elseif ( isset( $results['payment_type'] ) ) {
5247 $payment_type = $results['payment_type'];
5248 } else {
5249 $payment_type = '';
5250 }
5251 if ( ! empty( $payment_type ) ) {
5252 if ( isset( $results['acting_return'] ) ) {
5253 unset( $results['acting_return'] );
5254 unset( $results['page_id'] );
5255 unset( $results['0'] );
5256 unset( $results['reg_order'] );
5257 }
5258 $trading_id = ( isset( $results['trading_id'] ) ) ? $results['trading_id'] : '';
5259 $usces->set_order_meta_value( $acting_flg, usces_serialize( $results ), $order_id );
5260 $usces->set_order_meta_value( 'trading_id', $trading_id, $order_id );
5261 $usces->set_order_meta_value( 'wc_trans_id', $trading_id, $order_id );
5262
5263 switch ( $payment_type ) {
5264 case PAYMENT_TYPE_ATM:
5265 $payment_id = ( isset( $results['payment_id'] ) ) ? $results['payment_id'] : '';
5266 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
5267 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
5268 $this->save_acting_log( $settlement_ref, 'paygent_atm', 'reference_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
5269 } else {
5270 $this->save_acting_log( $settlement_ref, 'paygent_atm', $settlement_ref['payment_status'], RESULT_STATUS_NORMAL, $order_id, $trading_id );
5271 }
5272 break;
5273 case PAYMENT_TYPE_BANK:
5274 $this->save_acting_log( $results, 'paygent_bank', 'bank_applying', RESULT_STATUS_NORMAL, $order_id, $trading_id );
5275 break;
5276 }
5277 }
5278 }
5279
5280 /**
5281 * 決済エラーメッセージ
5282 * usces_filter_get_error_settlement
5283 *
5284 * @param string $form Payment error message.
5285 * @return string
5286 */
5287 public function error_page_message( $form ) {
5288 $acting = ( isset( $_GET['acting'] ) ) ? wp_unslash( $_GET['acting'] ) : '';
5289 if ( 'paygent_card' == $acting ) {
5290 if ( isset( $_GET['retry'] ) ) {
5291 $retry_url = add_query_arg(
5292 array(
5293 'backDelivery' => 'paygent_card',
5294 're-enter' => 1,
5295 ),
5296 USCES_CUSTOMER_URL
5297 );
5298 $form .= '<div class="support_box">クレジットカード�
5299 報に誤りがあります。<br />カード番号を再�
5300 �力する場合は、こちらをクリックしてください。<br /><br />';
5301 $form .= '<p class="return_settlement"><a href="' . $retry_url . '">カード番号の再�
5302 �力</a></p>';
5303 $form .= '</div>';
5304 }
5305 }
5306 return $form;
5307 }
5308
5309 /**
5310 * サンキューメール
5311 * usces_filter_send_order_mail_payment
5312 *
5313 * @param string $msg_payment Payment method message.
5314 * @param int $order_id Order number.
5315 * @param array $payment Payment data.
5316 * @param array $cart Cart data.
5317 * @param array $entry Entry data.
5318 * @param array $data Order data.
5319 * @return string
5320 */
5321 public function order_mail_payment( $msg_payment, $order_id, $payment, $cart, $entry, $data ) {
5322 global $usces;
5323
5324 switch ( $payment['settlement'] ) {
5325 case 'acting_paygent_card':
5326 break;
5327 case 'acting_paygent_conv':
5328 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_paygent_conv', $order_id ) );
5329 $usable_cvs_company_id = ( isset( $acting_data['usable_cvs_company_id'] ) ) ? $acting_data['usable_cvs_company_id'] : '';
5330 $receipt_number = ( isset( $acting_data['receipt_number'] ) ) ? $acting_data['receipt_number'] : '';
5331 $lb = ( usces_is_html_mail() ) ? '<br>' : "\r\n";
5332 if ( ! empty( $receipt_number ) ) {
5333 if ( false !== strpos( $usable_cvs_company_id, CODE_SEICOMART ) ) {
5334 $msg_payment .= $this->cvs_company_a[ CODE_SEICOMART ] . 'でのお支払い' . $lb;
5335 $msg_payment .= '受付番号:' . $receipt_number . $lb;
5336 }
5337 if ( false !== strpos( $usable_cvs_company_id, CODE_SEVENELEVEN ) ) {
5338 $msg_payment .= $this->cvs_company_a[ CODE_SEVENELEVEN ] . 'でのお支払い' . $lb;
5339 $msg_payment .= '払込票番号:' . $receipt_number . $lb;
5340 }
5341 if ( false !== strpos( $usable_cvs_company_id, CODE_LOWSON ) ) {
5342 $msg_payment .= $this->cvs_company_a[ CODE_LOWSON ] . 'でのお支払い' . $lb;
5343 $msg_payment .= 'お客様番号:' . $receipt_number . $lb;
5344 $msg_payment .= '確認番号:' . CONVENI_CONFIRMATION_NUMBER . $lb;
5345 }
5346 if ( false !== strpos( $usable_cvs_company_id, CODE_MINISTOP ) ) {
5347 $msg_payment .= $this->cvs_company_a[ CODE_MINISTOP ] . 'でのお支払い' . $lb;
5348 $msg_payment .= 'お客様番号:' . $receipt_number . $lb;
5349 $msg_payment .= '確認番号:' . CONVENI_CONFIRMATION_NUMBER . $lb;
5350 }
5351 if ( false !== strpos( $usable_cvs_company_id, CODE_FAMILYMART ) ) {
5352 $msg_payment .= $this->cvs_company_a[ CODE_FAMILYMART ] . 'でのお支払い' . $lb;
5353 $msg_payment .= '収納番号:' . $receipt_number . $lb;
5354 }
5355 if ( false !== strpos( $usable_cvs_company_id, CODE_YAMAZAKI ) ) {
5356 $msg_payment .= $this->cvs_company_a[ CODE_YAMAZAKI ] . 'でのお支払い' . $lb;
5357 $msg_payment .= '決済番号:' . $receipt_number . $lb;
5358 }
5359 }
5360 if ( ! empty( $acting_data['receipt_print_url'] ) ) {
5361 $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'];
5362 if ( false !== strpos( $usable_cvs_company_id, CODE_SEICOMART ) || false !== strpos( $usable_cvs_company_id, CODE_SEVENELEVEN ) ) {
5363 $msg_payment .= '払込票URL:' . $receipt_print_url . $lb;
5364 } else {
5365 $msg_payment .= '支払参�
5366 �URL:' . $receipt_print_url . $lb;
5367 }
5368 }
5369 if ( ! empty( $acting_data['payment_limit_date'] ) ) {
5370 $msg_payment .= 'お支払い期限日:' . date( __( 'Y/m/d' ), strtotime( $acting_data['payment_limit_date'] ) ) . $lb;
5371 }
5372 break;
5373 case 'acting_paygent_atm':
5374 $acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_paygent_atm', $order_id ) );
5375 $lb = ( usces_is_html_mail() ) ? '<br>' : "\r\n";
5376 if ( isset( $acting_data['pay_center_number'] ) ) {
5377 $msg_payment .= '収納機関番号:' . $acting_data['pay_center_number'] . $lb;
5378 }
5379 if ( isset( $acting_data['customer_number'] ) ) {
5380 $msg_payment .= 'お客様番号:' . $acting_data['customer_number'] . $lb;
5381 }
5382 if ( isset( $acting_data['conf_number'] ) ) {
5383 $msg_payment .= '確認番号:' . $acting_data['conf_number'] . $lb;
5384 }
5385 if ( ! empty( $acting_data['payment_limit_date'] ) ) {
5386 $msg_payment .= 'お支払い期限日:' . date( __( 'Y/m/d' ), strtotime( $acting_data['payment_limit_date'] ) ) . $lb;
5387 }
5388 break;
5389 case 'acting_paygent_bank':
5390 break;
5391 case 'acting_paygent_paidy':
5392 break;
5393 }
5394 return $msg_payment;
5395 }
5396
5397 /**
5398 * Redirect from 3DS authentication to purchase.
5399 * init
5400 */
5401 public function done_3ds_auth() {
5402 if ( ! $this->is_activate_card( 'module' ) ) {
5403 return;
5404 }
5405 if ( ! isset( $_GET['result'] ) || ! isset( $_GET['3ds_auth_id'] ) || ! isset( $_GET['done_3ds_auth'] ) ) {
5406 return;
5407 }
5408
5409 $acting_opts = $this->get_acting_settings();
5410 $trading_id = trim( $_GET['done_3ds_auth'] );
5411 $original_string = trim( $_GET['result'] ) . trim( $_GET['3ds_auth_id'] );
5412 if ( isset( $_GET['attempt_kbn'] ) ) {
5413 $original_string .= trim( $_GET['attempt_kbn'] );
5414 }
5415 $original_string .= trim( $acting_opts['threedsecure_hc'] );
5416 $hased_string = hash( 'sha256', $original_string );
5417
5418 /* Hash check */
5419 if ( $hased_string !== $_GET['hc'] ) {
5420 $log = array(
5421 'acting' => 'paygent_card(3ds_process)',
5422 'key' => $trading_id,
5423 'result' => '3DS ERROR',
5424 'data' => $_GET,
5425 );
5426 usces_save_order_acting_error( $log );
5427 wp_redirect(
5428 add_query_arg(
5429 array(
5430 'acting' => 'paygent_card',
5431 'acting_return' => 0,
5432 'retry' => 1,
5433 ),
5434 USCES_CART_URL
5435 )
5436 );
5437 exit();
5438 }
5439
5440 /* Get session data */
5441 $post_data = $this->get_post_data( $trading_id );
5442 if ( $post_data ) {
5443 $this->delete_post_data( $trading_id );
5444 ?>
5445 <!DOCTYPE html>
5446 <html lang="ja">
5447 <head>
5448 <title></title>
5449 </head>
5450 <body onload="javascript:document.forms['redirectForm'].submit();">
5451 <form action="<?php echo esc_url( USCES_CART_URL ); ?>" method="post" id="redirectForm">
5452 <?php
5453 foreach ( (array) $post_data as $key => $value ) {
5454 if ( is_array( $value ) ) {
5455 continue;
5456 }
5457 echo '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '" />' . "\n";
5458 }
5459 if ( isset( $_GET['result'] ) ) {
5460 echo '<input type="hidden" name="result" value="' . esc_attr( wp_unslash( $_GET['result'] ) ) . '" />' . "\n";
5461 }
5462 if ( isset( $_GET['3ds_auth_id'] ) ) {
5463 echo '<input type="hidden" name="3ds_auth_id" value="' . esc_attr( wp_unslash( $_GET['3ds_auth_id'] ) ) . '" />' . "\n";
5464 }
5465 if ( isset( $_GET['3dsecure_ds_transaction_id'] ) ) {
5466 echo '<input type="hidden" name="3dsecure_ds_transaction_id" value="' . esc_attr( wp_unslash( $_GET['3dsecure_ds_transaction_id'] ) ) . '" />' . "\n";
5467 }
5468 if ( isset( $_GET['attempt_kbn'] ) ) {
5469 echo '<input type="hidden" name="attempt_kbn" value="' . esc_attr( wp_unslash( $_GET['attempt_kbn'] ) ) . '" />' . "\n";
5470 }
5471 ?>
5472 <input type="hidden" name="purchase" value="purchase" />
5473 <input type="hidden" name="from3ds" value="1" />
5474 <div class="wait_message" style="text-align: center; margin-top: 100px;"><?php esc_html_e( __( 'Hold on for a while, please.', 'usces' ) ); ?></div>
5475 </form>
5476 </body>
5477 </html>
5478 <?php
5479 } else {
5480 $log = array(
5481 'acting' => 'paygent_card(3ds_process)',
5482 'key' => $trading_id,
5483 'result' => 'SESSION ERROR',
5484 'data' => $_GET,
5485 );
5486 usces_save_order_acting_error( $log );
5487 wp_redirect(
5488 add_query_arg(
5489 array(
5490 'acting' => 'paygent_card',
5491 'acting_return' => 0,
5492 'retry' => 1,
5493 ),
5494 USCES_CART_URL
5495 )
5496 );
5497 }
5498 exit();
5499 }
5500
5501 /**
5502 * Redirect to 3DS authentication.
5503 *
5504 * @param array $post_data Post data.
5505 * @param int $member_id Member ID.
5506 */
5507 public function certification_3ds( $post_data, $member_id ) {
5508 global $usces;
5509
5510 $entry = $usces->cart->get_entry();
5511 if ( ! $entry ) {
5512 wp_redirect( USCES_CART_URL );
5513 exit();
5514 }
5515
5516 $trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
5517 $this->save_post_data( $trading_id, $post_data );
5518
5519 $acting_opts = $this->get_acting_settings();
5520 $card_set_method = 'token';
5521 if ( 'on' == $acting_opts['stock_card_mode'] && ! empty( $member_id ) ) {
5522 if ( isset( $post_data['stock_card'] ) && 'stock' == $post_data['stock_card'] ) {
5523 $card_set_method = 'customer';
5524 }
5525 }
5526
5527 $merchant_name = mb_convert_kana( $usces->options['company_name'], 'RNASKV', 'UTF-8' );
5528 $term_url = add_query_arg( 'done_3ds_auth', $trading_id, USCES_CART_URL );
5529
5530 $pm = Paygent_Module::get_instance();
5531 $pm->init();
5532 $pm->req_put( 'term_url', $term_url );
5533 $pm->req_put( 'authentication_type', '01' );
5534 $pm->req_put( 'merchant_name', $merchant_name );
5535 $pm->req_put( 'payment_amount', $entry['order']['total_full_price'] );
5536 $pm->req_put( 'card_set_method', $card_set_method );
5537 if ( 'customer' == $card_set_method ) {
5538 $customer_card_id = $usces->get_member_meta_value( 'paygent_customer_card_id', $member_id );
5539 $pm->req_put( 'customer_id', $member_id );
5540 $pm->req_put( 'customer_card_id', $customer_card_id );
5541 } else {
5542 $pm->req_put( 'card_token', $post_data['token'] );
5543 }
5544 $result_post = $pm->post( PAYGENT_CARD_3DS2 );
5545 $result_status = $pm->get_result_status();
5546 if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
5547 $response_data = array(
5548 'result' => $result_post,
5549 'result_status' => $result_status,
5550 'response_code' => $pm->get_response_code(),
5551 'response_detail' => $pm->get_response_detail(),
5552 'result_message' => $pm->get_result_message(),
5553 );
5554 $response_code = ( true !== $result_post ) ? $result_post : $pm->get_response_code();
5555 $log = array(
5556 'acting' => $acting,
5557 'key' => $trading_id,
5558 'result' => $response_code,
5559 'data' => $response_data,
5560 );
5561 usces_save_order_acting_error( $log );
5562 wp_redirect(
5563 add_query_arg(
5564 array(
5565 'acting' => $acting,
5566 'acting_return' => 0,
5567 'retry' => 1,
5568 ),
5569 USCES_CART_URL
5570 )
5571 );
5572 exit();
5573 }
5574
5575 $response_data = $pm->get_response_data();
5576 if ( isset( $response_data['out_acs_html'] ) ) {
5577 echo( $response_data['out_acs_html'] );
5578 } else {
5579 $log = array(
5580 'acting' => $acting,
5581 'key' => $trading_id,
5582 'result' => '3DS OUT ACS ERROR',
5583 'data' => $response_data,
5584 );
5585 usces_save_order_acting_error( $log );
5586 wp_redirect(
5587 add_query_arg(
5588 array(
5589 'acting' => $acting,
5590 'acting_return' => 0,
5591 'retry' => 1,
5592 ),
5593 USCES_CART_URL
5594 )
5595 );
5596 }
5597 exit();
5598 }
5599
5600 /**
5601 * Scripts.
5602 * wp_enqueue_scripts
5603 */
5604 public function enqueue_scripts() {
5605 global $usces;
5606
5607 /* 発送・支払方法ページ、クレジットカード�
5608 報更新ページ */
5609 if ( ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'delivery' == $usces->page ) ||
5610 ( $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'] ) ) ) ) ) :
5611 // if ( $this->is_activate_card( 'module' ) ) :
5612 $acting_opts = $this->get_acting_settings();
5613 ?>
5614 <script type="text/javascript" src="<?php echo esc_url( $acting_opts['token_url'] ); ?>" charset="UTF-8"></script>
5615 <?php
5616 // endif;
5617 endif;
5618 }
5619
5620 /**
5621 * Front scripts.
5622 * wp_print_footer_scripts
5623 */
5624 public function footer_scripts() {
5625 global $usces;
5626
5627 if ( $this->is_validity_acting( 'card' ) || $this->is_validity_acting( 'conv' ) ) {
5628 /* 発送・支払方法ページ */
5629 if ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'delivery' == $usces->page ) {
5630 if ( $this->is_activate_card( 'module' ) || $this->is_activate_conv( 'module' ) ) {
5631 $acting_opts = $this->get_acting_settings();
5632 wp_register_style( 'paygent-token-style', USCES_FRONT_PLUGIN_URL . '/css/paygent_token.css' );
5633 wp_enqueue_style( 'paygent-token-style' );
5634 wp_register_script( 'usces_cart_paygent', USCES_FRONT_PLUGIN_URL . '/js/cart_paygent.js', array( 'jquery' ), USCES_VERSION, true );
5635 $paygent_params = array();
5636 if ( $this->is_activate_card( 'module' ) ) {
5637 $paygent_params['card_service_type'] = $this->get_service_type( 'card' );
5638 $paygent_params['seq_merchant_id'] = $acting_opts['seq_merchant_id'];
5639 $paygent_params['token_key'] = $acting_opts['token_key'];
5640 $paygent_params['use_card_conf_number'] = $acting_opts['use_card_conf_number'];
5641 $paygent_params['message']['error_token'] = __( 'Credit card information is not appropriate.', 'usces' );
5642 $paygent_params['message']['error_card_number'] = __( 'Credit card information is not appropriate.', 'usces' );
5643 $paygent_params['message']['error_card_expire'] = __( 'Credit card information is not appropriate.', 'usces' );
5644 $paygent_params['message']['error_card_cvc'] = __( 'Credit card information is not appropriate.', 'usces' );
5645 }
5646 if ( $this->is_activate_conv( 'module' ) ) {
5647 $paygent_params['conv_service_type'] = $this->get_service_type( 'conv' );
5648 $paygent_params['message']['error_customer_family_name'] = '利用�
5649 名(姓)を�
5650 �力してください。';
5651 $paygent_params['message']['error_customer_name'] = '利用�
5652 名(名)を�
5653 �力してください。';
5654 $paygent_params['message']['error_customer_tel'] = '利用�
5655 電話番号を�
5656 �力してください。';
5657 }
5658 wp_localize_script( 'usces_cart_paygent', 'paygent_params', $paygent_params );
5659 wp_enqueue_script( 'usces_cart_paygent' );
5660 }
5661 }
5662 }
5663
5664 if ( $this->is_validity_acting( 'card' ) ) :
5665 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) :
5666 /* クレジットカード�
5667 報更新ページ */
5668 if ( isset( $_GET['usces_page'] ) && ( 'member_register_settlement' == wp_unslash( $_GET['usces_page'] ) || 'member_update_settlement' == wp_unslash( $_GET['usces_page'] ) ) ) :
5669 $acting_opts = $this->get_acting_settings();
5670 wp_register_style( 'paygent-token-style', USCES_FRONT_PLUGIN_URL . '/css/paygent_token.css' );
5671 wp_enqueue_style( 'paygent-token-style' );
5672 wp_register_script( 'usces_member_paygent', USCES_FRONT_PLUGIN_URL . '/js/member_paygent.js', array( 'jquery' ), USCES_VERSION, true );
5673 $paygent_params = array();
5674 $paygent_params['seq_merchant_id'] = $acting_opts['seq_merchant_id'];
5675 $paygent_params['token_key'] = $acting_opts['token_key'];
5676 $paygent_params['use_card_conf_number'] = $acting_opts['use_card_conf_number'];
5677 $paygent_params['message'] = array(
5678 'error_token' => __( 'Credit card information is not appropriate.', 'usces' ),
5679 'error_card_number' => __( 'Credit card information is not appropriate.', 'usces' ),
5680 'error_card_expire' => __( 'Credit card information is not appropriate.', 'usces' ),
5681 'error_card_cvc' => __( 'Credit card information is not appropriate.', 'usces' ),
5682 'confirm_deletion' => __( 'Are you sure delete credit card registration?', 'usces' ),
5683 );
5684 wp_localize_script( 'usces_member_paygent', 'paygent_params', $paygent_params );
5685 wp_enqueue_script( 'usces_member_paygent' );
5686 print_google_recaptcha_response( wp_unslash( $_GET['usces_page'] ), 'member-card-info', 'member_update_settlement' );
5687 else :
5688 $member = $usces->get_member();
5689 if ( usces_have_member_continue_order( $member['ID'] ) || usces_have_member_regular_order( $member['ID'] ) ) :
5690 ?>
5691 <script type="text/javascript">
5692 jQuery( document ).ready( function( $ ) {
5693 $( "input[name='deletemember']" ).css( "display", "none" );
5694 });
5695 </script>
5696 <?php
5697 endif;
5698 endif;
5699 endif;
5700 endif;
5701
5702 if ( $this->is_validity_acting( 'paidy' ) ) :
5703 /* �
5704 容確認ページ */
5705 if ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'confirm' == $usces->page ) :
5706 $entry = $usces->cart->get_entry();
5707 $cart = $usces->cart->get_cart();
5708 if ( empty( $entry['order']['total_full_price'] ) ) {
5709 return;
5710 }
5711 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
5712 if ( isset( $payment['settlement'] ) && 'acting_paygent_paidy' == $payment['settlement'] ) {
5713 } else {
5714 return;
5715 }
5716
5717 $continue = ( defined( 'WCEX_DLSELLER' ) ) ? usces_have_continue_charge( $cart ) : false;
5718 $regular = ( defined( 'WCEX_AUTO_DELIVERY' ) ) ? usces_have_regular_order() : false;
5719 if ( $continue || $regular ) {
5720 return;
5721 }
5722
5723 $acting_opts = $this->get_acting_settings();
5724 if ( usces_is_login() ) {
5725 $member = $usces->get_member();
5726 $age = ceil( ( strtotime( date_i18n( 'Y-m-d H:i:s' ) ) - strtotime( $member['registered'] ) ) / ( 60 * 60 * 24 ) );
5727 $member_data = $this->get_buyer_data( $member['ID'] );
5728 $buyer_data = '"user_id": "' . $member['ID'] . '",' . "\n";
5729 $buyer_data .= "\t\t\t" . '"age": ' . $age . ',' . "\n";
5730 $buyer_data .= "\t\t\t" . '"ltv": ' . $member_data['ltv'] . ',' . "\n";
5731 $buyer_data .= "\t\t\t" . '"order_count": ' . $member_data['order_count'] . ',' . "\n";
5732 $buyer_data .= "\t\t\t" . '"last_order_amount": ' . $member_data['last_order_amount'] . ',' . "\n";
5733 $buyer_data .= "\t\t\t" . '"last_order_at": ' . $member_data['last_order_at'] . ',' . "\n";
5734 $number_of_points = '"number_of_points": "' . $member['point'] . '"' . "\n";
5735 } else {
5736 $buyer_data = '"age": null,' . "\n";
5737 $buyer_data .= "\t\t\t" . '"ltv": null,' . "\n";
5738 $buyer_data .= "\t\t\t" . '"order_count": null,' . "\n";
5739 $buyer_data .= "\t\t\t" . '"last_order_amount": null,' . "\n";
5740 $buyer_data .= "\t\t\t" . '"last_order_at": null,' . "\n";
5741 $number_of_points = '';
5742 }
5743 $amount = usces_crform( $entry['order']['total_full_price'], false, false, 'return', false );
5744 if ( isset( $acting_opts['ope'] ) && 'public' == $acting_opts['ope'] ) {
5745 $email = trim( $entry['customer']['mailaddress1'] );
5746 if ( ! empty( $entry['customer']['tel'] ) ) {
5747 $phone = '"phone": "' . str_replace( '-', '', mb_convert_kana( $entry['customer']['tel'], 'a', 'UTF-8' ) ) . '"' . "\n";
5748 } else {
5749 $phone = '';
5750 }
5751 } else {
5752 $email = 'successful.payment@paidy.com';
5753 $phone = '"phone": "08000000001"' . "\n";
5754 }
5755 $name1 = $entry['customer']['name1'] . ' ' . $entry['customer']['name2'];
5756 if ( ! empty( $entry['customer']['name3'] ) ) {
5757 $name2 = '"name2": "' . $entry['customer']['name3'] . ' ' . $entry['customer']['name4'] . '",' . "\n";
5758 } else {
5759 $name2 = '';
5760 }
5761 $line1 = '';
5762 $line2 = '';
5763 $city = '';
5764 $state = '';
5765 $zip = '';
5766 $additional_shipping_addresses = '';
5767 if ( usces_is_login() && defined( 'WCEX_MSA' ) && isset( $entry['delivery']['delivery_flag'] ) && 2 == $entry['delivery']['delivery_flag'] ) {
5768 $msacart = $usces->msacart->get_cart();
5769 $count_msa = ( is_array( $msacart ) ) ? count( $msacart ) : 0;
5770 if ( 0 < $count_msa ) {
5771 krsort( $msacart );
5772 $idx_msa = 0;
5773 foreach ( $msacart as $group_id => $group ) {
5774 $delivery = $group['delivery'];
5775 $destination_info = msa_get_destination( $usces->current_member['id'], $delivery['destination_id'] );
5776 if ( 7 == strlen( trim( $destination_info['msa_zip'] ) ) ) {
5777 $msa_zip = substr( trim( $destination_info['msa_zip'] ), 0, 3 ) . '-' . substr( trim( $destination_info['msa_zip'] ), 3 );
5778 } else {
5779 $msa_zip = trim( $destination_info['msa_zip'] );
5780 }
5781 if ( 0 == $idx_msa ) {
5782 $line1 = trim( $destination_info['msa_address3'] );
5783 $line2 = trim( $destination_info['msa_address2'] );
5784 $city = trim( $destination_info['msa_address1'] );
5785 $state = trim( $destination_info['msa_pref'] );
5786 $zip = $msa_zip;
5787 } elseif ( 1 == $idx_msa ) {
5788 $additional_shipping_addresses .= '"additional_shipping_addresses": [{' . "\n";
5789 $additional_shipping_addresses .= "\t\t\t\t" . '"line1": "' . trim( $destination_info['msa_address3'] ) . '",' . "\n";
5790 $additional_shipping_addresses .= "\t\t\t\t" . '"line2": "' . trim( $destination_info['msa_address2'] ) . '",' . "\n";
5791 $additional_shipping_addresses .= "\t\t\t\t" . '"city": "' . trim( $destination_info['msa_address1'] ) . '",' . "\n";
5792 $additional_shipping_addresses .= "\t\t\t\t" . '"state": "' . trim( $destination_info['msa_pref'] ) . '",' . "\n";
5793 $additional_shipping_addresses .= "\t\t\t\t" . '"zip": "' . $msa_zip . '"' . "\n";
5794 $additional_shipping_addresses .= "\t\t\t" . '}';
5795 } else {
5796 $additional_shipping_addresses .= ',' . "\n\t\t\t" . '{' . "\n";
5797 $additional_shipping_addresses .= "\t\t\t\t" . '"line1": "' . trim( $destination_info['msa_address3'] ) . '",' . "\n";
5798 $additional_shipping_addresses .= "\t\t\t\t" . '"line2": "' . trim( $destination_info['msa_address2'] ) . '",' . "\n";
5799 $additional_shipping_addresses .= "\t\t\t\t" . '"city": "' . trim( $destination_info['msa_address1'] ) . '",' . "\n";
5800 $additional_shipping_addresses .= "\t\t\t\t" . '"state": "' . trim( $destination_info['msa_pref'] ) . '",' . "\n";
5801 $additional_shipping_addresses .= "\t\t\t\t" . '"zip": "' . $msa_zip . '"' . "\n";
5802 $additional_shipping_addresses .= "\t\t\t" . '}';
5803 }
5804 $idx_msa++;
5805 }
5806 $additional_shipping_addresses .= '],' . "\n";
5807 }
5808 } else {
5809 $line1 = trim( $entry['delivery']['address3'] );
5810 $line2 = trim( $entry['delivery']['address2'] );
5811 $city = trim( $entry['delivery']['address1'] );
5812 $state = trim( $entry['delivery']['pref'] );
5813 if ( 7 == strlen( trim( $entry['delivery']['zipcode'] ) ) ) {
5814 $zip = substr( trim( $entry['delivery']['zipcode'] ), 0, 3 ) . '-' . substr( trim( $entry['delivery']['zipcode'] ), 3 );
5815 } else {
5816 $zip = trim( $entry['delivery']['zipcode'] );
5817 }
5818 }
5819 $items = '';
5820 foreach ( $cart as $cart_row ) {
5821 $items .= "\n\t\t\t\t" . '{' . "\n";
5822 $items .= "\t\t\t\t\t" . '"id": ' . wp_json_encode( (string) $usces->getItemCode( $cart_row['post_id'] ) ) . ',' . "\n";
5823 $items .= "\t\t\t\t\t" . '"quantity": ' . $cart_row['quantity'] . ',' . "\n";
5824 $items .= "\t\t\t\t\t" . '"title": ' . wp_json_encode( (string) $usces->getItemName( $cart_row['post_id'] ) ) . ',' . "\n";
5825 $items .= "\t\t\t\t\t" . '"unit_price": ' . $cart_row['price'] . "\n";
5826 $items .= "\t\t\t\t" . '},';
5827 }
5828 if ( isset( $entry['order']['discount'] ) && 0 != $entry['order']['discount'] ) {
5829 $items .= "\n\t\t\t\t" . '{' . "\n";
5830 $items .= "\t\t\t\t\t" . '"quantity": 1,' . "\n";
5831 $items .= "\t\t\t\t\t" . '"title": "' . apply_filters( 'usces_confirm_discount_label', __( 'Campaign discount', 'usces' ) ) . '",' . "\n";
5832 $items .= "\t\t\t\t\t" . '"unit_price": ' . $entry['order']['discount'] . "\n";
5833 $items .= "\t\t\t\t" . '},';
5834 }
5835 if ( usces_is_member_system() && usces_is_member_system_point() && ! empty( $entry['order']['usedpoint'] ) ) {
5836 $items .= "\n\t\t\t\t" . '{' . "\n";
5837 $items .= "\t\t\t\t\t" . '"quantity": 1,' . "\n";
5838 $items .= "\t\t\t\t\t" . '"title": "' . __( 'Used points', 'usces' ) . '",' . "\n";
5839 $items .= "\t\t\t\t\t" . '"unit_price": ' . ( $entry['order']['usedpoint'] * -1 ) . "\n";
5840 $items .= "\t\t\t\t" . '},';
5841 }
5842 if ( ! empty( $entry['order']['cod_fee'] ) ) {
5843 $items .= "\n\t\t\t\t" . '{' . "\n";
5844 $items .= "\t\t\t\t\t" . '"quantity": 1,' . "\n";
5845 $items .= "\t\t\t\t\t" . '"title": "' . apply_filters( 'usces_filter_paidy_fee_label', 'Paidy手数料' ) . '",' . "\n";
5846 $items .= "\t\t\t\t\t" . '"unit_price": ' . $entry['order']['cod_fee'] . "\n";
5847 $items .= "\t\t\t\t" . '},';
5848 }
5849 $items = rtrim( $items, ',' ) . "\n";
5850 if ( 0 != $entry['order']['shipping_charge'] ) {
5851 $shipping = $entry['order']['shipping_charge'];
5852 } else {
5853 $shipping = '0';
5854 }
5855 if ( isset( $entry['order']['tax'] ) && 'exclude' == usces_get_tax_mode() ) {
5856 $tax = $entry['order']['tax'] . "\n";
5857 } else {
5858 $tax = '0' . "\n";
5859 }
5860 ?>
5861 <script type="text/javascript" src="https://apps.paidy.com/"></script>
5862 <script type="text/javascript">
5863 var config = {
5864 "api_key": "<?php echo esc_html( $acting_opts['paidy_public_key'] ); ?>",
5865 "closed": function( callbackData ) {
5866 if ( 'closed' == callbackData.status ) {
5867 document.getElementById( "paidy-checkout-button" ).style.pointerEvents = "auto";
5868 } else {
5869 var purchase_form = document.forms.purchase_form;
5870 purchase_form.paidy_id.value = callbackData.id;
5871 purchase_form.paidy_created_at.value = callbackData.created_at;
5872 purchase_form.paidy_status.value = callbackData.status;
5873 purchase_form.submit();
5874 }
5875 }
5876 };
5877 var paidyHandler = Paidy.configure( config );
5878 function paidyPay() {
5879 document.getElementById( "paidy-checkout-button" ).style.pointerEvents = "none";
5880 var rand = document.getElementsByName( "trading_id" )[0].value;
5881 var payload = {
5882 "amount": <?php echo esc_js( $amount ); ?>,
5883 "currency": "JPY",
5884 "store_name": "<?php echo esc_html( get_option( 'blogname' ) ); ?>",
5885 "buyer": {
5886 "email": "<?php echo esc_js( $email ); ?>",
5887 "name1": "<?php echo esc_js( $name1 ); ?>",
5888 <?php wel_esc_script_e( $name2 ); ?>
5889 <?php wel_esc_script_e( $phone ); ?>
5890 },
5891 "buyer_data": {
5892 <?php wel_esc_script_e( $buyer_data ); ?>
5893 <?php wel_esc_script_e( $additional_shipping_addresses ); ?>
5894 <?php wel_esc_script_e( $number_of_points ); ?>
5895 },
5896 "order": {
5897 "items": [
5898 <?php wel_esc_script_e( $items ); ?>
5899 ],
5900 "order_ref": rand,
5901 "shipping": <?php wel_esc_script_e( $shipping ); ?>,
5902 "tax": <?php wel_esc_script_e( $tax ); ?>
5903 },
5904 "shipping_address": {
5905 "line1": "<?php echo esc_js( $line1 ); ?>",
5906 "line2": "<?php echo esc_js( $line2 ); ?>",
5907 "city": "<?php echo esc_js( $city ); ?>",
5908 "state": "<?php echo esc_js( $state ); ?>",
5909 "zip": "<?php echo esc_js( $zip ); ?>"
5910 }
5911 };
5912 paidyHandler.launch( payload );
5913 };
5914 </script>
5915 <?php
5916 endif;
5917 endif;
5918 }
5919
5920 /**
5921 * Paidy Checkout Buyer data オブジェクト
5922 *
5923 * @param int $member_id Post ID.
5924 * @return array
5925 */
5926 private function get_buyer_data( $member_id ) {
5927 global $wpdb;
5928
5929 $ltv = 0;
5930 $order_count = 0;
5931 $last_order_amount = 0;
5932 $last_order_at = 0;
5933
5934 $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}usces_order WHERE `mem_id` = %d ORDER BY `order_date` DESC", $member_id );
5935 $results = $wpdb->get_results( $query, ARRAY_A );
5936 if ( 0 < count( $results ) ) {
5937 foreach ( $results as $order ) {
5938 if ( false === strpos( $order['order_status'], 'cancel' ) && false === strpos( $order['order_status'], 'estimate' ) ) {
5939 $payment = usces_get_payments_by_name( $order['order_payment_name'] );
5940 if ( isset( $payment['settlement'] ) && 'acting_paygent_paidy' != $payment['settlement'] ) {
5941 $total_price = $order['order_item_total_price'] - $order['order_usedpoint'] + $order['order_discount'] + $order['order_shipping_charge'] + $order['order_cod_fee'] + $order['order_tax'];
5942 if ( 0 === $order_count ) {
5943 $last_order_amount = $total_price;
5944 $last_order_at = ceil( ( strtotime( date_i18n( 'Y-m-d H:i:s' ) ) - strtotime( $order['order_date'] ) ) / ( 60 * 60 * 24 ) );
5945 }
5946 $ltv += $total_price;
5947 $order_count++;
5948 }
5949 }
5950 }
5951 }
5952 $member_data = array(
5953 'ID' => $member_id,
5954 'ltv' => $ltv,
5955 'order_count' => $order_count,
5956 'last_order_amount' => $last_order_amount,
5957 'last_order_at' => $last_order_at,
5958 );
5959
5960 return $member_data;
5961 }
5962
5963 /**
5964 * Set uscesL10n.
5965 * usces_filter_uscesL10n
5966 *
5967 * @param string $l10n uscesL10n.
5968 * @param int $post_id Post ID.
5969 * @return string
5970 */
5971 public function set_uscesL10n( $l10n, $post_id ) {
5972 global $usces;
5973
5974 if ( ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) && 'delivery' == $usces->page ) ||
5975 ( $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'] ) ) ) ) ) {
5976 if ( $this->is_activate_card( 'module' ) ) {
5977 $front_ajaxurl = USCES_SSL_URL;
5978 if ( '/' != substr( $front_ajaxurl, -1 ) ) {
5979 $front_ajaxurl .= '/';
5980 }
5981 $front_ajaxurl .= 'index.php';
5982 $l10n .= "'front_ajaxurl': '" . $front_ajaxurl . "',\n";
5983 }
5984 }
5985 return $l10n;
5986 }
5987
5988 /**
5989 * 支払方法チェック
5990 * usces_filter_delivery_check
5991 *
5992 * @param string $mes Validation check message.
5993 * @return string
5994 */
5995 public function delivery_check( $mes ) {
5996 if ( ! isset( $_POST['offer']['payment_name'] ) ) {
5997 return $mes;
5998 }
5999
6000 if ( ! empty( $mes ) ) {
6001 return $mes;
6002 }
6003
6004 $payment = usces_get_payments_by_name( $_POST['offer']['payment_name'] );
6005 $acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
6006 switch ( $acting_flg ) {
6007 case 'acting_paygent_card':
6008 if ( $this->is_activate_card( 'module' ) ) {
6009 if ( isset( $_POST['stock_card'] ) && 'stock' == wp_unslash( $_POST['stock_card'] ) ) {
6010 $acting_opts = $this->get_acting_settings();
6011 if ( 'on' == $acting_opts['use_card_conf_number'] ) {
6012 if ( isset( $_POST['token'] ) && empty( $_POST['token'] ) ) {
6013 $mes .= __( 'Please enter the card information correctly.', 'usces' ) . '<br />';
6014 }
6015 }
6016 } else {
6017 if ( isset( $_POST['token'] ) && empty( $_POST['token'] ) ) {
6018 $mes .= __( 'Please enter the card information correctly.', 'usces' ) . '<br />';
6019 } else {
6020 if ( ! wel_check_credit_security() ) {
6021 $mes .= __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '<br />';
6022 }
6023 }
6024 }
6025 }
6026 break;
6027
6028 case 'acting_paygent_conv':
6029 if ( $this->is_activate_conv( 'module' ) ) {
6030 if ( isset( $_POST['customer_family_name'] ) && empty( $_POST['customer_family_name'] ) ) {
6031 $mes .= '利用�
6032 名(姓)を�
6033 �力してください。<br />';
6034 }
6035 if ( isset( $_POST['customer_name'] ) && empty( $_POST['customer_name'] ) ) {
6036 $mes .= '利用�
6037 名(名)を�
6038 �力してください。<br />';
6039 }
6040 if ( isset( $_POST['customer_tel'] ) && empty( $_POST['customer_tel'] ) ) {
6041 $mes .= '利用�
6042 電話番号を�
6043 �力してください。<br />';
6044 }
6045 }
6046 break;
6047
6048 case 'acting_paygent_atm':
6049 break;
6050
6051 case 'acting_paygent_bank':
6052 break;
6053 }
6054 return $mes;
6055 }
6056
6057 /**
6058 * 支払方法ページ用�
6059 �力フォーム
6060 * usces_filter_delivery_secure_form_loop
6061 *
6062 * @param string $nouse Empty.
6063 * @param array $payment Payment data.
6064 * @return string
6065 */
6066 public function delivery_secure_form_loop( $nouse, $payment ) {
6067 global $usces;
6068
6069 $form = '';
6070 switch ( $payment['settlement'] ) {
6071 case 'acting_paygent_card':
6072 if ( 'activate' != $payment['use'] || ! $this->is_activate_card( 'module' ) ) {
6073 return $form;
6074 }
6075
6076 $acting_opts = $this->get_acting_settings();
6077 $re_enter = ( isset( $_REQUEST['re_enter'] ) && false !== strpos( $_REQUEST['re_enter'], 'paygent_card' ) ) ? true : false;
6078
6079 $customer_id = '';
6080 if ( usces_is_login() ) {
6081 $usces->get_current_member();
6082 $customer_id = $usces->current_member['id'];
6083 }
6084
6085 $customer = array();
6086 if ( 'on' == $acting_opts['stock_card_mode'] ) {
6087 if ( ! empty( $customer_id ) ) {
6088 $customer = $this->customer_ref( $customer_id );
6089 }
6090 }
6091 $split_count = ( isset( $_POST['split_count'] ) ) ? wp_unslash( $_POST['split_count'] ) : '01';
6092 $card_area_class = 'paygent_card_area';
6093
6094 $form .= '
6095 <table class="customer_form" id="paygent_card_form">
6096 <tr>
6097 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>' . __( 'Credit card information', 'usces' ) . '</th>
6098 <td>';
6099 if ( 'on' == $acting_opts['stock_card_mode'] && ! empty( $customer['card_number'] ) ) {
6100 $card_area_class = 'paygent_new_card_area';
6101 $cardlast4 = substr( $customer['card_number'], -4 );
6102 $split_type = $this->split_type( $customer['card_brand'] );
6103 $form .= '
6104 <p><label><input type="radio" name="stock_card" class="stock_card" id="stock_card_use" value="stock"><span>登録済みのクレジットカードを使う</span></label></p>
6105 <div class="paygent_registerd_card_area">
6106 <div>登録済みのカード番号下4桁<span class="cardlast4">' . $cardlast4 . '</span></div>
6107 <input type="hidden" id="split_type" value="' . $split_type . '" />
6108 </div>
6109 <p><label><input type="radio" name="stock_card" class="stock_card" id="stock_card_new" value="new"><span>新しいクレジットカードを使う</span></label></p>';
6110 }
6111 $form .= '<div class="' . $card_area_class . '">
6112 <dl>
6113 <dt>' . __( 'card number', 'usces' ) . '</dt>
6114 <dd><input type="tel" class="card_number" id="card_number" maxlength="16" value=""></dd>';
6115 if ( 'on' == $acting_opts['stock_card_mode'] ) {
6116 if ( ! empty( $customer['card_number'] ) ) {
6117 if ( usces_have_regular_order() || usces_have_continue_charge() ) {
6118 $form .= '<input type="hidden" name="stock_card_mode" value="change">';
6119 } else {
6120 $form .= '<dd><label><input type="checkbox" name="stock_card_mode" id="stock_card_mode" value="change"><span id="stock_card_mode_label">登録済のカードを変更して購�
6121 �する</span></label></dd>';
6122 }
6123 } else {
6124 if ( usces_have_regular_order() || usces_have_continue_charge() ) {
6125 $form .= '<input type="hidden" name="stock_card_mode" value="save">';
6126 } else {
6127 $form .= '<dd><label><input type="checkbox" name="stock_card_mode" id="stock_card_mode" value="save"><span id="stock_card_mode_label">クレジットカードを登録して購�
6128 �する</span></label></dd>';
6129 }
6130 }
6131 }
6132 $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>' );
6133 $form .= $cardno_attention;
6134 $form .= '<dt>' . __( 'Card expiration', 'usces' ) . '</dt>
6135 <dd><select class="expire_month" id="expire_month">
6136 <option value="">--</option>';
6137 for ( $i = 1; $i <= 12; $i++ ) {
6138 $form .= '<option value="' . sprintf( '%02d', $i ) . '">' . sprintf( '%02d', $i ) . '</option>';
6139 }
6140 $form .= '</select>' . __( 'month', 'usces' ) . '&nbsp;
6141 <select class="expire_year" id="expire_year">
6142 <option value="">--</option>';
6143 for ( $i = 0; $i <= 15; $i++ ) {
6144 $year = date_i18n( 'Y' ) + $i;
6145 $year = substr( $year, -2 );
6146 $form .= '
6147 <option value="' . $year . '">' . $year . '</option>';
6148 }
6149 $form .= '</select>' . __( 'year', 'usces' ) . '</dd>
6150 </dl>
6151 </div>';
6152 if ( 'on' == $acting_opts['use_card_conf_number'] ) {
6153 $form .= '<div class="paygent_card_split_count_area">
6154 <dl><dt>' . __( 'security code', 'usces' ) . '</dt>
6155 <dd><input type="tel" class="cvc" id="cvc" maxlength="4" value=""></dd>';
6156 $cvc_attention = apply_filters( 'usces_filter_seccd_attention', '' );
6157 $form .= $cvc_attention;
6158 $form .= '
6159 </dl>
6160 </div>';
6161 }
6162
6163 $form_split_count = '';
6164 if ( ( usces_have_regular_order() || usces_have_continue_charge() ) && usces_is_login() ) {
6165 $form_split_count .= '<input type="hidden" name="split_count" value="01" />';
6166 } else {
6167 if ( 0 === (int) $acting_opts['payment_class'] ) {
6168 $form_split_count .= '<input type="hidden" name="split_count" value="01" />';
6169 } elseif ( 1 <= (int) $acting_opts['payment_class'] ) {
6170 $form_split_count = '<div class="paygent_card_split_count_area">
6171 <dl><dt>分割回数</dt>
6172 <dd>';
6173 $form_split_count .= '
6174 <select name="split_count" id="split_count_default" >
6175 <option value="01"' . ( ( '01' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'One time payment', 'usces' ) . '</option>
6176 </select>';
6177 $form_split_count .= '
6178 <select name="split_count" id="split_count_4535" style="display:none;" disabled="disabled" >
6179 <option value="01"' . ( ( '01' == $split_count ) ? ' selected="selected"' : '' ) . '>1' . __( '-time payment', 'usces' ) . '</option>
6180 <option value="02"' . ( ( '02' == $split_count ) ? ' selected="selected"' : '' ) . '>2' . __( '-time payment', 'usces' ) . '</option>
6181 <option value="03"' . ( ( '03' == $split_count ) ? ' selected="selected"' : '' ) . '>3' . __( '-time payment', 'usces' ) . '</option>
6182 <option value="05"' . ( ( '05' == $split_count ) ? ' selected="selected"' : '' ) . '>5' . __( '-time payment', 'usces' ) . '</option>
6183 <option value="06"' . ( ( '06' == $split_count ) ? ' selected="selected"' : '' ) . '>6' . __( '-time payment', 'usces' ) . '</option>
6184 <option value="10"' . ( ( '10' == $split_count ) ? ' selected="selected"' : '' ) . '>10' . __( '-time payment', 'usces' ) . '</option>
6185 <option value="12"' . ( ( '12' == $split_count ) ? ' selected="selected"' : '' ) . '>12' . __( '-time payment', 'usces' ) . '</option>
6186 <option value="15"' . ( ( '15' == $split_count ) ? ' selected="selected"' : '' ) . '>15' . __( '-time payment', 'usces' ) . '</option>
6187 <option value="18"' . ( ( '18' == $split_count ) ? ' selected="selected"' : '' ) . '>18' . __( '-time payment', 'usces' ) . '</option>
6188 <option value="20"' . ( ( '20' == $split_count ) ? ' selected="selected"' : '' ) . '>20' . __( '-time payment', 'usces' ) . '</option>
6189 <option value="24"' . ( ( '24' == $split_count ) ? ' selected="selected"' : '' ) . '>24' . __( '-time payment', 'usces' ) . '</option>
6190 <option value="80"' . ( ( '80' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'Libor Funding pay', 'usces' ) . '</option>';
6191 if ( 1 == (int) $acting_opts['payment_class'] ) {
6192 $form_split_count .= '
6193 <option value="23"' . ( ( '23' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'Bonus lump-sum payment', 'usces' ) . '</option>';
6194 }
6195 $form_split_count .= '
6196 </select>';
6197 $form_split_count .= '
6198 <select name="split_count" id="split_count_37" style="display:none;" disabled="disabled" >
6199 <option value="01"' . ( ( '01' == $split_count ) ? ' selected="selected"' : '' ) . '>1' . __( '-time payment', 'usces' ) . '</option>
6200 <option value="03"' . ( ( '03' == $split_count ) ? ' selected="selected"' : '' ) . '>3' . __( '-time payment', 'usces' ) . '</option>
6201 <option value="05"' . ( ( '05' == $split_count ) ? ' selected="selected"' : '' ) . '>5' . __( '-time payment', 'usces' ) . '</option>
6202 <option value="06"' . ( ( '06' == $split_count ) ? ' selected="selected"' : '' ) . '>6' . __( '-time payment', 'usces' ) . '</option>
6203 <option value="10"' . ( ( '10' == $split_count ) ? ' selected="selected"' : '' ) . '>10' . __( '-time payment', 'usces' ) . '</option>
6204 <option value="12"' . ( ( '12' == $split_count ) ? ' selected="selected"' : '' ) . '>12' . __( '-time payment', 'usces' ) . '</option>
6205 <option value="15"' . ( ( '15' == $split_count ) ? ' selected="selected"' : '' ) . '>15' . __( '-time payment', 'usces' ) . '</option>
6206 <option value="18"' . ( ( '18' == $split_count ) ? ' selected="selected"' : '' ) . '>18' . __( '-time payment', 'usces' ) . '</option>
6207 <option value="20"' . ( ( '20' == $split_count ) ? ' selected="selected"' : '' ) . '>20' . __( '-time payment', 'usces' ) . '</option>
6208 <option value="24"' . ( ( '24' == $split_count ) ? ' selected="selected"' : '' ) . '>24' . __( '-time payment', 'usces' ) . '</option>';
6209 if ( 1 == (int) $acting_opts['payment_class'] ) {
6210 $form_split_count .= '
6211 <option value="23"' . ( ( '23' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'Bonus lump-sum payment', 'usces' ) . '</option>';
6212 }
6213 $form_split_count .= '
6214 </select>';
6215 $form_split_count .= '
6216 <select name="split_count" id="split_count_36" style="display:none;" disabled="disabled" >
6217 <option value="01"' . ( ( '01' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'One time payment', 'usces' ) . '</option>
6218 <option value="80"' . ( ( '80' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'Libor Funding pay', 'usces' ) . '</option>';
6219 if ( 1 == (int) $acting_opts['payment_class'] ) {
6220 $form_split_count .= '
6221 <option value="23"' . ( ( '23' == $split_count ) ? ' selected="selected"' : '' ) . '>' . __( 'Bonus lump-sum payment', 'usces' ) . '</option>';
6222 }
6223 $form_split_count .= '
6224 </select>';
6225 $form_split_count .= '
6226 </dd>
6227 </dl>
6228 </div>';
6229 }
6230 }
6231 $form .= apply_filters( 'usces_filter_paygent_card_split_count', $form_split_count );
6232 $form .= '
6233 <input type="hidden" name="acting" value="paygent_card" />
6234 <input type="hidden" name="confirm" value="confirm" />
6235 <input type="hidden" name="token" id="token" value="" />
6236 <input type="hidden" name="masked_card_number" id="masked_card_number" value="" />
6237 <input type="hidden" name="valid_until" id="valid_until" value="" />
6238 <input type="hidden" name="fingerprint" id="fingerprint" value="" />
6239 <input type="hidden" name="hc" id="hc" value="" />';
6240 $form .= '
6241 </td></tr>
6242 </table>';
6243 break;
6244
6245 case 'acting_paygent_conv':
6246 if ( 'activate' != $payment['use'] || ! $this->is_activate_conv( 'module' ) ) {
6247 return $form;
6248 }
6249
6250 $acting_opts = $this->get_acting_settings();
6251 $entry = $usces->cart->get_entry();
6252 $cvs_company_id = ( isset( $_POST['cvs_company_id'] ) ) ? $_POST['cvs_company_id'] : '';
6253 $name1 = ( isset( $_POST['customer_family_name'] ) ) ? $_POST['customer_family_name'] : trim( $entry['customer']['name1'] );
6254 $name2 = ( isset( $_POST['customer_name'] ) ) ? $_POST['customer_name'] : trim( $entry['customer']['name2'] );
6255 $tel = ( isset( $_POST['customer_tel'] ) ) ? $_POST['customer_tel'] : trim( $entry['customer']['tel'] );
6256 $tel = str_replace( '-', '', mb_convert_kana( $tel, 'a', 'UTF-8' ) );
6257
6258 $form .= '
6259 <table class="customer_form" id="paygent_conv_form">
6260 <tr>
6261 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>' . __( 'Convenience store for payment', 'usces' ) . '</th>
6262 <td colspan="2">
6263 <select name="cvs_company_id" id="cvs_company_id">';
6264 foreach ( $this->cvs_company_a as $cvs_cd => $cvs_company ) {
6265 $cvs_type = $this->cvs_type_a[ $cvs_cd ];
6266 if ( ! in_array( $cvs_type, $acting_opts['cvs_type'] ) ) {
6267 continue;
6268 }
6269 $selected = ( $cvs_company_id == $cvs_cd ) ? ' selected="selected"' : '';
6270 $form .= '
6271 <option value="' . esc_attr( $cvs_cd ) . '"' . $selected . '>' . esc_attr( $cvs_company ) . '</option>';
6272 }
6273 $form .= '
6274 </select>
6275 </td>
6276 </tr>
6277 <tr>
6278 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>利用�
6279 名</th>
6280 <td>姓<input name="customer_family_name" class="customer_name" id="customer_family_name" type="text" value="' . esc_attr( $name1 ) . '" /></td>
6281 <td>名<input name="customer_name" class="customer_name" id="customer_name" type="text" value="' . esc_attr( $name2 ) . '" />(�
6282 �角)</td>
6283 </tr>
6284 <tr>
6285 <th scope="row"><em>' . __( '*', 'usces' ) . '</em>利用�
6286 電話番号</th>
6287 <td colspan="2"><input name="customer_tel" id="customer_tel" type="tel" value="' . esc_attr( $tel ) . '" /></td>
6288 </tr>
6289 </table>';
6290 break;
6291
6292 case 'acting_paygent_atm':
6293 if ( 'activate' != $payment['use'] || ! $this->is_activate_atm() ) {
6294 return $form;
6295 }
6296
6297 $acting_opts = $this->get_acting_settings();
6298 $entry = $usces->cart->get_entry();
6299 $name1 = ( isset( $_POST['customer_family_name'] ) ) ? $_POST['customer_family_name'] : trim( $entry['customer']['name1'] );
6300 $name2 = ( isset( $_POST['customer_name'] ) ) ? $_POST['customer_name'] : trim( $entry['customer']['name2'] );
6301 $name3 = ( isset( $_POST['customer_family_name_kana'] ) ) ? $_POST['customer_family_name_kana'] : String_Utitily::convert_katakana_zen2han( trim( $entry['customer']['name3'] ) );
6302 $name4 = ( isset( $_POST['customer_name_kana'] ) ) ? $_POST['customer_name_kana'] : String_Utitily::convert_katakana_zen2han( trim( $entry['customer']['name4'] ) );
6303
6304 $form .= '
6305 <table class="customer_form" id="paygent_atm_form">
6306 <tr>
6307 <th scope="row">利用�
6308 名</th>
6309 <td>姓<input name="customer_family_name" class="customer_name" id="customer_family_name" type="text" value="' . esc_attr( $name1 ) . '" /></td>
6310 <td>名<input name="customer_name" class="customer_name" id="customer_name" type="text" value="' . esc_attr( $name2 ) . '" />(�
6311 �角)</td>
6312 </tr>
6313 <tr>
6314 <th scope="row">利用�
6315 名カ�
6316 </th>
6317 <td>セイ<input name="customer_family_name_kana" class="customer_name" id="customer_family_name_kana" type="text" value="' . esc_attr( $name3 ) . '" /></td>
6318 <td>メイ<input name="customer_name_kana" class="customer_name" id="customer_name_kana" type="text" value="' . esc_attr( $name4 ) . '" />(半角カ�
6319 )</td>
6320 </tr>
6321 </table>';
6322 break;
6323
6324 case 'acting_paygent_bank':
6325 if ( 'activate' != $payment['use'] || ! $this->is_activate_bank() ) {
6326 return $form;
6327 }
6328
6329 $acting_opts = $this->get_acting_settings();
6330 $entry = $usces->cart->get_entry();
6331 $name1 = ( isset( $_POST['customer_family_name'] ) ) ? $_POST['customer_family_name'] : trim( $entry['customer']['name1'] );
6332 $name2 = ( isset( $_POST['customer_name'] ) ) ? $_POST['customer_name'] : trim( $entry['customer']['name2'] );
6333 $name3 = ( isset( $_POST['customer_family_name_kana'] ) ) ? $_POST['customer_family_name_kana'] : String_Utitily::convert_katakana_zen2han( trim( $entry['customer']['name3'] ) );
6334 $name4 = ( isset( $_POST['customer_name_kana'] ) ) ? $_POST['customer_name_kana'] : String_Utitily::convert_katakana_zen2han( trim( $entry['customer']['name4'] ) );
6335
6336 $form .= '
6337 <table class="customer_form" id="paygent_bank_form">
6338 <tr>
6339 <th scope="row">利用�
6340 名</th>
6341 <td>姓<input name="customer_family_name" class="customer_name" id="customer_family_name" type="text" value="' . esc_attr( $name1 ) . '" /></td>
6342 <td>名<input name="customer_name" class="customer_name" id="customer_name" type="text" value="' . esc_attr( $name2 ) . '" />(�
6343 �角)</td>
6344 </tr>
6345 <tr>
6346 <th scope="row">利用�
6347 名カ�
6348 </th>
6349 <td>セイ<input name="customer_family_name_kana" class="customer_name" id="customer_family_name_kana" type="text" value="' . esc_attr( $name3 ) . '" /></td>
6350 <td>メイ<input name="customer_name_kana" class="customer_name" id="customer_name_kana" type="text" value="' . esc_attr( $name4 ) . '" />(半角カ�
6351 )</td>
6352 </tr>
6353 </table>';
6354 break;
6355 }
6356 return $form;
6357 }
6358
6359 /**
6360 * お預かりカードの分割可能回数
6361 *
6362 * @param string $card_brand Card brand.
6363 * @return string
6364 */
6365 private function split_type( $card_brand ) {
6366 switch ( $card_brand ) {
6367 case 'VISA':
6368 case 'JCB':
6369 case 'MASTER':
6370 $split_type = '4535';
6371 break;
6372 case 'DINERS':
6373 $split_type = '36';
6374 break;
6375 case 'AMEX':
6376 $split_type = '37';
6377 break;
6378 default:
6379 $split_type = 'default';
6380 }
6381 return $split_type;
6382 }
6383
6384 /**
6385 * 購�
6386 �完了メッセージ
6387 * usces_filter_completion_settlement_message
6388 *
6389 * @param string $form Purchase complete message.
6390 * @param array $entry Entry data.
6391 * @return string
6392 */
6393 public function completion_settlement_message( $form, $entry ) {
6394 $acting = ( isset( $_GET['acting'] ) ) ? wp_unslash( $_GET['acting'] ) : '';
6395 if ( 'paygent_conv' == $acting || 'paygent_atm' == $acting ) {
6396 $form .= '<div class="completion-settlement-message"><span class="bold">' . $this->acting_formal_name . esc_html( $entry['order']['payment_name'] ) . '</span>';
6397 $form .= '<p>' . sprintf( __( "Information on payment will be mailed to %s.", 'usces' ), esc_html( $entry['customer']['mailaddress1'] ) ) . '</p>';
6398 $form .= '</div>';
6399 }
6400 return $form;
6401 }
6402
6403 /**
6404 * Temporary storage of session data.
6405 * usces_filter_save_order_acting_data
6406 *
6407 * @param array $data Session data.
6408 * @return array
6409 */
6410 public function save_order_acting_data( $data ) {
6411 if ( isset( $_POST['_nonce'] ) ) {
6412 $data['_nonce'] = wp_unslash( $_POST['_nonce'] );
6413 }
6414 return $data;
6415 }
6416
6417 /**
6418 * 会員データ削除チェック
6419 * usces_filter_delete_member_check
6420 *
6421 * @param boolean $deletable Deletable.
6422 * @param int $member_id Member ID.
6423 * @return boolean
6424 */
6425 public function delete_member_check( $deletable, $member_id ) {
6426 $customer = $this->customer_ref( $member_id );
6427 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id ) {
6428 if ( usces_have_member_continue_order( $member_id ) || usces_have_member_regular_order( $member_id ) ) {
6429 $deletable = false;
6430 }
6431 }
6432 return $deletable;
6433 }
6434
6435 /**
6436 * 会員データ削除
6437 * usces_action_pre_delete_memberdata
6438 *
6439 * @param string $member_id Member ID.
6440 */
6441 public function delete_member( $member_id ) {
6442 $this->customer_card_del( $member_id );
6443 }
6444
6445 /**
6446 * クレジットカード登録・変更ページ表示
6447 * usces_filter_template_redirect
6448 */
6449 public function member_update_settlement() {
6450 global $usces;
6451
6452 if ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
6453 if ( ! usces_is_membersystem_state() || ! usces_is_login() ) {
6454 return;
6455 }
6456 $acting_opts = $this->get_acting_settings();
6457 if ( 'on' != $acting_opts['stock_card_mode'] ) {
6458 return;
6459 }
6460 if ( isset( $_REQUEST['usces_page'] ) && 'member_update_settlement' == $_REQUEST['usces_page'] ) {
6461 add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) );
6462 $usces->page = 'member_update_settlement';
6463 $this->member_update_settlement_form();
6464 exit();
6465 } elseif ( isset( $_REQUEST['usces_page'] ) && 'member_register_settlement' == $_REQUEST['usces_page'] ) {
6466 add_filter( 'usces_filter_states_form_js', array( $this, 'states_form_js' ) );
6467 $usces->page = 'member_register_settlement';
6468 $this->member_update_settlement_form();
6469 exit();
6470 }
6471 }
6472 return false;
6473 }
6474
6475 /**
6476 * クレジットカード登録・変更ページ表示
6477 * usces_filter_states_form_js
6478 *
6479 * @param string $js Scripts.
6480 * @return string
6481 */
6482 public function states_form_js( $js ) {
6483 return '';
6484 }
6485
6486 /**
6487 * クレジットカード登録・変更ページリンク
6488 * usces_action_member_submenu_list
6489 */
6490 public function e_update_settlement() {
6491 global $usces;
6492
6493 $member = $usces->get_member();
6494 $form = $this->update_settlement( '', $member );
6495 echo $form; // no escape.
6496 }
6497
6498 /**
6499 * クレジットカード登録・変更ページリンク
6500 * usces_filter_member_submenu_list
6501 *
6502 * @param string $form Submenu area of the member page.
6503 * @param array $member Member information.
6504 * @return string
6505 */
6506 public function update_settlement( $form, $member ) {
6507 $acting_opts = $this->get_acting_settings();
6508 if ( isset( $acting_opts['card_activate'] ) && 'off' != $acting_opts['card_activate'] && 'on' == $acting_opts['stock_card_mode'] && ! empty( $member['ID'] ) ) {
6509 $customer = $this->customer_ref( $member['ID'] );
6510 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member['ID'] ) {
6511 $update_settlement_url = add_query_arg(
6512 array(
6513 'usces_page' => 'member_update_settlement',
6514 're-enter' => 1,
6515 ),
6516 USCES_MEMBER_URL
6517 );
6518 $form .= '<li><a href="' . $update_settlement_url . '">' . __( 'Change the credit card is here >>', 'usces' ) . '</a></li>';
6519 } else {
6520 $register_settlement_url = add_query_arg(
6521 array(
6522 'usces_page' => 'member_register_settlement',
6523 're-enter' => 1,
6524 ),
6525 USCES_MEMBER_URL
6526 );
6527 $form .= '<li><a href="' . $register_settlement_url . '">' . __( 'Credit card registration is here >>', 'usces' ) . '</a></li>';
6528 }
6529 }
6530 return $form;
6531 }
6532
6533 /**
6534 * クレジットカード登録・変更ページ
6535 */
6536 public function member_update_settlement_form() {
6537 global $usces;
6538
6539 $member = $usces->get_member();
6540 $acting_opts = $this->get_acting_settings();
6541
6542 $form = '';
6543 $script = '';
6544 $done_message = '';
6545 $update_settlement_url = add_query_arg(
6546 array(
6547 'usces_page' => $usces->page,
6548 'settlement' => 1,
6549 're-enter' => 1,
6550 ),
6551 USCES_MEMBER_URL
6552 );
6553 $register = ( 'member_register_settlement' == $usces->page ) ? true : false;
6554 $deleted = false;
6555
6556 $cardlast4 = '';
6557 $expyy = '';
6558 $expmm = '';
6559
6560 $update = ( isset( $_POST['update'] ) ) ? $_POST['update'] : '';
6561 if ( 'register' == $update ) {
6562 check_admin_referer( 'member_update_settlement', 'wc_nonce' );
6563 $verify_action = wel_verify_update_settlement( $member['ID'] );
6564 if ( ! $verify_action ) {
6565 $usces->error_message .= '<p>' . __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '</p>';
6566 $register = false;
6567 } else {
6568 $token = ( isset( $_POST['token'] ) ) ? trim( $_POST['token'] ) : '';
6569 $customer = $this->customer_card_add( $member['ID'], $token );
6570 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
6571 $usces->error_message .= '<p>' . __( 'Credit card information is not appropriate.', 'usces' ) . '</p>';
6572 $done_message = __( 'Registration failed.', 'usces' );
6573 } else {
6574 $done_message = __( 'Successfully registered.', 'usces' );
6575 $register = false;
6576 }
6577 }
6578 } elseif ( 'update' == $update ) {
6579 check_admin_referer( 'member_update_settlement', 'wc_nonce' );
6580 $verify_action = wel_verify_update_settlement( $member['ID'] );
6581 if ( ! $verify_action ) {
6582 $usces->error_message .= '<p>' . __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '</p>';
6583 $register = false;
6584 } else {
6585 $token = ( isset( $_POST['token'] ) ) ? trim( $_POST['token'] ) : '';
6586 $customer = $this->customer_card_upd( $member['ID'], $token );
6587 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
6588 $usces->error_message .= '<p>' . __( 'Credit card information is not appropriate.', 'usces' ) . '</p>';
6589 $done_message = __( 'Update failed.', 'usces' );
6590 $register = true; /* 登録画面 */
6591 } else {
6592 $this->send_update_settlement_mail();
6593 $done_message = __( 'Successfully updated.', 'usces' );
6594 }
6595 }
6596 } elseif ( 'delete' == $update ) {
6597 check_admin_referer( 'member_update_settlement', 'wc_nonce' );
6598 $customer = $this->customer_card_del( $member['ID'] );
6599 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
6600 $usces->error_message .= '<p>' . __( 'Credit card information is not appropriate.', 'usces' ) . '</p>';
6601 $done_message = __( 'Deletion failed.', 'usces' );
6602 } else {
6603 $done_message = __( 'Successfully deleted.', 'usces' );
6604 $register = true;
6605 }
6606 }
6607
6608 $customer = $this->customer_ref( $member['ID'] );
6609 if ( ! empty( $customer ) && isset( $customer['card_number'] ) && isset( $customer['card_valid_term'] ) ) {
6610 $cardlast4 = substr( $customer['card_number'], -4 );
6611 $expyy = substr( $customer['card_valid_term'], 2, 2 );
6612 $expmm = substr( $customer['card_valid_term'], 0, 2 );
6613 }
6614 $form .= '<input name="acting" type="hidden" value="' . $this->paymod_id . '" />
6615 <table class="customer_form" id="' . $this->paymod_id . '">';
6616 if ( ! empty( $cardlast4 ) ) {
6617 $form .= '
6618 <tr>
6619 <th scope="row">' . __( 'The last four digits of your card number', 'usces' ) . '</th>
6620 <td colspan="2"><p>' . $cardlast4 . '</p></td>
6621 </tr>';
6622 }
6623 $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>' );
6624 $form .= '
6625 <tr>
6626 <th scope="row">' . __( 'card number', 'usces' ) . '</th>
6627 <td colspan="2"><input type="tel" class="card_number" id="card_number" maxlength="16" value="">' . $cardno_attention . '</td>
6628 </tr>';
6629 $form .= '
6630 <tr>
6631 <th scope="row">' . __( 'Card expiration', 'usces' ) . '</th>
6632 <td colspan="2">
6633 <select class="expire_month" id="expire_month">
6634 <option value=""' . ( empty( $expmm ) ? ' selected="selected"' : '' ) . '>--</option>';
6635 for ( $i = 1; $i <= 12; $i++ ) {
6636 $form .= '
6637 <option value="' . sprintf( '%02d', $i ) . '"' . ( ( $i == (int) $expmm ) ? ' selected="selected"' : '' ) . '>' . sprintf( '%2d', $i ) . '</option>';
6638 }
6639 $form .= '
6640 </select>' . __( 'month', 'usces' ) . '&nbsp;
6641 <select class="expire_year" id="expire_year">
6642 <option value=""' . ( empty( $expyy ) ? ' selected="selected"' : '' ) . '>--</option>';
6643 for ( $i = 0; $i < 15; $i++ ) {
6644 $year = date_i18n( 'Y' ) + $i;
6645 $year = substr( $year, -2 );
6646 $selected = ( $year == $expyy ) ? ' selected="selected"' : '';
6647 $form .= '
6648 <option value="' . $year . '"' . $selected . '>' . $year . '</option>';
6649 }
6650 $form .= '
6651 </select>' . __( 'year', 'usces' ) . '
6652 </td>
6653 </tr>';
6654 if ( 'on' == $acting_opts['use_card_conf_number'] ) {
6655 $seccd_attention = apply_filters( 'usces_filter_seccd_attention', __( '(Single-byte numbers only)', 'usces' ) );
6656 $form .= '
6657 <tr>
6658 <th scope="row">' . __( 'security code', 'usces' ) . '</th>
6659 <td colspan="2"><input type="tel" class="cvc" id="cvc" maxlength="4" value="">' . $seccd_attention . '</td>
6660 </tr>';
6661 }
6662 $form .= '
6663 </table>';
6664
6665 if ( '' != $done_message ) {
6666 $script .= '
6667 <script type="text/javascript">
6668 jQuery.event.add( window, "load", function() {
6669 alert( "' . $done_message . '" );
6670 });
6671 </script>';
6672 }
6673 $error_message = apply_filters( 'usces_filter_member_update_settlement_error_message', $usces->error_message );
6674
6675 ob_start();
6676 get_header();
6677 if ( '' != $script ) {
6678 echo $script; // no escape due to script.
6679 }
6680 ?>
6681 <div id="content" class="two-column">
6682 <div class="catbox">
6683 <?php
6684 if ( have_posts() ) :
6685 usces_remove_filter();
6686 ?>
6687 <div class="post" id="wc_member_update_settlement">
6688 <?php if ( $register ) : ?>
6689 <h1 class="member_page_title"><?php esc_html_e( 'Credit card registration', 'usces' ); ?></h1>
6690 <?php else : ?>
6691 <h1 class="member_page_title"><?php esc_html_e( 'Credit card update', 'usces' ); ?></h1>
6692 <?php endif; ?>
6693 <div class="entry">
6694 <div id="memberpages">
6695 <div class="whitebox">
6696 <div id="memberinfo">
6697 <div class="header_explanation"></div>
6698 <div class="error_message"><?php wel_esc_script_e( $error_message ); ?></div>
6699 <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;}">
6700 <?php wel_esc_script_e( $form ); ?>
6701 <div class="send">
6702 <input type="hidden" name="update" value="" />
6703 <input type="hidden" name="token" id="token" value="" />
6704 <input type="hidden" name="masked_card_number" id="masked_card_number" value="" />
6705 <input type="hidden" name="valid_until" id="valid_until" value="" />
6706 <input type="hidden" name="fingerprint" id="fingerprint" value="" />
6707 <input type="hidden" name="hc" id="hc" value="" />
6708 <?php if ( $register ) : ?>
6709 <input type="button" id="card-register" class="card-update" data-update_mode="register" value="<?php esc_attr_e( 'Register', 'usces' ); ?>" />
6710 <?php else : ?>
6711 <input type="button" id="card-update" class="card-update" data-update_mode="update" value="<?php esc_attr_e( 'Update', 'usces' ); ?>" />
6712 <?php if ( ! usces_have_member_continue_order( $member['ID'] ) && ! usces_have_member_regular_order( $member['ID'] ) ) : ?>
6713 <input type="button" id="card-delete" class="card-delete" data-update_mode="delete" value="<?php esc_attr_e( 'Delete', 'usces' ); ?>" />
6714 <?php endif; ?>
6715 <?php endif; ?>
6716 <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 ); ?>'" />
6717 <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() ); ?>'" />
6718 </div>
6719 <?php wp_nonce_field( 'member_update_settlement', 'wc_nonce' ); ?>
6720 </form>
6721 <div class="footer_explanation"></div>
6722 </div><!-- end of memberinfo -->
6723 </div><!-- end of whitebox -->
6724 </div><!-- end of memberpages -->
6725 </div><!-- end of entry -->
6726 </div><!-- end of post -->
6727 <?php else : ?>
6728 <p><?php esc_html_e( 'Sorry, no posts matched your criteria.', 'usces' ); ?></p>
6729 <?php endif; ?>
6730 </div><!-- end of catbox -->
6731 </div><!-- end of content -->
6732 <?php
6733 $sidebar = apply_filters( 'usces_filter_member_update_settlement_page_sidebar', 'cartmember' );
6734 if ( ! empty( $sidebar ) ) {
6735 get_sidebar( $sidebar );
6736 }
6737 get_footer();
6738 $contents = ob_get_contents();
6739 ob_end_clean();
6740 echo $contents; // no escape.
6741 }
6742
6743 /**
6744 * クレジットカード変更メール
6745 */
6746 public function send_update_settlement_mail() {
6747 global $usces;
6748
6749 $member = $usces->get_member();
6750
6751 $subject = apply_filters( 'usces_filter_send_update_settlement_mail_subject', __( 'Confirmation of credit card update', 'usces' ), $member );
6752 $mail_header = __( 'Your credit card information has been updated on the membership page.', 'usces' ) . "\r\n\r\n";
6753 $mail_footer = get_option( 'blogname' ) . "\r\n";
6754 $name = usces_localized_name( $member['name1'], $member['name2'], 'return' );
6755
6756 $message = '--------------------------------' . "\r\n";
6757 $message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
6758 $message .= __( 'Name', 'usces' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
6759 $message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
6760 $message .= '--------------------------------' . "\r\n\r\n";
6761 $message .= __( 'If you have not requested this email, sorry to trouble you, but please contact us.', 'usces' ) . "\r\n\r\n";
6762 $message = apply_filters( 'usces_filter_send_update_settlement_mail_message', $message, $member );
6763 $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";
6764 $message = sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n" . $message;
6765
6766 $send_para = array(
6767 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
6768 'to_address' => $member['mailaddress1'],
6769 'from_name' => get_option( 'blogname' ),
6770 'from_address' => $usces->options['sender_mail'],
6771 'reply_name' => get_option( 'blogname' ),
6772 'reply_to' => usces_get_first_order_mail(),
6773 'return_path' => $usces->options['sender_mail'],
6774 'subject' => $subject,
6775 'message' => do_shortcode( $message ),
6776 );
6777 usces_send_mail( $send_para );
6778
6779 $admin_message = $mail_header;
6780 $admin_message .= '--------------------------------' . "\r\n";
6781 $admin_message .= __( 'Member ID', 'usces' ) . ' : ' . $member['ID'] . "\r\n";
6782 $admin_message .= __( 'Name', 'usces' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
6783 $admin_message .= __( 'e-mail adress', 'usces' ) . ' : ' . $member['mailaddress1'] . "\r\n";
6784 $admin_message .= '--------------------------------' . "\r\n\r\n";
6785 if ( usces_have_member_continue_order( $member['ID'] ) ) {
6786 $admin_message .= $this->message_continue_order( $member['ID'] );
6787 }
6788 if ( usces_have_member_regular_order( $member['ID'] ) ) {
6789 $admin_message .= $this->message_regular_order( $member['ID'] );
6790 }
6791 $admin_message .=
6792 "\r\n----------------------------------------------------\r\n" .
6793 'REMOTE_ADDR : ' . $_SERVER['REMOTE_ADDR'] .
6794 "\r\n----------------------------------------------------\r\n";
6795
6796 $admin_para = array(
6797 'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
6798 'to_address' => $usces->options['order_mail'],
6799 'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
6800 'from_address' => $usces->options['sender_mail'],
6801 'reply_name' => get_option( 'blogname' ),
6802 'reply_to' => usces_get_first_order_mail(),
6803 'return_path' => $usces->options['sender_mail'],
6804 'subject' => $subject . '( ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . ' )',
6805 'message' => do_shortcode( $admin_message ),
6806 );
6807 usces_send_mail( $admin_para );
6808 }
6809
6810 /**
6811 * 契約中の自動継続課金�
6812
6813 *
6814 * @param int $member_id Member ID.
6815 */
6816 public function message_continue_order( $member_id ) {
6817 global $usces, $wpdb;
6818 $message = '';
6819
6820 $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' );
6821 $continue_order = $wpdb->get_results( $query, ARRAY_A );
6822 if ( 0 < count( $continue_order ) ) {
6823 $message .= '--------------------------------' . "\r\n";
6824 $message .= __( 'Auto-continuation charging Information under Contract with a credit card', 'usces' ) . "\r\n";
6825 foreach ( $continue_order as $continue_data ) {
6826 $con_id = $continue_data['con_id'];
6827 $con_order_id = $continue_data['con_order_id'];
6828 $message .= __( 'Order number', 'usces' ) . ' : ' . $con_order_id;
6829 $latest_log = $this->get_acting_latest_log( $con_order_id, 0, RESULT_STATUS_ALL );
6830 if ( ! empty( $latest_log ) ) {
6831 $next_charging = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_charging( $con_order_id ) : $continue_data['con_next_contracting'];
6832 $message .= ' ( ' . __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . date( __( 'Y/m/d' ), strtotime( $next_charging ) );
6833 if ( 0 < (int) $continue_data['con_interval'] ) {
6834 $next_contracting = ( empty( $continue_data['con_next_contracting'] ) ) ? dlseller_next_contracting( $con_order_id ) : $continue_data['con_next_contracting'];
6835 $message .= ', ' . __( 'Renewal Date', 'dlseller' ) . ' : ' . date( __( 'Y/m/d' ), strtotime( $next_contracting ) );
6836 }
6837 $message .= ' )';
6838 if ( isset( $latest_log['result'] ) && RESULT_STATUS_NORMAL != $latest_log['result'] ) {
6839 $message .= ' ' . __( 'Condition', 'dlseller' ) . ' : ' . __( 'Settlement error', 'usces' );
6840 if ( ! empty( $latest_log['trading_id'] ) ) {
6841 $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $latest_log['trading_id'] . ' )';
6842 }
6843 }
6844 }
6845 $message .= "\r\n";
6846 }
6847 $message .= '--------------------------------' . "\r\n\r\n";
6848 }
6849 return $message;
6850 }
6851
6852 /**
6853 * 契約中の定期購�
6854 ��
6855
6856 *
6857 * @param int $member_id Member ID.
6858 */
6859 public function message_regular_order( $member_id ) {
6860 global $usces, $wpdb;
6861 $message = '';
6862
6863 $query_order = $wpdb->prepare(
6864 "SELECT r.reg_id, r.reg_payment_name, d.regdet_schedule_date
6865 FROM {$wpdb->prefix}usces_regular_detail AS `d`
6866 RIGHT JOIN {$wpdb->prefix}usces_regular AS `r` ON r.reg_id = d.reg_id
6867 WHERE r.reg_mem_id = %d AND d.regdet_condition = 'continuation'
6868 GROUP BY r.reg_id",
6869 $member_id
6870 );
6871 $regular_order = $wpdb->get_results( $query_order, ARRAY_A );
6872 if ( 0 < count( $regular_order ) ) {
6873 foreach ( $regular_order as $regular_data ) {
6874 $payment = $usces->getPayments( $regular_data['reg_payment_name'] );
6875 if ( isset( $payment['settlement'] ) && 'acting_paygent_card' != $payment['settlement'] ) {
6876 continue;
6877 }
6878 $reg_id = $regular_data['reg_id'];
6879 $query = $wpdb->prepare(
6880 "SELECT o.ID AS `order_id`, meta.meta_value AS `deco_id`, DATE_FORMAT( o.order_date, %s ) AS `order_date`
6881 FROM {$wpdb->prefix}usces_order AS `o`
6882 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta` ON o.ID = meta.order_id AND meta.meta_key = 'dec_order_id'
6883 LEFT JOIN {$wpdb->prefix}usces_regular ON o.ID = `reg_order_id`
6884 WHERE `reg_id` = %d
6885 UNION ALL
6886 SELECT o1.ID AS `order_id`, meta1.meta_value AS `deco_id`, DATE_FORMAT( o1.order_date, %s ) AS `order_date`
6887 FROM {$wpdb->prefix}usces_order AS `o1`
6888 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta1` ON o1.ID = meta1.order_id AND meta1.meta_key = 'dec_order_id'
6889 LEFT JOIN {$wpdb->prefix}usces_order_meta AS `meta2` ON o1.ID = meta2.order_id AND meta2.meta_key = 'regular_id'
6890 WHERE meta2.meta_value = %d
6891 ORDER BY `order_id` DESC, `order_date` DESC",
6892 '%Y-%m-%d',
6893 $reg_id,
6894 '%Y-%m-%d',
6895 $reg_id
6896 );
6897 $regular_order_data = $wpdb->get_results( $query, ARRAY_A );
6898 if ( 0 < count( $regular_order_data ) ) {
6899 $message .= __( 'Regular ID', 'autodelivery' ) . ' : ' . $reg_id;
6900 $reg_order_id = $regular_order_data[0]['order_id'];
6901 $latest_log = $this->get_acting_latest_log( $reg_order_id, 0, RESULT_STATUS_ALL );
6902 if ( isset( $latest_log['result'] ) && RESULT_STATUS_NORMAL != $latest_log['result'] ) {
6903 $message .= ' ' . __( 'Condition', 'autodelivery' ) . ' : ' . __( 'Settlement error', 'usces' );
6904 $trading_id = $usces->get_order_meta_value( 'trading_id', $reg_order_id );
6905 if ( $trading_id ) {
6906 $message .= ' ( ' . __( 'Transaction ID', 'usces' ) . ' : ' . $trading_id . ' )';
6907 }
6908 } else {
6909 if ( $this->isdate( $regular_data['regdet_schedule_date'] ) ) {
6910 $message .= ' ( ' . __( 'Scheduled order date', 'autodelivery' ) . ' : ' . date( __( 'Y/m/d' ), strtotime( $regular_data['regdet_schedule_date'] ) ) . ' )';
6911 }
6912 }
6913 $message .= "\r\n";
6914 }
6915 }
6916 if ( '' != $message ) {
6917 $message = '--------------------------------' . "\r\n"
6918 . __( 'Subscription Information under Contract with a credit card', 'usces' ) . "\r\n"
6919 . $message
6920 . '--------------------------------' . "\r\n\r\n";
6921 }
6922 }
6923 return $message;
6924 }
6925
6926 /**
6927 * 日付チェック
6928 *
6929 * @param object $date DateTime.
6930 * @return boolean
6931 */
6932 private function isdate( $date ) {
6933 if ( empty( $date ) ) {
6934 return false;
6935 }
6936 try {
6937 new DateTime( $date );
6938 list( $year, $month, $day ) = explode( '-', $date );
6939 $res = checkdate( (int) $month, (int) $day, (int) $year );
6940 return $res;
6941 } catch ( Exception $e ) {
6942 return false;
6943 }
6944 }
6945
6946 /**
6947 * 会員データ編集画面 カード�
6948 報登録�
6949
6950 * usces_action_admin_member_info
6951 *
6952 * @param array $member Member data.
6953 * @param array $member_metas Member meta data.
6954 * @param array $usces_member_history Member's history order data.
6955 */
6956 public function admin_member_info( $member, $member_metas, $usces_member_history ) {
6957 if ( 0 < count( $usces_member_history ) ) :
6958 $acting_opts = $this->get_acting_settings();
6959 if ( isset( $acting_opts['card_activate'] ) && 'off' != $acting_opts['card_activate'] && 'on' == $acting_opts['stock_card_mode'] ) :
6960 $customer = $this->customer_ref( $member['ID'] );
6961 if ( ! empty( $customer ) && isset( $customer['card_number'] ) && isset( $customer['card_valid_term'] ) ) :
6962 $cardlast4 = substr( $customer['card_number'], -4 );
6963 $expyy = substr( $customer['card_valid_term'], 2, 2 );
6964 $expmm = substr( $customer['card_valid_term'], 0, 2 );
6965 ?>
6966 <tr>
6967 <td class="label"><?php esc_html_e( 'Lower 4 digits', 'usces' ); ?></td>
6968 <td><div class="rod_left shortm"><?php echo esc_html( $cardlast4 ); ?></div></td>
6969 </tr>
6970 <tr>
6971 <td class="label"><?php esc_html_e( 'Expiration date', 'usces' ); ?></td>
6972 <td><div class="rod_left shortm"><?php echo esc_html( $expmm . '/' . $expyy ); ?></div></td>
6973 </tr>
6974 <tr>
6975 <td class="label">カード�
6976 </td>
6977 <td><div class="rod_left shortm"><?php esc_html_e( 'Registered', 'usces' ); ?></div></td>
6978 </tr>
6979 <?php
6980 if ( ! usces_have_member_continue_order( $member['ID'] ) && ! usces_have_member_regular_order( $member['ID'] ) ) :
6981 ?>
6982 <tr>
6983 <td class="label"><input type="checkbox" name="paygent_stock_card_mode" id="paygent-stock_card_mode-release" value="release"></td>
6984 <td><label for="paygent-stock_card_mode-release">カード�
6985 報の登録を解除する</label></td>
6986 </tr>
6987 <?php
6988 endif;
6989 endif;
6990 endif;
6991 endif;
6992 }
6993
6994 /**
6995 * 会員データ編集画面 カード�
6996 報登録解除
6997 * usces_action_post_update_memberdata
6998 *
6999 * @param int $member_id Member ID.
7000 * @param boolean $res Result.
7001 */
7002 public function admin_update_memberdata( $member_id, $res ) {
7003 if ( ! $this->is_activate_card() || false === $res ) {
7004 return;
7005 }
7006 if ( isset( $_POST['paygent_stock_card_mode'] ) && 'release' == $_POST['paygent_stock_card_mode'] ) {
7007 $this->customer_card_del( $member_id );
7008 }
7009 }
7010
7011 /**
7012 * 利用可能な支払方法(継続課金・定期購�
7013 �)
7014 * dlseller_filter_the_payment_method_restriction
7015 * wcad_filter_the_payment_method_restriction
7016 *
7017 * @param array $payments_restriction Payment method.
7018 * @param string $value Input value.
7019 * @return array
7020 */
7021 public function payment_method_restriction( $payments_restriction, $value ) {
7022 if ( ( usces_have_regular_order() || usces_have_continue_charge() ) && usces_is_login() ) {
7023 $paygent_card = false;
7024 foreach ( (array) $payments_restriction as $key => $payment ) {
7025 if ( isset( $payment['settlement'] ) && 'acting_paygent_card' == $payment['settlement'] ) {
7026 $paygent_card = true;
7027 }
7028 }
7029 if ( ! $paygent_card ) {
7030 $payments = usces_get_system_option( 'usces_payment_method', 'settlement' );
7031 $payments_restriction[] = $payments['acting_paygent_card'];
7032 }
7033 $sort = array();
7034 foreach ( (array) $payments_restriction as $key => $payment ) {
7035 $sort[ $key ] = $payment['sort'];
7036 }
7037 array_multisort( $sort, SORT_ASC, $payments_restriction );
7038 }
7039 return $payments_restriction;
7040 }
7041
7042 /**
7043 * 利用可能な支払方法
7044 * usces_filter_the_continue_payment_method
7045 *
7046 * @param array $payment_method Payment method.
7047 * @return array
7048 */
7049 public function continuation_payment_method( $payment_method ) {
7050 if ( ! array_key_exists( 'acting_paygent_card', $payment_method ) ) {
7051 $payment_method[] = 'acting_paygent_card';
7052 }
7053 return $payment_method;
7054 }
7055
7056 /**
7057 * 「初回引落し日」
7058 * dlseller_filter_first_charging
7059 *
7060 * @param object $time Datetime.
7061 * @param int $post_id Post ID.
7062 * @param array $usces_item Item data.
7063 * @param int $order_id Order number.
7064 * @param array $continue_data Continuation data.
7065 * @return object
7066 */
7067 public function first_charging_date( $time, $post_id, $usces_item, $order_id, $continue_data ) {
7068 if ( 99 === (int) $usces_item['item_chargingday'] ) {
7069 if ( empty( $order_id ) ) {
7070 $today = date_i18n( 'Y-m-d', current_time( 'timestamp' ) );
7071 list( $year, $month, $day ) = explode( '-', $today );
7072 $time = mktime( 0, 0, 0, (int) $month, (int) $day, (int) $year );
7073 }
7074 }
7075 return $time;
7076 }
7077
7078 /**
7079 * 継続課金会員リスト「状�
7080 �」
7081 * dlseller_filter_continue_member_list_condition
7082 *
7083 * @param string $condition Continuation condition.
7084 * @param int $member_id Member ID.
7085 * @param int $order_id Order number.
7086 * @param array $continue_data Continuation data.
7087 * @return string
7088 */
7089 public function continue_member_list_condition( $condition, $member_id, $order_id, $continue_data ) {
7090 global $usces;
7091
7092 if ( isset( $continue_data['acting'] ) && 'acting_paygent_card' == $continue_data['acting'] ) {
7093 $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 ) );
7094 $condition = '<a href="' . $url . '">' . __( 'Detail', 'usces' ) . '</a>';
7095 if ( 'continuation' == $continue_data['status'] ) {
7096 $latest_log = $this->get_acting_latest_log( $order_id, 0, RESULT_STATUS_ALL );
7097 if ( isset( $latest_log['result'] ) && RESULT_STATUS_NORMAL != $latest_log['result'] ) {
7098 $condition .= '<div class="acting-status paygent-error">' . __( 'Settlement error', 'usces' ) . '</div>';
7099 }
7100 }
7101 }
7102 return $condition;
7103 }
7104
7105 /**
7106 * 継続課金会員決済状況ページ表示
7107 * dlseller_action_continue_member_list_page
7108 *
7109 * @param string $continue_action Continuation action.
7110 */
7111 public function continue_member_list_page( $continue_action ) {
7112 if ( 'settlement_paygent_card' == $continue_action ) {
7113 $member_id = ( isset( $_GET['member_id'] ) ) ? wp_unslash( $_GET['member_id'] ) : '';
7114 $order_id = ( isset( $_GET['order_id'] ) ) ? wp_unslash( $_GET['order_id'] ) : '';
7115 if ( ! empty( $member_id ) && ! empty( $order_id ) ) {
7116 $this->continue_member_settlement_info_page( $member_id, $order_id );
7117 exit();
7118 }
7119 }
7120 }
7121
7122 /**
7123 * 継続課金会員決済詳細ページ
7124 *
7125 * @param int $member_id Member ID.
7126 * @param int $order_id Order number.
7127 */
7128 public function continue_member_settlement_info_page( $member_id, $order_id ) {
7129 global $usces;
7130
7131 $order_data = $usces->get_order_data( $order_id, 'direct' );
7132 if ( ! $order_data ) {
7133 return;
7134 }
7135
7136 $payment = $usces->getPayments( $order_data['order_payment_name'] );
7137 if ( isset( $payment['settlement'] ) && 'acting_paygent_card' != $payment['settlement'] ) {
7138 return;
7139 }
7140
7141 $continue_data = $this->get_continuation_data( $member_id, $order_id );
7142 if ( 'acting_paygent_card' != $continue_data['acting'] ) {
7143 return;
7144 }
7145
7146 $con_id = $continue_data['con_id'];
7147 $curent_url = esc_url( $_SERVER['REQUEST_URI'] );
7148
7149 $member_info = $usces->get_member_info( $member_id );
7150 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
7151
7152 $contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
7153 if ( ! empty( $contracted_date ) ) {
7154 list( $contracted_year, $contracted_month, $contracted_day ) = explode( '-', $contracted_date );
7155 } else {
7156 $contracted_year = 0;
7157 $contracted_month = 0;
7158 $contracted_day = 0;
7159 }
7160 $charged_date = ( empty( $continue_data['chargedday'] ) ) ? dlseller_next_charging( $order_id ) : $continue_data['chargedday'];
7161 if ( ! empty( $charged_date ) ) {
7162 list( $charged_year, $charged_month, $charged_day ) = explode( '-', $charged_date );
7163 } else {
7164 $charged_year = 0;
7165 $charged_month = 0;
7166 $charged_day = 0;
7167 }
7168 $this_year = substr( date_i18n( 'Y', current_time( 'timestamp' ) ), 0, 4 );
7169
7170 $log_data = $this->get_acting_log( $order_id, 0, RESULT_STATUS_ALL );
7171 $num = ( $log_data ) ? count( $log_data ) : 1;
7172 ?>
7173 <div class="wrap">
7174 <div class="usces_admin">
7175 <h1>Welcart Management <?php esc_html_e( 'Continuation charging member information', 'dlseller' ); ?></h1>
7176 <p class="version_info">Version <?php echo esc_html( WCEX_DLSELLER_VERSION ); ?></p>
7177 <?php usces_admin_action_status(); ?>
7178 <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>
7179 <div id="datatable">
7180 <div id="tablesearch" class="usces_tablesearch">
7181 <div id="searchBox" style="display:block">
7182 <table class="search_table">
7183 <tr>
7184 <td class="label"><?php esc_html_e( 'Continuation charging information', 'dlseller' ); ?></td>
7185 <td>
7186 <table class="order_info">
7187 <tr>
7188 <th><?php esc_html_e( 'Member ID', 'dlseller' ); ?></th>
7189 <td><?php echo esc_html( $member_id ); ?></td>
7190 <th><?php esc_html_e( 'Contractor name', 'dlseller' ); ?></th>
7191 <td><?php echo esc_html( $name ); ?></td>
7192 </tr>
7193 <tr>
7194 <th><?php esc_html_e( 'Order ID', 'dlseller' ); ?></th>
7195 <td><?php echo esc_html( $order_id ); ?></td>
7196 <th><?php esc_html_e( 'Application Date', 'dlseller' ); ?></th>
7197 <td><?php echo esc_html( $order_data['order_date'] ); ?></td>
7198 </tr>
7199 <tr>
7200 <th><?php esc_html_e( 'Renewal Date', 'dlseller' ); ?></th>
7201 <td>
7202 <?php
7203 echo '<select id="contracted-year">';
7204 if ( 0 == (int) $contracted_year ) {
7205 echo '<option value="0" selected="selected"></option>';
7206 } else {
7207 echo '<option value="0"></option>';
7208 }
7209 for ( $i = 0; $i <= 10; $i++ ) {
7210 $year = (int) $this_year + $i;
7211 if ( (int) $contracted_year == $year ) {
7212 echo "<option value=\"{$year}\" selected=\"selected\">{$year}</option>";
7213 } else {
7214 echo "<option value=\"{$year}\">{$year}</option>";
7215 }
7216 }
7217 echo '</select>-<select id="contracted-month">';
7218 if ( 0 == (int) $contracted_month ) {
7219 echo '<option value="0" selected="selected"></option>';
7220 } else {
7221 echo '<option value="0"></option>';
7222 }
7223 for ( $i = 1; $i <= 12; $i++ ) {
7224 $month = sprintf( '%02d', $i );
7225 if ( (int) $contracted_month == $i ) {
7226 echo "<option value=\"{$month}\" selected=\"selected\">{$month}</option>";
7227 } else {
7228 echo "<option value=\"{$month}\">{$month}</option>";
7229 }
7230 }
7231 echo '</select>-<select id="contracted-day">';
7232 if ( 0 == (int) $contracted_day ) {
7233 echo '<option value="0" selected="selected"></option>';
7234 } else {
7235 echo '<option value="0"></option>';
7236 }
7237 for ( $i = 1; $i <= 31; $i++ ) {
7238 $day = sprintf( '%02d', $i );
7239 if ( (int) $contracted_day == $i ) {
7240 echo "<option value=\"{$day}\" selected=\"selected\">{$day}</option>";
7241 } else {
7242 echo "<option value=\"{$day}\">{$day}</option>";
7243 }
7244 }
7245 echo '</select>';
7246 ?>
7247 </td>
7248 <th><?php _e( 'Next Withdrawal Date', 'dlseller' ); ?></th>
7249 <td>
7250 <?php
7251 echo '<select id="charged-year">';
7252 if ( 0 == (int) $charged_year ) {
7253 echo '<option value="0" selected="selected"></option>';
7254 } else {
7255 echo '<option value="0"></option>';
7256 }
7257 if ( $charged_year == $this_year ) {
7258 echo "<option value=\"{$this_year}\" selected=\"selected\">{$this_year}</option>";
7259 } else {
7260 echo "<option value=\"{$this_year}\">{$this_year}</option>";
7261 }
7262 $next_year = (int) $this_year + 1;
7263 if ( $charged_year == $next_year ) {
7264 echo "<option value=\"{$next_year}\" selected=\"selected\">{$next_year}</option>";
7265 } else {
7266 echo "<option value=\"{$next_year}\">{$next_year}</option>";
7267 }
7268 echo '</select>-<select id="charged-month">';
7269 if ( 0 == $charged_month ) {
7270 echo '<option value="0" selected="selected"></option>';
7271 } else {
7272 echo '<option value="0"></option>';
7273 }
7274 for ( $i = 1; $i <= 12; $i++ ) {
7275 $month = sprintf( '%02d', $i );
7276 if ( (int) $charged_month == $i ) {
7277 echo "<option value=\"{$month}\" selected=\"selected\">{$month}</option>";
7278 } else {
7279 echo "<option value=\"{$month}\">{$month}</option>";
7280 }
7281 }
7282 echo '</select>-<select id="charged-day">';
7283 if ( 0 == $charged_day ) {
7284 echo '<option value="0" selected="selected"></option>';
7285 } else {
7286 echo '<option value="0"></option>';
7287 }
7288 for ( $i = 1; $i <= 31; $i++ ) {
7289 $day = sprintf( '%02d', $i );
7290 if ( (int) $charged_day == $i ) {
7291 echo "<option value=\"{$day}\" selected=\"selected\">{$day}</option>";
7292 } else {
7293 echo "<option value=\"{$day}\">{$day}</option>";
7294 }
7295 }
7296 echo '</select>';
7297 ?>
7298 </td>
7299 </tr>
7300 <tr>
7301 <th><?php esc_html_e( 'Amount on order', 'usces' ); ?></th>
7302 <td><?php usces_crform( $continue_data['order_price'], false ); ?></td>
7303 <th><?php esc_html_e( 'Transaction amount', 'usces' ); ?></th>
7304 <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>
7305 </tr>
7306 <tr>
7307 <th><?php esc_html_e( 'Status', 'dlseller' ); ?></th>
7308 <td><select id="dlseller-status">
7309 <?php ob_start(); ?>
7310 <?php if ( 'continuation' == $continue_data['status'] ) : ?>
7311 <option value="continuation" selected="selected"><?php esc_html_e( 'Continuation', 'dlseller' ); ?></option>
7312 <option value="cancellation"><?php esc_html_e( 'Stop', 'dlseller' ); ?></option>
7313 <?php else : ?>
7314 <option value="cancellation" selected="selected"><?php esc_html_e( 'Cancellation', 'dlseller' ); ?></option>
7315 <option value="continuation"><?php esc_html_e( 'Resumption', 'dlseller' ); ?></option>
7316 <?php endif; ?>
7317 <?php
7318 $dlseller_status_options = ob_get_contents();
7319 ob_end_clean();
7320 $dlseller_status_options = apply_filters( 'usces_filter_continuation_charging_status_options', $dlseller_status_options, $continue_data );
7321 wel_esc_script_e( $dlseller_status_options );
7322 ?>
7323 </select></td>
7324 <td colspan="2"><input id="continuation-update" type="button" class="button button-primary" value="<?php _e( 'Update' ); ?>" /></td>
7325 </tr>
7326 </table>
7327 <?php do_action( 'usces_action_continuation_charging_information', $continue_data, $member_id, $order_id ); ?>
7328 </td>
7329 </tr>
7330 </table>
7331 </div><!-- searchBox -->
7332 </div><!-- tablesearch -->
7333 <table id="mainDataTable" class="new-table order-new-table">
7334 <thead>
7335 <tr>
7336 <th scope="col">&nbsp;</th>
7337 <th scope="col"><?php esc_html_e( 'Processing date', 'usces' ); ?></th>
7338 <th scope="col"><?php esc_html_e( 'Transaction ID', 'usces' ); ?></th>
7339 <th scope="col"><?php esc_html_e( 'Settlement amount', 'usces' ); ?></th>
7340 <th scope="col"><?php esc_html_e( 'Processing classification', 'usces' ); ?></th>
7341 <th scope="col">&nbsp;</th>
7342 </tr>
7343 </thead>
7344 <?php
7345 $trading_id = '';
7346 foreach ( (array) $log_data as $data ) :
7347 if ( isset( $data['tracking_id'] ) ) :
7348 if ( $trading_id == $data['tracking_id'] ) :
7349 continue;
7350 endif;
7351 $trading_id = $data['tracking_id'];
7352 endif;
7353 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id, RESULT_STATUS_ALL );
7354 if ( $latest_log ) :
7355 $payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
7356 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
7357 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) :
7358 $status = 'reference_error';
7359 $class = ' card-error';
7360 $status_name = $this->get_status_name( $status );
7361 $amount = usces_crform( $latest_log['amount'], false, true, 'return', true );
7362 else :
7363 $payment_status = $settlement_ref['payment_status'];
7364 $status = $this->get_status( $payment_status );
7365 $class = ' card-' . $status;
7366 $status_name = $this->get_status_name( $payment_status );
7367 $amount = usces_crform( $settlement_ref['payment_amount'], false, true, 'return', true );
7368 endif;
7369 ?>
7370 <tbody>
7371 <tr>
7372 <td><?php echo esc_html( $num ); ?></td>
7373 <td><?php echo esc_html( $data['datetime'] ); ?></td>
7374 <td><?php echo esc_html( $trading_id ); ?></td>
7375 <td class="amount"><?php echo esc_attr( $amount ); ?></td>
7376 <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>
7377 <td>
7378 <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' ); ?>">
7379 </td>
7380 </tr>
7381 </tbody>
7382 <?php
7383 $num--;
7384 endif;
7385 endforeach;
7386 ?>
7387 </table>
7388 </div><!--datatable-->
7389 <input name="member_id" type="hidden" id="member_id" value="<?php echo esc_attr( $member_id ); ?>" />
7390 <input name="order_id" type="hidden" id="order_id" value="<?php echo esc_attr( $order_id ); ?>" />
7391 <input name="con_id" type="hidden" id="con_id" value="<?php echo esc_attr( $con_id ); ?>" />
7392 <input name="usces_referer" type="hidden" id="usces_referer" value="<?php echo urlencode( $curent_url ); ?>" />
7393 <?php wp_nonce_field( 'order_edit', 'wc_nonce' ); ?>
7394 </div><!--usces_admin-->
7395 </div><!--wrap-->
7396 <?php
7397 $order_action = 'edit';
7398 $cart = array();
7399 $action_args = compact( 'order_action', 'order_id', 'cart' );
7400 $this->settlement_dialog( $order_data, $action_args );
7401 include ABSPATH . 'wp-admin/admin-footer.php';
7402 }
7403
7404 /**
7405 * 自動継続課金処理
7406 * dlseller_action_do_continuation_charging
7407 *
7408 * @param string $today Today.
7409 * @param int $member_id Member ID.
7410 * @param int $order_id Order number.
7411 * @param array $continue_data Continuation data.
7412 */
7413 public function auto_continuation_charging( $today, $member_id, $order_id, $continue_data ) {
7414 global $usces;
7415
7416 $acting_opts = $this->get_acting_settings();
7417 if ( ! usces_is_membersystem_state() || 'on' != $acting_opts['stock_card_mode'] ) {
7418 return;
7419 }
7420
7421 if ( 0 >= $continue_data['price'] ) {
7422 return;
7423 }
7424
7425 if ( 'acting_paygent_card' != $continue_data['acting'] ) {
7426 return;
7427 }
7428
7429 $order_data = $usces->get_order_data( $order_id, 'direct' );
7430 if ( ! $order_data || $usces->is_status( 'cancel', $order_data['order_status'] ) ) {
7431 return;
7432 }
7433
7434 $trading_id = usces_acting_key();
7435 $customer = $this->customer_ref( $member_id );
7436 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id && isset( $customer['customer_card_id'] ) ) {
7437 $telegram_kind = PAYGENT_CREDIT;
7438 $amount = usces_crform( $continue_data['price'], false, false, 'return', false );
7439
7440 $pm = Paygent_Module::get_instance();
7441 $pm->init();
7442 $pm->req_put( 'trading_id', $trading_id );
7443 $pm->req_put( 'payment_amount', $amount );
7444 $pm->req_put( 'payment_class', '10' );
7445 $pm->req_put( '3dsecure_ryaku', '1' );
7446 $pm->req_put( 'stock_card_mode', '1' );
7447 $pm->req_put( 'customer_id', $member_id );
7448 $pm->req_put( 'customer_card_id', $customer['customer_card_id'] );
7449 $pm->req_put( 'sales_mode', $acting_opts['sales_mode_dlseller'] );
7450
7451 $result_post = $pm->post( $telegram_kind );
7452 $result_status = $pm->get_result_status();
7453 if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
7454 $response_data = array(
7455 'result' => $result_post,
7456 'result_status' => $result_status,
7457 'response_code' => $pm->get_response_code(),
7458 'response_detail' => $pm->get_response_detail(),
7459 'result_message' => $pm->get_result_message(),
7460 );
7461 $response_code = ( true !== $result_post ) ? $result_post : $pm->get_response_code();
7462 $log = array(
7463 'acting' => 'paygent_card',
7464 'key' => $trading_id,
7465 'result' => $response_code,
7466 'data' => $response_data,
7467 );
7468 usces_save_order_acting_error( $log );
7469 $this->save_acting_log( $response_data, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
7470 $this->auto_settlement_error_mail( $member_id, $order_id, $response_data, $continue_data );
7471 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $response_data );
7472 } else {
7473 $response_data = $pm->get_response_data();
7474 $payment_id = ( isset( $response_data['payment_id'] ) ) ? $response_data['payment_id'] : '';
7475 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
7476 $settlement_ref = apply_filters( 'usces_filter_paygent_card_auto_continuation_charging_log', $settlement_ref, $order_id, $trading_id );
7477 if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
7478 $this->save_acting_log( $settlement_ref, 'paygent_card', 'reference_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
7479 } else {
7480 $this->save_acting_log( $settlement_ref, 'paygent_card', $settlement_ref['payment_status'], RESULT_STATUS_NORMAL, $order_id, $trading_id );
7481 }
7482 $this->auto_settlement_mail( $member_id, $order_id, $settlement_ref, $continue_data );
7483 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $settlement_ref );
7484 }
7485 } else {
7486 $result = ( isset( $customer['result'] ) ) ? $customer['result'] : 'error';
7487 $log = array(
7488 'acting' => 'paygent_card(member_process)',
7489 'key' => $member_id,
7490 'result' => $result,
7491 'data' => $customer,
7492 );
7493 usces_save_order_acting_error( $log );
7494 if ( ! isset( $customer['payment_type'] ) ) {
7495 $customer['payment_type'] = PAYMENT_TYPE_CREDIT;
7496 }
7497 $this->save_acting_log( $customer, 'paygent_card', 'customer_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
7498 $this->auto_settlement_error_mail( $member_id, $order_id, $customer, $continue_data );
7499 do_action( 'usces_action_auto_continuation_charging', $member_id, $order_id, $continue_data, $customer );
7500 }
7501 }
7502
7503 /**
7504 * 自動継続課金処理メール(正常)
7505 *
7506 * @param int $member_id Member ID.
7507 * @param int $order_id Order number.
7508 * @param array $data Response data.
7509 * @param array $continue_data Continuation data.
7510 */
7511 public function auto_settlement_mail( $member_id, $order_id, $data, $continue_data ) {
7512 global $usces;
7513
7514 $acting_opts = $this->get_acting_settings();
7515 $order_data = $usces->get_order_data( $order_id, 'direct' );
7516 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data, false );
7517
7518 if ( 'on' == $acting_opts['auto_settlement_mail'] ) {
7519 $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 );
7520 $member_info = $usces->get_member_info( $member_id );
7521 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
7522 $mail_data = usces_mail_data();
7523 $mail_header = '';
7524 if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
7525 $mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
7526 }
7527 $mail_header .= __( 'We will report automated accounting process was carried out as follows.', 'usces' ) . "\r\n\r\n";
7528 $mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
7529 $message = apply_filters( 'usces_filter_paygent_auto_settlement_mail_header', $mail_header, $member_id, $order_id, $order_data, $data, $continue_data ) .
7530 apply_filters( 'usces_filter_paygent_auto_settlement_mail_body', $mail_body, $member_id, $order_id, $order_data, $data, $continue_data ) .
7531 apply_filters( 'usces_filter_paygent_auto_settlement_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $data, $continue_data );
7532 $headers = apply_filters( 'usces_filter_paygent_auto_settlement_mail_headers', '' );
7533 $to_customer = array(
7534 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
7535 'to_address' => $member_info['mem_email'],
7536 'from_name' => get_option( 'blogname' ),
7537 'from_address' => $usces->options['sender_mail'],
7538 'reply_name' => get_option( 'blogname' ),
7539 'reply_to' => usces_get_first_order_mail(),
7540 'return_path' => $usces->options['sender_mail'],
7541 'subject' => $subject,
7542 'message' => do_shortcode( $message ),
7543 'headers' => $headers,
7544 );
7545 usces_send_mail( $to_customer );
7546 }
7547
7548 $ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
7549 $this->continuation_charging_mail['OK'] = $ok + 1;
7550 $this->continuation_charging_mail['mail'][] = $mail_body;
7551 }
7552
7553 /**
7554 * 自動継続課金処理メール(エラー)
7555 *
7556 * @param int $member_id Member ID.
7557 * @param int $order_id Order number.
7558 * @param array $data Response data.
7559 * @param array $continue_data Continuation data.
7560 */
7561 public function auto_settlement_error_mail( $member_id, $order_id, $data, $continue_data ) {
7562 global $usces;
7563
7564 $acting_opts = $this->get_acting_settings();
7565 $order_data = $usces->get_order_data( $order_id, 'direct' );
7566 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data, false );
7567
7568 if ( 'on' == $acting_opts['auto_settlement_mail'] ) {
7569 $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 );
7570 $member_info = $usces->get_member_info( $member_id );
7571 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
7572 $mail_data = usces_mail_data();
7573 $mail_header = '';
7574 if ( isset( $usces->options['put_customer_name'] ) && 1 === (int) $usces->options['put_customer_name'] ) {
7575 $mail_header .= sprintf( __( 'Dear %s', 'usces' ), $name ) . "\r\n\r\n";
7576 }
7577 $mail_header .= __( 'We will reported that an error occurred in automated accounting process.', 'usces' ) . "\r\n\r\n";
7578 $mail_footer = __( 'If you have any questions, please contact us.', 'usces' ) . "\r\n\r\n" . $mail_data['footer']['thankyou'];
7579 $message = apply_filters( 'usces_filter_paygent_auto_settlement_error_mail_header', $mail_header, $member_id, $order_id, $order_data, $data, $continue_data ) .
7580 apply_filters( 'usces_filter_paygent_auto_settlement_error_mail_body', $mail_body, $member_id, $order_id, $order_data, $data, $continue_data ) .
7581 apply_filters( 'usces_filter_paygent_auto_settlement_error_mail_footer', $mail_footer, $member_id, $order_id, $order_data, $data, $continue_data );
7582 $headers = apply_filters( 'usces_filter_paygent_auto_settlement_error_mail_headers', '' );
7583 $to_customer = array(
7584 'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $name ),
7585 'to_address' => $member_info['mem_email'],
7586 'from_name' => get_option( 'blogname' ),
7587 'from_address' => $usces->options['sender_mail'],
7588 'reply_name' => get_option( 'blogname' ),
7589 'reply_to' => usces_get_first_order_mail(),
7590 'return_path' => $usces->options['sender_mail'],
7591 'subject' => $subject,
7592 'message' => do_shortcode( $message ),
7593 'headers' => $headers,
7594 );
7595 usces_send_mail( $to_customer );
7596 }
7597
7598 $error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
7599 $this->continuation_charging_mail['NG'] = $error + 1;
7600 $this->continuation_charging_mail['mail'][] = $mail_body;
7601 }
7602
7603 /**
7604 * 自動継続課金処理メール本文
7605 *
7606 * @param int $member_id Member ID.
7607 * @param int $order_id Order number.
7608 * @param array $order_data Order data.
7609 * @param array $data Response data.
7610 * @param array $continue_data Continuation data.
7611 * @param boolean $html
7612 * @return string
7613 */
7614 public function auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data, $html = true ) {
7615 global $usces;
7616
7617 $member_info = $usces->get_member_info( $member_id );
7618 $name = usces_localized_name( $member_info['mem_name1'], $member_info['mem_name2'], 'return' );
7619 $contracted_date = ( isset( $continue_data['contractedday'] ) ) ? $continue_data['contractedday'] : '';
7620 $charged_date = ( isset( $continue_data['chargedday'] ) ) ? $continue_data['chargedday'] : '';
7621
7622 $cart = usces_get_ordercartdata( $order_id );
7623 if ( is_array( $cart ) && 0 < count( $cart ) ) {
7624 $cart_row = current( $cart );
7625 $item_name = $usces->getCartItemName_byOrder( $cart_row );
7626 $options = ( isset( $cart_row['options'] ) ) ? $cart_row['options'] : array();
7627 }
7628
7629 if ( usces_is_html_mail() && $html ) {
7630 $message = '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;"><tbody>';
7631 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7632 $message .= __( 'Order ID', 'dlseller' );
7633 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7634 $message .= $order_id;
7635 $message .= '</td></tr>';
7636
7637 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7638 $message .= __( 'Application Date', 'dlseller' );
7639 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7640 $message .= $order_data['order_date'];
7641 $message .= '</td></tr>';
7642
7643 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7644 $message .= __( 'Member ID', 'dlseller' );
7645 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7646 $message .= $member_id;
7647 $message .= '</td></tr>';
7648
7649 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7650 $message .= __( 'Contractor name', 'dlseller' );
7651 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7652 $message .= sprintf( _x( '%s', 'honorific', 'usces' ), $name );
7653 $message .= '</td></tr>';
7654 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7655 $message .= __( 'Items', 'usces' );
7656 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7657 $message .= $item_name;
7658 if ( is_array( $options ) && 0 < count( $options ) ) {
7659 $optstr = '';
7660 foreach ( $options as $key => $value ) {
7661 if ( ! empty( $key ) ) {
7662 $key = urldecode( $key );
7663 $value = wel_safe_maybe_unserialize( $value );
7664 if ( is_array( $value ) ) {
7665 $c = '';
7666 $optstr .= '( ' . $key . ' : ';
7667 foreach ( $value as $v ) {
7668 $optstr .= $c . rawurldecode( $v );
7669 $c = ', ';
7670 }
7671 $optstr .= ' )<br>';
7672 } else {
7673 $optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . ' )<br>';
7674 }
7675 }
7676 }
7677 $message .= $optstr;
7678 }
7679 $message .= '</td></tr>';
7680
7681 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7682 $message .= __( 'Settlement amount', 'usces' );
7683 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7684 $message .= usces_crform( $continue_data['price'], true, false, 'return' );
7685 $message .= '</td></tr>';
7686 if ( isset( $data['reminder'] ) ) {
7687 if ( ! empty( $charged_date ) ) {
7688 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7689 $message .= __( 'Next Withdrawal Date', 'dlseller' );
7690 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7691 $message .= $charged_date;
7692 $message .= '</td></tr>';
7693 }
7694 if ( ! empty( $contracted_date ) ) {
7695 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7696 $message .= __( 'Renewal Date', 'dlseller' );
7697 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7698 $message .= $contracted_date;
7699 $message .= '</td></tr>';
7700 }
7701 } else {
7702 if ( ! empty( $charged_date ) ) {
7703 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7704 $message .= __( 'Next Withdrawal Date', 'dlseller' );
7705 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7706 $message .= $charged_date;
7707 $message .= '</td></tr>';
7708 }
7709 if ( ! empty( $contracted_date ) ) {
7710 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7711 $message .= __( 'Renewal Date', 'dlseller' );
7712 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7713 $message .= $contracted_date;
7714 $message .= '</td></tr>';
7715 }
7716
7717 if ( isset( $data['result_status'] ) && RESULT_STATUS_ERROR == $data['result_status'] ) {
7718 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7719 $message .= __( 'Result', 'usces' );
7720 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7721 $message .= __( 'Error', 'usces' );
7722 $message .= '</td></tr>';
7723 } else {
7724 $message .= '<tr><td style="background-color: #f9f9f9; padding: 12px; width: 33%; border: 1px solid #ddd; text-align: left;">';
7725 $message .= __( 'Result', 'usces' );
7726 $message .= '</td><td style="padding: 12px; width: 67%; border: 1px solid #ddd;">';
7727 $message .= __( 'Normal done', 'usces' );
7728 $message .= '</td></tr>';
7729 }
7730 }
7731 $message .= '</tbody></table>';
7732
7733 } else {
7734 $message = usces_mail_line( 2 ); // --------------------
7735 $message .= __( 'Order ID', 'dlseller' ) . ' : ' . $order_id . "\r\n";
7736 $message .= __( 'Application Date', 'dlseller' ) . ' : ' . $order_data['order_date'] . "\r\n";
7737 $message .= __( 'Member ID', 'dlseller' ) . ' : ' . $member_id . "\r\n";
7738 $message .= __( 'Contractor name', 'dlseller' ) . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), $name ) . "\r\n";
7739
7740 $message .= __( 'Items', 'usces' ) . ' : ' . $item_name . "\r\n";
7741 if ( is_array( $options ) && 0 < count( $options ) ) {
7742 $optstr = '';
7743 foreach ( $options as $key => $value ) {
7744 if ( ! empty( $key ) ) {
7745 $key = urldecode( $key );
7746 $value = wel_safe_maybe_unserialize( $value );
7747 if ( is_array( $value ) ) {
7748 $c = '';
7749 $optstr .= '( ' . $key . ' : ';
7750 foreach ( $value as $v ) {
7751 $optstr .= $c . rawurldecode( $v );
7752 $c = ', ';
7753 }
7754 $optstr .= " )\r\n";
7755 } else {
7756 $optstr .= '( ' . $key . ' : ' . rawurldecode( $value ) . " )\r\n";
7757 }
7758 }
7759 }
7760 $message .= $optstr;
7761 }
7762
7763 $message .= __( 'Settlement amount', 'usces' ) . ' : ' . usces_crform( $continue_data['price'], true, false, 'return' ) . "\r\n";
7764 if ( ! empty( $charged_date ) ) {
7765 $message .= __( 'Next Withdrawal Date', 'dlseller' ) . ' : ' . $charged_date . "\r\n";
7766 }
7767 if ( ! empty( $contracted_date ) ) {
7768 $message .= __( 'Renewal Date', 'dlseller' ) . ' : ' . $contracted_date . "\r\n";
7769 }
7770 if ( isset( $data['reminder'] ) ) {
7771 } else {
7772 $message .= "\r\n";
7773 if ( isset( $data['result_status'] ) && RESULT_STATUS_ERROR == $data['result_status'] ) {
7774 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Error', 'usces' ) . "\r\n";
7775 if ( isset( $data['res_err_code'] ) ) {
7776 $message .= 'res_err_code : ' . $data['res_err_code'] . "\r\n";
7777 }
7778 } else {
7779 $message .= __( 'Result', 'usces' ) . ' : ' . __( 'Normal done', 'usces' ) . "\r\n";
7780 }
7781 }
7782 $message .= usces_mail_line( 2 ) . "\r\n"; // --------------------
7783 }
7784 return $message;
7785 }
7786
7787 /**
7788 * 自動継続課金処理
7789 * dlseller_action_do_continuation
7790 *
7791 * @param string $today Today.
7792 * @param array $todays_charging Charged data.
7793 */
7794 public function do_auto_continuation( $today, $todays_charging ) {
7795 global $usces;
7796
7797 if ( empty( $todays_charging ) ) {
7798 return;
7799 }
7800
7801 $ok = ( empty( $this->continuation_charging_mail['OK'] ) ) ? 0 : $this->continuation_charging_mail['OK'];
7802 $error = ( empty( $this->continuation_charging_mail['NG'] ) ) ? 0 : $this->continuation_charging_mail['NG'];
7803 $admin_subject = apply_filters( 'usces_filter_paygent_autobilling_email_admin_subject', __( 'Automatic Continuing Charging Process Result', 'usces' ) . ' ' . $today, $today );
7804 $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' ) );
7805 $admin_message = __( 'Report that automated accounting process has been completed.', 'usces' ) . "\r\n\r\n"
7806 . __( 'Processing date', 'usces' ) . ' : ' . date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "\r\n"
7807 . __( 'Normal done', 'usces' ) . ' : ' . $ok . "\r\n"
7808 . __( 'Abnormal done', 'usces' ) . ' : ' . $error . "\r\n\r\n";
7809 foreach ( (array) $this->continuation_charging_mail['mail'] as $mail ) {
7810 $admin_message .= $mail . "\r\n";
7811 }
7812 $admin_message .= $admin_footer . "\r\n";
7813
7814 $to_admin = array(
7815 'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ),
7816 'to_address' => $usces->options['order_mail'],
7817 'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ),
7818 'from_address' => $usces->options['sender_mail'],
7819 'reply_name' => get_option( 'blogname' ),
7820 'reply_to' => usces_get_first_order_mail(),
7821 'return_path' => $usces->options['sender_mail'],
7822 'subject' => $admin_subject,
7823 'message' => do_shortcode( $admin_message ),
7824 );
7825 usces_send_mail( $to_admin );
7826 unset( $this->continuation_charging_mail );
7827 }
7828
7829 /**
7830 * 課金日通知メール
7831 * dlseller_filter_reminder_mail_body
7832 *
7833 * @param string $mail_body Message body.
7834 * @param int $order_id Order number.
7835 * @param array $continue_data Continuation data.
7836 * @return string
7837 */
7838 public function reminder_mail_body( $mail_body, $order_id, $continue_data ) {
7839 global $usces;
7840
7841 $member_id = $continue_data['member_id'];
7842 $order_id = $continue_data['order_id'];
7843 $order_data = $usces->get_order_data( $order_id, 'direct' );
7844 $data = array( 'reminder' => 'reminder' );
7845 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data );
7846 return $mail_body;
7847 }
7848
7849 /**
7850 * 契約更新日通知メール
7851 * dlseller_filter_contract_renewal_mail_body
7852 *
7853 * @param string $mail_body Message body.
7854 * @param int $order_id Order number.
7855 * @param array $continue_data Continuation data.
7856 * @return string
7857 */
7858 public function contract_renewal_mail_body( $mail_body, $order_id, $continue_data ) {
7859 global $usces;
7860
7861 $member_id = $continue_data['member_id'];
7862 $order_data = $usces->get_order_data( $order_id, 'direct' );
7863 $data = array( 'reminder' => 'contract_renewal' );
7864 $mail_body = $this->auto_settlement_message( $member_id, $order_id, $order_data, $data, $continue_data );
7865 return $mail_body;
7866 }
7867
7868 /**
7869 * 継続課金会員データ取得
7870 *
7871 * @param int $member_id Member ID.
7872 * @param int $order_id Order number.
7873 * @return array
7874 */
7875 private function get_continuation_data( $member_id, $order_id ) {
7876 global $wpdb;
7877
7878 $query = $wpdb->prepare(
7879 "SELECT
7880 `con_id` AS `con_id`,
7881 `con_acting` AS `acting`,
7882 `con_order_price` AS `order_price`,
7883 `con_price` AS `price`,
7884 `con_next_charging` AS `chargedday`,
7885 `con_next_contracting` AS `contractedday`,
7886 `con_startdate` AS `startdate`,
7887 `con_status` AS `status`
7888 FROM {$wpdb->prefix}usces_continuation
7889 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7890 $order_id,
7891 $member_id
7892 );
7893 $data = $wpdb->get_row( $query, ARRAY_A );
7894 return $data;
7895 }
7896
7897 /**
7898 * 継続課金会員データ更新
7899 *
7900 * @param int $member_id Member ID.
7901 * @param int $order_id Order number.
7902 * @param array $data Continuation data.
7903 * @param boolean $stop Stop continuous billing.
7904 * @return boolean
7905 */
7906 private function update_continuation_data( $member_id, $order_id, $data, $stop = false ) {
7907 global $wpdb;
7908
7909 if ( $stop ) {
7910 $query = $wpdb->prepare(
7911 "UPDATE {$wpdb->prefix}usces_continuation SET
7912 `con_status` = 'cancellation'
7913 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7914 $order_id,
7915 $member_id
7916 );
7917 } else {
7918 $query = $wpdb->prepare(
7919 "UPDATE {$wpdb->prefix}usces_continuation SET
7920 `con_price` = %f,
7921 `con_next_charging` = %s,
7922 `con_next_contracting` = %s,
7923 `con_status` = %s
7924 WHERE `con_order_id` = %d AND `con_member_id` = %d",
7925 $data['price'],
7926 $data['chargedday'],
7927 $data['contractedday'],
7928 $data['status'],
7929 $order_id,
7930 $member_id
7931 );
7932 }
7933 $res = $wpdb->query( $query );
7934 return $res;
7935 }
7936
7937 /**
7938 * 管理画面メッセージ
7939 * wcad_filter_admin_notices
7940 *
7941 * @param string $msg Admin notice message.
7942 * @return string
7943 */
7944 public function admin_notices_autodelivery( $msg ) {
7945 global $usces;
7946
7947 $acting_opts = $this->get_acting_settings();
7948 if ( isset( $acting_opts['card_activate'] ) && 'off' != $acting_opts['card_activate'] && 'on' == $acting_opts['stock_card_mode'] ) {
7949 $msg = '';
7950 } else {
7951 $msg = '<div class="error"><p>「クレジット決済設定」にて、ペイジェントのカード�
7952 報お預りモードを「利用する」に設定してください。</p></div>';
7953 }
7954 return $msg;
7955 }
7956
7957 /**
7958 * 発送�
7959 �リスト利用可能決済
7960 * wcad_filter_shippinglist_acting
7961 *
7962 * @param string $acting Payment method.
7963 * @return string
7964 */
7965 public function set_shippinglist_acting( $acting ) {
7966 $acting = 'acting_paygent_card';
7967 return $acting;
7968 }
7969
7970 /**
7971 * 管理画面利用可能決済メッセージ
7972 * wcad_filter_available_regular_payment_method
7973 *
7974 * @param array $payment_method Payment method.
7975 * @return array
7976 */
7977 public function available_regular_payment_method( $payment_method ) {
7978 $payment_method[] = 'acting_paygent_card';
7979 return $payment_method;
7980 }
7981
7982 /**
7983 * 定期購�
7984 �決済処理
7985 * wcad_action_reg_auto_orderdata
7986 *
7987 * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $total_amount, $reg_id ).
7988 */
7989 public function register_auto_orderdata( $args ) {
7990 global $usces;
7991 extract( $args );
7992
7993 $acting_opts = $this->get_acting_settings();
7994 if ( ! usces_is_membersystem_state() || 'on' != $acting_opts['stock_card_mode'] ) {
7995 return;
7996 }
7997
7998 if ( 0 >= $total_amount ) {
7999 return;
8000 }
8001
8002 $acting_flg = ( isset( $payments['settlement'] ) ) ? $payments['settlement'] : '';
8003 if ( 'acting_paygent_card' != $acting_flg ) {
8004 return;
8005 }
8006
8007 $settltment_errmsg = '';
8008
8009 $trading_id = usces_acting_key();
8010 $customer = $this->customer_ref( $member_id );
8011 if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id && isset( $customer['customer_card_id'] ) ) {
8012 $telegram_kind = PAYGENT_CREDIT;
8013 $amount = usces_crform( $total_amount, false, false, 'return', false );
8014
8015 $pm = Paygent_Module::get_instance();
8016 $pm->init();
8017 $pm->req_put( 'trading_id', $trading_id );
8018 $pm->req_put( 'payment_amount', $amount );
8019 $pm->req_put( 'payment_class', '10' );
8020 $pm->req_put( '3dsecure_ryaku', '1' );
8021 $pm->req_put( 'stock_card_mode', '1' );
8022 $pm->req_put( 'customer_id', $member_id );
8023 $pm->req_put( 'customer_card_id', $customer['customer_card_id'] );
8024 $pm->req_put( 'sales_mode', $acting_opts['sales_mode'] );
8025
8026 $result_post = $pm->post( $telegram_kind );
8027 $result_status = $pm->get_result_status();
8028 if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
8029 $settltment_errmsg = __( '[Regular purchase] Settlement was not completed.', 'autodelivery' );
8030 $response_data = array(
8031 'result' => $result_post,
8032 'result_status' => $result_status,
8033 'response_code' => $pm->get_response_code(),
8034 'response_detail' => $pm->get_response_detail(),
8035 'result_message' => $pm->get_result_message(),
8036 );
8037 $response_code = ( true !== $result_post ) ? $result_post : $pm->get_response_code();
8038 $log = array(
8039 'acting' => 'paygent_card',
8040 'key' => $trading_id,
8041 'result' => $response_code,
8042 'data' => $response_data,
8043 );
8044 usces_save_order_acting_error( $log );
8045 $this->save_acting_log( $response_data, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
8046 do_action( 'usces_action_register_auto_orderdata', $args, $response_data );
8047 } else {
8048 $response_data = $pm->get_response_data();
8049 $payment_id = ( isset( $response_data['payment_id'] ) ) ? $response_data['payment_id'] : '';
8050 $settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
8051 $usces->set_order_meta_value( $acting_flg, usces_serialize( $settlement_ref ), $order_id );
8052 $usces->set_order_meta_value( 'trading_id', $trading_id, $order_id );
8053 $usces->set_order_meta_value( 'wc_trans_id', $trading_id, $order_id );
8054 do_action( 'usces_action_register_auto_orderdata', $args, $settlement_ref );
8055 }
8056 } else {
8057 $settltment_errmsg = __( '[Regular purchase] Member information acquisition error.', 'autodelivery' );
8058 $result = ( isset( $customer['result'] ) ) ? $customer['result'] : 'error';
8059 $log = array(
8060 'acting' => 'paygent_card(member_process)',
8061 'key' => $member_id,
8062 'result' => $result,
8063 'data' => $customer,
8064 );
8065 usces_save_order_acting_error( $log );
8066 if ( ! isset( $customer['payment_type'] ) ) {
8067 $customer['payment_type'] = PAYMENT_TYPE_CREDIT;
8068 }
8069 $this->save_acting_log( $customer, 'paygent_card', 'customer_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
8070 do_action( 'usces_action_register_auto_orderdata', $args, $customer );
8071 }
8072 if ( '' != $settltment_errmsg ) {
8073 $settlement = array(
8074 'settltment_status' => __( 'Failure', 'autodelivery' ),
8075 'settltment_errmsg' => $settltment_errmsg,
8076 'trading_id' => $trading_id,
8077 );
8078 $usces->set_order_meta_value( $acting_flg, usces_serialize( $settlement ), $order_id );
8079 $usces->set_order_meta_value( 'trading_id', $trading_id, $order_id );
8080 $usces->set_order_meta_value( 'wc_trans_id', $trading_id, $order_id );
8081 wcad_settlement_error_mail( $order_id, $settltment_errmsg );
8082 }
8083 }
8084
8085 /**
8086 * Save session data.
8087 *
8088 * @param string $trading_id Trading ID.
8089 * @param array $post_data Post data.
8090 * @return boolean
8091 */
8092 private function save_post_data( $trading_id, $post_data ) {
8093 global $wpdb;
8094
8095 $query = $wpdb->prepare(
8096 "INSERT INTO {$wpdb->prefix}usces_log ( `datetime`, `log`, `log_type`, `log_key` ) VALUES ( %s, %s, %s, %s )",
8097 current_time( 'mysql' ),
8098 usces_serialize( $post_data ),
8099 'acting_post_data',
8100 $trading_id
8101 );
8102 $res = $wpdb->query( $query );
8103 return $res;
8104 }
8105
8106 /**
8107 * Get session data.
8108 *
8109 * @param string $trading_id Trading ID.
8110 * @return array
8111 */
8112 private function get_post_data( $trading_id ) {
8113 global $wpdb;
8114
8115 $query = $wpdb->prepare( "SELECT `log` FROM {$wpdb->prefix}usces_log WHERE `log_type` = %s AND `log_key` = %s", 'acting_post_data', $trading_id );
8116 $data = $wpdb->get_var( $query );
8117 return usces_unserialize( $data );
8118 }
8119
8120 /**
8121 * Delete session data.
8122 *
8123 * @param string $trading_id Trading ID.
8124 */
8125 private function delete_post_data( $trading_id ) {
8126 global $wpdb;
8127
8128 $query = $wpdb->prepare( "DELETE FROM {$wpdb->prefix}usces_log WHERE `log_type` = %s AND `log_key` = %s", 'acting_post_data', $trading_id );
8129 $wpdb->query( $query );
8130 }
8131
8132 /**
8133 * サービスタイプ取得
8134 *
8135 * @param string $acting Acting type.
8136 * @return string
8137 */
8138 private function get_service_type( $acting ) {
8139 $service_type = '';
8140 $acting_opts = $this->get_acting_settings();
8141 $activation = $acting_opts[ $acting . '_activate' ];
8142 if ( 'on' == $activation ) {
8143 $service_type = 'link';
8144 } elseif ( 'module' == $activation ) {
8145 $service_type = 'module';
8146 }
8147 return $service_type;
8148 }
8149
8150 /**
8151 * 決済オプション取得
8152 *
8153 * @return array
8154 */
8155 protected function get_acting_settings() {
8156 global $usces;
8157
8158 $acting_settings = ( isset( $usces->options['acting_settings'][ $this->paymod_id ] ) ) ? $usces->options['acting_settings'][ $this->paymod_id ] : array();
8159 return $acting_settings;
8160 }
8161
8162 /**
8163 * 受注ID 取得
8164 *
8165 * @param string $trading_id Trading ID.
8166 * @return int
8167 */
8168 protected function get_order_id( $trading_id ) {
8169 global $wpdb;
8170
8171 $query = $wpdb->prepare( "SELECT `order_id` FROM {$wpdb->prefix}usces_order_meta WHERE `meta_key` = %s AND `meta_value` = %s", 'trading_id', $trading_id );
8172 $order_id = $wpdb->get_var( $query );
8173 return $order_id;
8174 }
8175
8176 /**
8177 * マーチャント取引ID 取得
8178 *
8179 * @param int $order_id Order number.
8180 * @return string
8181 */
8182 protected function get_trading_id( $order_id ) {
8183 global $usces;
8184
8185 $trading_id = $usces->get_order_meta_value( 'trading_id', $order_id );
8186 return $trading_id;
8187 }
8188
8189 /**
8190 * 受注ステータス取得
8191 *
8192 * @param int $order_id Order number.
8193 * @return string
8194 */
8195 protected function get_order_status( $order_id ) {
8196 global $wpdb;
8197
8198 $query = $wpdb->prepare( "SELECT LOCATE( 'receipted', `order_status` ) FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
8199 $order_status = $wpdb->get_var( $query );
8200 return $order_status;
8201 }
8202
8203 /**
8204 * 受注データ支払方法取得
8205 *
8206 * @param int $order_id Order number.
8207 * @return string
8208 */
8209 protected function get_order_acting_flg( $order_id ) {
8210 global $wpdb;
8211
8212 $query = $wpdb->prepare( "SELECT `order_payment_name` FROM {$wpdb->prefix}usces_order WHERE `ID` = %d", $order_id );
8213 $order_payment_name = $wpdb->get_var( $query );
8214 $payment = usces_get_payments_by_name( $order_payment_name );
8215 $acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
8216 return $acting_flg;
8217 }
8218
8219 /**
8220 * 決済ログ取得
8221 *
8222 * @param int $order_id Order number.
8223 * @param string $trading_id Trading ID.
8224 * @param string $result Result.
8225 * @return array
8226 */
8227 public function get_acting_log( $order_id = 0, $trading_id = 0, $result = RESULT_STATUS_NORMAL ) {
8228 global $wpdb;
8229
8230 if ( empty( $order_id ) ) {
8231 if ( RESULT_STATUS_NORMAL == $result ) {
8232 $query = $wpdb->prepare(
8233 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `tracking_id` = %s AND `result` = %s ORDER BY `datetime` DESC, `ID` DESC",
8234 $trading_id,
8235 RESULT_STATUS_NORMAL
8236 );
8237 } else {
8238 $query = $wpdb->prepare(
8239 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `tracking_id` = %s ORDER BY `datetime` DESC, `ID` DESC",
8240 $trading_id
8241 );
8242 }
8243 } else {
8244 if ( empty( $trading_id ) ) {
8245 if ( RESULT_STATUS_NORMAL == $result ) {
8246 $query = $wpdb->prepare(
8247 "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",
8248 $order_id,
8249 $order_id,
8250 RESULT_STATUS_NORMAL
8251 );
8252 } else {
8253 $query = $wpdb->prepare(
8254 "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",
8255 $order_id,
8256 $order_id
8257 );
8258 }
8259 } else {
8260 if ( RESULT_STATUS_NORMAL == $result ) {
8261 $query = $wpdb->prepare(
8262 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d AND `tracking_id` = %s AND `result` = %s ORDER BY `datetime` DESC, `ID` DESC",
8263 $order_id,
8264 $trading_id,
8265 RESULT_STATUS_NORMAL
8266 );
8267 } else {
8268 $query = $wpdb->prepare(
8269 "SELECT * FROM {$wpdb->prefix}usces_acting_log WHERE `order_id` = %d AND `tracking_id` = %s ORDER BY `datetime` DESC, `ID` DESC",
8270 $order_id,
8271 $trading_id
8272 );
8273 }
8274 }
8275 }
8276 $log_data = $wpdb->get_results( $query, ARRAY_A );
8277 return $log_data;
8278 }
8279
8280 /**
8281 * 決済ログ出力
8282 *
8283 * @param string $log Log data.
8284 * @param string $acting Acting type.
8285 * @param string $status Status.
8286 * @param string $result Result.
8287 * @param int $order_id Order number.
8288 * @param string $trading_id Trading ID.
8289 * @return array
8290 */
8291 private function save_acting_log( $log, $acting, $status, $result, $order_id, $trading_id ) {
8292 global $wpdb;
8293
8294 if ( isset( $log['payment_amount'] ) ) {
8295 $amount = $log['payment_amount'];
8296 } elseif ( isset( $log['reduced_amount'] ) ) {
8297 $amount = $log['reduced_amount'];
8298 } elseif ( isset( $log['amount'] ) ) {
8299 $amount = $log['amount'];
8300 } else {
8301 $amount = 0;
8302 }
8303 if ( ! empty( $log['payment_date'] ) ) {
8304 $datetime = date( 'Y-m-d H:i:s', strtotime( $log['payment_date'] ) );
8305 } elseif ( ! empty( $log['payment_init_date'] ) ) {
8306 $datetime = date( 'Y-m-d H:i:s', strtotime( $log['payment_init_date'] ) );
8307 } else {
8308 $datetime = current_time( 'mysql' );
8309 }
8310 $query = $wpdb->prepare(
8311 "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 )",
8312 $datetime,
8313 usces_serialize( $log ),
8314 $acting,
8315 $status,
8316 $result,
8317 $amount,
8318 $order_id,
8319 $trading_id
8320 );
8321 $res = $wpdb->query( $query );
8322 return $res;
8323 }
8324
8325 /**
8326 * 最新処理取得
8327 *
8328 * @param int $order_id Order number.
8329 * @param string $trading_id Trading ID.
8330 * @param string $result Result.
8331 * @return array
8332 */
8333 public function get_acting_latest_log( $order_id, $trading_id, $result = RESULT_STATUS_NORMAL ) {
8334 $latest_log = array();
8335 $log_data = $this->get_acting_log( $order_id, $trading_id, $result );
8336 if ( $log_data ) {
8337 $data = current( $log_data );
8338 $log = usces_unserialize( $data['log'] );
8339 if ( isset( $log['payment_id'] ) ) {
8340 $payment_id = $log['payment_id'];
8341 } else {
8342 $payment_id = '';
8343 }
8344 $latest_log['acting'] = $data['acting'];
8345 $latest_log['status'] = $data['status'];
8346 $latest_log['result'] = $data['result'];
8347 $latest_log['log'] = $log;
8348 $latest_log['amount'] = $data['amount'];
8349 $latest_log['order_id'] = $data['order_id'];
8350 $latest_log['payment_id'] = $payment_id;
8351 $latest_log['trading_id'] = $data['tracking_id'];
8352 }
8353 return $latest_log;
8354 }
8355
8356 /**
8357 * 決済ステータス取得
8358 *
8359 * @param int $order_id Order number.
8360 * @param string $trading_id Trading ID.
8361 * @return string
8362 */
8363 private function get_payment_status( $order_id, $trading_id ) {
8364 global $wpdb;
8365
8366 $payment_status = '';
8367 $latest_log = $this->get_acting_latest_log( $order_id, $trading_id, RESULT_STATUS_ALL );
8368 if ( isset( $latest_log['status'] ) ) {
8369 $payment_status = $latest_log['status'];
8370 }
8371 return $payment_status;
8372 }
8373
8374 /**
8375 * 処理区分名称取得
8376 *
8377 * @param string $payment_status Payment status code.
8378 * @return string
8379 */
8380 private function get_status_name( $payment_status ) {
8381 $status_name = '';
8382 switch ( $payment_status ) {
8383 case STATUS_REQUESTED: /* 申込済 */
8384 $status_name = '申込済';
8385 break;
8386 case STATUS_AUTHORIZE_NG: /* オーソリNG */
8387 $status_name = 'オーソリNG';
8388 break;
8389 case STATUS_PAYMENT_EXPIRED: /* 支払期限切 */
8390 $status_name = '支払期限切';
8391 break;
8392 case STATUS_3DSECURE_INTERRUPTION: /* 3Dセキュア中断 */
8393 $status_name = '3Dセキュア中断';
8394 break;
8395 case STATUS_3DSECURE_CERTIFICATION: /* 3Dセキュア認証 */
8396 $status_name = '3Dセキュア認証';
8397 break;
8398 case STATUS_REGISTRATION_SUSPENDED: /* 申込中断 */
8399 $status_name = '申込中断';
8400 break;
8401 case STATUS_PAYMENT_INVALIDITY_NO_CLEAR: /* 支払期限切(消込対象外) */
8402 $status_name = '支払期限切(消込対象外)';
8403 break;
8404 case STATUS_AUTHORIZE_OK: /* オーソリOK */
8405 $status_name = 'オーソリOK';
8406 break;
8407 case STATUS_AUTHORIZE_COMPLETED: /* オーソリ完了 */
8408 $status_name = 'オーソリ完了';
8409 break;
8410 case STATUS_SALES_REQUEST_PENDING: /* 売上要求中 */
8411 $status_name = '売上要求中';
8412 break;
8413 case STATUS_AUTHORIZE_CANCELING: /* オーソリ取消中 */
8414 $status_name = 'オーソリ取消中';
8415 break;
8416 case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
8417 $status_name = 'オーソリ取消済';
8418 break;
8419 case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
8420 $status_name = 'オーソリ期限切';
8421 break;
8422 case STATUS_CLEARED: /* 消込済 */
8423 $status_name = '消込済';
8424 break;
8425 case STATUS_CLEARED_SALES_CANCEL_INVALIDITY: /* 消込済(売上取消期限切) */
8426 $status_name = '消込済(売上取消期限切)';
8427 break;
8428 case STATUS_SALES_CANCELING: /* 売上取消中 */
8429 $status_name = '売上取消中';
8430 break;
8431 case STATUS_PRELIMINARY_DETECTED: /* 速報検地済 */
8432 $status_name = '速報検地済';
8433 break;
8434 case STATUS_COMPLETE_CLEARED: /* 消込完了 */
8435 $status_name = '消込完了';
8436 break;
8437 case STATUS_SALES_CANCELING_TALLY: /* 売上取消集計中 */
8438 $status_name = '売上取消集計中';
8439 break;
8440 case STATUS_SALES_CANCELED: /* 売上取消済 */
8441 $status_name = '売上取消済';
8442 break;
8443 case STATUS_PRELIMINARY_CANCELED: /* 速報取消済 */
8444 $status_name = '速報取消済';
8445 break;
8446 case STATUS_COMPLETE_CANCELED: /* 取消完了 */
8447 $status_name = '取消完了';
8448 break;
8449 case PAYGENT_CREDIT: /* カード決済オーソリ */
8450 $status_name = 'カード決済オーソリ';
8451 break;
8452 case PAYGENT_AUTH_CANCEL: /* カード決済オーソリキャンセル */
8453 $status_name = 'カード決済オーソリキャンセル';
8454 break;
8455 case PAYGENT_CARD_COMMIT: /* カード決済売上 */
8456 $status_name = 'カード決済売上';
8457 break;
8458 case PAYGENT_CARD_COMMIT_CANCEL: /* カード決済売上キャンセル */
8459 $status_name = 'カード決済売上キャンセル';
8460 break;
8461 case PAYGENT_CARD_COMMIT_AUTH_REVISE: /* カード決済補正オーソリ */
8462 $status_name = 'カード決済補正オーソリ';
8463 break;
8464 case PAYGENT_CARD_COMMIT_REVISE: /* カード決済補正売上 */
8465 $status_name = 'カード決済補正売上';
8466 break;
8467 case PAYGENT_PAIDY_AUTH_CANCEL: /* Paidy オーソリキャンセル */
8468 $status_name = 'Paidyオーソリキャンセル';
8469 break;
8470 case PAYGENT_PAIDY_CAPTURE: /* Paidy 売上 */
8471 $status_name = 'Paidy売上';
8472 break;
8473 case PAYGENT_PAIDY_REFUND: /* Paidy 返金 */
8474 $status_name = 'Paidy返金';
8475 break;
8476 case 'bank_applying': /* 銀行ネット決済ASP */
8477 $status_name = '申込中';
8478 break;
8479 case 'reference_error': /* 決済履歴取得不可 */
8480 $status_name = '決済履歴取得不可';
8481 break;
8482 case 'payment_error': /* 決済エラー */
8483 $status_name = '決済エラー';
8484 break;
8485 case 'customer_error': /* 会員�
8486 報エラー */
8487 $status_name = '会員�
8488 報エラー';
8489 break;
8490 case 'error': /* その他エラー */
8491 $status_name = 'エラー';
8492 break;
8493 default:
8494 $status_name = $payment_status;
8495 }
8496 return $status_name;
8497 }
8498
8499 /**
8500 * 処理区分取得
8501 *
8502 * @param string $payment_status Payment status code.
8503 * @return string
8504 */
8505 private function get_status( $payment_status ) {
8506 $status = '';
8507 switch ( $payment_status ) {
8508 case STATUS_REQUESTED: /* 申込済 */
8509 $status = 'requested';
8510 break;
8511 case STATUS_AUTHORIZE_NG: /* オーソリNG */
8512 $status = 'authorize-ng';
8513 break;
8514 case STATUS_PAYMENT_EXPIRED: /* 支払期限切 */
8515 $status = 'payment-expired';
8516 break;
8517 case STATUS_3DSECURE_INTERRUPTION: /* 3Dセキュア中断 */
8518 $status = '3dsecure-interruption';
8519 break;
8520 case STATUS_3DSECURE_CERTIFICATION: /* 3Dセキュア認証 */
8521 $status = '3dsecure-certification';
8522 break;
8523 case STATUS_REGISTRATION_SUSPENDED: /* 申込中断 */
8524 $status = 'registration-suspended';
8525 break;
8526 case STATUS_PAYMENT_INVALIDITY_NO_CLEAR: /* 支払期限切(消込対象外) */
8527 $status = 'payment-invalidity-no-clear';
8528 break;
8529 case STATUS_AUTHORIZE_OK: /* オーソリOK */
8530 $status = 'authorize-ok';
8531 break;
8532 case STATUS_AUTHORIZE_COMPLETED: /* オーソリ完了 */
8533 $status = 'authorize-completed';
8534 break;
8535 case STATUS_SALES_REQUEST_PENDING: /* 売上要求中 */
8536 $status = 'sales-request-pending';
8537 break;
8538 case STATUS_AUTHORIZE_CANCELING: /* オーソリ取消中 */
8539 $status = 'authorize-canceling';
8540 break;
8541 case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
8542 $status = 'authorize-canceled';
8543 break;
8544 case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
8545 $status = 'authorize-expired';
8546 break;
8547 case STATUS_CLEARED: /* 消込済 */
8548 $status = 'cleared';
8549 break;
8550 case STATUS_CLEARED_SALES_CANCEL_INVALIDITY: /* 消込済(売上取消期限切) */
8551 $status = 'cleared-sales-cancel-invalidity';
8552 break;
8553 case STATUS_SALES_CANCELING: /* 売上取消中 */
8554 $status = 'being-sales-canceling';
8555 break;
8556 case STATUS_PRELIMINARY_DETECTED: /* 速報検地済 */
8557 $status = 'preliminary-detected';
8558 break;
8559 case STATUS_COMPLETE_CLEARED: /* 消込完了 */
8560 $status = 'complete-cleared';
8561 break;
8562 case STATUS_SALES_CANCELING_TALLY: /* 売上取消集計中 */
8563 $status = 'being-sales-canceling-tally';
8564 break;
8565 case STATUS_SALES_CANCELED: /* 売上取消済 */
8566 $status = 'sales-canceled';
8567 break;
8568 case STATUS_PRELIMINARY_CANCELED: /* 速報取消済 */
8569 $status = 'preliminary-canceled';
8570 break;
8571 case STATUS_COMPLETE_CANCELED: /* 取消完了 */
8572 $status = 'complete-canceled';
8573 break;
8574 case 'bank_applying': /* 銀行ネット決済ASP */
8575 $status = 'applying';
8576 break;
8577 case 'reference_error': /* 決済履歴取得不可 */
8578 $status = 'reference-error';
8579 break;
8580 case 'payment_error': /* 決済エラー */
8581 $status = 'payment-error';
8582 break;
8583 case 'customer_error': /* 会員�
8584 報エラー */
8585 $status = 'customer-error';
8586 break;
8587 case 'error': /* その他エラー */
8588 $status = 'error';
8589 break;
8590 default:
8591 $status = $payment_status;
8592 }
8593 return $status;
8594 }
8595
8596 /**
8597 * 決済結果参�
8598
8599 *
8600 * @param int $order_id Order number.
8601 * @param string $trading_id マーチャント取引ID.
8602 * @param string $payment_id 決済ID.
8603 * @return array
8604 */
8605 private function settlement_ref( $order_id, $trading_id, $payment_id = '' ) {
8606 $settlement = array();
8607
8608 $pm = Paygent_Module::get_instance();
8609 $pm->init();
8610 $pm->req_put( 'trading_id', $trading_id );
8611 if ( ! empty( $payment_id ) ) {
8612 $pm->req_put( 'payment_id', $payment_id );
8613 }
8614 $result = $pm->post( PAYGENT_REF );
8615 $result_status = $pm->get_result_status();
8616 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8617 $settlement['result'] = $result;
8618 $settlement['result_status'] = RESULT_STATUS_ERROR;
8619 $settlement['response_code'] = $pm->get_response_code();
8620 $settlement['response_detail'] = $pm->get_response_detail();
8621 $settlement['result_message'] = $pm->get_result_message();
8622 } else {
8623 $settlement = $pm->get_response_data();
8624 }
8625 return $settlement;
8626 }
8627
8628 /**
8629 * 決済要求
8630 *
8631 * @param string $telegram_kind 電文種別ID.
8632 * @param string $trading_id マーチャント取引ID.
8633 * @param string $payment_id 決済ID.
8634 * @return array
8635 */
8636 private function settlement_request( $telegram_kind, $trading_id, $payment_id ) {
8637 $settlement = array();
8638
8639 $pm = Paygent_Module::get_instance();
8640 $pm->init();
8641 $pm->req_put( 'trading_id', $trading_id );
8642 $pm->req_put( 'payment_id', $payment_id );
8643 $result = $pm->post( $telegram_kind );
8644 $result_status = $pm->get_result_status();
8645 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8646 $settlement['result'] = $result;
8647 $settlement['result_status'] = RESULT_STATUS_ERROR;
8648 $settlement['response_code'] = $pm->get_response_code();
8649 $settlement['response_detail'] = $pm->get_response_detail();
8650 $settlement['result_message'] = $pm->get_result_message();
8651 } else {
8652 $settlement = $pm->get_response_data();
8653 }
8654 return $settlement;
8655 }
8656
8657 /**
8658 * 決済金額補正要求
8659 *
8660 * @param string $telegram_kind 電文種別ID.
8661 * @param string $trading_id マーチャント取引ID.
8662 * @param string $payment_id 決済ID.
8663 * @param float $amount 決済金額.
8664 * @return array
8665 */
8666 private function settlement_request_revise( $telegram_kind, $trading_id, $payment_id, $amount ) {
8667 $settlement = array();
8668
8669 $pm = Paygent_Module::get_instance();
8670 $pm->init();
8671 $pm->req_put( 'trading_id', $trading_id );
8672 $pm->req_put( 'payment_id', $payment_id );
8673 $pm->req_put( 'payment_amount', $amount );
8674 $pm->req_put( 'reduction_flag', '0' );
8675 $result = $pm->post( $telegram_kind );
8676 $result_status = $pm->get_result_status();
8677 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8678 $settlement['result'] = $result;
8679 $settlement['result_status'] = RESULT_STATUS_ERROR;
8680 $settlement['response_code'] = $pm->get_response_code();
8681 $settlement['response_detail'] = $pm->get_response_detail();
8682 $settlement['result_message'] = $pm->get_result_message();
8683 } else {
8684 $settlement = $pm->get_response_data();
8685 }
8686 return $settlement;
8687 }
8688
8689 /**
8690 * Paidy 要求
8691 *
8692 * @param string $telegram_kind 電文種別ID.
8693 * @param string $trading_id マーチャント取引ID.
8694 * @param string $payment_id 決済ID.
8695 * @return array
8696 */
8697 private function settlement_request_paidy( $telegram_kind, $trading_id, $payment_id = '' ) {
8698 $settlement = array();
8699
8700 $pm = Paygent_Module::get_instance();
8701 $pm->init();
8702 $pm->req_put( 'trading_id', $trading_id );
8703 if ( ! empty( $payment_id ) ) {
8704 $pm->req_put( 'payment_id', $payment_id );
8705 }
8706 $result = $pm->post( $telegram_kind );
8707 $result_status = $pm->get_result_status();
8708 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8709 $settlement['result'] = $result;
8710 $settlement['result_status'] = RESULT_STATUS_ERROR;
8711 $settlement['response_code'] = $pm->get_response_code();
8712 $settlement['response_detail'] = $pm->get_response_detail();
8713 $settlement['result_message'] = $pm->get_result_message();
8714 } else {
8715 $settlement = $pm->get_response_data();
8716 }
8717 return $settlement;
8718 }
8719
8720 /**
8721 * Paidy 返金要求
8722 *
8723 * @param string $telegram_kind 電文種別ID.
8724 * @param string $trading_id マーチャント取引ID.
8725 * @param float $amount 決済金額.
8726 * @param string $payment_id 決済ID.
8727 * @return array
8728 */
8729 private function settlement_request_paidy_refund( $telegram_kind, $trading_id, $amount, $payment_id = '' ) {
8730 $settlement = array();
8731
8732 $pm = Paygent_Module::get_instance();
8733 $pm->init();
8734 $pm->req_put( 'trading_id', $trading_id );
8735 if ( ! empty( $payment_id ) ) {
8736 $pm->req_put( 'payment_id', $payment_id );
8737 }
8738 $pm->req_put( 'amount', $amount );
8739 $result = $pm->post( $telegram_kind );
8740 $result_status = $pm->get_result_status();
8741 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8742 $settlement['result'] = $result;
8743 $settlement['result_status'] = RESULT_STATUS_ERROR;
8744 $settlement['response_code'] = $pm->get_response_code();
8745 $settlement['response_detail'] = $pm->get_response_detail();
8746 $settlement['result_message'] = $pm->get_result_message();
8747 } else {
8748 $settlement = $pm->get_response_data();
8749 }
8750 return $settlement;
8751 }
8752
8753 /**
8754 * 会員�
8755 報取得
8756 *
8757 * @param int $member_id Member ID.
8758 * @return array
8759 */
8760 private function customer_ref( $member_id ) {
8761 global $usces;
8762
8763 $customer = array();
8764 $customer_card_id = $usces->get_member_meta_value( 'paygent_customer_card_id', $member_id );
8765 if ( empty( $customer_card_id ) ) {
8766 return $customer;
8767 }
8768
8769 $pm = Paygent_Module::get_instance();
8770 $pm->init();
8771 $pm->req_put( 'customer_id', $member_id );
8772 $pm->req_put( 'customer_card_id', $customer_card_id );
8773 $result = $pm->post( PAYGENT_CARD_STOCK_GET );
8774 $result_status = $pm->get_result_status();
8775 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8776 $customer['result'] = $result;
8777 $customer['result_status'] = RESULT_STATUS_ERROR;
8778 $customer['response_code'] = $pm->get_response_code();
8779 $customer['response_detail'] = $pm->get_response_detail();
8780 $customer['result_message'] = $pm->get_result_message();
8781 } else {
8782 $customer = $pm->get_response_data();
8783 }
8784 return $customer;
8785 }
8786
8787 /**
8788 * 会員カード�
8789 報登録
8790 *
8791 * @param int $member_id Member ID.
8792 * @param string $token Card Token.
8793 * @return array
8794 */
8795 private function customer_card_add( $member_id, $token ) {
8796 global $usces;
8797
8798 $customer = array();
8799 $acting_opts = $this->get_acting_settings();
8800
8801 $pm = Paygent_Module::get_instance();
8802 $pm->init();
8803 $pm->req_put( 'customer_id', $member_id );
8804 $pm->req_put( 'valid_check_flg', 1 );
8805 $pm->req_put( 'card_token', $token );
8806 if ( 'on' == $acting_opts['use_card_conf_number'] ) {
8807 $pm->req_put( 'security_code_use', 1 );
8808 }
8809 $result = $pm->post( PAYGENT_CARD_STOCK_SET );
8810 $result_status = $pm->get_result_status();
8811 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8812 $customer['result'] = $result;
8813 $customer['result_status'] = RESULT_STATUS_ERROR;
8814 $customer['response_code'] = $pm->get_response_code();
8815 $customer['response_detail'] = $pm->get_response_detail();
8816 $customer['result_message'] = $pm->get_result_message();
8817 } else {
8818 $customer = $pm->get_response_data();
8819 if ( isset( $customer['customer_card_id'] ) ) {
8820 $usces->set_member_meta_value( 'paygent_customer_card_id', $customer['customer_card_id'], $member_id );
8821 }
8822 }
8823 return $customer;
8824 }
8825
8826 /**
8827 * 会員カード�
8828 報更新
8829 *
8830 * @param int $member_id Member ID.
8831 * @param string $token Card Token.
8832 * @return array
8833 */
8834 private function customer_card_upd( $member_id, $token ) {
8835 $customer = $this->customer_card_del( $member_id );
8836 if ( isset( $customer['result_status'] ) && RESULT_STATUS_ERROR == $customer['result_status'] ) {
8837 return $customer;
8838 }
8839 $customer = $this->customer_card_add( $member_id, $token );
8840 return $customer;
8841 }
8842
8843 /**
8844 * 会員カード�
8845 報削除
8846 *
8847 * @param int $member_id Member ID.
8848 * @return array
8849 */
8850 private function customer_card_del( $member_id ) {
8851 global $usces;
8852
8853 $customer = array();
8854 $customer_card_id = $usces->get_member_meta_value( 'paygent_customer_card_id', $member_id );
8855
8856 $pm = Paygent_Module::get_instance();
8857 $pm->init();
8858 $pm->req_put( 'customer_id', $member_id );
8859 $pm->req_put( 'customer_card_id', $customer_card_id );
8860 $result = $pm->post( PAYGENT_CARD_STOCK_DEL );
8861 $result_status = $pm->get_result_status();
8862 if ( ! ( true === $result ) || RESULT_STATUS_NORMAL != $result_status ) {
8863 $customer['result'] = $result;
8864 $customer['result_status'] = RESULT_STATUS_ERROR;
8865 $customer['response_code'] = $pm->get_response_code();
8866 $customer['response_detail'] = $pm->get_response_detail();
8867 $customer['result_message'] = $pm->get_result_message();
8868 } else {
8869 $usces->del_member_meta( 'paygent_customer_card_id', $member_id );
8870 $customer = $pm->get_response_data();
8871 }
8872 return $customer;
8873 }
8874
8875 /**
8876 * Save admin log.
8877 *
8878 * @since 2.7.4
8879 * @see admin_ajax()
8880 * @param integer $order_id The order id.
8881 * @param string $trading_id The trading id.
8882 * @return void
8883 */
8884 private function save_admin_log( $order_id, $trading_id ) {
8885 $latest_log = array();
8886 $log_data = $this->get_acting_log( $order_id, $trading_id );
8887 if ( $log_data ) {
8888 $data = current( $log_data );
8889 $log = usces_unserialize( $data['log'] );
8890
8891 $payment_id = ( isset( $log['payment_id'] ) ) ? $log['payment_id'] : 'no value';
8892
8893 $latest_log['datetime'] = $data['datetime'];
8894 $latest_log['acting'] = $data['acting'];
8895 $latest_log['status'] = $this->get_status_name( $data['status'] );
8896 $latest_log['result'] = $data['result'];
8897 $latest_log['log'] = $log;
8898 $latest_log['amount'] = $data['amount'];
8899 $latest_log['order_id'] = $data['order_id'];
8900 $latest_log['payment_id'] = $payment_id;
8901 $latest_log['trading_id'] = $data['tracking_id'];
8902 }
8903
8904 Logger::log( $order_id, 'orderedit', 'update', array( 'paygent_card' => $latest_log ) );
8905 }
8906 }
8907