目录

When handling an API exception, you need to use the OnFailureListener listener set in the task returned by the API to obtain the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an IapApiException instance object. You can obtain the result code through the getStatusCode() method in the IapApiException instance and obtain the related failure information through the getStatusMessage() method. In some scenarios, for example, when the isEnvReady() API is called and result code ORDER_HWID_NOT_LOGIN (60050) is returned, you can obtain a Status object through the getStatus method of the IapApiException object and use startResolutionForResult(activity, reqCode) of the Status object to open the account sign-in page provided by Huawei.

Example:

  1. task.addOnFailureListener(new OnFailureListener() {
  2.        @Override
  3.        public void onFailure(Exception e) {
  4.            if (e instanceof IapApiException) {
  5.                IapApiException iapApiException = (IapApiException) e;
  6.                Status status = iapApiException.getStatus();
  7.                int returnCode = iapApiException.getStatusCode();
  8.                String returnMsg = iapApiException.getStatusMessage;  
  9.                return;  
  10.            }  
  11.        }
  12. });


Result Code

Value

Description

Solution

OrderStatusCode.ORDER_STATE_SUCCESS

0

Success.

-

OrderStatusCode.ORDER_STATE_FAILED

-1

Common failure result code.

If this error code is returned during the purchase request, you are  advised to use the obtainOwnedPurchases API to check whether the user  has purchased the product.

OrderStatusCode.ORDER_STATE_CANCEL

60000

The payment is canceled by the user.

Record the order ID and execute the payment process when the user  performs the payment operation again.

OrderStatusCode.ORDER_STATE_PARAM_ERROR

60001

Parameter error (including no parameter).

Check whether request parameters are missing and whether the parameter format  is correct.

OrderStatusCode.ORDER_STATE_NET_ERROR

60005

Network connection error.

The app displays a message, asking the user to check the network.

OrderStatusCode.ORDER_VR_UNINSTALL_ERROR

60020

The VR APK is not installed.

Install the VR APK first. This code is returned in the VR payment  scenario.

OrderStatusCode.ORDER_HWID_NOT_LOGIN

60050

The HUAWEI ID is not signed in.

The sign-in scenario needs to be processed. For the payment and isEnvReady  APIs, you can use status to instruct users to sign in. For other APIs,  perform operations as needed.

OrderStatusCode.ORDER_PRODUCT_OWNED

60051

A user failed to purchase a product because the user already owns the  product.

Use the obtainOwnedPurchases API to check whether the user has purchased  the product.

If the user has purchased the in-app product and the product is  consumable, check whether the product has been delivered and consumed through  the consumeOwnedPurchase API. After being consumed, the in-app product  can be purchased next time.

If the product is a non-consumable product or an auto-renewable  subscription, the product cannot be purchased again.

OrderStatusCode.ORDER_PRODUCT_NOT_OWNED

60052

A user failed to consume a product because the user has not owned the  product.

Use the obtainOwnedPurchases API to check whether the user has  purchased the product.

OrderStatusCode.ORDER_PRODUCT_CONSUMED

60053

The product has been consumed and cannot be consumed again.

Use the obtainOwnedPurchaseRecord API to check whether the  product has a consumption record.

OrderStatusCode.ORDER_ACCOUNT_AREA_NOT_SUPPORTED

60054

The country or region of the signed-in HUAWEI ID does not support HUAWEI  IAP.

This result code may be returned when the HUAWEI IAP service is  supported by a user's country or region but there is a service error. In this  case, call related APIs or contact Huawei technical support.

OrderStatusCode.ORDER_HIGH_RISK_OPERATIONS

60056

The user triggers risk control, and the transaction is rejected.

-