fix: resolve false block checkout incompatibility warnings#11280
fix: resolve false block checkout incompatibility warnings#11280oaratovskyi merged 29 commits intodevelopfrom
Conversation
WooPayments was incorrectly shown as "incompatible with block-based checkout" in the WordPress block editor for split gateways and express checkout methods. Root cause: WooCommerce compares PHP gateways (where enabled='yes') with JS methods registered via registerPaymentMethod(). Express checkout uses registerExpressPaymentMethod() with different names, causing a mismatch. Split gateways could also have stale enabled settings not matching UPE config. Changes: - init_settings(): Set enabled='no' for express checkout in admin context to exclude them from the compatibility check. For split gateways, verify they're in the UPE enabled list. - is_enabled(): For split gateways, also check UPE config to prevent sync issues. - register_checkout_gateway(): Register all split gateways with blocks. - Blocks payment method: Use is_enabled() instead of is_available() and fix constructor timing for get_name(). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
|
Size Change: 0 B Total Size: 955 kB ℹ️ View Unchanged
|
rtio
left a comment
There was a problem hiding this comment.
tested and it works as described, just a few small comments.
…lback - Add EXPRESS_CHECKOUT_METHODS constant to WC_Payment_Gateway_WCPay - Update init_settings(), is_enabled(), and register_checkout_gateway() to use the constant - Add null fallback for gateway in WC_Payments_Blocks_Payment_Method constructor - Add null checks in is_active() and get_payment_method_data() methods Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Thank you @oaratovskyi ! |
|
Sounds good @frosso ! Looking forward to the review. |
|
Thanks @rtio ! Waiting for the final approval from Francesco. |
frosso
left a comment
There was a problem hiding this comment.
It took me a while to find something negatively affected by these changes using is_admin() 😅
The current approach seems to be affecting subscriptions behavior.
In the admin area, we have an AJAX call that returns customer tokens for subscriptions.
Let's have an example: you're an admin and you're managing your customer's subscriptions.
One of your customers has both Card and Amazon Pay saved tokens available.
Example 1: switching a subscription from Card -> Amazon Pay
- Ensure you have a customer with both
CardandAmazon Paysubscriptions- If you don't have such a customer: make 2 subscription purchases as a customer, one with a Card, another with Amazon Pay
- Edit one of the existing subscriptions paid with Card
- Make sure you're selecting the customer that has saved Amazon Pay tokens (or edit one of their own existing subscriptions)
- Edit the subscription's billing section
- You won't be able to find "Amazon Pay" from the available payment methods
Example 2: switching a subscription from Amazon Pay -> Card -> Amazon Pay
- Ensure you have a customer with both
CardandAmazon Paysubscriptions- If you don't have such a customer: make 2 subscription purchases as a customer, one with a Card, another with Amazon Pay
- Edit one of the existing subscriptions paid with Amazon Pay
- Edit the subscription's billing section
- Here, you should be able to see "Amazon Pay" in the list of payment methods because the codebase gracefully degrades indicating that if a subscription has been paid with a specific payment method, the payment method should be available in the dropdown
- Switch to a Card payment method
- Select a new saved token
- Save the subscription
- Edit the subscription again
- Now, you won't be able to find "Amazon Pay" from the available payment methods
In short, you should be able to show available Amazon Pay payment methods when editing a subscription, if the customer has any.
But these changes are interfering with the AJAX endpoint we're using to retrieve available payment methods.
I'm guessing that there might be other use cases (or extensions) that are affected, but I haven't been able to identify them, to be fully honest 😅
Here's an example of subscription that is using "Card" as a payment method: switching payment method doesn't show Amazon Pay in the list:

And here's another subscription that already has Amazon Pay: in this case, Amazon Pay is present in the dropdown and its tokens are shown:

