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

How can we help?

BACK

What is asynchronous notification?

An asynchronous notification is an API response that is sent to the API caller asynchronously with the POST method. To receive the asynchronous notification, the API caller must specify the targeted URL to handle the asynchronous notification by using notify_url field in the request.

After sending the notification, Alipay calls the notify page to check whether the notification is received. If the notify page does not display "success", Alipay continues to resend the notification. The notify page is one of the following pages in different languages:

  • Java: notify_url.jsp
  • Php: notify_url.php
  • C#: notify_url.aspx.cs

Please pay attention to the following specifications when you use asynchronous notifications:

  • Ensure that the Notification Page (as configured by notify_url) is absolutely blank, without space, html tag, or any error messages threw from the program system.
  • Alipay sends the notification information in POST method.
  • Asynchronous notification is only sent when a transaction exists in Alipay system and the transaction status is changed. For example, if the status of a real-time transaction is WAIT_BUYER_PAY, no notification is sent.
  • For some interfaces, if both return_url and notify_url are passed, both synchronous redirection and asynchronous notification are used when a transaction reaches a final state.
  • Asynchronous notification is the interaction between servers, which, unlike interaction between websites, is usually not visible.
  • After the notification is processed, the notification page must print "success" (without quote). If not, Alipay server keeps re-sending notification for the next 24 hours and 22 minutes. Generally, there are eight notifications within 25 hours (Frequency: 2m, 10m, 10m, 1h, 2h, 6h, 15h).
  • After the notification is processed, the notification page must not redirect. Otherwise, Alipay will not recognize a "success" string. Alipay system will then regard it as an error and keep sending notification.
  • Cookies and sessions are invalid on the notification page, which means these data cannot be captured.
  • The configuration and testing of asynchronous notification must be on a server that is connected to internet.
  • The main purpose of the asynchronous notification is to prevent loss of transaction orders. Even if a synchronous redirection fails, asynchronous notification can ensure that the merchant can still obtain the transaction information.
  • Alipay uses notify_id for idempotence control of asynchronous notifications. When the merchant receives the asynchronous notification and prints "success", the parameter notify_id becomes invalid.

  • Alipay might add new parameters (existing parameters will not change) along the way. When doing notification verification, merchants must use all parameters returned from Alipay, excluding sign_type and sign.

介:

异步通知是通过POST方法给接口调用者异步返回的接口调用结果。在调用支付宝接口时,通知页需要被设置目标URL以便之后能够处理接收到的异步通知信息。

发送异步通知之后,支付宝会调用通知页来检查是否异步通知已被接收方收到。如果通知页没有打印出“success”这七个字符(注意:无引号),支付宝会继续重发异步通知。通知页在不同编程语言示例代码中是以下页面:

  • Java: notify_url.jsp
  • Php: notify_url.php
  • C#: notify_url.aspx.cs

注意:

  • 必须保证服务器异步通知页面(notify_url)上无任何字符,如空格、HTML标签、开发系统自带抛出的异常提示信息等;

  • 支付宝是用POST方式发送通知信息.

  • 只有在支付宝的交易管理中存在该笔交易,且发生了交易状态的改变,支付宝才会通过该方式发起服务器通知(即时到账中交易状态为“等待买家付款”的状态默认是不会发送通知的);

  • 异步通知是服务器之间的交互,不像同步通知可以在页面上显示出来,这种交互方式是不可见的;

  • 第一次交易状态改变(即时到账中此时交易状态是交易完成)时,支付页面会跳转至指定的同步地址,服务器异步通知页面也会收到支付宝发来的处理结果通知;

  • 程序执行完后必须打印输出“success”(不包含引号)。如果商户反馈给支付宝的字符不是success这7个字符,支付宝服务器会不断重发通知,直到超过24小时22分钟。

一般情况下,25小时以内完成8次通知(通知的间隔频率一般是:2m,10m,10m,1h,2h,6h,15h);

  • 程序执行完成后,异步通知地址不能执行页面跳转。如果执行页面跳转,支付宝会收不到success字符,会被支付宝服务器判定为该页面程序运行出现异常,而重发处理结果通知;

  • cookies、session等在此页面会失效,即无法获取这些数据;

  • 该方式的调试与运行必须在服务器上,即互联网上才能访问;

  • 该方式的作用主要是防止订单丢失,当同步通知信息未被商户接收时,异步通知能够保证获取交易信息

  • 当商户收到服务器异步通知并打印出success时,服务器异步通知参数notify_id才会失效。也就是说在支付宝发送同一条异步通知时(包含商户并未成功打印出success导致支付宝重发数次通知),服务器异步通知参数notify_id是不变的。

  • 商户可以与支付宝联系,使异步通知返回更多的参数信息。随着业务的发展,异步通知也可能有新的参数信息返回,商户在收到异步通知后,支付宝所有的返回参数(除了sign_type和sign)都需要参与验签。

NEED HELP?

NEED HELP?