如下是TokenPay收款的时序图
sequenceDiagram
autonumber
participant B as 浏览器
participant N as New API服务器
participant Y as 易支付服务器
participant T as TokenPay服务器
%% === 阶段一:获取支付链接 (0s - 10s) ===
note over B, T: === 阶段一:请求支付链接 ===
note left of B: [0s]
B->>+N: 1. 请求充值
note left of B: [2s]
N->>+Y: 2. 调用易支付接口
note left of B: [4s]
Y->>+T: 3. 获取收银台地址
note left of B: [6s]
T-->>-Y: 4. 返回地址 (URL)
note left of B: [8s]
%% 【修正点】: 易支付返回给New API,而不是直接给用户
Y-->>-N: 5. 返回支付跳转连接
note left of B: [9s]
%% 【修正点】: New API 响应用户,请求结束,N 停止激活
N-->>-B: 6. HTTP 302 重定向
%% === 中场休息:用户操作 ===
note right of B: ... 用户浏览器跳转至 TokenPay ...
note left of B: [10s]
B->>T: 7. 访问收银台页面
note right of B: ... 用户扫码付款 (耗时5分钟) ...
B->>T: 8. 确认支付
%% === 阶段二:异步回调 (5min+) ===
note over B, T: === 阶段二:支付回调通知 ===
note left of B: [5min 2s]
T-)+Y: 9. 异步通知: 支付成功
note left of B: [5min 4s]
%% 【修正点】: 回调时,New API 被再次激活 (+)
Y->>+N: 10. 异步通知: 订单完成
note left of B: [5min 6s]
%% 这里通常只是更新数据库,不一定直接返回页面给用户(因为是后台回调)
%% 但为了闭环,我们假设这里 N 处理完逻辑返回个 "success" 字符串给 Y
N-->>-Y: 11. 确认收到 (Ack)
%% 可选:如果是WebSocket或轮询,N 此时才会通知 B
N--)B: WebSocket 推送: 到账成功