[Huawei Developers] Mike-mei:
HUAWEI In-App Purchases (IAP) implements convenient in-app purchasing via either the service's SDK or its server.

Features and integration details of IAP are well illustrated in its official documents. I've used the service extensively for my apps and kept track of its issues (both from myself and other developers). Following on from my previous article that looked at the sandbox testing issue, this article will present FAQs related to other IAP aspects.

Question 1: The callback request of IAP is empty, containing no valid user information. Why?​

Question details:​

I integrated my app with HMS Core SDK 6.4.0.301 and IAP SDK 4.0. Users paid for a yearly subscription in the app, but the backend of my app didn't automatically deliver the subscription to users. I went to the order report in AppGallery Connect to redeliver the subscription to users, but the callback result was invalid.

To troubleshoot this issue, I used the test API. In the printed callback request of IAP, I discovered that the request body was an empty string that contained no valid user information. So I checked the official IAP document, which says that an app using IAP SDK 4.0 will not receive the payment success callback, so I'm not sure whether it is normal that my app received an empty callback.

Also, the subscription callback API of the IAP server would return 200 even upon an exception. The reason, I assume, was that the IAP server believed that my app had delivered the subscription to users. In this case, can product redelivery be triggered after the app is restarted?

Answer:​

The official FAQs section for IAP illustrates what will happen after the redelivery button in the AppGallery Connect order report is clicked.

View attachment 5873453

Normally, there will be no callback upon payment success. However, a callback containing an empty request body is actually not an issue, which can be ignored.

The redelivery process of the IAP SDK applies only to consumables, which needs to be triggered in the app integrated with the SDK in some specified scenarios, such as app startup. When an exception occurs during the process, an error code (like -1, 60051, or 1) will be returned, which you need to deal with according to the error description. More details can be found here.

As for subscriptions, notifications of key events are used. Click here for more details.

In no scenario would the IAP server send 200 upon an exception to your app server because the IAP server believes that your app has delivered the subscription to users. If you are not sure why your app server receives 200, you can submit a ticket online with the order number corresponding to the subscription in question for the technical support of IAP to look into.

Question 2: I submitted settlement sheets in September 2022, and the sheets have been stuck in the In payment state since then. However, the corresponding earnings have not been sent to my bank account. Why?​

Answer:​

View attachment 5873455

The official Settlement document says that after a settlement sheet is submitted, the sheet will enter the In payment state. To receive the earnings, you may need to issue an invoice, according to where your app is released.

Specifically speaking, you are not required to issue an invoice if your products are distributed in countries or regions outside the Chinese mainland, and you have signed an online agreement with Huawei. According to Exhibit C of the HUAWEI Developers Merchant Service Agreement, Huawei will perform self-billing. To view and download invoices issued by Huawei, sign in to the console of HUAWEI Developers and go to My accounts > Credited. Find your settlement sheet and click Invoice.

If your app is released in the Chinese mainland, issue an invoice according to the official instructions.

Multiple settlements can be combined for invoicing in a single application. Such settlement sheets must have the same contract, service type, currency, signing entity, and prepayment term. It's also worth noting that the invoice amount must be the same as the amount sum of the combined settlement sheets.

For details about how to perform invoicing and other settlement-related instructions, go to the Self-service Settlement Guide.

Question 3: The official IAP document noted that it would gradually end support for the old domain names of AppGallery sites, TLS of earlier versions, and cipher suites. Are there any detailed instructions on how to replace the old domain names, TLS versions, or cipher suites with new ones?​

Question details:​

To ensure higher security and reliability for apps, IAP has changed its support for the domain names of AppGallery sites, TLS versions, and cipher suites. Specifically speaking, from April 2023, IAP will no longer support TLS earlier than 1.2 version or cipher suites that are not specified. The support for old domain names of AppGallery sites will be canceled in the near future.

View attachment 5873457

Answer:​

There is no guide document illustrating how to replace the old TLS versions or cipher suites, but the official IAP demo can serve as a reference.

View attachment 5873459

The sample code of the API for verifying the purchase token of the order service is used as an example here, to show how to replace the old domain name. For example, for an app released to AppGallery in the China site, replace

https://orders-at-dre.iap.dbankcloud.com

with

https://orders-drcn.iap.cloud.huawei.com.cn

, which is the domain name of this site.

View attachment 5873461

View attachment 5873463

Click here for more information.

Question 4: I noticed that there is an expirationDate field in the subscription purchase data of users, which is returned by IAP. Is the time indicated by this field the same as the time when IAP bills the user account for renewing a subscription near the end of the current billing cycle?​

Question details:​

A user purchased a yearly subscription on December 5, 2021, and IAP returned the expirationDate string, which is a timestamp. On December 4, 2022, IAP automatically billed the user account for subscription renewal. However, the time indicated by the timestamp is December 8, 2022. My question is: Will IAP bill a user in advance for subscription renewal? If not, does this mean that the expirationDate time is not the same as the time of billing for subscription renewal? Which field should I refer to if I need to know the billing time for subscription renewal?

Answer:​

In short, the time indicated by the expirationDate field is not the same as the billing time for subscription renewal.

Below is the official description of the expirationDate field in the InAppPurchaseData class.

View attachment 5873469

In other words, this field indicates the time when a subscription expires.

According to the billing rule of IAP for a subscription, IAP tries to bill a user 24 hours before a subscription renewal. Therefore, it is normal that IAP billed the user account on December 4, 2022, which is within 24 hours before the current billing cycle ended (December 5, 2022). If billing fails, IAP will repeatedly attempt to bill the user within a specific duration. Once the maximum number of failed attempts has been reached, IAP will cease billing.

On top of this, the IAP server does not return the billing time for subscription renewal or provide any accurate billing time. Instead, the server provides the subscription renewal time that may be slightly earlier than the billing time.

If you find the difference between the subscription renewal time and the time indicated by expirationDate is too big, you can submit a ticket online with the subscription order number or subscription ID for troubleshooting.

References​

Home page of HUAWEI IAP

Development Guide of HUAWEI IAP