Skip to content

Conversation

@ianrumac
Copy link
Collaborator

@ianrumac ianrumac commented Jan 26, 2026

Changes in this pull request

  • Enables paywall post-purchase action execution instead of dismissing

Checklist

  • All unit tests pass.
  • All UI tests pass.
  • Demo project builds and runs.
  • I added/updated tests or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have run ktlint in the main directory and fixed any issues.
  • I have updated the SDK documentation as well as the online docs.
  • I have reviewed the contributing guide

Greptile Overview

Greptile Summary

This PR enables paywall post-purchase action execution by introducing a shouldDismiss flag throughout the purchase flow, allowing paywalls to control whether they dismiss immediately after purchase or execute custom actions first.

Key Changes:

  • Added shouldDismiss boolean flag to purchase messages from WebView (defaults to false when not provided)
  • Propagated the flag through the entire purchase pipeline: PaywallMessage.PurchasePaywallWebEvent.InitiatePurchaseTransactionManager.purchase()didPurchase()
  • Modified dismissal logic to check both the shouldDismiss flag AND the automaticallyDismiss setting before dismissing the paywall
  • Introduced PaywallMessage.TransactionComplete message that is sent to the WebView after purchase, enabling paywalls to execute post-purchase actions
  • The implementation maintains backward compatibility by defaulting shouldDismiss to false

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-structured and follows the existing architecture patterns. The shouldDismiss flag properly defaults to false for backward compatibility, and the logic correctly combines both the flag and the existing automaticallyDismiss setting. The changes are additive and non-breaking, with the new TransactionComplete message enabling the intended post-purchase action functionality.
  • No files require special attention

Important Files Changed

Filename Overview
superwall/src/main/java/com/superwall/sdk/paywall/view/webview/messaging/PaywallMessage.kt Added shouldDismiss to Purchase message and new TransactionComplete message for paywall communication
superwall/src/main/java/com/superwall/sdk/dependencies/DependencyContainer.kt Sends TransactionComplete message to webview after successful purchase to enable post-purchase actions
superwall/src/main/java/com/superwall/sdk/store/transactions/TransactionManager.kt Updated purchase flow to use shouldDismiss flag, conditionally dismissing paywall only when both flag and settings allow

Sequence 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)

Loading

@ianrumac ianrumac merged commit cc5b770 into develop Jan 26, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants