Skip to main content

Server-Side Receipt Validation

This asset comes with server-side receipt validation pre-integrated, which can be enabled on demand. The Receipt Validator Service offers a FREE plan, please see the Receipt Validator website for more details.

Requirements:

  • You have created a free account on the Receipt Validator Service
  • You have created a new app in the Receipt Validator dashboard
  • You should have set up your app and products on the App Store(s) (see our store guides)

Project Setup

The Receipt Validator backend is contacted via the ReceiptValidatorServer component.

Because the ReceiptValidatorServer uses both local and server-side validation, please follow the steps mentioned in Client-Side Receipt Validation files for enabling local validation with Unity IAP.

  • Instead of client validation, add the ReceiptValidatorServer component to the IAPManager prefab in your Project panel

RV-Setup010

info

You can now access the ReceiptValidatorServer component programmatically using IAPManager.GetInstance().GetComponent<ReceiptValidatorServer>().

Usage

Select the IAPManager prefab in your Project panel. On its ReceiptValidatorServer component, enter your own App ID from the Receipt Validator Service.

PAID PLANS: If you want to make use of the User Inventory feature, do not enter any User ID in the inspector. Instead, update it at runtime with a unique user identifier returned from your custom authentication system. For this to work, disable automatic initialization on the IAPManager and call IAPManager.GetInstance().Initialize() after user login and setting the User ID. Select the appropriate Inventory Request Type, usually Once.

Testing

Since the Unity Editor does not have any connection to App Stores, you are not able to test purchases using it. You have to test on a real device that is actually able to receive valid receipts and transactions from the App Stores.

When running on a real device you will be able to fully test all purchase validation workflows. If you make use of the Receipt Validator's User Inventory feature, active subscriptions and non-consumable products will be returned for that user in subsequent app launches as well. Enable Development Build and watch the log output to see debug messages and responses from the ReceiptValidatorServer component.

Additional Notes

If you make use of User Inventory, at best, it should be accessed from memory throughout the session after it has been received, using ReceiptValidatorServer's GetInventory() method. 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 DBManager.IsPurchased(string productID).

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.

note

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().

Support

This extension was specifically designed to be used in combination with the Receipt Validator Service. For integration assistance or questions about the Service, please open a ticket at the Support tab in the Receipt Validator dashboard.