Skip to content

Conversation

hmouhtar
Copy link
Collaborator

@hmouhtar hmouhtar commented Oct 8, 2025

The previous approach for handling cross-browser AppSwitch flows relied on adding query parameters to the return URL. This approach broke the same-tab AppSwitch flow because with the addition of the query parameters, the browser detected the return URL as a different URL and opened a new tab, causing all orders to go through the resume flow.

To solve this, this PR migrates the cross-browser detection and handling logic to the frontend.

Copy link

github-actions bot commented Oct 8, 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.1.2-pr3755-18359678527-g1418c57 (built from this PR)

Login credentials:

  • Username: admin
  • Password: password

Plugin Details:

  • Version: 3.1.2-pr3755-18359678527-g1418c57
  • Commit: 1418c57
  • Artifact: woocommerce-paypal-payments-3.1.2-pr3755-18359678527-g1418c57

💡 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 1418c57 • Last updated: 2025-10-08T22:33:27.584Z

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 Himad. Left a couple of minor suggestions. Also please check the Unit tests

Comment on lines +254 to +258
/**
* Register filters that handle cross-browser AppSwitch orders.
* These filters allow guests to access pay-for-order and order-received pages
* for orders created via cross-browser AppSwitch flows.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/**
* Register filters that handle cross-browser AppSwitch orders.
* These filters allow guests to access pay-for-order and order-received pages
* for orders created via cross-browser AppSwitch flows.
*/
/**
* Registers filters that handle cross-browser AppSwitch orders.
*
* These filters allow guests to access pay-for-order and order-received pages
* for orders created via cross-browser AppSwitch flows.
*/


class CreateCrossBrowserOrderEndpoint implements EndpointInterface {

const ENDPOINT = 'ppc-create-cross-browser-order';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add visibility.

Suggested change
const ENDPOINT = 'ppc-create-cross-browser-order';
public const ENDPOINT = 'ppc-create-cross-browser-order';

assert( ! empty( $key ) );

$custom_args[ self::RETURN_URL_CART_QUERY_ARG ] = $key;
$custom_args['pcp-cart-hash'] = $cart_data->cart_hash();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the indent is not correctly aligned here

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.

2 participants