The sequence diagram provided by the official document is as follows (the dotted line in the figure identifies the merchant link and the solid line identifies the Alipay link.
):
user
Merchant client: our own App.
Alipay client SDK: Alipay SDK integrated in our application.
Alipay server: Our App is connected with Alipay server through Alipay SDK.
Merchant server: that is, the server side of our App.
1. Users use our App to initiate payment operation;
2. Then our application sends a payment request to our server. At this point, the server returns the signed order string to the client.
3. When the client receives this request, Alipay SDK will adjust the payment, and Alipay SDK will connect to Alipay server at this time;
4. After the payment is completed, Alipay server will synchronously return the payment result to Alipay SDK in our App, and SDK will call back the payment result to our app;
Note that at this time, we are not sure that the payment was successful. We still need to take the following steps:
5. Alipay SDK callback will carry some parameter information. We get these parameter information, and then request the interface of our server again, and send these parameters to the server, which will use these parameters to check and return the results to the client.
Only by completing the fifth step can we determine whether the payment is successful.
There are three steps to transfer payment to payment:
Step 1: the client clicks on the interface of the server that initiated the payment request, and the server directly sends the request string orderString assembled and signed to the client;
Step 2: the client obtains the returned data and calls Alipay payment SDK;;
Step 3: Jump to Alipay wallet (payment page) to make payment and process the payment result.
Payment verification is required after the payment result returned synchronously is 9000:
After the client gets the payment result of Alipay, it extracts the corresponding fields and sends them to the server, which verifies the legality of the notification parameters. Only after all the verification is passed can the buyer be deemed to have paid successfully. Ps: Alipay will send a notification to the server asynchronously after the payment is successful.
to be continued