# Test in-app purchases before release

> Buy your app's products in a TestFlight build or as a sandbox tester on your iPhone, see the test purchase in AirPayment, and have your Agents change how sandbox purchases behave.

Source: https://air.build/docs/app-store/test-purchases-before-release/

Before your products go to App Review, buy them yourself. A purchase in a TestFlight build, or one made with a sandbox tester's account, is a test purchase: Apple marks it as sandbox, and AirPayment lists it apart from real sales.

## Before you start

- Set up the products on the **In-App Purchases** tab, and have your Agents add the code that sells them. See [Sell in-app purchases and subscriptions](https://air.build/docs/app-store/sell-in-app/).
- To see your test purchases in AirPayment, turn it on first. See [Sell in-app purchases and subscriptions](https://air.build/docs/app-store/sell-in-app/#turn-it-on).
- Test on an iPhone or iPad. AirPayment keeps only purchases that Apple has signed. A purchase made in a simulator with a local StoreKit configuration file isn't, so AirPayment refuses it.

## Buy in a TestFlight build

1. Have your Agents upload a build with the purchase code. See [Share a beta with TestFlight](https://air.build/docs/app-store/test-with-testflight/#upload-a-new-build).
2. Add yourself to a testing group and install the build with Apple's TestFlight app. See [Share a beta with TestFlight](https://air.build/docs/app-store/test-with-testflight/#invite-testers).
3. In the app, buy the product the way a customer would.
4. Open the **AirPayment** tab. If it still says "Waiting for the first purchase", tap **Check Again**. On iPhone you can also pull down on the tab to read it again.

## Check the purchase in AirPayment

A test purchase is listed under **Transactions** like any other, and its row is marked **Sandbox**. In the totals at the top, it counts under **Sandbox**, not under **Revenue**: "Sandbox and TestFlight purchases never count toward revenue."

- Tap the transaction to see its **Product**, **Storefront** and **App Version**, and check they're the ones you tested.
- To see only test purchases, open the filter (three lines) and choose **Sandbox**.
- Test purchases don't send the Team a purchase notification.
- To clear a test purchase out of the list, touch and hold it (on the Mac, right-click it) and choose **Delete Record**.

See [Sell in-app purchases and subscriptions](https://air.build/docs/app-store/sell-in-app/#what-the-tab-shows) for every column and filter.

## Buy as a sandbox tester

A sandbox tester is a test Apple Account for in-app purchases. You add sandbox testers in App Store Connect.

Sign in with the sandbox tester on the device you test on, then buy in a build of your app installed on it with **Install**. **Install** is in the TestFlight and direct-download builds of AirBuild, not the App Store build. See [Install your app on your iPhone](https://air.build/docs/build/install-on-your-iphone/).

### Change how sandbox purchases behave

Ask an Agent in the Project's chat. Name the tester by their email.

| Ask | What it changes |
| --- | --- |
| "Set the sandbox tester's storefront to France." | The App Store country the tester buys in (`--territory`). Use it to test a price you set for one country. |
| "Turn on interrupted purchases for the sandbox tester." | Purchases are interrupted before they finish (`--interrupt-purchases`), so you can check what the app does then. |
| "Make the sandbox tester's subscriptions renew faster." | A monthly subscription renews much sooner, from once an hour to every few minutes (`--subscription-renewal-rate`). |
| "Clear the sandbox tester's purchase history." | The tester's purchase history is cleared, so you can test buying again (`asc sandbox clear-history`). |

The Agent tells you in the chat what it changed. To see the tester's settings, ask "Show my sandbox tester's settings." (`asc sandbox view`).

## Questions

**My test purchase isn't in AirPayment.**

The build has to include the purchase reporting your Agents added, and the purchase has to be made on a device, not in a simulator. Tap **Check Again**, or pull down on iPhone. Purchases are listed per Project, so make sure you're on the Project of the app you tested.

**Can my Agents make a sandbox tester for me?**

No. `asc sandbox` lists, shows and changes testers and clears their history, but adding one is done in App Store Connect.

**Does Delete Record undo the purchase?**

No. It only removes the record from AirPayment. To buy a product again as a sandbox tester, ask an Agent to clear the tester's purchase history.
