Android Client Reference
Class PayVault
Namespace: com.playerio
Language: Java
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:
Methods | |||
---|---|---|---|
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 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 |
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 direct item purchase with the specified PayVault provider. |
||
public long |
Get the current coin balance in this Vault. This method can only be called on an up-to-date vault. |
||
public VaultItem[] |
Get the list of items in this Vault. This method can only be called on an up-to-date vault. |
||
public void |
Give the user items without taking any of his coins from the vault. |
||
public boolean |
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 |
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. |
PayVault.buy
public void |
|
Buy items with Coins.
Arguments
boolean | storeItems |
BuyItemInfo[] | items |
Callback<Void> | callback |
Throws
PlayerIOError |
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 |
Callback<Void> | callback |
Throws
PlayerIOError |
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 |
Throws
PlayerIOError |
PayVault.credit
public void |
|
Give coins to this Vault
Arguments
int | coinAmount |
String | reason |
Callback<Void> | callback |
Throws
PlayerIOError |
PayVault.debit
public void |
|
Take coins from this Vault
Arguments
int | coinAmount |
String | reason |
Callback<Void> | callback |
Throws
PlayerIOError |
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 |
Throws
PlayerIOError |
PayVault.getBuyCoinsInfo
public void |
|
Gets information about how to make a coin purchase with the specified PayVault provider.
Arguments
String | provider |
Map<String,String> | purchaseArguments |
Callback<Map<String,String>> | callback |
Throws
PlayerIOError |
PayVault.getBuyDirectInfo
public void |
|
Gets information about how to make a direct item purchase with the specified PayVault provider.
Arguments
String | provider |
Map<String,String> | purchaseArguments |
BuyItemInfo[] | items |
Callback<Map<String,String>> | callback |
Throws
PlayerIOError |
PayVault.getCoins
public long |
|
Get the current coin balance in this Vault. This method can only be called on an up-to-date vault.
PayVault.getItems
public VaultItem[] |
|
Get the list of items in this Vault. This method can only be called on an up-to-date vault.
PayVault.give
public void |
|
Give the user items without taking any of his coins from the vault.
Arguments
BuyItemInfo[] | items |
Callback<Void> | callback |
Throws
PlayerIOError |
PayVault.has
public boolean |
|
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 |
Throws
PlayerIOError |
PayVault.readHistory
public void |
|
Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first.
Arguments
int | page |
int | pageSize |
Callback<PayVaultHistoryEntry[]> | callback |
Throws
PlayerIOError |
PayVault.refresh
public void |
|
Refreshes this Vault, making sure the Items and Coins are up-to-date.
Arguments
Callback<Void> | callback |
Throws
PlayerIOError |
PayVault.useBuyInfo
public void |
|
Use information from a provider to finalize a purchase with the specified PayVault provider.
Arguments
String | provider |
Map<String,String> | providerArguments |
Callback<Map<String,String>> | callback |
Throws
PlayerIOError, PlayerIOError |