API Access Rules
Protocol rule
Transmission mode: HTTPS
Test environment: https://ts-api-pay.gnete.com.hk
Production environment: https://api-pay.gnete.com.hk
Request method: POST
or GET
Content type: application/json
Character code: UTF-8
Signature algorithm: MD5
Parameter specification
Transaction amount: By default, it is in HKD. The unit is cent. The parameter value cannot have decimals.
Time parameter: All time parameters involved use a 13-digit value accurate to milliseconds, such as: 1622016572190. The time stamp specifically refers to the number of milliseconds from 00:00:00 on January 1, 1970, Greenwich Mean Time to the present.
Signature algorithm
The general steps for signature generation are as follows
Step 1: Set all the data sent or received as set M, sort the parameters with non-empty parameter values in set M in ascending order of parameter names' ASCII codes (lexicographical order), and append them at stringA using the URL key-value pair format (i.e., key1=value1&key2=value2...). Pay special attention to the following important rules:
- Sort the parameters in ascending order of parameter names' ASCII codes (lexicographical order);
- If the value of a parameter is empty, it will not be involved in the signature;
- The parameter names are case-sensitive;
- When verifying the signature in the return of a call or the active notification of the payment center, the transmitted sign parameter is not involved in the signature. The generated signature is checked against this sign value.
- Fields may be added on the payment center interface. When verifying the signature, the added extended fields must be supported
Step 2: Append key at the end of stringA '[i.e., StringA + "&key=" + private key]' to obtain stringSignTemp. Perform MD5 operation on stringSignTemp. Then convert all characters of the obtained string to uppercase to get signValue.
For example, the request payment system parameters are as follows:
Map signMap = new HashMap<>();
signMap.put("platId", "1000");
signMap.put("mchOrderNo", "P0123456789101");
signMap.put("amount", "10000");
signMap.put("clientIp", "192.168.0.111");
signMap.put("returnUrl", "https://www.baidu.com");
signMap.put("notifyUrl", "https://www.baidu.com");
signMap.put("reqTime", "20190723141000");
signMap.put("version", "1.0");
Value to be signed:
amount=10000&clientIp=192.168.0.111&mchOrderNo=P0123456789101¬ifyUrl=https://www.baidu.com&platId=1000&reqTime=20190723141000&returnUrl=https://www.baidu.com&version=1.0&key=EWEFD123RGSRETYDFNGFGFGSHDFGH
Signature result:
84E1CA56F984502BBAC06EA6707157F5
Final request payment system parameters:
amount=10000&clientIp=192.168.0.111&mchOrderNo=P0123456789101¬ifyUrl=https://www.baidu.com&platId=1000&reqTime=20190723141000&returnUrl=https://www.baidu.com&version=1.0&sign=84E1CA56F984502BBAC06EA6707157F5