Guides & References
A full guide and reference page for in-app purchases in the Unity Purchase provides the necessary kits and services for a seamless integration.
Unity's In-App Purchase (IAP) system allows developers to sell a variety of items directly within their games. This can include premium content, virtual goods, and subscriptions. Here's a brief guide on how to set up and use Unity IAP:
Understanding Unity IAP
Unity IAP lets you integrate in-app purchases into your games to sell digital goods or services.
It supports various platforms, including Android and iOS.
How to Login or Sign In
To use Unity Purchases, you need a Unity account. If you don't have one, you can create it at Unity's official website.
Sign Up or Log In:
Visit Unity ID to create a new account or log into an existing one.
Fill in your details or sign in with your credentials.
Access the Unity Dashboard:
Once logged in, access the Unity Dashboard.
Navigate to the Projects section to manage your existing projects or create a new one.
Enabling Unity Purchases Service
To enable the Unity Purchases service for your project:
Open Your Project in Unity Editor:
Launch Unity Editor(Unity Hub) and open your project.
Go to Services Window:
Select the Purchases Service:
Link or Create a Project ID:
If not linked, link your Unity project with a Unity Project ID or create a new one. (Do the Same thing for Organizations)
Enable the Service:
Toggle the switch to enable(ON) the Purchases service for your project.
Using Unity Purchases in Unity
To use Unity Purchases in your Unity project:
If doesn't Install the Packages, Install the Unity IAP and UDP Package:
Open the Unity Package Manager (
Window
>Package Manager
).Find and install the
In App Purchasing
package.Find and install the
Unity Distribution Portal
package.
Configure In-App Purchases:
Access the IAP Catalog in the Services window.
Define your products (e.g., consumables, non-consumables, subscriptions).
You can add products by writing code or go to the
Service > In App Purchasing > IAP Catalog
and add it.
Change the default store to "Unity Distribution Portal".
Activate the Huawei Account kit and In-App Purchases.
Adding below codes in HMSEditorUtils.cs file for running Unity Purchase
CODE:
Implementing Code:
In your Unity scripts, use the
UnityEngine.Purchasing
namespace.Set up a purchasing system, initialize it, and handle purchase events.
Look at codes at these links;
Testing Purchases:
Unity provides options for testing IAPs on test mobile devices(Do not use Editor with Huawei Services).
Ensure to test thoroughly before deploying.
Build and Deploy:
Build your project for the desired platform once everything is set up and tested.
Deploy it to the respective any stores.
Conclusion
Unity Purchases simplifies the implementation of in-app purchases, offering a unified API for different platforms. Remember to follow platform-specific guidelines for IAPs when deploying to various stores.
Sources🌐
Last updated