'1億円未満',
'2' => '1億円以上',
);
/**
* Inittal key to generate iv.
*
* @var string INITIAL
*/
const INITIAL = 'eXZscmRpb3NpOXNvbGJqaD';
/**
* Algo
*
* @var string AES_128_CBC
*/
const AES_128_CBC = 'AES-128-CBC';
/**
* The average prices options.
*
* @var object $average_price_options
*/
private $average_price_options = array(
'1' => '5万円未満',
'2' => '5万円以上',
);
/**
* The instance of this class.
*
* @var object $instance
*/
private static $instance = null;
/**
* The error message.
*
* @var string $error
*/
private $error = '';
/**
* The instant Paidy settings.
*
* @var string $settings
*/
private $settings = array(
'status' => '',
);
/**
* Constructor
*
* @access private
*/
private function __construct() {}
/**
* Create the instance of the "InstantPaidyWidget" class.
*/
public static function get_instance() {
if ( empty( self::$instance ) ) {
self::$instance = new self();
self::$instance->get_settings();
}
return self::$instance;
}
/**
* Receive the response of the Paidy server.
*/
public function receive_paidy_result() {
$received = false;
$status = (int) filter_input( INPUT_POST, 'status' );
$is_approved = self::APPROVED_STATUS === $status;
$is_denied = self::DENIED_STATUS === $status;
$is_canceled = self::CANCELED_STATUS === $status;
$is_result_valid = $is_approved || $is_denied || $is_canceled;
$current_setting = $this->get_settings();
if ( ! $current_setting ) {
wp_send_json_error();
return;
}
if ( $is_approved ) {
$public_live = filter_input( INPUT_POST, 'public_live' );
$secret_live = filter_input( INPUT_POST, 'secret_live' );
$public_test = filter_input( INPUT_POST, 'public_test' );
$secret_test = filter_input( INPUT_POST, 'secret_test' );
$is_valid_key = ! empty( $public_live ) && ! empty( $secret_live );
if ( self::DENIED_STATUS === (int) $current_setting['status'] || self::APPROVED_STATUS === (int) $current_setting['status'] ) {
$is_result_valid = false;
} elseif ( $is_valid_key ) {
$this->settings['status'] = self::APPROVED_STATUS;
$this->settings['public_live'] = self::decrypt( $public_live );
$this->settings['secret_live'] = self::decrypt( $secret_live );
$this->settings['public_test'] = self::decrypt( $public_test );
$this->settings['secret_test'] = self::decrypt( $secret_test );
$this->activate_paidy( 'preparation' );
$is_result_valid = true;
} else {
$is_result_valid = false;
}
} elseif ( $is_denied ) {
if ( self::DENIED_STATUS === (int) $current_setting['status'] || self::APPROVED_STATUS === (int) $current_setting['status'] ) {
$is_result_valid = false;
} else {
$this->settings['status'] = self::DENIED_STATUS;
$this->deactivate_paidy();
$is_result_valid = true;
}
} elseif ( $is_canceled ) {
$this->settings['status'] = 0;
$this->settings['denied'] = '';
$this->settings['mode'] = '';
$this->deactivate_paidy();
$is_result_valid = true;
}
if ( $is_result_valid ) {
$this->update_settings();
$received = true;
}
if ( $received ) {
wp_send_json_success();
} else {
wp_send_json_error();
}
}
/**
* Decrypt the encrypted key value.
*
* @param string $encrypted_value The encrypted value.
* @return string $value
*/
public static function decrypt( $encrypted_value ) {
$passphrase = get_option( 'usces_wcid' );
if ( empty( trim( $encrypted_value ) ) ) {
return $encrypted_value;
}
$iv = base64_decode( self::INITIAL );
$encrypted_value = base64_decode( $encrypted_value );
$value = openssl_decrypt( $encrypted_value, self::AES_128_CBC, $passphrase, OPENSSL_RAW_DATA, $iv );
return $value;
}
/**
* Check if the Paidy payment is active or not.
*
* @return bool true|false
*/
public function is_paidy_active() {
$options = get_option( 'usces', array() );
$active = isset( $options['acting_settings']['paidy']['activate'] ) && 'on' === $options['acting_settings']['paidy']['activate']
&& isset( $options['acting_settings']['paidy']['paidy_activate'] ) && 'on' === $options['acting_settings']['paidy']['paidy_activate']
&& ( '' === $this->settings['status'] || isset( $this->settings['mode'] ) && 'publish' === $this->settings['mode'] );
return $active;
}
/**
* Implementation of hook "wp_dashboard_setup()".
*/
public function register_widget() {
$user = wp_get_current_user();
$showed = ( in_array( 'wc_management', (array) $user->roles, true ) || in_array( 'administrator', (array) $user->roles, true ) )
&& ! $this->is_paidy_active()
&& empty( $this->settings['denied'] );
if ( $showed ) {
wp_add_dashboard_widget( 'dashboard_instant_paidy', 'ペイディ決済らくらく設定', array( $this, 'display' ) );
}
}
/**
* Render dashboard instant Paidy widget.
*/
public function display() {
global $usces;
$this->enqueue_script();
$company = isset( $usces->options['company_name'] ) ? $usces->options['company_name'] : '';
$email = isset( $usces->options['inquiry_mail'] ) ? $usces->options['inquiry_mail'] : '';
$tel = isset( $usces->options['tel_number'] ) ? $usces->options['tel_number'] : '';
$site_name = get_bloginfo( 'name' );
$home_url = home_url();
$is_registed_paidy = ! empty( $this->settings['status'] );
$status = $is_registed_paidy ? $this->settings['status'] : '';
$mode = empty( $this->settings['mode'] ) ? '' : $this->settings['mode'];
$paidy_pic = USCES_PLUGIN_URL . '/images/paidy-pic.png';
$is_waiting = $is_registed_paidy && self::WAITING_STATUS === $status;
$is_denied = $is_registed_paidy && self::DENIED_STATUS === $status;
$is_approved = $is_registed_paidy && self::APPROVED_STATUS === $status;
$is_canceled = $is_registed_paidy && self::CANCELED_STATUS === $status;
$is_test_mode = $is_approved && 'test' === $mode;
$is_publish_mode = $is_approved && 'publish' === $mode;
?>
| ステータス:審査中です
お申込みありがとうございました。 審査結果はメールおよび、このダッシュボードで通知いたします。
- 審査には最大10営業日かかることがございます。
- 審査に関するお問い合わせ:sales@paidy.com
|
|
ステータス:審査は否決されました
慎重に審査を重ねました結果、誠に申し訳ございませんが、今回はお取引を見送らせていただくこととなりました。 このたびはご希望に添えない結果となり、誠に申し訳ございません。 審査内容の詳細については、お答えいたしかねますのでご了承ください。
閉じる
|
|
ステータス:審査は承認されました
審査が完了し、加盟店契約が成立いたしました。 ご利用条件はPaidy合同会社から送信されるメールの条件通知書をご確認ください。
本番モードで公開前にWebhook URLをペイディ加盟店管理画面へ設定することを推奨します。 Webhook URLには次の値を設定してください。 [テスト・本番共通]
ペイディ加盟店管理画面についてはマニュアルをご覧ください。
下記のいずれかのボタンをクリックしてください。
テストモードを有効化する
本番モードで公開する
|
|
ペイディのテスト決済が有効化されました。
基本設定の支払方法に「あと払い(ペイディ)」が追加されて「使用」の状態になっているのを確認後、購入テストを行ってください。
テスト決済方法はこちらをご覧ください。
テスト完了後、以下のボタンから本番モードで公開してください。
本番モードで公開する
|
|
ペイディ決済が公開されました。
本項目を閉じた後、操作方法などを確認する場合は クレジット決済設定 > ペイディ > 【資料】をご参照ください。
閉じる
|
; ?>) |
ペイディの新規申し込みと設定が簡単に行えます。
今すぐ始める
|
| 導入コスト0円、決済手数料3.5%~、本経由申込で、なんとお試し1か月決済手数料無料!詳細はこちら |
| 非表示 |
filter_input( INPUT_POST, 'company' ),
'site_name' => filter_input( INPUT_POST, 'site_name' ),
'site_url' => filter_input( INPUT_POST, 'site_url' ),
'email' => filter_input( INPUT_POST, 'email' ),
'tel' => filter_input( INPUT_POST, 'tel' ),
'name' => filter_input( INPUT_POST, 'name' ),
'name_kana' => filter_input( INPUT_POST, 'name_kana' ),
'birthday' => filter_input( INPUT_POST, 'birthday' ),
'annual_value' => filter_input( INPUT_POST, 'annual_value' ),
'average_price' => filter_input( INPUT_POST, 'average_price' ),
'wcid' => get_option( 'usces_wcid', '' ),
'questionnaire' => filter_input( INPUT_POST, 'questionnaire' ),
);
$submited = $this->submit_paidy_application( $application );
if ( $submited ) {
$this->settings['status'] = self::WAITING_STATUS;
$this->update_settings();
wp_send_json_success();
} else {
wp_send_json_error( array( 'msg' => $this->error ) );
}
break;
case 'close_paidy_widget':
check_ajax_referer( 'paidy_widget_nonce', 'wcnonce' );
$this->settings['denied'] = '1';
$this->update_settings();
wp_send_json_success();
break;
case 'set_paidy_test_mode':
check_ajax_referer( 'paidy_widget_nonce', 'wcnonce' );
$this->activate_paidy( 'test' );
$this->settings['mode'] = 'test';
$this->update_settings();
wp_send_json_success();
break;
case 'set_paidy_publish_mode':
check_ajax_referer( 'paidy_widget_nonce', 'wcnonce' );
$this->activate_paidy( 'live' );
$this->settings['mode'] = 'publish';
$this->update_settings();
wp_send_json_success();
break;
case 'hide_paidy_widget':
check_ajax_referer( 'paidy_widget_nonce', 'wcnonce' );
$user_id = get_current_user_id();
$hidden_widgets = get_user_meta( $user_id, 'metaboxhidden_dashboard', true );
if ( is_array( $hidden_widgets ) ) {
if ( ! in_array( 'dashboard_instant_paidy', $hidden_widgets ) ) {
$hidden_widgets[] = 'dashboard_instant_paidy';
}
} else {
$hidden_widgets = array( 'dashboard_instant_paidy' );
}
update_user_meta( $user_id, 'metaboxhidden_dashboard', $hidden_widgets );
wp_send_json_success();
break;
}
}
/**
* Activate paidy payment.
*
* @param string $environment The environment.
* @return bool true|false
*/
private function activate_paidy( $environment ) {
if ( 'preparation' === $environment ) {
/**
* クレジット決済設定>ペイディオプション
* Welcart Shop > Settlement Setting
*/
$paidy_key = 'paidy';
$options = get_option( 'usces', array() );
$options['acting_settings'][ $paidy_key ] = array(
'activate' => 'on',
'paidy_activate' => 'off',
'environment' => 'test',
'public_key' => $this->settings['public_live'],
'secret_key' => $this->settings['secret_live'],
'public_key_test' => $this->settings['public_test'],
'secret_key_test' => $this->settings['secret_test'],
);
update_option( 'usces', $options );
} elseif ( 'test' === $environment ) {
/**
* クレジット決済設定>ペイディオプション
* Welcart Shop > Settlement Setting
*/
$paidy_key = 'paidy';
$options = get_option( 'usces', array() );
$options['acting_settings'][ $paidy_key ] = array(
'activate' => 'on',
'paidy_activate' => 'on',
'environment' => 'test',
'public_key' => $this->settings['public_live'],
'secret_key' => $this->settings['secret_live'],
'public_key_test' => $this->settings['public_test'],
'secret_key_test' => $this->settings['secret_test'],
);
update_option( 'usces', $options );
/**
* クレジット決済設定>利用中のクレジット決済モジュール.
* Welcart Shop > Settlement Setting > Selecting a Settlement Module.
*/
$settlement_selected = get_option( 'usces_settlement_selected', array() );
if ( ! in_array( $paidy_key, $settlement_selected, true ) ) {
$settlement_selected[] = $paidy_key;
update_option( 'usces_settlement_selected', $settlement_selected );
}
/**
* 基本設定>支払方法>「決済種別」に追加.
* Welcart Shop > General Setting > payment method > Type of payment.
*/
$payment_structure = get_option( 'usces_payment_structure', array() );
$payment_structure['acting_paidy'] = 'Paidy';
ksort( $payment_structure );
update_option( 'usces_payment_structure', $payment_structure );
/**
* 基本設定>「支払方法」に追加.
* Welcart Shop > General Setting > payment method.
*/
$usces_payment_methods = usces_get_system_option( 'usces_payment_method', 'settlement' );
if ( empty( $usces_payment_methods['acting_paidy'] ) ) {
$payment_methods = get_option( 'usces_payment_method', array() );
$id = $this->generate_payment_id( $payment_methods );
$sort = $this->generate_payment_sort( $payment_methods );
$payment = array(
'id' => $id,
'name' => 'あと払い(ペイディ)',
'explanation' => '
- クレジットカード、事前登録不要。
- メールアドレスと携帯番号だけで、今すぐお買い物。
- 1か月に何度お買い物しても、お支払いは翌月まとめて1回でOK。
- お支払いは翌月10日までに、コンビニ払い・銀行振込・口座振替で。
',
'settlement' => 'acting_paidy',
'module' => '',
'sort' => $sort,
'use' => 'activate',
);
usces_update_system_option( 'usces_payment_method', $id, $payment );
} else {
$acting_paidy = $usces_payment_methods['acting_paidy'];
$acting_paidy['use'] = 'activate';
usces_update_system_option( 'usces_payment_method', $acting_paidy['id'], $acting_paidy );
}
} elseif ( 'live' === $environment ) {
/**
* クレジット決済設定>ペイディオプション
* Welcart Shop > Settlement Setting
*/
$paidy_key = 'paidy';
$options = get_option( 'usces', array() );
$options['acting_settings'][ $paidy_key ] = array(
'activate' => 'on',
'paidy_activate' => 'on',
'environment' => 'live',
'public_key' => $this->settings['public_live'],
'secret_key' => $this->settings['secret_live'],
'public_key_test' => $this->settings['public_test'],
'secret_key_test' => $this->settings['secret_test'],
);
update_option( 'usces', $options );
/**
* クレジット決済設定>利用中のクレジット決済モジュール.
* Welcart Shop > Settlement Setting > Selecting a Settlement Module.
*/
$settlement_selected = get_option( 'usces_settlement_selected', array() );
if ( ! in_array( $paidy_key, $settlement_selected, true ) ) {
$settlement_selected[] = $paidy_key;
update_option( 'usces_settlement_selected', $settlement_selected );
}
/**
* 基本設定>支払方法>「決済種別」に追加.
* Welcart Shop > General Setting > payment method > Type of payment.
*/
$payment_structure = get_option( 'usces_payment_structure', array() );
$payment_structure['acting_paidy'] = 'Paidy';
ksort( $payment_structure );
update_option( 'usces_payment_structure', $payment_structure );
/**
* 基本設定>「支払方法」に追加.
* Welcart Shop > General Setting > payment method.
*/
$usces_payment_methods = usces_get_system_option( 'usces_payment_method', 'settlement' );
if ( empty( $usces_payment_methods['acting_paidy'] ) ) {
$payment_methods = get_option( 'usces_payment_method', array() );
$id = $this->generate_payment_id( $payment_methods );
$sort = $this->generate_payment_sort( $payment_methods );
$payment = array(
'id' => $id,
'name' => 'あと払い(ペイディ)',
'explanation' => '
- クレジットカード、事前登録不要。
- メールアドレスと携帯番号だけで、今すぐお買い物。
- 1か月に何度お買い物しても、お支払いは翌月まとめて1回でOK。
- お支払いは翌月10日までに、コンビニ払い・銀行振込・口座振替で。
',
'settlement' => 'acting_paidy',
'module' => '',
'sort' => $sort,
'use' => 'activate',
);
usces_update_system_option( 'usces_payment_method', $id, $payment );
} else {
$acting_paidy = $usces_payment_methods['acting_paidy'];
$acting_paidy['use'] = 'activate';
usces_update_system_option( 'usces_payment_method', $acting_paidy['id'], $acting_paidy );
}
}
return true;
}
/**
* Deactivate paidy payment.
*
* @return bool true|false
*/
private function deactivate_paidy() {
/**
* クレジット決済設定>ペイディオプション
* Welcart Shop > Settlement Setting
*/
$paidy_key = 'paidy';
$options = get_option( 'usces', array() );
$options['acting_settings'][ $paidy_key ] = array(
'activate' => 'on',
'paidy_activate' => 'off',
'environment' => 'test',
'public_key' => '',
'secret_key' => '',
'public_key_test' => '',
'secret_key_test' => '',
);
update_option( 'usces', $options );
/**
* 基本設定>「支払方法」>削除.
* Welcart Shop > General Setting > payment method.
*/
$usces_payment_methods = usces_get_system_option( 'usces_payment_method', 'settlement' );
if ( ! empty( $usces_payment_methods['acting_paidy'] ) ) {
$acting_paidy = $usces_payment_methods['acting_paidy'];
usces_del_system_option( 'usces_payment_method', $acting_paidy['id'] );
}
/**
* 基本設定>支払方法>「決済種別」から削除.
* Welcart Shop > General Setting > payment method > Type of payment.
*/
$payment_structure = get_option( 'usces_payment_structure', array() );
unset( $payment_structure['acting_paidy'] );
ksort( $payment_structure );
update_option( 'usces_payment_structure', $payment_structure );
return true;
}
/**
* Generate the id of the payment method.
*
* @param array $payment_methods The payment methods.
* @return integer The id.
*/
private function generate_payment_id( $payment_methods ) {
$ids = array_keys( $payment_methods );
if ( empty( $ids ) ) {
return 0;
}
$max_id = max( $ids );
$max_id++;
return $max_id;
}
/**
* Generate the max sort of the payment method.
*
* @param array $payment_methods The payment methods.
* @return integer $sort
*/
private function generate_payment_sort( $payment_methods ) {
$sort = 0;
if ( empty( $payment_methods ) ) {
return $sort;
}
foreach ( $payment_methods as $payment_method ) {
if ( $sort < $payment_method['sort'] ) {
$sort = $payment_method['sort'];
}
}
$sort++;
return $sort;
}
/**
* Update Instant Paidy settings.
*
* @return bool true|false
*/
private function update_settings() {
return update_option( 'usces_paidy_application', $this->settings );
}
/**
* Get Instant Paidy settings.
*
* @return array
*/
private function get_settings() {
$this->settings = get_option( 'usces_paidy_application', $this->settings );
return $this->settings;
}
/**
* Send the application to the Paidy application management server.
*
* @param array $application The application.
* @return bool true|false
*/
public function submit_paidy_application( $application ) {
$url = self::BASE_API_URL . '/wp-json/paidy-management/application';
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $application );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$result = curl_exec( $ch );
unset( $ch );
$result = json_decode( $result );
if ( empty( $result->success ) ) {
$this->error = $result->message;
return false;
} else {
return true;
}
}
/**
* Embbed javascript.
*
* @access private
* @return object $this itself.
*/
private function enqueue_script() {
?>