Table of Contents

OSL IAP Client

OSL IAP Client connects Unity IAP v5 pending orders to Apple/Google backend verification before rewards are granted. It persists unresolved receipts across app restarts and uses the included .NET 8 starter's transaction records to reduce duplicate rewards.

Overview

Use this package when a client purchase callback is not enough evidence to grant currency, items, or subscription access. The client queues purchase data, sends it to your backend, and follows explicit grant and confirmation flags returned after provider verification.

Features

  • Apple App Store and Google Play verification before reward delivery
  • Persistent osl_iap_pending_queue.json recovery after temporary failures or app restart
  • Configurable exponential backoff with 10 attempts by default
  • Backend idempotency that confirms AlreadyProcessed orders without granting twice
  • Product catalog, environment, endpoint, timeout, and retry configuration through IapSetupConfig
  • Included .NET 8 ASP.NET Core starter with SQLite/Dapper persistence

Prerequisites

Package Package ID
Unity 2021.3 LTS minimum; 2021.3.45f2 and 6000.3.12f1 import/compile tested
Unity Purchasing com.unity.purchasing 5.0.0 tested
Unity Services Core com.unity.services.core 1.14.0 tested
Backend .NET 8 SDK/runtime

If either package is missing, runtime IAP functionality is not available.

The backend source is a starter. Configure hosting, HTTPS, secrets, monitoring, account integration, and reward delivery for your project. The default queue limit is 10 attempts; exhausted receipts are reported through OnVerificationFailed, so zero-loss behavior is not guaranteed.

Installation

  1. Search for OSL IAP Client on the Unity Asset Store, or open it directly at Unity Asset Store (OSL IAP Client), then click Add to My Assets.
  2. In Unity, open Window > Package Manager, select Packages: My Assets, locate the package, and click Download then Import.
  3. Wait for Unity to finish script compilation.

Basic Configuration

IapSetupConfig is a ScriptableObject used to configure IAP-related settings for the Unity project.

Create one via the Create Setup Asset button in the Tools > OSL > IAP API Tester window, or by right-clicking in the Project window and selecting Create > OSL > IAP > Setup Config.

Common configuration areas include:

  • Unity Services environment name
  • Product catalog entries
  • Demo user and product IDs for local testing
  • Timeout and retry-related settings
  • Store-specific development options

Scene Setup

  1. Add an empty GameObject to your scene and attach the IapManager component.
  2. Assign your IapSetupConfig asset to the Setup Config slot.
  3. Assign the required component references shown in the Inspector.
  4. Set the current user identifier before starting a purchase flow.

Basic Purchase Example

iapManager.BuyProduct("gold_100");
iapManager.OnRewardGranted += OnItemGranted;

void OnItemGranted(string productId)
{
    // Grant only from this verified event and persist your own reward record.
    Debug.Log($"Verified purchase event received: {productId}");
}

Editor Test Tool

Open the editor tool via Tools > OSL > IAP API Tester to check basic request configuration during development.

Troubleshooting

Symptom Likely cause Action
IAP functionality is unavailable Required Unity packages are missing Install Unity Purchasing and Unity Services Core.
Product cannot be purchased Product ID or catalog setup is incomplete Check the product catalog configured in IapSetupConfig.
Editor tool values look wrong Setup asset has not been assigned or loaded Create or assign the correct IapSetupConfig.
Compile errors after import Missing dependency or assembly reference Resolve Unity package dependencies and recompile.