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

Creating the Pre-sign String

Complete the following steps to create the pre-sign string:
1、Identify the parameters to be signed.
All the parameters in the list of request and response parameters need to be signed except the sign and sign_type. (Sign_type also needs to be signed in some cases in the list of request parameters).

2、Sort the above parameters alphabetically.
Sort the parameters according to the key value ASCII code of the first character in ascending alphabetical order. For parameters with the same first character, make the sort based on the second character.

3、Create the pre-sign string.
Combine all the sorted parameters in the format of parameter name = parameter value and link the combinations with the character of &. In this way, you get the pre-sign string.

Note:

  • The parameter without a value doesn't need to be included in the pre-sign string.
  • Parameter values cannot be null or "null", which are not supported by the system.
  • According to HTTP protocol, special character like &,@ needs to do URL encoding, therefore the request receiver can get correct value. In this situation, pre-sign string shall be the original value instead of encoded one. For example: calling a particular API need to sign the parameter email, the pre-sign string shall be email=test@msn.com, rather than email=test%40msn.com.