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

How can we help?

BACK

Which charset is used for asynchronous notifications?

Question:

Which charset is used by the asynchronous notifications that are sent to my server?

Answer:

The charset of an Alipay response, including both synchronous responses and asynchronous notifications, is consistent with the charset of the request (parameter _input_charset). If _input_charset is UTF-8 in the request, the response is also UTF-8 encoded.

Notes:

  • If _input_charset is not passed, the response is GBK encoded by default.
  • For interface alipay.commerce.qrcode.create, the charset for asynchronous notification is specified by notify_charset under parameter biz_data.
  • If a POST request is used, the charset field (_input_charset or charset) in the request must be placed in the gateway section. Otherwise, Alipay will not be able to recognize the requested character set and will use GBK for processing by default, resulting in a request error. See Dynamic Tutorial Of Signature And Generating Request for more information.


问题:

发送到我服务器的异步通知会采用哪种字符集?

解答:

支付宝响应的字符集(包括同步响应与异步通知),与请求时的字符集一致。

请求时若_input_charset字段设置为UTF-8,则响应也为UTF-8编码。

若未传_input_charset字段,则响应为GBK编码。

若传了_input_charset为UTF-8但响应为GBK编码,请检查_input_charset字段是否有拼写错误,是否按要求传值。

  • alipay.commerce.qrcode.create接口为例外,该接口的异步通知的编码集需要在参数biz_data中通过notify_charset指定。

说明:

若采用POST请求,需要将请求参数中的字符集字段(_input_charset或charset)放到gateway部分。否则支付宝将无法识别请求的字符集,将默认用GBK进行处理,从而导致请求错误。

NEED HELP?

NEED HELP?