Home


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.

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()

Check if the In-App Payments support is currently available in your app.

Return Value:

Returns true if available, false otherwise.

Enhance.Purchases.AttemptPurchase

void Enhance.Purchases.AttemptPurchase(
    string productName,
    Action onPurchaseSuccessCallback,
    Action onPurchaseFailedCallback
)

Start the purchase flow for the given product.

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
)

Consume the given product, if applicable (availability of this feature depends on the SDK provider, not all support consumable goods).

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
)

Manually restore purchases and update the user's inventory, if applicable (availability of this feature depends on the SDK provider).

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
)

Check if the given product is already owned. The result may be inaccurate, depending on whether the SDK provider stores the information about your products or not.

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
)

Get a number of the given product that user owns, or 0 if none. The result may be inaccurate, depending on whether the SDK provider stores the information about your products or not.

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
)

Get a localized display price of the given product, for example: "100zł", "100¥".

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
)

Get a localized display title of the given product.

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
)

Get a localized display description of the given product.

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.