Skip to main content
Samsung Developer Program

Inventory

OpenIAB class functions for currently available in-app items

public class Inventory

This class is a container for items currently available in store listings.

Inventory Fields

Modifier and Type

Field

private Dictionary<String, SkuDetails>

_skuMap

Map of SKU item names and their details.

private Dictionary<String, Purchase>

_purchaseMap

Map of purchased items and their details.

Inventory Constructor Summary

Modifier

Constructor

public

Inventory(string json)

public

Inventory()

Inventory Constructor Details

Inventory

public Inventory()

Creates an Inventory instance.

This method is only used for WP8.

Inventory

public Inventory(string json)

Creates an Inventory instance using the specified JSON string.

The method parses the JSON string, converts the elements into Purchase and SkuDetails objects, and then maps these data to the _skuMap and _purchaseMap.

Parameters:

json  String object that contains the inventory details in JSON format

Inventory Method Summary

Modifier and Type

Method

public override

string ToString()

public SkuDetails

GetSkuDetails(string sku)

public Purchase

GetPurchase(string sku)

public bool

HasPurchase(string sku)

public bool

HasDetails(string sku)

public void

ErasePurchase(string sku)

public List<string>

GetAllOwnedSkus()

public List<string>

GetAllOwnedSkus(string itemType)

public List<Purchase>

GetAllPurchases()

public List<SkuDetails>

GetAllAvailableSkus()

public void

AddSkuDetails(SkuDetails d)

public void

AddPurchase(Purchase p)

Inventory Method Details

ToString

public override string ToString()

Returns a string of the purchase map and SKU map.

Returns:

A string containing the purchase map and SKU map.

GetSkuDetails

public SkuDetailsGetSkuDetails(string sku)

Get the details of the specified SKU item.

Parameters:

sku

SKU identifier of the item

Returns:

SkuDetails of the specified SKU when the SKU exists in the _skuMap. Returns null when the SKU does not exist.

GetPurchase

public Purchase GetPurchase(string sku)

Gets purchase information for the specified SKU item.

Parameters:

sku SKU identifier of the item

Returns:

Returns purchase information for the specified item. Returns null when there is no purchase.

HasPurchase

public Purchase HasPurchase(string sku)

Determines whether or not a purchase exists of the specified SKU item, and returns the results.

Parameters:

sku

SKU identifier of the item

Returns:

Returns true when a purchase for the item exists. Returns false otherwise.

HasDetails

public boolHasDetails(string sku)

Determines whether or not details exist about the specified SKU item, and returns the results.

Parameters:

sku

SKU identifier of the item

Returns:

Returns true when item details are available. Returns false otherwise.

ErasePurchase

public void ErasePurchase(string sku)

Deletes the purchase information of the specified SKU item from the inventory.

Parameters:

sku

SKU identifier of the item

GetAllOwnedSkus()

public List<string> GetAllOwnedSkus()

Gets the list of all purchased item SKUs by the user.

Returns:

Returns a list of all purchased item SKUs.

GetAllOwnedSkus

public List<string> GetAllOwnedSkus(string itemType)

Gets the list of all item SKUs of the specified item type that were purchased by the user.

Parameters:

itemType

Type of item:

inapp            Consumable or non-consumable item

subs              Non-recurring or auto-recurring subscription item

Returns:

Returns a list of all purchased SKUs of the requested item type.

GetAllPurchases

public List<Purchase> GetAllPurchases()

Gets all item SKUs purchased by the user.

Returns:

Returns a list of all SKUs in the _purchaseMap.

GetAllAvailableSkus

public List<SkuDetails> GetAllAvailableSkus()

Gets the SKUs of all available items.

Returns:

Returns a list of SKUs of all items available for purchase.

AddSkuDetails

public void AddSkuDetails(SkuDetails d)

Adds the item details in the specified object instance to the associated SkuDetails.

Parameters:

d

Name of the SKU details object instance

AddPurchase

public void AddPurchase(Purchase p)

Adds the purchase details in the specified object instance to the associated SKU item.

Parameters:

p

Name of the Purchase object instance

  • Was this article helpful?