目录

Data Types

InAppPurchaseData

Purchase data model, which supports consumables and non-consumables.

Name

Mandatory

Type

Description

applicationId

Yes

number

App ID.

applicationIdString

Yes

string

App ID in character string format.

autoRenewing

Yes

boolean

For consumables or non-consumables, the value is always false.

orderId

Yes

string

Order ID, which uniquely identifies a receipt to be charged. It is generated by the IAP server when an order is created or a subscription is renewed.

Each receipt 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:

After a successful verification of the signature in the payment result, it is a must to check the consistency of this parameter value between IAP Kit and your app.

productName

No

string

Product name.

purchaseTime

No

number

Time when a product is purchased. The value 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 an app passes when calling the payment 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:

After a successful verification of the signature in the payment result, it is a must to check the consistency of this parameter value between IAP Kit and your app.

price

No

number

Value after the actual price of a product is multiplied by 100. The actual price is accurate to two decimal places. For example, if the value of this parameter is 501, the actual product price is 5.01.

NOTE:

After a successful verification of the signature in the payment result, it is a must to check the consistency of this parameter value between IAP Kit and your app.

country

No

string

Country or region code, which is used to identify a country or region. The value must comply with the ISO 3166 standard.

payType

No

string

Payment method. For details about its values, please refer to payType.

payOrderId

No

string

Order ID, which is generated after a user successfully makes a payment.

payType

Below lists the values of payType.

Value

Description

0

HUAWEI Points.

4

Alipay.

94

Huawei Pay.

PurchaseData

It contains 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

jwsPurchaseOrder

No

string

Data in JWS format that contains order information. 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

Data in JWS format that contains subscription status information. 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.

PurchaseOrderPayload

Order information model, which supports consumables, non-consumables, and auto-renewable subscriptions.

Parameter

Mandatory

Type

Description

environment

Yes

string

Environment type.

  • NORMAL: production environment
  • SANDBOX: sandbox environment

purchaseOrderId

Yes

string

Order ID of a purchase.

purchaseToken

Yes

string

Purchase token. In a consumable/non-consumable purchase, each purchase token matches a specific order. In a 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

purchaseTime

Yes

number

Time when a product is purchased. The value 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: delivered
  • 2: not delivered

needFinish

No

boolean

Indicates whether it is a must to acknowledge the delivery to complete the purchase. The options are as follows:

  • true: The delivery must be acknowledged to complete the purchase.
  • false: Acknowledging the delivery to complete the purchase is optional.

price

Yes

number

Price, in cents.

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 an app passes when calling the payment API.

purchaseOrderRevocationReasonCode

No

string

Reason for revoking an order.

  • 0: other reasons
  • 1: refund when a user encounters a problem

revocationTime

No

number

Time when an order is revoked. The value is a UTC timestamp, in milliseconds.

offerTypeCode

No

string

Offer type.

  • 1: Special offers for new users
  • 2: Special offers for custom user groups

offerId

No

string

Offer ID.

countryCode

Yes

string

Country or region code, which is used to identify a country or region. The value must comply with the ISO 3166 standard.

signedTime

Yes

number

Time when signing is performed. The value is a UTC timestamp, in milliseconds.

Parameters returned only for subscriptions:

subGroupGenerationI

Yes

string

Generation ID of a subscription group.

  • When a user switches from one subscription to another, the ID remains unchanged.
  • When a user re-purchases a subscription after the previous one expires and the account hold period ends, the ID will change.

subscriptionId

Yes

string

Subscription ID. The ID will changes when:

  • A user switches from one subscription to another.
  • A user re-purchases a subscription after the previous one expires and the account hold period ends.

subGroupId

Yes

string

Subscription group ID.

duration

Yes

string

Validity period after a purchase. The value is in ISO 8601 format. For example, P1W indicates a week and P1M indicates a month.

durationTypeCode

Yes

string

Type of a subscription cycle.

  • 0: normal

SubGroupStatusPayload

Subscription status information related to a subscription group.

Name

Mandatory

Type

Description

environment

Yes

string

Environment type.

  • NORMAL: production environment
  • SANDBOX: sandbox environment

applicationId

Yes

string

App ID.

packageName

Yes

string

App package name.

subGroupId

Yes

string

Subscription group ID.

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 all historical subscription statuses (SubscriptionStatus) within a subscription group. For example, if a user switches from subscription A to B and then to C, this parameter indicates the statuses of subscriptions C, B, and A.

SubscriptionStatus

Information about the subscription status.

Name

Mandatory

Type

Description

subGroupGenerationId

Yes

string

Generation ID of a subscription group.

  • When a user switches from one subscription to another, the ID remains unchanged.
  • When a user re-purchases a subscription after the previous one expires and the account hold period ends, the ID will change.

subscriptionId

Yes

string

Subscription ID. The ID will changes when:

  • A user switches from one subscription to another.
  • A user re-purchases a subscription after the previous one expires and the account hold period ends.

purchaseToken

Yes

string

Purchase token. In a consumable/non-consumable 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: charge attempt
  • 5: revoked

expiresTime

Yes

number

Time when a subscription expires. The value is a UTC timestamp, in milliseconds.

lastPurchaseOrder

No

object

Latest order for a subscription. For details about the included parameters, please refer to PurchaseOrderPayload.

recentPurchaseOrderList

No

object[]

List of the latest orders for a subscription, including those generated upon renewal and balance conversion. For details about the included parameters, please refer to PurchaseOrderPayload.

renewalInfo

No

object

Latest future billing plan for a subscription. For details about the included parameters, please refer to SubRenewalInfo.

SubRenewalInfo

Information about the billing plan for a subscription.

Name

Mandatory

Type

Description

environment

Yes

string

Environment type.

  • NORMAL: production environment
  • SANDBOX: sandbox environment

subGroupGenerationId

Yes

string

Generation ID of a subscription group.

  • When a user switches from one subscription to another, the ID remains unchanged.
  • When a user re-purchases a subscription after the previous one expires and the account hold period ends, the ID will change.

nextRenewPeriodProductId

No

string

ID of the product to be purchased on the next billing date.

productId

Yes

string

ID of the product that is currently active.

autoRenewStatusCode

Yes

string

Auto-renewal status.

  • 0: disabled
  • 1: enabled

hasInBillingRetryPeriod

Yes

boolean

Indicates whether the system is still attempting to charge.

  • true: yes
  • false: no

priceIncreaseStatusCode

No

string

Price increase status code.

  • 1: A user has not agreed to a price increase.
  • 2: A user has agreed to a price increase.

offerTypeCode

No

string

Offer type.

  • 1: Special offers for new users
  • 2: Special offers for custom user groups

offerId

No

string

Offer ID.

renewalPrice

No

number

Price charged for the next renewal, in cents. This parameter is not returned in the subscription cancellation scenario.

currency

No

string

Currency. For details, please refer to the ISO 4217 standard. For example, CNY, USD, and MYR.

renewalTime

No

number

Time when a renewal happens. The value is a UTC timestamp, in milliseconds.

expirationIntent

No

string

Reason for subscription renewal failure.

  • 1: canceled by a user
  • 2: invalid product
  • 3: invalid contract signing
  • 4: abnormal fee deduction
  • 5: price increase rejected by a user
  • 6: unknown