Simple IAP System is our ready-to-use billing solution for the Unity game engine. It comes with the Receipt Validator pre-integrated, which can be enabled on demand. You can find more information about the asset as well as purchase options on our website.
Configure Simple IAP System by following its documentation. The Receipt Validator extension can be added on top, without requiring any specific settings during Plugin Setup. The Receipt Validator backend is contacted via the ReceiptValidatorServer component. As an optimization, the ReceiptValidatorServer validates the receipt locally before sending it to the remote backend.
- Configure Unity IAP's local validation under
Services > In-App Purchasing > Receipt Validation Obfuscator
The Google Play Public Key can be found in your Google Play Developer Console under
Your App > Monetisation setup
Click the Obfuscate button to generate your Google Play and Apple Tangle files
- On the supported target platforms (Android/iOS), add the
Project Settings > Player > Scripting Define Symbols
- Add the ReceiptValidatorServer component to the IAPManager prefab
You can then access the ReceiptValidatorServer component programmatically using
|Enter your |
You do not want to enter the
|If, how and when to request user inventory. As noted in the Inspector, leave it on |
Inventory Request Type:
The ReceiptValidatorServer component consists of the following public methods and events:
|Fired when Inventory is available.|
|Fired after request to server completes, for both failed and successful purchases.|
|Request user inventory from server. Called automatically after Unity IAP initalization.|
|Returns Dictionary with ProductID <-> PurchaseResponse items of the server's user inventory. Could be empty if RequestInventory has not been called yet.|
|Validates a product purchase locally then remotely. There is no need to call this manually, it is called automatically on an IAPManager purchase callback.|
|ReceiptValidator interface override that determines supported platforms. There is no need to call this manually.|
|Re-Validates each owned product. There is no need to call this manually. If you wish to initiate a restore, call IAPManager.RestoreTransactions() instead.|
|Returns whether local validation is supported on this platform.|
|Returns whether remote validation is supported on this platform.|
As done in the basic Unity sample and in compliance with the REST API on the GetUser call, RequestInventory calls are limited to one request every 30 minutes by default. At best, user inventory should be accessed from memory throughout the session after it has been received, using
GetInventory. Note that this is designed for getting the raw inventory data for custom processing. Simple IAP System updates its DBManager database of products automatically, so if you would like to check whether a product is purchased or not, you can also call
You could consider enabling
Memory Only on the DBManager if your app does not provide virtual currency or virtual products. In an enabled state, nothing is stored locally and owned products are only retrieved from the Receipt Validator inventory and stored in memory, effectively requiring internet access on app launch for the
RequestInventory call. This would ensure users are not able to tamper with game files on their device. If you offer any virtual currency or virtual products,
Memory Only should be disabled as otherwise local progress is lost.
Unity IAP has its own periodic retry mechanism when unable to initialize on the first try, for example on bad or no network connectivity. Since ReceiptValidatorServer's RequestInventory method is hooked on Unity IAP, it is fired off automatically once initialization completes successfully. This means that you do not have to build your own retry method continuously calling RequestInventory.