BlessingCR’s Blog
BlessingCR’s Blog

每个人都应该懂的支付方案设计

支付方案:

订单1:N 支付单。

用户选择支付方式后生成支付单或拿到最近支付单(注意分布式锁,并且支付单绑定订单号,防止多次支付)

返回前端, 前端用户支付

  1. 支付完成后支付回调, 收到回调后,重新查询支付单状态,并修改状态
  2. 用户前端刷新查询,查询第三方收款,若还是未支付返回等待/未支付

2B的要对接银行,而且要分别对接,偷懒的办法是让用户上传凭证手工核对。

在支付和订单的服务中,最好穿插MQ,也就是用户支付后,回调消息发送给支付服务,支付服务mq中发给订单服务。

如果在支付中,涉及优惠券/库存,需要注意分布式事务问题。支付单支付生成中,需要支付单生成,优惠券扣减,库存扣减同步发生。

这里几个风险点: 一个是支付方要求的Https证书类型,一个是像是Airwallex之类的支付接入会有考察,包括线下考察, 技术上反而没有什么很多的风险点,注意状态和数据还有保留痕迹(log)就好,支付方已经做了最大的风险方面把控。

订单过期:

消息队列,延迟队列(rocketmq中有自带实现,rabbitmq需要安装插件)

下单-> 延迟队列 --> 到期消费 --> 检测支付状态 --> 关闭订单

发表回复

textsms
account_circle
email

  • We’re a bunch of volunteers and opening a brand new scheme in our community. Your web site provided us with helpful info to paintings on. You have done a formidable process and our entire neighborhood will be grateful to you.

    2 月前 回复
  • I keep listening to the newscast talk about receiving free online grant applications so I have been looking around for the top site to get one. Could you advise me please, where could i acquire some?

    4 周前 回复
  • I’m extremely impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you customize it yourself? Either way keep up the excellent quality writing, it’s rare to see a great blog like this one these days..

    4 周前 回复
  • This site is my aspiration, really wonderful layout and perfect content material.

    19 小时前 回复

BlessingCR’s Blog

每个人都应该懂的支付方案设计
支付方案: 订单1:N 支付单。 用户选择支付方式后生成支付单或拿到最近支付单(注意分布式锁,并且支付单绑定订单号,防止多次支付) 返回前端, 前端用户支付 1. 支付完成后支付回调, …
扫描二维码继续阅读
2024-01-15