We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All

Documents from this version have been archived, and will not continue to be maintained. Please use the latest version.

HMS Core GuidesIn-App PurchasesVersion Change History

Version Change History

IAP SDK 4.0.4 (2020.05.26)

Latest release: 4.0.4.301

New Features

1. Added the startIapActivity API in IapClient. You can use this API to open the in-app payment pages, including the subscription editing page and subscription management page.

Note:

This API is used in HMS Core IAP SDK 4.0.4.300 and later versions to replace the subscription management page redirection method provided in earlier versions.

The following is an example:

Collapse
Word wrap
Dark theme
Copy code
  1. // Redirect to the subscription management page.
  2. StartIapActivityReq req = new StartIapActivityReq();
  3. req.setType(StartIapActivityReq.TYPE_SUBSCRIBE_MANAGER_ACTIVITY);
  4. final Activity activity = getActivity();
  5. IapClient mClient = Iap.getIapClient(activity);
  6. Task<StartIapActivityResult> task = mClient.startIapActivity(req);
  7. task.addOnSuccessListener(new OnSuccessListener<StartIapActivityResult>() {
  8.    @Override
  9.    public void onSuccess(StartIapActivityResult result) {
  10.        Log.i("startIapActivity", "onSuccess");
  11.        if (result != null) {
  12.            result.startActivity(activity);
  13.        }
  14.    }
  15. }).addOnFailureListener(new OnFailureListener() {
  16.    @Override
  17.    public void onFailure(Exception e) {
  18.        Log.e("startIapActivity", "onFailure");
  19.    }
  20. });
  21. // Redirect to the subscription editing page.
  22. StartIapActivityReq req = new StartIapActivityReq();
  23. req.setSubscribeProductId("XXX");
  24. req.setType(StartIapActivityReq.TYPE_SUBSCRIBE_EDIT_ACTIVITY);
  25. final Activity activity = getActivity();
  26. IapClient mClient = Iap.getIapClient(activity);
  27. Task<StartIapActivityResult> task = mClient.startIapActivity(req);
  28. task.addOnSuccessListener(new OnSuccessListener<StartIapActivityResult>() {
  29.    @Override
  30.    public void onSuccess(StartIapActivityResult result) {
  31.        Log.i("startIapActivity", "onSuccess");
  32.        if (result != null) {
  33.            result.startActivity(activity);
  34.        }
  35.    }
  36. }).addOnFailureListener(new OnFailureListener() {
  37.    @Override
  38.    public void onFailure(Exception e) {
  39.        Log.e("startIapActivity", "onFailure");
  40.    }
  41. });

2. Added the status field in ProductInfo and also the getter and setter methods for the field. You can use this field to obtain the actual status of a subscription.

3. Added the getAccountFlag method to the InAppPurchaseData class. You can use this method to identify the account type of a user.

4. Added the getIapClient(Activity activity, String subAppId) method to the Iap class for quick apps.

IAP SDK 4.0.2 (2020.03.14)

Latest release: 4.0.2.300

New Features

1. Added the isSandboxActivated API to IapClient for you to check whether the sign-in HUAWEI ID and the app APK version meets the requirements of the sandbox testing. The following is an example:

Collapse
Word wrap
Dark theme
Copy code
  1. // To get the Activity instance that calls this API.
  2. Activity activity = getActivity();
  3. IapClient mClient = Iap.getIapClient(activity);
  4. Task<IsSandboxActivatedResult> task = mClient.isSandboxActivated(new IsSandboxActivatedReq());
  5. task.addOnSuccessListener(new OnSuccessListener<IsSandboxActivatedResult>() {
  6.    @Override
  7.    public void onSuccess(IsSandboxActivatedResult result) {
  8.        Log.i(TAG, "isSandboxActivated success");
  9.        dealSandboxResult(activity, result, handler);
  10.    }
  11. }).addOnFailureListener(new OnFailureListener() {
  12.    @Override
  13.    public void onFailure(Exception e) {
  14.        Log.e(TAG, "isSandboxActivated fail");
  15.        if (e instanceof IapApiException) {
  16.            IapApiException apiException = (IapApiException)e;
  17.            int returnCode = apiException.getStatusCode();
  18.        } else {
  19.            // Other external errors
  20.        }
  21. }
  22. });

2. Added ORDER_HIGH_RISK_OPERATIONS (60056) to OrderStatusCode, which indicates that the transaction is rejected because the user triggers risk control.


IAP SDK 4.0.1 (2020.01.21)

Latest release: 4.0.1.300

New Features

1. Supports integrating the IAP SDK into an app project in the Eclipse IDE.  

IAP SDK 4.0.0 (2020.01.15)

Latest release: 4.0.0.300

New Features

1. Added a class InAppPurchaseData, using which you can parse InAppPurchaseData in JSON format.

Example:

Collapse
Word wrap
Dark theme
Copy code
  1. String token;
  2. try {
  3.    // You can get iapData using the createPurchaseIntent or obtainOwnedPurchases API.
  4.    InAppPurchaseData data = new InAppPurchaseData(iapData);
  5.    token = data.getPurchaseToken();
  6. } catch (JSONException e) {
  7.    handleError();
  8. }
  9. use(token);

2. Added originalLocalPrice and originalMicroPrice in ProductInfo returned after you call the obtainProductInfo API to obtain product details configured in AppGallery Connect. Your app can acquire the values of originalLocalPrice and originalMicroPrice to present both the original price and actual price of a product.

3. Added a tool class IapClientHelper. Using the parseRespCodeFromIntent method of this class, you can obtain result codes; using the parseRespMessageFromIntent method of this class, you can obtain response messages.

4. Added an API IapClient.PriceType, using which you can obtain the constant value IN_APP_CONSUMABLE, IN_APP_NONCONSUMABLE, or IN_APP_SUBSCRIPTION.

5. Added an API InAppPurchaseData.PurchaseState, using which you can obtain the constant value PURCHASED, CANCELED, or REFUNDED.

Modified Features

1. Changed the public fields in the com.huawei.hms.iap.entity package to the private fields and provided the corresponding getter and setter methods.

HMS SDK 3.0 (2019.10)

Latest release: 3.0.3.300

HMS SDK 3.0 Development Guide  

HMS SDK 2.0 (2017.04)

HMS SDK 2.0 Development Guide

About SDK dependencies

1. The SDK of this version runs on a mobile phone with HUAWEI HMS Core (APK) 4.0.4.300 or later installed. On a mobile phone that does not have HUAWEI HMS Core (APK) of 4.0.4.300 or later installed, the user will be prompted to install it when your app calls HUAWEI HMS Core (APK).

2. Basic features of HUAWEI IAP Kit are available on most Huawei devices, whereas some advanced features are available only on Huawei devices running EMUI of the required versions. For details, please refer to: EMUI Version-Dependent Features.

Tips:
If you have any questions on releasing your app in HUAWEI AppGallery, contact us via HMSCore@huawei.com.

 


 

This page may contain third-party content. For details, click here.
Search in Guides
Enter a keyword.