Unity IAP Example: Complete In-App Purchase Tutorial

Robert Jul 13, 2026

The Unity In-App Purchasing (IAP) system enables developers to sell digital content within their apps. It's a powerful tool for monetizing games and applications. Let's dive into a Unity IAP example to understand how it works.

Unity Game Engine 🎮⚡ (Complete Learning Guide)
Unity Game Engine 🎮⚡ (Complete Learning Guide)

Unity IAP is compatible with various platforms, including Android, iOS, Windows, and macOS. It supports a range of features such as purchases, consumables, subscriptions, and even Google Play orders. In this article, we'll explore Unity IAP's features and walk through an example of setting up IAP in a Unity project.

Unity Essentials - Unity Connect
Unity Essentials - Unity Connect

Setting Up Unity IAP

Before we dive into an IAP example, let's ensure Unity IAP is set up correctly in your project.

the game has many different levels and colors
the game has many different levels and colors

First, make sure your Unity project is using the latest version of Unity IAP. You can import it via the Unity Package Manager (UPM). Once imported, drag and drop the 'IAP' script onto your canvas in the Unity editor.

Defining Products

game making
game making

Start by defining your products in the Unity IAP dashboard. Products are the digital items or services you want to sell within your app. For each product, you'll specify details like its ID, type (consumable, non-consumable, subscription, or managed product), and pricing.

Once defined, these products are synced with the Unity IAP system and can be purchased within your app. Ensure you've correctly defined products for your project's needs.

Enabling IAP in Your Project

the game is showing an island with palm trees and other items on it, as well as
the game is showing an island with palm trees and other items on it, as well as

After defining your products, navigate to the 'IAP' script in your Unity project. In the Inspector, you'll find options to configure IAP. Set the 'Store Currency' to match your defined products' currency and enable 'Initialize On Start'.

This configuration ensures Unity IAP connects to the appropriate store (Google Play, Apple App Store, or Steam) and initializes the IAP system when your game or app starts.

Implementing IAP in Unity

an aerial view of a city with skyscrapers and buildings in blue, white and grey colors
an aerial view of a city with skyscrapers and buildings in blue, white and grey colors

Now that Unity IAP is set up, let's look at an example of implementing IAP within a Unity project.

For this example, let's assume we're creating a simple mobile game that offers a premium currency for purchase. The currency can be used to unlock new features or purchase in-game items. We'll use Unity IAP to manage these purchases.

Click Objects In Unity - How To Click Objects in Unity 5 | Unity Mouse Tutorial
Click Objects In Unity - How To Click Objects in Unity 5 | Unity Mouse Tutorial
35 FREE Unity 2026 Beta Features & Tools 🎮🚀
35 FREE Unity 2026 Beta Features & Tools 🎮🚀
Unity Tutorial: Enemy AI (Follow and Shoot)
Unity Tutorial: Enemy AI (Follow and Shoot)
Creating A Stylized Waterfall in Unity: Part 2
Creating A Stylized Waterfall in Unity: Part 2
Introduction to Unity: Getting Started – Part 1/2
Introduction to Unity: Getting Started – Part 1/2
an image of a pixel style landscape with rocks and grass
an image of a pixel style landscape with rocks and grass
Lowpoly Style Alpine Woodlands Environment | 3D Landscapes | Unity Asset Store
Lowpoly Style Alpine Woodlands Environment | 3D Landscapes | Unity Asset Store
Unity in UI UX Design Principles
Unity in UI UX Design Principles
𝔾𝕠𝕕𝕦𝕤
𝔾𝕠𝕕𝕦𝕤
Flow Map tutorial with Unity Shader Graph
Flow Map tutorial with Unity Shader Graph
Unity Inventory Tutorial : Pickup on Keypress & Trigger
Unity Inventory Tutorial : Pickup on Keypress & Trigger
Unity 5 Tutorial - Basic Glass with the Standard Shader
Unity 5 Tutorial - Basic Glass with the Standard Shader
an image of a bunch of items that are in the style of video game characters
an image of a bunch of items that are in the style of video game characters
How to Make a Simple Game in Unity 3D
How to Make a Simple Game in Unity 3D
Top 10 most frequently asked questions about game development using Unity
Top 10 most frequently asked questions about game development using Unity
Game Button Pixel Art, Pixel Art Game Button, Pixel Art Game Buttons, Pixel Art Game Menu, Pixel Game Button, 2d Game Pixel Art, Button Sprites, Game Ui Button Design, Pixel Art Game Icons
Game Button Pixel Art, Pixel Art Game Button, Pixel Art Game Buttons, Pixel Art Game Menu, Pixel Game Button, 2d Game Pixel Art, Button Sprites, Game Ui Button Design, Pixel Art Game Icons
two trees are standing next to each other
two trees are standing next to each other
TUTORIAL UNITY 5 - MENU PRINCIPAL (Unity 5.3 ou superior) (UI)
TUTORIAL UNITY 5 - MENU PRINCIPAL (Unity 5.3 ou superior) (UI)
Unity Mobile Joystick Asset
Unity Mobile Joystick Asset
Из пииздыыыы
Из пииздыыыы

Handling Purchases

In Unity, you can handle purchases using the IAPScript's 'PurchaseSuccess' and 'PurchaseFailed' events. Here's a basic example of how you might handle a successful purchase:

```csharp void PurchaseSuccess(Product product) { Debug.Log("Purchase succeeded: " + product.definition.id); // Add purchased currency to the player's inventory or update the game state accordingly } ```

In this script, when a purchase is successful, the 'PurchaseSuccess' event is triggered. The event passes the purchased product's definition, which contains details like the product ID and its metadata. You can use this information to update your game's state or implement additional functionality.

Listing Available Products

To display available products in your Unity UI, you can use the 'ProductList' variable from the IAPScript. Here's an example of how you might list available products in a Unity UI:

```csharp public void ListProducts() { foreach (Product product in iapScript.ProductList) { // Create a UI element for each product and populate it with product details GameObject productObject = Instantiate(productPrefab); productObject.GetComponent().Populate(product); } } ```

In this example, the 'ListProducts' function iterates through the 'ProductList' and instantiates a product UI prefab for each available product. The 'Populate' function is then called to populate the product UI with the product's details.

Restoring Purchases

To restore purchases, use the 'RestorePurchases' function from the IAPScript. This function connected to Google Play and the Apple App Store and restores any previously purchased items. Here's an example of how you might implement restoring purchases in your game:

```csharp частотности"IAPScript"(рcommand="RestorePurchases"); ```

llamarstaticmethod)">"Here, we simply call the 'RestorePurchases' function when the 'Restore purchases' button is clicked. Upon successful restoration, Unity IAP trig