Integrate with Enhance - OpenFL
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
var onPurchaseSuccess = function() { var price:String = Enhance.purchases.getDisplayPrice("my_product", "$5"); var title:String = Enhance.purchases.getDisplayTitle("my_product", "My Product"); var desc:String = Enhance.purchases.getDisplayDescription("my_product", "Some useful item."); }; var onPurchaseFailed = function() { // Failure }; if (Enhance.purchases.isSupported()) { Enhance.purchases.attemptPurchase("my_product", onPurchaseSuccess, onPurchaseFailed); }
Methods
Enhance.purchases.isSupported
Bool Enhance.purchases.isSupported()
Return Value:
Returns true
if available, false
otherwise.
Enhance.purchases.attemptPurchase
Void Enhance.purchases.attemptPurchase(
String productName,
Void->Void onPurchaseSuccessCallback,
Void->Void onPurchaseFailedCallback
)
Parameters:
String productName
- The reference name which you entered during the Enhance flow (SKU Mappings).
Void->Void onPurchaseSuccessCallback
- Called when a purchase is finished successfully.
Void->Void onPurchaseFailedCallback
- Called when a purchase failed for any reason.
Enhance.purchases.consume
Void Enhance.purchases.consume(
String productName,
Void->Void onConsumeSuccessCallback,
Void->Void onConsumeFailedCallback
)
Parameters:
String productName
- The reference name which you entered during the Enhance flow (SKU Mappings).
Void->Void onConsumeSuccessCallback
- Called when a consume is finished successfully.
Void->Void onConsumeFailedCallback
- Called when a consume failed for any reason.
Enhance.purchases.manuallyRestorePurchases
Void Enhance.purchases.manuallyRestorePurchases(
Void->Void onRestoreSuccessCallback,
Void->Void onRestoreFailedCallback
)
Parameters:
Void->Void onRestoreSuccessCallback
- Called when a restore is finished successfully.
Void->Void onRestoreFailedCallback
- Called when a restore failed for any reason.
Enhance.purchases.isItemOwned
Bool Enhance.purchases.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.purchases.getOwnedItemCount
Int Enhance.purchases.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.purchases.getDisplayPrice
String Enhance.purchases.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.purchases.getDisplayTitle
String Enhance.purchases.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.purchases.getDisplayDescription
String Enhance.purchases.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.