capacitor-in-app-purchases
Capacitor In-App Purchases
Set up in-app purchases and subscriptions in Capacitor apps, covering store configuration, plugin integration, purchase flows, receipt validation, and testing.
Prerequisites
- Capacitor 6, 7, or 8 app (Capawesome Purchases requires Capacitor 8+; RevenueCat requires Capacitor 8+).
- Node.js and npm installed.
- For iOS: A paid Apple Developer Program membership, Xcode installed, and an app created in App Store Connect.
- For Android: A Google Play Developer account, Android Studio installed, and an app created in Google Play Console.
Agent Behavior
- Guide step-by-step. Walk the user through the process one step at a time. Never present multiple unrelated questions at once.
- Auto-detect before asking. Check the project for platforms (
android/,ios/),package.jsondependencies, and Capacitor version. Only ask the user when something cannot be detected. - One decision at a time. When a step requires user input, ask that single question, wait for the answer, then continue.
- Present clear options. Provide concrete choices (e.g., "Which purchases plugin do you want to use? (1) Capawesome Purchases (2) RevenueCat") instead of open-ended questions.
Procedures
Step 1: Analyze the Project
Auto-detect the following by reading project files — do not ask the user for information that can be inferred:
- Platforms: Check which directories exist (
android/,ios/). These are the platforms to configure. - Capacitor version: Read
@capacitor/coreversion frompackage.json. - Existing purchases plugins: Check if
@capawesome-team/capacitor-purchases,@revenuecat/purchases-capacitor, or any other in-app purchase plugin is already inpackage.json. If found, inform the user and ask whether to continue with the existing plugin or switch.
Step 2: Configure Products in App Store Connect (iOS)
Skip if ios/ does not exist.
Read references/app-store-connect-setup.md and guide the user through creating in-app purchase products and subscriptions in App Store Connect. This covers:
- Accepting required developer agreements
- Verifying business configuration (Paid Apps Agreement, bank account, tax forms)
- Creating in-app purchase products (consumables, non-consumables, subscriptions)
- Subscription group setup
- Product status requirements
Step 3: Configure Products in Google Play Console (Android)
Skip if android/ does not exist.
Read references/google-play-console-setup.md and guide the user through creating in-app purchase products in Google Play Console. This covers:
- Completing compliance and metadata requirements
- Creating in-app products and subscriptions
- Configuring pricing and tax settings
- Activating products
Step 4: Choose a Purchases Plugin
Ask the user which plugin to use:
- Capawesome Purchases (
@capawesome-team/capacitor-purchases) — Lightweight, no third-party backend dependency. Requires a Capawesome Insiders license. Server-side receipt validation is the developer's responsibility. - RevenueCat (
@revenuecat/purchases-capacitor) — Full backend service with server-side receipt validation, entitlement management, analytics, and integrations. Requires a RevenueCat account.
Default recommendation: Capawesome Purchases for apps that already have a backend for receipt validation or want to avoid third-party dependencies. RevenueCat for apps that want managed receipt validation and subscription analytics out of the box.
Step 5: Install and Configure the Plugin
Based on the user's choice in Step 4:
- Capawesome Purchases: Read
references/capawesome-purchases-setup.mdand follow the installation and platform configuration steps. - RevenueCat: Read
references/revenuecat-setup.mdand follow the installation and platform configuration steps.
Step 6: Implement Purchase Flows
Based on the user's plugin choice:
- Capawesome Purchases: Read
references/capawesome-purchases-implementation.mdand add the purchase code to the project. - RevenueCat: Read
references/revenuecat-implementation.mdand add the purchase code to the project.
Adapt imports and code structure to match the user's framework (Angular, React, Vue, etc.).
The implementation covers:
- Fetching product details
- Purchasing a product
- Finishing transactions (Capawesome) or checking entitlements (RevenueCat)
- Restoring purchases
- Handling unfinished transactions on app startup
- Receipt validation strategy
Step 7: Configure Optional Features
Ask the user which optional features to enable:
- Subscription management — Display subscription status, handle renewals and expirations.
- Introductory offer eligibility — Check if a user qualifies for introductory pricing (Capawesome Purchases only).
- Server notifications — Set up App Store Server Notifications and/or Google Play Real-time Developer Notifications for subscription lifecycle events.
For each selected feature, read the corresponding implementation reference file and apply the relevant code.
Step 8: Test Purchases
Read references/testing.md and guide the user through testing in-app purchases on both platforms. This covers:
- iOS Sandbox testing with test accounts
- iOS StoreKit Testing in Xcode
- Android testing with Google Play Console internal track and license testing accounts
- Common testing pitfalls and debugging tips
Step 9: Sync and Verify
npx cap sync
Build and run on each platform to verify purchases work end-to-end:
npx cap run android
npx cap run ios
Error Handling
- Products not appearing: On iOS, products may take up to a few hours to become available after creation in App Store Connect. Verify product status is "Ready to Submit" or "Approved". On Android, verify products are in "Active" status and the app has been uploaded to at least the internal testing track.
- Purchase fails silently on Android: The app must be installed from Google Play (not via direct APK install). Upload the app to the internal testing track, add test accounts under License Testing, and install from Google Play.
- iOS sandbox purchase loops or fails: Ensure the device is signed into a Sandbox test account (Settings > App Store > Sandbox Account on iOS 14+). Do not use a production Apple ID for testing.
purchaseProduct()returns error on Android: Verifygoogle-services.jsonis present and the Google Play Billing Library version is compatible. Check$googlePlayBillingVersioninandroid/variables.gradle.- Receipt validation fails: On iOS, verify the JWS token via
transaction.verificationResult. On Android, validatetransaction.token,transaction.originalJson, andtransaction.signatureagainst the Google Play Developer API. - Restore purchases shows nothing: On iOS,
syncTransactions()displays a system authentication dialog — it must be called in response to an explicit user action (e.g., a "Restore Purchases" button tap). On Android, it runs silently. finishTransaction()not called: Unfinished transactions block future purchases on some platforms. Always callfinishTransaction()after delivering content. Check for unfinished transactions at every app launch.- Plugin not found at runtime: Ensure
npx cap syncwas run after installation. For Capawesome Purchases, verify the Capawesome npm registry is configured. - Capacitor version mismatch: Both Capawesome Purchases and RevenueCat require Capacitor 8+. Check
@capacitor/coreversion inpackage.json.
Related Skills
capacitor-plugins— For general Capacitor plugin installation and configuration, including the Capawesome Purchases and RevenueCat plugins.capawesome-cloud— For app store publishing after in-app purchases are configured.