Skip to content
Skip the menu

Guides

Testing

Try your whole integration without spending money, with the test environment, simulated payments, test players and the demo game.

View as Markdown

On this page

The test environment

Every game has a test environment, picked by the test keys (gc_sk_test_…, gc_pk_test_…). It behaves like the real thing, with two differences:

  • Payments are simulated. The payment page shows « Payer » and « Refuser » buttons. No money moves.
  • Data is disposable. Players, balances, the ledger, the inventory and orders of test are separate from those of live, and you can leave them behind.

Your catalog (currencies, items, packs) is shared between the two environments. You define it once and test it as it will be sold.

Note

test is the only environment you can use today. Real payments are not available yet, so nothing you test here costs money, and nothing you test here is real.

Four ways to try it

WayYou write code?Good for
The dashboard's test playersNoSeeing balances, orders and refunds without any code
The demo gameNoSeeing the browser SDK sell your own catalog
curl or a server SDKA littleChecking a call, a header or an error
Your own gameYesThe real integration

Test players in the dashboard

The dashboard is in French for now. Open your game, go to « Joueurs », and check that the environment (« Environnement ») is Test. Then:

  1. « Nouveau joueur de test »: give it an id such as joueur-test-1. This is an ext: player: its API name is ext:joueur-test-1.
  2. On the player's page, « Donner de la monnaie » grants currency, and « Simuler un achat » opens a simulated payment for a pack of your choice, in a new tab.
  3. Pay in that tab. Back on the player's page, the balance, the inventory and the order are updated.
  4. In « Commandes », open the order, and use « Rembourser » to try a refund.

« Bloquer » on the player's page blocks the player: all their client calls answer PLAYER_BLOCKED.

The demo game

The demo is a small clicker built on the browser SDK. It reads your catalog and shows the balance live, sells your packs and items, and lets you consume them. From your game's overview in the dashboard, use « Essayer dans le jeu de démonstration »: it opens the demo with your test key. You can also open the demo game and paste a publishable test key on its start screen.

The demo is in French. Its code is a good example of the SDK in a real page.

The simulated payment

When you create a checkout in test, its payment page offers two buttons:

ButtonWhat happensOrder statusWhere the player goes
« Payer »The payment succeeds. The pack is delivered at once.fulfilledsuccessUrl, with ?order=<id>&status=fulfilled
« Refuser »The payment fails. Nothing is delivered.failedcancelUrl, with ?order=<id>&status=failed

If the player closes the page without choosing, the order stays pending and expires after one hour.

The page also lets the buyer change the country, so you can see how the VAT changes. See Selling packs.

A test plan

Try each of these before you call your integration done. Every one is a real case your players will meet.

CaseHow to try itExpect
A new playerOpen the game in a fresh browser profile or a private windowA new anonymous player, with balances at 0
The same player returnsReload the pageSame player, same balance
A paid packPay in the simulated pageStatus fulfilled, balance up by the pack, change event fired
A declined paymentPress « Refuser »Status failed, balance unchanged, a clear message
A closed payment windowClose it without payingStatus pending, balance unchanged
Not enough currencySpend more than the balanceINSUFFICIENT_FUNDS with required and available; your shop opens
An item at its limitBuy a durable item twiceLIMIT_REACHED; your game shows "already owned"
A double clickClick "buy" twice quicklyTwo purchases: each call has its own key. Disable the button while a call runs. A second gc.checkout() during the first fails with CONFLICT.
A retrySend the same write twice with one idempotency keyThe same answer, Idempotent-Replayed: true
An expired tokenWait an hour, or use a token you alteredThe SDK renews it once; your onTokenExpired runs
A blocked player« Bloquer » in the dashboardPLAYER_BLOCKED on every call
A refund« Rembourser » on an order, after spending some of itA debt, or a shortfall: see Refunds
A popup blockerTurn it on in the browserThe SDK falls back to a redirect, and gc.returnedOrder has the order on return

Test with a script

For automated tests, give each run its own players. The ledger never forgets, so a player you reuse carries the balance of the last run. Make the id from the run:

LangageLanguage
PLAYER="ext%3Aci-$(date +%s)"

curl -X POST "https://gamecoin.apilow.com/api/v1/players/$PLAYER/wallet/grant" \
  -H "Authorization: Bearer $GAMECOIN_SECRET_KEY" \
  -H "Idempotency-Key: seed-$PLAYER" \
  -H "Content-Type: application/json" \
  -d '{"currency":"gems","amount":100}'

Keep a game for testing, with its own test keys, and put its secret key in the secret store of your CI, never in the repository.

The server SDKs generate an idempotency key for every call, so the script above needs none. With curl you give one.

To test a payment from a script, create the checkout through the API, then open checkoutUrl and press « Payer » once by hand, or drive the page with a browser test tool. Then read the order with GET /orders/{orderId}.

Go live

The live environment is for verified studios and real payments, and neither is available yet. Because the key picks the environment, going live later means changing the keys that your game and your server read, and nothing else. Until then, this page is how to be ready.

Where next