Pay principle

First, submit CUP pay principle:

1, the package payment request parameter

2, the parameters verify the signature, to be submitted in the form of html form UnionPay payment interface

Html form submission to What are the benefits?

Will facilitate the submission parameters

Second, synchronous and asynchronous callback callback notification

     1, synchronized callback (foreground notice):

      Third-party payment system to redirect the browser in the form of the payment to the merchant end result

                      Role: prompt to the user UnionPay payment system has been successful payment.

        2, asynchronous callback (Background information):

                     Third-party payment system using similar technology HttpClient call the merchant interface notification.

                      Role: CUP payment will be sent in the form of security to the merchant terminal, and the corresponding modification of the order status.

                Note: asynchronous notification is to modify the order status

Thinking:

1, third-party payment platform (CUP Alipay, micro-channel payment) payment of the outcome is notified to the merchant terminal

      Third-party payment platform technology will be paid by httpclient result of an asynchronous notification to the merchant terminal

2, there are reasons to pay a distributed system type thing problem:

   CUP user system, after the payment is completed, how the results to the business end: the third-party payment platform technology will be paid by httpclient result of an asynchronous notification to the merchant terminal

 3, how to solve the distributed transaction across the system problem?

       The final consistency of the two sides can adopt a brief inconsistent, but will ultimately achieve consistency. The use of compensatory notice

Signature verification principle: MD5 encrypted irreversible salt

Verify signatures prevent data from being tampered with

Encryption is to prevent the capture of data to obtain the plaintext reversible.

 

Payment process:

1, order service call payment service generates a payment token (userId, order number, payment amount)

2, service orders get paid token passing Token Jump to pay web form in order to use web.

Withholding payment records confessed to ensure the safety parameters of the problem.

The different execution address of the interface to the data store, a unified execution method using java reflection mechanism.

Overall implementation process:

  1. The need to provide payment services to create a payment interface, passing parameters userid, orderid, amount.
  2. 使用支付令牌查询支付交易信息

注意:订单id 支付id

整体实现流程:

  1. 支付服务需要提供创建支付接口 ,传递参数 userid、orderid、金额。
  2. 使用支付令牌查询支付交易信息

注意:订单id 支付id

四、分布式事务解决方案

LCN MQ 适合于内部系统实现服务指间分布式事务解决方案

如果产生跨平台之间分布式事务如何解决呢? 最终一致性概念

第三方系统中如何商户端没有及时响应状态码给第三方支付系统,这时候第三方系统采用补偿和重试机制。

支付回调中需要考虑的问题:

  1. 在网络延迟情况下,回调接口出现重试时,如何保证接口幂等性问题。

     (全局id) 重试机制是间隔性。

  1. 在网络延迟情况下,第三方系统没有及时的将支付结果通知给商户端,存在支付状态不一致时,如何解决?

解决方案:调用第三方系统主动查询支付状态

  1. 商户系统回调接口中,如果存在代码问题,或者是商户系统宕机,导致第三方支付系统一直在重试? 最后放弃重试 如何解决呢?
    1. 手动补偿机制+日志记录 主动调用第三方接口查询
    2. 写一个定时Job,每天定时检查数据,主动调用第三方接口查询,修改状态码

4.支付金额与商品金额如果不一致时,如何处理

在异步回调中,使用预支付金额与回调真实支付金额进行比对,如果不一致的话,说明该交易信息存在异常。

使用日志+对账核查。

  1. 支付服务如何与其他系统保证分布式事务问题

采用第三方支付流程 实现补偿和重试机制遵循最终一致性 Base理论和CAP理论。

  1. 与内部系统中出现分布式事务问题

LCN、 MQ 、TCCC

相同点: 最终一致性问题。

 

Guess you like

Origin www.cnblogs.com/cxyyh/p/11080018.html
Recommended