Beispiel #1
0
 /**
  * キャンセルキーの取得
  *
  */
 public function cancel_url()
 {
     // NONCEチェック
     if (!wp_verify_nonce($_POST['nonce'], "{$this->domain}_" . self::PAGE_NAME)) {
         $this->err_message = 'NONCE_ERROR';
         return false;
     }
     $booking_id = intval($_POST['booking_id']);
     $email = $_POST['client_email'];
     $this->booking = $this->get_booking($booking_id);
     // 予約IDとメールアドレスを確認する
     if (!$this->booking || $this->booking['client']['email'] !== $email) {
         $this->err_message = 'INVALID_INPUT';
         return false;
     }
     // キャンセルが有効か確認する
     $canceltime = $this->_check_cancel_limit();
     if ($canceltime <= 0) {
         $this->err_message = 'UNACCEPTABLE_TIME';
         return false;
     }
     // キャンセル実行のURIを戻す
     return add_query_arg(array('action' => 'cancel', 'bid' => $booking_id, 'key' => $this->_cancel_key($booking_id, $email)), MTS_Simple_Booking::get_permalink_by_slug(self::PAGE_NAME));
 }
Beispiel #2
0
 /**
  * Constructor
  *
  */
 public function __construct()
 {
     // ドメイン名セット
     $this->domain = MTS_Simple_Booking::DOMAIN;
     // セッションテーブルのインストール
     $this->_install_table();
     // PayPal SDK のオートロード設定
     if (file_exists(dirname(__FILE__) . '/pp/vendor/autoload.php')) {
         require 'pp/vendor/autoload.php';
     }
     if (extension_loaded('mcrypt')) {
         // wp-configからIV及びKEYの値を借りる
         $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
         if (defined('AUTH_SALT')) {
             $this->iv = substr(AUTH_SALT . $this->iv, 0, $iv_size);
         }
         if (defined('AUTH_KEY')) {
             $this->key = substr(AUTH_KEY . $this->key, 0, 32);
         }
         // モジュール利用可
         $this->available = true;
     }
     // PayPal APIアクセスのための認証データを読み出す
     $paypal = get_option($this->domain . '_paypal', true);
     $this->logo_url = $paypal['logo_url'];
     $this->use_sandbox = $paypal['use_sandbox'];
     // 暗号化(または未暗号化)したPayPalAPI設定値をセットする
     if ($this->available) {
         $this->pp_username = $this->mts_decode($paypal['pp_username']);
         $this->pp_password = $this->mts_decode($paypal['pp_password']);
         $this->pp_signature = $this->mts_decode($paypal['pp_signature']);
     } else {
         $this->pp_username = $paypal['pp_username'];
         $this->pp_password = $paypal['pp_password'];
         $this->pp_signature = $paypal['pp_signature'];
     }
     // https:// PayPalからのリダイレクトURL
     $this->page_url = MTS_Simple_Booking::get_permalink_by_slug(self::FORM_PAGE);
     if (empty($paypal['https_url'])) {
         $this->return_url = $this->page_url;
     } else {
         // 各種設定で「https://」が記述されていない場合は追加する
         $https_url = (preg_match('/^https:\\/\\//', $paypal['https_url']) ? '' : 'https://') . $paypal['https_url'];
         // URLからトップURL(例:http://example.com)を消去する
         $query = preg_replace('/' . preg_quote(home_url(), '/') . '/', '', $this->page_url);
         // トップURLをhttps://にしたURLを設定する($queryは/で始まるので削除しておく
         $this->return_url = preg_replace('/\\/$/', '', $https_url) . $query;
     }
 }