Class CodelessIAPStoreListener
Initializes Unity IAP with the Product
s defined in the default IAP ProductCatalog.
Automatically initializes at runtime load when enabled in the GUI. enableCodelessAutoInitialization
Manages IAPButton
s and IAPListener
s.
Namespace: UnityEngine.Purchasing
Syntax
public class CodelessIAPStoreListener : IStoreListener
Fields
catalog
For adding ProductDefinition
this default ProductCatalog
is
loaded from the Project
when I am instantiated.
Declaration
protected ProductCatalog catalog
Field Value
Type | Description |
---|---|
ProductCatalog |
controller
For advanced scripted IAP actions, use this session's IStoreController
after initialization.
Declaration
protected IStoreController controller
Field Value
Type | Description |
---|---|
IStoreController |
extensions
For advanced scripted store-specific IAP actions, use this session's IExtensionProvider
after initialization.
Declaration
protected IExtensionProvider extensions
Field Value
Type | Description |
---|---|
IExtensionProvider |
initializationComplete
Allows outside sources to know whether the successful initialization has completed.
Declaration
public static bool initializationComplete
Field Value
Type | Description |
---|---|
Boolean |
Properties
ExtensionProvider
For advanced scripted store-specific IAP actions, use this session's IExtensionProvider
after initialization.
Declaration
public IExtensionProvider ExtensionProvider { get; }
Property Value
Type | Description |
---|---|
IExtensionProvider |
Instance
Singleton of me. Initialized on first access.
Also initialized by RuntimeInitializeOnLoadMethod if ProductCatalog.enableCodelessAutoInitialization.enableCodelessAutoInitialization
is true.
Declaration
public static CodelessIAPStoreListener Instance { get; }
Property Value
Type | Description |
---|---|
CodelessIAPStoreListener |
StoreController
For advanced scripted IAP actions, use this session's IStoreController
after
initialization.
Declaration
public IStoreController StoreController { get; }
Property Value
Type | Description |
---|---|
IStoreController |
Methods
AddButton(IAPButton)
Register an IAPButton
to send IAP initialization and purchasing events.
Use to making IAP functionality visible to the user.
Declaration
public void AddButton(IAPButton button)
Parameters
Type | Name | Description |
---|---|---|
IAPButton | button | The |
AddListener(IAPListener)
Register an IAPListener
to send IAP purchasing events.
Declaration
public void AddListener(IAPListener listener)
Parameters
Type | Name | Description |
---|---|---|
IAPListener | listener | Listener to receive IAP purchasing events |
GetProduct(String)
Access a Product
for this app.
Declaration
public Product GetProduct(string productID)
Parameters
Type | Name | Description |
---|---|---|
String | productID | A product identifier to find as a |
Returns
Type | Description |
---|---|
Product | A |
HasProductInCatalog(String)
Inspect my ProductCatalog
for a product identifier.
Declaration
public bool HasProductInCatalog(string productID)
Parameters
Type | Name | Description |
---|---|---|
String | productID | Product identifier to look for in catalog. Note this is not the store-specific identifier. |
Returns
Type | Description |
---|---|
Boolean | Whether this identifier exists in catalog |
InitiatePurchase(String)
Purchase a product by its identifier.
Sends purchase failure event with PurchaseFailureReason.PurchasingUnavailable.PurchasingUnavailable
to all registered IAPButtons if not yet successfully initialized.
Declaration
public void InitiatePurchase(string productID)
Parameters
Type | Name | Description |
---|---|---|
String | productID | Product identifier of |
OnInitialized(IStoreController, IExtensionProvider)
Implementation of UnityEngine.Purchasing.IStoreListener.OnInitialized.Purchasing.IStoreListener.OnInitialized
which captures
successful IAP initialization results and refreshes all registered IAPButton
s.
Declaration
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
Parameters
Type | Name | Description |
---|---|---|
IStoreController | controller | Set as the current IAP session's single |
IExtensionProvider | extensions | Set as the current IAP session's single |
Implements
OnInitializeFailed(InitializationFailureReason)
Implementation of UnityEngine.Purchasing.IStoreListener.OnInitializeFailed.Purchasing.IStoreListener.OnInitializeFailed
which
logs the failure reason.
Declaration
public void OnInitializeFailed(InitializationFailureReason error)
Parameters
Type | Name | Description |
---|---|---|
InitializationFailureReason | error | Reported in the app log |
Implements
OnPurchaseFailed(Product, PurchaseFailureReason)
Implementation of UnityEngine.Purchasing.IStoreListener.OnPurchaseFailed.Purchasing.IStoreListener.OnPurchaseFailed
indicating
a purchase failed with specified reason. Send this event to any appropriate registered
IAPButton
s and IAPListener
s.
Logs an error if there are no appropriate registered handlers.
Declaration
public void OnPurchaseFailed(Product product, PurchaseFailureReason reason)
Parameters
Type | Name | Description |
---|---|---|
Product | product | What failed to purchase |
PurchaseFailureReason | reason | Why the purchase failed |
Implements
ProcessPurchase(PurchaseEventArgs)
Implementation of UnityEngine.Purchasing.IStoreListener.ProcessPurchase.Purchasing.IStoreListener.ProcessPurchase
which forwards
this successful purchase event to any appropriate registered IAPButton
s and
IAPListener
s. Logs an error if there are no appropriate registered handlers.
Declaration
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PurchaseEventArgs | e | Data for this purchase |
Returns
Type | Description |
---|---|
PurchaseProcessingResult | Any indication of whether this purchase has been completed by any of my appropriate registered
|
Implements
RemoveButton(IAPButton)
Stop sending initialization and purchasing events to an IAPButton
. Use when disabling
the button, e.g. when closing a scene containing that button and wanting to prevent the user from making any
IAP events for its product.
Declaration
public void RemoveButton(IAPButton button)
Parameters
Type | Name | Description |
---|---|---|
IAPButton | button |
RemoveListener(IAPListener)
Unregister an IAPListener
from IAP purchasing events.
Declaration
public void RemoveListener(IAPListener listener)
Parameters
Type | Name | Description |
---|---|---|
IAPListener | listener | Listener to no longer receive IAP purchasing events |