The following guide explains the required steps in order to receive payments using Alipay through the Openpay API.
Flow
Steps:
The customer requests to pay through Alipay
The merchant starts a new Alipay transaction using the Openpay API
The merchant redirects the customer to the URL returned by Openpay
The customer pays using his Alipay account
The transaction is completed in Openpay
The merchant is notified of a completed payment
The customer is redirected back to the merchant website, and the merchant verifies the transaction status
The merchant receives a notification from Openpay as an alternate confirmation method
The merchant must implement steps 1 through 3 to start the transaction, and step 6 to receive the completed payment notification.
Starting a transaction (Steps 1 through 3)
In order to start an Alipay transaction you must specify the transaction method as alipay. Additionaly, you must specify the URL to
where the customer will be redirected to once the payment process is completed.
If the process is successful, Openpay will return a response with an URL to which your customer must be redirected to in order
to complete their payment through Alipay.
Response:
Alipay payment (Steps 4 and 5)
Once the user arrives in the Alipay website, they can use the Alipay App to scan the given QR Code:
Or, alternatively, the customer can login into their Alipay account and complete payment in the browser:
Payment confirmation (Step 6)
Once the transaction has been paid, Openpay will set the transaction status to completed. The customer will be redirected back
to the merchant website and a notification will be sent to the merchant's configured webhooks.
Redirect confirmation (6a)
After the customer has completed their payment through Alipay, they will be redirected to the URL that you provided in the charge request,
with the addition of a parameter named id with the transaction ID of the completed payment.
The merchant must then use this ID to retrieve the transaction status using the Openpay API, and confirm that the transaction status is completed.
Note:
If the transaction status is not yet completed, the transaction is still pending payment and could still be completed at a later date.
Response:
Payment notification (6b)
There is the posibility that the customer is not returned to the final merchant webpage, for example, if the customer closes their browser after the payment,
or if the internet communication fails during the redirect.
In order to handle these cases, the customer must also listen to the Openpay webhook notifications. As with other transactions, Openpay will send a notification
once a transaction with Alipay is completed.
Note:
The webhook notification may be sent before or after the customer is redirected back to your webpage.