PXG_2026_API/README.md

67 lines
2.2 KiB
Markdown

# TOURNAMENT PXG 2026 — Laravel API Skeleton (matches Vue frontend contract)
This is a **Laravel API skeleton** you can copy into an existing Laravel 10/11 project.
It matches the frontend contract used by the Vue project:
## Endpoints (v1)
- `GET /api/v1/events/{event}`
- `POST /api/v1/events/{event}/registrations`
- `POST /api/v1/events/{event}/groups`
- `GET /api/v1/groups/{code}`
- `POST /api/v1/groups/{code}/join`
- `POST /api/v1/registrations/{registration}/pay`
- `POST /api/v1/pairing/lookup`
- `POST /api/v1/pairing/otp/request`
- `POST /api/v1/pairing/otp/verify`
- `GET /api/v1/pairing/me` (Bearer pairing_token)
- `POST /api/v1/webhooks/xendit`
## Environment variables (.env)
Add:
- `XENDIT_API_KEY=...`
- `XENDIT_WEBHOOK_TOKEN=...` (the token you set in Xendit dashboard)
- `WA_OTP_DRIVER=log` (default) or your provider driver name
- `PAIRING_TOKEN_TTL_MINUTES=30`
- `OTP_TTL_MINUTES=5`
## WhatsApp OTP
This skeleton provides an interface `OtpSenderInterface` + default driver `LogOtpSender` which writes OTP to logs.
Replace it with your WhatsApp Business API provider integration.
## Xendit
This skeleton includes a minimal `XenditService` stub.
Replace `createInvoice()` with real Xendit Invoice API call and map the webhook payload accordingly.
## Installation approach
1. Create a fresh Laravel project (or use existing).
2. Copy the `app/`, `routes/`, and `database/migrations/` from this skeleton into your project.
3. Run migrations:
```bash
php artisan migrate
```
4. Seed flights:
```bash
php artisan pxg:seed-flights --event=1
```
5. Configure `.env` and run:
```bash
php artisan serve
```
## Notes
- Pairing token is an **encrypted bearer token** (not Sanctum), issued after OTP verification.
- OTP uses hashing + rate-limits (basic) + attempt limits.
- Pairing assignment logic is **NOT implemented** here (you can plug your pairing job/service later).
The API returns pairing info only if a registration has been assigned to a flight via `flight_members`.
## Admin Dashboard (API)
- Login: `POST /api/v1/admin/login` with email+password -> returns Sanctum token
- Default seeded admin:
- email: `admin@pxg.local`
- password: `pxg2026admin`
Run:
```bash
php artisan db:seed --class=AdminUserSeeder
```