Integrate with Enhance - Native Android
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
if (Enhance.purchases.isSupported()) { Enhance.purchases.attemptPurchase("my_product", new EnhanceInAppPurchases.PurchaseCallback() { @Override public void onPurchaseSuccess() { String price = Enhance.purchases.getDisplayPrice("my_product", "$5"); String title = Enhance.purchases.getDisplayTitle("my_product", "My Product"); String desc = Enhance.purchases.getDisplayDescription("my_product", "Some useful item."); } @Override public void onPurchaseFailed() { // Failure } }); }
Methods
Enhance.purchases.isSupported
boolean Enhance.purchases.isSupported()
Return Value:
Returns true
if available, false
otherwise.
Enhance.purchases.attemptPurchase
void Enhance.purchases.attemptPurchase(
String productName,
EnhanceInAppPurchases.PurchaseCallback callbacks
)
Parameters:
String productName
- The reference name which you entered during the Enhance flow (SKU Mappings).
EnhanceInAppPurchases.PurchaseCallback callbacks
- Specifies the callback object. (For more information about the EnhanceInAppPurchases.PurchaseCallback
type, see the Interfaces section)
Enhance.purchases.consume
void Enhance.purchases.consume(
String productName,
EnhanceInAppPurchases.ConsumeCallback callbacks
)
Parameters:
String productName
- The reference name which you entered during the Enhance flow (SKU Mappings).
EnhanceInAppPurchases.ConsumeCallback callbacks
- Specifies the callback object. (For more information about the EnhanceInAppPurchases.ConsumeCallback
type, see the Interfaces section)
Enhance.purchases.manuallyRestorePurchases
void Enhance.purchases.manuallyRestorePurchases(
EnhanceInAppPurchases.RestoreCallback callbacks
)
Parameters:
EnhanceInAppPurchases.RestoreCallback callbacks
- Specifies the callback object. (For more information about the EnhanceInAppPurchases.RestoreCallback
type, see the Interfaces section)
Enhance.purchases.isItemOwned
boolean 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.
Interfaces
interface EnhanceInAppPurchases.PurchaseCallback {
void onPurchaseSuccess();
void onPurchaseFailed();
}
interface EnhanceInAppPurchases.ConsumeCallback {
void onConsumeSuccess();
void onConsumeFailed();
}
interface EnhanceInAppPurchases.RestoreCallback {
void onRestoreSuccess();
void onRestoreFailed();
}