MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / open_bind_card_task

Function open_bind_card_task

src/web/routes/payment.py:2475–2500  ·  view source on GitHub ↗

打开绑卡任务对应的 checkout 链接

(task_id: int)

Source from the content-addressed store, hash-verified

2473
2474@router.post("/bind-card/tasks/{task_id}/open")
2475def open_bind_card_task(task_id: int):
2476 """打开绑卡任务对应的 checkout 链接"""
2477 with get_db() as db:
2478 task = db.query(BindCardTask).options(joinedload(BindCardTask.account)).filter(BindCardTask.id == task_id).first()
2479 if not task:
2480 raise HTTPException(status_code=404, detail="绑卡任务不存在")
2481 if not task.checkout_url:
2482 raise HTTPException(status_code=400, detail="任务缺少 checkout 链接")
2483
2484 cookies_str = task.account.cookies if task.account else None
2485 logger.info("打开绑卡任务: task_id=%s account_id=%s", task.id, task.account_id)
2486 opened = open_url_incognito(task.checkout_url, cookies_str)
2487 if opened:
2488 if str(task.status or "") not in ("paid_pending_sync", "completed"):
2489 task.status = "opened"
2490 task.opened_at = utcnow_naive()
2491 task.last_error = None
2492 db.commit()
2493 db.refresh(task)
2494 logger.info("绑卡任务打开成功: task_id=%s", task.id)
2495 return {"success": True, "task": _serialize_bind_card_task(task)}
2496
2497 task.last_error = "未找到可用的浏览器"
2498 db.commit()
2499 logger.warning("绑卡任务打开失败: task_id=%s reason=%s", task.id, task.last_error)
2500 raise HTTPException(status_code=500, detail="未找到可用的浏览器,请手动复制链接")
2501
2502
2503@router.post("/bind-card/tasks/{task_id}/auto-bind-third-party")

Callers

nothing calls this directly

Calls 10

get_dbFunction · 0.85
open_url_incognitoFunction · 0.85
utcnow_naiveFunction · 0.85
firstMethod · 0.80
optionsMethod · 0.80
infoMethod · 0.80
warningMethod · 0.80
filterMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected