' 语法文档 http://plantuml.com/zh/sequence-diagram

@startuml 支付中心流程图

participant "小程序(客户端)" as MiniProgram order 100
participant "业务系统" as BizServer order 200
participant "支付中心" as PayCenter order 300
participant "微信服务器" as WeChatServer order 400

activate MiniProgram
MiniProgram -> MiniProgram: 调用wx.login得到登录code
MiniProgram -> BizServer: 使用code发起支付请求

activate BizServer
BizServer -> PayCenter: 使用code调用支付中心
note over BizServer
  调用支付中心不含与微信支付对接的任何参数:
  appid(小程序ID)
  secret(小程序密钥)
  mch_id(绑定商户号)
  api_secret(支付API密钥)
end note

activate PayCenter
PayCenter -> WeChatServer: 调用'/sns/jscode2session'接口
note over PayCenter
  此处的必须参数:
  code(小程序登录码)
  appid(小程序ID)
  secret(小程序密钥)
end note
activate WeChatServer
WeChatServer --> PayCenter: 返回openid
deactivate WeChatServer

PayCenter -> WeChatServer: 调用'/pay/unifiedorder'接口(统一下单)
note over PayCenter
  此处的必须参数:
  openid(小程序用户ID)
  appid(小程序ID)
  mch_id(绑定商户号)
  api_secret(支付API密钥)
end note
activate WeChatServer
WeChatServer --> PayCenter: 返回prepay_id
deactivate WeChatServer

PayCenter -> PayCenter: 准备好小程序调用wx.requestPayment需要的参数
PayCenter --> BizServer: 返回小程序调用wx.requestPayment需要的参数
deactivate PayCenter

BizServer --> MiniProgram: 返回小程序调用wx.requestPayment需要的参数
deactivate BizServer

MiniProgram -> WeChatServer: 调用wx.requestPayment发起支付
activate WeChatServer
WeChatServer --> MiniProgram: 返回支付结果
deactivate WeChatServer

MiniProgram -> MiniProgram: 处理展示支付结果

deactivate MiniProgram
@enduml

时序图

文档更新时间: 2019-08-12 15:41   作者:lizw