Standard solution
System interaction flow
- Users start to check out at the cashier of the merchant.
- Users open Alipay app and then scan the QR code provided by the partner to visit the page provided by the partner.
- When the partner server processes the HTTP request, it discovers the UA is from Alipay Wallet (judging from the User-Agent value enclosed in the http request header). Then the partner server will redirect the user to the Alipay authorization page and specify the callback page URL in the request parameter.
- Alipay authorization page immediately (the user will not notice the page jumps) redirects the user to the partner’s callback page with the auth_code attached.
- With the auth code, the alipay.system.oauth.token API is called to obtain the Alipay user ID, and then records the Alipay user ID into the session. After that, the partner renders the payment page.
- The user enters the payment amount on the payment page and then submits it to the partner server to process.
- With the Alipay user ID stored in the session and other required parameters, the partner creates an order by calling the alipay.acquire.create API, and then send the returned Alipay trade number back to the H5 page.
- Within the H5 page, the partner calls jsapi:tradepay interface with the trade number using the Javascript language to request the payment.
- Alipay app prompts the user to confirm the order and pay. The user enters the password to complete the payment.
- After the payment succeeds, Alipay sends an asynchronous notification to the partner.
- In the meantime, Alipay notify the user of the successful payment by messages.
For the standard solution, a partner needs to complete the following steps:
- Apply for a developer account on Alipay open platform.
- Configure the web-based authorization callback page domain name on Alipay open platform.
- Construct an Alipay web-based authorization page URL.
- Provide the authorization callback page.
- Integrate the alipay.system.oauth.token.acquire API to obtain the Alipay user ID.
- Integrate the alipay.acquire.create API to create orders
- Integrate the jsapi:tradePay API to request payment.
- Receive the asynchronous notification of the payment result.