> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autosana.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing In-App Purchases

> Test RevenueCat purchase flows and entitlements on Autosana virtual devices.

Use RevenueCat Test Store to automate in-app purchase flows without an App Store or Google Play test account. Test purchases update `CustomerInfo`, grant entitlements, and appear as sandbox data in RevenueCat.

## RevenueCat

### How it works

RevenueCat Test Store replaces the native store purchase sheet with a test modal. Autosana can select a successful, failed, or cancelled outcome and then verify how your app responds.

Use this workflow to test:

* Paywall navigation and product selection
* Successful purchases and entitlement unlocks
* Failed and cancelled purchases
* Entitlement state after the app is reopened

### Configure RevenueCat Test Store

1. Check that your RevenueCat SDK supports Test Store in the [RevenueCat Test Store requirements](https://www.revenuecat.com/docs/test-and-launch/sandbox/test-store#sdk-version-requirements).
2. In RevenueCat, open **Apps and providers** and create or select a Test Store.
3. In **Product catalog**, create the products used by your test paywall.
4. Attach each product to a package in an offering. Make sure your app fetches that offering.
5. Initialize the RevenueCat SDK with the Test Store API key. Test Store keys begin with `test_`.

<Warning>
  Never submit a build configured with a Test Store key to the App Store or Google Play. Use build configuration or environment variables to select the Test Store key only for dedicated test builds.
</Warning>

### Build a standalone test app

Create a development or debug build that:

* Uses the RevenueCat `test_` key
* Includes the app code and assets needed to run without a development server
* Does not depend on Metro, hot reload, or another process on your computer

If your framework's normal debug build connects to a local bundler, create a dedicated standalone testing configuration that remains a development/debug build while bundling the app locally.

See [Building Your Mobile App for Our Cloud](/app-build-guide) for supported artifact formats and platform-specific build requirements.

### Upload the build to Autosana

1. Open **[Apps](https://autosana.ai/apps)** in Autosana.
2. Create or select your iOS or Android app.
3. Upload the standalone test artifact and make it the active build: a zipped `.app` for an iOS Simulator, or an `.apk` or `.aab` for Android.
4. Run the purchase flows on a compatible virtual device.

### Create purchase flows

Create separate flows for outcomes that need a clean starting state. Replace the bracketed text with the screens, plans, and premium state used by your app.

<Tabs>
  <Tab title="Successful purchase">
    ```text theme={null}
    Open the app and navigate to [the subscription paywall].
    Choose [the monthly plan].
    In the RevenueCat Test Store purchase dialog, choose the successful purchase option.
    Verify that the purchase completes.
    Verify that [the premium screen or feature] is unlocked.
    ```
  </Tab>

  <Tab title="Failed purchase">
    ```text theme={null}
    Open the app and navigate to [the subscription paywall].
    Choose [the monthly plan].
    In the RevenueCat Test Store purchase dialog, choose the failed purchase option.
    Verify that the app shows an error and remains usable.
    Verify that [the premium screen or feature] is still locked.
    ```
  </Tab>

  <Tab title="Cancelled purchase">
    ```text theme={null}
    Open the app and navigate to [the subscription paywall].
    Choose [the monthly plan].
    Cancel the RevenueCat Test Store purchase dialog.
    Verify that the app returns to the paywall and remains usable.
    Verify that [the premium screen or feature] is still locked.
    ```
  </Tab>

  <Tab title="Entitlement persistence">
    ```text theme={null}
    Complete a successful purchase for [the monthly plan].
    Close and reopen the app.
    Verify that [the premium screen or feature] remains unlocked.
    ```
  </Tab>
</Tabs>

### Verify the result in RevenueCat

After a run, open the customer in RevenueCat and enable sandbox data. Confirm that:

* The purchase is associated with the expected App User ID
* A successful purchase activated the expected entitlement
* A failed or cancelled purchase did not activate the entitlement

If you use RevenueCat webhooks or integrations, you can also confirm that the matching sandbox event was delivered.

### Troubleshooting

| Problem                                                               | What to check                                                                                                        |
| --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| Offerings or packages are empty                                       | Confirm that each Test Store product is attached to a package in the offering fetched by the app.                    |
| The app exits during RevenueCat configuration                         | Confirm that the `test_` key is used by a development/debug test build, not a production build.                      |
| A native store sheet appears or the app reports `BILLING_UNAVAILABLE` | Confirm that this build initializes RevenueCat with the Test Store key instead of an Apple or Google key.            |
| The app unlocks content but no purchase appears in RevenueCat         | Enable sandbox data and confirm the App User ID used by the test.                                                    |
| A test starts with an existing entitlement                            | Use a fresh test App User ID or reset the customer's Test Store state in RevenueCat before testing a first purchase. |

### Before you ship

Replace the `test_` key with the correct platform-specific RevenueCat key before releasing the app. RevenueCat also recommends completing final purchase validation through Apple or Google platform sandboxes; follow [RevenueCat's sandbox testing guide](https://www.revenuecat.com/docs/test-and-launch/sandbox) for those steps.
