Revenuecat Purchase Flow
Implement the RevenueCat purchase and restore flow.
by revenuecat · MIT
The skill
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-purchase-flow: buy a package and restore purchases
Use this skill when the user wants to complete the purchase side of RevenueCat: fetch offerings, call purchase, deal with cancellation and errors, and expose a "Restore" action. It does not cover rendering a paywall UI (that lives in revenuecat-paywall) or gating features (that lives in revenuecat-entitlements-gate).
If the app has no paywall yet and the user has not asked for a custom one, settle how the paywall is built first (integrate-revenuecat, Section 5c). The default is a RevenueCat Paywall, which handles the purchase itself.
1. Detect the platform
Inspect the working directory and pick the first match, from top to bottom:
- React Native:
package.jsonhas areact-native-purchasesentry, orreact-nativeas a dependency → readplatforms/react-native.md. Ifexpois also a dependency, note it as an Expo project. - Flutter:
pubspec.yamlexists at the project root → readplatforms/flutter.md. - Kotlin Multiplatform:
build.gradle.ktscontains akotlin { … }multiplatform source sets block, or depends oncom.revenuecat.purchases:purchases-kmp*→ readplatforms/kmp.md. - Android (native):
build.gradle(.kts)appliescom.android.application(and is not KMP) → readplatforms/android.md. - iOS (native):
Package.swift,*.xcodeproj,*.xcworkspace, orPodfileat the project root → readplatforms/ios.md.
If several match (e.g. an ios/ folder inside a Flutter project), pick the outermost project, the one that owns the build. If still ambiguous, ask the user which platform they want to configure.
2. Shared concepts (all platforms)
- Flow. Call
getOfferings(), pick aPackagefrom the current offering, callpurchase(package). When it completes successfully, the returnedcustomerInfoalready reflects the purchase. ReadcustomerInfo.entitlements.active["<id>"]to confirm access. - User cancellation is not an application error. Each SDK surfaces it differently: iOS throws a
purchaseCancelledErrorcode, Android throws aPurchasesExceptionwithPurchasesErrorCode.PurchaseCancelledError, Flutter surfaces aPlatformExceptionwith that same code, React Native setse.userCancelled === true. Return silently in this case. Do not show an alert. - Errors worth messaging. Payment declined, network errors, store unavailable, receipt already in use. Everything else should be logged and let the user try again. Never silently succeed when the purchase actually failed.
- Do not unlock content inside the purchase callback. Refresh customer info and let your entitlements listener (see
revenuecat-entitlements-gate) flip the gated UI. This keeps one source of truth for access and avoids drift between the purchase path and the restore path. restorePurchases()is a user action, not an automatic step. It asks the store for the current receipt and syncs it to RevenueCat. Expose it from a visible "Restore purchases" button on the paywall and/or settings screen. Legal requirements on iOS mandate such a button.- One purchase at a time. Disable the paywall buy buttons while a purchase is in flight to prevent double charges.
3. Implementation
Read the platform file that matches detection:
platforms/ios.mdplatforms/android.mdplatforms/kmp.mdplatforms/flutter.mdplatforms/react-native.md
Each platform file contains a complete purchase function and a restore function.
4. Verify
Do not claim the flow works until:
- A sandbox purchase of the current offering's package succeeds end to end, and the user's entitlement flips to active.
- Cancelling the store sheet does not show an error alert and does not leave the UI in a loading state.
- A second purchase attempt for the same active subscription is handled cleanly (StoreKit / Play Billing will surface a
productAlreadyPurchased/receiptAlreadyInUsepath; the flow should not crash). - The restore button, on a fresh install signed in to the same store account, restores the entitlement and updates the UI.
Use this skill
Connect your agent to the Skill Store MCP server and ask for it by ref: revenuecat/revenuecat-purchase-flow-68726491095.
Details
- Publisher
- revenuecat
- Category
- Software Development › Mobile apps
- License
- MIT
- Updated
- 2026-09-25
References
More from revenuecat
- Rc Alternative Billing Use this skill when scoping Google Play alternative billing work with RevenueCat Android SDK 10.x.
- Rc Backend Use this skill when your backend needs to read or update RevenueCat state on Android.
- Rc Cancellations Pauses Winback Use this skill when surfacing cancellation, pause, and winback state on Android with RevenueCat.
- Rc Catalog Management Use this skill when managing the Android product catalog through the Play Console and the Revenue…