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

      Best practice

      Create optimal payment experiences for your customers by following these best practices for integrations. 


      #How to use an inquiry process?

      The Payment Result Inquiry interface can be used to check the transaction status of a payment request retry process. You can decide further actions based on the result of the inquiry process. The Inquiry interface can be used for the following cases:


      Use case 1

      If a payment API is called and a successful payment result is returned, the merchant can use the paymentId or paymentRequestId field to inquire the payment result of the payment request by calling the Inquiry interface.


      cp2 bp1.png

      Figure 1. Initiate a query process for a successful payment


      Use case 2

      If a payment API is called and a timeout payment result or a payment result with unknown exception is returned, the merchant can use the paymentRequestId field to inquire the payment result of the payment request by calling the Inquiry interface.


      cp2 bp2.png

      Figure 2. Initiate a query process for a payment that times out or with unknown result 


      Use case 3

      If a cancel API is called and a timeout result or a result with unknown exception is returned, the merchant can use the paymentId or paymentRequestId field of the original payment request to query the cancel result.


      cp2 bp3.png

      Figure 3. Initiate a query process for a cancellation process that times out or with unknown result 


      Use case 4

      If a capture API is called and a timeout result or a result with unknown exception is returned, the merchant can use the paymentId or paymentRequestId field of the original payment request to query the capture result.


      Note:

      Using the captureRequestId field for the query process is not supported.


      cp2 bp4.png

      Figure 4. Initiate a query process for a capture process that times out or with unknown result 


      Use case 5

      If a refund API is called and a timeout result or a result with unknown exception is returned, the merchant can use the paymentId or paymentRequestId field of the original payment to query the refund result.


      Note:

      Using the refundRequestId field for the query process is not supported.


      cp2 bp5.png

      Figure 5. Initiate a query process for a refund process that times out or with unknown result 


      #Difference between a retry and an inquiry process

      You need to choose between a retry and an inquiry process when handling exceptions or handling the payment process.


      Handling exceptions

      For a timeout process or a process that receives an unknown exception, a retry process performs the action again if the action is not completed while an inquiry process does not perform the action again. If the action is already completed, the retry process and the inquiry process return the same result that shows the status of the corresponding process.


      If you want to make a payment request or a refund request be completed regardless of the payment or refund result, it is recommended to initiate a retry process when a timeout or unknown exception is received.


      Handling the payment in process

      When an auto debit payment is in process, the system is waiting for the downstream nodes to complete the payment. You can initiated an inquiry process to inquire the transaction status until it is completed, or you can initiate a retry process instead.


      When a cashier payment is in process, the system is waiting for a wallet user to be redirected to the cashier page to complete the payment. Before the payment process is completed and reaches a final status of success or failure, the retry or inquiry process returns a result that shows the payment is in process. Only when the payment process is completed, the retry or inquiry process returns the final status of the payment process, which is success or failure.


      Note:

      For a cashier payment, if and only if the payment is in process, the redirection action form and other related information are still to be included so that the user can be redirected again if needed.


      #Retry and inquiry strategy

      If you want to use the inquiry or retry process to get the status of the previous payment call, it is recommended to use an exponential backoff strategy when retrying or calling the Payment Inquiry interface to avoid flooding the API and running into rate-limiting.


      #About notifications

      Only cashier payments get the payment notification that shows the final status of a payment in real-time after the completion of user's payment action on the cashier page. 


      The following table shows the list of notifications for different cashier payment cases:

      Payment Result

      Background

      Notification

      Trigger Condition

      Success

      User completed the payment successfully

      Success

      The user is redirected.

      Failed

      User closed the wallet app or exited the browser, and returned to the merchant site.

      Payment is in process until it times out. No notification is sent until the order is closed.

      The final notification:

      Failed: the order is closed due to timeout. 

      The order times out on the wallet side.

      User made a payment attempt but failed with all other payment options on the cashier page due to the following reasons:

      • Insufficient balance
      • Card authorization decline
      • Risk rejection
      • Exceed payment limits
      • Others


      Payment is in process until it  times out. No notification is sent until the order is closed.

      The final notification:

      Failed: the order is closed due to timeout.

      The order times out on the wallet side.

      User did not complete the payment, and remained in the payment flow until it times out. 

      The order is closed 

      The order times out on the wallet side.

      Table 1. The list of notifications for different cashier payment cases


      #About the currency

      Currency related data fields exist for both APIs and reconciliation reports. One of them is the payment amount that is presented by the amount field. The amount field has sub fields of currency and value. And all currency fields of Alipay APIs or reports follow the same definition. 

      #Amount

      Field

      Description

      currency

      MANDATORY String (3)
      The 3-letter currency code that follows ISO 4217 standard.

      value

      MANDATORY String (16)

      The amount to charge as a positive integer in the smallest currency unit. (That is, 100 cents to charge $1.00, or 100 to charge JPY ¥100, a zero-decimal currency).

      Table 2. Subfields of the amount field


      Notes:

      • The wallet is specified by the value of paymentMethodType, and the corresponding currency for the wallet is specified by currency.
      • The actual value in the value field of the amount field is represented in the smallest unit of the currency. Alipay follows the ISO 4217 standard for the definition of the smallest unit of a currency. For example:

      Currency Code

      Smallest Unit

      (Number of the Digits after Decimal)

      Value in the Amount

      USD

      cent (2)

      1.00 USD needs to be set as "value:100"

      For example: {"currency":"USD","value":"100"}

      PHP

      cent (2)

      1.00 PHP needs to be set as "value:100"

      For example: {"currency":"PHP","value":"100"}

      IDR

      cent (2)

      1.00 IDR needs to be set as "value:100"

      For example: {"currency":"IDR","value":"100"}

      Note: For the currency of IDR, the amount value needs to be an integral multiple of 100. Otherwise, an error of PARAM_ILLEGAL is to be returned for the payment request.

      KRW

      yuan (0)

      1 KRW needs to be set as "value:1"

      For example: {"currency":"KRW","value":"1"}

      THB

      cent (2)

      1.00 THB needs to be set as "value: 100"

      For example: {"currency":"THB","value":"100"}

      HKD

      cent (2)

      1.00 HKD needs to be set as "value: 100"

      For example: {"currency":"HKD","value":"100"}

      MYR

      cent (2)

      1.00 MYR needs to be set as "value: 100"

      For example: {"currency":"MYR","value":"100"}

      CNY

      cent (2)

      1.00 CNY needs to be set as "value: 100"

      For example: {"currency":"CNY","value":"100"}

      BDT

      cent (2)

      1.00 BDT needs to be set as "value: 100"

      For example: {"currency":"BDT","value":"100"}

      PKR

      cent (2)

      1.00 PKR needs to be set as "value: 100"

      For example: {"currency":"PKR","value":"100"}

      Table 3. Details about the currency


      #About the payment or refund amount

      The minimum payment or refund amount differs for each wallet. The following table shows the details of the minimum payment or refund amount of each wallet.


      WalletMinimum payment amount

      Minimum refund amount

      TrueMoney wallet

      1 THB


      1 THB

      Touch'n Go wallet

      0.1 MYR

      0.1 MYR

      Gcash wallet

      1 PHP

      1 PHP

      Dana wallet

      300 IDR

      300 IDR

      bKash wallet

      0.01 BDT

      0.01 BDT

      EasyPaisa wallet

      100 PKR

      100 PKR

      KakaoPay wallet

      50 KRW

      50 KRW

      Alipay HK wallet

      For Cashier Payment, the minimum payment amount is 0.1 HKD.

      Note:

      For Auto Debit, the minimum payment amount is 0.01 HKD.

      For Cashier Payment, the minimum refund amount is 0.1 HKD.

      Note:

      For Auto Debit, the minimum refund amount is 0.01 HKD.

      Table 4. The minimum payment or refund amount for different wallet.