目录

CLASS info
public class InAppPurchaseData extends java.lang.Object
A utility class to parse InAppPurchaseData String.

Nested Class Summary

TypeNameDesc
static interfaceInAppPurchaseData.PurchaseStatePossible state of a purchase.

Field Summary

TypeNameDesc
static intNOT_PRESENTIndicates that the field is not present in source json string.

Public Constructor Summary

Constructor name

InAppPurchaseData(java.lang.String iapData)

Constructs an InAppPurchaseData from InAppPurchaseData String.

Public Method Summary

Return typeMethod name
java.lang.StringgetAppInfo()
App information, which is reserved.
longgetApplicationId()
the application id.
intgetCancelledSubKeepDays()
Number of days for retaining a subscription relationship after the subscription is canceled.
intgetCancelReason()
Cause of subscription cancellation.
longgetCancelTime()
Timestamp of the subscription cancellation time.
java.lang.StringgetCountry()
Country code, which is used to identify a country.
java.lang.StringgetCurrency()
Currency
longgetDaysLasted()
Days of paid service, excluding the free trial period and promotion period.
java.lang.StringgetDeveloperPayload()
developer provided payload
longgetExpirationDate()
Timestamp of the subscription expiration time.
intgetExpirationIntent()
Reason why a subscription expires.
intgetIntroductoryFlag()
Indicates whether a subscription is in the promotion period.
java.lang.StringgetLastOrderId()
Order ID generated by the payment server during fee deduction on the previous renewal date.
intgetNotifyClosed()
Indicates whether a user has disabled subscription notifications.
longgetNumOfDiscount()
Number of successful renewal periods with promotion.
longgetNumOfPeriods()
Number of successful standard renewal periods (that is, renewal periods without promotion).
java.lang.StringgetOrderID()
Order ID on the Huawei payment server, which uniquely identifies a transaction and is generated by the Huawei payment server during payment.
longgetOriPurchaseTime()
Timestamp of the first fee deduction time, milliseconds since 00:00:00 on January 1, 1970.
java.lang.StringgetPackageName()
App installation package name.
longgetPrice()
Value after the actual price of an in-app product is multiplied by 100.
intgetPriceConsentStatus()
User opinion on the price increase of an in-app product.
java.lang.StringgetProductGroup()
ID of the subscription group to which a subscription belongs.
java.lang.StringgetProductId()
In-app product ID.
java.lang.StringgetProductName()
In-app product name.
intgetPurchaseState()
Transaction status.
longgetPurchaseTime()
Timestamp of the purchase time, milliseconds since 00:00:00 on January 1, 1970.
java.lang.StringgetPurchaseToken()
Purchase token, which uniquely identifies the mapping between an in-app product and a user and is generated by the Huawei payment server when the payment is complete.
intgetPurchaseType()
Purchase type.
intgetQuantity()
Purchase quantity.
longgetRenewPrice()
Price used upon the next renewal.
intgetRenewStatus()
Renewal status.
intgetRetryFlag()
Indicates whether the system still tries to renew an expired subscription.
java.lang.StringgetSubscriptionId()
Subscription ID.
intgetTrialFlag()
Indicates whether a subscription is in the free trial period.
booleanisAutoRenewing()
purchase auto renewing status.
booleanisSubValid()
true: A user has been charged for an in-app product, the in-app product has not expired, and no refund has been made.
int

getKind()

Product type

java.lang.StringgetDeveloperChallenge()
Challenge defined when an app initiates a consumption request, which uniquely identifies the consumption request. This parameter exists only for one-off products.
intgetConsumptionState()
Consumption status, which exists only for one-off products.
java.lang.String

getPayOrderId()

Merchant ID, which uniquely identifies a transaction and is generated by the Huawei IAP server during payment.
java.lang.String

getPayType()

Payment method. 
int

getDeferFlag()

Indicates whether to postpone the settlement date. The value 1 indicates that the settlement date is postponed.
java.lang.String

