Build With RevenueCat

Build a customized mobile subscription business with RevenueCat. We do the heavy lifting of normalizing subscribers from any source and maintain a single source of truth for subscription status, so you can get back to building your app.

RevenueCat is a powerful, secure, reliable, and free to use in-app purchase server with global support. All you need to get started is an API key.

Get Started    REST API Endpoints

Apple App Store

Testing purchases in App Store Sandbox

πŸ‘

This section assumes you've followed our Quickstart section of our Getting Started guide to install and configure our SDK.

Create a sandbox test account

In order to test your purchases, you'll need a sandbox test account. You can create test accounts from your App Store Connect dashboard > Users and Access > Sandbox Testers.

If you need help, you can refer to Apple's guide on creating sandbox testers here.

πŸ“˜

Valid email required for sandbox accounts

Keep in mind you'll need to create sandbox accounts with valid emails that you can verify you own.

Testing on Device

This section is for testing on a physical device. If you want to test on the simulator, skip to the next section for instructions on how to get started with StoreKit testing.

Add the sandbox test account to your device

On iOS 13 and earlier, even for sandbox purchases, you'll need to test on a real device. Starting in iOS 12, you're able to add a sandbox account to your device without having to sign out of your iTunes account.

On iOS 12 or greater, navigate to Settings > [Your Account] > iTunes & App Store > Sandbox Account.

On iOS 13 or greater, navigate to Settings > iTunes & App Store > Sandbox Account.

Add the sandbox account credentials that you previously created. (The sandbox account credentials won't appear until you've made a purchase using a sandbox account in a development build.)

Add your sandbox account under iOS settings to streamline testing

πŸ“˜

If you do not see the option to add a sandbox account under iOS settings, make a sandbox purchase in your app. Apple will show a popup to enter login details, then you will see your account in iOS settings.

iOS 14 Only: Testing on the Simulator

Starting from iOS 14, you can test sandbox purchases in the simulator. If you're using a physical device, you can skip this section.

Testing on the simulator requires one of these SDK versions:

SDK

Version

iOS

3.9.0+

Flutter

2.0.0+

React Native

4.0.0+

Cordova

2.0.0+

Unity

3.0.0+

πŸ“˜

StoreKit testing works on iOS 14 and later

Make sure to test on a real device if testing on iOS 13 or earlier.

Step 1: Add a StoreKit Configuration file

Go to File > New > File... in the menu bar and select StoreKit Configuration File. Save the file in the top-level folder of your project and add it to your targets.

Search for "storekit" to find the configuration file template quicker.

Add the configuration file to your targets and save.

Step 2: Create a new scheme for StoreKit testing

Click the scheme in the scheme menu and click Manage Schemes...

Select your current scheme and click Duplicate.

In the scheme editor, add the StoreKit Configuration file you created in Step 1 and click Close.

Step 3: Setting up the StoreKit Configuration file.

In the editor, click the "+" button at the bottom and create a new product. In this tutorial, an auto-renewable subscription will be created.

Enter a name for a new subscription group and click Done. The subscription group name should match one that is set up for your app in App Store Connect, but it's not a requirement. That means you can test your subscription groups and products in the simulator and then create the products in App Store Connect later.

πŸ“˜

Products in the configuration file must be set up in RevenueCat

Even though products don't have to be set up in App Store Connect, they have to be set up in RevenueCat so that RevenueCat can validate the sandbox receipt. Refer to the Configuring Products guide for more information.

Configure the subscription as needed by filling in the Reference Name, Product ID, Price, Subscription Duration, and optionally an Introductory Offer. Again, this product doesn't have to exist in App Store Connect for you to test purchasing in the simulator. Here is a sample configuration:

Repeat this for as many products as you want.

Step 4: Uploading the public certificate to RevenueCat.

Go to Editor > Save Public Certificate and save the public certificate to your project.

Go to your app's StoreKit Testing settings and upload the certificate to your app. If successful, you should see Certificate added.

πŸ‘

You did it!

You're ready to make purchases locally in the simulator!

Make a purchase

Build and run your app on your device. When you attempt to make a purchase, you may be still be prompted to sign in with the sandbox account you just created.

πŸ“˜

Apple may prompt you to sign into an iTunes account whenever you make or restore a purchase. When using Purchases, this could only happen when you call .purchasePackage or .restoreTransactions. Developers don't have control over the type of prompt that is shown (Face ID, Touch ID, password, etc.)

Verify transaction appears in dashboard

After a purchase is successful, you should be able to view the transaction immediately in the RevenueCat dashboard. If the purchase does not appear in the dashboard, it's not being tracked by RevenueCat.

πŸ“˜

Make sure Sandbox Data is enabled

Make sure the the View Sandbox Data toggle is enabled in the navigation bar.

πŸ“˜

Sandbox receipts are transferred between users

If a user uploads an expired sandbox receipt (when making a purchase or restoring purchases) that had previously belonged to a different user, the receipt is transferred to the new user. This behavior is in place so you don't need to create a new sandbox user in App Store Connect for every App User Id you wish to test with.

Sandbox specific logic

If latest subscription has expired in sandbox and a new App User Id attempts to purchase or restore, RevenueCat will move the purchases around between users. This logic exists to simplify sandbox testing so you don’t need to create new sandbox users all the time to avoid hitting RECEIPT_ALREADY_IN_USE errors frequently.

Working with subscriptions

In the the sandbox environment, subscription renewals happen at an accelerated rate, and auto-renewable subscriptions renew a maximum of six times per day. This enables you to test how your app handles a subscription renewal, a subscription lapse, and a subscription history that includes gaps.

Because of the accelerated expiration and renewal rates, sometimes not all renewals are reflected in the RevenueCat customer dashboard.

Deleting test users

When testing, it may be helpful to delete a customer and all their receipts from RevenueCat to simulate a new installation. You can delete a specific user from the customer dashboard in RevenueCat. See our docs on deleting users for more information.

πŸ“˜

Make sure to log out of the sandbox user on your testing device

Deleting the user from RevenueCat doesn't delete the user's purchase history with Apple. It only deletes the user's receipt and metadata from our servers. That means making or restoring purchases will restore those purchases with RevenueCat. To simulate purchasing as a completely new user, make sure to log out of the sandbox account on your device and create a new one.

Next Steps

For more information, take a look at the official Apple documentation:
Apple App Store: Testing in-app purchases

Updated about a month ago


Apple App Store


Testing purchases in App Store Sandbox

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.