-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
537a687
commit 5cc9f10
Showing
3 changed files
with
10 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
from fastapi import APIRouter, HTTPException, Request, FastAPI | ||
import httpx | ||
import asyncio | ||
|
||
import httpx | ||
from fastapi import APIRouter, HTTPException, Request | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.post("/api/v1/payment-status") | ||
async def receive_payment_status(request: Request): | ||
try: | ||
data = await request.json() | ||
result = data["payment_status"] | ||
print(f"Payment result {result}") | ||
except Exception as exc: | ||
except Exception: | ||
raise HTTPException(status_code=500, detail="Server Error") | ||
|
||
|
||
WEBHOOK_URL = "http://localhost:8001/set-webhook" | ||
|
||
|
||
async def register_webhook_payment_server(): | ||
params = { | ||
"user_id": "0", | ||
} | ||
body = { | ||
"webhook_url": "http://localhost:8000/api/v1/payment-status" | ||
} | ||
|
||
async with httpx.AsyncClient() as client: | ||
resp = await client.post(WEBHOOK_URL, params=params, json=body) | ||
print(resp) | ||
if (resp.status_code != 200): | ||
print(f"Failed to register webhook in the payment mock server: {WEBHOOK_URL}") | ||
|
||
|
||
asyncio.run(register_webhook_payment_server()) |
4 changes: 1 addition & 3 deletions
4
src/api/presentation/shared/dtos/create_product_request_dto.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters