目录

PurchaseIntentReq

Class Info

public class PurchaseIntentReq extends BaseReq

Request information of the createPurchaseIntent API.

Public Constructor Summary

Constructor Name

PurchaseIntentReq()

Constructs a PurchaseIntentReq object.

Public Method Summary

Qualifier and Type

Method Name and Description

String

getDeveloperPayload()

Obtains the information stored on the merchant side.

int

getPriceType()

Obtains the product type.

String

getProductId()

Obtains the product ID.

String

getSignatureAlgorithm()

Obtains the signature algorithm.

void

setDeveloperPayload(String developerPayload)

Sets the information stored on the merchant side.

void

setPriceType(int priceType)

Sets the product type.

void

setProductId(String productId)

Sets the product ID.

void

setSignatureAlgorithm(String signatureAlgorithm)

Sets the signature algorithm.

Methods Inherited from Class com.huawei.hms.iap.entity.BaseReq

getReservedInfor, setReservedInfor

Public Constructors

[h2]PurchaseIntentReq

Constructor

PurchaseIntentReq()

Constructs a PurchaseIntentReq object.

Public Methods

[h2]getDeveloperPayload

Method

public String getDeveloperPayload()

Obtains the information stored on the merchant side.

Returns

Type

Description

String

Information stored on the merchant side.

If a value exists, the value will be returned in the callback result to the app after successful payment.

NOTE:

The value length range is [0, 256].

[h2]getPriceType

Method

public int getPriceType()

Obtains the product type.

Returns

Type

Description

int

Product type. The options are as follows:

  • 0: consumable
  • 1: non-consumable
  • 2: subscription

[h2]getProductId

Method

public String getProductId()

Obtains the product ID.

Returns

Type

Description

String

ID of a product to be paid. The product ID is defined when you add a product in AppGallery Connect.

NOTE:

The value length range is (0, 148].

The product ID must be unique within an app. Once saved, the product ID cannot be changed. This ID cannot be used again even if the product is deleted.

[h2]getSignatureAlgorithm

Method

public String getSignatureAlgorithm()

Obtains the signature algorithm that you have passed.

Returns

Type

Description

String

Signature algorithm.

[h2]setDeveloperPayload

Method

public void setDeveloperPayload(String developerPayload)

Optional. Sets the information stored on the merchant side.

Parameters

Name

Description

developerPayload

Information stored on the merchant side.

If a value exists, the value will be returned in the callback result to the app after successful payment.

NOTE:

The value length range is [0, 256].

[h2]setPriceType

Method

public void setPriceType(int priceType)

Mandatory. Sets the product type.

NOTE:

If no product type is passed, the product type 0 will be used by default, which indicates consumables.

Parameters

Name

Description

priceType

Product type. The options are as follows:

  • 0: consumable
  • 1: non-consumable
  • 2: subscription

[h2]setProductId

Method

public void setProductId(String productId)

Mandatory. Sets the product ID.

Parameters

Name

Description

productId

ID of a product to be paid. The product ID is defined when you add a product in AppGallery Connect.

NOTE:

The value length range is (0, 148].

The product ID must be unique within an app. Once saved, the product ID cannot be changed. This ID cannot be used again even if the product is deleted.

[h2]setSignatureAlgorithm

Method

public void setSignatureAlgorithm(String signatureAlgorithm)

Optional. Sets the signature algorithm.

Parameters

Name

Description

signatureAlgorithm

Signature algorithm, which is optional. If a signature algorithm is passed, IAP will use it to sign order data.

Currently, the value can only be SIGNATURE_ALGORITHM_SHA256WITHRSA_PSS, which indicates the SHA256WithRSA/PSS algorithm.

NOTE:

If no signature algorithm is passed, IAP will use the SHA256WithRSA algorithm by default to sign purchase data.

CAUTION:

For server-side signature verification, you can use the signatureAlgorithm field and set it to SHA256WithRSA/PSS, while for client-side signature verification, the signatureAlgorithm field is not allowed.