Class: IapApi

iap.IapApi

In-app-purchase wrapper class. Handles product query and purchases.

Constructors

constructor

new IapApi(client): IapApi

Parameters

Name Type
client Client

Returns

IapApi

Properties

client

Private client: Client


qsIAP

Private Optional qsIAP: QSIapApi


viberPrepare

viberPrepare: () => Promise<boolean>

Type declaration

▸ (): Promise<boolean>

Returns

Promise<boolean>

Methods

consumePurchase

consumePurchase(purchaseToken): Promise<void>

Consumes a specific purchase belonging to the player. Before provisioning a product’s effects to the player, the game should request the consumption of the purchased product. Once the purchase is successfully consumed, the game should immediately provide the player with the effects of their purchase.

Parameters

Name Type Description
purchaseToken string The purchase token of the purchase that should be consumed

Returns

Promise<void>


getCatalog

getCatalog(): Promise<Product[]>

Get a list of all products registered for the game.

Returns

Promise<Product[]>


getPurchases

getPurchases(): Promise<Purchase[]>

Get all of the player’s unconsumed purchases. As a best practice, the game should fetch the player’s purchases as soon as the client indicates that it is ready to perform payments-related operations, ie. the prepare call has resolved. The game can then process and consume any purchases that are waiting to be consumed.

Returns

Promise<Purchase[]>


isSupported

isSupported(): boolean

Are in-app-purchases supported on the current platform.

Returns

boolean


log

log(event, parameters): void

Parameters

Name Type
event string
parameters Object

Returns

void


prepare

prepare(): Promise<boolean>

Prepare any required systems for in-app-purchases. Resolves with false if in-app-purchases are not supported and true if they are.

Returns

Promise<boolean>


purchase

purchase(config): Promise<null | Purchase>

Begins the purchase flow for a specific product. Only unknown exception are thrown, if the user cancels the purchase the function will resolve with null.

Parameters

Name Type
config PurchaseConfig

Returns

Promise<null | Purchase>