Refactor payment method registration to include all registered payment gateways #10380
Labels
category: refactor
The issue/PR is related to refactoring.
focus: checkout payments
impact: high
This issue impacts a lot of users as reported by our Happiness Engineers.
priority: high
The issue/PR is high priority—it affects lots of customers substantially, but not critically.
type: bug
The issue is a confirmed bug.
Describe the bug
Currently, WooPayments conditionally registers payment methods for the checkout block, filtering out those that are ineligible based on requirements like country, total, etc. This is problem because WooCommerce core expects all registered payment gateways to have a matching call to
registerPaymentMethod()
and WooPayments registers each UPE payment method as a gateway, viaregister_gateway()
in PHP. Relevant code here. When a registered gateway does not have a matching call toregisterPaymentMethod()
, a warning is displayed in the checkout editor stating that the missing payment method is incompatible with the checkout block. This is a false positive and only occurs due to the mismatch described above.One situation that triggers this warning occurs when an enabled payment method has a minimum purchase amount, and the logged-in admin has items in their cart that do not meet that minimum. The checkout block relies on StoreAPI data for cart totals; therefore, the enabled payment method is not registered via
registerPaymentMethod()
in that scenario.Ideally, all payment methods should be registered via
registerPaymentMethod()
and their display should be controlled viacanMakePayment
as opposed to conditionally registering each payment method.This might also be an opportunity to ensure payment method names are displayed properly in the checkout block editor. For example, when the Payment Options block is highlighted, a list of payment methods appears in the sidebar. Rather than detailing each enabled payment method, WooPayments is duplicated for each payment method:
To Reproduce
Actual behavior
WooPayments payment methods are not always registered via
registerPaymentMethod()
which can lead to false incompatibility warnings.Screenshots
Expected behavior
WooPayments payment methods should all be registered via
registerPaymentMethod()
and no incompatibility notices should appear.Additional context
The text was updated successfully, but these errors were encountered: