GameMaker Studio · GML · Currency & store
gmda_buyPack
Starts a real-money top-up: opens Stripe Checkout in the browser to credit currency.
Signature
gmda_buyPack(pack_sku, [success_url], [cancel_url], [idempotency_key]) -> realWhat it does
POSTs /currency/topup/checkout with the session headers. The queued topup_started event carries success and response, whose url is the Stripe Checkout link you open in the system browser (use url_open(e.response.url)). After the player pays, the server credits the linked grant via a Stripe webhook, so call gmda_getBalances() when they return to see the new balance. When success is false, response (or the event's error field) carries the reason. Returns 1 once dispatched, or 0 when there is no active session.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| pack_sku | string | required | The top-up pack SKU configured in the panel (e.g. "premium_pack"). |
| success_url | string | "https://gamdato.com/topup/ok" | Where Stripe redirects after a successful payment. Defaults to a gamdato.com page; must be https:// (or http://localhost in dev). |
| cancel_url | string | "https://gamdato.com/topup/cancel" | Where Stripe redirects if the player cancels. Defaults to a gamdato.com page; must be https:// (or http://localhost in dev). |
| idempotency_key | string | optional | Optional key to make retries safe. Omit it and the client generates a 24-character key for you. |
How to call it
Call gmda_buyPack(pack_sku), then read the topup_started event with gmda_pollEvent() and open response.url. Because crediting happens via webhook, refresh with gmda_getBalances() when the player comes back to the game.
Result event: topup_started { success, response }
Example
gmda_buyPack("premium_pack");
// in the Step event, drain the queue:
var e = gmda_pollEvent();
while (!is_undefined(e)) {
if (e.event == "topup_started" && e.success) {
url_open(e.response.url); // open Stripe Checkout
}
e = gmda_pollEvent();
}Use cases
- Sell a gem pack for real money via Stripe Checkout.
- Offer a starter bundle that tops up the player's soft currency.