The IAP Service provides a convenient in-app payment experience for apps. Through in-app payment, users can purchase various types of virtual goods in applications, including consumable goods, non-consumable goods, and subscription goods.
For more information, you can click the following link to reach directly:
To integrate with IAP service:
Open the OpenHarmonySDKKitsSettings window.
Fill in the common configuration include client_id, app_id, Bundle Name.
Check the IAP Kit.
Add the information of products and choose correct product type which should be added in AppGallery.
Click on Open Scene to open the demo scene with the interface integrated, and operate each function in the scene.
If you want the application to integrate this service when it starts, please check Init On Start.
To open the IAP Service demo scene in the Tuanjie Editor: OpenHarmonySDKKits > OpenHarmonySDKKitsSettings > IAP Kit > Open Scene.
The IAP scene is divided into two parts: Common query and Purchase & Subscriptions process.
The functions of Common query and their calling interfaces are as follows:
| Area | Description |
|---|---|
| Verify Pay Env | Click to Send a queryEnvironmentStatus request to IAP Kit to determine whether the service location of the user’s currently logged-in account is in a country/region that IAP Kit supports settlement. |
| Query Subscription Items | Click to call queryProducts to obtain product information configured on AppGallery Connect and return a list of subscribed product information Products, including product price, name, description, etc. |
| Query Consumable Items | Click to call queryProducts to obtain product information configured on AppGallery Connect and return a list of consumable product information Products, including product price, name, description, etc. |
| Query Unconsumable Items | Click to call queryProducts to obtain product information configured on AppGallery Connect and return a list of unconsumable product information Products, including product price, name, description, etc. |
| Log Info | The relevant log will be displayed here. |
Purchasing and subscribing are two complete processes that require calling a series of interfaces. It is recommended to click the buttons in order.
The functions ofPurchase & Subscriptions process and their calling interfaces are as follows:
| Area | Description |
|---|---|
| Create Purchase | Click to display a window contains the consumable and non-consumable items that can be purchased. Then send a createPurchase request to pull up the IAP Kit cashier. |
| Create Subscription | Click to display a window contains the subscription items that can be subscribe. Then send a createPurchase request to pull up the IAP Kit cashier. |
| Check Purchase/Subscription Info | Click to call queryPurchases to view the results of this purchase. |
| Finish Purchase/Subscription | Click to send FinishPurchase request to confirm shipment, notify the IAP server to update the product’s shipment status, and complete the purchase process. |
To run the demo on the OpenHarmony devices:
client_id, app_id and Bundle Name have been filled correctly. Make sure IAP Kit have been checked.Product List has been filled correctly.