TorbatYar/backend/services/payment/app/api/v1/health.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

18 lines
1.5 KiB
Python

from fastapi import APIRouter, Depends
from sqlalchemy import select
from app import __version__
from app.api.deps import require_tenant
from app.core.database import get_db
from app.models import PaymentWorkspace, TenantPaymentBundle, PaymentFeatureToggle
router=APIRouter()
@router.get("/health")
async def health(): return {"status":"ok","service":"payment-service","version":__version__}
@router.get("/metrics")
async def metrics(): return {"service":"payment-service","version":__version__,"phase":"14.5","metrics":{"outbox_events":"tenant_scoped","transactions":"tenant_scoped"}}
@router.get("/capabilities")
async def capabilities(tenant_id=Depends(require_tenant),db=Depends(get_db)):
ws=(await db.execute(select(PaymentWorkspace).where(PaymentWorkspace.tenant_id==tenant_id))).scalars().first()
bundles=(await db.execute(select(TenantPaymentBundle).where(TenantPaymentBundle.tenant_id==tenant_id,TenantPaymentBundle.is_active.is_(True)))).scalars().all()
toggles=(await db.execute(select(PaymentFeatureToggle).where(PaymentFeatureToggle.tenant_id==tenant_id))).scalars().all()
return {"service":"payment","version":__version__,"phase":"14.5","workspace_status":ws.status if ws else "disabled","default_payment_mode":ws.default_payment_mode if ws else "byo_psp","active_bundles":[x.bundle_code for x in bundles],"feature_toggles":{x.key:x.enabled for x in toggles},"payment_sources_supported":["PSP","MERCHANT_FACILITATOR"],"payment_sources_reserved":["CREDIT_PROVIDER"],"contract_versions":{"payment_intent":"v1","callback_ingress":"v1"}}