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 retrieveing 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 |
(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 |
(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 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 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 |
| 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 |
| 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 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 |
| Give |
(BuyItemInfo[] items, Callback successCallback) |
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 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 |
| 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 |
| 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 |
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.
|
PayVault.Coins
This property contains the current coin balance of this Vault. This property can only be read on an up-to-date vault.
PayVault.Items
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, 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 |
(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.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.Count
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.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.First
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.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.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.Has
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 |
| 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.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.Refresh
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. |