Add Transaction API Tutorial

This tutorial gives a stepwise approach to call the Add Transaction API.

// function that calculates the signature according to Pockyt rules  
function CalculateSignature(token,parameters)  
{  
    // calculate the hash value of the token

var ApiTokenHashvalue = crypto.createHash('md5').update(token).digest("hex")

// order parameters alphabetically  
var SortedParams = sortObj(parameters);

// Concatenate: add '&' between key and value pair and replace: for =  
var MyString = '' ;  
for (const [key, value] of Object.entries(SortedParams)) {  
    MyString += (`${key}=${value}&`);}

//  add hash value of token at the and of the string  
MyString += ApiTokenHashvalue ;

// create the verifySign

const MySignature = crypto.createHash('md5').update(MyString).digest("hex");

return MySignature;

// alphabetical sort helper function  
    function sortObj(obj) {  
        return Object.keys(obj).sort().reduce(function (result, key) {  
          result[key] = obj[key];  
          return result;  
        }, {});  
      }  
}