Generating pre-sign string

Last updated: 2019-4-4

Except for sign and sign_type, all other parameters used need to be signed.

Generating the pre-sign string for request

For the following parameter array:

string[]  parameters={"partner=\"208861122157****\"",
"seller_id=\"208861122157****\"",
"out_trade_no=\"0811172929-1013\"",
"subject=\"test\"",
"body=\"test\"",
"currency=\"HKD\"",
"total_fee=\"0.1\"",
"notify_url=\"http://0ee96cd2.ngrok.io/notify.htm\"",
"service=\"mobile.securitypay.pay\"",
"payment_type=\"1\"",
"_input_charset=\"utf-8\"",
"appenv=\"system=java^version=1.8\"",
"forex_biz=\"FP\""
  };

Combine all array values in the format of key="value" and then link them up by the character "&" in an alphabetical order. For example:

_input_charset="utf-8"&appenv="system=java^version=1.8"&body="test"&currency="HKD"&forex_biz="FP"&notify_url="http://0ee96cd2.ngrok.io/notify.htm"&out_trade_no="0811172929-1013"&partner="208861122157****”&payment_type="1"&seller_id="208861122157****”&service="mobile.securitypay.pay"&sign="$$$"&sign_type="RSA"&subject="test"&total_fee="0.1"

Generating the pre-sign string for synchronous notification

The following sample illustrates the content of a synchronous notification:

resultStatus={9000};memo={};result={partner="2088101568358171"&seller_id="xxx@alipay.com"&out_trade_no="0819145412-6177"&subject="test"&body="testtest"&total_fee="0.01"&notify_url="http://notify.msp.hk/notify.htm"&service="mobile.securitypay.pay"&payment_type="1"&_input_charset="utf-8"&it_b_pay="30m"&show_url="m.alipay.com"&success="true"&sign_type="RSA"&sign="hkFZr+zE9499nuqDNLZEF7W75RFFPsly876QuRSeN8WMaUgcdR00IKy5ZyBJ4eldhoJ/2zghqrD4E2G2mNjs3aE+HCLiBXrPDNdLKCZgSOIqmv46TfPTEqopYfhs+o5fZzXxt34fwdrzN4mX6S13cr3UwmEV4L3Ffir/02RBVtU="}

Take out the part of result, remove sign and sign_type parameters:

partner="2088101568358171"&seller_id="xxx@alipay.com"&out_trade_no="0819145412-6177"&subject="test"&body="testtest"&total_fee="0.01"&notify_url="http://notify.msp.hk/notify.htm"&service="mobile.securitypay.pay"&payment_type="1"&_input_charset="utf-8"&it_b_pay="30m"&show_url="m.alipay.com"&success="true"

Generating the pre-sign string for asynchronous notification

The following sample illustrates the contents of an asynchronous notification:

http://0ee96cd2.ngrok.io/notify.htm? buyer_id=208812287878****&currency=HKD&forex_rate=0.85420000&notify_id=e5f5c6a77034fcd111e373e7e61dcbegdy&notify_type=trade_status_sync&notify_time=2017-08-11 17:31:39&out_trade_no=0811172929-1013&rmb_fee=0.09&seller_id=208861122157****&trade_no=2017081121001003050274536539&total_fee=0.10&trade_status=TRADE_FINISHED&sign_type=RSA&sign=$$$

Remove sign and sign_type, sort other parameters in alphabetical order, and then link up all array values by the character of "&":

buyer_id=208812287878****&currency=HKD&forex_rate=0.85420000&notify_id=e5f5c6a77034fcd111e373e7e61dcbegdy&notify_type=trade_status_sync&notify_time=2017-08-11 17:31:39&out_trade_no=0811172929-1013&rmb_fee=0.09&seller_id=208861122157****&trade_no=2017081121001003050274536539&total_fee=0.10&trade_status=TRADE_FINISHED

Note:

  • Parameters without value don't need to be transmitted, nor to be included in the data to be signed;
  • At signing, the character set used to change the character into byte stream must be consistent with that specified in _input_charset;
  • If the parameter _input_charset is transmitted, it shall also be included in the data to be signed.

If you have any question, please contact us