update pay ui
This commit is contained in:
34
app.py
34
app.py
@@ -2687,7 +2687,8 @@ def create_alipay_order():
|
||||
{
|
||||
"plan_name": "pro",
|
||||
"billing_cycle": "yearly",
|
||||
"promo_code": "WELCOME2025" // 可选
|
||||
"promo_code": "WELCOME2025", // 可选
|
||||
"is_mobile": true // 可选,是否为手机端(自动使用 WAP 支付)
|
||||
}
|
||||
"""
|
||||
try:
|
||||
@@ -2698,6 +2699,8 @@ def create_alipay_order():
|
||||
plan_name = data.get('plan_name')
|
||||
billing_cycle = data.get('billing_cycle')
|
||||
promo_code = (data.get('promo_code') or '').strip() or None
|
||||
# 前端传入的设备类型,用于决定使用 page 支付还是 wap 支付
|
||||
is_mobile = data.get('is_mobile', False)
|
||||
|
||||
if not plan_name or not billing_cycle:
|
||||
return jsonify({'success': False, 'error': '参数不完整'}), 400
|
||||
@@ -2782,8 +2785,12 @@ def create_alipay_order():
|
||||
# 金额格式化为两位小数(支付宝要求)
|
||||
amount_str = f"{float(amount):.2f}"
|
||||
|
||||
# 根据设备类型选择支付方式:wap=手机网站支付,page=电脑网站支付
|
||||
pay_type = 'wap' if is_mobile else 'page'
|
||||
print(f"[支付宝] 设备类型: {'手机' if is_mobile else '电脑'}, 支付方式: {pay_type}")
|
||||
|
||||
create_result = subprocess.run(
|
||||
[sys.executable, script_path, 'create', order.order_no, amount_str, subject, body],
|
||||
[sys.executable, script_path, 'create', order.order_no, amount_str, subject, body, pay_type],
|
||||
capture_output=True, text=True, timeout=60
|
||||
)
|
||||
|
||||
@@ -3104,6 +3111,29 @@ def check_alipay_order_status(order_id):
|
||||
return jsonify({'success': False, 'error': '查询失败'}), 500
|
||||
|
||||
|
||||
@app.route('/api/payment/alipay/order-by-no/<order_no>/status', methods=['GET'])
|
||||
def check_alipay_order_status_by_no(order_no):
|
||||
"""通过订单号查询支付宝订单支付状态(用于手机端支付返回)"""
|
||||
try:
|
||||
if 'user_id' not in session:
|
||||
return jsonify({'success': False, 'error': '未登录'}), 401
|
||||
|
||||
# 通过订单号查找订单
|
||||
order = PaymentOrder.query.filter_by(
|
||||
order_no=order_no,
|
||||
user_id=session['user_id']
|
||||
).first()
|
||||
|
||||
if not order:
|
||||
return jsonify({'success': False, 'error': '订单不存在'}), 404
|
||||
|
||||
# 复用现有的状态检查逻辑
|
||||
return check_alipay_order_status(str(order.id))
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({'success': False, 'error': '查询失败'}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/session', methods=['GET'])
|
||||
def get_session_info():
|
||||
"""获取当前登录用户信息"""
|
||||
|
||||
Reference in New Issue
Block a user