Purchase data model, which supports consumables and non-consumables.
| Name | Mandatory | Type | Description |
|---|---|---|---|
| applicationId | Yes | number | App ID. The value contains 1 to 64 characters. |
| applicationIdString | Yes | string | App ID in character string format. The value contains 1 to 64 characters. |
| autoRenewing | Yes | boolean | Whether auto-renewal is enabled for a subscription. - true: yes. - false: no. |
| orderId | Yes | string | Order ID, which uniquely identifies an order to be charged. It is generated by the IAP server when an order is created or a subscription is renewed. Each order matches a unique order ID. |
| kind | Yes | number | Product type. The options are as follows: 0: consumable. 1: non-consumable. |
| packageName | No | string | App package name. |
| productId | Yes | string | Product ID. Note: To avoid financial losses, after successfully verifying the signature of the payment result, you must also verify the consistency of the parameter value between IAP Kit and your app. |
| productName | No | string | Product name. |
| purchaseTime | No | number | Purchase time, which is a UTC timestamp in milliseconds. If the purchase is not complete, this parameter is left empty. |
| purchaseTimeMillis | No | number | A parameter that has the same meaning as purchaseTime and used by APIs of earlier versions. If your app has the latest version integrated, just ignore this parameter. |
| purchaseState | Yes | number | Purchase status. The options are as follows: -1: initialized. 0: purchased. 1: canceled. 2: refunded. 3: pending. |
| developerPayload | No | string | Information stored on the merchant side, which you pass when calling the purchase API. |
| developerChallenge | No | string | Challenge defined when an app initiates a consumption request, which uniquely identifies the consumption request. |
| consumptionState | No | number | Consumption status. The options are as follows: 0: not consumed. 1: consumed. |
| confirmed | No | number | Acknowledgement status. The options are as follows: 0: not acknowledged. 1: acknowledged. If this parameter is left empty, no acknowledgement is required. Note: This parameter is used only for compatibility with earlier versions. If your app has the latest version integrated, just ignore this parameter. |
| purchaseToken | Yes | string | Purchase token, which uniquely identifies the mapping between a product and a user. It is generated by the IAP server when a payment is complete. NOTE - Currently, the value contains 92 characters and its length may be expanded. If the value needs to be stored, you are advised to reserve 128 characters. - For security purposes, you are advised to encrypt the purchase token before storing it. |
| purchaseType | No | number | Purchase type. 0: sandbox environment (currently unsupported). 1: promotional activity (currently unsupported). This parameter is not returned during formal purchase. |
| currency | No | string | Currency. For example, CNY. Note: To avoid financial losses, after successfully verifying the signature of the payment result, you must also verify the consistency of the parameter value between IAP Kit and your app. |
| price | No | number | Price in currency sub-units. The specific sub-unit, like cents, varies by currency. The price is affected by: - Product price that you have configured in AppGallery Connect. - Discounted price applied through promotional offers, including introductory offers for new users, promotional offers for specific user groups, and win-back offers for users considering cancellation. - Total price for bulk purchases. Note: To avoid financial losses, after successfully verifying the signature of the payment result, you must also verify the consistency of the parameter value between IAP Kit and your app. |
| country | No | string | Country/region code, which is used to identify the country or region. For details, please refer to the ISO 3166 standard. |
| payType | No | string | Payment method. For details about the value, please refer to payType. |
| payOrderId | No | string | Order ID, which is generated after a user successfully makes a payment. |
Represents the order information and subscription status information in JWS format.
| Name | Mandatory | Type | Description |
|---|---|---|---|
| type | Yes | number | Product type. 0: consumable. 1: non-consumable. 2: auto-renewable subscription. 3: non-renewable subscription. |
| jwsPurchaseOrder | No | string | Order information in JWS format. Follow the instructions in Verifying the Signature in the Returned Result to decode and perform signature verification for the returned result to obtain purchase data in JSON format. Check the parameters in the JSON string in PurchaseOrderPayload. |
| jwsSubscriptionStatus | No | string | Subscription status information in JWS format. Follow the instructions in Verifying the Signature in the Returned Result to decode and perform signature verification for the returned result to obtain subscription status information in JSON format. Check the parameters in the JSON string in SubGroupStatusPayload. |
Order information model, which supports consumables, non-consumables, auto-renewable subscriptions, and non-renewable subscriptions.
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| environment | Yes | string | Environment type. - NORMAL: normal environment. - SANDBOX: sandbox environment. |
| purchaseOrderId | Yes | string | Order ID of a purchase. The value contains a maximum of 256 characters. |
| purchaseToken | Yes | string | Purchase token. In a consumable/non-consumable/non-renewable subscription purchase, each purchase token matches a specific order. In an auto-renewable subscription purchase, each purchase token matches a subscription ID. |
| applicationId | Yes | string | App ID. |
| productId | Yes | string | Product ID. |
| productType | Yes | string | Product type. The options are as follows: 0: consumable. 1: non-consumable. 2: auto-renewable subscription. 3: non-renewable subscription. |
| quantity | No | number | Quantity of the purchased consumables or non-renewable subscriptions. The quantity parameter applies to one product type only. It does not support a mix of different product types. The maximum quantity is 10. Note: If the quantity parameter is used to support bulk purchases of products, your app needs to verify that the ordered quantity matches the final delivered quantity to prevent under-deliveries or over-deliveries. Atomic service API: This API can be used in atomic services since version 5.0.3(15). Since: 5.0.3(15) |
| purchaseTime | Yes | number | Purchase time, which is a UTC timestamp in milliseconds. If the purchase is not complete, this parameter is left empty. |
| finishStatus | No | string | Delivery status. The options are as follows: 1: The product is delivered. 2: The product is not delivered. |
| needFinish | No | boolean | Whether the delivery should be acknowledged to complete the purchase process. The options are as follows: - true: Delivery acknowledgement is required. - false: Delivery acknowledgement is optional. |
| price | Yes | number | Price in currency sub-units. The specific sub-unit, like cents, varies by currency. The price is affected by: - Product price that you have configured in AppGallery Connect. - Discounted price applied through promotional offers, including introductory offers for new users, promotional offers for specific user groups, and win-back offers for users considering cancellation. - Total price for bulk purchases. |
| currency | Yes | string | Currency. For details, please refer to the ISO 4217 standard. For example, CNY, USD, and MYR. |
| developerPayload | No | string | Information stored on the merchant side, which you pass when calling the purchase API. |
| purchaseOrderRevocationReasonCode | No | string | Reason for revoking an order. 0: others. 1: order revoked at the user's request. |
| revocationTime | No | number | Time when a purchase order is canceled, which is a UTC timestamp in ms. |
| offerTypeCode | No | string | Offer type. 1: introductory offers for new users. 2: promotional offers for specific user groups. 4: win-back offers for at-risk users. |
| offerId | No | string | Promotional offer ID. |
| countryCode | Yes | string | Country/region code, which is used to identify the country or region. For details, please refer to the ISO 3166 standard. |
| signedTime | Yes | number | Time when signing is performed, which is a UTC timestamp in ms. |
Parameters returned only for auto-renewable subscriptions.
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| subGroupGenerationId | Yes | string | Subscription group generation ID. - This ID remains unchanged when a user switches between different subscription products in the same group. - This ID will change when a user purchases a subscription again after the subscription expires and the account hold period ends. |
| subscriptionId | Yes | string | Subscription ID. The ID will change when: - A user switches from a subscription to another. - When a user purchases a subscription again after the subscription expires and the account hold period ends. |
| subGroupId | Yes | string | ID of the subscription group to which a subscription belongs. |
| duration | Yes | string | Validity period of the current purchase, in ISO 8601 format. For example, P1W represents one week, and P1M represents one month. |
| durationTypeCode | Yes | string | Type of a subscription cycle. 0: normal. 1: extended. |
Represents the subscription status information related to a subscription group.
| Name | Mandatory | Type | Description |
|---|---|---|---|
| environment | Yes | string | Environment type. - NORMAL: normal environment. - SANDBOX: sandbox environment. |
| applicationId | Yes | string | App ID. |
| packageName | Yes | string | App package name. |
| subGroupId | Yes | string | ID of the subscription group to which a subscription belongs. |
| lastSubscriptionStatus | No | object | Final subscription status (SubscriptionStatus) within a subscription group. For example, if a user switches from subscription A to B and then to C, this parameter indicates the status of subscription C. |
| historySubscriptionStatusList | No | object[] | List of recent active subscription statuses (SubscriptionStatus) within a subscription group, sorted in ascending order by the time of subscription switching. The list contains up to 10 valid status records. For example, if subscription A switches to B, and B switches to C, the list will include the three subscription status records for A, B, and C. |
Represents subscription status information.
| Name | Mandatory | Type | Description |
|---|---|---|---|
| subGroupGenerationId | Yes | string | Subscription group generation ID. - This ID remains unchanged when a user switches between different subscription products in the same group. - This ID will change when a user purchases a subscription again after the subscription expires and the account hold period ends. |
| subscriptionId | Yes | string | Subscription ID. The ID will change when: - A user switches from a subscription to another. - When a user purchases a subscription again after the subscription expires and the account hold period ends. |
| purchaseToken | Yes | string | Purchase token. In a consumable/non-consumable/non-renewable subscription purchase, each purchase token matches a specific order. In a subscription purchase, each purchase token matches a subscription ID. |
| status | Yes | string | Subscription status. 1: active. 2: expired. 3: billing retry. 5: revoked. |
| expiresTime | Yes | number | Expiration time of a subscription that supports auto-renewal. The value is a UTC timestamp in ms. |
| lastPurchaseOrder | No | object | Latest purchase order for a subscription. For details about the parameters contained in the purchase order, please refer to PurchaseOrderPayload. |
| recentPurchaseOrderList | No | object[] | List of the latest orders for a subscription, including those generated upon renewal, proration, and extension. For details about the parameters contained in the purchase order, see PurchaseOrderPayload. |
| renewalInfo | No | object | Latest future billing plan of the current subscription. For details about the parameters contained in the billing plan, please refer to SubRenewalInfo. |
Represents the renewal information about a subscription.
| Name | Mandatory | Type | Description |
|---|---|---|---|
| environment | Yes | string | Environment type. - NORMAL: normal environment. - SANDBOX: sandbox environment. |
| subGroupGenerationId | Yes | string | Subscription group generation ID. - This ID remains unchanged when a user switches between different subscription products in the same group. - This ID will change when a user purchases a subscription again after the subscription expires and the account hold period ends. |
| nextRenewPeriodProductId | No | string | ID of the product to be renewed in the next billing cycle. |
| productId | Yes | string | ID of the product that is currently active. |
| autoRenewStatusCode | Yes | string | Auto-renewal status. 0: disabled. 1: enabled. |
| hasInBillingRetryPeriod | Yes | boolean | Whether the system is still attempting to retry the billing. - true: yes. - false: no. |
| priceIncreaseStatusCode | No | string | Price increase status code. 1: The user has not agreed to a price increase. 2: The user has agreed to a price increase. |
| offerTypeCode | No | string | Offer type. 1: introductory offers for new users. 2: promotional offers for specific user groups. 4: win-back offers for at-risk users. |
| offerId | No | string | Promotional offer ID. |
| renewalPrice | No | number | Price for the next renewal, in currency sub-units. The specific sub-unit, like cents, varies by currency. This field is not returned if the subscription is revoked. |
| currency | No | string | Currency. For details, please refer to the ISO 4217 standard. For example, CNY, USD, and MYR. |
| renewalTime | No | number | Renewal time, which is a UTC timestamp in ms. |
| expirationIntent | No | string | Reason for subscription renewal failure. 1: The user canceled the subscription. 2: The product is invalid. 3: The subscription agreement is invalid. 4: An exception occurred during billing. 5: The user did not agree to the price increase. 6: The failure reason is unknown. 7: There is an unfulfilled subscription order. |