Loading...
Loading...
Use this skill when implementing a RevenueCat purchase on Android. Covers awaitPurchase, PurchasesTransactionException, reading CustomerInfo entitlements to grant access, restoring purchases, and the six SDK managed steps that happen inside a single call.
npx skill4agent add revenuecat/ai-toolkit rc-purchase-flowPurchases.sharedInstance.awaitPurchase(params)| Step | What happens |
|---|---|
| 1 | Builds |
| 2 | Calls |
| 3 | Suspends until the |
| 4 | If |
| 5 | Backend verifies via |
| 6 | SDK acknowledges (subs or non-consumables) or consumes (consumables) within the 3 day Google window |
PurchaseResult(storeTransaction, customerInfo)Packageval offerings = Purchases.sharedInstance.awaitOfferings()
val pkg = offerings.current?.monthly ?: returnSubscriptionOptionPurchaseParams.Builderval option = pkg.product.subscriptionOptions
?.firstOrNull { it.tags.contains("promo_50_off") }
?: pkg.product.defaultOption
?: return.isPersonalizedPrice(true)customerInfotry {
val result = Purchases.sharedInstance.awaitPurchase(
PurchaseParams.Builder(activity, pkg).build()
)
val customerInfo = result.customerInfo
if (customerInfo.entitlements["pro"]?.isActive == true) {
navigateToApp()
}
} catch (e: PurchasesTransactionException) {
when {
e.userCancelled -> { /* backed out, do nothing */ }
e.error.code == PurchasesErrorCode.ProductAlreadyPurchasedError ->
showMessage("You already have this subscription")
else -> showError(e.error.message)
}
}PurchaseResult@Pokoresult.customerInforesult.storeTransactionval (transaction, customerInfo) = resultcustomerInfo.entitlements["<id>"]?.isActive == truestoreTransactionPurchasesTransactionExceptionawaitPurchaseuserCancellede.error.codepurchaseWith(params, onError, onSuccess)result.storeTransactioncustomerInfo| Field | Type | Notes |
|---|---|---|
| | Null for restored purchases |
| | Raw Play purchase token |
| | Product IDs in the transaction |
| | Epoch millis |
| | |
queryPurchasesAsync()CustomerInfotry {
val customerInfo = Purchases.sharedInstance.awaitRestore()
if (customerInfo.entitlements["pro"]?.isActive == true) {
navigateToApp()
} else {
showMessage("No active purchases found")
}
} catch (e: PurchasesException) {
showError(e.error.message)
}awaitRestore()PurchasesExceptionPurchasesTransactionExceptionuserCancelled| Call | Thrown exception | Has |
|---|---|---|
| | Yes |
| | No |