3
This commit is contained in:
@@ -1092,12 +1092,43 @@ def run_payment_flow(page, email, step_callback=None):
|
||||
|
||||
# ========== 步骤 8: 等待支付成功 ==========
|
||||
step_cb("等待支付处理...")
|
||||
log_status("等待", "等待支付处理(超时60秒)...")
|
||||
try:
|
||||
page.wait.url_change('payments/success-team', timeout=60)
|
||||
log_status("等待", "等待支付处理(超时90秒)...")
|
||||
|
||||
# 使用轮询方式等待支付成功,而不是 url_change
|
||||
# 因为 url_change 在 URL 没有变化时会立即返回
|
||||
payment_success = False
|
||||
start_time = time.time()
|
||||
max_wait = 90 # 最多等待 90 秒
|
||||
|
||||
while time.time() - start_time < max_wait:
|
||||
current_url = page.url
|
||||
|
||||
# 检查是否支付成功
|
||||
if 'payments/success' in current_url or 'success-team' in current_url:
|
||||
payment_success = True
|
||||
log_status("成功", "[OK] 支付成功!")
|
||||
except:
|
||||
log_status("超时", "[X] 支付未完成")
|
||||
break
|
||||
|
||||
# 检查是否有错误页面
|
||||
if 'error' in current_url.lower() or 'failed' in current_url.lower():
|
||||
log_status("失败", f"[X] 支付失败: {current_url}")
|
||||
return None
|
||||
|
||||
# 检查停止请求
|
||||
if _is_shutdown_requested():
|
||||
log_progress("[!] 检测到停止请求")
|
||||
return {"stopped": True}
|
||||
|
||||
# 每 2 秒检查一次
|
||||
elapsed = int(time.time() - start_time)
|
||||
if elapsed % 10 == 0 and elapsed > 0:
|
||||
log_progress(f"[等待中] 已等待 {elapsed} 秒...")
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
if not payment_success:
|
||||
log_status("超时", "[X] 支付未完成(超时)")
|
||||
log_progress(f"最终URL: {page.url}")
|
||||
return None
|
||||
|
||||
# ========== 步骤 9: 获取 token 和 account_id ==========
|
||||
|
||||
Reference in New Issue
Block a user