getOriSubscriptionId()

Original subscription ID.
int

getCancelWay()

Subscription cancellation initiator. 
long

getCancellationTime()

Subscription cancellation time in UTC.

long

getResumeTime()

Time when a subscription is resumed.

intgetAccountFlag()

Obtains the account type.

Constants

Constant
public static final int NOT_PRESENT
Indicates that the field is not present in source json string.

Public Constructors

constructor
public InAppPurchaseData(java.lang.String iapData) throws org.json.JSONException
Constructs an InAppPurchaseData from InAppPurchaseData String.

Parameters

Parameter nameParameter desc
iapDataString to describe user purchase details.


Throws

Parameter nameParameter desc
org.json.JSONExceptionwhen mandatory field failed to parse from iapData.

Public Methods

Method
public long getApplicationId()
the application id.
Method
public boolean isAutoRenewing()

purchase auto renewing status. For consumables and non-consumables, the value is fixed to false. 

For subscriptions, the options are as follows: 

● true: A subscription is in active state and will be automatically renewed on the next renewal date. 

● false: A user has canceled the subscription. The user can access the subscribed content before the next renewal date but will be unable to access content after the date unless they resume the subscription. If a grace period is provided, this value remains true for the subscription as long as it is still in the grace period. The next renewal date is automatically extended every day until the grace period ends or the user changes their payment method.

Method
public java.lang.String getOrderID()
Order ID on the Huawei payment server, which uniquely identifies a transaction and is generated by the Huawei payment server during payment.
Method
public java.lang.String getPackageName()
App installation package name.
Method
public java.lang.String getProductId()
In-app product ID. Each in-app product must have a unique ID, which is maintained in the PMS or transferred to the PMS when the app initiates a purchase.
Method
public java.lang.String getProductName()
In-app product name.
Method
public long getPurchaseTime()
Timestamp of the purchase time, milliseconds since 00:00:00 on January 1, 1970.
Method
public int getPurchaseState()
Transaction status.
Method
public java.lang.String getDeveloperPayload()
developer provided payload.
Method
public java.lang.String getPurchaseToken()
Purchase token, which uniquely identifies the mapping between an in-app product and a user and is generated by the Huawei payment server when the payment is complete.
Method
public int getPurchaseType()

Purchase type. 

● 0: in the sandbox 

● 1: in the promotion period (not supported now) This parameter is not returned during formal purchase.

Method
public java.lang.String getCurrency()
Currency.
Method
public long getPrice()
Value after the actual price of an in-app product is multiplied by 100. The actual price is accurate to two decimal places.
Method
public java.lang.String getCountry()
Country code, which is used to identify a country.
Method
public java.lang.String getLastOrderId()
Order ID generated by the payment server during fee deduction on the previous renewal date.
Method
public java.lang.String getProductGroup()
ID of the subscription group to which a subscription belongs.
Method
public long getOriPurchaseTime()
Timestamp of the first fee deduction time, milliseconds since 00:00:00 on January 1, 1970.
Method
public java.lang.String getSubscriptionId()
Subscription ID.
Method
public int getQuantity()
Purchase quantity.
Method
public long getDaysLasted()
Days of paid service, excluding the free trial period and promotion period.
Method
public long getNumOfPeriods()
Number of successful standard renewal periods (that is, renewal periods without promotion). If the value is 0 or left empty, no renewal has been performed successfully.
Method
public long getNumOfDiscount()
Number of successful renewal periods with promotion.
Method
public long getExpirationDate()
Timestamp of the subscription expiration time. For an automatic renewal receipt where the fee has been deducted successfully, this parameter indicates the renewal date or expiration date. If the value is a past time for the latest receipt of an in-app product, the subscription has expired.
Method
public int getExpirationIntent()

Reason why a subscription expires. 

● 1: canceled by a user 

● 2: in-app product being unavailable 

