Class VirtualPurchaseDefinition
Represents a virtual purchase configuration.
Inherited Members
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
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 |