Skip to content

Add onWebCheckoutOpened to PaywallListener#3809

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

Add onWebCheckoutOpened to PaywallListener#3809
AlvaroBrey wants to merge 5 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 to PaywallListener 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

  • PaywallListener.onWebCheckoutOpened(): no-op default, called when a web-checkout button is tapped and the URL actually opens.
  • Listener-only; PaywallResult unchanged.
  • Fires only for web-checkout navigation, not generic Button-component URLs.

Related PRs

Testing

  • PaywallActionTests: autoDismiss true/false, unknown-method case.
  • api.txt updated.

Note

Low Risk
Backward-compatible public API default method; behavior is limited to paywall web-checkout navigation and listener signaling, with no purchase or auth changes.

Overview
Adds PaywallListener.onWebCheckoutOpened() (default no-op) so host apps can tell when a paywall web-checkout CTA successfully hands off to an external URL, separate from dismiss/cancel. PaywallResult is unchanged; PaywallActivity forwards the callback to the app listener.

Web checkout handling in InternalPaywall is extracted into handleLaunchWebCheckout, which calls notifyWebCheckoutOpened() only when the URL actually opens. URLOpener.openURL and handleUrlDestination now return Boolean so unknown open methods and open failures (e.g. no handler) do not fire the listener. autoDismiss behavior is unchanged.

Public api.txt, Java API tester, mocks, and PaywallActionTests cover auto-dismiss on/off, unknown method, and failed deep-link open.

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

Notifies listeners when the user taps a web checkout CTA, so hosts can
react (e.g. syncPurchases) on the other side of a web purchase flow
instead of only seeing a generic dismiss. SDK-4398.
Kotlin default interface methods aren't inherited by Java callers
without -Xjvm-default, so the Java api-tester's anonymous PaywallListener
must implement every method explicitly. Fixes CI compile failure.
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.43%. Comparing base (0ed226a) to head (b67639b).
⚠️ Report is 18 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3809   +/-   ##
=======================================
  Coverage   80.43%   80.43%           
=======================================
  Files         407      407           
  Lines       16877    16877           
  Branches     2464     2464           
=======================================
  Hits        13575    13575           
  Misses       2342     2342           
  Partials      960      960           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AlvaroBrey

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 3b43c28. Configure here.

handleUrlDestination silently no-ops for an unrecognized url_method
(decoded as UNKNOWN), but the listener was still being told a web
checkout had launched. Gate the notification on the URL actually
being opened, and add regression tests for both the unknown-method
and non-autoDismiss paths.
…ions

Reduces rememberPaywallActionHandler's cyclomatic complexity below threshold. TooManyFunctions suppression matches existing convention in LoadingPaywall.kt/PaywallActivity.kt.
@AlvaroBrey
AlvaroBrey marked this pull request as ready for review July 23, 2026 11:31
@AlvaroBrey
AlvaroBrey requested a review from a team as a code owner July 23, 2026 11:31

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice one!

}
}

URLOpener.openURL(this, url, openingMethod)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess this may still fail if there is an issue with the URL... but that shouldn't normally happen and one could argue it's a problem on the developer side so I think it's fine for this.

URLOpener.openURL previously returned Unit, so handleUrlDestination
always reported success for any recognized method even if the actual
Android URL-opening call failed (no matching activity, bad URI).
openURL now returns whether it actually opened the URL.

Per review discussion: #3809 (comment)
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.

2 participants