# Set-up, going live and hosting

## Before go-live (tools/go-live.php refuses until these are done)
1. **Tax invoice details** — Settings → invoices: legal name, registration number, VAT number (10 digits starting with 4), address, invoice e-mail.
2. **Gateway fees** — Fees & margins step 3: the payment gateway's real % and fixed fee (currently 2.9% + R2).
3. **Live margins** — Fees & margins step 4: every sector we sell.
4. **E-mail** — Settings: mail switched on, sending address at our own domain, SMTP server (port 587 STARTTLS or 465 SSL); send yourself a test.
5. **Back office address** (admin_url) — the public https address used in e-mail links.
6. **Two-step sign-in** for every admin (My profile → Two-step sign-in; keep the recovery codes).
7. **Cron job** on the server every 15 minutes: `php -d extension=pdo_sqlite <path>/tools/cron.php` (confirmations, balances, reminders, daily backups, the books check).
8. Run `tools/go-live.php` (dry run first). With --yes it backs up, then clears test transactions; refuses if a live-mode payment exists. From go-live the books are sealed and money actions need two-step sign-in.

## The payment gateway
Any gateway (including our own planned one) must keep four rules: the amount is worked out on the server; the billing guard above R5 000; only a lookup with the gateway marks a payment paid; a successful payment is never changed. In anything people see we say "gateway fees (card)" or "payment gateway", never the gateway company's name.

## Hosting (Afrihost shared cPanel, Linux)
- Address: https://getaway.apitravelsolutions.com — subdomain document root = `getaway/public`.
- Corporate bookers on the same server at `/<shortname>/` (folders in corporate/clients); a client's own domain is added in the hosting panel with the same folder and its free certificate.
- Updates go up as zips built outside the repo (C:\Users\Personal\IdeaProjects\GETAWAY_deploy):
  - **code-only zip** = for the live server; keeps the live database, config and corporate data. New tables create themselves.
  - **complete/showcase zip** = a fresh server only; it REPLACES the database and config — never upload it over a live server.
- Never zipped: partner documents (KYC), backups, the link key, encryption key, logs, TravelClip's memory.
- Storage, config and src folders are denied to the web.

## Local development
- Platform: `C:\PHP84\php.exe -d extension=pdo_sqlite -d extension=sqlite3 -S 0.0.0.0:8090 -t public public/router.php` → http://localhost:8090 (admin at /admin/).
- Corporate booker: same with `-S 0.0.0.0:8091 -t corporate/public corporate/public/router.php`.
- Phone on the same Wi-Fi: http://192.168.1.103:8090 (the address can change between networks; the Android app is built for a fixed address).
- TravelClip: double-click travelbrain\Start TravelClip.cmd (brain on 127.0.0.1:8188).

## Self-tests (run before every update zip)
- `tools/backoffice-audit.php` (522 checks; run with GW_AUDIT_SOURCE = the pre-sortout baseline backup), `tools/security-audit.php` (74), `tools/books-proof.php` (53 identities), `tools/ledger-fuzz.php`, `tools/books-fuzz.php`.
