You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue describes the required work needed to separate the Card and WooPayments gateway implementation in order to be able to disable the Card payment method without affecting other functionality. The work listed here is the result of the spike #9798 (Proof of Concept: #9844 )
Implement the following helper functions, the initial implementation of this function will return the same values for both the main and card gateway id, for more details see the POC PR:
These helpers should be added to either WC_Payment_Gateway_WCPay or WC_Payments (Note: These could also be defined using constants, if we think that'd be a better choice).
We need to also implement a way to forward the results of some of these functions to the frontend (see enqueue_gateway_config_scripts function in the POC).
The next step can be split into pieces, we need to audit every place where the following is used:
The strings 'card', 'link' or their corresponding backend constants PAYMENT_METHOD_IDS::CARD, PAYMENT_METHOD_IDS::LINK or frontend constants PAYMENT_METHOD_IDS
The string woocommerce_payments when used to refer to the main Gateway, as well as the relevant backend constants WC_Payment_Gateway_WCPay::GATEWAY_ID and frontend constants like PAYMENT_METHOD_NAME_CARD
For each one of the found usages, we need to use the data from the helper methods to determine if we are referring to the main gateway or the card gateway. You can find some examples in the POC, but usually we'll only want to refer to the main gateway when configuring the gateways when the app is being bootstrapped (like in WC_Payments::init()), when checking if WooPayments is enabled, or when working with Express Payment methods. In most other scenarios we'll want to use the Card gateway/payment method.
We need to perform the same audit in the E2E tests, however, instead of using the helper methods we could just add the gateway IDs to the tests config (see an example of this in the POC, implemented for the Playwright tests).
Update the SCSS files using variables that reference woocommerce_payments (like the selector .payment_method_woocommerce_payments) to use a variable instead. See an example in the POC, search for $card_gateway_id in the webpack shared config and scss files.
At this point and once all references have been replaced, the plugin behavior should remain exactly the same, with no regressions in sight.
Now, we need to integrate the rest of the work in a single PR (if needed we can split the task and work using a "main" feature branch). The required work would be the following:
Add a new "Dummy" Payment Method for the Main Gateway (See Main_Payment_Method in the POC). This is required since the class that implements the functionality for all Gateways (WC_Payment_Gateway_WCPay) requires a Payment Method to work properly, although ideally we would want to have a separate class for the main gateway, doing so would considerably increase the effort of this plan.
Update the helper methods to differentiate between the Main Gateway (woocommerce_payments) and Main Payment Method (main) from the Card Gateway (woocommerce_payments_card) and Card Payment Method (card) (see POC).
There are some snippets that need to be added to help differentiate the "main" Payment method from actual payment methods. You can search in the POC PR for is_using_separate_gateways to see some examples. In general, we don't want the "main" Payment method to be an option during checkout (but it still needs to be available as a gateway in order to process Express payments).
Update all the css rules so they can reference the woocommerce_payments_card element. (See some examples in the draft PR).
Make sure the Card Gateway is enabled by default in new installations (See set_defaults and $this->form_fields in draft PR).
Add a migration to make sure the new Card Gateway is enabled by default in all existing installations. This migration should also update the gateway_id in all existing card payment tokens (WC_Payment_Token_CC and WC_Payment_Token_WCPay_Link) to use the new Card Gateway ID.
Update the settings logic to disable Link and WooPay if the Card payment method is disabled (Maybe this could be a follow-up task?).
The text was updated successfully, but these errors were encountered:
Description
This issue describes the required work needed to separate the Card and WooPayments gateway implementation in order to be able to disable the Card payment method without affecting other functionality. The work listed here is the result of the spike #9798 (Proof of Concept: #9844 )
The text was updated successfully, but these errors were encountered: