Skip to main content

In App Purchases


In App Purchase integration is optional.


This asset makes use of Unity IAP and adds a very basic implementation for in-app purchases. If you would like to look into a fully featured shop system with real money and virtual currency purchases, please have a look at my Simple IAP System asset on the Unity Asset Store.

In order to integrate the built-in billing scripts, download the latest In App Purchasing package from the Package Manager and add the UNITY_IAP define to Scripting Define Symbols under Edit > Project Settings > Player > Script Compilation and your desired target platform.


For in-app purchases to work, you must first create an app in your respective App Store account and create in-app products there. Note that depending on the App Store you are deploying to, certain limitations apply when testing in-app purchases. For example, Google Play requires your app to be submitted and live as alpha/beta version (not draft). With your app and products created in the App Store, open the Intro scene and have a look at the IAPProduct shop items in the inspector. They have an identifier and type defined in there. This should be your unique product identifier and type used when creating your products on the App Store. For the products you created in the App Store, also enable the Buyable checkbox so they are correctly initialized with Unity IAP.


You will also notice that when opening the shop window on iOS, there is an additional button at the top (highlighted in the following screenshot). This button handles restoring purchases, because as per Apple requirements, your app would get rejected without having it.


The UnityIAPManager component handles initiating and processing of in-app purchases. If you are using shop entries, like with the IAPProducts showcased in this asset, you already have a buy button linked to them in the UI. If you would like to initiate a purchase directly via code instead, you can do so by calling UnityIAPManager.PurchaseProduct(). In this case you will have to add the product identifier to the Purchasing builder in its Start() method manually though. To make in app purchase storage more secure and not allowing clients to manipulate their game data locally, you can enable the Encryptor functionality in the Intro scene, located under the "Managers" game object.

Server-Side Receipt Validation

Never trust the client! Validating in app purchases locally, or even not validating receipts at all introduce a massive security risk to your app, making it easy for hackers to unlock IAPs for free. Being the most secure validation method, I am offering a platform for receipt validation, without requiring your own servers! You have two options to integrate the Receipt Validator service into your app:

  • By using Simple IAP System, which comes pre-integrated with the service. See this guide on how to integrate Simple IAP System with this asset first. Then follow the documentation shipped in the package regarding Receipt Validator Service integration.
  • By adding the separate Receipt Validator asset to your project. Please see this guide on how to get started with the Receipt Validator. No code required!