Unity3D Client Reference
Class 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 |
This property contains the current coin balance of this Vault. This property can only be read on an up-to-date vault. |
||
public VaultItem[] |
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 items with Coins. |
||
public void |
Buy items with Coins. |
||
public void |
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 items in this Vault. This will cause them to be removed, but this action will not show up in the vault history. |
||
public int |
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 |
Give coins to this Vault. |
||
public void |
Give coins to this Vault. |
||
public void |
Take coins from this Vault |
||
public void |
Take coins from this Vault |
||
public VaultItem |
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 |
Gets information about how to make a coin purchase with the specified PayVault provider. |
||
public void |
Gets information about how to make a coin purchase with the specified PayVault provider. |
||
public void |
Gets information about how to make a direct item purchase with the specified PayVault provider. |
||
public void |
Gets information about how to make a direct item purchase with the specified PayVault provider. |
||
public void |
Give the user items without taking any of his coins from the vault. |
||
public void |
Give the user items without taking any of his coins from the vault. |
||
public bool |
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 void |
Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first. |
||
public void |
Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first. |
||
public void |
Refreshes this Vault, making sure the Items and Coins are up-to-date. |
||
public void |
Refreshes this Vault, making sure the Items and Coins are up-to-date. |
||
public void |
Use information from a provider to finalize a purchase with the specified PayVault provider. |
||
public void |
Use information from a provider to finalize a purchase with the specified PayVault provider. |
PayVault.Coins
public int |
|
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[] |
|
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 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 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 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 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 |
|
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 |
|
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 |
|
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.Debit
public void |
|
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 |
|
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.First
public VaultItem |
|
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 |
|
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 void |
|
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 |
|
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 void |
|
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.Give
public void |
|
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.Give
public void |
|
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.Has
public bool |
|
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 void |
|
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.ReadHistory
public void |
|
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.Refresh
public void |
|
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 |
|
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 |
|
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 void |
|
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. |