[Problem record] About the callback address of ping++ payment jump (Alipay and WeChat are inconsistent)

Problem Description

The h5 webpage payment of our company's webview is a payment that integrates ping++. It is very simple to use. You only need to create a charge payment credential object, and all the payment-related element information is stored in this object (usually the request interface obtains these payment-related information from the server), and then you only need to call a function of ping++, pingpp.createPayment(), to invoke the payment.

But after the payment operation is completed, we often need to do some processing by judging the payment status (successful payment, payment failure, payment cancellation). At this time, we have to step on the pit! ! ! !

extra Additional parameters required when a specific channel initiates a transaction, and additional parameters returned by some channels for successful payment

According to the ping++ development document, the page address returned after the payment is completed needs to be passed in the extra attribute of the charge object.

Generally, there are three callback addresses, result_ur, cancel_url, and success_url. but! ! ! The callback address of different payment channels is handled differently, so don't deal with it blindly, this is where you step on the pit! ! !

problem analysis

I currently only use Alipay mobile website payment (payment method is alipay_wap), and WeChat H5 payment (payment method is wx_wap). Callback address note:

1. Alipay web payment

  • Alipay has two callback addresses
success_url Callback address for successful payment
cancel_url Callback address for payment cancellation
  • Android can automatically return to the app after successfully paying with Alipay by clicking Finish (if the URL scheme is configured), that is, jump to success_url, and jump to cancel_url if the payment is cancelled.
  • After ios pays successfully with Alipay, it cannot return to the app (currently no solution has been found), it can only be returned manually, but even if you pay successfully, the jump is still cancel_url, and all the jumps that are equivalent to ios payment with Alipay are cancel_url

2. WeChat web payment

  • WeChat has only one callback address, regardless of the payment status, as long as the page is returned after the payment is initiated, the result_url is the result_url
result_url The callback address of payment completion.

problem solved

  •  To sum up, only when you challenge the success_url, can you ensure that the payment is successful, and jumping to cancel_url or result_url cannot confirm whether the payment is successful
  • Therefore, after the payment operation is completed, if processing is required, except for success_url, other callback addresses need to actively obtain the payment status (use order_no order id to obtain the payment status)
  • It should be noted that because it takes time to write the payment status to the database, the accurate payment status may not be obtained after returning to h5 at the first time, so it is necessary to delay obtaining the payment status
  • You can consider adding a buffer page, and the callback address should not directly jump back to the h5 homepage, so as to prolong the operation time and ensure that the payment status can be obtained normally

Guess you like

Origin blog.csdn.net/qq_38974163/article/details/128419667