woocommerce / woocommerce-square

Square POS and Payments Integration
https://woo.com/products/square
Other
11 stars 7 forks source link

Fix CashApp Pay and Digital Wallet payments on Block Checkout for WooCommerce 9.3 #216

Closed iamdharmesh closed 2 months ago

iamdharmesh commented 2 months ago

All Submissions:


Changes proposed in this Pull Request:

This PR fixes the CashApp Pay and Digital Wallet payments on Block Checkout for WooCommerce 9.3. The issue was occurring only with WooCommerce 9.3, and I suspect it's due to the React 18 upgrade in WC 9.3. The token updates in the state are not reflected in onPaymentSetup when onSubmit is called.

This PR fixes the issue by replacing onSubmit(); with setTimeout( onSubmit, 0 );, breaking out of the current event loop to ensure state updates in onPaymentSetup. We are having an ongoing discussion with the Woo Team to figure out the proper fix. However, with WC 9.3 releasing tomorrow, proceeding with this fix for now is fine.

Closes #214

Steps to test the changes in this Pull Request:

  1. Upgrade to WooCommerce 9.3(-rc-1)
  2. Try placing an order using CashApp pay from block checkout and verify its works as expected.
  3. Try placing an order using Digital wallets (GooglePay and ApplePay) from block checkout and verify it works as expected.

Changelog entry

Fix - CashApp Pay and Digital Wallet payments on Block Checkout for WooCommerce 9.3

Sidsector9 commented 2 months ago

Related https://github.com/woocommerce/woocommerce-square/issues/217

iamdharmesh commented 2 months ago

Note: The failing test (1 test is failing) is already fixed in the PR https://github.com/woocommerce/woocommerce-square/pull/204

qasumitbagthariya commented 2 months ago

QA Update ✅


I have verified this PR in the enhancement/341 branch which has been fixed and is functioning as intended.

I tested the following on this branch:

Testing Environment

- WordPress: 6.6.2 - Theme: Twenty Twenty-Four 1.2 - WooCommerce - 9.3.0-rc.1 - PHP: 8.0.30 - Web Server: Nginx 1.20.2 - Browser: Chrome - OS: macOS Ventura 13.3 - Branch: fix/214

https://github.com/user-attachments/assets/df3f1b9c-ef2a-47f9-89c2-72c09a1ae9a3

https://github.com/user-attachments/assets/6f625dac-997b-4c14-a2dc-72dc120d7876

dkotter commented 2 months ago

Going to close this out since the issue was resolved in Woo 9.3 itself and this fix is no longer needed