● 3: abnormal user signing information 

● 4: billing error 

● 5: price increase disagreed with by a user 

● 6: unknown error

Method
public int getRetryFlag()
Indicates whether the system still tries to renew an expired subscription.
Method
public int getIntroductoryFlag()
Indicates whether a subscription is in the promotion period.
Method
public int getTrialFlag()
Indicates whether a subscription is in the free trial period.
Method
public long getCancelTime()
Timestamp of the subscription cancellation time. This parameter has a value when a user makes a complaint and cancels a subscription through the customer service personnel, or when a user performs subscription upgrade or cross-grade that immediately takes effect and cancels the previous receipt of the original subscription. Timestamp of the subscription cancellation time.
Method
public int getCancelReason()

Cause of subscription cancellation. 

● 2: A user performs subscription upgrade or cross-grade. 

● 1: A user encounters a problem within the app and cancels the subscription. 

● 0: other causes. For example, a user mistakenly purchases a subscription and has to cancel it. Cause of subscription cancellation.

Method
public java.lang.String getAppInfo()
App information, which is reserved.
Method
public int getNotifyClosed()
Indicates whether a user has disabled subscription notifications.
Method
public int getRenewStatus()

Renewal status. 

● 1: The subscription renewal is normal. 

● 0: The user cancels subscription renewal. 

Method
public int getPriceConsentStatus()

User opinion on the price increase of an in-app product. 

● 1: The user has agreed to the price increase. 

● 0: The user does not take any action. After the subscription expires, it becomes invalid. 

Method
public long getRenewPrice()
Price used upon the next renewal. It is provided as a reference for users when the getPriceConsentStatus() parameter is returned.
Method
public boolean isSubValid()

● true: A user has been charged for an in-app product, the in-app product has not expired, and no refund has been made. In this case, you can provide services for the user. 

● false: The purchase of an in-app product is not finished, the in-app product has expired, or a refund has been made for the in-app product after its purchase is the subscription valid.

Method

public int getCancelledSubKeepDays()

Number of days for retaining a subscription relationship after the subscription is canceled.

Method
public int getKind()

Product type. The options are as follows: 

● 0: consumable 

● 1: non-consumable 

● 2: renewable subscription 

● 3: non-renewable subscription

Method
public int getDeveloperChallenge()
Challenge defined when an app initiates a consumption request, which uniquely identifies the consumption request. This parameter exists only for one-off products.
Method
public int getConsumptionState()
Consumption status, which exists only for one-off products. The options are as follows:
● 0: not consumed
● 1: consumed
Method
public int getPayOrderId()
Merchant ID, which uniquely identifies a transaction and is generated by the Huawei IAP server during payment.
Method
public int getPayType()
Payment method. The options are as follows:
● 0: HUAWEI Points
● 3: credit card
● 4: Alipay
● 6: carrier billing
● 13: PayPal
● 16: debit card
● 17: WeChat Pay
● 19: gift card
● 20: balance
● 21: HUAWEI Point card
● 24: WorldPay
● 31: Huawei Pay
● 32: Ant Credit Pay
● 200: M-Pesa
Method
public int getDeferFlag()
Indicates whether to postpone the settlement date. The value 1 indicates that the settlement date is postponed.
Method
public int getOriSubscriptionId()
Original subscription ID. If this parameter is set to a value, the current subscription is switched from another one. The value can be associated with the subscription about the original subscription.
Method
public int getCancelWay()
Subscription cancellation initiator. The options are 0 (user), 1 (developer), and 2 (Huawei).
Method
public int getCancellationTime()

Subscription cancellation time in UTC.

Note: 
cancelWay and cancellationTime are displayed when a subscription renewal stops (the refund is not involved).
Method
public  long getResumeTime()
Time when a subscription is resumed.
Method
public  int getAccountFlag()

Obtains the account type. The options are as follows:

  • 1: AppTouch user account

  • Other values: HUAWEI ID