diff --git a/ecommerce/OptionKeys.php b/ecommerce/OptionKeys.php index e473e82dcb..315f794c2d 100644 --- a/ecommerce/OptionKeys.php +++ b/ecommerce/OptionKeys.php @@ -44,6 +44,9 @@ class OptionKeys { const BUY_NOW = 'is_enable_buy_now'; + // PayPal advanced settings. + const PAYPAL_ENABLE_VAULTING = 'tutor_paypal_enable_vaulting'; + /** * Get billing field options * diff --git a/ecommerce/PaymentGateways/Configs/PaypalConfig.php b/ecommerce/PaymentGateways/Configs/PaypalConfig.php index 2c724648d3..015f913640 100644 --- a/ecommerce/PaymentGateways/Configs/PaypalConfig.php +++ b/ecommerce/PaymentGateways/Configs/PaypalConfig.php @@ -2,6 +2,7 @@ namespace Tutor\PaymentGateways\Configs; +use Tutor\Ecommerce\OptionKeys; use Tutor\Ecommerce\Settings; use Ollyo\PaymentHub\Core\Payment\BaseConfig; use Ollyo\PaymentHub\Contracts\Payment\ConfigContract; @@ -129,12 +130,14 @@ public function getApiURL() { public function createConfig(): void { parent::createConfig(); + $enable_vaulting = (bool) tutor_utils()->get_option( OptionKeys::PAYPAL_ENABLE_VAULTING, true ); + $config = array( 'client_id' => $this->getClientID(), 'merchant_email' => $this->getMerchantEmail(), 'api_url' => $this->getApiURL(), 'client_secret' => $this->getClientSecret(), - 'save_payment_method' => true, + 'save_payment_method' => $enable_vaulting, 'webhook_id' => $this->webhook_id ); diff --git a/ecommerce/Settings.php b/ecommerce/Settings.php index 77e9c5b698..b622f0cc63 100644 --- a/ecommerce/Settings.php +++ b/ecommerce/Settings.php @@ -241,6 +241,21 @@ public static function add_ecommerce_settings( $fields ) { ), ), ), + array( + 'label' => __( 'PayPal Settings', 'tutor' ), + 'desc' => __( 'Advanced configuration options for PayPal.', 'tutor' ), + 'slug' => 'paypal_settings', + 'block_type' => 'uniform', + 'fields' => array( + array( + 'key' => OptionKeys::PAYPAL_ENABLE_VAULTING, + 'type' => 'toggle_switch', + 'label' => __( 'Enable PayPal Vaulting (Save Payment Methods)', 'tutor' ), + 'default' => 'on', + 'desc' => __( 'Allow PayPal to save customer payment methods for future purchases.', 'tutor' ), + ), + ), + ), ), );