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

PaymentDSK.class.php in Welcart e-Commerce 2.12.4, at classes/PaymentDSK.class.php

408 lines 20.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * DSK 電算システム
4 *
5 * @package Welcart
6 * @author Collne Inc.
7 * @version 1.0.1
8 * @since 1.4.14
9 */
10 class DSK_SETTLEMENT extends SBPS_MAIN {
11
12 /**
13 * Instance of this class.
14 *
15 * @var object
16 */
17 protected static $instance = null;
18
19 /**
20 * Construct.
21 */
22 public function __construct() {
23
24 $this->acting_name = 'DSK';
25 $this->acting_formal_name = 'DSK 電算システム';
26
27 $this->acting_card = 'dsk_card';
28 $this->acting_conv = 'dsk_conv';
29 $this->acting_payeasy = 'dsk_payeasy';
30 $this->acting_wallet = 'dsk_wallet';
31 $this->acting_mobile = 'dsk_mobile';
32
33 $this->acting_flg_card = 'acting_dsk_card';
34 $this->acting_flg_conv = 'acting_dsk_conv';
35 $this->acting_flg_payeasy = 'acting_dsk_payeasy';
36 $this->acting_flg_wallet = 'acting_dsk_wallet';
37 $this->acting_flg_mobile = 'acting_dsk_mobile';
38
39 $this->pay_method = array(
40 'acting_dsk_card',
41 'acting_dsk_conv',
42 'acting_dsk_payeasy',
43 );
44
45 parent::__construct( 'dsk' );
46
47 $this->initialize_data();
48 }
49
50 /**
51 * Return an instance of this class.
52 */
53 public static function get_instance() {
54 if ( is_null( self::$instance ) ) {
55 self::$instance = new self();
56 }
57 return self::$instance;
58 }
59
60 /**
61 * Initialize
62 */
63 public function initialize_data() {
64 $options = get_option( 'usces', array() );
65
66 $options['acting_settings']['dsk']['merchant_id'] = ( isset( $options['acting_settings']['dsk']['merchant_id'] ) ) ? $options['acting_settings']['dsk']['merchant_id'] : '';
67 $options['acting_settings']['dsk']['service_id'] = ( isset( $options['acting_settings']['dsk']['service_id'] ) ) ? $options['acting_settings']['dsk']['service_id'] : '';
68 $options['acting_settings']['dsk']['hash_key'] = ( isset( $options['acting_settings']['dsk']['hash_key'] ) ) ? $options['acting_settings']['dsk']['hash_key'] : '';
69 $options['acting_settings']['dsk']['ope'] = ( isset( $options['acting_settings']['dsk']['ope'] ) ) ? $options['acting_settings']['dsk']['ope'] : '';
70 $options['acting_settings']['dsk']['card_activate'] = ( isset( $options['acting_settings']['dsk']['card_activate'] ) ) ? $options['acting_settings']['dsk']['card_activate'] : 'off';
71 $options['acting_settings']['dsk']['3d_secure'] = ( isset( $options['acting_settings']['dsk']['3d_secure'] ) ) ? $options['acting_settings']['dsk']['3d_secure'] : 'off';
72 $options['acting_settings']['dsk']['conv_activate'] = ( isset( $options['acting_settings']['dsk']['conv_activate'] ) ) ? $options['acting_settings']['dsk']['conv_activate'] : 'off';
73 $options['acting_settings']['dsk']['conv_limit'] = ( isset( $options['acting_settings']['dsk']['conv_limit'] ) ) ? $options['acting_settings']['dsk']['conv_limit'] : '';
74 $options['acting_settings']['dsk']['payeasy_activate'] = ( isset( $options['acting_settings']['dsk']['payeasy_activate'] ) ) ? $options['acting_settings']['dsk']['payeasy_activate'] : 'off';
75 $options['acting_settings']['dsk']['wallet_activate'] = 'off';
76 $options['acting_settings']['dsk']['mobile_activate'] = 'off';
77 update_option( 'usces', $options );
78
79 $available_settlement = get_option( 'usces_available_settlement', array() );
80 if ( ! in_array( 'dsk', $available_settlement ) ) {
81 $available_settlement['dsk'] = $this->acting_formal_name;
82 update_option( 'usces_available_settlement', $available_settlement );
83 }
84
85 $noreceipt_status = get_option( 'usces_noreceipt_status', array() );
86 if ( ! in_array( 'acting_dsk_conv', $noreceipt_status ) || ! in_array( 'acting_dsk_payeasy', $noreceipt_status ) ) {
87 $noreceipt_status[] = 'acting_dsk_conv';
88 $noreceipt_status[] = 'acting_dsk_payeasy';
89 update_option( 'usces_noreceipt_status', $noreceipt_status );
90 }
91
92 $this->unavailable_method = array( 'acting_sbps_card', 'acting_sbps_conv', 'acting_sbps_payeasy', 'acting_sbps_wallet', 'acting_sbps_mobile' );
93 }
94
95 /**
96 * Admin script.
97 * admin_print_footer_scripts
98 */
99 public function admin_scripts() {
100
101 $admin_page = ( isset( $_GET['page'] ) ) ? wp_unslash( $_GET['page'] ) : '';
102 switch ( $admin_page ) :
103 case 'usces_settlement':
104 $settlement_selected = get_option( 'usces_settlement_selected', array() );
105 if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) :
106 $acting_opts = $this->get_acting_settings();
107 ?>
108 <script type="text/javascript">
109 jQuery( document ).ready( function( $ ) {
110
111 var dsk_card_activate = "<?php echo esc_js( $acting_opts['card_activate'] ); ?>";
112 var dsk_conv_activate = "<?php echo esc_js( $acting_opts['conv_activate'] ); ?>";
113 if( "on" == dsk_card_activate ) {
114 $( ".card_link_dsk" ).css( "display", "" );
115 } else {
116 $( ".card_link_dsk" ).css( "display", "none" );
117 }
118
119 $( document ).on( "change", ".card_activate_dsk", function() {
120 if( "on" == $( this ).val() ) {
121 $( ".card_link_dsk" ).css( "display", "" );
122 } else {
123 $( ".card_link_dsk" ).css( "display", "none" );
124 }
125 });
126
127 if ( "on" == dsk_conv_activate ) {
128 $( ".conv_dsk" ).css( "display", "" );
129 } else {
130 $( ".conv_dsk" ).css( "display", "none" );
131 }
132
133 $( document ).on( "change", ".conv_activate_dsk", function() {
134 if( "on" == $( this ).val() ) {
135 $( ".conv_dsk" ).css( "display", "" );
136 } else {
137 $( ".conv_dsk" ).css( "display", "none" );
138 }
139 });
140 });
141 </script>
142 <?php
143 endif;
144 break;
145 endswitch;
146 }
147
148 /**
149 * 決済オプション登録・更新
150 * usces_action_admin_settlement_update
151 */
152 public function settlement_update() {
153 global $usces;
154
155 if ( isset( $_POST['page'] ) && 'dsk' !== wp_unslash( $_POST['page'] ) ) {
156 return;
157 }
158
159 $this->error_mes = '';
160 $options = get_option( 'usces', array() );
161 $payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
162 $post_data = wp_unslash( $_POST );
163
164 unset( $options['acting_settings']['dsk'] );
165 $options['acting_settings']['dsk']['merchant_id'] = ( isset( $post_data['merchant_id'] ) ) ? trim( $post_data['merchant_id'] ) : '';
166 $options['acting_settings']['dsk']['service_id'] = ( isset( $post_data['service_id'] ) ) ? trim( $post_data['service_id'] ) : '';
167 $options['acting_settings']['dsk']['hash_key'] = ( isset( $post_data['hash_key'] ) ) ? trim( $post_data['hash_key'] ) : '';
168 $options['acting_settings']['dsk']['ope'] = ( isset( $post_data['ope'] ) ) ? $post_data['ope'] : '';
169 $options['acting_settings']['dsk']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : 'off';
170 $options['acting_settings']['dsk']['3d_secure'] = ( isset( $post_data['3d_secure'] ) ) ? $post_data['3d_secure'] : 'off';
171 $options['acting_settings']['dsk']['conv_activate'] = ( isset( $post_data['conv_activate'] ) ) ? $post_data['conv_activate'] : 'off';
172 $options['acting_settings']['dsk']['conv_limit'] = ( isset( $post_data['conv_limit'] ) ) ? $post_data['conv_limit'] : '';
173 $options['acting_settings']['dsk']['payeasy_activate'] = ( isset( $post_data['payeasy_activate'] ) ) ? $post_data['payeasy_activate'] : 'off';
174 $options['acting_settings']['dsk']['wallet_activate'] = 'off';
175 $options['acting_settings']['dsk']['mobile_activate'] = 'off';
176
177 if ( 'on' === $options['acting_settings']['dsk']['card_activate'] || 'on' === $options['acting_settings']['dsk']['conv_activate'] || 'on' === $options['acting_settings']['dsk']['payeasy_activate'] ) {
178 $unavailable_activate = false;
179 foreach ( $payment_method as $settlement => $payment ) {
180 if ( in_array( $settlement, $this->unavailable_method ) && 'activate' === $payment['use'] ) {
181 $unavailable_activate = true;
182 break;
183 }
184 }
185 if ( $unavailable_activate ) {
186 $this->error_mes .= __( '* Settlement that can not be used together is activated.', 'usces' ) . '<br />';
187 } else {
188 if ( WCUtils::is_blank( $post_data['merchant_id'] ) ) {
189 $this->error_mes .= '※マーチャントID を�
190 �力してください<br />';
191 }
192 if ( WCUtils::is_blank( $post_data['service_id'] ) ) {
193 $this->error_mes .= '※サービスID を�
194 �力してください<br />';
195 }
196 if ( WCUtils::is_blank( $post_data['hash_key'] ) ) {
197 $this->error_mes .= '※ハッシュキーを�
198 �力してください<br />';
199 }
200 }
201 }
202
203 if ( '' === $this->error_mes ) {
204 $usces->action_status = 'success';
205 $usces->action_message = __( 'Options are updated.', 'usces' );
206 if ( 'on' === $options['acting_settings']['dsk']['card_activate'] || 'on' === $options['acting_settings']['dsk']['conv_activate'] || 'on' === $options['acting_settings']['dsk']['payeasy_activate'] ) {
207 $options['acting_settings']['dsk']['activate'] = 'on';
208 $options['acting_settings']['dsk']['send_url'] = 'https://fep.sps-system.com/f01/FepBuyInfoReceive.do';
209 $options['acting_settings']['dsk']['send_url_check'] = 'https://stbfep.sps-system.com/Extra/BuyRequestAction.do';
210 $options['acting_settings']['dsk']['send_url_test'] = 'https://stbfep.sps-system.com/f01/FepBuyInfoReceive.do';
211 $options['acting_settings']['dsk']['token_url'] = '';
212 $options['acting_settings']['dsk']['token_url_test'] = '';
213 $options['acting_settings']['dsk']['api_url'] = '';
214 $options['acting_settings']['dsk']['api_url_test'] = '';
215 $options['acting_settings']['dsk']['cust_url'] = '';
216 $options['acting_settings']['dsk']['cust_url_test'] = '';
217 $toactive = array();
218 if ( 'on' === $options['acting_settings']['dsk']['card_activate'] ) {
219 $usces->payment_structure[ $this->acting_flg_card ] = 'カード決済(DSK)';
220 foreach ( $payment_method as $settlement => $payment ) {
221 if ( $this->acting_flg_card === $settlement && 'deactivate' === $payment['use'] ) {
222 $toactive[] = $payment['name'];
223 }
224 }
225 } else {
226 unset( $usces->payment_structure[ $this->acting_flg_card ] );
227 }
228 if ( 'on' === $options['acting_settings']['dsk']['conv_activate'] ) {
229 $usces->payment_structure[ $this->acting_flg_conv ] = 'コンビニ決済(DSK)';
230 foreach ( $payment_method as $settlement => $payment ) {
231 if ( $this->acting_flg_conv === $settlement && 'deactivate' === $payment['use'] ) {
232 $toactive[] = $payment['name'];
233 }
234 }
235 } else {
236 unset( $usces->payment_structure[ $this->acting_flg_conv ] );
237 }
238 if ( 'on' === $options['acting_settings']['dsk']['payeasy_activate'] ) {
239 $usces->payment_structure[ $this->acting_flg_payeasy ] = 'ペイジー決済(DSK)';
240 foreach ( $payment_method as $settlement => $payment ) {
241 if ( $this->acting_flg_payeasy === $settlement && 'deactivate' === $payment['use'] ) {
242 $toactive[] = $payment['name'];
243 }
244 }
245 } else {
246 unset( $usces->payment_structure[ $this->acting_flg_payeasy ] );
247 }
248 usces_admin_orderlist_show_wc_trans_id();
249 if ( 0 < count( $toactive ) ) {
250 $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' );
251 }
252 } else {
253 $options['acting_settings']['dsk']['activate'] = 'off';
254 unset( $usces->payment_structure[ $this->acting_flg_card ] );
255 unset( $usces->payment_structure[ $this->acting_flg_conv ] );
256 unset( $usces->payment_structure[ $this->acting_flg_payeasy ] );
257 }
258 $deactivate = array();
259 foreach ( $payment_method as $settlement => $payment ) {
260 if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
261 if ( 'deactivate' !== $payment['use'] ) {
262 $payment['use'] = 'deactivate';
263 $deactivate[] = $payment['name'];
264 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
265 }
266 }
267 }
268 if ( 0 < count( $deactivate ) ) {
269 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
270 $usces->action_message .= $deactivate_message;
271 }
272 } else {
273 $usces->action_status = 'error';
274 $usces->action_message = __( 'Data have deficiency.', 'usces' );
275 $options['acting_settings']['dsk']['activate'] = 'off';
276 unset( $usces->payment_structure[ $this->acting_flg_card ] );
277 unset( $usces->payment_structure[ $this->acting_flg_conv ] );
278 unset( $usces->payment_structure[ $this->acting_flg_payeasy ] );
279 $deactivate = array();
280 foreach ( $payment_method as $settlement => $payment ) {
281 if ( in_array( $settlement, $this->pay_method ) ) {
282 if ( 'deactivate' !== $payment['use'] ) {
283 $payment['use'] = 'deactivate';
284 $deactivate[] = $payment['name'];
285 usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
286 }
287 }
288 }
289 if ( 0 < count( $deactivate ) ) {
290 $deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
291 $usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
292 }
293 }
294 ksort( $usces->payment_structure );
295 update_option( 'usces', $options );
296 update_option( 'usces_payment_structure', $usces->payment_structure );
297 }
298
299 /**
300 * クレジット決済設定画面フォーム
301 * usces_action_settlement_tab_body
302 */
303 public function settlement_tab_body() {
304
305 $settlement_selected = get_option( 'usces_settlement_selected', array() );
306 if ( in_array( 'dsk', (array) $settlement_selected ) ) :
307 $acting_opts = $this->get_acting_settings();
308 $merchant_id = isset( $acting_opts['merchant_id'] ) ? $acting_opts['merchant_id'] : '';
309 $service_id = isset( $acting_opts['service_id'] ) ? $acting_opts['service_id'] : '';
310 $hash_key = isset( $acting_opts['hash_key'] ) ? $acting_opts['hash_key'] : '';
311 ?>
312 <div id="uscestabs_dsk">
313 <div class="settlement_service"><span class="service_title"><?php echo esc_html( $this->acting_formal_name ); ?></span></div>
314 <?php
315 if ( isset( $_POST['acting'] ) && 'dsk' === wp_unslash( $_POST['acting'] ) ) :
316 if ( '' !== $this->error_mes ) :
317 ?>
318 <div class="error_message"><?php wel_esc_script_e( $this->error_mes ); ?></div>
319 <?php
320 elseif ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) :
321 ?>
322 <div class="message"><?php esc_html_e( 'Test thoroughly before use.', 'usces' ); ?></div>
323 <?php
324 endif;
325 endif;
326 ?>
327 <form action="" method="post" name="dsk_form" id="dsk_form">
328 <table class="settle_table">
329 <tr>
330 <th><a class="explanation-label" id="ex_merchant_id_dsk">マーチャントID</a></th>
331 <td><input name="merchant_id" type="text" id="merchant_id_dsk" value="<?php echo esc_attr( $merchant_id ); ?>" class="regular-text" maxlength="5" /></td>
332 </tr>
333 <tr id="ex_merchant_id_dsk" class="explanation"><td colspan="2">契約時にDSKから発行されるマーチャントID(半角数字)</td></tr>
334 <tr>
335 <th><a class="explanation-label" id="label_ex_service_id_dsk">サービスID</a></th>
336 <td><input name="service_id" type="text" id="service_id_dsk" value="<?php echo esc_attr( $service_id ); ?>" class="regular-text" maxlength="3" /></td>
337 </tr>
338 <tr id="ex_service_id_dsk" class="explanation"><td colspan="2">契約時にDSKから発行されるサービスID(半角数字)</td></tr>
339 <tr>
340 <th><a class="explanation-label" id="label_ex_hash_key_sk">ハッシュキー</a></th>
341 <td><input name="hash_key" type="text" id="hash_key_dsk" value="<?php echo esc_attr( $hash_key ); ?>" class="regular-text" maxlength="40" /></td>
342 </tr>
343 <tr id="ex_hash_key_dsk" class="explanation"><td colspan="2">契約時にDSKから発行されるハッシュキー(半角英数)</td></tr>
344 <tr>
345 <th><a class="explanation-label" id="label_ex_ope_dsk"><?php esc_html_e( 'Operation Environment', 'usces' ); ?></a></th>
346 <td><label><input name="ope" type="radio" id="ope_dsk_1" value="check"<?php checked( $acting_opts['ope'], 'check' ); ?> /><span>接続支援サイト</span></label><br />
347 <label><input name="ope" type="radio" id="ope_dsk_2" value="test"<?php checked( $acting_opts['ope'], 'test' ); ?> /><span>テスト環境</span></label><br />
348 <label><input name="ope" type="radio" id="ope_dsk_3" value="public"<?php checked( $acting_opts['ope'], 'public' ); ?> /><span>本番環境</span></label>
349 </td>
350 </tr>
351 <tr id="ex_ope_dsk" class="explanation"><td colspan="2"><?php esc_html_e( 'Switch the operating environment.', 'usces' ); ?></td></tr>
352 </table>
353 <table class="settle_table">
354 <tr>
355 <th>クレジットカード決済</th>
356 <td><label><input name="card_activate" type="radio" class="card_activate_dsk" id="card_activate_dsk_1" value="on"<?php checked( $acting_opts['card_activate'], 'on' ); ?> /><span><?php esc_html_e( 'Use', 'usces' ); ?></span></label><br />
357 <label><input name="card_activate" type="radio" class="card_activate_dsk" id="card_activate_dsk_0" value="off"<?php checked( $acting_opts['card_activate'], 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
358 </td>
359 </tr>
360 <tr class="card_link_dsk">
361 <th>3Dセキュア</th>
362 <td><label><input name="3d_secure" type="radio" id="3d_secure_dsk_1" value="on"<?php checked( $acting_opts['3d_secure'], 'on' ); ?> /><span><?php esc_html_e( 'Use', 'usces' ); ?></span></label><br />
363 <label><input name="3d_secure" type="radio" id="3d_secure_dsk_2" value="off"<?php checked( $acting_opts['3d_secure'], 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
364 </td>
365 </tr>
366 </table>
367 <table class="settle_table">
368 <tr>
369 <th>コンビニ決済</th>
370 <td><label><input name="conv_activate" type="radio" class="conv_activate_dsk" id="conv_activate_dsk_1" value="on"<?php checked( $acting_opts['conv_activate'], 'on' ); ?> /><span><?php esc_html_e( 'Use', 'usces' ); ?></span></label><br />
371 <label><input name="conv_activate" type="radio" class="conv_activate_dsk" id="conv_activate_dsk_2" value="off"<?php checked( $acting_opts['conv_activate'], 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
372 </td>
373 </tr>
374 <tr class="conv_dsk">
375 <th><a class="explanation-label" id="label_ex_conv_limit_dsk"><?php esc_html_e( 'Payment due days', 'usces' ); ?></a></th>
376 <td><input name="conv_limit" type="text" id="conv_limit" value="<?php echo esc_attr( $acting_opts['conv_limit'] ); ?>" class="small-text" /><?php esc_html_e( 'days', 'usces' ); ?>(1~59)</td>
377 </tr>
378 <tr id="ex_conv_limit_dsk" class="explanation"><td colspan="2">未設定の場合は申込時に設定した既定値となります。ここでの変更は、申込時に設定した既定値以�
379 の指定が可能(既定値が14日の場合、13日まで)となります。既定値が不明な場合はDSKにお問い合わせください。</td></tr>
380 </table>
381 <table class="settle_table">
382 <tr>
383 <th>Pay-easy(ペイジー)決済</th>
384 <td><label><input name="payeasy_activate" type="radio" id="payeasy_activate_dsk_1" value="on"<?php checked( $acting_opts['payeasy_activate'], 'on' ); ?> /><span><?php esc_html_e( 'Use', 'usces' ); ?></span></label><br />
385 <label><input name="payeasy_activate" type="radio" id="payeasy_activate_dsk_2" value="off"<?php checked( $acting_opts['payeasy_activate'], 'off' ); ?> /><span><?php esc_html_e( 'Do not Use', 'usces' ); ?></span></label>
386 </td>
387 </tr>
388 </table>
389 <input name="acting" type="hidden" value="dsk" />
390 <input name="usces_option_update" type="submit" class="button button-primary" value="DSK の設定を更新する" />
391 <?php wp_nonce_field( 'admin_settlement', 'wc_nonce' ); ?>
392 </form>
393 <div class="settle_exp">
394 <p><strong>DSK 株式会社電算システム</strong></p>
395 <a href="https://www.welcart.com/wc-settlement/dsk_guide/" target="_blank">DSK の詳細はこちら </a>
396 <p></p>
397 <p>この決済は「外部リンク型」の決済システムです。</p>
398 <p>「外部リンク型」とは、決済会社のページへ遷移してカード�
399 報を�
400 �力する決済システムです。</p>
401 <p>尚、本番環境では、正規SSL証明書のみでのSSL通信となりますのでご注意ください。</p>
402 </div>
403 </div><!-- uscestabs_dsk -->
404 <?php
405 endif;
406 }
407 }
408