CRM Open API DocumentationCRM Open API Documentation
REST API
Webhooks
PSP Open API
External Exchange Rates
REST API
Webhooks
PSP Open API
External Exchange Rates
  • PSP Open API Introduction
  • Signature Algorithm
  • API Specifications

    • 1. PSP Get Payment URL
    • 2. PSP Payment Callback
  • Errors

Signature Algorithm (sign)

  1. Extract the parameters from the POST request and exclude any parameter with an empty value to reduce unnecessary processing.
  2. Sort the remaining non-empty parameters alphabetically by their keys following the ASCII dictionary order.
  3. Concatenate the sorted key-value pairs into a single string in the format: key1=value1&key2=value2... This string is referred to as StringA.
  4. Append the crm-pay-token to StringA to form StringB, which will be used for encryption.
  5. Perform a SHA1 hash on StringB. Convert the resulting hash value into a hexadecimal string.
  6. Convert the hexadecimal string to uppercase to get the final signature value.

Sample code to obtain the signature

js
let query = Object.keys(data)
   .sort()
   .reduce((result, key) => result + key + '=' + data[key] + '&', "")
   .slice(0, -1);

let sign = crypto.createHash('sha1').update(query + crm_pay_token).digest('hex').toUpperCase();
python
query = '&'.join([f"{key}={data[key]}" for key in sorted(data)])

sign = hashlib.sha1((query + crm_pay_token).encode('utf-8')).hexdigest().upper()
Last Updated:: 10/16/24, 7:13 AM
Prev
PSP Open API Introduction