Module: iap
Table of contents
Functions
Functions
consumePurchaseAsync
▸ consumePurchaseAsync(token
): Promise
<void
>
Consumes the given purchase. This will remove the purchase from the player's available purchases inventory and reset its availability in the catalog.
Example
Parameters
Name | Type | Description |
---|---|---|
token |
string |
String representing the purchaseToken of the item to consume. |
Returns
Promise
<void
>
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
getCatalogAsync
▸ getCatalogAsync(): Promise
<Product
[]>
Gets the catalog of available products the player can purchase.
Example
Returns
Promise
<Product
[]>
Array of products available to the player. Returns an empty list if purchases are not supported in the player's region.
Throws
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
getPurchasesAsync
▸ getPurchasesAsync(): Promise
<Purchase
[]>
Gets the purchases the player has made that have not yet been consumed. Purchase signature should be validated on the game developer's server or transaction database before provisioning the purchase to the player.
Example
Returns
Promise
<Purchase
[]>
Array of purchases.
Throws
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
isEnabled
▸ isEnabled(): boolean
Checks whether IAP is enabled in this session.
Returns
boolean
True if IAP is available to the user. False if IAP is not supported on the current platform, the player's device, or the IAP service failed to load properly.
makePurchaseAsync
▸ makePurchaseAsync(purchase
): Promise
<Purchase
>
Attempts to make a purchase of the given product. Will launch the native IAP screen and return the result.
Example
Wortal.iap.makePurchaseAsync({
productID: 'my_product_123',
}).then(purchase => console.log(purchase));
Parameters
Name | Type | Description |
---|---|---|
purchase |
PurchaseConfig |
Object defining the product ID and purchase information. |
Returns
Promise
<Purchase
>
Information about the purchase.
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM