HMS Core in-App Payment (IAPS) offers a convenient in-app payment experience and easy access process. After the developer’s app integrates with the IAP SDK, it invokes the IAP SDK interface and activates the IAP checkout to make in-app payments. With in-app payment services, users can purchase various types of virtual goods within the app, including one-time items (both consumable and non-consumable) and subscription items. In-app payment service supports client and server development. For details, please refer to the following official documents:

Developer.huawei.com/consumer/cn…

On a daily basis, we receive comments from developers asking us frequently asked questions about IAP integration, so here are a few that we can share and summarize for other developers who have similar problems

  1. Com. Huawei. Results. The tasks. The use of the Task.

Task is a basic abstract class of the underlying framework of the HMS Core SDK. It implements the relevant abstract methods in the Task class. For example, adding one or more listeners, which are called when the task completes successfully, and adding more listeners, which are called in the order in which they were added, are executed on the main thread.

Because it is already integrated into the project Gradle package, it can be used directly without the need to recreate the declaration. Gradle = gradle = gradle = gradle = gradle

Developers can also refer to the following documentation for troubleshooting:

Developer.huawei.com/consumer/cn…

  1. Is there no accountFlag in the InAppPurchaseData parameter normal?

There is no accountFlag problem in the InAppPurchaseData parameter. According to the reference API of InAppPurchaseData in the official document of in-app payment service:

Developer.huawei.com/consumer/cn…

The InAppPurchaseData JSON type is used to store user purchase information, including consumable, non-consumable, and subscription items. The parameter accountFlag is a non-mandatory and optional field. This value is returned only when the AppTouch application is used.

  1. Document createPurchaseIntentWithPrice parameters (Exception e) of the onFailure (e instanceof IapApiException).

First, you need to confirm the device and integration environment information (preferably updated to the latest version) : HMS Core version number, integrated SDK version number, whether the device is a mobile phone or a smart screen.

The developer can retrieve a Status object from the IapApiException returned from the request interface. The Status object contains the IAP page. An application can start the protocol page using the startResolutionForResult method of Status.

There may also be several reasons for this problem:

(1) The interface fails to be obtained due to a network exception.

(2) Whether IapApiException is correctly referenced.

(3) Whether there is a popup window during payment. If there is no popup window, you need to enable the “Background popup interface” permission of the device. The Settings are as follows: Find the HMS Core application details page — Rights Management — “Background popup interface” — select “Always Allow” and re-test.

(4) If it is a code problem, please refer to the official Demo implementation and test of developer Union in detail. Demo download address:

Developer.huawei.com/consumer/cn…

  1. The application server verifies that the token purchase fails. Procedure

First, the message “Failed to verify token purchase” is displayed. Check whether the OBTAINED AT is an application-level AT by referring to each step in obtaining an application-level AT. Obtain the application level AT address document:

Developer.huawei.com/consumer/cn…

Then encapsulate the obtained application-level AT and reconstruct the authorization in the request header. For details, please refer to part of the documentation of the common instructions:

Developer.huawei.com/consumer/cn…

For more application payment service in details, please refer to: developer.huawei.com/consumer/cn…

Huawei Developer Alliance official website obtain development guidance documents to participate in developer discussions. Download demo and sample code from Reddit. Visit Github to resolve integration problems

For more details >>

Visit the official website of Huawei Developer Alliance to obtain the development guide. The open-source repositories of Huawei mobile services are GitHub and Gitee

Follow us for updates on HMS Core