Documentation

Support

In-App Purchasing

In-App Purchasing

Codeless IAP

Use Codeless IAP to configure and test in-app purchases with minimal scripting, streamlining setup across supported stores.
Read time 2 minutesLast updated 5 hours ago

Codeless IAP allows you to implement in-app purchases using the Unity Editor interface with minimal scripting. It handles the underlying transaction process, so that you can create a functional in-game store without writing complex purchasing code. When a player taps an IAP button, Unity initiates the purchase flow for the associated product, communicates with the app store, and returns the result.

Set up Codeless IAP

To implement Codeless IAP in your project, complete the following steps in the Editor:
  1. Add IAP buttons to your scene: Create and configure IAP buttons in the Editor to start purchases or restore transactions. Refer to Codeless IAP button configuration for details.
  2. Define products in the IAP Catalog: List all products available for purchase in the Editor's product catalog: List all products available for purchase in the Editor's product catalog. Refer to Define your products for details.
  3. Set up automatic initialization: Configure Unity IAP to initialize automatically so the purchasing system is ready when your game starts.
    • In the IAP Catalog window, select Automatically initialize UnityIAPServices at the bottom of the window.

Purchase fulfillment

After a successful purchase, Unity calls your purchase fulfillment script to deliver the purchased content to the player.
  1. In the Scene view, select the IAP Button.
  2. In the Inspector, open the Product ID drop-down and select the product you want to link.
  3. Create a function that handles purchase fulfillment, or import an Asset that provides this functionality. Refer to the code sample below.
  4. Apply your purchase fulfillment script to a GameObject as a component.
  5. With the IAP Button selected, go to the IAP Button (Script) component in the Inspector.
  6. In the On Purchase Pending (Product) list, select + to add a new event.
  7. Drag the GameObject with the purchase fulfillment script into the event field, then select your fulfillment function from the drop-down menu.
The following code sample checks if the correct product was purchased and grants it to the player.
public void ExampleProductPurchased(Product product){ // Check if the correct product has been passed if (product.definition.id == "com.example.product") { // Grant product to player } else { // Handle unexpected product }}