Post purchase actions #350
Merged
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.
Changes in this pull request
Checklist
CHANGELOG.mdfor any breaking changes, enhancements, or bug fixes.ktlintin the main directory and fixed any issues.Greptile Overview
Greptile Summary
This PR enables paywall post-purchase action execution by introducing a
shouldDismissflag throughout the purchase flow, allowing paywalls to control whether they dismiss immediately after purchase or execute custom actions first.Key Changes:
shouldDismissboolean flag to purchase messages from WebView (defaults tofalsewhen not provided)PaywallMessage.Purchase→PaywallWebEvent.InitiatePurchase→TransactionManager.purchase()→didPurchase()shouldDismissflag AND theautomaticallyDismisssetting before dismissing the paywallPaywallMessage.TransactionCompletemessage that is sent to the WebView after purchase, enabling paywalls to execute post-purchase actionsshouldDismisstofalseConfidence Score: 5/5
shouldDismissflag properly defaults tofalsefor backward compatibility, and the logic correctly combines both the flag and the existingautomaticallyDismisssetting. The changes are additive and non-breaking, with the newTransactionCompletemessage enabling the intended post-purchase action functionality.Important Files Changed
shouldDismisstoPurchasemessage and newTransactionCompletemessage for paywall communicationTransactionCompletemessage to webview after successful purchase to enable post-purchase actionsshouldDismissflag, conditionally dismissing paywall only when both flag and settings allowSequence Diagram
sequenceDiagram participant WebView as Paywall WebView participant Handler as PaywallMessageHandler participant Superwall as Superwall.kt participant TxnMgr as TransactionManager participant Billing as Google Play Billing participant DepContainer as DependencyContainer WebView->>Handler: Purchase message<br/>(productId, shouldDismiss) Handler->>Handler: Parse shouldDismiss flag<br/>(defaults to false if not provided) Handler->>Superwall: InitiatePurchase event<br/>(productId, shouldDismiss) Superwall->>TxnMgr: purchase(purchaseSource, shouldDismiss) TxnMgr->>Billing: Execute purchase flow Billing-->>TxnMgr: Purchase result TxnMgr->>TxnMgr: didPurchase(product, source, trial, shouldDismiss) alt shouldDismiss == true AND automaticallyDismiss == true TxnMgr->>TxnMgr: dismiss(paywallId, PaywallResult.Purchased) else shouldDismiss == false TxnMgr->>TxnMgr: Skip dismissal end TxnMgr->>DepContainer: notifyOfTransactionComplete(cacheKey, trialEndDate, productId) DepContainer->>Handler: handle(TransactionComplete message) Handler->>WebView: Pass TransactionComplete event<br/>(enables post-purchase actions)