Le check-in remplace l'intégration banking V1 (cf. CLAUDE.md → Glossaire) :
avant que la 1re relance ne parte, on demande à l'user "as-tu été payé ?"
via email, et il clique sur l'un des 2 liens publics.
Service checkin_token.ts : génération + hash SHA-256. 32 bytes random base64url, plain dans le mail, hash en DB (CheckinTask.token_hash unique).
Service checkin_scheduler.ts :
- scheduleCheckinForInvoice(invoice) : crée 1 CheckinTask à dueDate (now+1min si dueDate dans le passé). Idempotent par invoice — cancel les scheduled précédents avant.
- cancelCheckinForInvoice(invoiceId) : appelé par mark-paid pour stopper.
Job send_checkin_job.ts : worker queue 'checkins', skip si invoice paid/cancelled (no-op), construit l'URL avec le plain token (passé dans le payload du job, pas relu DB), appelle sendCheckinEmail.
mail_dispatcher.ts : sendCheckinEmail() — texte brut, destinataire = user (pas client !), 2 URLs (paid / pending), TTL 24h annoncé.
Controller CheckinController :
- GET /api/v1/checkin/:token/paid : status=answered + answer=paid + mark invoice paid (mêmes effets que POST /invoices/:id/mark-paid : rubis +1, ActivityEvent invoice_paid avec label "via check-in", cancelFutureRelances). Idempotent : 2e click → redirect "already_answered".
- GET /api/v1/checkin/:token/pending : status=answered + answer=still_pending. Les relances suivent leur cours.
- Validation : lookup hash, expiry (sentAt + 24h), redirects propres pour invalid / expired / already_answered.
Routes : nouveau group public `checkin` (PAS de middleware.auth) à côté du group auth, sous /api/v1.
Triggers branchés :
- InvoicesController.store et ImportBatchesController.validateDraft → scheduleCheckinForInvoice après création
- InvoicesController.markPaid → cancelCheckinForInvoice dans la tx
start/queue.ts : registerWorker('checkins', sendCheckinJob).
env : nouveau WEB_URL (URL du SPA pour redirects), default localhost:5173 en dev.
Bruno : nouveau dossier 08-Checkin avec doc complète du flow + 2 requêtes (paid / pending). var d'env `checkinToken` à remplir manuellement après avoir reçu l'email dans Mailpit.
76 lines
2.2 KiB
Plaintext
76 lines
2.2 KiB
Plaintext
# Node
|
|
TZ=UTC
|
|
PORT=3333
|
|
HOST=localhost
|
|
NODE_ENV=development
|
|
|
|
# App
|
|
LOG_LEVEL=info
|
|
APP_KEY=
|
|
APP_URL=http://${HOST}:${PORT}
|
|
|
|
# Session
|
|
SESSION_DRIVER=cookie
|
|
|
|
#--------------------------------------------------------------------
|
|
# CORS (configure allowed origins for API access)
|
|
#--------------------------------------------------------------------
|
|
# CORS_ORIGIN=http://localhost:5173,http://localhost:3000
|
|
|
|
#--------------------------------------------------------------------
|
|
# Database (Postgres via docker-compose.dev.yml)
|
|
#--------------------------------------------------------------------
|
|
DB_CONNECTION=postgres
|
|
PG_HOST=localhost
|
|
PG_PORT=5433
|
|
PG_USER=rubis
|
|
PG_PASSWORD=rubis
|
|
PG_DB_NAME=rubis_dev
|
|
|
|
#--------------------------------------------------------------------
|
|
# Redis (BullMQ + cache)
|
|
#--------------------------------------------------------------------
|
|
REDIS_HOST=localhost
|
|
REDIS_PORT=6380
|
|
REDIS_PASSWORD=
|
|
|
|
#--------------------------------------------------------------------
|
|
# Storage (MinIO via S3 driver)
|
|
#--------------------------------------------------------------------
|
|
DRIVE_DISK=s3
|
|
S3_ENDPOINT=http://localhost:9100
|
|
S3_REGION=fr-par
|
|
S3_BUCKET=rubis-invoices
|
|
S3_ACCESS_KEY=rubis
|
|
S3_SECRET_KEY=rubis-dev-secret
|
|
S3_FORCE_PATH_STYLE=true
|
|
|
|
#--------------------------------------------------------------------
|
|
# Mail (Mailhog en dev, Resend en prod)
|
|
#--------------------------------------------------------------------
|
|
MAIL_FROM_ADDRESS=relances@rubis-sur-l-ongle.fr
|
|
MAIL_FROM_NAME=Rubis Sur l'Ongle
|
|
MAIL_DRIVER=smtp
|
|
SMTP_HOST=localhost
|
|
SMTP_PORT=1025
|
|
RESEND_API_KEY=
|
|
|
|
#--------------------------------------------------------------------
|
|
# OCR (Mistral)
|
|
#--------------------------------------------------------------------
|
|
OCR_PROVIDER=mock
|
|
MISTRAL_API_KEY=
|
|
|
|
#--------------------------------------------------------------------
|
|
# Web (URL du SPA, utilisée pour les redirects post-checkin)
|
|
#--------------------------------------------------------------------
|
|
WEB_URL=http://localhost:5173
|
|
|
|
#--------------------------------------------------------------------
|
|
# Auth (refresh tokens)
|
|
#--------------------------------------------------------------------
|
|
ACCESS_TOKEN_TTL_MINUTES=30
|
|
REFRESH_TOKEN_TTL_DAYS=30
|
|
COOKIE_DOMAIN=
|
|
COOKIE_SECURE=false
|
|
LIMITER_STORE=redis |