> For the complete documentation index, see [llms.txt](https://help.twinr.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.twinr.dev/extensions/in-app-purchase-iap/revenuecat.md).

# RevenueCat

Instead of handling store validation and subscription logic separately for each platform, RevenueCat acts as a centralized backend layer over:

* Google Play Billing (Android)
* Apple StoreKit (iOS)

Twinr integrates directly with RevenueCat to help you:

* Manage subscriptions across platforms
* Validate receipts securely
* Track subscription lifecycle events
* Simplify purchase implementation
* Access analytics and reporting

## When Should You Use RevenueCat?

RevenueCat is recommended if:

* You offer subscriptions (monthly, yearly, etc.)
* You support both Android and iOS
* You want centralized subscription control
* You need subscription analytics
* You want easier lifecycle management (renewals, cancellations, upgrades)

If you only need simple one-time purchases, native IAP may be sufficient.

## Prerequisites

Before configuring RevenueCat in Twinr, ensure:

1. Your app is created in:
   * Google Play Console
   * Apple App Store Connect
2. In-app products or subscriptions are already created in the respective store.
3. A RevenueCat account is created.

## Step-by-Step Setup Guide

### Step 1: Create a RevenueCat Account

1. Go to: <https://www.revenuecat.com>
2. Sign up or log in.
3. Create a **New Project**.
4. Add both:
   * Android App
   * iOS App

### Step 2: Connect Stores to RevenueCat

Inside RevenueCat dashboard:

#### For Android:

* Connect Google Play Console
* Sync your products

#### For iOS:

* Connect App Store Connect
* Sync your subscription products

{% hint style="info" %}
&#x20;Products must exist in the stores before adding them to RevenueCat.
{% endhint %}

### Step 3: Configure Products & Entitlements

1. Go to **Products**
2. Import or create products
3. Create **Entitlements** (e.g., Premium Access)
4. Attach products to entitlements
5. Create an **Offering**
6. Set the offering as **Current**

This step defines what users unlock after purchase.

### Step 4: Get RevenueCat API Keys

Inside RevenueCat:

1. Go to **Project Settings**
2. Copy:
   * **Public SDK Key (Android)**
   * **Public SDK Key (iOS)**

These keys will be used in Twinr.

## Configure RevenueCat in Twinr

📍 Go to:

**Twinr Builder → Add-Ons → In-App Purchase**

1. Enable **In-App Purchase**
2. Select **Purchase Provider → RevenueCat**
3. Enter:
   * Android API Key (RevenueCat Public SDK Key)
   * iOS API Key (RevenueCat Public SDK Key)
4. Click **Save As Draft**
5. Publish to Production

Once published, RevenueCat integration becomes active.

## How It Works

1. User initiates purchase in the app.
2. Store processes payment.
3. RevenueCat validates the receipt.
4. RevenueCat updates subscription status.
5. Twinr unlocks the entitlement for the user.

All lifecycle events such as renewals, cancellations, and expirations are handled automatically.

## Testing RevenueCat Integration

Before going live:

* Use sandbox test accounts.
* Verify entitlement activation.
* Test subscription renewal.
* Test cancellation behavior.
* Confirm subscription expiration flow.

## Important Notes

* Products must match exactly between:
  * Store
  * RevenueCat
* The offering must be marked as **Current**
* Always test in sandbox mode before production release
* RevenueCat integration is available only for Premium plan customers
