Signing API Parameters

Signing the API parameters is a feature that allows you to secure your 2Pay API calls, by using MD5 encryption and authenticated hash.

You will need to retrieve your API token from the 2Pay Dashboard in order to build the parameters of your API calls. API parameters must be signed with MD5 encryption.

Building the API parameter signature

To sign the API parameters, you need to follow these steps:

  1. Sort the parameters alphabetically according to the parameter name.Delete parameters with empty values.

  2. Concatenate the parameter names and values using '=' and '&' character.

  3. Append the MD5 hash value of your API token to the end of your parameters with the '&' prefix.

  4. Calculate the MD5 hash value of the Step 3 result.

📢 Parameters with empty values do not participate in the signature.

EXAMPLE

Consider the following parameters:

"merchantNo": "M1652121481867",
"vendor": "alipay",
"reference": "2-16602210967",
"amount": "10.00",
"currency": "USD",
"description": "",
"terminal": "ONLINE",
"callbackUrl": "http://pay.ios.com/2pay/callback_secure_pay.php?reference={reference}&status={status}",
"ipnUrl": "http://pay.ios.com/2pay/callback_secure_pay_ipn.php?vendor=alipay",
"goodsInfo": "",  
"timeout": "120",
"note": "213",

1. Delete fields with empty values in parameters

2. Concatenate the parameter names and values using '=' and '&' character

amount=10.00&callbackUrl=http://pay.ios.com/2pay/callback_secure_pay.php?reference={reference}&status={status}&currency=USD&ipnUrl=http://pay.ios.com/2pay/callback_secure_pay_ipn.php?vendor=alipay&merchantNo=M1652121481867&note=213&reference=2-16602210967&terminal=ONLINE&timeout=120&vendor=alipay

3. Append MD5 hash value of API token with '&' prefix.

When the API token is 5cbfb079f15b150122261c8537086d77a, the MD5 hash value is 186abea4b8610d7ff03768255588597a.

So the result string is :

amount=10.00&callbackUrl=http://pay.ios.com/2pay/callback_secure_pay.php?reference={reference}&status={status}&currency=USD&ipnUrl=http://pay.ios.com/2pay/callback_secure_pay_ipn.php?vendor=alipay&merchantNo=M1652121481867&note=213&reference=2-16602210967&terminal=ONLINE&timeout=120&vendor=alipay186abea4b8610d7ff03768255588597a

4. Calculate the MD5 hash value of Step 3 result string.

MD5 hash value is b40df6c2ef1b8893f229acb62b39fe2d

Last updated