PlayerIO

The fastest way to build online games without breaking a sweat.

.NET Client Reference

Multiplayer  class documentationClass PayVault

Namespace: PlayerIOClient
Language: C# / .NET

The Player.IO PayVault.

Instances of this class represent a specific user's Vault, and contains methods and properties both for inspecting and manipulating the contents.

All properties and methods that inspect the Vault requires that it is up-to-date first. This can be achieved explicitly by calling the Refresh() method or implicitly by calling any method which modifies the Vault.

Here is how to read the Coins balance:

This is how you check if an item exists:

Credit and Debit can be used like this:

Buying items with Coins is really easy. This requires that you have created an item in the PayVaultItems table in BigDB with the key "speedboost", and a property "PriceCoins" containing the price.

And here's how to consume an item:

When it's time for a user to add more Coins, you can do it like this:

And this is how to let the user buy an item directly. This requires that you have created an item in the PayVaultItems table in BigDB with the key "supercar", and a property "PriceUSD" containing the price.

Finally, there are methods for retrieving the payment history of a user:

Properties

 
public int
Coins  [read-only]

This property contains the current coin balance of this Vault. This property can only be read on an up-to-date vault.

public VaultItem[]
Items  [read-only]

This property contains the list of items in this Vault. This property can only be read on an up-to-date vault.

Methods

 
public void
Buy (bool storeItems, params BuyItemInfo[] items)

Buy items with Coins.

public void
Buy (bool storeItems, BuyItemInfo[] items, Callback successCallback)

Buy items with Coins.

public void
Buy (bool storeItems, BuyItemInfo[] items, Callback successCallback, Callback<PlayerIOError> errorCallback)

Buy items with Coins.

public void
Consume (params VaultItem[] items)

Consume items in this Vault. This will cause them to be removed, but this action will not show up in the vault history.

public void
Consume (VaultItem[] items, Callback successCallback)

Consume items in this Vault. This will cause them to be removed, but this action will not show up in the vault history.

public void
Consume (VaultItem[] items, Callback successCallback, Callback<PlayerIOError> errorCallback)

Consume items in this Vault. This will cause them to be removed, but this action will not show up in the vault history.

public int
Count (string itemKey)

Returns the number of items of a given itemKey is in this Vault. This method can only be called on an up-to-date vault.

public void
Credit (uint coinAmount, string reason, Callback successCallback, Callback<PlayerIOError> errorCallback)

Give coins to this Vault.

public void
Credit (uint coinAmount, string reason, Callback successCallback)

Give coins to this Vault.

public void
Credit (uint coinAmount, string reason)

Give coins to this Vault.

public void
Debit (uint coinAmount, string reason, Callback successCallback, Callback<PlayerIOError> errorCallback)

Take coins from this Vault

public void
Debit (uint coinAmount, string reason, Callback successCallback)

Take coins from this Vault

public void
Debit (uint coinAmount, string reason)

Take coins from this Vault

public VaultItem
First (string itemKey)

Returns the first item of the given itemKey from this Vault. This method can only be called on an up-to-date vault.

public void
GetBuyCoinsInfo (string provider, Dictionary<string, string> purchaseArguments, Callback<Dictionary<string, string>> successCallback, Callback<PlayerIOError> errorCallback)

Gets information about how to make a coin purchase with the specified PayVault provider.

public Dictionary<string, string>
GetBuyCoinsInfo (string provider, Dictionary<string, string> purchaseArguments)

Gets information about how to make a coin purchase with the specified PayVault provider.

public void
GetBuyCoinsInfo (string provider, Dictionary<string, string> purchaseArguments, Callback<Dictionary<string, string>> successCallback)

Gets information about how to make a coin purchase with the specified PayVault provider.

public void
GetBuyDirectInfo (string provider, Dictionary<string, string> purchaseArguments, BuyItemInfo[] items, Callback<Dictionary<string, string>> successCallback, Callback<PlayerIOError> errorCallback)

Gets information about how to make a direct item purchase with the specified PayVault provider.

public void
GetBuyDirectInfo (string provider, Dictionary<string, string> purchaseArguments, BuyItemInfo[] items, Callback<Dictionary<string, string>> successCallback)

Gets information about how to make a direct item purchase with the specified PayVault provider.

public Dictionary<string, string>
GetBuyDirectInfo (string provider, Dictionary<string, string> purchaseArguments, params BuyItemInfo[] items)

Gets information about how to make a direct item purchase with the specified PayVault provider.

public void
Give (params BuyItemInfo[] items)

Give the user items without taking any of his coins from the vault.

public void
Give (BuyItemInfo[] items, Callback successCallback, Callback<PlayerIOError> errorCallback)

Give the user items without taking any of his coins from the vault.

public void
Give (BuyItemInfo[] items, Callback successCallback)

