Purpl Docs
Connect the Purpl service
Connect managed catalogs and server entitlements to an Android app.
Prepare the service
- Register the app and Google Play store in Purpl.
- Connect products to entitlements.
- Create a catalog and a paywall that uses it.
Configure server mode
Server mode can load product and entitlement configuration from Purpl without a local PurchaseConfiguration. The SDK resolves the active configuration using the package name, paywall identifier, and current language. Never include Google service account credentials in the app.
import sh.purpl.*
import sh.purpl.ui.*
val purchases = Purchases.configure(
context = applicationContext,
configuration = PurchasesConfiguration(
entitlementMode = EntitlementMode.Server
)
)
PaywallView(purchases = purchases, paywallIdentifier = "standard") {
PremiumMarketingContent()
}Local paywall fallback
To show a local paywall while the remote configuration is loading or unavailable, pass the app PaywallConfiguration as configuration together with paywallIdentifier.
import sh.purpl.*
import sh.purpl.ui.*
PaywallView(
purchases = purchases,
paywallIdentifier = "standard",
configuration = PaywallConfiguration(
catalog = standardCatalog,
defaultPurchaseOptionIdentifier = "plus-yearly"
)
) {
PremiumMarketingContent()
}Entitlement modes
- GooglePlay: Loads current Play purchases and verifies their signatures on the device. Requires the local purchase configuration and the app public key.
- Server: Purpl verifies purchase tokens with Google. Requires the app, store, product, and entitlement setup in Purpl.
- ServerWithGooglePlayFallback: Uses the server first and falls back to device verification during a server outage. Requires both setups.
Only server errors, network failures, and response decoding failures fall back to device verification. Purchases the server has confirmed as inactive, invalid, pending, or not completed never regain access through the fallback.
Remote configuration priority
PaywallModel shows the local fallback first when one exists. A cached remote configuration is applied immediately and refreshed in the background, and refreshed configurations reach open paywalls through paywallConfigurationUpdates. The model waits for the first server response only when neither a cache nor a local fallback is available, and shows an error if that request also fails.