How to manage user balance
Do I need this?
If you want to manage your users' balance in your own system, you can use this API.
This API can:
- Provide player's balance in cents and tokens
- Deduct player's tokens in cents
- Add player's tokens in cents
Prerequisites
- Active account in the Scrimmage Rewards Program
- User's auth token. Check Get started section for more details.
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 that you want to charge player's for 100 cents for the T-shirt purchase. 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 to create a special data type for adding tokens to player's balance and game rule for it.
Updated 27 days ago