PlayerIO

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

Android Client Reference

Android  class documentationClass 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 (boolean storeItems, BuyItemInfo[] items, Callback<Void> callback)

Buy items with Coins.

public void
consume (VaultItem[] items, Callback<Void> callback)

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 (int coinAmount, String reason, Callback<Void> callback)

Give coins to this Vault

public void
debit (int coinAmount, String reason, Callback<Void> callback)

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, Map<String,String> purchaseArguments, Callback<Map<String,String>> callback)

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

public void
getBuyDirectInfo (String provider, Map<String,String> purchaseArguments, BuyItemInfo[] items, Callback<Map<String,String>> callback)

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

public long
getCoins ()

Get the current coin balance in this Vault. This method can only be called on an up-to-date vault.

public VaultItem[]
getItems ()

Get the list of items in this Vault. This method can only be called on an up-to-date vault.

public void
give (BuyItemInfo[] items, Callback<Void> callback)

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

public boolean
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 void
readHistory (int page, int pageSize, Callback<PayVaultHistoryEntry[]> callback)

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

public void
refresh (Callback<Void> callback)

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

public void
useBuyInfo (String provider, Map<String,String> providerArguments, Callback<Map<String,String>> callback)

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

PayVault.buy

public void
buy (boolean storeItems, BuyItemInfo[] items, Callback<Void> callback)

Buy items with Coins.

Arguments

boolean storeItems
Whether or not to store the items in the vault after purchase
BuyItemInfo[] items
A list of items to buy, together with any additional payload.
Callback<Void> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

PayVault.consume

public void
consume (VaultItem[] items, Callback<Void> callback)

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 of items in this Vault.
Callback<Void> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

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.

Throws

PlayerIOError

PayVault.credit

public void
credit (int coinAmount, String reason, Callback<Void> callback)

Give coins to this Vault

Arguments

int 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<Void> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

PayVault.debit

public void
debit (int coinAmount, String reason, Callback<Void> callback)

Take coins from this Vault

Arguments

int 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<Void> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

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.

Throws

PlayerIOError

PayVault.getBuyCoinsInfo

public void
getBuyCoinsInfo (String provider, Map<String,String> purchaseArguments, Callback<Map<String,String>> callback)

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.
Map<String,String> purchaseArguments
Any additional information that will be given to the PayVault provider to configure this purchase.
Callback<Map<String,String>> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

PayVault.getBuyDirectInfo

public void
getBuyDirectInfo (String provider, Map<String,String> purchaseArguments, BuyItemInfo[] items, Callback<Map<String,String>> callback)

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 item purchase.
Map<String,String> purchaseArguments
Any additional information that will be given to the PayVault provider to configure this purchase.
BuyItemInfo[] items
A list of items to buy, together with any additional payload.
Callback<Map<String,String>> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

PayVault.getCoins

public long
getCoins ()

Get the current coin balance in this Vault. This method can only be called on an up-to-date vault.

PayVault.getItems

public VaultItem[]
getItems ()

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 (BuyItemInfo[] items, Callback<Void> callback)

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

Arguments

BuyItemInfo[] items
A list of items to give, together with any additional payload.
Callback<Void> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

PayVault.has

public boolean
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.

Throws

PlayerIOError

PayVault.readHistory

public void
readHistory (int page, int pageSize, Callback<PayVaultHistoryEntry[]> callback)

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

Arguments

int page
The page of entries to load. The first page has number 0.
int pageSize
The number of entries per page.
Callback<PayVaultHistoryEntry[]> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

PayVault.refresh

public void
refresh (Callback<Void> callback)

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

Arguments

Callback<Void> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

PayVault.useBuyInfo

public void
useBuyInfo (String provider, Map<String,String> providerArguments, Callback<Map<String,String>> callback)

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 for the purchase.
Map<String,String> providerArguments
The information needed to finalize this purchase.
Callback<Map<String,String>> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError, PlayerIOError