Create PaywallPurchaseContext to PurchaseLogic for product changes and offers#3129
Create PaywallPurchaseContext to PurchaseLogic for product changes and offers#3129
PaywallPurchaseContext to PurchaseLogic for product changes and offers#3129Conversation
…rchases-android into cesar/myapp_product_change
tonidero
left a comment
There was a problem hiding this comment.
Some thoughts on the API. Not ideal to have 2 such similarly named types... but I think it might be the better option so let's go with this.
ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/PurchaseLogic.kt
Outdated
Show resolved
Hide resolved
...uecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/activity/PaywallActivity.kt
Outdated
Show resolved
Hide resolved
ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/PurchaseLogic.kt
Outdated
Show resolved
Hide resolved
ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/PurchaseLogic.kt
Outdated
Show resolved
Hide resolved
ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/PurchaseLogic.kt
Outdated
Show resolved
Hide resolved
ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/PurchaseLogic.kt
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3129 +/- ##
=======================================
Coverage 79.22% 79.22%
=======================================
Files 347 347
Lines 13911 13911
Branches 1884 1884
=======================================
Hits 11021 11021
Misses 2109 2109
Partials 781 781 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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, enable Autofix in the Cursor dashboard.
ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/PurchaseLogic.kt
Outdated
Show resolved
Hide resolved
tonidero
left a comment
There was a problem hiding this comment.
Nice one! I think this is probably the cleanest 🫶
I guess we need to do similar changes in iOS + hybrids right? One step at a time 😅
This is a followup from #3062 (comment)
PaywallPurchaseLogicandPaywallPurchaseLogicWithCallback. New interfaces extending the existingPurchaseLogic/PurchaseLogicWithCallback, enabling developers usingMY_APPmode to handle subscription upgrades/downgrades and promotional offers from paywalls.PaywallPurchaseContextcontaining the package, an optionalProductChange, and an optionalSubscriptionOption.PurchaseLogicandPurchaseLogicWithCallbackin favor of the new interfaces. Existing implementations continue to work without changes.PaywallPurchaseLogiconly need to implementperformPurchase(activity, context). No need to implement the oldperformPurchase(activity, rcPackage).Note
Medium Risk
Touches purchase execution paths for
MY_APPmode and changes public API types, so regressions could break custom purchase integrations despite deprecation shims and added tests.Overview
Adds a new custom purchase API for paywalls:
PaywallPurchaseLogic(plusPaywallPurchaseLogicWithCallback) and aPaywallPurchaseLogicParamsobject that carries thePackageplus optional product-change (oldProductId/ReplacementMode) andSubscriptionOptionoffer details.Updates all paywall entry points (
PaywallOptions,PaywallDialogOptions,PaywallActivityLaunchOptions,PaywallView) to acceptPaywallPurchaseLogicinstead ofPurchaseLogic, and deprecates the oldPurchaseLogic/PurchaseLogicWithCallbackwhile keeping them source-compatible via an adapter implementation.Wires the new params through
PaywallViewModelwhenPurchasesAreCompletedBy.MY_APP, and expands tests + api-tester coverage to validate the new context is passed for product changes and resolved offers; public API surface (api.txt) is updated accordingly.Written by Cursor Bugbot for commit 4627605. This will update automatically on new commits. Configure here.