To integrate a merchant's system with Alipay to run the Barcode payment, the merchant is required to implement functions of purchase, payment cancel, refund, order query, and settlement. These function flows are respectively explained in this chapter.
The following business flow shows how an Alipay payment integration works. The process involves the customer, the merchant, and Alipay.
The following simplified flow shows the main process after calling the barcode payment interface:
Merchants can call Payment Interface to place an order and initiate a charge request.
The following diagram shows a full purchase flow:
- To protect users from fraud, occasionally, the system might require the user to be authenticated before making a purchase. Users will be prompted to enter the payment password for various reasons, for example:
- Alipay risk engine determines a payment looks suspicious.
- Regulatory requirements demand an authentication step.
- If the payment status is unknown or if the transaction times out, call Query Interface to check the exact status.
For more information about the parameters and error codes, see Payment Interface and Query Interface.
During the payment process of a transaction, it is possible to encounter issues such as system exception or network accessibility. In such cases, merchants can reverse the transaction by using the cancel interface.
The following diagram shows the cancel flow:
- 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 has been charged by Alipay will always be refunded as well.
- For a transaction 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.
For a transaction that has been successfully paid, the customer can request the merchant for refund as long as the refund period is still valid, and the refund interface is used to complete the refund through the following business flow.
Merchants can call the refund interface to issue the refund. The following diagram shows the refund flow:
- The refund service name is: alipay.acquire.overseas.spot.refund.
- The refunding service is only applicable to a transaction that has been successfully paid.
- 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.
- Whether the transaction fee charged by Alipay will be refunded depends on your contract with Alipay.
- Comparing with the cancel interface (alipay.acquire.cancel), this service does not impose the 24-hours constraint, i.e. the merchant server can invoke this service at any time that between the moment when the transaction was paid and the time before the refund period expires.
- If a refund request encounters a failure, please retry for a reasonable number of times.
For more information about the parameters and error codes, see Refund Interface.
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.