Home





In App Payments

The connector library provides a set of functions which help you to make use of different In-App Payment SDKs in your app.

function on_purchase_success()
    local price = enhance.getDisplayPrice("my_product", "$5")
    local title = enhance.getDisplayTitle("my_product", "My Product")
    local desc = enhance.getDisplayDescription("my_product", "Some useful item.")
end

function on_purchase_failed()
    // Failure
end

function purchase()
    if enhance.iapIsSupported() then
        enhance.attemptPurchase("my_product", on_purchase_success, on_purchase_failed)
    end
end

Methods

enhance.iapIsSupported

boolean enhance.iapIsSupported()

Check if the In-App Payments support is currently available in your app.

Return Value:

Returns true if available, false otherwise.

enhance.attemptPurchase

nil enhance.attemptPurchase(
    string productName,
    function onPurchaseSuccessCallback,
    function onPurchaseFailedCallback
)

Start the purchase flow for the given product.

Parameters:

string  productName - The reference name which you entered during the Enhance flow (SKU Mappings).

function  onPurchaseSuccessCallback - Called when a purchase is finished successfully.

function  onPurchaseFailedCallback - Called when a purchase failed for any reason.

enhance.consume

nil enhance.consume(
    string productName,
    function onConsumeSuccessCallback,
    function onConsumeFailedCallback
)

Consume the given product, if applicable (availability of this feature depends on the SDK provider, not all support consumable goods).

Parameters:

string  productName - The reference name which you entered during the Enhance flow (SKU Mappings).

function  onConsumeSuccessCallback - Called when a consume is finished successfully.

function  onConsumeFailedCallback - Called when a consume failed for any reason.

enhance.manuallyRestorePurchases

nil enhance.manuallyRestorePurchases(
    function onRestoreSuccessCallback,
    function onRestoreFailedCallback
)

Manually restore purchases and update the user's inventory, if applicable (availability of this feature depends on the SDK provider).

Parameters:

function  onRestoreSuccessCallback - Called when a restore is finished successfully.

function  onRestoreFailedCallback - Called when a restore failed for any reason.

enhance.isItemOwned

boolean enhance.isItemOwned(
    string productName
)

Check if the given product is already owned. The result may be inaccurate, depending on whether the SDK provider stores the information about your products or not.

Parameters:

string  productName - The reference name which you entered during the Enhance flow (SKU Mappings).

Return Value:

Returns true if owned, false otherwise.

enhance.getOwnedItemCount

number enhance.getOwnedItemCount(
    string productName
)

Get a number of the given product that user owns, or 0 if none. The result may be inaccurate, depending on whether the SDK provider stores the information about your products or not.

Parameters:

string  productName - The reference name which you entered during the Enhance flow (SKU Mappings).

Return Value:

Returns a number of the given product copies.

enhance.getDisplayPrice

string enhance.getDisplayPrice(
    string productName,
    string defaultPrice
)

Get a localized display price of the given product, for example: "100zł", "100¥".

Parameters:

string  productName - The reference name which you entered during the Enhance flow (SKU Mappings).

string  defaultPrice - Default value, used if the real one cannot be fetched for any reason.

Return Value:

Returns a string containing the localized display price.

enhance.getDisplayTitle

string enhance.getDisplayTitle(
    string productName,
    string defaultTitle
)

Get a localized display title of the given product.

Parameters:

string  productName - The reference name which you entered during the Enhance flow (SKU Mappings).

string  defaultTitle - Default value, used if the real one cannot be fetched for any reason.

Return Value:

Returns a string containing the localized display title.

enhance.getDisplayDescription

string enhance.getDisplayDescription(
    string productName,
    string defaultDescription
)

Get a localized display description of the given product.

Parameters:

string  productName - The reference name which you entered during the Enhance flow (SKU Mappings).

string  defaultDescription - Default value, used if the real one cannot be fetched for any reason.

Return Value:

Returns a string containing the localized display description.