IAPManager
IAPManager uses Unity IAP 5.4.1 StoreController APIs for store connection, product lookup, purchase, pending-order retry, and restoration. In player builds, it confirms an order only after its reward has been persisted.
com.unity.purchasing 5.4.1 is an AchEngine dependency, and AchManagerInstaller registers IAPManager automatically.
Quick setup
Product IDs must exactly match Google Play Console or App Store Connect. For player builds, configure products and a receipt validator before initialization.
Editor Fake Store testing
In the Unity Editor, IAPManager explicitly selects Unity IAP's fake store.
Only in the Editor, a Fake Store order is automatically confirmed when both
ReceiptValidator and PurchaseProcessor are unset. This lets you test purchase
buttons, completion events, and popup flow without making a real payment or
calling a backend.
This behavior is compiled only under UNITY_EDITOR. Android, iOS, and other
player builds still require a receipt validator or fulfillment processor before
a purchase can start. The editor fake order is not granted as a real purchase.
The Full Sample PurchasePopup also enables its purchase buttons without a
validator in the Editor. Assign the game-specific server validator to the
Receipt Validator field for real builds.
Implement IIAPReceiptValidator in the game project. Authenticate the player, send platform transaction data to the backend, and persist rewards idempotently on the server.
Purchase requests
PurchaseAsync returns only after store purchase, server fulfillment, and order confirmation are complete. In player builds, without a validator or processor, it does not open the purchase dialog. The Editor uses the Fake Store flow described above.
Server receipt validation
Send the transaction ID, Unity receipt, Apple StoreKit 2 JWS, app-account token, and product list to the server. The server should use the transaction ID as an idempotency key and return matching transactionId, isValid, and isFulfilled values.
Retry unfulfilled orders in the current session or re-read the store purchase list:
Restore and events
Initialize() reads existing purchases after product discovery. Update non-consumable and subscription ownership from PurchaseRestored. Apple apps should expose a user-facing restore button:
API
Always make fulfillment idempotent by transaction ID. A validator or processor failure leaves the order unconfirmed so it can be retried.