Webhook User Guide
Use webhooks to notify your application about payment events.
What is a webhook?
When you will receive a webhook?
Steps to receive a webhook
1
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
import uvicorn
from pyngrok import ngrok
app = FastAPI()
@app.post("/api/webhooks")
async def handle_post(request: Request):
try:
payload = await request.json()
print(payload)
return JSONResponse(status_code=200, content={"message": "Success"})
except Exception as e:
print(f"Error: {e}")
return JSONResponse(status_code=400, content={"error": "Invalid request body"})
if __name__ == "__main__":
listening_port = 8000
public_url = ngrok.connect(listening_port)
print(f"ngrok Public URL: {public_url}")
uvicorn.run(app, host="0.0.0.0", port=listening_port)
2


3






Last updated

