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.
For this flow, we would like to highlight:
- 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.
- The parameter values for calling the precreate service are encapsulated in the first HTTPs request data, including the signature related data.
- The CREATE service request will fail if either the signature is invalid or other compulsory parameter values are absent or illegal.
- 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.
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.
To implement this reversing, we would like to highlight the notes of below:
- In this integration, please use the CANCEL to reverse a transaction, and the interface name is: alipay.acquire.cancel
- For a transaction that has been successfully paid, the CANCEL is able to refund the transaction within the transaction day (GMT+8).
- 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
- 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
- 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.
For the integration of the refunding service, we would like to highlight:
- The refunding service name is: alipay.acquire.overseas.spot.refund (REFUND);
- To refund a transaction, the interface REVERSE is applicable as long as the refunding period has not expired yet;
- 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.
The following simplified flow shows the main process after calling the query interface:
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.