Skip to main content
Samsung Developer Program

OpenIAB

 

public class OpenIAB

This is the main class for OpenIAB functions. This class creates the OpenIAB plugin billing instance using the OpenIAB interface based on the current platform (Android™, iOS®, or Windows Phone 8). The methods from this class use the Java® Native Interface to access the methods in the UnityPlugin.java source code.

OpenIAB Constructor Summary

Modifier

Constructor

static

OpenIAB()

OpenIAB Constructor Details

static OpenIAB()

This static constructor initializes the OpenIAB plugin billing instance based on the current platform, which is determined based on the Unity preprocessor, for example, #if UNITY_ANDROID – OpenIAB_Android.

OpenIAB Fields

Modifier Field and Description
static IOpenIAB

_billing

The static OpenIAB plugin billing instance created based on the current platform.

OpenIAB Method Summary

Modifier and Type

Method

public static void

mapSku(string sku, string storeName, string storeSku)

public static void

init(Options options)

public static void

unbindService()

public static bool

areSubscriptionsSupported()

public static void

queryInventory(params object[] extraParams)

public static void

queryInventory(string[] skus, params object[] extraParams)

public static void

purchaseProduct(string sku, string developerPayload = "")

public static void

purchaseSubscription(string sku, string developerPayload = "")

public static void

consumeProduct(Purchase purchase)

public static void

restoreTransactions()

public static void

samsungIapMode (int mode)

public static void

samsungForcedMode(boolean enabled)

public static bool

isDebugLog()

public static void

enableDebugLogging(bool enabled)

public static void

enableDebugLogging(bool enabled, string tag)

public static void

querySkuList()

public static void

querySkuList(string skuType)

OpenIAB Method Details

mapSku

public static void mapSku(string sku, string storeName, string storeSku)

This method initializes the app store items by mapping the store items to the supported stores. 

NOTE: When a commercial item's app store SKUs are the same for all app stores, do not use the mapSku API call for that commercial item.

This API method must be called ONLY before init().

Parameters:

sku

SKU identifier of the item specified in the Unity plugin code

storeName

App store name, for example, STORE_SAMSUNG

storeSku

Combination of the item group ID and the item ID. For Samsung IAP version 4.0.1, use only the item ID, because itemgroupID  has been deprecated.

Examples:

Prepare the sku parameter:

public const string SKU_PLANE_FUEL = "sku_plane_fuel";
public const string SKU_CHANGE_PLANE = "sku_change_plane";

Use with the storeName and the storeSKU parameters respectively:

// Samsung IAP ver. 3 doesn't require the twelve digit itemGroupID
// but it can still be used as shown with SKU_PLANE_FUEL
OpenIAB.mapSku(SKU_PLANE_FUEL, OpenIAB_Android.STORE_SAMSUNG, "100000105847/sku_plane_fuel");
​OpenIAB.mapSku(SKU_CHANGE_PLANE, OpenIAB_Android.STORE_SAMSUNG, "sku_change_plane");
init

public static void init(Options options)

Starts the billing service. This will fire the appropriate event (billingSupportedEvent or billingNotSupportedEvent) after checking if in-app billing is supported.

The Options object specifies options for the billing service (such as preferred app store names, available app store names, app store search strategy).

For field details, see Option Fields.

Parameters:                 

options

OpenIAB library options object

Example:

Prior to calling this method, set the OpenIAB library options first using the Options class, and then set this as the parameter for the OpenIAB plugin billing instance initialization.

OpenIAB.init(options);
unbindService

public static void unbindService()

Unbinds and shuts down the billing service. 
areSubscriptionsSupported

public static boolareSubscriptionsSupported()

Determines whether or not subscription items are supported.

NOTE: Currently, this API call is only used by Android™ service apps.

Returns:

Returns true when subscription items are supported. Returns false otherwise.

queryInventory

public static void queryInventory(params object[] extraParams)

Saves all completed purchases in _purchaseMap and saves all available items in _skuMap.

Parameters:

extraParams

List of purchase parameters in addition to the basic parameters. This allows the use of variable number of parameters to support Samsung IAP 4.0.1’s cached inbox list by passing the string "true" as an extra parameter (i.e., cached query inventory). Other app stores do not make use of this extra parameter.

Extra parameter to be added:

true           will not save anything in _purchaseMap

false          saves in _purchaseMap all purchased items except for consumable items

Example:

public const string SKU_PLANE_FUEL = "sku_plane_fuel";
public const string SKU_CHANGE_PLANE = "sku_change_plane";
public const string SKU_INFINITE_FUEL = "sku_infinite_fuel";
public const string SKU_GHOST_MODE = "sku_ghost_mode";

private string[] skuList = new string[] { SKU_PLANE_FUEL, SKU_CHANGE_PLANE, SKU_INFINITE_FUEL, SKU_GHOST_MODE };
OpenIAB.queryInventory(skuList);
queryInventory (SKUs)

