Add subscriptions mode selector

This commit is contained in:
emilicastells 2023-02-01 16:30:39 +01:00
parent b1091765dc
commit ee425588bf
No known key found for this signature in database
GPG key ID: 1520C07081754570
8 changed files with 39 additions and 17 deletions

View file

@ -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';
}

View file

@ -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';
}
/**

View file

@ -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;

File diff suppressed because one or more lines are too long

View file

@ -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

View file

@ -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',

View file

@ -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',