Guide to Using and Understanding Huawei InAppPurchase’s Demo Scene in Unity

Alihan98ersoy
Huawei Developers
Published in
3 min readNov 1, 2023

--

The MainMenu Scene

Introduction

In this article, I aim to help you understand the in-app purchase better and easily add it to your game by explaining how you can use our second sample scene, which consists of two demo scenes, the Main Menu, and the Store scene, that we created for In-app purchase and how it works.

You can access demo scenes from the “Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/” folder in version v2.3.4 of the plugin and above versions.

Steps to Use the Demo Scene:

  1. Complete the quick start steps.
  2. Activate the account kit and IAP from “kit settings”.
  3. Make sure that IAP and Account Kit are activated in the AppGallery Connect console. (If not, do so and refresh the agconnect-services.json file.)
  4. Add these products to the console with the same productIDs.

a. Product ID: coin100 — Type: consumable
b. Product ID: coin1000 — Type: consumable
c. Product ID: removeAds — Type: non-consumable
D. Product ID: premium — Type: subscription (1 week)

5. Add these products you added to the console to the window we prepared for IAP. Unity > Huawei > Kit Settings > IAP. Then click the “create constant classes” button.
6. Add the scenes to the scenes section in BuildSettings.

BuildSettings

7. Disable the Initialize On Start.

Unity > Huawei > Kit Settings > IAP

Understanding Code Piece by Piece

SignIn:

SignIn

Preliminary Procedures Required for In-app Purchase:

Using IAP — Store Scene:

Store Scene
StoreManager In-app purchases

--

--