Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
176 stars 69 forks source link

Blocks: load payment request button configuration in the Blocks Checkout PHP handler instead of relying on configuration loaded for the Shortcode checkout #2604

Open reykjalin opened 3 years ago

reykjalin commented 3 years ago

Similar to the changes introduced in Stripe: https://github.com/woocommerce/woocommerce-gateway-stripe/pull/1585

Problem

We currently rely on the JS configuration loaded for the shortcode checkout here in the block-based checkout (see for example how we use the wcpayPaymentRequestParams global here).

This is bad for at least 2 reasons:

Proposed solution

  1. Extract the configuration object into it's own function (similar to what we did in the Stripe plugin).
  2. Use that function to load the payment request configuration into the Blocks settings here.
  3. Stop using the wcpayPaymentRequestParams global in the block integration JS.

Look at https://github.com/woocommerce/woocommerce-gateway-stripe/pull/1585 for inspiration.

Things to consider and test

  1. Are we relying on some JS from the shortcode JS in the block integration JS?
    • If yes, then we should remove that dependency and implement everything in the block integration JS.
  2. How will this affect other theme builders with their own custom cart and checkout blocks, if at all?
    • Themes to look out for here that we've made mistakes with in the past (see pc4etw-aT-p2): CartFlows, possibly others.
  3. What possible side effects could a refactor like this have?
  4. Can we introduce unit (or even e2e) tests here that help us make sure the refactor doesn't break any existing functionality? Do these tests already exist?
vbelolapotkov commented 8 months ago

@c-shultz this one is related to checkout, but doesn't show up in your board, could you please check?