Give the user items without taking any of his coins from the vault.

public bool
Has (string itemKey)

This method checks if the Vault contains at least one item of the given itemKey. This method can only be called on an up-to-date vault.

public PayVaultHistoryEntry[]
ReadHistory (uint page, uint pageSize)

Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first.

public void
ReadHistory (uint page, uint pageSize, Callback<PayVaultHistoryEntry[]> successCallback)

Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first.

public void
ReadHistory (uint page, uint pageSize, Callback<PayVaultHistoryEntry[]> successCallback, Callback<PlayerIOError> errorCallback)

Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first.

public void
Refresh ()

Refreshes this Vault, making sure the Items and Coins are up-to-date.

public void
Refresh (Callback successCallback)

Refreshes this Vault, making sure the Items and Coins are up-to-date.

public void
Refresh (Callback successCallback, Callback<PlayerIOError> errorCallback)

Refreshes this Vault, making sure the Items and Coins are up-to-date.

public void
UseBuyInfo (string provider, Dictionary<string, string> providerArguments, Callback<Dictionary<string, string>> successCallback)

Use information from a provider to finalize a purchase with the specified PayVault provider.

public Dictionary<string, string>
UseBuyInfo (string provider, Dictionary<string, string> providerArguments)

Use information from a provider to finalize a purchase with the specified PayVault provider.

public void
UseBuyInfo (string provider, Dictionary<string, string> providerArguments, Callback<Dictionary<string, string>> successCallback, Callback<PlayerIOError> errorCallback)

Use information from a provider to finalize a purchase with the specified PayVault provider.

PayVault.Coins

public int
Coins  [read-only]

This property contains the current coin balance of this Vault. This property can only be read on an up-to-date vault.

PayVault.Items

public VaultItem[]
Items  [read-only]

This property contains the list of items in this Vault. This property can only be read on an up-to-date vault.

PayVault.Buy

public void
Buy (bool storeItems, params BuyItemInfo[] items)

Buy items with Coins.

Arguments

bool storeItems
If true, the items will be stored in the Vault. If false, the items will be consumed immediately after purchase.
params BuyItemInfo[] items
A list of items to buy, together with any additional payload.

PayVault.Buy

public void
Buy (bool storeItems, BuyItemInfo[] items, Callback successCallback)

Buy items with Coins.

Arguments

bool storeItems
If true, the items will be stored in the Vault. If false, the items will be consumed immediately after purchase.
BuyItemInfo[] items
A list of items to buy, together with any additional payload.
Callback successCallback
Callback that will be called if the buy is succesful.

PayVault.Buy

public void
Buy (bool storeItems, BuyItemInfo[] items, Callback successCallback, Callback<PlayerIOError> errorCallback)

Buy items with Coins.

Arguments

bool storeItems
If true, the items will be stored in the Vault. If false, the items will be consumed immediately after purchase.
BuyItemInfo[] items
A list of items to buy, together with any additional payload.
Callback successCallback
Callback that will be called if the buy is succesful.
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs.

PayVault.Consume

public void
Consume (params VaultItem[] items)

Consume items in this Vault. This will cause them to be removed, but this action will not show up in the vault history.

Arguments

params VaultItem[] items
The VaultItems to use from the users vault - this should be instances from the Items array property.

PayVault.Consume

public void
Consume (VaultItem[] items, Callback successCallback)

Consume items in this Vault. This will cause them to be removed, but this action will not show up in the vault history.

Arguments

VaultItem[] items
The VaultItems to use from the users vault - this should be instances from the Items array property.
Callback successCallback
Callback that will be called if the use is succesful.

PayVault.Consume

public void
Consume (VaultItem[] items, Callback successCallback, Callback<PlayerIOError> errorCallback)

Consume items in this Vault. This will cause them to be removed, but this action will not show up in the vault history.

Arguments

VaultItem[] items
The VaultItems to use from the users vault - this should be instances from the Items array property.
Callback successCallback
Callback that will be called if the use is succesful.
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs.

PayVault.Count

public int
Count (string itemKey)

Returns the number of items of a given itemKey is in this Vault. This method can only be called on an up-to-date vault.

Arguments

string itemKey
The itemKey of the items to count

PayVault.Credit

public void
Credit (uint coinAmount, string reason, Callback successCallback, Callback<PlayerIOError> errorCallback)

Give coins to this Vault.

Arguments

uint coinAmount
The amount of coins to give.
string reason
Your reason for giving the coins to this user. This will show up in the vault history, and in the PayVault admin panel for this user.
Callback successCallback
Callback that will be called if the credit is succesful.
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs.

PayVault.Credit

public void
Credit (uint coinAmount, string reason, Callback successCallback)

Give coins to this Vault.

Arguments

