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

Calling APIs

You can send an HTTP/HTTPS request to get a specific Alipay-provided service:

  • To issue a payment: create_forex_trade
  • To issue a refund: forex_refund
  • To query a transaction: single_trade_query
  • To register in the AlipayHK system: alipay.overseas.secmerchant.online.maintain

How to call an API?

By sending an HTTP/HTTPS request, you can call one of the Alipay-provided APIs. The following graphic shows the process of calling an API and the corresponding results.

Calling APIs

  1. Generate a request URL and send an HTTP/HTTPS request to the Alipay server. The Alipay server verifies request parameters and then redirect you to the buyer’s login page. For more information about the request URL, see Creating the Request URL.
  1. After a payment is made, Alipay returns an asynchronous notification, or a synchronous notification, or both. For more information about the returned notifications, see Processing Notifications.
  1. If you cannot receive the asynchronous notification for an internet reason, you can call the Alipay transaction query API (single_trade_query) to get the payment and transaction data. 

Note:

You can use the Alipay transaction query API directly to obtain the transaction data, no need to rely on the asynchronous notification.

  1. After one successful trade, both synchronous and asynchronous notifications might be returned. It is recommended that you verify the asynchronous notification first. The process of verifying the synchronous notification is optional. For more information about verifying the notifications, see Processing Notifications.
  1. If the signature verification is passed, check the content of the notification. Ensure the consistency between the content of the notification and the original request and determine your further actions according to the trade status.