Skip to content

Balance Query Callback ​

VCT Platform queries the player's available balance on the Agent (Operator) side while processing a game launch request.

Note

VCT calls this API after a player requests a game launch and before game entry is confirmed, to query the available balance and create a temporary launch_pending record. The Agent must implement this endpoint for VCT.

A successful /balance response means only that the balance query and launch preparation succeeded; it does not mean the player entered the game. The game becomes enterable only after VCT returns code=0, a non-empty game_url, and the matching session_id is confirmed.

Environment URLs ​

EnvironmentBase URL
Productionhttps://hub-panel-api.v7stech.com
Staginghttps://hub-panel-api-dev.v7stech.com

Endpoint ​

PropertyValue
PathPOST /api/v1/callback/balance
CallerVCT Platform → Agent (Operator)

Authentication and Signature ​

See Authentication for the common Header Token rule. This endpoint's Body sign is HMAC-SHA256(username + "." + timestamp, agent_api_secret); the Header and Body timestamps must match exactly.

Request Parameters (from VCT) ​

ParameterTypeRequiredDescription
usernamestringYesPlayer username
currencystringYesCurrency code
session_idstringYesUnique session ID generated by Hub for this game launch
game_idstringYesHub game-directory GUID; use it to look up the Brand in the synced directory
providerstringNoProvider code for cross-checking only
brand_guidstringYesStable Hub Brand identifier for linkage and auditing
brand_codestringYesCurrent Brand business code for audit display
brand_namestringYesCurrent Brand display name for audit display
signstringYesRequest signature
timestamplongYesRequest timestamp

Session, Game, and Brand Identity ​

The Agent must use session_id + game_id as the primary identity of this balance request, then look up brand_guid from its synced game directory using game_id. provider is only a cross-check and must not be the sole key for a game, session, or Brand. Hub's brand_guid is for linkage and audit; brand_code and brand_name are display snapshots and must not merge Brands with different GUIDs.

Response Fields ​

FieldTypeRequiredDescription
statusstringYesProcessing status: success / player_not_found / error
balancedecimalYesPlayer's current available balance (only valid when status is success)
currencystringYesCurrency code (required when status is success)
usernamestringYesPlayer username (required when status is success)

Example Request ​

json
{
  "username": "player001",
  "currency": "MYR",
  "session_id": "vct-session-uuid-001",
  "game_id": "hub-game-guid-001",
  "provider": "gsc",
  "brand_guid": "3d3e51ba-1a7d-47b8-9dc8-3b9d99ef68fc",
  "brand_code": "YB",
  "brand_name": "YB Brand",
  "sign": "9a2f64d0bcfa829...",
  "timestamp": 1783324700
}

Example Response ​

Success Response ​

json
{
  "status": "success",
  "username": "player001",
  "currency": "MYR",
  "balance": 100.00
}

Player Not Found (Abort login) ​

json
{
  "status": "player_not_found"
}

Validation Logic & Processing Recommendations ​

1. Strict Authentication Verification ​

  • The Authorization Header is mandatory; verifying only the Body sign is not sufficient.
  • The agent_api_key must resolve to the matching agent_api_secret; do not try multiple Secrets.
  • Reject the request when the Header and Body timestamps differ.

2. Strict Status Verification ​

  • Status Field is Mandatory: The response returned by the Agent system must contain the status field.
  • Reject Game Access: If status is missing, or its value is not "success" (e.g. "player_not_found", "error", etc.), VCT Platform will immediately terminate the game launching process and throw a login exception. This prevents invalid or non-existent players from entering the game and causing subsequent wallet reclaim failures.

3. Player Account Checks ​

  • It is recommended that the Agent system evaluates the player's account status (e.g., whether it is suspended, locked, etc.) during a /balance query. If the player is not allowed to play, return {"status": "player_not_found"} or {"status": "error"} to abort the launch.

Provider Source Mapping ​

ProviderCallback PathRequest Format
BGopen.operator.user.balanceJSON-RPC 2.0 (sn/sign/random)
GSCseamless/balanceJSON (operator_code/sign/request_time)
SAGetUserBalanceEncrypted URL-encoded body
WMwebhook (cmd=CallBalance)form-data (cmd/signature/user)

AI Implementation Prompt (Copy Ready) ​

text
Implement the Agent endpoint POST /api/v1/callback/balance for Hub balance queries. The request includes username, currency, session_id, game_id, provider, brand_guid, brand_code, brand_name, sign, and timestamp.

Requirements:
1. Verify Authorization Bearer {agent_api_key}.{timestamp}.{header_signature}, where header_signature is lowercase hex HMAC-SHA256(agent_api_key + "." + timestamp, agent_api_secret).
2. Header timestamp must exactly equal Body timestamp and be within the accepted window. Compare signatures in constant time.
3. Verify Body sign as lowercase hex HMAC-SHA256(username + "." + timestamp, agent_api_secret). Never try another Agent's Secret.
4. Query the exact username + currency wallet, validate player/currency/account state, and use decimal money types.
5. Use session_id + game_id as the launch identity. Persist session_id unchanged and enforce a unique launch_pending record for Agent + username + currency + session_id. Look up brand_guid from game_id in the synced directory; provider is only a cross-check. Persist Hub brand_guid, brand_code, and brand_name as audit snapshots without merging Brands by code or name.
6. Return status=success with balance and currency only after success. Return player_not_found/error to stop launch when invalid.
7. Balance success is preparation only: do not record enter_game until Game Launch succeeds with the same session_id.
8. Process repeated session_id requests idempotently without duplicate locks or records.
9. Redact Secret, Token, and signatures from logs. Test auth/body signatures, timestamp mismatch/expiry, player/currency/account errors, duplicates, and decimal precision.

Reuse the project's auth, wallet, transaction, and error components. Deliver route, service, idempotent storage, and tests.

VCT Gaming Integration Platform