mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Add subscriptions mode selector
This commit is contained in:
parent
b1091765dc
commit
ee425588bf
8 changed files with 39 additions and 17 deletions
|
@ -107,8 +107,8 @@ return array(
|
|||
$other_context_intent = $subscription_helper->cart_contains_subscription() ? 'authorize' : $intent;
|
||||
|
||||
if (
|
||||
$settings->has( 'subscription_handler' )
|
||||
&& $settings->get( 'subscription_handler' ) === true
|
||||
$settings->has( 'subscriptions_mode' )
|
||||
&& $settings->get( 'subscriptions_mode' ) === 'subscriptions_api'
|
||||
) {
|
||||
return 'subscription';
|
||||
}
|
||||
|
|
|
@ -724,12 +724,12 @@ class SmartButton implements SmartButtonInterface {
|
|||
*/
|
||||
private function paypal_subscriptions_enabled(): bool {
|
||||
try {
|
||||
$subscription_handler = $this->settings->get( 'subscription_handler' );
|
||||
$subscriptions_mode = $this->settings->get( 'subscriptions_mode' );
|
||||
} catch ( NotFoundException $exception ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $subscription_handler;
|
||||
return $subscriptions_mode === 'subscriptions_api';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -147,13 +147,13 @@ class SubscriptionModule implements ModuleInterface {
|
|||
assert( $settings instanceof Settings );
|
||||
|
||||
try {
|
||||
$subscription_handler = $settings->get( 'subscription_handler' );
|
||||
$subscriptions_mode = $settings->get( 'subscriptions_mode' );
|
||||
} catch ( NotFoundException $exception ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
$subscription_handler !== true
|
||||
$subscriptions_mode !== 'subscriptions_api'
|
||||
|| empty( $_POST['_wcsnonce'] )
|
||||
|| ! wp_verify_nonce( wc_clean( wp_unslash( $_POST['_wcsnonce'] ) ), 'wcs_subscription_meta' ) ) {
|
||||
return;
|
||||
|
|
3
modules/ppcp-vaulting/assets/js/myaccount-payments.js
Normal file
3
modules/ppcp-vaulting/assets/js/myaccount-payments.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
File diff suppressed because one or more lines are too long
|
@ -669,16 +669,6 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => array( 'paypal', 'dcc' ),
|
||||
),
|
||||
'subscription_handler' => array(
|
||||
'title' => __( 'Subscription handler', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'checkbox',
|
||||
'default' => false,
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'card_billing_data_mode' => array(
|
||||
'title' => __( 'Card billing data handling', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'select',
|
||||
|
|
|
@ -413,7 +413,34 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'gateway' => Settings::CONNECTION_TAB_ID,
|
||||
'input_class' => $container->get( 'wcgateway.settings.should-disable-fraudnet-checkbox' ) ? array( 'ppcp-disabled-checkbox' ) : array(),
|
||||
),
|
||||
|
||||
'subscriptions_configuration_heading' => array(
|
||||
'heading' => __( 'Subscriptions', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => Settings::CONNECTION_TAB_ID,
|
||||
'description' => __( 'Configure WooCommerce Subscriptions integration with PayPal.', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'subscriptions_mode' => array(
|
||||
'title' => __( 'Subscriptions Mode', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'select',
|
||||
'class' => array(),
|
||||
'input_class' => array( 'wc-enhanced-select' ),
|
||||
'desc_tip' => true,
|
||||
'description' => '',
|
||||
'default' => 'vaulting_api',
|
||||
'options' => array(
|
||||
'vaulting_api' => __( 'PayPal Vaulting', 'woocommerce-paypal-payments' ),
|
||||
'subscriptions_api' => __( 'PayPal Subscriptions', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => Settings::CONNECTION_TAB_ID,
|
||||
),
|
||||
'credentials_integration_configuration_heading' => array(
|
||||
'heading' => __( 'General integration configuration', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-heading',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue