Skip to content

Changes for toggling app switch for checkout#353

Draft
KunJeongPark wants to merge 6 commits into
feature/app-switchfrom
start-with-app-switch
Draft

Changes for toggling app switch for checkout#353
KunJeongPark wants to merge 6 commits into
feature/app-switchfrom
start-with-app-switch

Conversation

@KunJeongPark

Copy link
Copy Markdown
Contributor

Reason for changes

  • Implement app switch if opted in, eligible or no errors in app launch

Summary of changes

  • Create appSwitchIfEligible property in PayPalWebCheckoutRequest
  • Toggle existing paypal web checkout with app switch if eligible flow
  • If not app switch launched, fallback to web checkout flow

TODO: unit tests

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

* patchCCOWithAppSwitchEligibility

* separate out PatchCcoWithAppSwitchEligibilityResponse

* fix lint error

* unit test and mock
* PayPalWebCheckout handleReturnURL

* Steven PR feedback
@KunJeongPark

KunJeongPark commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

I pushed this as a working draft of app switch for paypal web checkout.
I have working version of app switch for both web checkout and vaulting locally that I did as a POC.
I kept the singleton class for routing incoming universal links back to the merchant app (similar to Braintree's BTAppContextSwitcher) lightweight since we have pending testing for different flows.

I want to separate out the PRs for readability and so reviews are not overwhelming and so unit tests don't have to be
duplicated, rewritten for vault vs web checkout functionalities.

I will keep this PR as a draft and open other PRs in this order:

  1. further demo app changes to support vault without purchase app switch => I just finished testing out payload for app switch for this flow.
  2. demo app changes to enable toggling for app switch with request objects that toggle app switch
  3. handleURLRequest function in PayPalWebCheckoutClient that handles incoming universal links from vault and checkout, unit tests
  4. PayPalWebCheckoutClient changes to implement logic of toggling ASWebSession flow and app switch flow for both
    start and vault functions.
  5. lightweight singleton class to route the incoming URLs from app switch (allow future extensions to support Venmo app switch).
  6. New analytic events and errors

I may change order of #4 and #5 depending on what is the best path for unit testing.
There may be changes after further discussions with checkout team members.
I've posted questions about some scenarios and technical details on backend implementations based on behavior I observed during testing on my POC.

self?.analyticsService?.sendEvent("paypal-web-payments:checkout:auth-challenge-presentation:failed")
}
},
sessionDidComplete: { [weak self] url, error in

@KunJeongPark KunJeongPark Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

While I was testing vault web flow, I had a strange issue with infinite spinner upon return back to the demo app, completion was not being invoked.
I think it's because of the demo app not having a strong reference to the PayPalWebCheckoutClient
in the vaultViewModel in demo app. I faintly remember an inbound few years ago and this is the reason we removed [weak self] in sessionDidComplete block since we have no control over merchant integrations.
Removing weak self here solved the issue since the client with completion reference was not deallocated.

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.

1 participant