I tested this behavior with #11283
On that branch, I can see Amazon Pay as a payment method when switching the subscription's payment method from Card.
Is there maybe another approach that can be used, instead of relying on is_admin()?
|
@oaratovskyi all I did was navigate to the block-based checkout page and click on the payment methods list Screen.Recording.2026-02-10.at.3.46.23.PM.mov |
|
Thanks, @frosso ! See it now 👍 |
Use enqueue_block_editor_assets hook to disable express checkout gateways before WC reads their enabled state, avoiding false "incompatible" warnings without affecting subscriptions or frontend. Also simplify register_checkout_gateway and require gateway param in WC_Payments_Blocks_Payment_Method constructor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ed_at_checkout Remove the is_admin_context relaxation for capability status check that was added for block editor compatibility — now handled by the enqueue_block_editor_assets hook. Clean up stale comments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@frosso I have finally fixed and removed / updated stale code. The filter approach finally worked. Could you give it a try, please? 🙏 4p7DJg.mp4 |
|
Thank you @oaratovskyi ! I'm still reviewing the changes, I'm experimenting to see if there's an opportunity to simplify it even further :) |
There was a problem hiding this comment.
Hey @oaratovskyi , thank you for your patience with this!
I think I'm seeing some changes that seem superfluous to the outcome we desire - specifically to the class-wc-payment-gateway-wcpay.php class with the init_settings and is_enabled methods, and to the class-wc-payments-blocks-payment-method.php class and its initialization.
FWIW, the change to the get_enabled_payment_method_config() method could also be achieved (or substituted) by adding another filter to this line: https://github.com/Automattic/woocommerce-payments/blob/develop/client/checkout/blocks/index.js#L50
In this commit you can see what I mean by reverting some of the changes: 88e7fd1
Could you please also take a look to ensure I'm not hallucinating? 😄
…eway Revert superfluous changes per review feedback: remove constructor from WC_Payments_Blocks_Payment_Method, restore is_available() in is_active(), simplify is_enabled() and register_checkout_gateway() back to develop state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
parent::init_settings() already sets $this->enabled from settings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@frosso and I had a huddle and aligned on the final iteration! 🎉 |
Single loop using gateway->get_payment_method() directly instead of building an intermediate array of IDs with string composition. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@frosso Thanks for your quality reviews, timed feedback, and willingness to help, too! Could you please run the last smoke test before 🚢? |

Fixes WOOPMNT-5640
Changes proposed in this Pull Request
Fixes WooPayments incorrectly showing as "incompatible with block-based checkout" in the WordPress block editor.
Root Cause
WooCommerce's block editor compares
globalPaymentMethods(PHP gateways withenabled='yes') againstavailablePaymentMethods/availableExpressPaymentMethods(JS-registered methods). Two issues caused false "incompatible" warnings:registerExpressPaymentMethod()in JS with different names than their PHP gateway IDs (e.g.apple_pay_ecevswoocommerce_payments_apple_pay), so WooCommerce can't match them.enabled=yesin the database even when not in the UPE enabled methods list.Changes
disable_express_checkout_in_block_editor()(new,class-wc-payments.php): Hooks intoenqueue_block_editor_assetsat priority 1 to setenabled='no'on express checkout gateways before WC reads their state at priority 10. Only fires in the block editor — does not affect frontend, AJAX, or subscription admin pages.init_settings()(class-wc-payment-gateway-wcpay.php): For split gateways, verify the method is in the UPE enabled list. This prevents sync issues where a gateway hasenabled=yesbut isn't actually configured in WCPay settings.is_available_for_express_checkout()(class-wc-payment-gateway-wcpay.php): In admin context, skip runtime availability checks (HTTPS, currency, capability status) that fail without an active cart/customer session. Use a simple enabled check instead.get_enabled_payment_method_config()(class-wc-payments-checkout.php): Skip express checkout methods when building UPE config to prevent them from being registered as regular payment methods viaregisterPaymentMethod().Testing instructions
Prerequisites
10.6.0inwoocommerce-payments.phpnpm run update-fees-fixtures && npm run upwp option update _wcpay_feature_amazon_pay 1Test 1: Block checkout editor shows no false incompatibility warnings
Test 2: Amazon Pay appears on the product page
Test 3: Amazon Pay appears on the block checkout page
Test 4: Switch a subscription from Card to Amazon Pay
Test 5: Switch a subscription from Amazon Pay to Card and back to Amazon Pay
npm run changelogto add a changelog file, choosepatchto leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge