's'
This commit is contained in:
@@ -7,8 +7,6 @@ import time
|
||||
from fastapi import APIRouter, Request, HTTPException
|
||||
from fastapi.responses import RedirectResponse, JSONResponse
|
||||
|
||||
import requests
|
||||
|
||||
from ..config import BASE_URL, ZPAY_PID, ZPAY_KEY
|
||||
from ..payment.zpay import ZPayProvider
|
||||
from ..services import handle_payment_success, processed_orders
|
||||
@@ -118,25 +116,10 @@ async def nomadvip_payh5_redirect(item: dict, request: Request):
|
||||
@router.get("/zpay_order_status")
|
||||
async def nomadvip_zpay_order_status(out_trade_no: str):
|
||||
"""nomadvip 专用:查询 ZPAY 订单支付状态"""
|
||||
url = f"https://zpayz.cn/api.php?act=order&pid={ZPAY_PID}&key={ZPAY_KEY}&out_trade_no={out_trade_no}"
|
||||
try:
|
||||
resp = requests.get(url, timeout=10)
|
||||
result = resp.json() if resp.ok else {}
|
||||
except Exception as e:
|
||||
logging.warning(f"nomadvip ZPAY 订单查询失败: {e}")
|
||||
return {"paid": False, "error": str(e)}
|
||||
try:
|
||||
code = result.get("code", 0)
|
||||
code = int(code) if isinstance(code, (int, float)) or str(code).isdigit() else 0
|
||||
except (ValueError, TypeError):
|
||||
code = 0
|
||||
if code != 1:
|
||||
return {"paid": False, "msg": result.get("msg", "查询失败")}
|
||||
try:
|
||||
status = int(result.get("status", 0))
|
||||
except (ValueError, TypeError):
|
||||
status = 0
|
||||
return {"paid": status == 1, "status": status}
|
||||
result = _nomadvip_zpay.query_order_status(out_trade_no, timeout=15)
|
||||
if result.get("error"):
|
||||
logging.warning(f"nomadvip ZPAY 订单查询失败: {result.get('error')}")
|
||||
return result
|
||||
|
||||
|
||||
@router.get("/zpay_notify")
|
||||
|
||||
Reference in New Issue
Block a user