This commit is contained in:
@@ -741,12 +741,20 @@ class OrderViewSet(viewsets.ModelViewSet):
|
||||
description = f"报名 {order.course.title}"
|
||||
else:
|
||||
description = f"支付订单 {order.id}"
|
||||
|
||||
|
||||
# 强制修正回调地址为正确的后端接口地址
|
||||
# 用户配置可能是 /pay (前端页面),我们需要的是 /api/finish/ (后端回调接口)
|
||||
current_notify = wechat_config.notify_url
|
||||
if 'quant-speed.com' in current_notify:
|
||||
notify_url = "https://market.quant-speed.com/api/finish/"
|
||||
else:
|
||||
notify_url = current_notify # Fallback
|
||||
|
||||
print(f"准备发起微信支付(小程序):")
|
||||
print(f" OutTradeNo: {out_trade_no}")
|
||||
print(f" Amount: {amount_in_cents} 分")
|
||||
print(f" OpenID: {user.openid}")
|
||||
print(f" NotifyURL: {wechat_config.notify_url}")
|
||||
print(f" NotifyURL: {notify_url}")
|
||||
|
||||
# 统一下单 (JSAPI)
|
||||
code, message = wxpay.pay(
|
||||
@@ -754,7 +762,7 @@ class OrderViewSet(viewsets.ModelViewSet):
|
||||
out_trade_no=out_trade_no,
|
||||
amount={'total': amount_in_cents, 'currency': 'CNY'},
|
||||
payer={'openid': user.openid}, # 小程序支付必须传 openid
|
||||
notify_url=wechat_config.notify_url
|
||||
notify_url=notify_url
|
||||
)
|
||||
|
||||
print(f"微信支付响应: Code={code}, Message={message}")
|
||||
|
||||
Reference in New Issue
Block a user