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

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

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