What Can I Do If –1 Is Returned by the consumeOwnedPurchase API?
Symptom:
After I have integrated HUAWEI In-App Purchases (IAP), my app calls createPurchaseIntent to successfully purchase a product, and then calls consumeOwnedPurchase to consume the product after successful delivery. However, the product consumption fails, and result code –1 is returned.
Analysis
- Refer to the description of the result code in the official documentation of HUAWEI IAP:
I called the API in the description, and then the API returned the order information. That is, the product in this order had not been consumed, and I needed to call an API to consume the product, based on the official documentation.
The description here indicates that if result code –1 is returned when I call the payment API, I need to check whether the order is missed. If so, the product needs to be delivered again.
- Search for the keyword hms_pay in logs to check for the cause.
As I have communicated with Huawei technical support, the following information in red is the key to solve the problem:
It is found that the field length exceeds the upper limit.
Summary
If HUAWEI IAP-related result codes are returned, you can first refer to the result code description and then search for the hms_pay keyword in logs to view relevant information for fault locating. Thanks for your attention.