v3.1.2
2020.3+

Class VirtualPurchaseDefinition

Represents a virtual purchase configuration.

Inheritance
VirtualPurchaseDefinition
Namespace: Unity.Services.Economy.Model
Syntax
[Preserve]
public class VirtualPurchaseDefinition : ConfigurationItemDefinition

Fields

Costs

A list of costs associated with this purchase.

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

Rewards

A list of rewards associated with this purchase.

Declaration
[Preserve]
public List<PurchaseItemQuantity> Rewards
Field Value
TypeDescription
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
TypeDescription
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
TypeNameDescription
List<PlayersInventoryItem>playersInventoryItems

A list of PlayersInventoryItems to use in this purchase

Returns
TypeDescription
Task<MakeVirtualPurchaseResult>

A MakeVirtualPurchaseResult containing details of the purchase

Exceptions
TypeCondition
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
TypeNameDescription
MakeVirtualPurchaseOptionsoptions

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

Returns
TypeDescription
Task<MakeVirtualPurchaseResult>

A MakeVirtualPurchaseResult containing details of the purchase

Exceptions
TypeCondition
EconomyException

Thrown if purchase is unsuccessful