# Deploy Endorphina Seamless Wallet to https://test.grandvipbet.com/

## Requirements (cPanel)

- PHP **8.3+**
- Extensions: `bcmath`, `openssl`, `mbstring`, `tokenizer`, `xml`, `ctype`, `json`, `fileinfo`, `pdo`
- Apache `mod_rewrite` enabled
- SSL for `test.grandvipbet.com`
- Writable folders: `storage/`, `bootstrap/cache/`

## Upload layout (best)

Point subdomain document root to Laravel `public/`:

```
/home/USER/test.grandvipbet.com/     ← project root (outside web if possible)
  app/
  bootstrap/
  config/
  public/                            ← DOCUMENT ROOT for test.grandvipbet.com
  storage/
  vendor/
  .env                               ← copy from .env.staging
```

If you **cannot** change document root, upload the whole project into the subdomain folder and copy `cpanel-root.htaccess` → `.htaccess` in that folder.

## Steps

1. Build zip locally (PowerShell):

```powershell
cd C:\Users\imran\Documents\server\api
.\deploy\build-cpanel-zip.ps1
```

2. Upload `deploy/grandvipbet-seamless-test.zip` via cPanel File Manager / FTP.
3. Extract into the subdomain directory.
4. Rename `.env.staging` → `.env` on the server (or upload as `.env`).
5. In cPanel → MultiPHP, set this subdomain to **PHP 8.3** (or higher).
6. Set permissions:
   - `storage` and `bootstrap/cache` → `775` (or writable by web user)
7. Create empty SQLite DB if using default staging env:

```bash
# SSH (if available)
cd ~/test.grandvipbet.com
touch database/database.sqlite
php artisan config:clear
php artisan cache:clear
```

If no SSH: create empty file `database/database.sqlite` in File Manager. File cache still works without migrations for this demo wallet.

8. Confirm endpoints (signature required — 401 without sign is OK):

- https://test.grandvipbet.com/check
- https://test.grandvipbet.com/session
- https://test.grandvipbet.com/balance
- https://test.grandvipbet.com/up

9. Open demo launcher:

- https://test.grandvipbet.com/demo

10. Email Endorphina (if not already):

```
Endpoint URL for test keys: https://test.grandvipbet.com/
Server IP: 209.74.68.3
Domain for demo: test.grandvipbet.com
```

## Live game launch

Use https://test.grandvipbet.com/demo or:

```
https://test.endorphina.network/api/sessions/seamless/rest/v1?nodeId=3612&token=YOUR_TOKEN&exit=https://test.grandvipbet.com&sign=SHA1(3612+YOUR_TOKEN+SECRET)
```

## After deploy checklist

- [ ] PHP 8.3+ with bcmath
- [ ] Document root = `public/` (or root `.htaccess` shim)
- [ ] `.env` has `APP_URL=https://test.grandvipbet.com`
- [ ] `ENDORPHINA_NODE_ID=3612` and matching secret
- [ ] `storage` writable
- [ ] `/demo` page loads
- [ ] Endorphina confirmed callback URL
