PaywallModel

class PaywallModel(val purchases: Purchases, localConfiguration: PaywallConfiguration? = null, paywallIdentifier: String? = null)

Coordinates local and remote paywall configuration with the purchase and restoration flow.

Parameters

localConfiguration

The local paywall configuration, or the fallback for a remote paywall.

paywallIdentifier

The remote paywall identifier created in Purpl.

Constructors

Link copied to clipboard
constructor(purchases: Purchases, localConfiguration: PaywallConfiguration? = null, paywallIdentifier: String? = null)

Properties

Link copied to clipboard

The Purpl instance used for purchases and entitlement checks.

Link copied to clipboard
val state: StateFlow<PaywallState>

The current paywall state.

Functions

Link copied to clipboard
suspend fun load()

Shows the local fallback first, then loads the remote configuration and actual store products.

Link copied to clipboard

Applies remote paywall changes that arrive after a cached configuration is shown.

Link copied to clipboard
suspend fun observeCustomerInfo()

Applies the latest customer information after purchases, restoration, or returning to the app.

Link copied to clipboard
suspend fun purchase(activity: Activity, option: StorePurchaseOption, replacement: suspend (StorePurchaseOption) -> SubscriptionReplacement? = { null }): PurchaseResult?

Purchases an option, applying the subscription replacement policy chosen by the app.

Link copied to clipboard
suspend fun restore(): CustomerInfo?

Restores owned purchases and shows the latest entitlement result.

Link copied to clipboard
fun select(identifier: String)

Selects a purchase option that is currently available.