After a user purchases an auto-renewable subscription, this API is used by the Huawei paymentIAP server calls an API to send a key event notification of the subscription scenario to the developer server.
If you have configured the subscription notification address of your server when applying for the HUAWEI IAP service in AppGallery Connect, the Huawei IAP server will call this API to notify your server of a key subscription event after a user purchases a subscription of your app. The following subscription scenarios are involved:
A user's first subscription is successful.
The operations or customer service personnel cancel the subscription of a user due to special reasons.
An expired subscription is automatically renewed.
A user proactively renews an expired subscription.
A user chooses to downgrade or crossgrade between subscriptions, which takes effect on the next renewal date.
If a user proactively cancels a subscription or an app cancels a subscription, the paid service of the subscription is still valid, but the renewal will stop.
A user proactively resumes the renewal status of a subscription that has been canceled.
A subscription is renewed successfully.
An expired subscription enters the account retention period.
A user agrees that the price of a subscription increases and the subscription will be renewed at a higher price.
If your server returns a failure response (the value of http status code in the response is not 200), the notification about the key event will be resent periodically. It is recommended that your server return a success response immediately after the minimum processing is complete to avoid message stock.
Do not configure an IP address allowlist on your server to restrict Huawei egress IP addresses. Configuring an IP address allowlist is meaningless because it restricts business development without improving security, especially when a more secure RSA signature mechanism is available. You are accountable for any consequence in the case of your breach of this rule.
The callback address of your server must be configured in AppGallery Connect before development. The address must support the HTTPS protocol and have a valid commercial certificate.
Protocol | HTTPS POST |
Direction | Huawei IAP server -> Developer server |
URL | The URL is configured when you apply for the HUAWEI IAP service. |
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Parameter | Mandatory(M)/Optional (O) | Type | Description |
statusUpdateNotification | M | String | Notification message, which is a JSON string. For details, please refer to the description of Table statusUpdateNotification. |
notifycationSignature | M | String | Signature string for the statusUpdateNotification parameter. The signature algorithm is SHA256withRSA. After receiving the signature string, your server needs to use the payment public key to verify the JSON string of the statusUpdateNotification parameter. For details, please refer to Verifying the Signature in the Returned Result. For details about how to obtain the public key, please refer to Querying IAP Information. |
Table 1 statusUpdateNotification
Parameter | Mandatory(M)/Optional (O) | Type | Description |
environment | M | String | Environment for sending a notification.
|
notificationType | M | Integer | Notification event type. For details, please refer to the notificationType table. |
subscriptionId | M | String | Subscription ID. |
cancellationDate | O | Long | Timestamp, which is passed only when notificationType is set to CANCEL(1). |
orderId | M | String | Order ID used for payment during subscription renewal. |
latestReceipt | O | String | Token of the latest receipt, which is passed only when notificationType is set to INITIAL_BUY(0), RENEWAL(2), or INTERACTIVE_RENEWAL(3) and the renewal is successful. |
latestReceiptInfo | O | String | Latest receipt, which is a JSON string. This parameter is left empty when notificationType is set to CANCEL(1). For details about the parameters contained, please refer to the description of InAppPurchaseDetails. |
latestReceiptInfoSignature | O | String | Signature string for the latestReceiptInfo parameter. The signature algorithm is SHA256withRSA. After receiving the signature string, your server needs to use the payment public key to verify the JSON string of the latestReceiptInfo parameter. For details, please refer to Verifying the Signature in the Returned Result. For details about how to obtain the public key, please refer to Querying IAP Information. |
latestExpiredReceipt | O | String | Token of the latest expired receipt. This parameter has a value only when notificationType is set to RENEWAL(2) or INTERACTIVE_RENEWAL(3). |
latestExpiredReceiptInfo | O | String | Latest expired receipt, which is a JSON string. This parameter has a value only when notificationType is set to RENEWAL(2) or INTERACTIVE_RENEWAL(3). |
latestExpiredReceiptInfoSignature | O | String | Signature string for the latestExpiredReceiptInfo parameter. The signature algorithm is SHA256withRSA. After receiving the signature string, your server needs to use the payment public key to verify the JSON string of the latestExpiredReceiptInfo parameter. For details, please refer to Verifying the Signature in the Returned Result. For details about how to obtain the public key, please refer to Querying IAP Information. |
autoRenewStatus | M | Integer | Renewal status.
|
refundPayOrderId | O | String | Refund order ID. This parameter has a value only when notificationType is set to CANCEL(1). |
productId | M | String | In-app product ID. |
applicationId | O | Long | App ID. |
expirationIntent | O | Integer | Expiration reason. This parameter has a value only when notificationType is set to RENEWAL(2) or INTERACTIVE_RENEWAL(3) and the renewal is successful. |
The latest purchaseToken parameter obtained after payment indicates the mapping between the product and the user.
latestReceipt indicates the token of the receipt for successful charging.
latestExpiredReceipt indicates the token of the receipt in the last period.
If the renewal is successful:
For renewal, the value of purchaseToken is the same as that of latestReceipt.
For switchover, the value of purchaseToken is different from that of latestReceipt.
Value | Description |
INITIAL_BUY(0) | Integer. First purchase behavior of a subscription. |
CANCEL(1) | Integer. When customer service personnel or an app cancels a subscription, the cancellation time (when the refund starts) can be obtained using cancellationDate. |
RENEWAL(2) | Integer. When an expired subscription is automatically renewed, the next renewal time can be obtained based on the expiration time in the receipt. |
INTERACTIVE_RENEWAL(3) | Integer. When a user renews an expired subscription or switches from an expired subscription to another one, the service takes effect immediately after the operation is successful. |
NEW_RENEWAL_PREF(4) | Integer. A user selects another subscription in a group and it takes effect after the current subscription expires. The subscription validity period is not affected. That is, the subscription takes effect in the next validity period after downgrade or crossgrade. The notification carries the last valid receipt and new subscription information, including the product ID and subscription ID. |
RENEWAL_STOPPED(5) | Integer. The renewal of a subscription is stopped by a user, a developer, or Huawei, but the paid service of the subscription is still valid. The notification contains the latest receipt, product ID, app ID, subscription ID, and subscription token. |
RENEWAL_RESTORED(6) | Integer. A user renews a subscription and the renewal status is normal. The notification contains the latest receipt, product ID, app ID, subscription ID, and subscription token. |
RENEWAL_RECURRING(7) | Integer. One-time renewal fees are successfully deducted in the promotion period, free trial period, and sandbox testing. The notification contains the latest receipt, product ID, app ID, subscription ID, and subscription token. Notice: If INITIAL_BUY, RENEWAL, or INTERACTIVE_RENEWAL exists, RENEWAL_RECURRING does not exist because all of them indicate a successful renewal. |
IN_GRACE_PERIOD(8) | Integer. The subscription expires but the grace period is enabled. Notice: A grace period is not supported currently. |
ON_HOLD(9) | Integer. An expired subscription enters the account retention period. Notice: A grace period is not supported currently. |
PAUSED(10) | Integer. After a user makes a renewal suspension plan, the subscription enters the paused state when its validity period ends. |
PAUSE_PLAN_CHANGED(11) | Integer. A user has made a renewal suspension plan. |
PRICE_CHANGE_CONFIRMED(12) | Integer. A user agreed to the price increase. |
DEFERRED(13) | Integer. The subscription renewal time has been postponed. |
Output Parameters
Parameter | Mandatory(M)/Optional (O) | Type | Description |
errorCode | O | String | Processing failure result code. The result code is defined by a developer. |
errorMsg | O | String | Failure cause description. |