Simple IAP System  4.3
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Events | List of all members
IAPManager

Unity IAP cross-platform wrapper for real money purchases, as well as for virtual ingame purchases (for virtual currency). Initializes the Unity IAP billing system, handles different store interfaces and integrates their callbacks respectively. More...

Inheritance diagram for IAPManager:

Public Member Functions

void Initialize ()
 Initializes the IAP service with a platform-dependant billing connection. More...
 
void OnSceneWasLoaded (Scene scene, LoadSceneMode m)
 Detect and initiate the ShopManager initialization on scene changes. More...
 
void OnInitialized (IStoreController ctrl, IExtensionProvider ext)
 Initialization callback of Unity IAP. Optionally: verify old purchases online. Once we've received the product list, we overwrite the existing shop item values with this online data. More...
 
PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e)
 This will be called when a purchase completes. Optional: verify new product receipt. More...
 
void PurchaseVerified (string id)
 Sets a product to purchased after successful verification (or without). This alters the database entry for non-consumable or products with usage as well. More...
 
void OnInitializeFailed (InitializationFailureReason error)
 Callback of Unity IAP returning why the store could not be initialized to begin with. More...
 
void OnPurchaseFailed (Product item, PurchaseFailureReason reason)
 This will be called when an attempted purchase fails. More...
 

Static Public Member Functions

static IAPManager GetInstance ()
 Returns a static reference to this script. More...
 
static void PurchaseProduct (string productId)
 Purchase product based on its product id. If the productId matches "restore", we restore transactions instead. Our delegates then fire the appropriate succeeded/fail/restore event. More...
 
static void PurchaseProduct (IAPObject obj)
 Overload for purchasing virtual product based on its product identifier. More...
 
static void RestoreTransactions ()
 Restore already purchased user's transactions for non consumable IAPs. More...
 
static void OnTransactionsRestored (bool success)
 Callback invoked after initiating a restore attempt. More...
 
static void OnPurchaseFailed (string error)
 Overload for failed purchases with string error message. More...
 
static List< string > GetIAPUpgrades (string productId)
 Returns a list of all upgrade ids associated to a product. More...
 
static string GetCurrentUpgrade (string productId)
 Returns the last purchased upgrade id of a product, or the main product itself if it hasn't been purchased yet. More...
 
static string GetNextUpgrade (string productId)
 Returns the next unpurchased upgrade id of a product. More...
 
static string GetIAPIdentifier (string storeId)
 Returns the global identifier of an in-app product, specified in the IAP Settings editor. More...
 
static List< IAPCurrencyGetCurrencies ()
 Returns the list of currencies defined in the IAP Settings editor. More...
 
static ProductDefinition[] GetProductDefinitions ()
 Returns the list of products used when initializing Unity IAP. More...
 
static string[] GetIAPKeys ()
 Returns a string array of all IAP ids. Used by DBManager. More...
 
static string[] GetRealKeys ()
 Returns a string array of all real money IAP ids only. More...
 
static IAPObject GetIAPObject (string id)
 Returns the IAPObject with a specific id. More...
 
static string GetIAPObjectGroupName (string id)
 Returns the group name of a specific product id. Used by DBManager. More...
 

Public Attributes

bool autoInitialize = true
 Toggle that defines whether the IAPManager should initialize itself on first load. More...
 
StoreKeys storeKeys = new StoreKeys()
 Keys required for some store initialization processes. More...
 
List< IAPGroupIAPs = new List<IAPGroup>()
 In app products, set in the IAP Settings editor More...
 
List< IAPCurrencycurrencies = new List<IAPCurrency>()
 list of virtual currency, set in the IAP Settings editor More...
 
Dictionary< string, IAPObjectIAPObjects = new Dictionary<string, IAPObject>()
 dictionary of product ids, mapped to the corresponding IAPObject for quick lookup More...
 

Static Public Attributes

static bool isDebug = false
 Debug messages are enabled in Development build automatically. More...
 
static IStoreController controller
 
static IExtensionProvider extensions
 

Events

static Action< string > purchaseSucceededEvent
 fired when a purchase succeeds, delivering its product id More...
 
