How to manage user balance through API

Do I need this?

If you want to manage your users' balance in your system, you can use this API.
This API can:

Prerequisites

Get player balance in cents

Check Get game information for user endpoint.

Response example:

{
  "tokens": 0,
  "balanceInCents": 0,
  "levelConfig": {
    ...
  },
  "nextLevelConfig": {
    ...
  },
  "daily": {
    ...
  }
}

Use balanceInCents field to get player's balance in cents and tokens field to get player's balance in tokens.

Deduct player's tokens in cents

Check Charge user endpoint.

Body example:

{
  "amount": 100,
  "currency": "USD_CENTS",
  "transactionId": "unique_transaction_id",
  "reason": "T-shirt purchase"
}

It means you want to charge players 100 cents for the T-shirt purchase. The reason will be shown in the player's transaction history.

Amount in cents will be converted to tokens according to the current rate. The response is a charged amount converted to tokens.

Add tokens to player's balance in cents

We recommend creating a special data type for adding tokens to player's balance and game rule for it.