Key Takeaways
- A working Unity in app purchase setup involves three places: your Unity project, the Google Play Console and App Store Connect. Most failures come from a mismatch between them.
- Product IDs must match exactly across your catalog and each store, and Google does not let you change or reuse a product ID after it is created.
- Grant the item first, then confirm the order. For consumables, Unity IAP blocks a repeat purchase until the previous order is confirmed.
- Test with Google license testers and Apple sandbox accounts, never with real payments.
- Unity IAP changes between versions, so check the official page for your package version before you copy code.
Table of Contents
Unity in app purchase setup looks simple on paper: install a package, add a buy button and wait for the money. In practice, you must configure products in two stores, link your project, choose a catalog, write purchase code that grants items safely and test everything with special accounts.
This guide walks you through the whole process, from planning product IDs to testing on Android and iOS, with a version-labelled code skeleton and a troubleshooting table. Unity’s In-App Purchasing package changed a lot in version 5, and store consoles change too, so we link the official pages and tell you where versions matter. Rules about what you may sell through in-app purchases also differ by store and region, so read each store’s policies before you plan your shop.
Unity In App Purchase Setup: The Big Picture
Think of the setup as three parts that must agree with each other.
| Place | What you do there | What must match |
|---|---|---|
| Unity project | Install the IAP package, define the catalog, write the purchase code | Product IDs in the catalog |
| Google Play Console | Create and activate in-app products, add license testers | The same product IDs |
| App Store Connect | Create in-app purchases, accept agreements, create sandbox testers | The same product IDs |
If any ID, agreement or activation step is missing, the store returns no products and your shop stays empty. That is the most common beginner problem, so keep a single product list as your source of truth.
Before You Start: Requirements and Decisions
According to Unity’s IAP setup documentation, you need a project on a supported Unity version (Unity 6.0 or later is recommended, with Unity 2022.3 as the minimum), build support modules for each platform and the In-App Purchasing package version 5.4 or later. If you build for Android on Unity 2022.3, the same page links a troubleshooting note about the required build configuration.
You also need to decide three things before you write code:
- Product types. Consumable items (coins), non-consumable items (remove ads) and subscriptions behave differently.
- Catalog type. A Remote Catalog lets you change products without a new build. A local catalog is fixed in the build.
- Platforms. Android only, or Android and iOS.
If you take over a ready-made project that already contains purchase code, read our Unity game reskin vs remake guide first. You will need to replace product IDs, store accounts and any seller-owned configuration with your own.
Step 1: Plan Your Products and Product IDs
Write your full product list before you touch a console. Use clear, lowercase IDs with underscores, and keep the same ID on every platform whenever possible.
| Product ID (example) | Type | What the player gets |
|---|---|---|
| coins_small | Consumable | A small coin pack |
| coins_large | Consumable | A large coin pack |
| remove_ads | Non-consumable | Ads removed permanently |
| starter_pack | Non-consumable | A one-time bundle |
Google’s rules matter here. Its help page says product IDs must start with a number or lowercase letter and may contain numbers, lowercase letters, underscores and periods, and that you cannot change or reuse a product ID after it is created. Choose names you will not regret.
Step 2: Create Products in Google Play Console
In Play Console, go to Monetize with Play, then Products, and create an in-app product (Google also calls these one-time products, and it is moving products to a newer one-time product model, so your menu may look different). Enter the product ID, name, description and price, then save and activate it. Google’s help page for creating in-app products lists the current steps and ID rules.
A few practical points from Google’s documentation:
- Your app must use Google Play’s billing system, and the Billing Library adds the needed permission in current versions.
- Products must be published or activated before they can be tested.
- Add your test accounts under Settings, then License testing, so they can buy without being charged.
Step 3: Create Products in App Store Connect
In App Store Connect, open your app, find In-App Purchases under Monetization and create each product. Apple’s overview for configuring In-App Purchases explains the product types, including consumable and non-consumable, and says the Account Holder must accept the Paid Apps Agreement before you can offer In-App Purchases. It also notes that changes to product information can take up to an hour to appear in the sandbox, so be patient before you assume something is broken.
Create sandbox tester accounts in App Store Connect under Users and Access, and use them only for testing.
Step 4: Install Unity IAP and Enable the Service
In Unity, open Window, then Package Management, then Package Manager, choose the Unity Registry and install In-App Purchasing (com.unity.purchasing). Then, according to Unity’s setup page:
- Link your project to a cloud project under Services, General Settings, so it gets a Unity Project ID. A project that sells only through native stores with a local catalog can skip this, but its transactions then do not appear in Unity’s IAP revenue reporting.
- Enable In-App Purchases under Services.
- For Google Play, add your Google license key. From IAP 5.4.4, Android builds log a warning until you link the project and add the key.
- Select your environment under Project Settings, Services, Environments.
The same page recommends against anonymous sign-in as your authentication method in production, because an anonymous player loses purchase history when the app is reinstalled or its data is cleared. This applies when you use services that need a signed-in player, such as the Remote Catalog.
Step 5: Define Your Catalog: Remote or Local
| Catalog | Best for | Trade-off |
|---|---|---|
| Remote Catalog | Most projects. Lets you change prices and products without a new build | Needs project linking and a signed-in player |
| Local catalog | Simple projects that sell only through native stores with a fixed list | Changes need a new build |
Unity recommends the Remote Catalog for all projects, but states that a local catalog still works. If you want the simplest path to a first working shop, start with a local catalog built in the IAP Catalog window in the Editor, and move to the Remote Catalog later. Unity also offers Codeless IAP, which lets you add purchase buttons without writing code. Check the Unity documentation to decide whether it fits your project.
How a Purchase Flows From Tap to Confirmation
Understanding the flow prevents most bugs.
- Your game connects to the store and fetches the products.
- The player taps a buy button, and your code asks the store to purchase a product ID.
- The store handles payment and reports a pending order back to your game.
- Your code grants the item and saves it.
- Your code confirms the order so the store can close it.
Unity’s documentation states that you should always confirm orders with Unity IAP, even if you manage entitlements on your own server. For consumable products, Unity IAP prevents the player from buying the same item again until you confirm the previous order.
Step 6: Write the Initialization and Purchase Code
Unity’s documentation says the code differs between package versions: IAP 5.5 and later use one PurchasingController for every store, while IAP 5.4 uses one StoreController for each store. The skeleton below follows the IAP 5.4 style for the default native store and a local catalog. It is a starting point, not a production-complete system. Copy Unity’s current script for your package version, and test everything.
// Unity IAP 5.4 style (StoreController). IAP 5.5 and later use PurchasingController.
// Skeleton only: check Unity's setup page for the script that matches your version.
using UnityEngine;
using UnityEngine.Purchasing;
using UnityEngine.Purchasing.Extension;
public class SimpleIap : MonoBehaviour
{
private StoreController _store;
private async void Start()
{
_store = UnityIAPServices.StoreController();
// Subscribe to events BEFORE connecting, or you can miss early events.
_store.OnStoreDisconnected += d => Debug.LogError($"Store disconnected: {d.message}");
_store.OnProductsFetchFailed += f => Debug.LogError($"Product fetch failed: {f.FailureReason}");
_store.OnProductsFetched += products =>
{
Debug.Log($"{products.Count} products are ready to display.");
_store.FetchPurchases(); // check existing orders after products are available
};
_store.OnPurchasePending += OnPurchasePending;
await _store.Connect();
// Local catalog created in the IAP Catalog window in the Editor.
ProductCatalog catalog = ProductCatalog.LoadDefaultCatalog();
CatalogProvider provider = CodelessCatalogProvider.PopulateCatalogProvider(catalog);
provider.FetchProducts(_store.FetchProductsWithNoRetries, UnityIAPServices.GetDefaultStore());
}
// Call this from your shop button. productId must match your catalog and store IDs.
public void Buy(string productId)
{
_store.PurchaseProduct(productId);
}
private void OnPurchasePending(PendingOrder order)
{
// 1) Grant the item (coins, unlock) and SAVE it.
// 2) Only then confirm the order.
GrantItemsFor(order);
_store.ConfirmPurchase(order);
}
private void GrantItemsFor(PendingOrder order)
{
// Read the purchased products from the order (see the Order API in Unity's docs)
// and update your game data here.
}
private void OnDestroy()
{
if (_store != null)
{
_store.OnPurchasePending -= OnPurchasePending;
}
}
}
Unity’s page adds an important note: the GameObject that holds this script must live as long as your app sells anything, because its handlers fulfill and confirm purchases. If the first scene unloads, call DontDestroyOnLoad on the object or put the script on one that already persists.
Step 7: Grant the Item, Save It and Confirm
Granting is the most sensitive part. If you confirm before you save, a crash can leave the player without the item they paid for. If you grant but never confirm, a consumable cannot be bought again.
For consumables, such as coins, add the amount to the player’s balance and save it. For non-consumables, such as remove ads, store a permanent flag and make sure it survives reinstalls where your platform and account system allow it. Our Unity save system guide explains how to store player data safely, which matters directly for purchases.
Also handle purchases that were left unfinished. Unity recommends fetching existing purchases and handling them before you start new ones. According to its documentation, on Google Play unprocessed purchases can arrive through the pending-order event after you fetch purchases, and on the Apple App Store the pending-order event can fire for unprocessed orders after products are fetched.
Step 8: Test on Android and iOS
Never test with real money. Both stores provide test tools.
Android. Google’s page on testing your Play Billing integration explains that license testers can use test payment methods without being charged. It also notes that the Billing Library is normally blocked for apps that are not signed and uploaded to Google Play, so you test through a test track, and it can take a few hours after publishing before testers see the app. Play Billing Lab is an additional testing tool from Google.
iOS. Use sandbox accounts created in App Store Connect on devices with Developer Mode enabled. Apple says a sandbox account works only for apps that belong to the same Apple Developer Program account, and metadata changes can take up to an hour to appear.
Run this checklist on a real device for each platform.
| Check | Expected result |
|---|---|
| Products load in the shop | Names and prices come from the store |
| Buy a consumable | Pending order arrives, item is granted, order is confirmed |
| Buy the same consumable again | Works after the first order is confirmed |
| Buy a non-consumable | Flag is saved and stays after restarting the app |
| Cancel a purchase | No item is granted |
| Kill the app during a purchase | Item is granted after the next launch if payment succeeded |
| Reinstall the app | Non-consumable access is restored through your restore flow |
Our Unity game QA checklist covers more general testing steps you can combine with this list.
A Hypothetical Example: Coin Packs and a Remove-Ads Purchase
This example is illustrative, not a real project. A small team ships a casual puzzle game with two coin packs and one remove-ads purchase. They list three product IDs, create them in both stores, activate the Google products and wait for Apple’s sandbox to show the new metadata. They install Unity IAP, link the project, add the Google license key and use a local catalog for the first release.
Their shop buttons call one Buy method with the product ID. In the pending-order handler they add coins or set a remove-ads flag, save the data and then confirm the order. They test with license testers and sandbox accounts, then ship. Later they move to the Remote Catalog so they can change offers without a new build. If you want to see Unity mobile projects built by our team, you can browse our Circuit Car Racing Unity source code project and our Football Simulation 2024 Unity project as examples of our work. We do not claim these projects include in-app purchases.
Troubleshooting Your Unity In App Purchase Setup
| Symptom | Likely cause | What to try |
|---|---|---|
| No products returned | Product ID mismatch, inactive product, missing agreement or store propagation delay | Compare IDs, activate the product, check agreements, wait and retry |
| Buy does nothing | Store not connected or products not fetched yet | Wait for connection and fetch events before enabling the button |
| Cannot buy a consumable again | The previous order was never confirmed | Confirm the order after granting the item |
| Works in a local build but not on Google Play | The app is not signed and uploaded for Billing | Use a test track and a license tester account |
| Android build warning about verification | Project not linked or Google license key missing | Link the cloud project and add the key |
| Compile errors from tutorial code | Code was written for another IAP version | Use the script for your package version |
Common Mistakes in Unity In App Purchase Setup
- Product IDs that do not match across the catalog and both stores.
- Forgetting to activate products in Play Console or to accept agreements in App Store Connect.
- Confirming before saving, which can lose the player’s item after a crash.
- Never confirming consumables, which blocks repeat purchases.
- Using anonymous sign-in in production when purchase history matters.
- Testing with real accounts instead of license testers and sandbox accounts.
- Hiding the restore path for non-consumables.
- Copying code from old tutorials that target a different IAP version.
- Ignoring cost and time. Shops add design, coding and testing work, as we explain in our guide to the cost to make a mobile game in Unity.
Designing the Shop Screen
A technical setup alone does not sell items. A clear shop screen shows what each pack gives and keeps important buttons large enough to press. Our guide to mobile game UI/UX design best practices covers readable layouts, and you can combine purchases with ads, as described in our guide to adding AdMob to a Unity game.
Conclusion
A reliable Unity in app purchase setup means keeping three places in agreement: your Unity catalog, Google Play Console and App Store Connect. Plan your product IDs, create and activate products, install the correct IAP version, grant items safely, confirm every order and test with license testers and sandbox accounts. Check the official pages again before each release, because stores and packages change.
At GamePro Studio, we build Unity games, 3D art and game UI/UX for mobile, PC and VR. If you need help with your Unity in app purchase setup or with planning monetization, you can start with our Unity game developer hiring service.
Frequently Asked Questions
Do I need Unity Gaming Services to use Unity IAP?
Not always. Unity’s documentation says a project that sells only through native stores with a local catalog can skip linking a cloud project, but then its transactions do not appear in Unity’s IAP revenue reporting. The Remote Catalog and some other features need project linking and a signed-in player.
What is the difference between consumable and non-consumable products?
A consumable is used once and can be bought again, such as a coin pack. A non-consumable is bought once and stays, such as removing ads. Apple and Google both use these basic types, and your granting logic should match each type.
Do I need to upgrade from Unity IAP version 4 to version 5?
Unity has a migration guide, and version 5 changed how initialization and purchases work, including a move to StoreKit 2 on Apple platforms. If you start a new project, use the current version. If you maintain an older project, read Unity’s upgrade guide before you change anything.
Do I need receipt validation?
It depends on the value of what you sell and your risk. Unity IAP supports verifying transactions, and Unity’s documentation has a separate page on receipt validation. For high-value items or competitive games, consider server-side checks, and ask a security professional if needed.
Why do my Android purchases fail in a local build?
Google states that the Play Billing Library is normally blocked for apps that are not signed and uploaded to Google Play. Use a test track and a license tester account to test purchases.