Overview
When a user accepts an offer, the SDK fires onPurchaseRequest with the product to purchase. Your handler triggers the purchase through your billing library.
Setup
Register your purchase handler at app startup, after configure():
Encore.onPurchaseRequest { request ->
// request.productId — store product to purchase
// request.placementId — which placement triggered this
// request.promoOfferId — promotional offer ID (iOS only, nullable)
yourBillingService.purchase(request.productId)
}
Example: RevenueCat
Encore.onPurchaseRequest { request ->
val product = Purchases.sharedInstance
.getProductsAsync(listOf(request.productId))
.firstOrNull() ?: return@onPurchaseRequest
Purchases.sharedInstance.purchaseProduct(product)
}
If you use a third-party subscription manager (RevenueCat, Adapty, etc.), always set onPurchaseRequest so purchases route through your manager’s SDK for proper attribution and receipt validation.
Native Billing Fallback
If no onPurchaseRequest handler is set, the native SDK falls through to platform billing (Play Billing on Android, StoreKit on iOS).
Use onPurchaseComplete to be notified when a native purchase completes:
Encore.onPurchaseComplete { result, productId ->
// result.purchaseToken — Android Play Billing token
// result.transactionId — iOS StoreKit transaction ID
// result.productId — the purchased product
}