first commit
This commit is contained in:
commit
34ea15a54d
246 changed files with 18660 additions and 0 deletions
31
backend/app/api/routes/webhooks.py
Normal file
31
backend/app/api/routes/webhooks.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
from fastapi import APIRouter, Header, HTTPException, Request
|
||||
|
||||
from app.core.config import get_settings
|
||||
from app.core.deps import DbSession
|
||||
from app.services.payments.service import process_webhook
|
||||
|
||||
router = APIRouter(prefix="/webhooks", tags=["webhooks"])
|
||||
|
||||
|
||||
@router.post("/razorpay")
|
||||
async def razorpay_webhook(
|
||||
request: Request,
|
||||
db: DbSession,
|
||||
x_razorpay_signature: str | None = Header(default=None, alias="X-Razorpay-Signature"),
|
||||
) -> dict:
|
||||
body = await request.body()
|
||||
return process_webhook(db, body=body, signature=x_razorpay_signature)
|
||||
|
||||
|
||||
@router.post("/mock")
|
||||
async def mock_payment_webhook(
|
||||
request: Request,
|
||||
db: DbSession,
|
||||
x_mock_signature: str | None = Header(default=None, alias="X-Mock-Signature"),
|
||||
) -> dict:
|
||||
"""Mock provider webhook (development / tests only)."""
|
||||
settings = get_settings()
|
||||
if settings.environment.lower() != "development":
|
||||
raise HTTPException(status_code=404, detail="Not found")
|
||||
body = await request.body()
|
||||
return process_webhook(db, body=body, signature=x_mock_signature)
|
||||
Loading…
Add table
Add a link
Reference in a new issue