Skip to content

feat(stash-pay): WebKit same-tab redirect (2.3.0) — no extra tabs - #8

Closed
anton-stash wants to merge 3 commits into
mainfrom
feat/stash-pay-webkit-toplevel-checkout
Closed

feat(stash-pay): WebKit same-tab redirect (2.3.0) — no extra tabs#8
anton-stash wants to merge 3 commits into
mainfrom
feat/stash-pay-webkit-toplevel-checkout

Conversation

@anton-stash

@anton-stash anton-stash commented Aug 7, 2026

Copy link
Copy Markdown

Summary

  • On WebKit (desktop Safari + all iOS browsers), @stashgg/stash-pay skips the iframe drawer and same-tab redirects via location.assign(checkoutUrl) so Apple Pay / Google Pay run first-party with no extra tab (explicitly not window.open).
  • Chromium / non-WebKit keep today’s iframe drawer unchanged.
  • New options: preferRedirectOnWebKit (default true), onTopLevelNavigation({ url, mode: 'redirect' }).
  • Callbacks: after redirect the host unloads — do not expect in-page onSuccess / onFailure / onClose on WebKit; fulfillment via webhooks + checkout return URLs. onOpen / onReady still fire immediately before assign.
  • Package 2.3.0; README + MIGRATION updated. Partners only need an npm bump (no DNS / CNAME / pie-mono change).

Why redirect (not new tab / not iframe)

Approach Extra tab? Partner DNS?
Status quo dpm=gpay handoff Yes No
SDK window.open Yes No
SDK location.assign (this PR) No No
Same-origin iframe No Yes

Huuuge rollout

  1. Merge + publish @stashgg/stash-pay@2.3.0
  2. Partner bumps SDK and redeploys
  3. Safari/iOS: pay → same tab navigates to checkout (no drawer, no 2nd tab)
  4. Chrome: drawer unchanged
  5. Confirm webhook + return-URL path covers Safari (drawer callbacks won’t fire after redirect)

Test plan

  • Unit: WebKit UA matrix
  • Unit: redirect vs iframe branch; no window.open; callback order before assign; URL validation still throws
  • typecheck + build
  • Manual: desktop Safari — same-tab navigate to checkout, no iframe, no second tab
  • Manual: desktop Chromium — still iframe drawer
  • Manual: iOS Safari GPay completes without dpm=gpay handoff tab

Note

Medium Risk
Safari/iOS checkout UX and callback semantics change (no in-page success/failure after redirect); integrators must confirm webhooks and return URLs; Chromium path is unchanged.

Overview
@stashgg/stash-pay 2.3.0 changes how checkout opens on WebKit (Safari + iOS): instead of the iframe drawer, the SDK same-tab redirects with location.assign(checkoutUrl) so Apple Pay / Google Pay run first-party without an extra tab. Chromium still uses the iframe drawer.

New API: preferRedirectOnWebKit (default true), onTopLevelNavigation({ url, mode: 'redirect' }), and exported isWebKitEngine(). After redirect the host page unloads — onSuccess / onFailure / onClose won’t run on WebKit; partners should rely on webhooks and checkout return URLs. onOpen / onReady still fire in order before assign.

Adds Vitest + happy-dom and unit tests for WebKit detection and redirect vs iframe branches. README and MIGRATION document the Safari behavior change.

Reviewed by Cursor Bugbot for commit 076bb33. Bugbot is set up for automated code reviews on this repo. Configure here.

On Safari/iOS, skip the cross-origin iframe drawer and open checkout in a
new tab so Google Pay / Apple Pay can complete first-party. Chromium keeps
the existing iframe path. Popup-blocked falls back to location.assign.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stash-pay-web Ready Ready Preview Aug 7, 2026 2:13pm

Request Review

Comment thread packages/stash-pay/src/core/controller.ts Outdated
Partner requirement is no extra tabs. On WebKit, skip the iframe drawer and
location.assign to checkout so wallets run first-party in the same tab.
Document that in-page onSuccess/onFailure/onClose will not run after unload.

Co-authored-by: Cursor <cursoragent@cursor.com>
@anton-stash anton-stash changed the title feat(stash-pay): WebKit top-level checkout (2.3.0) for Safari GPay feat(stash-pay): WebKit same-tab redirect (2.3.0) — no extra tabs Aug 7, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@anton-stash
anton-stash deleted the feat/stash-pay-webkit-toplevel-checkout branch August 25, 2026 10:29
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