docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class VirtualPurchaseDefinition

    Represents a virtual purchase configuration.

    Inheritance
    object
    ConfigurationItemDefinition
    VirtualPurchaseDefinition
    Inherited Members
    ConfigurationItemDefinition.Id
    ConfigurationItemDefinition.Name
    ConfigurationItemDefinition.Type
    ConfigurationItemDefinition.CustomData
    ConfigurationItemDefinition.CustomDataDeserializable
    ConfigurationItemDefinition.Created
    ConfigurationItemDefinition.Modified
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Services.Economy.Model
    Assembly: Unity.Services.Economy.dll
    Syntax
    [Preserve]
    public class VirtualPurchaseDefinition : ConfigurationItemDefinition

    Constructors

    VirtualPurchaseDefinition()

    Declaration
    [Preserve]
    public VirtualPurchaseDefinition()

    Fields

    Costs

    A list of costs associated with this purchase.

    Declaration
    [Preserve]
    [JsonRequired]
    [JsonProperty("costs")]
    public List<PurchaseItemQuantity> Costs
    Field Value
    Type Description
    List<PurchaseItemQuantity>

    Rewards

    A list of rewards associated with this purchase.

    Declaration
    [Preserve]
    [JsonRequired]
    [JsonProperty("rewards")]
    public List<PurchaseItemQuantity> Rewards
    Field Value
    Type Description
    List<PurchaseItemQuantity>

    Methods

    CanPlayerAffordPurchaseAsync()

    Check if this purchase is affordable for the currently signed in user.

    Note: This call is very costly, as it will make multiple API calls to check the player's current balances against the costs specified in this purchase.

    Declaration
    public Task<bool> CanPlayerAffordPurchaseAsync()
    Returns
    Type Description
    Task<bool>

    True if the player has the inventory/currency balances to pay for the purchase, false otherwise.

    MakePurchaseAsync(List<PlayersInventoryItem>)

    Make this purchase using the PlayersInventoryItems provided to pay the inventory item cost.

    Declaration
    public Task<MakeVirtualPurchaseResult> MakePurchaseAsync(List<PlayersInventoryItem> playersInventoryItems)
    Parameters
    Type Name Description
    List<PlayersInventoryItem> playersInventoryItems

    A list of PlayersInventoryItems to use in this purchase

    Returns
    Type Description
    Task<MakeVirtualPurchaseResult>

    A MakeVirtualPurchaseResult containing details of the purchase

    Exceptions
    Type Condition
    EconomyException

    Thrown if purchase is unsuccessful

    MakePurchaseAsync(MakeVirtualPurchaseOptions)

    Make this purchase. Optionally takes instance IDs of items to use in the purchase.

    Declaration
    public Task<MakeVirtualPurchaseResult> MakePurchaseAsync(MakeVirtualPurchaseOptions options = null)
    Parameters
    Type Name Description
    MakeVirtualPurchaseOptions options

    (Optional) Use to set a list of item instance IDs to use in this purchase

    Returns
    Type Description
    Task<MakeVirtualPurchaseResult>

    A MakeVirtualPurchaseResult containing details of the purchase

    Exceptions
    Type Condition
    EconomyException

    Thrown if purchase is unsuccessful

    In This Article
    Back to top
    Copyright © 2024 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)