Integrate with Enhance - Cordova
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 callback = function() { var onPurchaseSuccess = function() { Enhance.purchases.getDisplayTitle('my_product', 'My product', function(result) { alert(result); }); }; var onPurchaseFailed = function() { // Failure }; Enhance.purchases.attemptPurchase('my_product', onPurchaseSuccess, onPurchaseFailed); }; Enhance.purchases.isSupported(callback);
Methods
Enhance.purchases.isSupported
void Enhance.purchases.isSupported(
Function resultCallback
)
Parameters:
Function resultCallback
- Specifices the callback function.
Return Value:
Returns true
to the callback function if available, false
otherwise.
Enhance.purchases.attemptPurchase
void Enhance.purchases.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.purchases.consume
void Enhance.purchases.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.purchases.manuallyRestorePurchases
void Enhance.purchases.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.purchases.isItemOwned
void Enhance.purchases.isItemOwned(
String productName,
Function resultCallback
)
Parameters:
String productName
- The reference name which you entered during the Enhance flow (SKU Mappings).
Function resultCallback
- Specifices the callback function.
Return Value:
Returns true
to the callback function if owned, false
otherwise.
Enhance.purchases.getOwnedItemCount
void Enhance.purchases.getOwnedItemCount(
String productName,
Function resultCallback
)
Parameters:
String productName
- The reference name which you entered during the Enhance flow (SKU Mappings).
Function resultCallback
- Specifices the callback function.
Return Value:
Returns a number of the given product copies to the callback function.
Enhance.purchases.getDisplayPrice
void Enhance.purchases.getDisplayPrice(
String productName,
String defaultPrice,
Function resultCallback
)
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.
Function resultCallback
- Specifices the callback function.
Return Value:
Returns a string containing the localized display price to the callback function.
Enhance.purchases.getDisplayTitle
void Enhance.purchases.getDisplayTitle(
String productName,
String defaultTitle,
Function resultCallback
)
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.
Function resultCallback
- Specifices the callback function.
Return Value:
Returns a string containing the localized display title to the callback function.
Enhance.purchases.getDisplayDescription
void Enhance.purchases.getDisplayDescription(
String productName,
String defaultDescription,
Function resultCallback
)
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.
Function resultCallback
- Specifices the callback function.
Return Value:
Returns a string containing the localized display description to the callback function.