TorbatYar/backend/services/payment/app/middlewares/tenant.py
Mortezakoohjani 9fac160258 feat(payment): ship Torbat Pay MVP phases 14.0-14.5
Add independent payment-service (port 8012, payment_db) with foundation licensing, BYO-PSP, merchant accounts, idempotent requests, callbacks, and immutable ledger.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 17:57:04 +03:30

11 lines
476 B
Python

from uuid import UUID
from starlette.middleware.base import BaseHTTPMiddleware
from shared.tenant import HEADER_TENANT_ID, STATE_TENANT_ID
class TenantHeaderMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request, call_next):
raw=request.headers.get(HEADER_TENANT_ID)
try: value=UUID(raw) if raw else None
except ValueError: value=None
setattr(request.state,STATE_TENANT_ID,value)
return await call_next(request)