| 1 |
<?php |
| 2 |
/** |
| 3 |
* The instant Paidy Dashboard class. |
| 4 |
* |
| 5 |
* @package Welcart |
| 6 |
* @author Collne Inc. |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Class InstantPaidyDashboard |
| 11 |
*/ |
| 12 |
class InstantPaidyDashboard { |
| 13 |
/** |
| 14 |
* The Welcart api server url. |
| 15 |
* |
| 16 |
* @var string BASE_API_URL |
| 17 |
*/ |
| 18 |
const BASE_API_URL = 'https://api.welcart.com/'; |
| 19 |
|
| 20 |
/** |
| 21 |
* The paidy waiting status. |
| 22 |
* |
| 23 |
* @var string WAITING_STATUS |
| 24 |
*/ |
| 25 |
const WAITING_STATUS = 1; |
| 26 |
|
| 27 |
/** |
| 28 |
* The paidy approved status. |
| 29 |
* |
| 30 |
* @var string APPROVED_STATUS |
| 31 |
*/ |
| 32 |
const APPROVED_STATUS = 2; |
| 33 |
|
| 34 |
/** |
| 35 |
* The paidy denied status. |
| 36 |
* |
| 37 |
* @var string DENIED_STATUS |
| 38 |
*/ |
| 39 |
const DENIED_STATUS = 3; |
| 40 |
|
| 41 |
/** |
| 42 |
* The paidy canceled status. |
| 43 |
* |
| 44 |
* @var string CANCELED_STATUS |
| 45 |
*/ |
| 46 |
const CANCELED_STATUS = 4; |
| 47 |
|
| 48 |
/** |
| 49 |
* The annual value options. |
| 50 |
* |
| 51 |
* @var object $annual_value_options |
| 52 |
*/ |
| 53 |
private $annual_value_options = array( |
| 54 |
'1' => '1億円未満', |
| 55 |
'2' => '1億円以上', |
| 56 |
); |
| 57 |
|
| 58 |
/** |
| 59 |
* Inittal key to generate iv. |
| 60 |
* |
| 61 |
* @var string INITIAL |
| 62 |
*/ |
| 63 |
const INITIAL = 'eXZscmRpb3NpOXNvbGJqaD'; |
| 64 |
|
| 65 |
/** |
| 66 |
* Algo |
| 67 |
* |
| 68 |
* @var string AES_128_CBC |
| 69 |
*/ |
| 70 |
const AES_128_CBC = 'AES-128-CBC'; |
| 71 |
|
| 72 |
/** |
| 73 |
* The average prices options. |
| 74 |
* |
| 75 |
* @var object $average_price_options |
| 76 |
*/ |
| 77 |
private $average_price_options = array( |
| 78 |
'1' => '5万円未満', |
| 79 |
'2' => '5万円以上', |
| 80 |
); |
| 81 |
|
| 82 |
/** |
| 83 |
* The instance of this class. |
| 84 |
* |
| 85 |
* @var object $instance |
| 86 |
*/ |
| 87 |
private static $instance = null; |
| 88 |
|
| 89 |
/** |
| 90 |
* The error message. |
| 91 |
* |
| 92 |
* @var string $error |
| 93 |
*/ |
| 94 |
private $error = ''; |
| 95 |
|
| 96 |
/** |
| 97 |
* The instant Paidy settings. |
| 98 |
* |
| 99 |
* @var string $settings |
| 100 |
*/ |
| 101 |
private $settings = array( |
| 102 |
'status' => '', |
| 103 |
); |
| 104 |
|
| 105 |
/** |
| 106 |
* Constructor |
| 107 |
* |
| 108 |
* @access private |
| 109 |
*/ |
| 110 |
private function __construct() {} |
| 111 |
|
| 112 |
/** |
| 113 |
* Create the instance of the "InstantPaidyWidget" class. |
| 114 |
*/ |
| 115 |
public static function get_instance() { |
| 116 |
if ( empty( self::$instance ) ) { |
| 117 |
self::$instance = new self(); |
| 118 |
self::$instance->get_settings(); |
| 119 |
} |
| 120 |
|
| 121 |
return self::$instance; |
| 122 |
} |
| 123 |
|
| 124 |
/** |
| 125 |
* Receive the response of the Paidy server. |
| 126 |
*/ |
| 127 |
public function receive_paidy_result() { |
| 128 |
$received = false; |
| 129 |
$status = (int) filter_input( INPUT_POST, 'status' ); |
| 130 |
$is_approved = self::APPROVED_STATUS === $status; |
| 131 |
$is_denied = self::DENIED_STATUS === $status; |
| 132 |
$is_canceled = self::CANCELED_STATUS === $status; |
| 133 |
$is_result_valid = $is_approved || $is_denied || $is_canceled; |
| 134 |
$current_setting = $this->get_settings(); |
| 135 |
|
| 136 |
if ( ! $current_setting ) { |
| 137 |
wp_send_json_error(); |
| 138 |
return; |
| 139 |
} |
| 140 |
|
| 141 |
if ( $is_approved ) { |
| 142 |
$public_live = filter_input( INPUT_POST, 'public_live' ); |
| 143 |
$secret_live = filter_input( INPUT_POST, 'secret_live' ); |
| 144 |
$public_test = filter_input( INPUT_POST, 'public_test' ); |
| 145 |
$secret_test = filter_input( INPUT_POST, 'secret_test' ); |
| 146 |
$is_valid_key = ! empty( $public_live ) && ! empty( $secret_live ); |
| 147 |
|
| 148 |
if ( self::DENIED_STATUS === (int) $current_setting['status'] || self::APPROVED_STATUS === (int) $current_setting['status'] ) { |
| 149 |
|
| 150 |
$is_result_valid = false; |
| 151 |
|
| 152 |
} elseif ( $is_valid_key ) { |
| 153 |
|
| 154 |
$this->settings['status'] = self::APPROVED_STATUS; |
| 155 |
$this->settings['public_live'] = self::decrypt( $public_live ); |
| 156 |
$this->settings['secret_live'] = self::decrypt( $secret_live ); |
| 157 |
$this->settings['public_test'] = self::decrypt( $public_test ); |
| 158 |
$this->settings['secret_test'] = self::decrypt( $secret_test ); |
| 159 |
$this->activate_paidy( 'preparation' ); |
| 160 |
$is_result_valid = true; |
| 161 |
|
| 162 |
} else { |
| 163 |
|
| 164 |
$is_result_valid = false; |
| 165 |
|
| 166 |
} |
| 167 |
|
| 168 |
} elseif ( $is_denied ) { |
| 169 |
|
| 170 |
if ( self::DENIED_STATUS === (int) $current_setting['status'] || self::APPROVED_STATUS === (int) $current_setting['status'] ) { |
| 171 |
|
| 172 |
$is_result_valid = false; |
| 173 |
|
| 174 |
} else { |
| 175 |
|
| 176 |
$this->settings['status'] = self::DENIED_STATUS; |
| 177 |
$this->deactivate_paidy(); |
| 178 |
$is_result_valid = true; |
| 179 |
} |
| 180 |
|
| 181 |
} elseif ( $is_canceled ) { |
| 182 |
|
| 183 |
$this->settings['status'] = 0; |
| 184 |
$this->settings['denied'] = ''; |
| 185 |
$this->settings['mode'] = ''; |
| 186 |
$this->deactivate_paidy(); |
| 187 |
$is_result_valid = true; |
| 188 |
|
| 189 |
} |
| 190 |
|
| 191 |
if ( $is_result_valid ) { |
| 192 |
$this->update_settings(); |
| 193 |
$received = true; |
| 194 |
} |
| 195 |
|
| 196 |
if ( $received ) { |
| 197 |
wp_send_json_success(); |
| 198 |
} else { |
| 199 |
wp_send_json_error(); |
| 200 |
} |
| 201 |
} |
| 202 |
|
| 203 |
/** |
| 204 |
* Decrypt the encrypted key value. |
| 205 |
* |
| 206 |
* @param string $encrypted_value The encrypted value. |
| 207 |
* @return string $value |
| 208 |
*/ |
| 209 |
public static function decrypt( $encrypted_value ) { |
| 210 |
$passphrase = get_option( 'usces_wcid' ); |
| 211 |
|
| 212 |
if ( empty( trim( $encrypted_value ) ) ) { |
| 213 |
return $encrypted_value; |
| 214 |
} |
| 215 |
|
| 216 |
$iv = base64_decode( self::INITIAL ); |
| 217 |
$encrypted_value = base64_decode( $encrypted_value ); |
| 218 |
$value = openssl_decrypt( $encrypted_value, self::AES_128_CBC, $passphrase, OPENSSL_RAW_DATA, $iv ); |
| 219 |
return $value; |
| 220 |
} |
| 221 |
|
| 222 |
/** |
| 223 |
* Check if the Paidy payment is active or not. |
| 224 |
* |
| 225 |
* @return bool true|false |
| 226 |
*/ |
| 227 |
public function is_paidy_active() { |
| 228 |
$options = get_option( 'usces', array() ); |
| 229 |
$active = isset( $options['acting_settings']['paidy']['activate'] ) && 'on' === $options['acting_settings']['paidy']['activate'] |
| 230 |
&& isset( $options['acting_settings']['paidy']['paidy_activate'] ) && 'on' === $options['acting_settings']['paidy']['paidy_activate'] |
| 231 |
&& ( '' === $this->settings['status'] || isset( $this->settings['mode'] ) && 'publish' === $this->settings['mode'] ); |
| 232 |
return $active; |
| 233 |
} |
| 234 |
|
| 235 |
/** |
| 236 |
* Implementation of hook "wp_dashboard_setup()". |
| 237 |
*/ |
| 238 |
public function register_widget() { |
| 239 |
$user = wp_get_current_user(); |
| 240 |
$showed = ( in_array( 'wc_management', (array) $user->roles, true ) || in_array( 'administrator', (array) $user->roles, true ) ) |
| 241 |
&& ! $this->is_paidy_active() |
| 242 |
&& empty( $this->settings['denied'] ); |
| 243 |
if ( $showed ) { |
| 244 |
wp_add_dashboard_widget( 'dashboard_instant_paidy', 'ペイディ決済らくらく設定', array( $this, 'display' ) ); |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
/** |
| 249 |
* Render dashboard instant Paidy widget. |
| 250 |
*/ |
| 251 |
public function display() { |
| 252 |
global $usces; |
| 253 |
|
| 254 |
$this->enqueue_script(); |
| 255 |
$company = isset( $usces->options['company_name'] ) ? $usces->options['company_name'] : ''; |
| 256 |
$email = isset( $usces->options['inquiry_mail'] ) ? $usces->options['inquiry_mail'] : ''; |
| 257 |
$tel = isset( $usces->options['tel_number'] ) ? $usces->options['tel_number'] : ''; |
| 258 |
$site_name = get_bloginfo( 'name' ); |
| 259 |
$home_url = home_url(); |
| 260 |
|
| 261 |
$is_registed_paidy = ! empty( $this->settings['status'] ); |
| 262 |
$status = $is_registed_paidy ? $this->settings['status'] : ''; |
| 263 |
$mode = empty( $this->settings['mode'] ) ? '' : $this->settings['mode']; |
| 264 |
$paidy_pic = USCES_PLUGIN_URL . '/images/paidy-pic.png'; |
| 265 |
$is_waiting = $is_registed_paidy && self::WAITING_STATUS === $status; |
| 266 |
$is_denied = $is_registed_paidy && self::DENIED_STATUS === $status; |
| 267 |
$is_approved = $is_registed_paidy && self::APPROVED_STATUS === $status; |
| 268 |
$is_canceled = $is_registed_paidy && self::CANCELED_STATUS === $status; |
| 269 |
$is_test_mode = $is_approved && 'test' === $mode; |
| 270 |
$is_publish_mode = $is_approved && 'publish' === $mode; |
| 271 |
?> |
| 272 |
<?php if ( $is_registed_paidy ) : ?> |
| 273 |
<?php if ( $is_waiting ) : ?> |
| 274 |
<table class="paidy-waiting-screen"> |
| 275 |
<tr> |
| 276 |
<td><span style="color:#E30E80; font-weight: bold;">ステータス:審査中です</span> |
| 277 |
<p>お申込みありがとうございました。<br>審査結果はメールおよび、このダッシュボードで通知いたします。</p> |
| 278 |
<ul style="margin-left: 20px; list-style-type: circle;"> |
| 279 |
<li>審査には最大10営業日かかることがございます。</li> |
| 280 |
<li>審査に関するお問い合わせ:sales@paidy.com</li> |
| 281 |
</ul> |
| 282 |
</td> |
| 283 |
</tr> |
| 284 |
</table> |
| 285 |
<?php endif; ?> |
| 286 |
<?php if ( $is_denied ) : ?> |
| 287 |
<table class="paidy-denied-screen"> |
| 288 |
<tr> |
| 289 |
<td> |
| 290 |
<span style="color:#E30E80; font-weight: bold;">ステータス:審査は否決されました</span> |
| 291 |
<p> |
| 292 |
� |
| 293 |
�重に審査を重ねました結果、誠に申し訳ございませんが、今回はお取引を見送らせていただくこととなりました。<br>このたびはご希望に添えない結果となり、誠に申し訳ございません。<br>審査� |
| 294 |
容の詳細については、お答えいたしかねますのでご了承ください。 |
| 295 |
</p> |
| 296 |
<a href="#" class="button" style="background-color: #E30E80; color:white; float:left;">閉じる</a> |
| 297 |
</td> |
| 298 |
</tr> |
| 299 |
</table> |
| 300 |
<?php endif; ?> |
| 301 |
<?php if ( $is_approved ) : ?> |
| 302 |
<?php if ( ! $is_test_mode && ! $is_publish_mode ) : ?> |
| 303 |
<table class="paidy-approved-screen"> |
| 304 |
<tr> |
| 305 |
<td> |
| 306 |
<span style="color:#E30E80; font-weight: bold;">ステータス:審査は承認されました</span> |
| 307 |
<p>審査が完了し、加盟店契約が成立いたしました。<br>ご利用条件はPaidy合同会社から送信されるメールの条件通知書をご確認ください。</p> |
| 308 |
<p>本番モードで� |
| 309 |
�開前にWebhook URLをペイディ加盟店管理画面へ設定することを推奨します。<br>Webhook URLには次の値を設定してください。<br>[テスト・本番� |
| 310 |
�通] <br> |
| 311 |
<pre><?php echo esc_url( home_url( '/' ) ); ?></pre> |
| 312 |
ペイディ加盟店管理画面については<a href="https://download.paidy.com/merchant/PaidyMerchantWebUserGuide.pdf" style="color:#E30E80;" target="_blank">マニュアル</a>をご覧ください。 |
| 313 |
</p> |
| 314 |
<p>下記のいずれかのボタンをクリックしてください。</p> |
| 315 |
<a href="#" class="button test-paidy-btn" style="width: 200px; background-color: #E30E80; color:white; float:left;">テストモードを有効化する</a> |
| 316 |
<br class="clear"> |
| 317 |
<a href="#" class="button publish-paidy-btn" style="width: 200px; background-color: #E30E80; color:white; float:left; margin-top: 5px;">本番モードで� |
| 318 |
�開する</a><br> |
| 319 |
</td> |
| 320 |
</tr> |
| 321 |
</table> |
| 322 |
<?php endif; ?> |
| 323 |
<?php if ( $is_test_mode ) : ?> |
| 324 |
<table class="paidy-test-mode-screen"> |
| 325 |
<tr> |
| 326 |
<td> |
| 327 |
<p><b>ペイディのテスト決済が有効化されました。</b><br> |
| 328 |
基本設定の支払方法に「あと払い(ペイディ)」が追加されて「使用」の状� |
| 329 |
�になっているのを確認後、購� |
| 330 |
�テストを行ってください。</p> |
| 331 |
<p>テスト決済方法は<a href="https://paidy.com/docs/jp/testing.html" target="_blank" style="color:#E30E80;">こちら</a>をご覧ください。</p> |
| 332 |
<p>テスト完了後、以下のボタンから本番モードで� |
| 333 |
�開してください。</p> |
| 334 |
<a href="#" class="button publish-paidy-btn" style="width: 200px; background-color: #E30E80; color:white; float:left; margin-top: 5px;">本番モードで� |
| 335 |
�開する</a><br> |
| 336 |
</td> |
| 337 |
</tr> |
| 338 |
</table> |
| 339 |
<?php endif; ?> |
| 340 |
<table class="paidy-publish-mode-screen" style="display:none;"> |
| 341 |
<tr> |
| 342 |
<td> |
| 343 |
<p><b>ペイディ決済が� |
| 344 |
�開されました。</b></p> |
| 345 |
<p>本� |
| 346 |
目を閉じた後、操作方法などを確認する場合は クレジット決済設定 > ペイディ > 【資料】をご参� |
| 347 |
�ください。</p> |
| 348 |
<p> </p> |
| 349 |
<p><a href="#" class="button finish-paidy-btn" onClick="location.reload();" style="width: 200px; background-color: #E30E80; color:white; float:left; margin-top: 5px;">閉じる</a></p> |
| 350 |
</td> |
| 351 |
</tr> |
| 352 |
</table> |
| 353 |
<?php endif; ?> |
| 354 |
<?php else : ?> |
| 355 |
<table class="paidy-intro-screen"> |
| 356 |
<tr> |
| 357 |
<td><a href="https://paidy.com/campaign/merchant/202404_WW/" target="_blank"><img src="<?php echo esc_url( $paidy_pic ); ?>" style="margin-right: 20px;" /></a></td> |
| 358 |
<td> |
| 359 |
ペイディの新規申し込みと設定が簡単に行えます。 |
| 360 |
<br> |
| 361 |
<a href="#" class="button next-paidy-form-btn" style="background-color: #E30E80; color:white;">今すぐ始める</a> |
| 362 |
</td> |
| 363 |
</tr> |
| 364 |
<tr> |
| 365 |
<td colspan="2">導� |
| 366 |
�コスト0円、決済手数料3.5� |
| 367 |
~、本経由申込で、なんとお試し1か月決済手数料無料!詳細は<a href="https://paidy.com/campaign/merchant/202404_WW/" target="_blank">こちら</a></td> |
| 368 |
</tr> |
| 369 |
<tr> |
| 370 |
<td colspan="2" style="text-align: right;"><a href="#" id="hide_paidy_widget">非表示</a></td> |
| 371 |
</tr> |
| 372 |
</table> |
| 373 |
<form id="paidy-form" style="display:none;"> |
| 374 |
<table class="paidy-form"> |
| 375 |
<tr> |
| 376 |
<th colspan="2" style="border-bottom: 1px solid black; text-align: left;">お申し込みフロー</th> |
| 377 |
</tr> |
| 378 |
<tr> |
| 379 |
<td colspan="2"> |
| 380 |
<ol style="margin-left: 20px;"> |
| 381 |
<li>本申込み画面の� |
| 382 |
目を� |
| 383 |
�て記� |
| 384 |
�し、画面下の「上記へ同意して申込み」ボタンをクリックしてください。</li> |
| 385 |
<li>申込� |
| 386 |
報をもとにペイディにて加盟店審査を行います。最大10営業日かかることがございます。</li> |
| 387 |
<li>審査結果はメールおよびWelcartダッシュボードにて通知いたします。</li> |
| 388 |
<li>審査承認時は、Welcartのダッシュボードからペイディを有効化できます。審査否決時は、ペイディをご利用いただくことはできません。</li> |
| 389 |
</ol> |
| 390 |
</td> |
| 391 |
</tr> |
| 392 |
<tr><th colspan="2" style="border-bottom: 1px solid black; text-align: left;"><br>基本� |
| 393 |
報</th></tr> |
| 394 |
<tr> |
| 395 |
<th style="text-align:left;"><br>商号/屋号</th> |
| 396 |
<td><br> |
| 397 |
<input type="text" id="company" name="company" required class="validate" style="width: 100%;" value="<?php echo esc_attr( $company ); ?>"/> |
| 398 |
</td> |
| 399 |
</tr> |
| 400 |
<tr> |
| 401 |
<th style="text-align:left;">貴社のECサイト名</th> |
| 402 |
<td> |
| 403 |
<input type="text" name="site_name" required class="validate" style="width: 100%;" value="<?php echo esc_attr( $site_name ); ?>"/> |
| 404 |
</td> |
| 405 |
</tr> |
| 406 |
<tr> |
| 407 |
<th style="text-align:left;">貴社のECサイトURL</th> |
| 408 |
<td> |
| 409 |
<input type="url" name="site_url" required class="validate" style="width: 100%;" value="<?php echo esc_attr( $home_url ); ?>"/> |
| 410 |
</td> |
| 411 |
</tr> |
| 412 |
<tr> |
| 413 |
<th style="text-align:left;">ペイディ登録用メールアドレス</th> |
| 414 |
<td> |
| 415 |
<input type="email" name="email" required class="validate" style="width: 100%;" value="<?php echo esc_attr( $email ); ?>"/> |
| 416 |
</td> |
| 417 |
</tr> |
| 418 |
<tr> |
| 419 |
<th style="text-align:left;">ご� |
| 420 |
当窓口電話番号</th> |
| 421 |
<td> |
| 422 |
<input type="tel" name="tel" required class="validate" style="width: 100%;" value="<?php echo esc_attr( $tel ); ?>"/> |
| 423 |
</td> |
| 424 |
</tr> |
| 425 |
<tr> |
| 426 |
<th style="text-align:left;">代表� |
| 427 |
(姓名)</th> |
| 428 |
<td> |
| 429 |
<input type="text" name="name" required class="validate" style="width: 100%;"/> |
| 430 |
</td> |
| 431 |
</tr> |
| 432 |
<tr> |
| 433 |
<th style="text-align:left;">代表� |
| 434 |
カナ(セイメイ)</th> |
| 435 |
<td> |
| 436 |
<input type="text" name="name_kana" required class="validate" style="width: 100%;"/> |
| 437 |
</td> |
| 438 |
</tr> |
| 439 |
<tr> |
| 440 |
<th style="text-align:left;">代表� |
| 441 |
生年月日(西暦)</th> |
| 442 |
<td> |
| 443 |
<input type="date" name="birthday" required class="validate" style="width: 100%;"/> |
| 444 |
</td> |
| 445 |
</tr> |
| 446 |
<tr> |
| 447 |
<th style="text-align:left;">年間流通総額</th> |
| 448 |
<td> |
| 449 |
<?php foreach ( $this->annual_value_options as $key => $label ) : ?> |
| 450 |
<input type="radio" name="annual_value" value="<?php echo esc_attr( $key ); ?>" <?php checked( '1', $key ); ?>/><?php echo esc_html( $label ); ?> |
| 451 |
<?php endforeach; ?> |
| 452 |
</td> |
| 453 |
</tr> |
| 454 |
<tr> |
| 455 |
<th style="text-align:left;">ご注文あたりの平均購� |
| 456 |
�額</th> |
| 457 |
<td> |
| 458 |
<?php foreach ( $this->average_price_options as $key => $label ) : ?> |
| 459 |
<input type="radio" name="average_price" value="<?php echo esc_attr( $key ); ?>" <?php checked( '1', $key ); ?> /><?php echo esc_html( $label ); ?> |
| 460 |
<?php endforeach; ?> |
| 461 |
</td> |
| 462 |
</tr> |
| 463 |
<tr> |
| 464 |
<th colspan="2" style="border-bottom: 1px solid black; text-align: left;"><br>セキュリティアンケート</th> |
| 465 |
</tr> |
| 466 |
<tr> |
| 467 |
<td colspan="2"><br> |
| 468 |
<input type="checkbox" id="squestion1" name="squestion1" value="1" checked /><label for="squestion1">カートシステム管理画面へのアクセス(ログイン)には、パスワードの� |
| 469 |
�力が� |
| 470 |
須となっている。</label> |
| 471 |
</td> |
| 472 |
</tr> |
| 473 |
<tr> |
| 474 |
<td colspan="2"> |
| 475 |
<input type="checkbox" id="squestion2" name="squestion2" value="1" checked /><label for="squestion2">カートシステムの管理画面は、ID、パスワードでのログイン制限の他、アクセス制限が可能となっている。</label> |
| 476 |
</td> |
| 477 |
</tr> |
| 478 |
<tr> |
| 479 |
<td colspan="2"> |
| 480 |
<input type="checkbox" id="squestion3" name="squestion3" value="1" checked /> |
| 481 |
<label for="squestion3">管理画面アクセス制限等について下記のうちいずれかの対応が可能となっている。</label> |
| 482 |
<ul style="margin-left: 20px; list-style-type: circle;"> |
| 483 |
<li>管理� |
| 484 |
にてアクセス可能なIPアドレスを制限可能。</li> |
| 485 |
<li>管理画面にベーシック認証等のアクセス制限の設定が可能。</li> |
| 486 |
<li>その他の方法で対応をしている。</li> |
| 487 |
</ul> |
| 488 |
</td> |
| 489 |
</tr> |
| 490 |
<tr> |
| 491 |
<td colspan="2"> |
| 492 |
<input type="checkbox" id="squestion4" name="squestion4" value="1" checked /> |
| 493 |
<label for="squestion4">データディレクトリ*の露見に対する設定が下記のいずれかの方法でされている。</label> |
| 494 |
<ul style="margin-left: 20px; list-style-type: circle;"> |
| 495 |
<li>� |
| 496 |
�開ディレクトリには、重要なファイルを� |
| 497 |
�置出来ないよう、特定のディレクトリを非� |
| 498 |
�開にする。</li> |
| 499 |
<li>� |
| 500 |
�開ディレクトリ以外に重要なファイルを� |
| 501 |
�置する等の� |
| 502 |
�� |
| 503 |
�がある。</li> |
| 504 |
</ul> |
| 505 |
</td> |
| 506 |
</tr> |
| 507 |
<tr> |
| 508 |
<td colspan="2"> |
| 509 |
<input type="checkbox" id="squestion5" name="squestion5" value="1" checked /> |
| 510 |
<label for="squestion5">WebサーバやWebアプリケーションによりアップロード可能な拡張子やファイルを制限する等の設定を行っている。</label> |
| 511 |
<ul style="margin-left: 20px; list-style-type: circle;"> |
| 512 |
<li>その他の方法で対応している。</li> |
| 513 |
</ul> |
| 514 |
</td> |
| 515 |
</tr> |
| 516 |
<tr> |
| 517 |
<td colspan="2"> |
| 518 |
<input type="checkbox" id="squestion6" name="squestion6" value="1" checked /> |
| 519 |
<label for="squestion6">脆弱性診断またはペネトレーションテスト*を定期的(年1回またはシステム変更時)に実施している。</label> |
| 520 |
<ul style="margin-left: 20px; list-style-type: circle;"> |
| 521 |
<li>脆弱性診断またはペネトレーションテストを定期的に実施し、� |
| 522 |
要な修正対応を行っている。</li> |
| 523 |
<li>SQLインジェクションの脆弱性やクロスサイトスクリプティングの脆弱性対策として、当該脆弱性の無いプラグインの使用やソフトウェアのバージョンアップを実施している。</li> |
| 524 |
<li>Webアプリケーションを開発またはカスタマイズされている場合には、セキュアコーディング済みであるか、ソースコードレビューを行い確認している。その際には、� |
| 525 |
�力フォームの� |
| 526 |
�力値のチェックも行っている。</li> |
| 527 |
<li>その他の方法で対応している。</li> |
| 528 |
</ul> |
| 529 |
</td> |
| 530 |
</tr> |
| 531 |
<tr> |
| 532 |
<td colspan="2"> |
| 533 |
<input type="checkbox" id="squestion7" name="squestion7" value="1" checked /> |
| 534 |
<label for="squestion7">マルウェア対策としてのウイルス対策ソフトの導� |
| 535 |
�、運用を下記方法等で行っている。</label> |
| 536 |
<ul style="margin-left: 20px; list-style-type: circle;"> |
| 537 |
<li>マルウェア検知/除去などの対策としてウイルス対策ソフトを導� |
| 538 |
�して、シグネチャーの更新や定期的なフルスキャンなどを行っている。</li> |
| 539 |
<li>その他の方法で対応している。</li> |
| 540 |
</ul> |
| 541 |
</td> |
| 542 |
</tr> |
| 543 |
<tr> |
| 544 |
<td colspan="2"><br> |
| 545 |
<input type="checkbox" id="squestion8" name="squestion8" value="1" checked /><label for="squestion8">直近5年間に、特定商取引に関する法律による処分受けたことがない。</label> |
| 546 |
</td> |
| 547 |
</tr> |
| 548 |
<tr> |
| 549 |
<td colspan="2"><br> |
| 550 |
<input type="checkbox" id="squestion9" name="squestion9" value="1" checked /><label for="squestion9">直近5年間に、消費� |
| 551 |
契約法違反の行為を理由とした民事上の訴訟を提起され、敗訴判決を受けたことがない。</label> |
| 552 |
</td> |
| 553 |
</tr> |
| 554 |
<tr> |
| 555 |
<th colspan="2" style="border-bottom: 1px solid black; text-align: left;"><br>同意事� |
| 556 |
</th> |
| 557 |
</tr> |
| 558 |
<tr> |
| 559 |
<td colspan="2"><br> |
| 560 |
下記の� |
| 561 |
容についてご確認・ご同意ください。 |
| 562 |
<ol> |
| 563 |
<li><a href="https://terms.paidy.com/docs/merchant-terms-and-conditions.pdf" target="_blank">ペイディ加盟店規約</a></li> |
| 564 |
<li><a href="https://terms.paidy.com/docs/agreement-on-handling-of-comprehensive-member-shop-and-member-shop-information.pdf" target="_blank">加盟店� |
| 565 |
報の取扱いに関する同意条� |
| 566 |
</a></li> |
| 567 |
<li>特定商取引法に基づく表記に弊社所定の表記を追加すること。<br><a href="https://merchant-support.paidy.com/hc/ja/articles/16629903258649" target="_blank">特商法に基づく表示サンプル</a></li> |
| 568 |
<li>プライバシーポリシーページに弊社所定の表記を追加すること。<br><a href="https://merchant-support.paidy.com/hc/ja/articles/16631714849561" target="_blank">プライバシーポリシーの記� |
| 569 |
�例</a></li> |
| 570 |
<li>Paidy合同会社が、Welcartを介して貴社に代わり、ECサイトへAPIキーの設定を行うこと。</li> |
| 571 |
<li>当社(株式会社Welcart)は、以下の場合に、個人� |
| 572 |
報を第三� |
| 573 |
に提供いたします。 |
| 574 |
<ul style="margin-left: 20px; list-style-type: circle;"> |
| 575 |
<li>決済会社での加盟店審査等のために個人� |
| 576 |
報を開示する場合。</li> |
| 577 |
</ul> |
| 578 |
</li> |
| 579 |
</ol> |
| 580 |
</td> |
| 581 |
</tr> |
| 582 |
<tr id="msgs"> |
| 583 |
<td colspan="2"> |
| 584 |
</td> |
| 585 |
</tr> |
| 586 |
<tr> |
| 587 |
<td colspan="2"> |
| 588 |
<a href="javascript:void(0);" class="button send-paidy-form-btn" style="background-color: #E30E80; color:white; float:right;">上記� |
| 589 |
容へ同意して申し込み</a> |
| 590 |
</td> |
| 591 |
</tr> |
| 592 |
</table> |
| 593 |
</form> |
| 594 |
<?php endif; ?> |
| 595 |
<input id="loading-img" type="hidden" value="<?php echo esc_url( USCES_PLUGIN_URL . 'images/loading.gif' ); ?>"> |
| 596 |
<input type="hidden" id="paidy_widget_nonce" name="paidy_widget_nonce" value="<?php echo esc_attr( wp_create_nonce( 'paidy_widget_nonce' ) ); ?>" /> |
| 597 |
|
| 598 |
<?php |
| 599 |
} |
| 600 |
|
| 601 |
/** |
| 602 |
* Implementation of hook wp_ajax_{paidy_application} |
| 603 |
*/ |
| 604 |
public function handle_ajax() { |
| 605 |
$sub_action = filter_input( INPUT_POST, 'sub_action' ); |
| 606 |
switch ( $sub_action ) { |
| 607 |
case 'registered': |
| 608 |
check_ajax_referer( 'paidy_widget_nonce', 'wcnonce' ); |
| 609 |
$application = array( |
| 610 |
'company' => filter_input( INPUT_POST, 'company' ), |
| 611 |
'site_name' => filter_input( INPUT_POST, 'site_name' ), |
| 612 |
'site_url' => filter_input( INPUT_POST, 'site_url' ), |
| 613 |
'email' => filter_input( INPUT_POST, 'email' ), |
| 614 |
'tel' => filter_input( INPUT_POST, 'tel' ), |
| 615 |
'name' => filter_input( INPUT_POST, 'name' ), |
| 616 |
'name_kana' => filter_input( INPUT_POST, 'name_kana' ), |
| 617 |
'birthday' => filter_input( INPUT_POST, 'birthday' ), |
| 618 |
'annual_value' => filter_input( INPUT_POST, 'annual_value' ), |
| 619 |
'average_price' => filter_input( INPUT_POST, 'average_price' ), |
| 620 |
'wcid' => get_option( 'usces_wcid', '' ), |
| 621 |
'questionnaire' => filter_input( INPUT_POST, 'questionnaire' ), |
| 622 |
); |
| 623 |
|
| 624 |
$submited = $this->submit_paidy_application( $application ); |
| 625 |
if ( $submited ) { |
| 626 |
$this->settings['status'] = self::WAITING_STATUS; |
| 627 |
$this->update_settings(); |
| 628 |
wp_send_json_success(); |
| 629 |
} else { |
| 630 |
wp_send_json_error( array( 'msg' => $this->error ) ); |
| 631 |
} |
| 632 |
break; |
| 633 |
case 'close_paidy_widget': |
| 634 |
check_ajax_referer( 'paidy_widget_nonce', 'wcnonce' ); |
| 635 |
$this->settings['denied'] = '1'; |
| 636 |
$this->update_settings(); |
| 637 |
wp_send_json_success(); |
| 638 |
break; |
| 639 |
case 'set_paidy_test_mode': |
| 640 |
check_ajax_referer( 'paidy_widget_nonce', 'wcnonce' ); |
| 641 |
$this->activate_paidy( 'test' ); |
| 642 |
$this->settings['mode'] = 'test'; |
| 643 |
$this->update_settings(); |
| 644 |
wp_send_json_success(); |
| 645 |
break; |
| 646 |
case 'set_paidy_publish_mode': |
| 647 |
check_ajax_referer( 'paidy_widget_nonce', 'wcnonce' ); |
| 648 |
$this->activate_paidy( 'live' ); |
| 649 |
$this->settings['mode'] = 'publish'; |
| 650 |
$this->update_settings(); |
| 651 |
wp_send_json_success(); |
| 652 |
break; |
| 653 |
case 'hide_paidy_widget': |
| 654 |
check_ajax_referer( 'paidy_widget_nonce', 'wcnonce' ); |
| 655 |
|
| 656 |
$user_id = get_current_user_id(); |
| 657 |
$hidden_widgets = get_user_meta( $user_id, 'metaboxhidden_dashboard', true ); |
| 658 |
|
| 659 |
if ( is_array( $hidden_widgets ) ) { |
| 660 |
if ( ! in_array( 'dashboard_instant_paidy', $hidden_widgets ) ) { |
| 661 |
$hidden_widgets[] = 'dashboard_instant_paidy'; |
| 662 |
} |
| 663 |
} else { |
| 664 |
$hidden_widgets = array( 'dashboard_instant_paidy' ); |
| 665 |
} |
| 666 |
|
| 667 |
update_user_meta( $user_id, 'metaboxhidden_dashboard', $hidden_widgets ); |
| 668 |
wp_send_json_success(); |
| 669 |
break; |
| 670 |
} |
| 671 |
} |
| 672 |
|
| 673 |
/** |
| 674 |
* Activate paidy payment. |
| 675 |
* |
| 676 |
* @param string $environment The environment. |
| 677 |
* @return bool true|false |
| 678 |
*/ |
| 679 |
private function activate_paidy( $environment ) { |
| 680 |
|
| 681 |
if ( 'preparation' === $environment ) { |
| 682 |
|
| 683 |
/** |
| 684 |
* クレジット決済設定>ペイディオプション |
| 685 |
* Welcart Shop > Settlement Setting |
| 686 |
*/ |
| 687 |
$paidy_key = 'paidy'; |
| 688 |
$options = get_option( 'usces', array() ); |
| 689 |
$options['acting_settings'][ $paidy_key ] = array( |
| 690 |
'activate' => 'on', |
| 691 |
'paidy_activate' => 'off', |
| 692 |
'environment' => 'test', |
| 693 |
'public_key' => $this->settings['public_live'], |
| 694 |
'secret_key' => $this->settings['secret_live'], |
| 695 |
'public_key_test' => $this->settings['public_test'], |
| 696 |
'secret_key_test' => $this->settings['secret_test'], |
| 697 |
); |
| 698 |
update_option( 'usces', $options ); |
| 699 |
|
| 700 |
} elseif ( 'test' === $environment ) { |
| 701 |
|
| 702 |
/** |
| 703 |
* クレジット決済設定>ペイディオプション |
| 704 |
* Welcart Shop > Settlement Setting |
| 705 |
*/ |
| 706 |
$paidy_key = 'paidy'; |
| 707 |
$options = get_option( 'usces', array() ); |
| 708 |
$options['acting_settings'][ $paidy_key ] = array( |
| 709 |
'activate' => 'on', |
| 710 |
'paidy_activate' => 'on', |
| 711 |
'environment' => 'test', |
| 712 |
'public_key' => $this->settings['public_live'], |
| 713 |
'secret_key' => $this->settings['secret_live'], |
| 714 |
'public_key_test' => $this->settings['public_test'], |
| 715 |
'secret_key_test' => $this->settings['secret_test'], |
| 716 |
); |
| 717 |
update_option( 'usces', $options ); |
| 718 |
|
| 719 |
/** |
| 720 |
* クレジット決済設定>利用中のクレジット決済モジュール. |
| 721 |
* Welcart Shop > Settlement Setting > Selecting a Settlement Module. |
| 722 |
*/ |
| 723 |
$settlement_selected = get_option( 'usces_settlement_selected', array() ); |
| 724 |
if ( ! in_array( $paidy_key, $settlement_selected, true ) ) { |
| 725 |
$settlement_selected[] = $paidy_key; |
| 726 |
update_option( 'usces_settlement_selected', $settlement_selected ); |
| 727 |
} |
| 728 |
|
| 729 |
/** |
| 730 |
* 基本設定>支払方法>「決済種別」に追加. |
| 731 |
* Welcart Shop > General Setting > payment method > Type of payment. |
| 732 |
*/ |
| 733 |
$payment_structure = get_option( 'usces_payment_structure', array() ); |
| 734 |
$payment_structure['acting_paidy'] = 'Paidy'; |
| 735 |
ksort( $payment_structure ); |
| 736 |
update_option( 'usces_payment_structure', $payment_structure ); |
| 737 |
|
| 738 |
/** |
| 739 |
* 基本設定>「支払方法」に追加. |
| 740 |
* Welcart Shop > General Setting > payment method. |
| 741 |
*/ |
| 742 |
$usces_payment_methods = usces_get_system_option( 'usces_payment_method', 'settlement' ); |
| 743 |
if ( empty( $usces_payment_methods['acting_paidy'] ) ) { |
| 744 |
$payment_methods = get_option( 'usces_payment_method', array() ); |
| 745 |
$id = $this->generate_payment_id( $payment_methods ); |
| 746 |
$sort = $this->generate_payment_sort( $payment_methods ); |
| 747 |
|
| 748 |
$payment = array( |
| 749 |
'id' => $id, |
| 750 |
'name' => 'あと払い(ペイディ)', |
| 751 |
'explanation' => '<ul> |
| 752 |
<li>クレジットカード、事前登録不要。</li> |
| 753 |
<li>メールアドレスと携帯番号だけで、今すぐお買い物。</li> |
| 754 |
<li>1か月に何度お買い物しても、お支払いは翌月まとめて1回でOK。</li> |
| 755 |
<li>お支払いは翌月10日までに、コンビニ払い・銀行振込・口座振替で。</li> |
| 756 |
</ul>', |
| 757 |
'settlement' => 'acting_paidy', |
| 758 |
'module' => '', |
| 759 |
'sort' => $sort, |
| 760 |
'use' => 'activate', |
| 761 |
); |
| 762 |
usces_update_system_option( 'usces_payment_method', $id, $payment ); |
| 763 |
} else { |
| 764 |
$acting_paidy = $usces_payment_methods['acting_paidy']; |
| 765 |
$acting_paidy['use'] = 'activate'; |
| 766 |
usces_update_system_option( 'usces_payment_method', $acting_paidy['id'], $acting_paidy ); |
| 767 |
} |
| 768 |
|
| 769 |
} elseif ( 'live' === $environment ) { |
| 770 |
|
| 771 |
/** |
| 772 |
* クレジット決済設定>ペイディオプション |
| 773 |
* Welcart Shop > Settlement Setting |
| 774 |
*/ |
| 775 |
$paidy_key = 'paidy'; |
| 776 |
$options = get_option( 'usces', array() ); |
| 777 |
$options['acting_settings'][ $paidy_key ] = array( |
| 778 |
'activate' => 'on', |
| 779 |
'paidy_activate' => 'on', |
| 780 |
'environment' => 'live', |
| 781 |
'public_key' => $this->settings['public_live'], |
| 782 |
'secret_key' => $this->settings['secret_live'], |
| 783 |
'public_key_test' => $this->settings['public_test'], |
| 784 |
'secret_key_test' => $this->settings['secret_test'], |
| 785 |
); |
| 786 |
update_option( 'usces', $options ); |
| 787 |
|
| 788 |
/** |
| 789 |
* クレジット決済設定>利用中のクレジット決済モジュール. |
| 790 |
* Welcart Shop > Settlement Setting > Selecting a Settlement Module. |
| 791 |
*/ |
| 792 |
$settlement_selected = get_option( 'usces_settlement_selected', array() ); |
| 793 |
if ( ! in_array( $paidy_key, $settlement_selected, true ) ) { |
| 794 |
$settlement_selected[] = $paidy_key; |
| 795 |
update_option( 'usces_settlement_selected', $settlement_selected ); |
| 796 |
} |
| 797 |
|
| 798 |
/** |
| 799 |
* 基本設定>支払方法>「決済種別」に追加. |
| 800 |
* Welcart Shop > General Setting > payment method > Type of payment. |
| 801 |
*/ |
| 802 |
$payment_structure = get_option( 'usces_payment_structure', array() ); |
| 803 |
$payment_structure['acting_paidy'] = 'Paidy'; |
| 804 |
ksort( $payment_structure ); |
| 805 |
update_option( 'usces_payment_structure', $payment_structure ); |
| 806 |
|
| 807 |
/** |
| 808 |
* 基本設定>「支払方法」に追加. |
| 809 |
* Welcart Shop > General Setting > payment method. |
| 810 |
*/ |
| 811 |
$usces_payment_methods = usces_get_system_option( 'usces_payment_method', 'settlement' ); |
| 812 |
if ( empty( $usces_payment_methods['acting_paidy'] ) ) { |
| 813 |
$payment_methods = get_option( 'usces_payment_method', array() ); |
| 814 |
$id = $this->generate_payment_id( $payment_methods ); |
| 815 |
$sort = $this->generate_payment_sort( $payment_methods ); |
| 816 |
|
| 817 |
$payment = array( |
| 818 |
'id' => $id, |
| 819 |
'name' => 'あと払い(ペイディ)', |
| 820 |
'explanation' => '<ul> |
| 821 |
<li>クレジットカード、事前登録不要。</li> |
| 822 |
<li>メールアドレスと携帯番号だけで、今すぐお買い物。</li> |
| 823 |
<li>1か月に何度お買い物しても、お支払いは翌月まとめて1回でOK。</li> |
| 824 |
<li>お支払いは翌月10日までに、コンビニ払い・銀行振込・口座振替で。</li> |
| 825 |
</ul>', |
| 826 |
'settlement' => 'acting_paidy', |
| 827 |
'module' => '', |
| 828 |
'sort' => $sort, |
| 829 |
'use' => 'activate', |
| 830 |
); |
| 831 |
usces_update_system_option( 'usces_payment_method', $id, $payment ); |
| 832 |
} else { |
| 833 |
$acting_paidy = $usces_payment_methods['acting_paidy']; |
| 834 |
$acting_paidy['use'] = 'activate'; |
| 835 |
usces_update_system_option( 'usces_payment_method', $acting_paidy['id'], $acting_paidy ); |
| 836 |
} |
| 837 |
} |
| 838 |
|
| 839 |
return true; |
| 840 |
} |
| 841 |
|
| 842 |
/** |
| 843 |
* Deactivate paidy payment. |
| 844 |
* |
| 845 |
* @return bool true|false |
| 846 |
*/ |
| 847 |
private function deactivate_paidy() { |
| 848 |
/** |
| 849 |
* クレジット決済設定>ペイディオプション |
| 850 |
* Welcart Shop > Settlement Setting |
| 851 |
*/ |
| 852 |
$paidy_key = 'paidy'; |
| 853 |
$options = get_option( 'usces', array() ); |
| 854 |
$options['acting_settings'][ $paidy_key ] = array( |
| 855 |
'activate' => 'on', |
| 856 |
'paidy_activate' => 'off', |
| 857 |
'environment' => 'test', |
| 858 |
'public_key' => '', |
| 859 |
'secret_key' => '', |
| 860 |
'public_key_test' => '', |
| 861 |
'secret_key_test' => '', |
| 862 |
); |
| 863 |
update_option( 'usces', $options ); |
| 864 |
|
| 865 |
/** |
| 866 |
* 基本設定>「支払方法」>削除. |
| 867 |
* Welcart Shop > General Setting > payment method. |
| 868 |
*/ |
| 869 |
$usces_payment_methods = usces_get_system_option( 'usces_payment_method', 'settlement' ); |
| 870 |
if ( ! empty( $usces_payment_methods['acting_paidy'] ) ) { |
| 871 |
$acting_paidy = $usces_payment_methods['acting_paidy']; |
| 872 |
usces_del_system_option( 'usces_payment_method', $acting_paidy['id'] ); |
| 873 |
} |
| 874 |
|
| 875 |
/** |
| 876 |
* 基本設定>支払方法>「決済種別」から削除. |
| 877 |
* Welcart Shop > General Setting > payment method > Type of payment. |
| 878 |
*/ |
| 879 |
$payment_structure = get_option( 'usces_payment_structure', array() ); |
| 880 |
unset( $payment_structure['acting_paidy'] ); |
| 881 |
ksort( $payment_structure ); |
| 882 |
update_option( 'usces_payment_structure', $payment_structure ); |
| 883 |
|
| 884 |
return true; |
| 885 |
} |
| 886 |
|
| 887 |
/** |
| 888 |
* Generate the id of the payment method. |
| 889 |
* |
| 890 |
* @param array $payment_methods The payment methods. |
| 891 |
* @return integer The id. |
| 892 |
*/ |
| 893 |
private function generate_payment_id( $payment_methods ) { |
| 894 |
$ids = array_keys( $payment_methods ); |
| 895 |
if ( empty( $ids ) ) { |
| 896 |
return 0; |
| 897 |
} |
| 898 |
|
| 899 |
$max_id = max( $ids ); |
| 900 |
$max_id++; |
| 901 |
|
| 902 |
return $max_id; |
| 903 |
} |
| 904 |
|
| 905 |
/** |
| 906 |
* Generate the max sort of the payment method. |
| 907 |
* |
| 908 |
* @param array $payment_methods The payment methods. |
| 909 |
* @return integer $sort |
| 910 |
*/ |
| 911 |
private function generate_payment_sort( $payment_methods ) { |
| 912 |
$sort = 0; |
| 913 |
if ( empty( $payment_methods ) ) { |
| 914 |
return $sort; |
| 915 |
} |
| 916 |
|
| 917 |
foreach ( $payment_methods as $payment_method ) { |
| 918 |
if ( $sort < $payment_method['sort'] ) { |
| 919 |
$sort = $payment_method['sort']; |
| 920 |
} |
| 921 |
} |
| 922 |
|
| 923 |
$sort++; |
| 924 |
return $sort; |
| 925 |
} |
| 926 |
|
| 927 |
/** |
| 928 |
* Update Instant Paidy settings. |
| 929 |
* |
| 930 |
* @return bool true|false |
| 931 |
*/ |
| 932 |
private function update_settings() { |
| 933 |
return update_option( 'usces_paidy_application', $this->settings ); |
| 934 |
} |
| 935 |
|
| 936 |
/** |
| 937 |
* Get Instant Paidy settings. |
| 938 |
* |
| 939 |
* @return array |
| 940 |
*/ |
| 941 |
private function get_settings() { |
| 942 |
$this->settings = get_option( 'usces_paidy_application', $this->settings ); |
| 943 |
return $this->settings; |
| 944 |
} |
| 945 |
|
| 946 |
/** |
| 947 |
* Send the application to the Paidy application management server. |
| 948 |
* |
| 949 |
* @param array $application The application. |
| 950 |
* @return bool true|false |
| 951 |
*/ |
| 952 |
public function submit_paidy_application( $application ) { |
| 953 |
$url = self::BASE_API_URL . '/wp-json/paidy-management/application'; |
| 954 |
$ch = curl_init(); |
| 955 |
curl_setopt( $ch, CURLOPT_URL, $url ); |
| 956 |
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' ); |
| 957 |
curl_setopt( $ch, CURLOPT_POST, true ); |
| 958 |
curl_setopt( $ch, CURLOPT_POSTFIELDS, $application ); |
| 959 |
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
| 960 |
$result = curl_exec( $ch ); |
| 961 |
unset( $ch ); |
| 962 |
$result = json_decode( $result ); |
| 963 |
|
| 964 |
if ( empty( $result->success ) ) { |
| 965 |
$this->error = $result->message; |
| 966 |
return false; |
| 967 |
} else { |
| 968 |
return true; |
| 969 |
} |
| 970 |
} |
| 971 |
|
| 972 |
/** |
| 973 |
* Embbed javascript. |
| 974 |
* |
| 975 |
* @access private |
| 976 |
* @return object $this itself. |
| 977 |
*/ |
| 978 |
private function enqueue_script() { |
| 979 |
?> |
| 980 |
<script> |
| 981 |
jQuery(document).ready(function ($) { |
| 982 |
const instantPaidyWidget = { |
| 983 |
start: function () { |
| 984 |
this.listen(); |
| 985 |
}, |
| 986 |
listen: function () { |
| 987 |
// Registered Paidy screen. |
| 988 |
this.onClickNextPaidyFormBtn(); |
| 989 |
this.onClickSendPaidyFormBtn(); |
| 990 |
|
| 991 |
//Approved Paidy screen. |
| 992 |
this.onClickTestPaidyBtn(); |
| 993 |
this.onClickPublishPaidyBtn(); |
| 994 |
|
| 995 |
//Denied Paidy screen. |
| 996 |
this.onClickCloseBtnOnDeniedScreen(); |
| 997 |
|
| 998 |
this.onClickHidePaidyWidget(); |
| 999 |
}, |
| 1000 |
onClickCloseBtnOnDeniedScreen: function () { |
| 1001 |
$('.paidy-denied-screen .button').on('click', function () { |
| 1002 |
var nonce = $('#paidy_widget_nonce').val(); |
| 1003 |
|
| 1004 |
$.ajax({ |
| 1005 |
url: ajaxurl, |
| 1006 |
type: 'POST', |
| 1007 |
data: { |
| 1008 |
action: 'paidy_application', |
| 1009 |
sub_action: 'close_paidy_widget', |
| 1010 |
wcnonce: nonce, |
| 1011 |
}, |
| 1012 |
beforeSend: function () { |
| 1013 |
$('.paidy-denied-screen .button').attr('disabled','disabled'); |
| 1014 |
$('.paidy-denied-screen .button').after('<img id="loading" src="'+$('#loading-img').val()+'"/>'); |
| 1015 |
}, |
| 1016 |
}).done(function (res) { |
| 1017 |
location.reload(); |
| 1018 |
}); |
| 1019 |
}); |
| 1020 |
}, |
| 1021 |
onClickTestPaidyBtn: function () { |
| 1022 |
$('.paidy-approved-screen .test-paidy-btn').on( |
| 1023 |
'click', |
| 1024 |
function () { |
| 1025 |
var nonce = $('#paidy_widget_nonce').val(); |
| 1026 |
|
| 1027 |
$.ajax({ |
| 1028 |
url: ajaxurl, |
| 1029 |
type: 'POST', |
| 1030 |
data: { |
| 1031 |
action: 'paidy_application', |
| 1032 |
sub_action: 'set_paidy_test_mode', |
| 1033 |
wcnonce: nonce, |
| 1034 |
}, |
| 1035 |
beforeSend: function () { |
| 1036 |
$('.paidy-approved-screen .button').attr('disabled', 'disabled'); |
| 1037 |
$('.paidy-approved-screen .test-paidy-btn').after('<img id="loading" src="'+$('#loading-img').val()+'"/>'); |
| 1038 |
}, |
| 1039 |
}).done(function (res) { |
| 1040 |
location.reload(); |
| 1041 |
}); |
| 1042 |
} |
| 1043 |
); |
| 1044 |
}, |
| 1045 |
onClickPublishPaidyBtn: function () { |
| 1046 |
$('.paidy-approved-screen .publish-paidy-btn, .paidy-test-mode-screen .publish-paidy-btn').on('click', function () { |
| 1047 |
var nonce = $('#paidy_widget_nonce').val(); |
| 1048 |
|
| 1049 |
$.ajax({ |
| 1050 |
url: ajaxurl, |
| 1051 |
type: 'POST', |
| 1052 |
data: { |
| 1053 |
action: 'paidy_application', |
| 1054 |
sub_action: 'set_paidy_publish_mode', |
| 1055 |
wcnonce: nonce, |
| 1056 |
}, |
| 1057 |
beforeSend: function () { |
| 1058 |
$('.paidy-approved-screen .button, .paidy-test-mode-screen .button').attr('disabled', 'disabled'); |
| 1059 |
$('.paidy-approved-screen .publish-paidy-btn, .paidy-test-mode-screen .publish-paidy-btn').after( |
| 1060 |
'<img id="loading" src="'+$('#loading-img').val()+'"/>'); |
| 1061 |
}, |
| 1062 |
}).done(function (res) { |
| 1063 |
$('.paidy-approved-screen, .paidy-test-mode-screen').hide(); |
| 1064 |
$('.paidy-publish-mode-screen').show(); |
| 1065 |
}); |
| 1066 |
}); |
| 1067 |
}, |
| 1068 |
onClickNextPaidyFormBtn: function () { |
| 1069 |
const self = this; |
| 1070 |
$('.paidy-intro-screen .next-paidy-form-btn').on( |
| 1071 |
'click', |
| 1072 |
function () { |
| 1073 |
$('.paidy-intro-screen').hide(); |
| 1074 |
$('#dashboard_instant_paidy h2').html('ペイディ申し込み'); |
| 1075 |
$('#paidy-form').show(); |
| 1076 |
} |
| 1077 |
); |
| 1078 |
}, |
| 1079 |
onClickSendPaidyFormBtn: function () { |
| 1080 |
const self = this; |
| 1081 |
$('#paidy-form .send-paidy-form-btn').on('click', function () { |
| 1082 |
var nonce = $('#paidy_widget_nonce').val(); |
| 1083 |
var question = ''; |
| 1084 |
|
| 1085 |
for (var i = 1; i <= 9; i++) { |
| 1086 |
var checkBoxId = '#squestion' + i; |
| 1087 |
|
| 1088 |
if ($(checkBoxId).is(':checked')) { |
| 1089 |
question += '1'; |
| 1090 |
} else { |
| 1091 |
question += '0'; |
| 1092 |
} |
| 1093 |
} |
| 1094 |
|
| 1095 |
if (self.validatePaidyForm()) { |
| 1096 |
$.ajax({ |
| 1097 |
url: ajaxurl, |
| 1098 |
type: 'POST', |
| 1099 |
data: { |
| 1100 |
action: 'paidy_application', |
| 1101 |
sub_action: 'registered', |
| 1102 |
wcnonce: nonce, |
| 1103 |
company: $('#paidy-form input[name=company]').val(), |
| 1104 |
site_name: $('#paidy-form input[name=site_name]').val(), |
| 1105 |
site_url: $('#paidy-form input[name=site_url]').val(), |
| 1106 |
email: $('#paidy-form input[name=email]').val(), |
| 1107 |
tel: $('#paidy-form input[name=tel]').val(), |
| 1108 |
name: $('#paidy-form input[name=name]').val(), |
| 1109 |
name_kana: $('#paidy-form input[name=name_kana]').val(), |
| 1110 |
birthday: $('#paidy-form input[name=birthday]').val(), |
| 1111 |
annual_value: $('#paidy-form input[name=annual_value]:checked').val(), |
| 1112 |
average_price: $('#paidy-form input[name=average_price]:checked').val(), |
| 1113 |
questionnaire: question, |
| 1114 |
}, |
| 1115 |
beforeSend: function () { |
| 1116 |
$('#paidy-form input').attr('disabled', 'disabled'); |
| 1117 |
$('#paidy-form .send-paidy-form-btn').attr('disabled', 'disabled'); |
| 1118 |
$('#paidy-form #msgs td').html('<img id="loading" src="'+$('#loading-img').val()+'"/>'); |
| 1119 |
}, |
| 1120 |
}).done(function (res) { |
| 1121 |
if (res.success) { |
| 1122 |
location.reload(); |
| 1123 |
} else { |
| 1124 |
$('#paidy-form input').removeAttr('disabled'); |
| 1125 |
$('#paidy-form .send-paidy-form-btn').removeAttr('disabled'); |
| 1126 |
$('#paidy-form #loading').remove(); |
| 1127 |
$('#paidy-form #msgs td').html('<div id="error" style="color:red;">'+res.data.msg+'</div>'); |
| 1128 |
} |
| 1129 |
}); |
| 1130 |
} |
| 1131 |
}); |
| 1132 |
}, |
| 1133 |
validatePaidyForm: function () { |
| 1134 |
const self = this; |
| 1135 |
let valid = true; |
| 1136 |
const inputs = $('#paidy-form input.validate'); |
| 1137 |
inputs.each(function () { |
| 1138 |
const input = $(this); |
| 1139 |
if (self.isEmpty(input)) { |
| 1140 |
valid = false; |
| 1141 |
} |
| 1142 |
}); |
| 1143 |
const formVaild = document.getElementById('paidy-form').reportValidity(); |
| 1144 |
valid = valid && formVaild; |
| 1145 |
|
| 1146 |
return valid; |
| 1147 |
}, |
| 1148 |
isEmpty: function (ele) { |
| 1149 |
const isEmpty = '' === ele.val().trim(); |
| 1150 |
if (isEmpty) { |
| 1151 |
ele.val(''); |
| 1152 |
} |
| 1153 |
return isEmpty; |
| 1154 |
}, |
| 1155 |
onClickHidePaidyWidget: function () { |
| 1156 |
$('#hide_paidy_widget').on('click', function (e) { |
| 1157 |
e.preventDefault(); |
| 1158 |
|
| 1159 |
var nonce = $('#paidy_widget_nonce').val(); |
| 1160 |
$.ajax({ |
| 1161 |
url: ajaxurl, |
| 1162 |
type: 'POST', |
| 1163 |
data: { |
| 1164 |
action: 'paidy_application', |
| 1165 |
sub_action: 'hide_paidy_widget', |
| 1166 |
wcnonce: nonce |
| 1167 |
}, |
| 1168 |
beforeSend: function () { |
| 1169 |
$('#dashboard_instant_paidy').hide(); |
| 1170 |
}, |
| 1171 |
}).done(function (res) { |
| 1172 |
console.log('Server response: ', res); |
| 1173 |
location.reload(); |
| 1174 |
}); |
| 1175 |
}); |
| 1176 |
}, |
| 1177 |
}; |
| 1178 |
|
| 1179 |
instantPaidyWidget.start(); |
| 1180 |
}); |
| 1181 |
</script> |
| 1182 |
<?php |
| 1183 |
return $this; |
| 1184 |
} |
| 1185 |
} |
| 1186 |
|