Functions and constants for interacting with Apple's In-app purchases and Google's In-app billing.

Static methods

staticbuy(id:String, ?options:IapBuyOptions):Void

Perform a product purchase.

Calling Iap.finish is required on a successful transaction if auto_finish_transactions is disabled in project settings.

Parameters:

id

product to buy

options

table of optional parameters as properties.

staticbuy_premium():Void

Purchase a premium license.

Performs a purchase of a premium game license. The purchase transaction is handled like regular iap purchases; calling the currently se iap_listener with the transaction results.

This function does not work when testing the application locally in the Gameroom client.

staticfinish(transaction:IapTransaction):Void

Finish buying product.

Explicitly finish a product transaction.

Calling Iap.finish is required on a successful transaction if auto_finish_transactions is disabled in project settings. Calling this function with auto_finish_transactions set will be ignored and a warning is printed. The transaction.state field must equal IapTransactionState.TRANS_STATE_PURCHASED.

Parameters:

transaction

transaction table parameter as supplied in listener callback

staticget_provider_id():IapProviderId

Get current provider id.

Returns:

provider id.

statichas_premium<T>(callback:(self:T, has_premium:Bool) ‑> Void):Void

Check if user has already purchased premium license.

Checks if a license for the game has been purchased by the user. You should provide a callback function that will be called with the result of the check.

This function does not work when testing the application locally in the Gameroom client.

Parameters:

callbackresult

callback

staticlist<T>(ids:Table<Int, String>, callback:(self:T, products:Table<String, IapProduct>, error:Null<IapError>) ‑> Void):Void

List in-app products.

Nested calls, that is calling Iap.list from within the callback is not supported. Doing so will result in call being ignored with the engine reporting "Unexpected callback set".

Parameters:

ids

table to get information about

callback

result callback

staticrestore():Bool

Restore products (non-consumable).

Returns:

true if current store supports handling restored transactions, otherwise false.

staticset_listener<T>(listener:(self:T, transaction:IapTransaction, error:Null<IapError>) ‑> Void):Void

Set purchase transaction listener.

The listener callback has the following signature: function(self, transaction, error) where transaction is a table describing the transaction and error is a table. The error parameter is nil on success.

Parameters:

listener

listener function