Skip to content

Conversation

@naderchehab
Copy link

@naderchehab naderchehab commented Dec 3, 2025

Description

Add support for new-tab based app switch flows to preserve merchant client-side state during PayPal checkout.

Problem

Today, when appSwitchWhenAvailable: true is set and the PayPal app is not installed, the SDK performs a full-page redirect to web checkout. This clears the merchant page's client-side state, which is problematic for merchants who rely on that state.

Solution

Introduce a new preferences object that allows merchants to configure app switch behavior:

  paypal.Buttons({
    preferences: {
      appSwitchWhenAvailable: true,
      launchAppSwitchIn: 'newTab'  // or 'sameTab'
    },
    createOrder: () => fetch('/api/orders').then(r => r.text()),
    onApprove: ({ orderID, isAppSwitchManualReturn }) => { /* ... */ }
  }).render('#paypal-buttons');

Behavior

  • launchAppSwitchIn: 'newTab': Opens a loader in a new tab, deep-links to the PayPal app from there. If the app is not installed, web checkout renders in the new tab, preserving the merchant page state.
  • launchAppSwitchIn: 'sameTab': Uses full-page redirect (existing/legacy behavior).

Why are we making these changes? Include references to any related Jira tasks or GitHub Issues

Reproduction Steps (if applicable)

Screenshots (if applicable)

Dependent Changes (if applicable)

Groups who should review (if applicable)

❤️ Thank you!

@naderchehab naderchehab force-pushed the feature/appSwitchNewTab branch from 9e15c45 to 187a71d Compare December 3, 2025 06:20
// Accepts boolean (legacy) OR object { enabled, mode }
appSwitchWhenAvailable: {
type: "boolean",
type: "object",
Copy link

Choose a reason for hiding this comment

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

This opens up possibility of errors.

Copy link
Author

Choose a reason for hiding this comment

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

Updated

@naderchehab naderchehab force-pushed the feature/appSwitchNewTab branch 2 times, most recently from 3f8ab37 to 5274252 Compare December 4, 2025 20:54
@naderchehab naderchehab marked this pull request as ready for review December 5, 2025 17:07
@naderchehab naderchehab requested a review from a team as a code owner December 5, 2025 17:07
@naderchehab naderchehab force-pushed the feature/appSwitchNewTab branch from 6dbaa6a to ae31aa3 Compare December 5, 2025 17:48
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.

3 participants