docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Payments

    Contains functions and properties related to payments and purchases of game products.

    Inheritance
    object
    JsObject
    Payments
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Meta.InstantGames.v8
    Assembly: Unity.Meta.InstantGames.Sdk.v8.dll
    Syntax
    public class Payments : JsObject

    Constructors

    Payments()

    Construct an instance of Payments

    Declaration
    public Payments()

    Methods

    ConsumePurchaseAsync(string)

    Consumes a specific purchase belonging to the current player. Before provisioning a product's effects to the player, the game should request the consumption of the purchased product. Once the purchase is successfully consumed, the game should immediately provide the player with the effects of their purchase. Exceptions: CLIENT_UNSUPPORTED_OPERATION, PAYMENTS_NOT_INITIALIZED, INVALID_PARAM, NETWORK_FAILURE

    Declaration
    public WebTask ConsumePurchaseAsync(string purchaseToken)
    Parameters
    Type Name Description
    string purchaseToken

    The purchase token of the purchase that should be consumed.

    Returns
    Type Description
    WebTask

    A WebTask that resolves when the purchase has been consumed successfully.

    GetCatalogAsync()

    Fetches the game's product catalog. Exceptions: CLIENT_UNSUPPORTED_OPERATION, PAYMENTS_NOT_INITIALIZED, NETWORK_FAILURE

    Declaration
    public WebTask<Product[]> GetCatalogAsync()
    Returns
    Type Description
    WebTask<Product[]>

    A WebTask containing the set of Products that are registered to the game.

    GetPurchasesAsync()

    Fetches all of the player's unconsumed purchases. The game must fetch the current player's purchases as soon as the client indicates that it is ready to perform payments-related operations, i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. Exceptions: CLIENT_UNSUPPORTED_OPERATION, PAYMENTS_NOT_INITIALIZED, NETWORK_FAILURE

    Declaration
    public WebTask<Purchase[]> GetPurchasesAsync()
    Returns
    Type Description
    WebTask<Purchase[]>

    A WebTask<T> containing an array of Purchase.

    OnReady(Action)

    Sets a callback to be triggered when Payments operations are available.

    Declaration
    public void OnReady(Action callback)
    Parameters
    Type Name Description
    Action callback

    The callback function to be executed when Payments are available.

    PurchaseAsync(PurchaseConfig)

    Begins the purchase flow for a specific product. Will immediately reject if called before FBInstant.StartGameAsync() has resolved. Exceptions: CLIENT_UNSUPPORTED_OPERATION, PAYMENTS_NOT_INITIALIZED, INVALID_PARAM, NETWORK_FAILURE, INVALID_OPERATION, USER_INPUT

    Declaration
    public WebTask<Purchase> PurchaseAsync(PurchaseConfig purchaseConfig)
    Parameters
    Type Name Description
    PurchaseConfig purchaseConfig

    The purchase's configuration details.

    Returns
    Type Description
    WebTask<Purchase>

    A WebTask<T> containing a Purchase that resolves when the product is successfully purchased by the player. Otherwise, it rejects.

    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)