Add onWebCheckoutOpened to paywall listener surfaces#7260
Open
AlvaroBrey wants to merge 10 commits into
Open
Conversation
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.
2 tasks
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.
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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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 throughpresentPaywallIfNeeded/presentPaywall(last param, for ABI compat).PaywallViewControllerDelegate.paywallViewControllerDidOpenWebCheckout(_:)for UIKit.Related PRs
Testing
OnWebCheckoutOpenedModifierTests+PurchaseHandlerTestscoverage..swiftinterfacebaselines 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, andWebCheckoutOpenedPreferenceKeydriven byPurchaseHandler.signalWebCheckoutOpened()(fresh UUID per tap). Wired throughPaywallView/PaywallsV2Viewand allpresentPaywall/presentPaywallIfNeededoverloads as an optional trailing parameter.UIKit: Optional
paywallViewControllerDidOpenWebCheckout(_:)onPaywallViewControllerDelegate.When it fires: V2 web checkout buttons call
Browser.navigateTowith 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 callsclearWebCheckoutOpened()synchronously so the reusedPurchaseHandlerdoes 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.