Skip to content

Conversation

@hmouhtar
Copy link
Collaborator

@hmouhtar hmouhtar commented Jul 15, 2025

When returning from AppSwitch, the onApprove callback takes a few seconds to finish processing. During this time, the user could click the PayPal button again or trigger other WooCommerce actions like "Proceed to Checkout", which disrupted the AppSwitch flow and caused unexpected issues reported by QA.

This PR addresses the problem by implementing the same approach used at checkout: blocking the entire UI while the payment is being processed.

Classic contexts:

To address this in classic contexts, I've reused the Spinner class, triggering a full-page blocking overlay when the onApprove callback is triggered, and removing it in the .finally callback.

Block contexts:

Block contexts are trickier. Unblocking the spinner in the .finally callback of the onApprove method was too soon, since WooCommerce has its own async order processing in block contexts. This left a significant time window in which the user could perform actions like clicking "Proceed to Checkout".

To handle block contexts, I’ve set up a useEffect that tracks the value of isFullPageSpinnerActive and toggles the spinner when it changes. This allows the spinner to be enabled in the onApprove callback, remain active, and be removed only in exceptional circumstances such as checkout errors which are handled by WooCommerce events.

@hmouhtar hmouhtar requested a review from danieldudzic July 15, 2025 20:57
@hmouhtar hmouhtar marked this pull request as ready for review July 15, 2025 20:57
@hmouhtar hmouhtar requested review from Dinamiko and Narek13 July 16, 2025 13:10
@hmouhtar hmouhtar force-pushed the PCP-4712-appswitch-qa branch from 764a49f to 2937d6a Compare July 16, 2025 13:11
Copy link
Collaborator

@Narek13 Narek13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for working on this.

@hmouhtar hmouhtar changed the title Block UI during onApprove callback on classic components (4712) Block UI during onApprove callback (4712) Jul 16, 2025
@hmouhtar hmouhtar force-pushed the PCP-4712-appswitch-qa branch 2 times, most recently from 570f8fa to ba2b724 Compare August 12, 2025 21:53
@github-actions
Copy link

github-actions bot commented Aug 12, 2025

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

🔗 Test this pull request with WordPress Playground

What's included:

  • ✅ WordPress (latest)
  • ✅ WooCommerce (latest)
  • ✅ PayPal Payments plugin v3.0.9-pr3533-17446459823-gb267836 (built from this PR)

Login credentials:

  • Username: admin
  • Password: password

Plugin Details:

  • Version: 3.0.9-pr3533-17446459823-gb267836
  • Commit: b267836
  • Artifact: woocommerce-paypal-payments-3.0.9-pr3533-17446459823-gb267836

💡 The demo environment resets each time you refresh. Perfect for testing!

🔄 This link updates automatically with each new commit to the PR.

⚠️ This URL is valid for 30 days from when this comment was last updated.


🤖 Auto-generated for commit b267836 • Last updated: 2025-09-03T21:29:56.465Z

Copy link
Collaborator

@Narek13 Narek13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. LGTM

@hmouhtar hmouhtar force-pushed the PCP-4712-appswitch-qa branch from ba2b724 to 02d05dc Compare August 25, 2025 00:59
@hmouhtar hmouhtar changed the base branch from trunk to develop August 25, 2025 01:00
@hmouhtar hmouhtar force-pushed the PCP-4712-appswitch-qa branch from da9f409 to d4a3b6d Compare September 3, 2025 21:10
@hmouhtar hmouhtar force-pushed the PCP-4712-appswitch-qa branch from d4a3b6d to c7270c8 Compare September 3, 2025 21:12
@Dinamiko Dinamiko merged commit 760489e into develop Sep 5, 2025
21 checks passed
@Dinamiko Dinamiko deleted the PCP-4712-appswitch-qa branch September 5, 2025 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants