docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class StoreController

    Main controller class that provides a unified interface for store operations, product management, and purchase handling.

    Inheritance
    object
    StoreController
    Implements
    IStoreService
    IProductService
    IPurchaseService
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Purchasing
    Assembly: Unity.Purchasing.dll
    Syntax
    public class StoreController : IStoreService, IProductService, IPurchaseService

    Constructors

    StoreController(string?)

    Initializes a new instance of the StoreController class.

    Declaration
    public StoreController(string? storeName = null)
    Parameters
    Type Name Description
    string storeName

    Optional store name to use for service selection. If null, default services will be used.

    Properties

    AppleStoreExtendedProductService

    Gets the Apple Store extended product service for platform-specific product operations.

    Declaration
    public IAppleStoreExtendedProductService? AppleStoreExtendedProductService { get; }
    Property Value
    Type Description
    IAppleStoreExtendedProductService

    AppleStoreExtendedPurchaseService

    Gets the Apple Store extended purchase service for platform-specific purchase operations.

    Declaration
    public IAppleStoreExtendedPurchaseService? AppleStoreExtendedPurchaseService { get; }
    Property Value
    Type Description
    IAppleStoreExtendedPurchaseService

    AppleStoreExtendedService

    Gets the Apple Store extended store service for platform-specific operations.

    Declaration
    public IAppleStoreExtendedService? AppleStoreExtendedService { get; }
    Property Value
    Type Description
    IAppleStoreExtendedService

    GooglePlayStoreExtendedPurchaseService

    Gets the Google Play Store extended purchase service for platform-specific purchase operations.

    Declaration
    public IGooglePlayStoreExtendedPurchaseService? GooglePlayStoreExtendedPurchaseService { get; }
    Property Value
    Type Description
    IGooglePlayStoreExtendedPurchaseService

    GooglePlayStoreExtendedService

    Gets the Google Play Store extended service for platform-specific operations.

    Declaration
    public IGooglePlayStoreExtendedService? GooglePlayStoreExtendedService { get; }
    Property Value
    Type Description
    IGooglePlayStoreExtendedService

    Methods

    CheckEntitlement(Product)

    Checks the entitlement status for the specified product.

    Declaration
    public void CheckEntitlement(Product product)
    Parameters
    Type Name Description
    Product product

    The product to check entitlement for.

    ConfirmPurchase(PendingOrder)

    Confirms a pending purchase order, completing the transaction.

    Declaration
    public void ConfirmPurchase(PendingOrder order)
    Parameters
    Type Name Description
    PendingOrder order

    The pending order to confirm.

    Connect()

    Establishes a connection to the store asynchronously.

    Declaration
    public Task Connect()
    Returns
    Type Description
    Task

    A task representing the connection operation.

    FetchProducts(List<ProductDefinition>, IRetryPolicy?)

    Fetches product information from the store with optional retry policy.

    Declaration
    public void FetchProducts(List<ProductDefinition> productDefinitions, IRetryPolicy? retryPolicy = null)
    Parameters
    Type Name Description
    List<ProductDefinition> productDefinitions

    The list of product definitions to fetch information for.

    IRetryPolicy retryPolicy

    Optional retry policy to use for failed requests.

    FetchProductsWithNoRetries(List<ProductDefinition>)

    Fetches product information from the store without retry logic.

    Declaration
    public void FetchProductsWithNoRetries(List<ProductDefinition> productDefinitions)
    Parameters
    Type Name Description
    List<ProductDefinition> productDefinitions

    The list of product definitions to fetch information for.

    FetchPurchases()

    Fetches existing purchases from the store.

    Declaration
    public void FetchPurchases()

    GetProductById(string)

    Gets a specific product by its identifier.

    Declaration
    public Product? GetProductById(string productId)
    Parameters
    Type Name Description
    string productId

    The product identifier to search for.

    Returns
    Type Description
    Product

    The product if found, or null if not found.

    GetProducts()

    Gets a read-only collection of all currently loaded products.

    Declaration
    public ReadOnlyObservableCollection<Product> GetProducts()
    Returns
    Type Description
    ReadOnlyObservableCollection<Product>

    A read-only observable collection of products.

    GetPurchases()

    Gets a read-only collection of all completed purchase orders.

    Declaration
    public ReadOnlyObservableCollection<Order> GetPurchases()
    Returns
    Type Description
    ReadOnlyObservableCollection<Order>

    A read-only observable collection of orders.

    ProcessPendingOrdersOnPurchasesFetched(bool)

    Configures whether pending orders should be automatically processed when purchases are fetched.

    Declaration
    public void ProcessPendingOrdersOnPurchasesFetched(bool shouldProcess)
    Parameters
    Type Name Description
    bool shouldProcess

    True to automatically process pending orders, false otherwise.

    Purchase(ICart)

    Initiates a purchase for all items in the specified cart.

    Declaration
    public void Purchase(ICart cart)
    Parameters
    Type Name Description
    ICart cart

    The cart containing items to purchase.

    PurchaseProduct(string?)

    Purchase a product by product id Be sure to first register callbacks via AddPurchasePendingAction and AddPurchaseFailedAction.

    Declaration
    public void PurchaseProduct(string? productId)
    Parameters
    Type Name Description
    string productId

    The product id to purchase.

    PurchaseProduct(Product)

    Initiates a purchase for the specified product.

    Declaration
    public void PurchaseProduct(Product product)
    Parameters
    Type Name Description
    Product product

    The product to purchase.

    RestoreTransactions(Action<bool, string?>?)

    Restores previously purchased transactions (iOS and some other platforms).

    Declaration
    public void RestoreTransactions(Action<bool, string?>? callback)
    Parameters
    Type Name Description
    Action<bool, string> callback

    Optional callback to handle the restore operation result.

    SetStoreReconnectionRetryPolicyOnDisconnection(IRetryPolicy?)

    Sets the retry policy to use when the store disconnects and needs to reconnect.

    Declaration
    public void SetStoreReconnectionRetryPolicyOnDisconnection(IRetryPolicy? retryPolicy)
    Parameters
    Type Name Description
    IRetryPolicy retryPolicy

    The retry policy to use, or null to disable automatic reconnection.

    Events

    OnCheckEntitlement

    Event triggered when an entitlement check operation completes.

    Declaration
    public event Action<Entitlement>? OnCheckEntitlement
    Event Type
    Type Description
    Action<Entitlement>

    OnProductsFetchFailed

    Event triggered when fetching products from the store has failed.

    Declaration
    public event Action<ProductFetchFailed>? OnProductsFetchFailed
    Event Type
    Type Description
    Action<ProductFetchFailed>

    OnProductsFetched

    Event triggered when products have been successfully fetched from the store.

    Declaration
    public event Action<List<Product>>? OnProductsFetched
    Event Type
    Type Description
    Action<List<Product>>

    OnPurchaseConfirmed

    Event triggered when confirming a purchase with either a ConfirmedOrder or a FailedOrder.

    Declaration
    public event Action<Order>? OnPurchaseConfirmed
    Event Type
    Type Description
    Action<Order>

    OnPurchaseDeferred

    Event triggered when a purchase has been deferred for later processing.

    Declaration
    public event Action<DeferredOrder>? OnPurchaseDeferred
    Event Type
    Type Description
    Action<DeferredOrder>

    OnPurchaseFailed

    Event triggered when a purchase attempt has failed.

    Declaration
    public event Action<FailedOrder>? OnPurchaseFailed
    Event Type
    Type Description
    Action<FailedOrder>

    OnPurchasePending

    Event triggered when a purchase is pending and awaiting user action or store processing.

    Declaration
    public event Action<PendingOrder>? OnPurchasePending
    Event Type
    Type Description
    Action<PendingOrder>

    OnPurchasesFetchFailed

    Event triggered when fetching existing purchases from the store has failed.

    Declaration
    public event Action<PurchasesFetchFailureDescription>? OnPurchasesFetchFailed
    Event Type
    Type Description
    Action<PurchasesFetchFailureDescription>

    OnPurchasesFetched

    Event triggered when existing purchases have been successfully fetched from the store.

    Declaration
    public event Action<Orders>? OnPurchasesFetched
    Event Type
    Type Description
    Action<Orders>

    OnStoreDisconnected

    Event triggered when the store connection is lost or fails.

    Declaration
    public event Action<StoreConnectionFailureDescription>? OnStoreDisconnected
    Event Type
    Type Description
    Action<StoreConnectionFailureDescription>

    Implements

    IStoreService
    IProductService
    IPurchaseService
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)