uint coinAmount
The amount of coins to give.
string reason
Your reason for giving the coins to this user. This will show up in the vault history, and in the PayVault admin panel for this user.
Callback successCallback
Callback that will be called if the credit is succesful.

PayVault.Credit

public void
Credit (uint coinAmount, string reason)

Give coins to this Vault.

Arguments

uint coinAmount
The amount of coins to give.
string reason
Your reason for giving the coins to this user. This will show up in the vault history, and in the PayVault admin panel for this user.

PayVault.Debit

public void
Debit (uint coinAmount, string reason, Callback successCallback, Callback<PlayerIOError> errorCallback)

Take coins from this Vault

Arguments

uint coinAmount
The amount of coins to take.
string reason
Your reason for taking the coins from this user. This will show up in the vault history, and in the PayVault admin panel for this user.
Callback successCallback
Callback that will be called if the debit is succesful.
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs.

PayVault.Debit

public void
Debit (uint coinAmount, string reason, Callback successCallback)

Take coins from this Vault

Arguments

uint coinAmount
The amount of coins to take.
string reason
Your reason for taking the coins from this user. This will show up in the vault history, and in the PayVault admin panel for this user.
Callback successCallback
Callback that will be called if the debit is succesful.

PayVault.Debit

public void
Debit (uint coinAmount, string reason)

Take coins from this Vault

Arguments

uint coinAmount
The amount of coins to take.
string reason
Your reason for taking the coins from this user. This will show up in the vault history, and in the PayVault admin panel for this user.

PayVault.First

public VaultItem
First (string itemKey)

Returns the first item of the given itemKey from this Vault. This method can only be called on an up-to-date vault.

Arguments

string itemKey
The itemKey of the item to get

PayVault.GetBuyCoinsInfo

public void
GetBuyCoinsInfo (string provider, Dictionary<string, string> purchaseArguments, Callback<Dictionary<string, string>> successCallback, Callback<PlayerIOError> errorCallback)

Gets information about how to make a coin purchase with the specified PayVault provider.

Arguments

string provider
The name of the PayVault provider to use for the coin purchase.
Dictionary<string, string> purchaseArguments
Any additional information that will be given to the PayVault provider to configure this purchase.
Callback<Dictionary<string, string>> successCallback
Callback that will be called with information about how to proceed with the purchase.
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs.

PayVault.GetBuyCoinsInfo

public Dictionary<string, string>
GetBuyCoinsInfo (string provider, Dictionary<string, string> purchaseArguments)

Gets information about how to make a coin purchase with the specified PayVault provider.

Arguments

string provider
The name of the PayVault provider to use for the coin purchase.
Dictionary<string, string> purchaseArguments
Any additional information that will be given to the PayVault provider to configure this purchase.

PayVault.GetBuyCoinsInfo

public void
GetBuyCoinsInfo (string provider, Dictionary<string, string> purchaseArguments, Callback<Dictionary<string, string>> successCallback)

Gets information about how to make a coin purchase with the specified PayVault provider.

Arguments

string provider
The name of the PayVault provider to use for the coin purchase.
Dictionary<string, string> purchaseArguments
Any additional information that will be given to the PayVault provider to configure this purchase.
Callback<Dictionary<string, string>> successCallback
Callback that will be called with information about how to proceed with the purchase.

PayVault.GetBuyDirectInfo

public void
GetBuyDirectInfo (string provider, Dictionary<string, string> purchaseArguments, BuyItemInfo[] items, Callback<Dictionary<string, string>> successCallback, Callback<PlayerIOError> errorCallback)

Gets information about how to make a direct item purchase with the specified PayVault provider.

Arguments

string provider
The name of the PayVault provider to use for the coin purchase.
Dictionary<string, string> purchaseArguments
Any additional information that will be given to the PayVault provider to configure this purchase.
BuyItemInfo[] items
Each BuyItemInfo instance contains the key of the item to buy and any additional payload.
Callback<Dictionary<string, string>> successCallback
Callback that will be called with information about how to proceed with the purchase.
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs.

PayVault.GetBuyDirectInfo

public void
GetBuyDirectInfo (string provider, Dictionary<string, string> purchaseArguments, BuyItemInfo[] items, Callback<Dictionary<string, string>> successCallback)

Gets information about how to make a direct item purchase with the specified PayVault provider.

Arguments

string provider
The name of the PayVault provider to use for the coin purchase.
Dictionary<string, string> purchaseArguments
Any additional information that will be given to the PayVault provider to configure this purchase.
BuyItemInfo[] items
Each BuyItemInfo instance contains the key of the item to buy and any additional payload.
Callback<Dictionary<string, string>> successCallback
Callback that will be called with information about how to proceed with the purchase.

PayVault.GetBuyDirectInfo