static Action< string > purchaseFailedEvent
 fired when a purchase fails, delivering its product id More...
 

Detailed Description

Unity IAP cross-platform wrapper for real money purchases, as well as for virtual ingame purchases (for virtual currency). Initializes the Unity IAP billing system, handles different store interfaces and integrates their callbacks respectively.

Member Function Documentation

static List<IAPCurrency> GetCurrencies ( )
static

Returns the list of currencies defined in the IAP Settings editor.

static string GetCurrentUpgrade ( string  productId)
static

Returns the last purchased upgrade id of a product, or the main product itself if it hasn't been purchased yet.

static string GetIAPIdentifier ( string  storeId)
static

Returns the global identifier of an in-app product, specified in the IAP Settings editor.

static string [] GetIAPKeys ( )
static

Returns a string array of all IAP ids. Used by DBManager.

static IAPObject GetIAPObject ( string  id)
static

Returns the IAPObject with a specific id.

static string GetIAPObjectGroupName ( string  id)
static

Returns the group name of a specific product id. Used by DBManager.

static List<string> GetIAPUpgrades ( string  productId)
static

Returns a list of all upgrade ids associated to a product.

static IAPManager GetInstance ( )
static

Returns a static reference to this script.

static string GetNextUpgrade ( string  productId)
static

Returns the next unpurchased upgrade id of a product.

static ProductDefinition [] GetProductDefinitions ( )
static

Returns the list of products used when initializing Unity IAP.

static string [] GetRealKeys ( )
static

Returns a string array of all real money IAP ids only.

void Initialize ( )

Initializes the IAP service with a platform-dependant billing connection.

void OnInitialized ( IStoreController  ctrl,
IExtensionProvider  ext 
)

Initialization callback of Unity IAP. Optionally: verify old purchases online. Once we've received the product list, we overwrite the existing shop item values with this online data.

void OnInitializeFailed ( InitializationFailureReason  error)

Callback of Unity IAP returning why the store could not be initialized to begin with.

void OnPurchaseFailed ( Product  item,
PurchaseFailureReason  reason 
)

This will be called when an attempted purchase fails.

static void OnPurchaseFailed ( string  error)
static

Overload for failed purchases with string error message.

void OnSceneWasLoaded ( Scene  scene,
LoadSceneMode  m 
)

Detect and initiate the ShopManager initialization on scene changes.

static void OnTransactionsRestored ( bool  success)
static

Callback invoked after initiating a restore attempt.

PurchaseProcessingResult ProcessPurchase ( PurchaseEventArgs  e)

This will be called when a purchase completes. Optional: verify new product receipt.

static void PurchaseProduct ( string  productId)
static

Purchase product based on its product id. If the productId matches "restore", we restore transactions instead. Our delegates then fire the appropriate succeeded/fail/restore event.

static void PurchaseProduct ( IAPObject  obj)
static

Overload for purchasing virtual product based on its product identifier.

void PurchaseVerified ( string  id)

Sets a product to purchased after successful verification (or without). This alters the database entry for non-consumable or products with usage as well.

static void RestoreTransactions ( )
static

Restore already purchased user's transactions for non consumable IAPs.

Member Data Documentation

bool autoInitialize = true

Toggle that defines whether the IAPManager should initialize itself on first load.

IStoreController controller
static
List<IAPCurrency> currencies = new List<IAPCurrency>()

list of virtual currency, set in the IAP Settings editor

IExtensionProvider extensions
static
Dictionary<string, IAPObject> IAPObjects = new Dictionary<string, IAPObject>()

dictionary of product ids, mapped to the corresponding IAPObject for quick lookup

List<IAPGroup> IAPs = new List<IAPGroup>()

In app products, set in the IAP Settings editor

bool isDebug = false
static

Debug messages are enabled in Development build automatically.

StoreKeys storeKeys = new StoreKeys()

Keys required for some store initialization processes.

Event Documentation

Action<string> purchaseFailedEvent
static

fired when a purchase fails, delivering its product id

Action<string> purchaseSucceededEvent
static

fired when a purchase succeeds, delivering its product id


The documentation for this class was generated from the following file: