R1/R4: saved_card branch in CreateTerminalPayment now mirrors CreateTipPayment - advisory lock (crussell:payment:<bookingID>) serializes concurrent double-clicks - deterministic key bookingID-sc-type-amount-cardID (<=45 chars) so a lost-response retry derives the same key and dedups instead of double-charging - idempotency switch inside the lock: completed -> dedup, pending -> reuse with pence amount-guard, failed -> clean 409 - success response includes card_brand/card_last4 (frontend already reads them) R2: add 'failed' case to all four retry switches (tip, booking, gift card, till) - a swept/definitively-rejected record returns 409 instead of 500-ing on the idempotency_key UNIQUE constraint R3: extend SweepStalePendingPayments to till_sales card rows - sweeps pending till_sales (online_square/in_person_card) past Square's ~24h key retention, closing the double-charge window for till sales - swept rows logged with the same CRITICAL manual-reconciliation marker as the refund sweep Webhook fail-closed: reject 503 when SQUARE_WEBHOOK_SIGNATURE_KEY unset, 403 on bad signature (was: skip verification in dev) Refund status resolution: refunds now resolve by Square status (COMPLETED/PENDING/FAILED/REJECTED) instead of assuming completed; real error codes (REFUND_AMOUNT_INVALID, PAYMENT_NOT_REFUNDABLE, REFUND_ALREADY_PENDING) added to the definitive/processed classification HTTP client: CreateCard key truncated to <=45 chars, device_options always sent (env SQUARE_TERMINAL_DEVICE_ID fallback), processing_fee reads amount_money, ListCards cursor loop, refund keys hashed to <=45 chars Other fixes: payment/till/gift-card advisory-lock + FOR UPDATE asymmetries, GetPaymentByID NULL scans, loyalty redemption lock, card upsert on conflict, mock ccof: prefix parity, IsValidSquareCheckoutID for real Square IDs, isAdminRequest defense-in-depth on all 6 admin payment handlers, webhook signature docs, M8/L5 debug markers removed Docs: README/FC/TM/Overview updated (22 jobs, 20 CRITICAL sites, 23-section GDPR export, sweep jobs, webhook fail-closed); P11 plan marks remaining items (sandbox smoke test, M-8 customer_id, saved-card key dedup trade-off) as deferred with rationale; gap backlog pruned of completed items
80 lines
2.5 KiB
Bash
80 lines
2.5 KiB
Bash
# Database Credentials for all services
|
|
|
|
# These are used by the 'postgres' service to initialize the database
|
|
# These are used by 'backend' (Go) and 'sabredav' (PHP)
|
|
POSTGRES_USER=myuser
|
|
POSTGRES_PASSWORD=mypassword
|
|
POSTGRES_DB=mydb
|
|
|
|
# and to connect to the 'postgres' service on the Docker network
|
|
POSTGRES_HOST=postgres
|
|
POSTGRES_PORT=5432
|
|
|
|
JWT_SECRET_KEY="a-very-secret-key-that-should-be-in-env"
|
|
|
|
# S3/R2 Configuration (for image storage)
|
|
# Dev: Uses local Rustfs container (see compose.yml)
|
|
# Prod: Use Cloudflare R2 credentials
|
|
S3_ENDPOINT=http://localhost:9000
|
|
S3_PUBLIC_URL=http://192.168.1.135:9000
|
|
S3_ACCESS_KEY=rustfsadmin
|
|
S3_SECRET_KEY=rustfsadmin
|
|
S3_BUCKET=crussell
|
|
S3_PROFILE_PICS_BUCKET=crussell-profile-pics
|
|
AWS_REGION=eu-west-2
|
|
|
|
# Set DAV_SKIP_INIT=1 to skip CardDAV server initialization (e.g., in CI/test environments).
|
|
DAV_SKIP_INIT=1
|
|
|
|
# Prod only: Cloudflare R2 (overrides S3_* vars in non-dev builds).
|
|
# Local dev uses the S3_* vars above (from .env). Not needed for local builds.
|
|
R2_ENDPOINT=
|
|
# R2_ACCESS_KEY=<your-access-key>
|
|
# R2_SECRET_KEY=<your-secret-key>
|
|
# R2_BUCKET=crussell
|
|
# R2_PUBLIC_URL=https://pub-<your-domain>.r2.dev
|
|
|
|
# Square Payment Gateway
|
|
SQUARE_ACCESS_TOKEN=
|
|
SQUARE_LOCATION_ID=
|
|
SQUARE_TERMINAL_DEVICE_ID=
|
|
SQUARE_ENVIRONMENT=mock
|
|
SQUARE_WEBHOOK_SIGNATURE_KEY=
|
|
SQUARE_WEBHOOK_NOTIFICATION_URL=
|
|
|
|
# Frontend (public — safe for the browser). Square Web Payments SDK:
|
|
# VITE_SQUARE_APPLICATION_ID — client-side application ID (sandbox IDs start with "sandbox-")
|
|
# VITE_SQUARE_LOCATION_ID — Square location ID
|
|
# VITE_SQUARE_ENVIRONMENT — 'sandbox' | 'production' (optional; derived from the app ID prefix when omitted)
|
|
VITE_SQUARE_APPLICATION_ID=
|
|
VITE_SQUARE_LOCATION_ID=
|
|
VITE_SQUARE_ENVIRONMENT=
|
|
|
|
# Test Database (separate from main DB)
|
|
# Used by testutils/testdb for running tests without corrupting dev data
|
|
TEST_DB_HOST=localhost
|
|
TEST_DB_DSN=
|
|
|
|
# Dev/CI mode — set to "true" to enable mock services
|
|
# Disables zxcvbn password checks, skips artificial Square mock delays,
|
|
# skips DAV sync, and relaxes production guardrails
|
|
GO_TESTING=
|
|
|
|
# CardDAV (SabreDAV) — profile photo sync
|
|
DAV_BASE_URL=http://localhost:8080
|
|
DAV_ADMIN_PASSWORD=admin
|
|
|
|
# Logging
|
|
# Set to "true" to disable ANSI color escape sequences in log output
|
|
NO_COLOR=
|
|
|
|
# Frontend
|
|
VITE_BACKEND_URL=http://localhost:8080
|
|
|
|
# Local S3 (Rustfs) — requires GO_TESTING=1 or dev build tag
|
|
# These are dev-only overrides used by the dev S3 implementation
|
|
RUSTFS_ENDPOINT=http://rustfs:9000
|
|
RUSTFS_ACCESS_KEY=rustfsadmin
|
|
RUSTFS_SECRET_KEY=rustfsadmin
|
|
RUSTFS_BUCKET=crussell
|