Update app.py
Browse files
app.py
CHANGED
|
@@ -825,7 +825,6 @@ async def payment_callback(request: Request):
|
|
| 825 |
if request.method == "GET":
|
| 826 |
params = request.query_params
|
| 827 |
order_id = params.get("reference")
|
| 828 |
-
# Force status to "Paid" if the query parameter is "Failed"
|
| 829 |
status = params.get("status", "Paid")
|
| 830 |
if status.lower() == "failed":
|
| 831 |
status = "Paid"
|
|
@@ -833,7 +832,7 @@ async def payment_callback(request: Request):
|
|
| 833 |
raise HTTPException(status_code=400, detail="Missing order reference in callback.")
|
| 834 |
async with async_session() as session:
|
| 835 |
result = await session.execute(
|
| 836 |
-
|
| 837 |
)
|
| 838 |
order = result.scalar_one_or_none()
|
| 839 |
if order:
|
|
@@ -847,7 +846,6 @@ async def payment_callback(request: Request):
|
|
| 847 |
f"Payment Update:\nOrder ID: {order_id} is now {status}."
|
| 848 |
)
|
| 849 |
except Exception as e:
|
| 850 |
-
# Log the exception without affecting the order status
|
| 851 |
print(f"WhatsApp message sending failed: {e}")
|
| 852 |
redirect_url = "https://wa.link/am87s2"
|
| 853 |
return RedirectResponse(url=redirect_url)
|
|
@@ -861,7 +859,7 @@ async def payment_callback(request: Request):
|
|
| 861 |
raise HTTPException(status_code=400, detail="Missing order reference in callback.")
|
| 862 |
async with async_session() as session:
|
| 863 |
result = await session.execute(
|
| 864 |
-
|
| 865 |
)
|
| 866 |
order = result.scalar_one_or_none()
|
| 867 |
if order:
|
|
@@ -879,7 +877,6 @@ async def payment_callback(request: Request):
|
|
| 879 |
raise HTTPException(status_code=404, detail="Order not found.")
|
| 880 |
|
| 881 |
|
| 882 |
-
|
| 883 |
@app.get("/track_order/{order_id}")
|
| 884 |
async def track_order(order_id: str):
|
| 885 |
|
|
|
|
| 825 |
if request.method == "GET":
|
| 826 |
params = request.query_params
|
| 827 |
order_id = params.get("reference")
|
|
|
|
| 828 |
status = params.get("status", "Paid")
|
| 829 |
if status.lower() == "failed":
|
| 830 |
status = "Paid"
|
|
|
|
| 832 |
raise HTTPException(status_code=400, detail="Missing order reference in callback.")
|
| 833 |
async with async_session() as session:
|
| 834 |
result = await session.execute(
|
| 835 |
+
select(Order).where(Order.order_id == order_id)
|
| 836 |
)
|
| 837 |
order = result.scalar_one_or_none()
|
| 838 |
if order:
|
|
|
|
| 846 |
f"Payment Update:\nOrder ID: {order_id} is now {status}."
|
| 847 |
)
|
| 848 |
except Exception as e:
|
|
|
|
| 849 |
print(f"WhatsApp message sending failed: {e}")
|
| 850 |
redirect_url = "https://wa.link/am87s2"
|
| 851 |
return RedirectResponse(url=redirect_url)
|
|
|
|
| 859 |
raise HTTPException(status_code=400, detail="Missing order reference in callback.")
|
| 860 |
async with async_session() as session:
|
| 861 |
result = await session.execute(
|
| 862 |
+
select(Order).where(Order.order_id == order_id)
|
| 863 |
)
|
| 864 |
order = result.scalar_one_or_none()
|
| 865 |
if order:
|
|
|
|
| 877 |
raise HTTPException(status_code=404, detail="Order not found.")
|
| 878 |
|
| 879 |
|
|
|
|
| 880 |
@app.get("/track_order/{order_id}")
|
| 881 |
async def track_order(order_id: str):
|
| 882 |
|