# HalaVoice Salla App — Deployment Checklist

## Completed
- [x] PostgreSQL database `halavoice_salla` created + 23 migrations + seeders
- [x] PHP 8.3 (cPanel ea-php83) configured in PM2
- [x] `.env` switched to PostgreSQL + production mode
- [x] PM2 ecosystem (`salla-app-web` port 4020 + `salla-app-queue` worker)
- [x] Config/routes/views cached, storage linked
- [x] CSRF webhook exclusion fixed (`bootstrap/app.php`)
- [x] CDN Tailwind replaced with built Vite assets (`@vite`)
- [x] `app-config.json` manifest created (Salla Partners Portal reference)
- [x] Webhook signature verification working (401 instead of 419)
- [x] `resources/assets/screenshots/` directory created

## TODO Before Salla App Gallery Submission

### 1. Salla Partners Registration
- [ ] Register at https://portal.salla.partners/
- [ ] Create a Public App (category: General)
- [ ] Get `client_id` and `client_secret`
- [ ] Put them in `.env`:
  ```
  SALLA_CLIENT_ID=<from portal>
  SALLA_CLIENT_SECRET=<from portal>
  ```

### 2. Reverse Proxy + SSL
- [ ] Set up Apache/Nginx reverse proxy: `salla.halavoice.store` → `127.0.0.1:4020`
- [ ] Install SSL certificate (Let's Encrypt or cPanel AutoSSL)
- [ ] Verify HTTPS works: `curl https://salla.halavoice.store/health`

### 3. Partners Portal Configuration
- [ ] Set **Webhook URL**: `https://salla.halavoice.store/webhook`
- [ ] Set **OAuth Redirect URI**: `https://salla.halavoice.store/oauth/callback`
- [ ] Add **Trusted IP** (server public IP)
- [ ] Select all **App Scopes** (9 scopes — see `app-config.json` oauth.scopes)
- [ ] Subscribe to **10 App Events** (see `app-config.json` webhook_events.app_events)
- [ ] Subscribe to **13 Store Events** (see `app-config.json` webhook_events.store_events)
- [ ] Configure **App Settings** fields (8 fields — see `app-config.json` app_settings.fields)

### 4. App Assets
- [ ] Create **app icon** (250×250px PNG) → `resources/assets/app-icon.png`
- [ ] Take **5 screenshots** → `resources/assets/screenshots/`:
  - `dashboard-overview.png` — لوحة التحكم الرئيسية
  - `call-logs.png` — سجل المكالمات
  - `automation-rules.png` — قواعد الأتمتة
  - `voice-scripts.png` — النصوص الصوتية
  - `billing.png` — الفواتير
- [ ] Fill in **Basic Information** (name AR/EN, description, support email)
- [ ] Upload icon + screenshots in Partners Portal

### 5. Pricing Plans
- [ ] Configure in Partners Portal → Custom Plans:
  - **Starter**: 99 SAR/month — 500 min, 1K WhatsApp
  - **Growth**: 299 SAR/month — 2K min, 5K WhatsApp (popular)
  - **Pro**: 599 SAR/month — 5K min, 15K WhatsApp
- [ ] Set **14-day free trial**

### 6. HalaVoice API Credentials
- [ ] Set in `.env`:
  ```
  HALAVOICE_API_KEY=<from halavoice.store admin>
  HALAVOICE_API_SECRET=<from halavoice.store admin>
  ```
- [ ] Verify `/health` endpoint shows `halavoice_api: true`

### 7. Testing
- [ ] Test OAuth flow: `https://salla.halavoice.store/oauth/redirect`
- [ ] Test webhook delivery from Salla demo store
- [ ] Test COD confirmation call
- [ ] Test abandoned cart WhatsApp message
- [ ] Test shipping notification
- [ ] Test app install/uninstall lifecycle events
- [ ] Write basic Feature tests (OAuth, webhook, HalaVoice client)

### 8. Publishing
- [ ] Use Salla demo store for full testing (OTP: `1111`)
- [ ] Click "Start Publishing your App" in Partners Portal
- [ ] Fill all 6 publishing sections:
  1. Basic Information
  2. App Configurations
  3. App Features
  4. Pricing
  5. Contact Information
  6. Service Trial
- [ ] Submit for Salla review

## Architecture Summary
- **App**: Laravel 13.17 + PHP 8.3 (cPanel ea-php83)
- **DB**: PostgreSQL `halavoice_salla` (user: agentlabs)
- **PM2**: `salla-app-web` (port 4020) + `salla-app-queue`
- **PHP binary**: `/opt/cpanel/ea-php83/root/usr/bin/php`
- **Config file**: `app-config.json` (reference for Partners Portal)
- **Webhook**: `/webhook` (Salla) + `/zid/webhook` (Zid)
- **OAuth**: `/oauth/redirect` → `/oauth/callback`
- **Dashboard**: 10 pages (overview, call-logs, whatsapp-logs, automation-rules, billing, settings, voice-scripts, whatsapp-templates, recovered-revenue, setup-wizard)

## HalaVoice Main App (halavoice.store) Status
- Build: `npm run build` passes ✅
- tsc errors: 77 remaining (non-blocking, runtime works)
- PM2: `halavoice` process online (port 5003)
- DB: PostgreSQL `agentlabs` (user: agentlabs)
