# Payment Engine Architecture ## Overview Managed via `PaymentRouter.py`. Supports Razorpay online payments and Cash/Offline payments. --- ## Payment Status Ledger Every transaction is recorded in an append-only `payment_ledger`: | Field | Type | Description | | :--- | :--- | :--- | | `payment_id` | String(26) ULID | Primary key | | `order_id` | String(26) ULID | Foreign key to `orders` | | `provider` | String(30) | `RAZORPAY`, `CASH`, `POS_CARD` | | `transaction_ref` | String(100) | Provider transaction ID | | `amount` | Numeric(10, 2) | Payment amount | | `status` | String(30) | `PENDING`, `CAPTURED`, `FAILED`, `REFUNDED` | | `created_at` | DateTime | Timestamp |