Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

Main flows

To integrate a merchant's system with Alipay to run the Merchant QR Code payment, the merchant is required to implement functions of QR code generation, payment, cancel, query, and refund. These function flows are respectively explained in this chapter.

Create flow

A merchant can request to generate a QR Code to permanently represent its counter in this Merchant QR Code Payment solution. The following figure illustrates the work flow.

image

For this flow, we would like to highlight:

  1. The merchant can request to generate a static QR code by this interface alipay.commerce.qrcode.create(CREATE), and it is important to note that this interface requires to input a "notification URL", to which Alipay will send a notification with transaction status after a successful payment.
  2. The parameter values for calling the precreate service are encapsulated in the first HTTPs request data, including the signature related data.
  3. The CREATE service request will fail if either the signature is invalid or other compulsory parameter values are absent or illegal.
  4. For the full list of parameters and values of the CREATE service, please refer the corresponding interface API for detail.

Pay flow

In the context of the Merchant QR Code payment, the QR Code permanently represent the mechant's counter. Thus, whenever a customer needs to pay an order, the customer just needs to scan the QR Code to input the amount to pay and then confirm the payment, and the Alipay will send a notification then.


The following figure illustrates the work flow.

image

Upon receiving the notification of a payment from Alipay, the merchant should verify the signature and validate the information sent back in the notification with the customer's payment details. 

Cancel flow

During the payment process of a transaction, it is possible to encounter issues such as system exception or network accessibility. In such a scenario, you need to reverse the transaction.


The following figure illustrates the work flow.

image

To implement this reversing, we would like to highlight the notes of below:

  1. In this integration, please use the CANCEL to reverse a transaction, and the interface name is: alipay.acquire.cancel
  2. For a transaction that has been successfully paid, the CANCEL is able to refund the transaction within the transaction day (GMT+8).
  3. Comparing with the REFUND service, if a transaction can be refunded by this CANCEL interface, the transaction fee that hass been charged by Alipay will always be refunded as well
  4. For a transaction has encountered technical issues during making the payment, the CANCEL is able to roll back all the actions have been performed in the Alipay system regarding the specific transaction
  5. For the full list of parameters and error code of this CANCEL service, please refer the interface API document for details. 

Refund flow

For a transaction that has been successfully paid, the customer can request the merchant for refunding as long as the refunding period is still valid, and the merchant can make use of the refunding interface to complete the refunding.

The following figure illustrates the work flow.

image

For the integration of the refunding service, we would like to highlight:

  1. The refunding service name is: alipay.acquire.overseas.spot.refund (REFUND);
  2. To refund a transaction, the interface REVERSE is applicable as long as the refunding period has not expired yet;
  3. the refunding of a transaction can be full or partial, i.e. the refunding amount can respectively be the same as or less than the original transaction amount that has been paid; furthermore, for a transaction, multiple refunding request is allowed provided the sum of the amount of the multiple refunding request is less than or equal with the original transaction amount.

Query flow

You can query the status of a transaction order by using the query interface.

image

The following simplified flow shows the main process after calling the query interface:

image

For more information about the parameters and error codes, see the Query Interface.

Notes:

  • For payment that has result_code = UNKNOW, the query processes must be initiated to obtain the actual transaction status. Before calling the query interface, merchants can check the transaction details through the backend system, or by scanning the code on user's Alipay app or receipts.
  • For transactions with the status WAIT_BUYER_PAY, wait till timeout (3 minutes by default), and then call the query interface again to obtain the final transaction status.