This API is used to postpone the settlement date of a user.
When you launch some preferential activities using your app, for example, rewarding users with product use duration, you can call the API provided by the Huawei IAP server to postpone the settlement date of the user. The user can continue to use the paid service and content and will not be charged during the postponed period. HUAWEI IAP updates the subscription renewal date. You can perform the following operations by postponing settlement:
Provide free content or services to users as part of a package or special preferential scheme (for example, allow the user who subscribes to annual magazines to access specific content free of charge).
Reward the permission of accessing content or services to specified users.
The settlement date can be postponed by at least one day and at most one year (365 days). You can call the API again before the new settlement date arrives for postponing again. After the postponing, the next renewal starts after the new settlement date ends.
Your app may need to notify users by email or in the app that their settlement date has been postponed.
Protocol | HTTPS POST |
Direction | Developer server -> Huawei IAP server |
URL | {rootUrl}/sub/applications/{apiVersion}/purchases/delay The value of rootUrl varies depending on the site. You must select the subscription service address of the nearest site for access. For details, please refer to Site Information and Site Selection. |
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Parameter | Mandatory(M)/Optional (O) | Type | Description |
subscriptionId | M | String | Subscription ID. |
purchaseToken | M | String | Purchase token of a product. This parameter is returned when an app initiates a purchase request or queries subscription information. |
currentExpirationTime | M | Long | Subscription validity period. The value is a standard timestamp and must be the same as the current expiration time. |
desiredExpirationTime | M | Long | Subscription validity period after postponing. The value is a standard timestamp and must be greater than the current subscription validity period. The settlement date can be postponed by at least one day and at most 365 days. |
Parameter | Mandatory(M)/Optional (O) | Type | Description |
responseCode | M | String | Result code. The options are as follows: ● 0: success ● Other values: failure. For details about the result codes, please refer to API Result Codes. |
responseMessage | O | String | Response description. |
newExpirationTime | O | Long | Subscription validity period after postponing. The value is a standard timestamp. |
- public class SubscriptionService {
- // TODO: replace the (ip:port) to the real one, and if the protocol is https, you should deal with the license
- // yourself.
- public static final String TOC_SITE_URL = "http://ip:port";
- // site for telecom carrier
- public static final String TOBTOC_SITE_URL = "https://subscr-at-dre.iap.dbankcloud.com";
- public static String getRootUrl(Integer accountFlag) {
- if (accountFlag != null && accountFlag == 1) {
- return TOBTOC_SITE_URL;
- }
- return TOC_SITE_URL;
- }
- public static void delaySubscription(String subscriptionId, String purchaseToken, Long currentExpirationTime,
- Long desiredExpirationTime, Integer accountFlag) throws Exception {
- // fetch the App Level AccessToken
- String appAt = AtDemo.getAppAT();
- // construct the Authorization in Header
- Map<String, String> headers = AtDemo.buildAuthorization(appAt);
- // pack the request body
- Map<String, Object> bodyMap = new HashMap<>();
- bodyMap.put("subscriptionId", subscriptionId);
- bodyMap.put("purchaseToken", purchaseToken);
- bodyMap.put("currentExpirationTime", currentExpirationTime);
- bodyMap.put("desiredExpirationTime", desiredExpirationTime);
- String msgBody = JSONObject.toJSONString(bodyMap);
- String response = AtDemo.httpPost(getRootUrl(accountFlag) + "/sub/applications/v2/purchases/delay",
- "application/json; charset=UTF-8", msgBody, 5000, 5000, headers);
- // TODO: display the response as string in console, you can replace it with your business logic.
- System.out.println(response);
- }
- }