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

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

720 lines 30.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * ロボットペイメント
4 * (旧 Cloud Payment )
5 * (旧 J-Payment )
6 *
7 * @package Welcart
8 * @author Collne Inc.
9 * @version 1.0.0
10 * @since 1.9.20
11 */
12
13 /**
14 * ロボットペイメント
15 */
16 class JPAYMENT_SETTLEMENT {
17 /**
18 * Instance of this class.
19 *
20 * @var object
21 */
22 protected static $instance = null;
23
24 /**
25 * 決済代行会社ID
26 *
27 * @var string
28 */
29 protected $paymod_id;
30
31 /**
32 * 決済種別
33 *
34 * @var string
35 */
36 protected $pay_method;
37
38 /**
39 * 決済代行会社略称
40 *
41 * @var string
42 */
43 protected $acting_name;
44
45 /**
46 * 決済代行会社正式名称
47 *
48 * @var string
49 */
50 protected $acting_formal_name;
51
52 /**
53 * 決済代行会社URL
54 *
55 * @var string
56 */
57 protected $acting_company_url;
58
59 /**
60 * エラーメッセージ
61 *
62 * @var string
63 */
64 protected $error_mes;
65
66 /**
67 * Construct.
68 */
69 public function __construct() {
70
71 $this->paymod_id = 'jpayment';
72 $this->pay_method = array(
73 'acting_jpayment_card',
74 'acting_jpayment_conv',
75 'acting_jpayment_bank',
76 );
77 $this->acting_name = 'ROBOT PAYMENT';
78 $this->acting_formal_name = 'ROBOT PAYMENT';
79 $this->acting_company_url = 'https://www.robotpayment.co.jp/';
80
81 $this->initialize_data();
82
83 if ( is_admin() ) {
84 // add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
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() || $this->is_activate_bank() ) {
91 add_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) );
92 }
93
94 if ( $this->is_activate_conv() || $this->is_activate_bank() ) {
95 add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'order_confirm_mail_payment' ), 10, 5 );
96 add_filter( 'usces_filter_send_order_mail_payment', array( $this, 'send_order_mail_payment' ), 10, 6 );
97 }
98
99 if ( $this->is_validity_acting( 'conv' ) ) {
100 add_filter( 'usces_filter_payment_detail', array( $this, 'payment_detail' ), 10, 2 );
101 add_action( 'usces_filter_completion_settlement_message', array( $this, 'completion_settlement_message' ), 10, 2 );
102 }
103 }
104
105 /**
106 * Return an instance of this class.
107 */
108 public static function get_instance() {
109 if ( null == self::$instance ) {
110 self::$instance = new self();
111 }
112 return self::$instance;
113 }
114
115 /**
116 * Initialize.
117 */
118 public function initialize_data() {
119 $options = get_option( 'usces', array() );
120 if ( ! isset( $options['acting_settings'] ) || ! isset( $options['acting_settings']['jpayment'] ) ) {
121 $options['acting_settings']['jpayment']['activate'] = '';
122 $options['acting_settings']['jpayment']['aid'] = '';
123 $options['acting_settings']['jpayment']['card_activate'] = 'off';
124 $options['acting_settings']['jpayment']['card_jb'] = '';
125 $options['acting_settings']['jpayment']['conv_activate'] = 'off';
126 $options['acting_settings']['jpayment']['conv_limit'] = '14';
127 $options['acting_settings']['jpayment']['webm_activate'] = 'off';
128 $options['acting_settings']['jpayment']['bitc_activate'] = 'off';
129 $options['acting_settings']['jpayment']['suica_activate'] = 'off';
130 $options['acting_settings']['jpayment']['bank_activate'] = 'off';
131 update_option( 'usces', $options );
132 }
133 }
134
135 /**
136 * 決済有効判定
137 * 支払方法で使用している場合に true
138 *
139 * @param string $type Module type.
140 * @return boolean
141 */
142 public function is_validity_acting( $type = '' ) {
143 $acting_opts = $this->get_acting_settings();
144 if ( empty( $acting_opts ) ) {
145 return false;
146 }
147
148 $payment_method = usces_get_system_option( 'usces_payment_method', 'sort' );
149 $method = false;
150
151 switch ( $type ) {
152 case 'card':
153 foreach ( $payment_method as $payment ) {
154 if ( 'acting_jpayment_card' == $payment['settlement'] && 'activate' == $payment['use'] ) {
155 $method = true;
156 break;
157 }
158 }
159 if ( $method && $this->is_activate_card() ) {
160 return true;
161 } else {
162 return false;
163 }
164 break;
165
166 case 'conv':
167 foreach ( $payment_method as $payment ) {
168 if ( 'acting_jpayment_conv' == $payment['settlement'] && 'activate' == $payment['use'] ) {
169 $method = true;
170 break;
171 }
172 }
173 if ( $method && $this->is_activate_conv() ) {
174 return true;
175 } else {
176 return false;
177 }
178 break;
179
180 case 'bank':
181 foreach ( $payment_method as $payment ) {
182 if ( 'acting_jpayment_bank' == $payment['settlement'] && 'activate' == $payment['use'] ) {
183 $method = true;
184 break;
185 }
186 }
187 if ( $method && $this->is_activate_bank() ) {
188 return true;
189 } else {
190 return false;
191 }
192 break;
193
194 default:
195 if ( 'on' == $acting_opts['activate'] ) {
196 return true;
197 } else {
198 return false;
199 }
200 }
201 }
202
203 /**
204 * クレジットカード決済有効判定
205 *
206 * @return boolean
207 */
208 public function is_activate_card() {
209 $acting_opts = $this->get_acting_settings();
210 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
211 ( isset( $acting_opts['card_activate'] ) && ( 'on' == $acting_opts['card_activate'] ) ) ) {
212 $res = true;
213 } else {
214 $res = false;
215 }
216 return $res;
217 }
218
219 /**
220 * コンビニ決済有効判定
221 *
222 * @return boolean
223 */
224 public function is_activate_conv() {
225
226 $acting_opts = $this->get_acting_settings();
227 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
228 ( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) ) {
229 $res = true;
230 } else {
231 $res = false;
232 }
233 return $res;
234 }
235
236 /**
237 * バンクチェック決済有効判定
238 *
239 * @return boolean
240 */
241 public function is_activate_bank() {
242
243 $acting_opts = $this->get_acting_settings();
244 if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
245 ( isset( $acting_opts['bank_activate'] ) && 'on' == $acting_opts['bank_activate'] ) ) {
246 $res = true;
247 } else {
248 $res = false;
249 }
250 return $res;
251 }
252
253 /**
254 * 管理画面スクリプト
255 * admin_print_footer_scripts
256 */
257 public function admin_scripts() {
258
259 }
260
261 /**
262 * 決済オプション登録・更新
263 * usces_action_admin_settlement_update
264 */
265 public function settlement_update() {
266 global $usces;
267
268 if ( $this->paymod_id != wp_unslash( $_POST['acting'] ) ) {
269 return;
270 }
271
272 $this->error_mes = '';
273 $options = get_option( 'usces', array() );
274 $payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
275
276 unset( $options['acting_settings']['jpayment'] );
277 $options['acting_settings']['jpayment']['aid'] = ( isset( $_POST['aid'] ) ) ? trim( wp_unslash( $_POST['aid'] ) ) : '';
278 $options['acting_settings']['jpayment']['card_activate'] = ( isset( $_POST['card_activate'] ) ) ? wp_unslash( $_POST['card_activate'] ) : '';
279 $options['acting_settings']['jpayment']['card_jb'] = ( isset( $_POST['card_jb'] ) ) ? wp_unslash( $_POST['card_jb'] ) : '';
280 $options['acting_settings']['jpayment']['conv_activate'] = ( isset( $_POST['conv_activate'] ) ) ? wp_unslash( $_POST['conv_activate'] ) : '';
281 $options['acting_settings']['jpayment']['conv_limit'] = ( isset( $_POST['conv_limit'] ) ) ? $_POST['conv_limit'] : '14';
282 $options['acting_settings']['jpayment']['bank_activate'] = ( isset( $_POST['bank_activate'] ) ) ? wp_unslash( $_POST['bank_activate'] ) : '';
283
284 if ( WCUtils::is_blank( $_POST['aid'] ) ) {
285 $this->error_mes .= '※店舗IDコードを�
286 �力してください<br />';
287 }
288 if ( isset( $_POST['card_activate'] ) && 'on' == wp_unslash( $_POST['card_activate'] ) && empty( $_POST['card_jb'] ) ) {
289 $this->error_mes .= '※ジョブタイプを指定してください<br />';
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']['jpayment']['card_activate'] || 'on' == $options['acting_settings']['jpayment']['conv_activate'] || 'on' == $options['acting_settings']['jpayment']['bank_activate'] ) {
296 $options['acting_settings']['jpayment']['activate'] = 'on';
297 $options['acting_settings']['jpayment']['send_url'] = 'https://credit.j-payment.co.jp/gateway/payform.aspx';
298 $toactive = array();
299 if ( 'on' == $options['acting_settings']['jpayment']['card_activate'] ) {
300 $usces->payment_structure['acting_jpayment_card'] = 'カード決済(' . $this->acting_name . '';
301 foreach ( $payment_method as $settlement => $payment ) {
302 if ( 'acting_jpayment_card' == $settlement && 'deactivate' == $payment['use'] ) {
303 $toactive[] = $payment['name'];
304 }
305 }
306 } else {
307 unset( $usces->payment_structure['acting_jpayment_card'] );
308 }
309 if ( 'on' == $options['acting_settings']['jpayment']['conv_activate'] ) {
310 $usces->payment_structure['acting_jpayment_conv'] = 'コンビニ決済(' . $this->acting_name . '';
311 foreach ( $payment_method as $settlement => $payment ) {
312 if ( 'acting_jpayment_conv' == $settlement && 'deactivate' == $payment['use'] ) {
313 $toactive[] = $payment['name'];
314 }
315 }
316 } else {
317 unset( $usces->payment_structure['acting_jpayment_conv'] );
318 }
319 if ( 'on' == $options['acting_settings']['jpayment']['bank_activate'] ) {
320 $usces->payment_structure['acting_jpayment_bank'] = 'バンクチェック決済(' . $this->acting_name . '';
321 foreach ( $payment_method as $settlement => $payment ) {
322 if ( 'acting_jpayment_bank' == $settlement && 'deactivate' == $payment['use'] ) {
323 $toactive[] = $payment['name'];
324 }
325 }
326 } else {
327 unset( $usces->payment_structure['acting_jpayment_bank'] );
328 }
329 usces_admin_orderlist_show_wc_trans_id();
330 if ( 0 < count( $toactive ) ) {
331 $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' );
332 }
333 } else {
334 $options['acting_settings']['jpayment']['activate'] = 'off';
335 unset( $usces->payment_structure['acting_jpayment_card'] );
336 unset( $usces->payment_structure['acting_jpayment_conv'] );
337 unset( $usces->payment_structure['acting_jpayment_bank'] );
338 }
339 $deactivate = array();
340 foreach ( $payment_method as $settlement => $payment ) {
341 if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
342 if ( 'deactivate' != $payment['use'] ) {
343 $payment['use'] = 'deactivate';
344 $deactivate[] = $payment['name'];
345 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
346 }
347 }
348 }
349 if ( 0 < count( $deactivate ) ) {
350 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
351 $usces->action_message .= $deactivate_message;
352 }
353 } else {
354 $usces->action_status = 'error';
355 $usces->action_message = __( 'Data have deficiency.', 'usces' );
356 $options['acting_settings']['jpayment']['activate'] = 'off';
357 unset( $usces->payment_structure['acting_jpayment_card'] );
358 unset( $usces->payment_structure['acting_jpayment_conv'] );
359 unset( $usces->payment_structure['acting_jpayment_bank'] );
360 $deactivate = array();
361 foreach ( $payment_method as $settlement => $payment ) {
362 if ( in_array( $settlement, $this->pay_method ) ) {
363 if ( 'deactivate' != $payment['use'] ) {
364 $payment['use'] = 'deactivate';
365 $deactivate[] = $payment['name'];
366 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
367 }
368 }
369 }
370 if ( 0 < count( $deactivate ) ) {
371 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
372 $usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
373 }
374 }
375 ksort( $usces->payment_structure );
376 update_option( 'usces', $options );
377 update_option( 'usces_payment_structure', $usces->payment_structure );
378 }
379
380 /**
381 * クレジット決済設定画面タブ
382 * usces_action_settlement_tab_title
383 */
384 public function settlement_tab_title() {
385 $settlement_selected = get_option( 'usces_settlement_selected' );
386 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) {
387 echo '<li><a href="#uscestabs_' . esc_html( $this->paymod_id ) . '">' . esc_html( $this->acting_name ) . '</a></li>';
388 }
389 }
390
391 /**
392 * クレジット決済設定画面フォーム
393 * usces_action_settlement_tab_body
394 */
395 public function settlement_tab_body() {
396 global $usces;
397
398 $settlement_selected = get_option( 'usces_settlement_selected' );
399 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) :
400 $acting_opts = $this->get_acting_settings();
401 $aid = ( isset( $acting_opts['aid'] ) ) ? $acting_opts['aid'] : '';
402 $card_activate = ( isset( $acting_opts['card_activate'] ) && 'on' == $acting_opts['card_activate'] ) ? 'on' : 'off';
403 $card_jb = ( isset( $acting_opts['card_jb'] ) ) ? $acting_opts['card_jb'] : '';
404 $conv_activate = ( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) ? 'on' : 'off';
405 $webm_activate = ( isset( $acting_opts['webm_activate'] ) && 'on' == $acting_opts['webm_activate'] ) ? 'on' : 'off';
406 $bitc_activate = ( isset( $acting_opts['bitc_activate'] ) && 'on' == $acting_opts['bitc_activate'] ) ? 'on' : 'off';
407 $suica_activate = ( isset( $acting_opts['suica_activate'] ) && 'on' == $acting_opts['suica_activate'] ) ? 'on' : 'off';
408 $bank_activate = ( isset( $acting_opts['bank_activate'] ) && 'on' == $acting_opts['bank_activate'] ) ? 'on' : 'off';
409 ?>
410 <div id="uscestabs_jpayment">
411 <div class="settlement_service"><span class="service_title"><?php echo esc_html( $this->acting_formal_name ); ?></span></div>
412 <?php
413 if ( isset( $_POST['acting'] ) && 'jpayment' == wp_unslash( $_POST['acting'] ) ) :
414 if ( '' != $this->error_mes ) :
415 ?>
416 <div class="error_message"><?php wel_esc_script_e( $this->error_mes ); ?></div>
417 <?php elseif ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) : ?>
418 <div class="message">十分にテストを行ってから運用してください。</div>
419 <?php
420 endif;
421 endif;
422 ?>
423 <form action="" method="post" name="jpayment_form" id="jpayment_form">
424 <table class="settle_table">
425 <tr>
426 <th><a class="explanation-label" id="label_ex_aid_jpayment">店舗ID</a></th>
427 <td><input name="aid" type="text" id="aid_jpayment" value="<?php echo esc_html( $aid ); ?>" class="regular-text" maxlength="6" /></td>
428 </tr>
429 <tr id="ex_aid_jpayment" class="explanation"><td colspan="2">契約時に <?php echo esc_html( $this->acting_name ); ?> から発行される店舗ID(半角数字)</td></tr>
430 </table>
431 <table class="settle_table">
432 <tr>
433 <th><a class="explanation-label" id="label_ex_card_jpayment">クレジットカード決済</a></th>
434 <td><label><input name="card_activate" type="radio" id="card_activate_jpayment_1" value="on"<?php checked( $card_activate, 'on' ); ?> /><span>利用する</span></label><br />
435 <label><input name="card_activate" type="radio" id="card_activate_jpayment_2" value="off"<?php checked( $card_activate, 'off' ); ?> /><span>利用しない</span></label>
436 </td>
437 </tr>
438 <tr id="ex_card_jpayment" class="explanation"><td colspan="2">クレジットカード決済を利用するかどうか。<br />※自動継続課金には対応していません。</td></tr>
439 <tr>
440 <th><a class="explanation-label" id="label_ex_card_jb_jpayment">ジョブタイプ</a></th>
441 <td><!--<label><input name="card_jb" type="radio" id="card_jb_jpayment_1" value="CHECK"<?php checked( $card_jb, 'CHECK' ); ?> /><span>有効性チェック</span></label><br />-->
442 <label><input name="card_jb" type="radio" id="card_jb_jpayment_2" value="AUTH"<?php checked( $card_jb, 'AUTH' ); ?> /><span>仮売上処理</span></label><br />
443 <label><input name="card_jb" type="radio" id="card_jb_jpayment_3" value="CAPTURE"<?php checked( $card_jb, 'CAPTURE' ); ?> /><span>仮実同時売上処理</span></label>
444 </td>
445 </tr>
446 <tr id="ex_card_jb_jpayment" class="explanation"><td colspan="2">決済の種類を指定します。</td></tr>
447 </table>
448 <table class="settle_table">
449 <tr>
450 <th><a class="explanation-label" id="label_ex_conv_jpayment">コンビニ決済</a></th>
451 <td><label><input name="conv_activate" type="radio" id="conv_activate_jpayment_1" value="on"<?php checked( $conv_activate, 'on' ); ?> /><span>利用する</span></label><br />
452 <label><input name="conv_activate" type="radio" id="conv_activate_jpayment_2" value="off"<?php checked( $conv_activate, 'off' ); ?> /><span>利用しない</span></label>
453 </td>
454 </tr>
455 <tr id="ex_conv_jpayment" class="explanation"><td colspan="2">コンビニ(ペーパーレス)決済を利用するかどうか。</td></tr>
456 <tr>
457 <th><a class="explanation-label" id="label_ex_conv_limit_jpayment">支払期限</a></th>
458 <td>
459 <?php
460 $selected = array_fill( 1, 30, '' );
461 if ( isset( $acting_opts['conv_limit'] ) ) {
462 $selected[ $acting_opts['conv_limit'] ] = ' selected';
463 } else {
464 $selected[14] = ' selected';
465 }
466 ?>
467 <select name="conv_limit" id="conv_limit">
468 <?php for ( $i = 1; $i <= 30; $i++ ) : ?>
469 <option value="<?php echo esc_html( $i ); ?>"<?php echo esc_html( $selected[ $i ] ); ?>><?php echo esc_html( $i ); ?></option>
470 <?php endfor; ?>
471 </select></td>
472 </tr>
473 <tr id="ex_conv_limit_jpayment" class="explanation"><td colspan="2">設定する場合は契約時の支払期限と合わせる�
474 要があります。変更したい場合は <?php echo esc_html( $this->acting_name ); ?> にお申し込みください。ここでの設定はあくまで�
475 容確認ページでの支払時期を表示するものとなります。</td></tr>
476 </table>
477 <!--<table class="settle_table">
478 <tr>
479 <th><a class="explanation-label" id="label_ex_webm_jpayment">WebMoney決済</a></th>
480 <td><label><input name="webm_activate" type="radio" id="webm_activate_jpayment_1" value="on"<?php checked( $webm_activate, 'on' ); ?> /><span>利用する</span></label><br />
481 <label><input name="webm_activate" type="radio" id="webm_activate_jpayment_2" value="off"<?php checked( $webm_activate, 'off' ); ?> /><span>利用しない</span></label>
482 </td>
483 </tr>
484 <tr id="ex_webm_jpayment" class="explanation"><td colspan="2">電子マネー(WebMoney)決済を利用するかどうか。</td></tr>
485 </table>
486 <table class="settle_table">
487 <tr>
488 <th><a class="explanation-label" id="label_ex_bitc_jpayment">BitCash決済</a></th>
489 <td><label><input name="bitc_activate" type="radio" id="bitc_activate_jpayment_1" value="on"<?php checked( $bitc_activate, 'on' ); ?> /><span>利用する</span></label><br />
490 <label><input name="bitc_activate" type="radio" id="bitc_activate_jpayment_2" value="off"<?php checked( $bitc_activate, 'off' ); ?> /><span>利用しない</span></label>
491 </td>
492 </tr>
493 <tr id="ex_bitc_jpayment" class="explanation"><td colspan="2">電子マネー(BitCash)決済を利用するかどうか。</td></tr>
494 </table>
495 <table class="settle_table">
496 <tr>
497 <th><a class="explanation-label" id="label_ex_suica_jpayment">モバイルSuica決済</a></th>
498 <td><label><input name="suica_activate" type="radio" id="suica_activate_jpayment_1" value="on"<?php checked( $suica_activate, 'on' ); ?> /><span>利用する</span></label><br />
499 <label><input name="suica_activate" type="radio" id="suica_activate_jpayment_2" value="off"<?php checked( $suica_activate, 'off' ); ?> /><span>利用しない</span></label>
500 </td>
501 </tr>
502 <tr id="ex_suica_jpayment" class="explanation"><td colspan="2">電子マネー(モバイルSuica)決済を利用するかどうか。</td></tr>
503 </table>-->
504 <table class="settle_table">
505 <tr>
506 <th><a class="explanation-label" id="label_ex_bank_jpayment">バンクチェック決済</a></th>
507 <td><label><input name="bank_activate" type="radio" id="bank_activate_jpayment_1" value="on"<?php checked( $bank_activate, 'on' ); ?> /><span>利用する</span></label><br />
508 <label><input name="bank_activate" type="radio" id="bank_activate_jpayment_2" value="off"<?php checked( $bank_activate, 'off' ); ?> /><span>利用しない</span></label>
509 </td>
510 </tr>
511 <tr id="ex_bank_jpayment" class="explanation"><td colspan="2">バンクチェック決済を利用するかどうか。</td></tr>
512 </table>
513 <input name="acting" type="hidden" value="jpayment" />
514 <input name="usces_option_update" type="submit" class="button button-primary" value="<?php echo esc_attr( $this->acting_name ); ?> の設定を更新する" />
515 <?php wp_nonce_field( 'admin_settlement', 'wc_nonce' ); ?>
516 </form>
517 <div class="settle_exp">
518 <p><strong><?php echo esc_html( $this->acting_formal_name ); ?></strong></p>
519 <a href="<?php echo esc_url( $this->acting_company_url ); ?>" target="_blank"><?php echo esc_html( $this->acting_name ); ?> の詳細はこちら </a>
520 <p> </p>
521 <p>この決済は「外部リンク型」の決済システムです。</p>
522 <p>「外部リンク型」とは、決済会社のページへ遷移してカード�
523 報を�
524 �力する決済システムです。</p>
525 </div>
526 </div><!--uscestabs_jpayment-->
527 <?php
528 endif;
529 }
530
531 /**
532 * 受注データ登録
533 * Called by usces_reg_orderdata() and usces_new_orderdata().
534 * usces_action_reg_orderdata
535 *
536 * @param array $args Compact array( $cart, $entry, $order_id, $member_id, $payments, $charging_type, $results ).
537 */
538 public function register_orderdata( $args ) {
539 global $usces;
540 extract( $args );
541
542 $acting_flg = $payments['settlement'];
543 if ( ! in_array( $acting_flg, $this->pay_method ) ) {
544 return;
545 }
546
547 if ( ! $entry['order']['total_full_price'] ) {
548 return;
549 }
550
551 if ( isset( $_REQUEST['acting'] ) && ( 'jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'] ) ) {
552 $usces->set_order_meta_value( 'settlement_id', wp_unslash( $_GET['cod'] ), $order_id );
553 if ( ! empty( $_GET['gid'] ) ) {
554 $usces->set_order_meta_value( 'wc_trans_id', wp_unslash( $_GET['gid'] ), $order_id );
555 }
556 foreach ( $_GET as $key => $value ) {
557 if ( 'purchase_jpayment' != $key ) {
558 $data[ $key ] = wp_unslash( $value );
559 }
560 }
561 $usces->set_order_meta_value( 'acting_' . wp_unslash( $_REQUEST['acting'] ), serialize( $data ), $order_id );
562 }
563 }
564
565 /**
566 * 管理画面送信メール
567 * usces_filter_order_confirm_mail_payment
568 *
569 * @param string $msg_payment Payment information message.
570 * @param int $order_id Order number.
571 * @param array $payment Payment data.
572 * @param array $cart Cart data.
573 * @param array $data Order data.
574 * @return string
575 */
576 public function order_confirm_mail_payment( $msg_payment, $order_id, $payment, $cart, $data ) {
577 global $usces;
578
579 if ( 'acting_jpayment_conv' == $payment['settlement'] ) {
580 $args = maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
581 $msg_payment .= '決済番号 : ' . $args['gid'] . "\r\n";
582 $msg_payment .= '決済金額 : ' . number_format( $args['ta'] ) . __( 'dollars', 'usces' ) . "\r\n";
583 $msg_payment .= 'お支払�
584 � : ' . usces_get_conv_name( $args['cv'] ) . "\r\n";
585 $msg_payment .= 'コンビニ受付番号 : ' . $args['no'] . "\r\n";
586 if ( '030' != $args['cv'] ) { /* ファミリーマート以外 */
587 $msg_payment .= 'コンビニ受付番号�
588 報URL : ' . $args['cu'] . "\r\n";
589 }
590 $msg_payment .= "\r\n" . usces_mail_line( 2, $data['order_email'] ) . "\r\n";
591
592 } elseif ( 'acting_jpayment_bank' == $payment['settlement'] ) {
593 $args = maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
594 $msg_payment .= '決済番号 : ' . $args['gid'] . "\r\n";
595 $msg_payment .= '決済金額 : ' . number_format( $args['ta'] ) . __( 'dollars', 'usces' ) . "\r\n";
596 $bank = explode( '.', $args['bank'] );
597 $msg_payment .= '銀行コード : ' . $bank[0] . "\r\n";
598 $msg_payment .= '銀行名 : ' . $bank[1] . "\r\n";
599 $msg_payment .= '支店コード : ' . $bank[2] . "\r\n";
600 $msg_payment .= '支店名 : ' . $bank[3] . "\r\n";
601 $msg_payment .= '口座種別 : ' . $bank[4] . "\r\n";
602 $msg_payment .= '口座番号 : ' . $bank[5] . "\r\n";
603 $msg_payment .= '口座名義 : ' . $bank[6] . "\r\n";
604 $msg_payment .= '支払期限 : ' . substr( $args['exp'], 0, 4 ) . '' . substr( $args['exp'], 4, 2 ) . '' . substr( $args['exp'], 6, 2 ) . "日\r\n";
605 $msg_payment .= "\r\n" . usces_mail_line( 2, $data['order_email'] ) . "\r\n";
606 }
607 return $msg_payment;
608 }
609
610 /**
611 * サンキューメール
612 * usces_filter_send_order_mail_payment
613 *
614 * @param string $msg_payment Payment method message.
615 * @param int $order_id Order number.
616 * @param array $payment Payment data.
617 * @param array $cart Cart data.
618 * @param array $entry Entry data.
619 * @param array $data Order data.
620 * @return string
621 */
622 public function send_order_mail_payment( $msg_payment, $order_id, $payment, $cart, $entry, $data ) {
623 global $usces;
624
625 if ( 'acting_jpayment_conv' == $payment['settlement'] ) {
626 $args = maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
627 $msg_payment .= '決済番号 : ' . $args['gid'] . "\r\n";
628 $msg_payment .= '決済金額 : ' . number_format( $args['ta'] ) . __( 'dollars', 'usces' ) . "\r\n";
629 $msg_payment .= 'お支払�
630 � : ' . usces_get_conv_name( $args['cv'] ) . "\r\n";
631 $msg_payment .= 'コンビニ受付番号 : ' . $args['no'] . "\r\n";
632 if ( '030' != $args['cv'] ) { /* ファミリーマート以外 */
633 $msg_payment .= 'コンビニ受付番号�
634 報URL : ' . $args['cu'] . "\r\n";
635 }
636 $msg_payment .= "\r\n" . usces_mail_line( 2, $entry['customer']['mailaddress1'] ) . "\r\n";
637
638 } elseif ( 'acting_jpayment_bank' == $payment['settlement'] ) {
639 $args = maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
640 $msg_payment .= '決済番号 : ' . $args['gid'] . "\r\n";
641 $msg_payment .= '決済金額 : ' . number_format( $args['ta'] ) . __( 'dollars', 'usces' ) . "\r\n";
642 $bank = explode( '.', $args['bank'] );
643 $msg_payment .= '銀行コード : ' . $bank[0] . "\r\n";
644 $msg_payment .= '銀行名 : ' . $bank[1] . "\r\n";
645 $msg_payment .= '支店コード : ' . $bank[2] . "\r\n";
646 $msg_payment .= '支店名 : ' . $bank[3] . "\r\n";
647 $msg_payment .= '口座種別 : ' . $bank[4] . "\r\n";
648 $msg_payment .= '口座番号 : ' . $bank[5] . "\r\n";
649 $msg_payment .= '口座名義 : ' . $bank[6] . "\r\n";
650 $msg_payment .= '支払期限 : ' . substr( $args['exp'], 0, 4 ) . '' . substr( $args['exp'], 4, 2 ) . '' . substr( $args['exp'], 6, 2 ) . "\r\n";
651 $msg_payment .= "\r\n" . usces_mail_line( 2, $entry['customer']['mailaddress1'] ) . "\r\n";
652 }
653 return $msg_payment;
654 }
655
656 /**
657 * 支払方法説明
658 * usces_filter_payment_detail
659 *
660 * @param string $str Payment method description.
661 * @param array $entry Entry data.
662 * @return string
663 */
664 public function payment_detail( $str, $entry ) {
665 $payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
666 if ( isset( $payment['settlement'] ) && 'acting_jpayment_conv' == $payment['settlement'] ) {
667 $acting_opts = $this->get_acting_settings();
668 if ( ! empty( $acting_opts['conv_limit'] ) ) {
669 $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['conv_limit'] ) . __( ')', 'usces' );
670 $str = apply_filters( 'usces_filter_jpayment_payment_limit_conv', $payment_detail, $acting_opts['conv_limit'] );
671 }
672 }
673 return $str;
674 }
675
676 /**
677 * 購�
678 �完了メッセージ
679 * usces_filter_completion_settlement_message
680 *
681 * @param string $form Purchase complete message.
682 * @param array $entry Entry data.
683 * @return string
684 */
685 public function completion_settlement_message( $form, $entry ) {
686 global $usces;
687
688 if ( isset( $_REQUEST['acting'] ) && 'jpayment_conv' == $_REQUEST['acting'] ) {
689 $form .= '<div id="status_table"><h5>' . esc_html( $this->acting_formal_name ) . ' コンビニペーパーレス決済</h5>';
690 $form .= '<table>';
691 $form .= '<tr><th>決済番号</th><td>' . esc_html( wp_unslash( $_GET['gid'] ) ) . '</td></tr>';
692 $form .= '<tr><th>決済金額</th><td>' . esc_html( wp_unslash( $_GET['ta'] ) ) . '</td></tr>';
693 $form .= '<tr><th>お支払�
694 �</th><td>' . esc_html( usces_get_conv_name( wp_unslash( $_GET['cv'] ) ) ) . '</td></tr>';
695 $form .= '<tr><th>コンビニ受付番号</th><td>' . esc_html( wp_unslash( $_GET['no'] ) ) . '</td></tr>';
696 if ( '030' != wp_unslash( $_GET['cv'] ) ) { /* ファミリーマート以外 */
697 $form .= '<tr><th>コンビニ受付番号�
698 報URL</th><td><a href="' . esc_html( wp_unslash( $_GET['cu'] ) ) . '" target="_blank">' . esc_html( wp_unslash( $_GET['cu'] ) ) . '</a></td></tr>';
699 }
700 $form .= '</table>';
701 $form .= '<p>「お支払いのご案�
702 」は、' . esc_html( $entry['customer']['mailaddress1'] ) . ' 宛にメールさせていただいております。</p>';
703 $form .= '</div>';
704 }
705 return $form;
706 }
707
708 /**
709 * 決済オプション取得
710 *
711 * @return array
712 */
713 protected function get_acting_settings() {
714 global $usces;
715
716 $acting_settings = ( isset( $usces->options['acting_settings'][ $this->paymod_id ] ) ) ? $usces->options['acting_settings'][ $this->paymod_id ] : array();
717 return $acting_settings;
718 }
719 }
720