TorbatYar/backend/services/payment/app/main.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

19 lines
1023 B
Python

from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from app import __version__
from app.api.v1 import api_router, health
from app.core.config import settings
from app.middlewares.tenant import TenantHeaderMiddleware
from shared.exceptions import AppError
def create_app():
app=FastAPI(title="Torbat Pay",version=__version__,description="Payment service phases 14.0-14.5")
app.add_middleware(CORSMiddleware,allow_origins=settings.cors_origin_list,allow_credentials=False,allow_methods=["*"],allow_headers=["*"])
app.add_middleware(TenantHeaderMiddleware)
@app.exception_handler(AppError)
async def handle(request:Request,exc:AppError): return JSONResponse(status_code=exc.status_code,content={"error":{"code":exc.error_code,"message":exc.message,"details":exc.details}})
app.include_router(health.router)
app.include_router(api_router,prefix=settings.api_v1_prefix)
return app
app=create_app()