docs.unity3d.com
    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.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Services.Economy.Model
    Syntax
    [Preserve]
    public class VirtualPurchaseDefinition : ConfigurationItemDefinition

    Constructors

    VirtualPurchaseDefinition()

    Declaration
    [Preserve]
    public VirtualPurchaseDefinition()

    Fields

    Costs

    A list of costs associated with this purchase.

    Declaration
    [Preserve]
    public List<PurchaseItemQuantity> Costs
    Field Value
    Type Description
    List<PurchaseItemQuantity>

    Rewards

    A list of rewards associated with this purchase.

    Declaration
    [Preserve]
    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 async Task<bool> CanPlayerAffordPurchaseAsync()
    Returns
    Type Description
    Task<Boolean>

    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 async 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 async 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

    Back to top
    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