public static void queryInventory(string[] skus, params object[] extraParams)

Saves all completed purchases in _purchaseMap and saves all available items in _skuMap. 

Parameters:

skus

List of SKU identifiers of the items that will be included in the _purchaseMap

extraParams

List of purchase parameters in addition to the basic parameters. This allows the use of variable number of parameters to support Samsung IAP 4.0.1’s cached inbox list by passing the string "true" as an extra parameter (i.e., cached query inventory). Other app stores do not make use of this extra parameter.

Extra parameter to be added:

true        saves in _purchaseMap all purchased items as specified in the SKU list parameter

false      saves in _purchaseMap all purchased items except for consumable items

Example:

public const string SKU_PLANE_FUEL = "sku_plane_fuel";
public const string SKU_CHANGE_PLANE = "sku_change_plane";
public const string SKU_INFINITE_FUEL = "sku_infinite_fuel";
public const string SKU_GHOST_MODE = "sku_ghost_mode";
private string[] skuList = new string[] { SKU_PLANE_FUEL, SKU_CHANGE_PLANE, SKU_INFINITE_FUEL, SKU_GHOST_MODE };
​OpenIAB.queryInventory(skuList, "true");
purchaseProduct

public static void purchaseProduct(string sku, string developerPayload = "")

Initiates purchase processing of specified non-subscription SKU item (such as consumable and nonconsumable items). 

Parameters:

sku

SKU identifier of the item to be purchased

developerPayload 

Always specified as a blank string because Samsung IAP does not currently support developer payload

Example:

OpenIAB.purchaseProduct(SKU_PLANE_FUEL);
OpenIAB.purchaseProduct(SKU_CHANGE_PLANE);
purchaseSubscription

public static void purchaseSubscription(string sku, string developerPayload = "")

Initiates purchase processing of the specified subscription SKU item (such as non-recurring and auto-recurring subscription items).

Parameters:

sku

SKU identifier of the item to be purchased

developerPayload 

Always specified as a blank string because Samsung IAP does not currently support developer payload

consumeProduct

public static void consumeProduct(Purchase purchase)

Sends a request to consume the product specified in the Purchase object instance. This method is supported by OpenIAB but currently is not applicable to Samsung IAP.

Parameters:

purchase

Purchase object instance of the purchased item

restoreTransactions

public static void restoreTransactions(Purchase purchase)

Restores purchased items specified in the Purchase object instance. This method is supported by OpenIAB but currently is not applicable to Android because this is an iOS® App Store requirement.

Parameters:

purchase

Purchase object instance of the purchased item

samsungIapMode

public static void samsungIapMode (int mode)

Sets the operational mode that controls how API method call requests are processed.

Parameters:

mode

Operational mode to be set:

0           Production mode: Valid requests result in successful transaction including payment processing. Invalid requests result in failure cases.

1           Test mode success: Valid requests result in successful processing EXCEPT for payment processing. Invalid requests result in failure cases.

-1         Test mode failure: ALL requests result in failure cases.

samsungForcedMode

public static void samsungForcedMode(boolean enabled)

Sets the Samsung Galaxy Apps Store as the selected store during OpenIAB initialization for testing purposes.

Parameters:

enabled

Store mode to be set:

true        The Samsung Galaxy Apps Store is selected.

false       The app store selected depends on the options specified in the Options object.

For more details on determining the store search strategy, refer to OpenIAB Unity Plugin Integration.

isDebugLog

public static void isDebugLog()

Determines whether or not verbose logging is enabled and returns the result.

Verbose logging is a logging mode that records more information than the usual logging mode.

The Android logging system provides a way of viewing debug output. LogCat dumps logs that you have written in the source code by using the Log class. LogCat can be run through ADB or from DDMS, which show the Log messages in real time.

Returns:

Returns true when verbose logging is enabled. Returns false otherwise.

enableDebugLogging

public static void enableDebugLogging(bool enabled)

Enables debug logging to get more debug information. 

The Android logging system provides a way of viewing debug output. LogCat dumps logs that you have written in the source code by using the Log class. LogCat can be run through ADB or from DDMS, which show the Log messages in real time.

Parameters:

enabled

Whether or not additional debug information is to be logged:

true                 Debug information will be logged and logs will be displayed in the debug console.

false                Debug information will NOT be logged.

enableDebugLogging (tag)

public static void (bool enabled, string tag)

Enables debug logging to get more debug information using the specified tag.

The Android logging system provides a way of viewing debug output. LogCat dumps logs that you have written in the source code by using the Log class. LogCat can be run through ADB or from DDMS, which show the Log messages in real time.

querySkuList

public static void querySkuList()

Saves in skuDetails all available items for purchase.

querySkuList

public static void querySkuList(string skuType)

Saves in skuDetails all available items for purchase with the specified SKU type.

Parameters:

skuType SKU type to be queried.

 

  • Was this article helpful?