Integrate with Enhance - Xamarin
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
private 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."); } private void OnPurchaseFailed() { // 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,
Action onPurchaseSuccessCallback,
Action onPurchaseFailedCallback
)
Parameters:
string productName
- The reference name which you entered during the Enhance flow (SKU Mappings).
Action onPurchaseSuccessCallback
- Called when a purchase is finished successfully.
Action onPurchaseFailedCallback
- Called when a purchase failed for any reason.
Enhance.Purchases.Consume
void Enhance.Purchases.Consume(
string productName,
Action onConsumeSuccessCallback,
Action onConsumeFailedCallback
)
Parameters:
string productName
- The reference name which you entered during the Enhance flow (SKU Mappings).
Action onConsumeSuccessCallback
- Called when a consume is finished successfully.
Action onConsumeFailedCallback
- Called when a consume failed for any reason.
Enhance.Purchases.ManuallyRestorePurchases
void Enhance.Purchases.ManuallyRestorePurchases(
Action onRestoreSuccessCallback,
Action onRestoreFailedCallback
)
Parameters:
Action onRestoreSuccessCallback
- Called when a restore is finished successfully.
Action 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.