Cashier payment
With this topic, you can learn how to implement cashier payment capability in your mini program. Cashier payment provides an easy, secure payment experience for users to pay on your mini program. To dig deeper, see Alipay+ Cashier Payment Introduction for the benefits, features, and user experience of cashier payments.
Note: This solution is aimed at mini programs that are released to AlipayCN (Alipay China). If you release your mini program to Alipay+ partner apps, refer to the Alipay+ cashier payment solution.
Before you start
- Make sure you know who your acquiring partner is:
- If you choose Alipay merchant service, refer to Alipay Developer Center to get API documentation.
- If you choose other acquiring partners of Alipay+, contact your local acquiring partner to get API documentation.
- Contact your solution architect for permission to call the my.getSiteInfo and my.crossPay JSAPIs.
Note: This solution is based on Alipay merchant service as the acquiring partner, which is also applicable to other acquiring partners of Alipay+.
Sequence
The following sequence diagram illustrates how to achieve cashier payment capability:
The steps in the diagram are described as follows:
- The user opens a mini program and places an order [1]. The mini program shows the order to the user.
- After the user confirms the order, the mini program invokes the my.getSiteInfo JASPI and gets the system information of the super app [1.2].
- The mini program calls the merchant server's order creation API and sends a request to create the order [1.3].
- The merchant server sends the order creation request to the acquiring partner [1.3.1]. Note: For the order creation API of Alipay merchant service, see /v1/payments/pay. The key parameter that is passed in includes terminalType and its value is
MINI_APP
. - The acquiring partner verifies the request and returns the payment URL to the merchant server [1.3.1.3]. The merchant server returns the URL to the mini program [1.4].
- With the payment URL, the mini program invokes the my.crossPay JSAPI to make the payment to the super app [1.5]. The super app transfers the payment request to the super app server for decoding. Then the super app shows the cashier page [1.5.1].
- The user checks the order and confirms to make the payment [2]. The super app will process the payment and notify the acquiring partner of the payment result [2.1].
- The my.crossPay JSAPI returns the result code
8000
(Trade is processing) when the user is redirected from the cashier page to the mini program [2.2]. Note that the my.crossPay JSAPI cannot get the final payment result regardless of whether the user confirms or cancels the payment. - The acquiring partner calls the notification API to send the payment result to the merchant [3.1]. You can also use the payment result inquiry API to get the final payment result. Note: For the notifyPayment API of Alipay merchant service, see notifyPayment. For the inquiryPayment API of Alipay merchant service, see inquiryPayment.
- The mini program gets the payment result [2.2.2].
- The user has completed the payment on the mini program.
API list
Refer to the following two tables for the APIs that are used in the above procedures:
JSAPI
API name | Description |
Obtains the site information. | |
Starts a payment transaction. |
OpenAPI
API name | Description |
Initiates a payment and processes payment results. | |
Sends the payment result. | |
Queries for information about a previously submitted payment request or accept the asynchronous processing results for a payment. |
Note: The openAPIs listed above belong to Alipay merchant service. For other acquiring partners of Alipay+, contact your local acquiring partner to get API documentation.
More information
Alipay+ Cashier Payment Introduction