docs.unity3d.com
    Show / Hide Table of Contents

    Class CodelessIAPStoreListener

    Initializes Unity IAP with the Products defined in the default IAP ProductCatalog. Automatically initializes at runtime load when enabled in the GUI. enableCodelessAutoInitialization Manages IAPButtons and IAPListeners.

    Inheritance
    Object
    CodelessIAPStoreListener
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    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

    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 IAPButton

    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 Product

    Returns
    Type Description
    Product

    A Product corresponding to productID, or null if the identifier is not available.

    GetStoreConfiguration<T>()

    For advanced scripted store-specific IAP actions, use this session's IStoreConfigurations. Note, these instances are only available after initialization through Codeless IAP, currently.

    Declaration
    public T GetStoreConfiguration<T>()
        where T : IStoreConfiguration
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    A subclass of IStoreConfiguration such as IAppleConfiguration

    GetStoreExtensions<T>()

    For advanced scripted store-specific IAP actions, use this session's IStoreExtensions after initialization.

    Declaration
    public T GetStoreExtensions<T>()
        where T : IStoreExtension
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    A subclass of IStoreExtension such as IAppleExtensions

    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 Product to be purchased

    OnInitialized(IStoreController, IExtensionProvider)

    Implementation of UnityEngine.Purchasing.IStoreListener.OnInitialized.Purchasing.IStoreListener.OnInitialized which captures successful IAP initialization results and refreshes all registered IAPButtons.

    Declaration
    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    Parameters
    Type Name Description
    IStoreController controller

    Set as the current IAP session's single IStoreController

    IExtensionProvider extensions

    Set as the current IAP session's single IExtensionProvider

    Implements
    IStoreListener.OnInitialized(IStoreController, IExtensionProvider)

    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
    IStoreListener.OnInitializeFailed(InitializationFailureReason)

    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 IAPButtons and IAPListeners. 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
    IStoreListener.OnPurchaseFailed(Product, PurchaseFailureReason)

    ProcessPurchase(PurchaseEventArgs)

    Implementation of UnityEngine.Purchasing.IStoreListener.ProcessPurchase.Purchasing.IStoreListener.ProcessPurchase which forwards this successful purchase event to any appropriate registered IAPButtons and IAPListeners. 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 IAPButtons or IAPListeners

    Implements
    IStoreListener.ProcessPurchase(PurchaseEventArgs)

    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

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023