
rc-purchase-flow
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.
- Installs
- 637
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/revenuecat/ai-toolkit --skill rc-purchase-flow- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads rc-purchase-flow automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Purchase Flow
A RevenueCat purchase on Android is two lines of code. The SDK handles the billing params, the Play sheet, the purchase token round trip, server side verification, and acknowledgment. You decide which package to pass in and what to do with the returned entitlements.
Phase 1: Understand what awaitPurchase() does
One call to Purchases.sharedInstance.awaitPurchase(params) runs six steps under the hood. You do not write any of this.
| Step | What happens |
|---|---|
| 1 | Builds BillingFlowParams with the correct ProductDetailsParams from your Package |
| 2 | Calls BillingClient.launchBillingFlow() against the activity you passed |
| 3 | Suspends until the PurchasesUpdatedListener result arrives |
| 4 | If OK, posts the Play purchase token to the RevenueCat backend |
| 5 | Backend verifies via purchases.subscriptionsv2.get or purchases.products.get |
| 6 | SDK acknowledges (subs or non-consumables) or consumes (consumables) within the 3 day Google window |
The call returns PurchaseResult(storeTransaction, customerInfo). Retriable failures are retried automatically.
See the Purchase Flow chapter on revenuecat.com for the six-step diagram and the full picture.
Phase 2: Prepare the package
You need a Package from offerings before you can purchase. Fetch offerings, let your UI pick one, and hold the activity.
val offerings = Purchases.sharedInstance.awaitOfferings()
val pkg = offerings.current?.monthly ?: return
If you need a specific offer instead of the default, resolve a SubscriptionOption and pass that to PurchaseParams.Builder instead of the package.
val option = pkg.product.subscriptionOptions
?.firstOrNull { it.tags.contains("promo_50_off") }
?: pkg.product.defaultOption
?: return
For EU personalized pricing, chain .isPersonalizedPrice(true) on the builder so Play shows the customized price notice.
Phase 3: Execute the purchase
Build the params, await the purchase, read customerInfo to gate access, and handle the two expected error branches.
try {
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)
}
}
Rules for this block:
PurchaseResultis@Poko. Access fields asresult.customerInfoandresult.storeTransaction. Do not destructure withval (transaction, customerInfo) = result.customerInfo.entitlements["<id>"]?.isActive == trueis the gate. Do not checkstoreTransactionto decide access.PurchasesTransactionExceptionis the only exception type thrown byawaitPurchase. Catch it, branch onuserCancelledfirst, then one.error.code.- User cancellation is not an error to surface. Swallow it.
If you prefer callbacks over coroutines, purchaseWith(params, onError, onSuccess) is the equivalent entry point.
Phase 4: Inspect StoreTransaction only if you need it
result.storeTransaction is available but usually unused. customerInfo is the source of truth for entitlements. If you need transaction level data for logging or your own backend:
| Field | Type | Notes |
|---|---|---|
orderId | String? | Null for restored purchases |
purchaseToken | String | Raw Play purchase token |
productIds | List<String> | Product IDs in the transaction |
purchaseTime | Long | Epoch millis |
type | ProductType | SUBS or INAPP |
Phase 5: Restore on reinstall or device switch
Restore runs queryPurchasesAsync(), posts everything found to RevenueCat, and returns the fresh CustomerInfo. Gate access the same way you do after a purchase.
try {
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)
}
Note the exception type. awaitRestore() throws PurchasesException, not PurchasesTransactionException. There is no userCancelled flag to check because no billing sheet is shown.
Exception types at a glance
| Call | Thrown exception | Has userCancelled? |
|---|---|---|
awaitPurchase(params) | PurchasesTransactionException | Yes |
awaitRestore() | PurchasesException | No |
References
FAQ
What does the rc-purchase-flow skill do?
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.
How do I install rc-purchase-flow?
Run npx skills add https://github.com/revenuecat/ai-toolkit --skill rc-purchase-flow in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/rc-purchase-flow/ (personal) or .claude/skills/rc-purchase-flow/ (project).
Which AI agents can use rc-purchase-flow?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is rc-purchase-flow safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains rc-purchase-flow?
It is published by revenuecat in revenuecat/ai-toolkit. It has 637 recorded installs.
More from revenuecat/ai-toolkit
revenuecat-paywall
revenuecat/ai-toolkit
Display a RevenueCat paywall inside an app using the RevenueCatUI SDK. Use when the user asks to add a paywall, show a RevenueCat paywall, present PaywallView, integrate RevenueCatUI, gate a premium screen with a paywall, launch PaywallActivity, call presentPaywall or presentPaywallIfNeeded, or show the dashboard configured paywall UI on iOS, Android, Kotlin Multiplatform, Flutter, or React Native. To create, edit, evaluate, or audit the dashboard paywall itself, use revenuecat-paywall-design.
integrate-revenuecat
revenuecat/ai-toolkit
End-to-end RevenueCat integration — sets up the dashboard side via the RevenueCat MCP or the rc CLI (project, app, public API key) and installs/configures the Purchases SDK in the app. Use when the user asks to add RevenueCat, hook up RevenueCat, add subscriptions or in-app purchases to an app, integrate Purchases, install the RevenueCat SDK, set up a RevenueCat API key, configure Purchases on launch, or set up a brand new RevenueCat integration on iOS, Android, Kotlin Multiplatform, Flutter, or React Native.
revenuecat-purchase-flow
revenuecat/ai-toolkit
Implement the RevenueCat purchase and restore flow. Use when the user asks to buy a package, purchase a subscription, fetch offerings, build the purchase logic behind a custom (hand-coded) paywall, handle purchase errors, detect user cancelled, or restore previous purchases on iOS, Android, Kotlin Multiplatform, Flutter, or React Native.
revenuecat-testing-setup
revenuecat/ai-toolkit
Set up a testing environment for RevenueCat purchases without charging real money. Use when the user says test RevenueCat purchases, sandbox setup, StoreKit configuration file, license tester, how do I test purchases without real money, set up sandbox account, internal testing track, or test paywall on iOS, Android, Kotlin Multiplatform, Flutter, or React Native.
create-revenuecat-project
revenuecat/ai-toolkit
Set up a complete RevenueCat project from scratch — creates apps, products, entitlements, offerings, and packages in the correct order. Use when the user wants to create a new RevenueCat project, configure in-app purchases, set up subscriptions or monetization, or bootstrap IAP infrastructure for iOS, Android, or Web.
revenuecat-troubleshoot
revenuecat/ai-toolkit
Diagnose and resolve RevenueCat integration issues — inspects dashboard configuration through the RevenueCat MCP, walks the SDK debug logs, and covers code-side gotchas. Use when the user says offerings are empty, products not loading, entitlement not active after purchase, paywall won't load, transactions not appearing, customer info shows no entitlements, sandbox purchase not working, an SDK-gated RevenueCat feature not working, or RevenueCat is broken on iOS, Android, Kotlin Multiplatform, Flutter, or React Native. Also use when asked to check or validate the store / product setup.
Popular mobile skills
design-mobile-apps
designed-by-ai/skills
Design mobile app screens with Sleek, edit Sleek projects, and implement their designs in React Native or HTML.
ios-design
uizze.sh
Design and review iOS UI/UX for iPhone apps in SwiftUI, UIKit, or React Native. Use for mobile app design, screen redesigns, navigation flows, typography, forms, keyboard and safe-area layout, and accessibility checks. Apply Apple Human Interface Guidelines and consult real product references through the optional Uizze connection.
vercel-react-native-skills
vercel-labs/agent-skills
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
animate-expo
emilkowalski/skills
Build animations in React Native and Expo, making the decisions in the order that determines whether they feel right — should it animate, which thread it runs on, which properties, spring or timing, how the gesture hands off, how it degrades. Writes the implementation with Reanimated, Gesture Handler, Expo Router and expo-haptics. Use when animating anything in an Expo app, adding gestures, sheets, screen transitions, press feedback or haptics, or fixing motion that stutters on device. For web animation use animate.
xcode-project-setup
firebase/agent-skills
Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).
firebase-remote-config-basics
firebase/agent-skills
Manages Firebase Remote Config templates, feature flags, loading strategies, and SDKs (Android, iOS). Use when downloading/deploying remoteconfig JSON templates, managing version history/feature flags, setting in-app defaults, fetchAndActivate(), real-time listeners, or SDK setup. Don't use for Firebase Hosting, Auth, Firestore, Data Connect, Crashlytics, or App Hosting.