Delivery Failures still irritating you? Try Out HUAWEI In-App Purchases Right Now!
What Does a Delivery Failure Mean?
A delivery failure refers to a situation where a user does not receive the item they have purchased.
A user purchases a virtual product or service within an app, but the user does not receive the purchased item due to an error (such as network exception or process termination) occurring in data synchronization between the app and the in-app purchases server.
Delivery failures can be damaging to both users and developers, and may lead to your app receiving a one-star rating, or users directly turning away from it. This may in turn have a knock-on effect on potential users, driving them away from your app before even giving it a chance. Clearly, this is something that needs to be avoided.
Common Way of Handling a Delivery Failure
The user claims that they have paid but did not receive the purchased item, and subsequently requests a refund. This will undoubtedly break the user’s trust in your app.
Integrating HUAWEI IAP to Eliminate Delivery Failures
With HUAWEI IAP, you can completely eliminate the chance of a missing delivery occurring.
Your app calls the APIs of HUAWEI IAP to query order information from the HUAWEI IAP server. The server will return orders that are paid but not consumed to your app, which will then redeliver the products based on the query result, and tell the server to update the order status.
You can complete integration by following these instructions:
HUAWEI IAP: Purchase Process
For a purchased consumable, your app will call the consumption API to consume the product. If the API call fails, product delivery will fail. A non-consumable product or subscription service will not experience a delivery failure.
A typical consumable purchasing process:
1. A user initiates a purchase request from your app, which your app then sends to HMS Core (APK).
2. Request a delivery. Verify the signature of purchase data before delivering the requested product. 3. Deliver the product and send the purchase token to your app server. This token can be used to obtain the product delivery status so that you can determine whether to redeliver a product if its consumption fails due to delivery failure.
4. After a product is successfully delivered, call the consumeOwnedPurchaseAPI to consume the product and send a notification to the Huawei IAP server to update its delivery status. purchaseToken is passed in the API call request, and once consumption is complete, the Huawei IAP server resets the product status to available for purchase. The product can then be purchased again.
Besides the consumeOwnedPurchase API provided by the IAP client, your app can also use the API provided by the IAP server for product consumption. For details, please refer to Confirming the Purchase for the Order Service.
How HUAWEI IAP redelivers a product:
With HUAWEI IAP you can redeliver a consumable when a delivery failure occurs because of data synchronization errors (caused by network exception, process termination, or others) between your app and the IAP server. The following figure illustrates the redelivery process.
Your app needs to trigger a redelivery in the following scenarios:
- The app launches.
- Result code -1 (OrderStatusCode. ORDER_STATE_FAILED) is returned for a purchase request.
- Result code 60051 (OrderStatusCode. ORDER_PRODUCT_OWNED) is returned for a purchase request.
Implement the redelivery function as follows:
If this API is successfully called, HUAWEI IAP will return an OwnedPurchasesResult object, which contains the purchase data and signature data of all purchased products that have not being delivered. Use the public key allocated by AppGallery Connect to verify the signature. For more information about the verification method, please refer to Verifying the Signature in the Returned Result.
Each purchase’s data is a character string in JSON format that contains the parameters listed in InAppPurchaseData. You need to parse the purchaseState field from the InAppPurchaseData character string. If purchaseState of a purchase is 0, the purchase is successful and delivery will be performed.
2. Call the consumeOwnedPurchase API to consume a delivered product.
Perform a delivery confirmation for all products queried through the obtainOwnedPurchases API. If a product is already delivered, call the consumeOwnedPurchase API to consume the product and instruct the Huawei IAP server to update the delivery status. Following consumption, the Huawei IAP server resets the product status to available for purchase, allowing the product to be purchased again.
>> For more details, please click:
To learn more, please visit:
>> Reddit to join developer discussions
>> Stack Overflow to solve integration problems
Follow our official account for the latest HMS Core-related news and updates.