# ๐ŸŽฎ Play Game Setup Guide - TBS2 Integration ## โœ… Current Status (April 9, 2026) ### What's Working: - โœ… Callback endpoint accessible at `http://localhost/api/callback.php` - โœ… Authentication working (Hall ID: 3210917, Key verified) - โœ… Database queries successful - โœ… User balance retrieval working (sadok12: 300,000 IDR) - โœ… Game ID mapping correct (The Catfather = TBS2 ID 12222) - โœ… Response format matches TBS2 specification - โœ… Ngrok tunnel is ONLINE ### What's NOT Working: - โŒ **Cannot open games** - Error: `hall_balance_less_100` - โŒ TBS2 API rejects openGame requests --- ## ๐Ÿ”ง REQUIRED ACTION: Add Balance to Hall in TBS2 Admin ### Step 1: Login to TBS2 Admin Panel ``` URL: https://tbs2api.dark-a.com/admin/ ``` ### Step 2: Find Your Hall - Look for **Hall ID: 3210917** - Hall Name: allgames (or similar) - Currency: IDR ### Step 3: Check/Add Balance You need to add balance in ONE of these fields (depending on your mode): #### Option A: Real Money Mode (GAME_DEMO_MODE=0) - Field: **Balance** or **Deposit** - Amount: Minimum **100 IDR** (recommended: 1000+ IDR) #### Option B: Demo Mode (GAME_DEMO_MODE=1) โ† CURRENT MODE - Field: **Demo Balance** - Amount: Minimum **100 IDR** (recommended: 1000+ IDR) ### Step 4: Verify Callback URL In the same Hall configuration page, ensure: ``` Callback URL: https://fumed-querulously-leslee.ngrok-free.dev/api/callback.php ``` If ngrok URL has changed, update it! ### Step 5: Save Configuration Click **Save** or **Update** button. --- ## ๐Ÿงช Testing After Adding Balance ### Test 1: Run Complete Play Game Test ```bash cd c:\xampp\htdocs php test_complete_play_game.php ``` Expected output: ``` โœ… Game opened successfully! Game URL: https://... ``` ### Test 2: Monitor Hall Status (Automatic Retry) ```bash php monitor_hall_status.php ``` This will automatically retry every 5 seconds until Hall is ready. ### Test 3: Manual Browser Test 1. Open browser: `http://localhost/` 2. Login as user: `sadok12` 3. Navigate to game lobby 4. Click on "The Catfather" or any game 5. Game should open in iframe/popup --- ## ๐Ÿ“‹ Configuration Summary ### Environment Variables (.env) ```env GAME_API_URL=https://tbs2api.dark-a.com/API/ GAME_API_SECRET=otYLUhFp5rye7944WQdGOE1z1 GAME_HALL_ID=3210917 GAME_DEMO_MODE=1 APP_URL=https://fumed-querulously-leslee.ngrok-free.dev ``` ### Apache Configuration - DocumentRoot: `C:/xampp/htdocs` (changed from `/public`) - Access: `http://localhost/` (no `/public` needed) ### Database - User: sadok12 (ID: 4) - Balance: 300,000 IDR - Game: The Catfather (DB ID: 8960, TBS2 ID: 12222) --- ## ๐Ÿ” Troubleshooting ### Problem: Still getting `hall_balance_less_100` **Solution:** 1. Double-check you added balance to the CORRECT Hall (3210917) 2. Make sure you're checking the right field (Demo Balance vs Real Balance) 3. Try adding MORE balance (e.g., 1000 IDR instead of 100) 4. Refresh/reload the Hall configuration page in admin panel 5. Wait 1-2 minutes and try again ### Problem: Ngrok URL expired/changed **Solution:** ```bash # Stop current ngrok (Ctrl+C in ngrok terminal) # Restart ngrok: ngrok http 80 # Copy new URL and update: # 1. .env file (APP_URL) # 2. TBS2 Admin Panel (Callback URL) ``` ### Problem: 404 Error on callback **Solution:** Verify Apache DocumentRoot is set correctly: ```apache # In C:\xampp\apache\conf\httpd.conf DocumentRoot "C:/xampp/htdocs" ``` Then restart Apache. ### Problem: Callback not receiving requests **Check Apache error logs:** ``` C:\xampp\apache\logs\error.log ``` **Test callback manually:** ```bash php test_callback_localhost.php ``` --- ## ๐Ÿ“ž Support Checklist If still having issues, prepare this information: 1. โœ… Hall ID: 3210917 2. โœ… Currency: IDR 3. โœ… Current Balance: [Check in TBS2 admin] 4. โœ… Demo Balance: [Check in TBS2 admin] 5. โœ… Callback URL: [Current ngrok URL] 6. โœ… GAME_DEMO_MODE: 1 7. โœ… Test User: sadok12 (Balance: 300,000 IDR) 8. โœ… Test Game: The Catfather (TBS2 ID: 12222) 9. โœ… Error Message: hall_balance_less_100 10. โœ… Ngrok Status: Online (HTTP 404 to root is normal) --- ## ๐ŸŽฏ Success Criteria Play game is working when: - โœ… `test_complete_play_game.php` returns success - โœ… Game URL is returned from TBS2 API - โœ… Can open game in browser without errors - โœ… Callback getBalance returns user balance - โœ… No `hall_balance_less_100` error --- ## ๐Ÿ“š Related Files - **Test Scripts:** - `test_complete_play_game.php` - Full integration test - `test_callback_localhost.php` - Callback endpoint test - `monitor_hall_status.php` - Automatic retry monitor - **Core Files:** - `app/config/game_api.php` - TBS2 API client - `app/controllers/GameController.php` - Game logic - `app/controllers/ApiController.php` - Callback handler - `public/api/callback.php` - Callback entry point - **Configuration:** - `.env` - Environment variables - `C:\xampp\apache\conf\httpd.conf` - Apache config --- **Last Updated:** April 9, 2026 **Status:** Waiting for Hall balance to be added in TBS2 admin