Skip to content

Add onWebCheckoutOpened to paywall listener surfaces#7260

Open
AlvaroBrey wants to merge 10 commits into
mainfrom
alvarobrey/sdk-4398-web-checkout-opened-listener
Open

Add onWebCheckoutOpened to paywall listener surfaces#7260
AlvaroBrey wants to merge 10 commits into
mainfrom
alvarobrey/sdk-4398-web-checkout-opened-listener

Conversation

@AlvaroBrey

@AlvaroBrey AlvaroBrey commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Motivation

Adds a callback so host apps know when a paywall hands off to web checkout, instead of just seeing it dismiss with no signal.

Part of SDK-4398.

Changes

  • PurchaseHandler.signalWebCheckoutOpened() + WebCheckoutOpenedPreferenceKey.
  • .onWebCheckoutOpened { } modifier, threaded through presentPaywallIfNeeded/presentPaywall (last param, for ABI compat).
  • PaywallViewControllerDelegate.paywallViewControllerDidOpenWebCheckout(_:) for UIKit.
  • Fires only once the URL opens successfully; cleared before an exit offer presents so it can't leak into it.

Related PRs

Testing

  • New OnWebCheckoutOpenedModifierTests + PurchaseHandlerTests coverage.
  • API testers updated, .swiftinterface baselines regenerated.

Note

Medium Risk
Additive public API on paywall presentation and purchase handoff paths; timing around dismiss, session reset, and exit offers could affect callback delivery if regressed.

Overview
Adds a web checkout opened signal so host apps can react when a paywall sends the user to external web checkout, separate from purchase cancel or dismiss.

SwiftUI: New WebCheckoutOpenedHandler, .onWebCheckoutOpened, and WebCheckoutOpenedPreferenceKey driven by PurchaseHandler.signalWebCheckoutOpened() (fresh UUID per tap). Wired through PaywallView / PaywallsV2View and all presentPaywall / presentPaywallIfNeeded overloads as an optional trailing parameter.

UIKit: Optional paywallViewControllerDidOpenWebCheckout(_:) on PaywallViewControllerDelegate.

When it fires: V2 web checkout buttons call Browser.navigateTo with a completion; they signal and dismiss only if the URL actually opened. Failed or unknown URL methods do not fire the callback.

Lifecycle: resetForNewSession() defers clearing the signal so observers still see it after dismiss; presenting an exit offer calls clearWebCheckoutOpened() synchronously so the reused PurchaseHandler does not re-fire on the exit offer paywall.

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

Notifies hosts when the user taps a web checkout CTA (Purchase Button
web methods and the Button component's web paywall link), so they can
react on their side of a web purchase flow instead of only seeing a
dismiss. Adds a SwiftUI onWebCheckoutOpened modifier and a UIKit
paywallViewControllerDidOpenWebCheckout delegate method. SDK-4398.
@AlvaroBrey AlvaroBrey added the pr:feat A new feature label Jul 20, 2026
@AlvaroBrey AlvaroBrey self-assigned this Jul 20, 2026
Closes a coverage gap: the modifier's PreferenceKey plumbing had no
test exercising it end-to-end (unlike Android's Compose click test),
only PurchaseHandler's own state change was covered.
Adds onWebCheckoutOpened/WebCheckoutOpenedHandler/paywallViewControllerDidOpenWebCheckout
to the checked-in swiftinterface baselines across all 9 platforms, and
registers OnWebCheckoutOpenedModifierTests.swift in RevenueCat.xcodeproj
so it isn't flagged as an orphaned file.
Both openWebPaywallLink implementations fired signalWebCheckoutOpened
and dismissed synchronously, ahead of openURL's async completion, so
a failed URL open still reported success. Route ButtonComponentView's
web paywall link through Browser.navigateTo (matching
PurchaseButtonComponentView and honoring the configured open method,
which it previously ignored) and gate the signal on completion.
These convenience modifiers forwarded every other purchase/restore
event to their PaywallView but silently dropped onWebCheckoutOpened.
Also clear the pending signal before presenting an exit offer: it
reuses the same PurchaseHandler without a full session reset, so a
stale UUID could re-fire the callback on the exit offer's paywall.
@AlvaroBrey
AlvaroBrey marked this pull request as ready for review July 23, 2026 11:31
@AlvaroBrey
AlvaroBrey requested review from a team as code owners July 23, 2026 11:31
signalWebCheckoutOpened() and the subsequent dismiss/reset can run in
the same synchronous step, and clearing webCheckoutOpened immediately
can coalesce away the SwiftUI render pass that delivers the signal to
onWebCheckoutOpened observers, silently dropping the callback.

Found by Cursor Bugbot on this PR.
PaywallsV2View published every other purchase/restore preference key
except this one, so onWebCheckoutOpened never fired for V2 full-screen
paywalls: the only surface with web checkout buttons.

Found by Cursor Bugbot on this PR.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 018e8b8. Configure here.

Comment thread RevenueCatUI/Purchasing/PurchaseHandler.swift
The previous commit deferred this clear to fix a different race, but
that broke the exit-offer path: presentIfAvailable() and this clear run
in the same synchronous step as the exit offer's paywall mounting, so a
deferred clear let its brand new onWebCheckoutOpened observer see the
stale, already-handled signal as its own fresh one. resetForNewSession's
clear stays deferred; only this call site needs to be synchronous.

Found by Cursor Bugbot on this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant