-
Notifications
You must be signed in to change notification settings - Fork 215
Disabling BNPLs when other official plugins are active #4492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disabling BNPLs when other official plugins are active #4492
Conversation
* | ||
* @return bool | ||
*/ | ||
public static function has_other_bnpl_plugins_active() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we need this logic in multiple places, I moved it to a new helper function.
} | ||
} | ||
if ( $has_other_bnpl_plugins_active ) { | ||
if ( WC_Stripe_Helper::has_other_bnpl_plugins_active() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making use of the new helper function.
@@ -287,7 +278,7 @@ public function admin_scripts( $hook_suffix ) { | |||
'is_oc_available' => WC_Stripe_Feature_Flags::is_oc_available(), | |||
'oauth_nonce' => wp_create_nonce( 'wc_stripe_get_oauth_urls' ), | |||
'is_sepa_tokens_enabled' => 'yes' === $this->gateway->get_option( 'sepa_tokens_for_other_methods', 'no' ), | |||
'has_other_bnpl_plugins' => $has_other_bnpl_plugins_active, | |||
'has_other_bnpl_plugins' => WC_Stripe_Helper::has_other_bnpl_plugins_active(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making use of the new helper function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR disables Stripe’s UPE BNPL methods (Affirm & Klarna) when the corresponding official plugins are active and centralizes the detection logic in helper methods.
- Introduces
has_gateway_plugin_active
andhas_other_bnpl_plugins_active
with constants for official plugin IDs. - Updates UPE payment gateway, promotion note, and settings controller to use the new helpers.
- Adds/testing adjustments for the new helpers and updates changelog/readme and client-side JS to remove BNPL methods.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/phpunit/WC_Stripe_Helper_Test.php | Replaces old tests, adds tests for has_other_bnpl_plugins_active and has_gateway_plugin_active . |
readme.txt | Adds entry about disabling BNPL when official plugins are active. |
includes/payment-methods/class-wc-stripe-upe-payment-gateway.php | Skips Affirm/Klarna methods via new helper checks. |
includes/notes/class-wc-stripe-bnpl-promotion-note.php | Uses has_other_bnpl_plugins_active instead of manual loop. |
includes/class-wc-stripe-helper.php | Adds constants and helper methods for plugin detection. |
includes/admin/class-wc-stripe-settings-controller.php | Removes manual checks and localizes flags with new helper methods. |
client/settings/general-settings-section/payment-methods-list.js | Removes BNPL methods in the UI when official plugins are active. |
changelog.txt | Reflects the BNPL disabling feature. |
Comments suppressed due to low confidence (4)
tests/phpunit/WC_Stripe_Helper_Test.php:222
- The data provider key
'payment gateways'
should be'payment_gateways'
to exactly match the test method’s$payment_gateways
parameter name.
'payment gateways' => [
tests/phpunit/WC_Stripe_Helper_Test.php:273
- The data provider key
'plugin id'
should be'plugin_id'
to align with the test method’s$plugin_id
parameter name.
'plugin id' => WC_Stripe_Helper::OFFICIAL_PLUGIN_ID_KLARNA,
tests/phpunit/WC_Stripe_Helper_Test.php:274
- Also update this key from
'payment gateways'
to'payment_gateways'
so PHPUnit can map it to the$payment_gateways
parameter.
'payment gateways' => [
client/settings/general-settings-section/payment-methods-list.js:194
- Import
PAYMENT_METHOD_AFFIRM
from 'wcstripe/stripe-utils/constants' at the top of the file, since it’s referenced here but not imported.
availablePaymentMethods.includes( PAYMENT_METHOD_AFFIRM )
'has_other_bnpl_plugins' => $has_other_bnpl_plugins_active, | ||
'has_affirm_gateway_plugin' => WC_Stripe_Helper::has_gateway_plugin_active( WC_Stripe_Helper::OFFICIAL_PLUGIN_ID_AFFIRM ), | ||
'has_klarna_gateway_plugin' => WC_Stripe_Helper::has_gateway_plugin_active( WC_Stripe_Helper::OFFICIAL_PLUGIN_ID_KLARNA ), | ||
'has_other_bnpl_plugins' => WC_Stripe_Helper::has_other_bnpl_plugins_active(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option here would be to reuse the return of both WC_Stripe_Helper::has_gateway_plugin_active
. Not sure if it is worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After installing and enabling the WooCommerce Gateway Affirm
plugin:
As a shopper, confirm Klarna and Affirm are now gone from the payment methods settings page (depending on the official extension you installed, or both if you installed both)
This works as indicated; the Stripe payment method is no longer shown in the payment method list in the settings.
As a merchant, go to the checkout page and confirm that the same happened
But it's still visible in the checkout.

--
Additionally, removing the Affirm/Klarna methods from the payment method list in the settings without providing any feedback may be confusing.
Maybe we can set it as disabled and add a yellow pill, similar to the one we use for "Requires activation"?
Or show a notice or message explaining why Affirm/Klarna are not available in the list, or group them at the bottom under an 'Unavailable Payment Methods' group?
+1 to this. Completely removing the payment methods could be confusing for the user. I like the idea of showing it disabled, preferably with a tooltip explaining the reason for it being disabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good and works as expected. Left a suggestion about the wording in the pill.
Tested:
When official plugin is installed and active:
✅ Klarna unavailable in settings, and not shown in block/classic checkout
✅ Affirm unavailable in settings, and not shown in block/classic checkout
When official plugin is not enabled:
✅ Klarna available in settings, and shown in block/classic checkout if enabled
✅ Affirm available in settings, and shown in block/classic checkout if enabled
Noting our earlier discussion where in a future iteration, we may also disable Klarna/Affirm in the merchant's PMC. Right now, they are disabled for the store when a conflict exists, but they remain enabled in the PMC, even after a settings update.
client/components/payment-method-unavailable-due-conflict-pill/index.js
Outdated
Show resolved
Hide resolved
Actually, I want to double-check that I am understanding the earlier discussion correctly. This is the flow I'm wondering about:
We are okay with this flow, and will update things for OC, is that correct? |
Thanks for the review, Anne! Yes, that's my understanding as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📈 PHP Unit Code Coverage Report
|
* Disabling BNPLs when other official plugins are active * Simplifying logic * Changelog and readme entries * Unit tests * Checking for specific official plugins instead of any * Adding constants * Unit test * Fix methods availability in the block checkout * Fix methods availability in the block checkout * Keeping methods visible in the settings page * Fix methods availability in the shortcode checkout * New pill to inform about the conflict * Unit test * Disable checkbox when unavailable * Reverting unit tests removal * Update index.js * Update index.test.js * Update index.js
Fixes STRIPE-431
Changes proposed in this Pull Request:
To prevent Affirm and Klarna from being displayed alongside other official plugins, we are now removing them when the other plugins are active. Instead of checking for any of the plugins, we are disabling each corresponding method.
I am also adding some new helper methods specific to this logic to reduce duplicate code.
Testing instructions
develop
branch on your test environmentwp-admin/admin.php?page=wc-settings&tab=checkout§ion=stripe&panel=methods
)update/disable-bnpls-when-other-plugins-are-active
)Changelog entry
Changelog Entry Comment
Comment
Post merge