GameMaker Studio · GML
Currency & purchases
Gamdato ships with an economy: virtual currencies the player buys with real money (via Stripe), and items they acquire by spending those currencies. Everything is defined in the panel and consumed from the extension.
Define Currencies & Items
In the panel, define your currencies (each with a code) and the shop items (each with a SKU).
The currency "code" is what you pass to gmda_getCurrencyLeaderboard().
Balances
Read the current balances and your currency catalog. Read balances_loaded.
gmda_getBalances(); // -> balances_loaded# balances: Array, each:
{
"currency_id": String,
"balance": int
}
# currencies: Array, the catalog you defined in the panel:
{
"id": String,
"code": String,
"display_name": String,
"icon_url": String,
"is_active": bool
}
# "code" is the currency code you pass to get_currency_leaderboard().Buying Currency (Top-up)
Start a Stripe checkout for a currency pack and read topup_started; open the returned URL.
gmda_buyPack("coins_500"); // -> topup_started (e.response.url)Spending on Items
Purchase a shop item by SKU. An idempotency key is generated for you if you omit it.
gmda_purchase("sword_of_dawn"); // -> purchase_completedPass your own idempotency key as the 2nd argument to make a retry safe.
Inventory
List the items the player owns and read inventory_loaded.
gmda_getInventory(); // -> inventory_loaded# items: Array, each owned item:
{
"item_id": String,
"source": String,
"acquired_at": String,
"metadata": Dictionary
}
# Rows also include internal ids (id, player_id, game_id).Ledger
Read the transaction history (newest first) and read ledger_loaded.
gmda_getLedger(); // -> ledger_loaded
gmda_getLedger(50, 0); // limit, offset# entries: Array, newest first:
{
"id": String,
"currency_id": String,
"delta": int,
"balance_after": int,
"op_type": String,
"created_at": String
}
# Rows also include internal ids/metadata (player_id, game_id, ref_kind, ref_value, idempotency_key, metadata).Currency Ranking
A leaderboard ordered by currency balance. Read currency_leaderboard_loaded.
gmda_getCurrencyLeaderboard("gold"); // -> currency_leaderboard_loaded# entries: Array, ordered by balance, highest first:
{
"rank": int,
"player_id": String,
"player_name": String,
"balance": int
}Granting Currency
Apply a server-defined grant by reason key (e.g. a quest reward) and read grant_completed.
gmda_grantCurrency("daily_quest"); // -> grant_completedGrants are defined in the panel; the client only references them by reason key.