IAP API Reference
Scripting Reference
Namespace: MobileCore.IAPModule
IAPManager Class
The static manager handles all purchase flows and product queries.
Properties
| Property | Description |
|---|---|
IsInitialized | Returns true if the IAP service is connected to the store. |
Methods
| Method | Description |
|---|---|
Initialize(GameObject, IAPManagerInitializer) | Initializes the module manually (usually handled by MainSystem). |
SubscribeOnPurchaseModuleInitted(PrimitiveCallback) | Subscribes to the init event. If already initialized, executes the callback immediately. |
BuyProduct(ProductKeyType) | Initiates a purchase for the product enum. |
RestorePurchases() | Restores transactions (Critical for iOS). |
IsSubscribed(ProductKeyType) | Checks if a subscription is currently active. |
GetProductData(ProductKeyType) | Returns metadata (Price, ISO Code, Title) encapsulated in ProductData. |
GetIAPItem(ProductKeyType) / GetIAPItem(string) | Returns the internal IAPItem definition corresponding to the product key or ID. |
GetProduct(ProductKeyType) | Returns the raw UnityEngine.Purchasing.Product object (Only available when Unity IAP is installed). |
GetProductLocalPriceString(ProductKeyType) | Returns formatted price (e.g. “$4.99”). |
Events
// Successful Purchase
IAPManager.OnPurchaseComplete += (productKey) => {
Debug.Log($"Bought: {productKey}");
};
// Failed Purchase
IAPManager.OnPurchaseFailded += (productKey, reason) => {
Debug.LogError($"Failed: {reason}");
};
// Initialization
IAPManager.OnPurchaseModuleInitted += () => {
Debug.Log("Store Ready");
};
Data Structures
ProductKeyType
An enum you define in the code (usually via Editor) to map to your specific products.
Use ProductKeyType.NoAds for the remove ads functionality.
IAPItem
A configuration class defined in IAPSettings representing a single product’s ID, type, and key mapping.
ProductData
A simple data structure holding the retrieved Title, Description, ISO Currency Code, and decimal Price from the store.
PurchaseFailureReason
Standard Unity IAP failure reasons (UserCancelled, PurchasingUnavailable, etc.).
ProductType
Standard Unity IAP product types (Consumable, NonConsumable, Subscription).