Integrate with Enhance - Defold
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.
Example Usage
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()
Return Value:
Returns true
if available, false
otherwise.
enhance.attemptPurchase
nil enhance.attemptPurchase(
string productName,
function onPurchaseSuccessCallback,
function onPurchaseFailedCallback
)
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
)
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
)
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
)
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
)
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
)
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
)
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
)
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.