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

  1. 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.
  1. 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:

image

The steps in the diagram are described as follows:

  1. The user opens a mini program and places an order [1]. The mini program shows the order to the user.
  2. 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].
  3. The mini program calls the merchant server's order creation API and sends a request to create the order [1.3].
  4. 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.
  5. 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].
  6. 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].
  7. 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].
  8. 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.
  9. 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.
  10. The mini program gets the payment result [2.2.2].
  11. 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

my.getSiteInfo

Obtains the site information.

my.crossPay

Starts a payment transaction.

OpenAPI

API name

Description

/v1/payments/pay

Initiates a payment and processes payment results.

notifyPayment

Sends the payment result.

inquiryPayment

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

Alipay+ cashier payment solution

Alipay Developer Center

Manage Alipay+ mini programs in Alipay China