public Dictionary<string, string>
GetBuyDirectInfo (string provider, Dictionary<string, string> purchaseArguments, params BuyItemInfo[] items)

Gets information about how to make a direct item purchase with the specified PayVault provider.

Arguments

string provider
The name of the PayVault provider to use for the coin purchase.
Dictionary<string, string> purchaseArguments
Any additional information that will be given to the PayVault provider to configure this purchase.
params BuyItemInfo[] items
Each BuyItemInfo instance contains the key of the item to buy and any additional payload.

PayVault.Give

public void
Give (params BuyItemInfo[] items)

Give the user items without taking any of his coins from the vault.

Arguments

params BuyItemInfo[] items
Each BuyItemInfo instance contains the key of the item to give in the PayVaultItems BigDB table and any additional payload.

PayVault.Give

public void
Give (BuyItemInfo[] items, Callback successCallback, Callback<PlayerIOError> errorCallback)

Give the user items without taking any of his coins from the vault.

Arguments

BuyItemInfo[] items
Each BuyItemInfo instance contains the key of the item to give in the PayVaultItems BigDB table and any additional payload.
Callback successCallback
Callback that will be called if the give is succesfull.
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs.

PayVault.Give

public void
Give (BuyItemInfo[] items, Callback successCallback)

Give the user items without taking any of his coins from the vault.

Arguments

BuyItemInfo[] items
Each BuyItemInfo instance contains the key of the item to give in the PayVaultItems BigDB table and any additional payload.
Callback successCallback
Callback that will be called if the give is succesfull.

PayVault.Has

public bool
Has (string itemKey)

This method checks if the Vault contains at least one item of the given itemKey. This method can only be called on an up-to-date vault.

Arguments

string itemKey
The itemKey to check for

PayVault.ReadHistory

public PayVaultHistoryEntry[]
ReadHistory (uint page, uint pageSize)

Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first.

Arguments

uint page
The page of entries to load. The first page has number 0.
uint pageSize
The number of entries per page.

PayVault.ReadHistory

public void
ReadHistory (uint page, uint pageSize, Callback<PayVaultHistoryEntry[]> successCallback)

Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first.

Arguments

uint page
The page of entries to load. The first page has number 0.
uint pageSize
The number of entries per page.
Callback<PayVaultHistoryEntry[]> successCallback
Callback that will be called with the loaded PayVault history entries, or an empty array if none were found on the given page.

PayVault.ReadHistory

public void
ReadHistory (uint page, uint pageSize, Callback<PayVaultHistoryEntry[]> successCallback, Callback<PlayerIOError> errorCallback)

Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first.

Arguments

uint page
The page of entries to load. The first page has number 0.
uint pageSize
The number of entries per page.
Callback<PayVaultHistoryEntry[]> successCallback
Callback that will be called with the loaded PayVault history entries, or an empty array if none were found on the given page.
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs during the loading of history entries.

PayVault.Refresh

public void
Refresh ()

Refreshes this Vault, making sure the Items and Coins are up-to-date.

PayVault.Refresh

public void
Refresh (Callback successCallback)

Refreshes this Vault, making sure the Items and Coins are up-to-date.

Arguments

Callback successCallback
Callback that will be called when the refresh is completed

PayVault.Refresh

public void
Refresh (Callback successCallback, Callback<PlayerIOError> errorCallback)

Refreshes this Vault, making sure the Items and Coins are up-to-date.

Arguments

Callback successCallback
Callback that will be called when the refresh is completed
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs during the refresh.

PayVault.UseBuyInfo

public void
UseBuyInfo (string provider, Dictionary<string, string> providerArguments, Callback<Dictionary<string, string>> successCallback)

Use information from a provider to finalize a purchase with the specified PayVault provider.

Arguments

string provider
The name of the PayVault provider to use.
Dictionary<string, string> providerArguments
The information needed to finalize this purchase.
Callback<Dictionary<string, string>> successCallback
Callback that will be called with PayVault provider-specific information about the purchase.

PayVault.UseBuyInfo

public Dictionary<string, string>
UseBuyInfo (string provider, Dictionary<string, string> providerArguments)

Use information from a provider to finalize a purchase with the specified PayVault provider.

Arguments

string provider
The name of the PayVault provider to use.
Dictionary<string, string> providerArguments
The information needed to finalize this purchase.

PayVault.UseBuyInfo

public void
UseBuyInfo (string provider, Dictionary<string, string> providerArguments, Callback<Dictionary<string, string>> successCallback, Callback<PlayerIOError> errorCallback)

Use information from a provider to finalize a purchase with the specified PayVault provider.

Arguments

string provider
The name of the PayVault provider to use.
Dictionary<string, string> providerArguments
The information needed to finalize this purchase.
Callback<Dictionary<string, string>> successCallback
Callback that will be called with PayVault provider-specific information about the purchase.
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs.