PlaytoliaWallet tracks balances for all virtual currencies. Balances update automatically after purchases.
Getting balances
var wallets = PlaytoliaWallet.GetWallets(); // all wallets
var wallet = PlaytoliaWallet.GetWalletForCurrencyWithCode("GOLD");
var wallet = PlaytoliaWallet.GetWalletForCurrencyWithId(currencyId);
Debug.Log(wallet.Balance); // string — supports large numbers
Debug.Log(wallet.Currency.Name);
Getting currencies
var currencies = PlaytoliaWallet.GetCurrencies();
var currency = PlaytoliaWallet.GetCurrencyByCode("GOLD");
var currency = PlaytoliaWallet.GetCurrencyById(id);
Balance is a string to support arbitrarily large values. Parse to long if you need arithmetic.
Listening to changes
void Start()
{
PlaytoliaWallet.AddListener(UpdateUI);
}
void UpdateUI()
{
var w = PlaytoliaWallet.GetWalletForCurrencyWithCode("GOLD");
goldText.text = w?.Balance ?? "0";
}
void OnDestroy() => PlaytoliaWallet.RemoveListener(UpdateUI);
In-game Stores
Trigger purchases that update wallet balances