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 function onPurchaseSuccess():void {
    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.");
}

private function onPurchaseFailed():void {
    // Failure
}

private function purchase():void {
    if (Enhance.purchases.isSupported()) {
        Enhance.purchases.attemptPurchase("my_product", onPurchaseSuccess, onPurchaseFailed);
    } 
}

Methods

Enhance.purchases.isSupported

Boolean 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,
    Function onPurchaseSuccessCallback,
    Function onPurchaseFailedCallback
)

Start the purchase flow for the given product.

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
)

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

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
)

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

Parameters:

Function  onRestoreSuccessCallback - Called when a restore is finished successfully.

Function  onRestoreFailedCallback - Called when a restore failed for any reason.

Enhance.purchases.isItemOwned

Boolean 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.