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

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

799 lines 33.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Settlement Class.
4 * ペイメントフォー
5 * ( 旧 メタップスペイメント )
6 * ( 旧 ペイデザイン )
7 * ( 旧 デジタルチェック )
8 *
9 * @package Welcart
10 * @author Welcart Inc.
11 * @version 1.0.0
12 * @since 1.9.20
13 */
14
15 /**
16 * ペイメントフォー
17 */
18 class DIGITALCHECK_SETTLEMENT {
19 /**
20 * Instance of this class.
21 *
22 * @var object
23 */
24 protected static $instance = null;
25
26 /**
27 * 決済代行会社ID
28 *
29 * @var string
30 */
31 protected $paymod_id;
32
33 /**
34 * 決済種別
35 *
36 * @var string
37 */
38 protected $pay_method;
39
40 /**
41 * 決済代行会社略称
42 *
43 * @var string
44 */
45 protected $acting_name;
46
47 /**
48 * 決済代行会社正式名称
49 *
50 * @var string
51 */
52 protected $acting_formal_name;
53
54 /**
55 * 決済代行会社URL
56 *
57 * @var string
58 */
59 protected $acting_company_url;
60
61 /**
62 * エラーメッセージ
63 *
64 * @var string
65 */
66 protected $error_mes;
67
68 /**
69 * Construct.
70 */
71 public function __construct() {
72
73 $this->paymod_id = 'digitalcheck';
74 $this->pay_method = array(
75 'acting_digitalcheck_card',
76 'acting_digitalcheck_conv',
77 );
78 $this->acting_name = 'ペイメントフォー';
79 $this->acting_formal_name = 'ペイメントフォー';
80 $this->acting_company_url = 'https://www.paymentfor.com/';
81
82 $this->initialize_data();
83
84 if ( is_admin() ) {
85 add_action( 'usces_action_admin_settlement_update', array( $this, 'settlement_update' ) );
86 add_action( 'usces_action_settlement_tab_title', array( $this, 'settlement_tab_title' ) );
87 add_action( 'usces_action_settlement_tab_body', array( $this, 'settlement_tab_body' ) );
88 }
89
90 if ( $this->is_activate_card() || $this->is_activate_conv() ) {
91 add_filter( 'usces_filter_settle_info_field_meta_keys', array( $this, 'settlement_info_field_meta_keys' ) );
92 add_filter( 'usces_filter_settle_info_field_keys', array( $this, 'settlement_info_field_keys' ) );
93 add_filter( 'usces_filter_check_acting_return_duplicate', array( $this, 'check_acting_return_duplicate' ), 10, 2 );
94 add_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) );
95 }
96
97 if ( $this->is_activate_conv() ) {
98 add_filter( 'usces_filter_payment_detail', array( $this, 'payment_detail' ), 10, 2 );
99 add_filter( 'usces_filter_send_order_mail_payment', array( $this, 'order_mail_payment' ), 10, 6 );
100 add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'order_confirm_mail_payment' ), 10, 5 );
101 }
102
103 if ( $this->is_validity_acting( 'card' ) ) {
104 if ( is_admin() ) {
105 add_action( 'usces_action_admin_member_info', array( $this, 'member_settlement_info' ), 10, 3 );
106 add_action( 'usces_action_post_update_memberdata', array( $this, 'member_edit_post' ), 10, 2 );
107 }
108 }
109 }
110
111 /**
112 * Return an instance of this class.
113 */
114 public static function get_instance() {
115 if ( is_null( self::$instance ) ) {
116 self::$instance = new self();
117 }
118 return self::$instance;
119 }
120
121 /**
122 * Initialize.
123 */
124 public function initialize_data() {
125 $options = get_option( 'usces', array() );
126 if ( ! isset( $options['acting_settings'] ) || ! isset( $options['acting_settings']['digitalcheck'] ) ) {
127 $options['acting_settings']['digitalcheck']['card_activate'] = 'off';
128 $options['acting_settings']['digitalcheck']['card_ip'] = '';
129 $options['acting_settings']['digitalcheck']['card_pass'] = '';
130 $options['acting_settings']['digitalcheck']['card_kakutei'] = '';
131 $options['acting_settings']['digitalcheck']['card_user_id'] = '';
132 $options['acting_settings']['digitalcheck']['conv_activate'] = 'off';
133 $options['acting_settings']['digitalcheck']['conv_ip'] = '';
134 $options['acting_settings']['digitalcheck']['conv_store'] = array();
135 $options['acting_settings']['digitalcheck']['conv_kigen'] = '14';
136 update_option( 'usces', $options );
137 } else {
138 $options['acting_settings']['digitalcheck']['card_activate'] = ( isset( $options['acting_settings']['digitalcheck']['card_activate'] ) ) ? $options['acting_settings']['digitalcheck']['card_activate'] : 'off';
139 $options['acting_settings']['digitalcheck']['conv_activate'] = ( isset( $options['acting_settings']['digitalcheck']['conv_activate'] ) ) ? $options['acting_settings']['digitalcheck']['conv_activate'] : 'off';
140 if ( 'on' === $options['acting_settings']['digitalcheck']['card_activate'] || 'on' === $options['acting_settings']['digitalcheck']['card_activate'] ) {
141 $options['acting_settings']['digitalcheck']['card_ip'] = ( isset( $options['acting_settings']['digitalcheck']['card_ip'] ) ) ? $options['acting_settings']['digitalcheck']['card_ip'] : '';
142 $options['acting_settings']['digitalcheck']['card_pass'] = ( isset( $options['acting_settings']['digitalcheck']['card_pass'] ) ) ? $options['acting_settings']['digitalcheck']['card_pass'] : '';
143 $options['acting_settings']['digitalcheck']['card_kakutei'] = ( isset( $options['acting_settings']['digitalcheck']['card_kakutei'] ) ) ? $options['acting_settings']['digitalcheck']['card_kakutei'] : '0';
144 $options['acting_settings']['digitalcheck']['card_user_id'] = ( isset( $options['acting_settings']['digitalcheck']['card_user_id'] ) ) ? $options['acting_settings']['digitalcheck']['card_user_id'] : 'off';
145 $options['acting_settings']['digitalcheck']['send_url_card'] = 'https://www.paydesign.jp/settle/settle3/bp3.dll';
146 $options['acting_settings']['digitalcheck']['send_url_user_id'] = 'https://www.paydesign.jp/settle/settlex/credit2.dll';
147 $options['acting_settings']['digitalcheck']['conv_ip'] = ( isset( $options['acting_settings']['digitalcheck']['conv_ip'] ) ) ? $options['acting_settings']['digitalcheck']['conv_ip'] : '';
148 $options['acting_settings']['digitalcheck']['conv_store'] = ( isset( $options['acting_settings']['digitalcheck']['conv_store'] ) ) ? $options['acting_settings']['digitalcheck']['conv_store'] : array();
149 $options['acting_settings']['digitalcheck']['conv_kigen'] = ( isset( $options['acting_settings']['digitalcheck']['conv_kigen'] ) ) ? $options['acting_settings']['digitalcheck']['conv_kigen'] : '14';
150 $options['acting_settings']['digitalcheck']['send_url_conv'] = 'https://www.paydesign.jp/settle/settle3/bp3.dll';
151 update_option( 'usces', $options );
152 }
153 }
154 }
155
156 /**
157 * 決済有効判定
158 * 支払方法で使用している場合に true
159 *
160 * @param string $type Module type.
161 * @return boolean
162 */
163 public function is_validity_acting( $type = '' ) {
164 $acting_opts = $this->get_acting_settings();
165 if ( empty( $acting_opts ) ) {
166 return false;
167 }
168
169 $payment_method = usces_get_system_option( 'usces_payment_method', 'sort' );
170 $method = false;
171
172 switch ( $type ) {
173 case 'card':
174 foreach ( $payment_method as $payment ) {
175 if ( 'acting_digitalcheck_card' == $payment['settlement'] && 'activate' == $payment['use'] ) {
176 $method = true;
177 break;
178 }
179 }
180 if ( $method && $this->is_activate_card() ) {
181 return true;
182 } else {
183 return false;
184 }
185 break;
186
187 case 'conv':
188 foreach ( $payment_method as $payment ) {
189 if ( 'acting_digitalcheck_conv' == $payment['settlement'] && 'activate' == $payment['use'] ) {
190 $method = true;
191 break;
192 }
193 }
194 if ( $method && $this->is_activate_conv() ) {
195 return true;
196 } else {
197 return false;
198 }
199 break;
200
201 default:
202 if ( 'on' == $acting_opts['activate'] ) {
203 return true;
204 } else {
205 return false;
206 }
207 }
208 }
209
210 /**
211 * クレジットカード決済有効判定
212 *
213 * @return boolean
214 */
215 public function is_activate_card() {
216
217 $acting_opts = $this->get_acting_settings();
218 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
219 ( isset( $acting_opts['card_activate'] ) && ( 'on' == $acting_opts['card_activate'] ) ) ) {
220 $res = true;
221 } else {
222 $res = false;
223 }
224 return $res;
225 }
226
227 /**
228 * コンビニ決済有効判定
229 *
230 * @return boolean
231 */
232 public function is_activate_conv() {
233
234 $acting_opts = $this->get_acting_settings();
235 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
236 ( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) ) {
237 $res = true;
238 } else {
239 $res = false;
240 }
241 return $res;
242 }
243
244 /**
245 * 決済オプション登録・更新
246 * usces_action_admin_settlement_update
247 */
248 public function settlement_update() {
249 global $usces;
250
251 if ( $this->paymod_id != wp_unslash( $_POST['acting'] ) ) {
252 return;
253 }
254
255 $this->error_mes = '';
256 $options = get_option( 'usces', array() );
257 $payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
258
259 unset( $options['acting_settings']['digitalcheck'] );
260 $options['acting_settings']['digitalcheck']['card_activate'] = ( isset( $_POST['card_activate'] ) ) ? $_POST['card_activate'] : 'off';
261 $options['acting_settings']['digitalcheck']['card_ip'] = ( isset( $_POST['card_ip'] ) ) ? $_POST['card_ip'] : '';
262 $options['acting_settings']['digitalcheck']['card_pass'] = ( isset( $_POST['card_pass'] ) ) ? $_POST['card_pass'] : '';
263 $options['acting_settings']['digitalcheck']['card_kakutei'] = ( isset( $_POST['card_kakutei'] ) ) ? $_POST['card_kakutei'] : '0';
264 $options['acting_settings']['digitalcheck']['card_user_id'] = ( isset( $_POST['card_user_id'] ) ) ? $_POST['card_user_id'] : 'off';
265 $options['acting_settings']['digitalcheck']['conv_activate'] = ( isset( $_POST['conv_activate'] ) ) ? $_POST['conv_activate'] : 'off';
266 $options['acting_settings']['digitalcheck']['conv_ip'] = ( isset( $_POST['conv_ip'] ) ) ? $_POST['conv_ip'] : '';
267 $options['acting_settings']['digitalcheck']['conv_store'] = ( isset( $_POST['conv_store'] ) ) ? $_POST['conv_store'] : array();
268 $options['acting_settings']['digitalcheck']['conv_kigen'] = ( isset( $_POST['conv_kigen'] ) ) ? $_POST['conv_kigen'] : '14';
269
270 if ( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ) {
271 if ( WCUtils::is_blank( $_POST['card_ip'] ) ) {
272 $this->error_mes .= '※加盟店コードを�
273 �力してください<br />';
274 }
275 if ( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
276 if ( WCUtils::is_blank( $_POST['card_pass'] ) ) {
277 $this->error_mes .= '※加盟店パスワードを�
278 �力してください<br />';
279 }
280 }
281 }
282 if ( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) {
283 if ( WCUtils::is_blank( $_POST['conv_ip'] ) ) {
284 $this->error_mes .= '※加盟店コードを�
285 �力してください<br />';
286 }
287 if ( empty( $_POST['conv_store'] ) ) {
288 $this->error_mes .= '※利用コンビニを選択してください<br />';
289 }
290 }
291
292 if ( '' == $this->error_mes ) {
293 $usces->action_status = 'success';
294 $usces->action_message = __( 'Options are updated.', 'usces' );
295 if ( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] || 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) {
296 $options['acting_settings']['digitalcheck']['activate'] = 'on';
297 $toactive = array();
298 if ( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ) {
299 $options['acting_settings']['digitalcheck']['send_url_card'] = 'https://www.paydesign.jp/settle/settle3/bp3.dll';
300 if ( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
301 $options['acting_settings']['digitalcheck']['send_url_user_id'] = 'https://www.paydesign.jp/settle/settlex/credit2.dll';
302 } else {
303 $options['acting_settings']['digitalcheck']['send_url_user_id'] = '';
304 }
305 $usces->payment_structure['acting_digitalcheck_card'] = 'カード決済(' . $this->acting_name . '';
306 foreach ( $payment_method as $settlement => $payment ) {
307 if ( 'acting_digitalcheck_card' == $settlement && 'deactivate' == $payment['use'] ) {
308 $toactive[] = $payment['name'];
309 }
310 }
311 } else {
312 unset( $usces->payment_structure['acting_digitalcheck_card'] );
313 }
314 if ( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) {
315 $options['acting_settings']['digitalcheck']['send_url_conv'] = 'https://www.paydesign.jp/settle/settle3/bp3.dll';
316 $usces->payment_structure['acting_digitalcheck_conv'] = 'コンビニ決済(' . $this->acting_name . '';
317 foreach ( $payment_method as $settlement => $payment ) {
318 if ( 'acting_digitalcheck_conv' == $settlement && 'deactivate' == $payment['use'] ) {
319 $toactive[] = $payment['name'];
320 }
321 }
322 } else {
323 unset( $usces->payment_structure['acting_digitalcheck_conv'] );
324 }
325 usces_admin_orderlist_show_wc_trans_id();
326 if ( 0 < count( $toactive ) ) {
327 $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' );
328 }
329 } else {
330 $options['acting_settings']['digitalcheck']['activate'] = 'off';
331 unset( $usces->payment_structure['acting_digitalcheck_card'] );
332 unset( $usces->payment_structure['acting_digitalcheck_conv'] );
333 }
334 if ( 'on' != $options['acting_settings']['digitalcheck']['card_user_id'] || 'off' == $options['acting_settings']['digitalcheck']['activate'] ) {
335 usces_clear_quickcharge( 'digitalcheck_ip_user_id' );
336 }
337 $deactivate = array();
338 foreach ( $payment_method as $settlement => $payment ) {
339 if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
340 if ( 'deactivate' != $payment['use'] ) {
341 $payment['use'] = 'deactivate';
342 $deactivate[] = $payment['name'];
343 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
344 }
345 }
346 }
347 if ( 0 < count( $deactivate ) ) {
348 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
349 $usces->action_message .= $deactivate_message;
350 }
351 } else {
352 $usces->action_status = 'error';
353 $usces->action_message = __( 'Data have deficiency.', 'usces' );
354 $options['acting_settings']['digitalcheck']['activate'] = 'off';
355 unset( $usces->payment_structure['acting_digitalcheck_card'] );
356 unset( $usces->payment_structure['acting_digitalcheck_conv'] );
357 $deactivate = array();
358 foreach ( $payment_method as $settlement => $payment ) {
359 if ( in_array( $settlement, $this->pay_method ) ) {
360 if ( 'deactivate' != $payment['use'] ) {
361 $payment['use'] = 'deactivate';
362 $deactivate[] = $payment['name'];
363 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
364 }
365 }
366 }
367 if ( 0 < count( $deactivate ) ) {
368 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
369 $usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
370 }
371 }
372 ksort( $usces->payment_structure );
373 update_option( 'usces', $options );
374 update_option( 'usces_payment_structure', $usces->payment_structure );
375 }
376
377 /**
378 * クレジット決済設定画面タブ
379 * usces_action_settlement_tab_title
380 */
381 public function settlement_tab_title() {
382 $settlement_selected = get_option( 'usces_settlement_selected' );
383 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) {
384 echo '<li><a href="#uscestabs_' . esc_html( $this->paymod_id ) . '">' . esc_html( $this->acting_name ) . '</a></li>';
385 }
386 }
387
388 /**
389 * クレジット決済設定画面フォーム
390 * usces_action_settlement_tab_body
391 */
392 public function settlement_tab_body() {
393 global $usces;
394
395 $acting_opts = $this->get_acting_settings();
396 $settlement_selected = get_option( 'usces_settlement_selected' );
397 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) :
398 $card_activate = ( isset( $acting_opts['card_activate'] ) && 'on' == $acting_opts['card_activate'] ) ? 'on' : 'off';
399 $card_ip = ( isset( $acting_opts['card_ip'] ) ) ? $acting_opts['card_ip'] : '';
400 $card_pass = ( isset( $acting_opts['card_pass'] ) ) ? $acting_opts['card_pass'] : '';
401 $card_kakutei = ( isset( $acting_opts['card_kakutei'] ) ) ? $acting_opts['card_kakutei'] : '0';
402 $card_user_id = ( isset( $acting_opts['card_user_id'] ) && 'on' == $acting_opts['card_user_id'] ) ? 'on' : 'off';
403 $conv_activate = ( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) ? 'on' : 'off';
404 $conv_ip = ( isset( $acting_opts['conv_ip'] ) ) ? $acting_opts['conv_ip'] : '';
405 $conv_store = ( isset( $acting_opts['conv_store'] ) && is_array( $acting_opts['conv_store'] ) ) ? $acting_opts['conv_store'] : array();
406 ?>
407 <div id="uscestabs_digitalcheck">
408 <div class="settlement_service"><span class="service_title"><?php echo esc_html( $this->acting_formal_name ); ?></span></div>
409 <?php
410 if ( isset( $_POST['acting'] ) && $this->paymod_id == $_POST['acting'] ) :
411 if ( '' != $this->error_mes ) :
412 ?>
413 <div class="error_message"><?php wel_esc_script_e( $this->error_mes ); ?></div>
414 <?php elseif ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) : ?>
415 <div class="message">十分にテストを行ってから運用してください。</div>
416 <?php
417 endif;
418 endif;
419 ?>
420 <form action="" method="post" name="digitalcheck_form" id="digitalcheck_form">
421 <table class="settle_table">
422 <tr>
423 <th>クレジットカード決済</th>
424 <td><label><input name="card_activate" type="radio" id="card_activate_digitalcheck_1" value="on"<?php checked( $card_activate, 'on' ); ?> /><span>利用する</span></label><br />
425 <label><input name="card_activate" type="radio" id="card_activate_digitalcheck_2" value="off"<?php checked( $card_activate, 'off' ); ?> /><span>利用しない</span></label>
426 </td>
427 </tr>
428 <tr>
429 <th><a class="explanation-label" id="label_ex_card_ip_digitalcheck">加盟店コード</a></th>
430 <td><input name="card_ip" type="text" id="card_ip_digitalcheck" value="<?php echo esc_html( $card_ip ); ?>" class="regular-text" maxlength="10" /></td>
431 </tr>
432 <tr id="ex_card_ip_digitalcheck" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行される加盟店コード(半角英数字)</td></tr>
433 <tr>
434 <th><a class="explanation-label" id="label_ex_card_pass_digitalcheck">加盟店パスワード</a></th>
435 <td><input name="card_pass" type="text" id="card_pass_digitalcheck" value="<?php echo esc_html( $card_pass ); ?>" class="regular-text" maxlength="10" /></td>
436 </tr>
437 <tr id="ex_card_pass_digitalcheck" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行される加盟店パスワード(半角英数字)<br />ユーザID決済をご利用の場合は、�
438 須となります。</td></tr>
439 <tr>
440 <th><a class="explanation-label" id="label_ex_card_kakutei">決済自動確定</a></th>
441 <td><label><input name="card_kakutei" type="radio" id="card_kakutei_0" value="0"<?php checked( $card_kakutei, '0' ); ?> /><span>与信のみ</span></label><br />
442 <label><input name="card_kakutei" type="radio" id="card_kakutei_1" value="1"<?php checked( $card_kakutei, '1' ); ?> /><span>売上確定</span></label>
443 </td>
444 </tr>
445 <tr id="ex_card_kakutei" class="explanation"><td colspan="2">注文の際にクレジットの与信のみを行ないます。<br />実際の売上として計上するには確定処理が�
446 要となります。省略時は「売上確定(確定まで同時に行う)」です。</td></tr>
447 <tr>
448 <th><a class="explanation-label" id="label_ex_card_user_id">ユーザID決済</a></th>
449 <td><label><input name="card_user_id" type="radio" id="card_user_id_1" value="on"<?php checked( $card_user_id, 'on' ); ?> /><span>利用する</span></label><br />
450 <label><input name="card_user_id" type="radio" id="card_user_id_2" value="off"<?php checked( $card_user_id, 'off' ); ?> /><span>利用しない</span></label>
451 </td>
452 </tr>
453 <tr id="ex_card_user_id" class="explanation"><td colspan="2">過去にクレジットカードでのお取引があるユーザは、次回からカード�
454 報の�
455 �力を省略することが可能となります。</td></tr>
456 </table>
457 <table class="settle_table">
458 <tr>
459 <th>コンビニ決済</th>
460 <td><label><input name="conv_activate" type="radio" id="conv_activate_digitalcheck_1" value="on"<?php checked( $conv_activate, 'on' ); ?> /><span>利用する</span></label><br />
461 <label><input name="conv_activate" type="radio" id="conv_activate_digitalcheck_2" value="off"<?php checked( $conv_activate, 'off' ); ?> /><span>利用しない</span></label>
462 </td>
463 </tr>
464 <tr>
465 <th><a class="explanation-label" id="label_ex_conv_ip_digitalcheck">加盟店コード</a></th>
466 <td><input name="conv_ip" type="text" id="conv_ip_digitalcheck" value="<?php echo esc_html( isset( $acting_opts['conv_ip'] ) ? $acting_opts['conv_ip'] : '' ); ?>" class="regular-text" maxlength="10" /></td>
467 </tr>
468 <tr id="ex_conv_ip_digitalcheck" class="explanation"><td colspan="2">契約時に<?php echo esc_html( $this->acting_name ); ?>から発行される加盟店コード(半角英数字)</td></tr>
469 <tr>
470 <th rowspan="4"><a class="explanation-label" id="label_ex_conv_store_digitalcheck">利用コンビニ</a></th>
471 <td><label><input name="conv_store[]" type="checkbox" id="conv_store_1" value="1"<?php checked( in_array( '1', $conv_store ), true ); ?> /><span>Loppi決済(ローソン・セイコーマート・ミニストップ)</span></label></td>
472 </tr>
473 <tr>
474 <td><label><input name="conv_store[]" type="checkbox" id="conv_store_2" value="2"<?php checked( in_array( '2', $conv_store ), true ); ?> /><span>Seven決済(セブンイレブン)</span></label></td>
475 </tr>
476 <tr>
477 <td><label><input name="conv_store[]" type="checkbox" id="conv_store_3" value="3"<?php checked( in_array( '3', $conv_store ), true ); ?> /><span>FAMIMA決済(ファミリーマート)</span></label></td>
478 </tr>
479 <tr>
480 <td><label><input name="conv_store[]" type="checkbox" id="conv_store_73" value="73"<?php checked( in_array( '73', $conv_store ), true ); ?> /><span>オンライン決済(デイリーヤマザキ・ヤマザキデイリーストアー)</span></label></td>
481 </tr>
482 <tr id="ex_conv_store_digitalcheck" class="explanation"><td colspan="2">収納�
483 �のコンビニを選択します。コンビニ毎の審査が�
484 要となり、審査通過後にご利用可能となります。</td></tr>
485 <tr>
486 <th><a class="explanation-label" id="label_ex_conv_kigen_digitalcheck">支払期限</a></th>
487 <td>
488 <?php
489 $selected = array_fill( 1, 30, '' );
490 if ( isset( $acting_opts['conv_kigen'] ) ) {
491 $selected[ $acting_opts['conv_kigen'] ] = ' selected="selected"';
492 } else {
493 $selected[14] = ' selected="selected"';
494 }
495 ?>
496 <select name="conv_kigen" id="conv_kigen">
497 <?php for ( $i = 1; $i <= 30; $i++ ) : ?>
498 <option value="<?php echo esc_html( $i ); ?>"<?php echo esc_html( $selected[ $i ] ); ?>><?php echo esc_html( $i ); ?></option>
499 <?php endfor; ?>
500 </select>(日数)</td>
501 </tr>
502 <tr id="ex_conv_kigen_digitalcheck" class="explanation"><td colspan="2">コンビニ店頭でお支払いいただける期限となります。</td></tr>
503 </table>
504 <input name="acting" type="hidden" value="digitalcheck" />
505 <input name="usces_option_update" type="submit" class="button button-primary" value="<?php echo esc_attr( $this->acting_name ); ?>の設定を更新する" />
506 <?php wp_nonce_field( 'admin_settlement', 'wc_nonce' ); ?>
507 </form>
508 <div class="settle_exp">
509 <p><strong><?php echo esc_html( $this->acting_formal_name ); ?></strong></p>
510 <a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank"><?php echo esc_html( $this->acting_name ); ?>の詳細はこちら </a>
511 <p> </p>
512 <p>この決済は「外部リンク型」の決済システムです。</p>
513 <p>「外部リンク型」とは、決済会社のページへ遷移してカード�
514 報を�
515 �力する決済システムです。</p>
516 </div>
517 </div><!--uscestabs_digitalcheck-->
518 <?php
519 endif;
520 }
521
522 /**
523 * 受注データから取得する決済�
524 報のキー
525 * usces_filter_settle_info_field_meta_keys
526 *
527 * @param array $keys Settlement information key.
528 * @return array
529 */
530 public function settlement_info_field_meta_keys( $keys ) {
531 $keys = array_merge( $keys, array( 'SID', 'DATE', 'TIME', 'CVS', 'SHONIN', 'SHNO' ) );
532 return $keys;
533 }
534
535 /**
536 * 受注編集画面に表示する決済�
537 報のキー
538 * usces_filter_settle_info_field_keys
539 *
540 * @param array $keys Settlement information keys.
541 * @return array
542 */
543 public function settlement_info_field_keys( $keys ) {
544 $keys = array_merge( $keys, array( 'SID', 'DATE', 'TIME', 'CVS', 'SHONIN', 'SHNO' ) );
545 return $keys;
546 }
547
548 /**
549 * 重複オーダー禁止処理
550 * usces_filter_check_acting_return_duplicate
551 *
552 * @param string $trans_id Transaction ID.
553 * @param array $results Result data.
554 * @return string
555 */
556 public function check_acting_return_duplicate( $trans_id, $results ) {
557 if ( isset( $_REQUEST['SID'] ) && isset( $_REQUEST['FUKA'] ) ) {
558 $fuka = substr( wp_unslash( $_REQUEST['FUKA'] ), 0, 24 );
559 if ( 'acting_digitalcheck_card' == $fuka || 'acting_digitalcheck_conv' == $fuka ) {
560 $trans_id = wp_unslash( $_REQUEST['SID'] );
561 $_REQUEST['absolute_trans_id'] = $trans_id;
562 }
563 }
564 return $trans_id;
565 }
566
567 /**
568 * 受注データ登録
569 * Called by usces_reg_orderdata() and usces_new_orderdata().
570 * usces_action_reg_orderdata
571 *
572 * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $results ).
573 */
574 public function register_orderdata( $args ) {
575 global $usces;
576 extract( $args );
577
578 $acting_flg = $payments['settlement'];
579 if ( ! in_array( $acting_flg, $this->pay_method ) ) {
580 return;
581 }
582
583 if ( ! $entry['order']['total_full_price'] ) {
584 return;
585 }
586
587 if ( isset( $_REQUEST['SID'] ) && isset( $_REQUEST['FUKA'] ) ) {
588 $fuka = substr( wp_unslash( $_REQUEST['FUKA'] ), 0, 24 );
589 if ( 'acting_digitalcheck_card' == $fuka ) {
590 $data = array();
591 foreach ( $_REQUEST as $key => $value ) {
592 $data[ $key ] = $value;
593 }
594 $usces->set_order_meta_value( 'acting_digitalcheck_card', serialize( $data ), $order_id );
595 }
596 if ( 'acting_digitalcheck_conv' == $fuka ) {
597 $data = array();
598 $data['SID'] = wp_unslash( $_REQUEST['SID'] );
599 if ( ! empty( $_REQUEST['CVS'] ) ) {
600 $data['CVS'] = wp_unslash( $_REQUEST['CVS'] );
601 }
602 if ( ! empty( $_REQUEST['SHNO'] ) ) {
603 $data['SHNO'] = wp_unslash( $_REQUEST['SHNO'] );
604 }
605 if ( ! empty( $_REQUEST['FURL'] ) ) {
606 $data['FURL'] = wp_unslash( $_REQUEST['FURL'] );
607 }
608 $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
609 }
610 $usces->set_order_meta_value( 'SID', wp_unslash( $_REQUEST['SID'] ), $order_id );
611 $usces->set_order_meta_value( 'wc_trans_id', wp_unslash( $_REQUEST['SID'] ), $order_id );
612 }
613 }
614
615 /**
616 * 会員データ編集画面
617 * usces_action_admin_member_info
618 *
619 * @param array $member_data Member data.
620 * @param array $member_meta_data Member meta data.
621 * @param array $member_history Member history data.
622 */
623 public function member_settlement_info( $member_data, $member_meta_data, $member_history ) {
624 if ( 0 < count( $member_meta_data ) ) :
625 $cardinfo = array();
626 foreach ( $member_meta_data as $value ) {
627 if ( in_array( $value['meta_key'], array( 'digitalcheck_ip_user_id' ) ) ) {
628 $cardinfo[ $value['meta_key'] ] = $value['meta_value'];
629 }
630 }
631 if ( 0 < count( $cardinfo ) ) :
632 foreach ( $cardinfo as $key => $value ) :
633 if ( 'digitalcheck_ip_user_id' != $key ) :
634 ?>
635 <tr>
636 <td class="label"><?php echo esc_html( $key ); ?></td>
637 <td><div class="rod_left shortm"><?php echo esc_html( $value ); ?></div></td>
638 </tr>
639 <?php
640 endif;
641 endforeach;
642 if ( array_key_exists( 'digitalcheck_ip_user_id', $cardinfo ) ) :
643 ?>
644 <tr>
645 <td class="label">ユーザID決済</td>
646 <td><div class="rod_left shortm">登録あり</div></td>
647 </tr>
648 <tr>
649 <td class="label"><input type="checkbox" name="digitalcheck_ip_user_id" id="digitalcheck_ip_user_id" value="delete"></td>
650 <td><label for="digitalcheck_ip_user_id">ユーザID決済を解除する</label></td>
651 </tr>
652 <?php
653 endif;
654 endif;
655 endif;
656 }
657
658 /**
659 * 会員データ編集画面 カード�
660 報登録解除
661 * usces_action_post_update_memberdata
662 *
663 * @param int $member_id Member ID.
664 * @param boolean $res Result.
665 */
666 public function member_edit_post( $member_id, $res ) {
667 global $usces;
668
669 if ( isset( $_POST['digitalcheck_ip_user_id'] ) && 'delete' == wp_unslash( $_POST['digitalcheck_ip_user_id'] ) ) {
670 $usces->del_member_meta( 'digitalcheck_ip_user_id', $member_id );
671 }
672 }
673
674 /**
675 * 支払方法説明
676 * usces_filter_payment_detail
677 *
678 * @param string $str Payment method description.
679 * @param array $entry Entry data.
680 * @return string
681 */
682 public function payment_detail( $str, $entry ) {
683 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
684 if ( isset( $payment['settlement'] ) && 'acting_digitalcheck_conv' == $payment['settlement'] ) {
685 $acting_opts = $this->get_acting_settings();
686 $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['conv_kigen'] ) . __( ')', 'usces' );
687 $str = apply_filters( 'usces_filter_digitalcheck_payment_limit_conv', $payment_detail, $acting_opts['conv_kigen'] );
688 }
689 return $str;
690 }
691
692 /**
693 * サンキューメール
694 * usces_filter_send_order_mail_payment
695 *
696 * @param string $msg_payment Payment method message.
697 * @param int $order_id Order number.
698 * @param array $payment Payment data.
699 * @param array $cart Cart data.
700 * @param array $entry Entry data.
701 * @param array $data Order data.
702 * @return string
703 */
704 public function order_mail_payment( $msg_payment, $order_id, $payment, $cart, $entry, $data ) {
705 global $usces;
706
707 if ( 'acting_digitalcheck_conv' != $payment['settlement'] ) {
708 return $msg_payment;
709 }
710
711 $args = maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
712 if ( isset( $args['CVS'] ) ) {
713 $msg_payment .= '支払�
714 � : ' . $this->get_conv_name( $args['CVS'] ) . "\r\n";
715 }
716 if ( isset( $args['SHNO'] ) ) {
717 $msg_payment .= '支払番号 : ' . $args['SHNO'] . "\r\n";
718 }
719 if ( isset( $args['FURL'] ) ) {
720 $msg_payment .= '支払�
721 報URL : ' . $args['FURL'] . "\r\n";
722 }
723 return $msg_payment;
724 }
725
726 /**
727 * 管理画面送信メール
728 * usces_filter_order_confirm_mail_payment
729 *
730 * @param string $msg_payment Payment information message.
731 * @param int $order_id Order number.
732 * @param array $payment Payment data.
733 * @param array $cart Cart data.
734 * @param array $data Order data.
735 * @return string
736 */
737 public function order_confirm_mail_payment( $msg_payment, $order_id, $payment, $cart, $data ) {
738 global $usces;
739
740 if ( 'acting_digitalcheck_conv' != $payment['settlement'] ) {
741 return $msg_payment;
742 }
743
744 if ( 'orderConfirmMail' == $_POST['mode'] ) {
745 $args = maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
746 if ( isset( $args['CVS'] ) ) {
747 $msg_payment .= '支払�
748 � : ' . $this->get_conv_name( $args['CVS'] ) . "\r\n";
749 }
750 if ( isset( $args['SHNO'] ) ) {
751 $msg_payment .= '支払番号 : ' . $args['SHNO'] . "\r\n";
752 }
753 if ( isset( $args['FURL'] ) ) {
754 $msg_payment .= '支払�
755 報URL : ' . $args['FURL'] . "\r\n";
756 }
757 }
758 return $msg_payment;
759 }
760
761 /**
762 * コンビニ名称取得
763 *
764 * @param string $code CVS code.
765 * @return string
766 */
767 protected function get_conv_name( $code ) {
768 switch ( $code ) {
769 case 'SEVEN':
770 $name = 'セブン-イレブン';
771 break;
772 case 'loppi':
773 $name = 'ローソン/ミニストップ/セイコーマート';
774 break;
775 case 'famima':
776 $name = 'ファミリーマート';
777 break;
778 case 'wellnet':
779 $name = 'デイリーヤマザキ/ヤマザキデイリーストア';
780 break;
781 default:
782 $name = $code;
783 }
784 return $name;
785 }
786
787 /**
788 * 決済オプション取得
789 *
790 * @return array
791 */
792 protected function get_acting_settings() {
793 global $usces;
794
795 $acting_settings = ( isset( $usces->options['acting_settings'][ $this->paymod_id ] ) ) ? $usces->options['acting_settings'][ $this->paymod_id ] : array();
796 return $acting_settings;
797 }
798 }
799