docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IPurchaseService

    Public Interface for a service responsible for ordering products, fetching previous purchases and validating product entitlements.

    Namespace: UnityEngine.Purchasing
    Assembly: Unity.Purchasing.dll
    Syntax
    public interface IPurchaseService

    Properties

    Apple

    Apple Specific Purchase Extensions

    Declaration
    IAppleStoreExtendedPurchaseService? Apple { get; }
    Property Value
    Type Description
    IAppleStoreExtendedPurchaseService

    Google

    Google Specific Purchase Extensions

    Declaration
    IGooglePlayStoreExtendedPurchaseService? Google { get; }
    Property Value
    Type Description
    IGooglePlayStoreExtendedPurchaseService

    Methods

    CheckEntitlement(Product)

    Check if a Product has been entitled. Be sure to first register your callback via OnCheckEntitlement.

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

    The Product to check for entitlement.

    ConfirmPurchase(PendingOrder)

    Confirm a pending order. Be sure to first register your callbacks via OnPurchaseConfirmed.

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

    The pending order to confirm.

    FetchPurchases()

    Fetch pre-existing purchases. Be sure to first register your callbacks via OnPurchasesFetched and OnPurchasesFetchFailed.

    Declaration
    void FetchPurchases()

    GetPurchases()

    Gets an observable collection of the purchases fetched, confirmed and ordered.

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

    The read-only observable collection of all purchases made.

    ProcessPendingOrdersOnPurchasesFetched(bool)

    Sets whether to process pending orders when purchases are fetched by sending them to the OnPurchasePending callback. Default is true.

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

    Whether to process pending orders when purchases are fetched.

    Purchase(ICart)

    Purchase a cart. Be sure to first register your callback via OnPurchasePending and OnPurchaseFailed.

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

    The cart to purchase.

    PurchaseProduct(Product)

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

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

    The Product to purchase.

    RestoreTransactions(Action<bool, string?>?)

    Initiate a request to restore previously made purchases.

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

    Action will be called when the request to restore transactions comes back. The bool will be true if it was successful or false if it was not. The string is an optional error message.

    Events

    OnCheckEntitlement

    Callback when a check for product entitlement is complete.

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

    OnPurchaseConfirmed

    Callback when a purchase has been confirmed. This can pass a ConfirmedOrder or a FailedOrder depending on the purchase outcome.

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

    OnPurchaseDeferred

    Callback when products orders are deferred.

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

    OnPurchaseFailed

    Callback when products orders fail.

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

    OnPurchasePending

    Callback when a purchase has been paid, but hasn't been confirmed yet.

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

    OnPurchasesFetchFailed

    Callback when an attempt to fetch previous purchases has failed.

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

    OnPurchasesFetched

    Callback when previous purchases are fetched.

    Declaration
    event Action<Orders>? OnPurchasesFetched
    Event Type
    Type Description
    Action<Orders>
    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)