from fastapi import FastAPI, Request, HTTPExceptionapp = FastAPI()@app.post("/webhooks/payments")async def webhook(req: Request): body = await req.json() if "status" not in body or "results" not in body: raise HTTPException(400, "Invalid payload") # verify hash (optional), then persist idempotently save_or_update(body["results"]["payment_uuid"], body) return {"ok": True}