Integration Guide EN InfinityAPI Documentation Ye docs aapko InfinityAPI integrate karne me help karega. Aapko API Key + Client Secret (HMAC signature) chahiye. Ye aapko Master Admin provide karega (ya aap Tokens page me dekh sakte ho). 1) Base URL https://infinityapi.site All endpoints below isi domain pe hain. 2) Authentication + Security - api_key: har request me query parameter me pass hota hai. - Signature (Recommended): ts aur sig se request verify hota hai. - IP Whitelist (Optional): agar Master ne enable kiya hai to only whitelisted IPs allowed. Signature format (HMAC-SHA256) data = api_key|user_id|game_uid|balance|ts sig = hmac_sha256(data, client_secret) - ts seconds timestamp recommended (ms bhi chalega). Time window ±120 seconds. - sig lowercase hex. 3) Launch Game - Complete PHP Example PHP Integration Code (Copy & Paste) $apiKey, 'user_id' => $userId, 'game_uid' => $gameUid, 'balance' => $balance, 'ts' => $ts, 'sig' => $sig, // Optional parameters // 'currency_code' => 'INR', // 'language' => 'en', // 'return_url' => 'https://your-site.com/return', // 'callback_url' => 'https://your-site.com/callback' (for client-side reference mainly) ]); $fullUrl = $apiUrl . '?' . $queryString; // Execute Request // You can redirect user directly OR fetch JSON if you want to inspect response first $response = file_get_contents($fullUrl); if ($response !== false) { $result = json_decode($response, true); if (isset($result['ok']) && $result['ok'] === true && isset($result['game_url'])) { // Success! Redirect user to game header("Location: " . $result['game_url']); exit; } else { // Handle Error echo "Error Launching Game: " . ($result['error'] ?? 'Unknown Error'); } } else { echo "API Request Failed (Network/Server Error)"; } ?> 4) Callback Handler - PHP Example Create a file (e.g., callback.php) on your server and set its URL in the Master Panel > Clients > Settings (Forward Callback URL). callback.php Code 'error', 'message' => 'Invalid JSON']); exit; } // 2. Extract Data $userId = $data['member_account'] ?? ''; // Your user ID passed during launch $gameUid = $data['game_uid'] ?? ''; $betAmount = (float)($data['bet_amount'] ?? 0); $winAmount = (float)($data['win_amount'] ?? 0); $netAmount = $winAmount - $betAmount; // Profit/Loss // System calculated credit amount (if needed) $creditAmount = $data['credit_amount'] ?? -1; // 3. Process Transaction in YOUR Database // Example Logic: // $user = getUser($userId); // $newBalance = $user['balance'] + $netAmount; // updateUserBalance($userId, $newBalance); // logTransaction($userId, $gameUid, $betAmount, $winAmount); // 4. Log for debugging file_put_contents('callback.log', date('[Y-m-d H:i:s] ') . $rawInput . PHP_EOL, FILE_APPEND); // 5. Respond "OK" (InfinityAPI doesn't strictly require a specific response body for forwarding, but HTTP 200 is good) echo json_encode(['status' => 'success', 'new_balance' => 0]); // Replace 0 with actual new balance if you want ?> Note: InfinityAPI handles the immediate credit/debit with the game provider to ensure speed. This callback is forwarded to you for synchronization with your database. 5) Return URL (Game close) GET /v1/return If you don't pass a return_url param, the user will see a default "Game Closed" page.