NodeJS Example for RIS Call

  1. Require needed libraries (querystring, https).
  2. Create your inquiry data array.
  3. Create your http options.
  4. Make a callback function to handle the response from the http call and pass it into the http request.
  5. Process the response object in the callback function.
var querystring = require('querystring');
var https = require('https');
var data = querystring.stringify(
{
"ANID":"0123456789",
"AUTH":"A",
"CURR":"USD",
"EMAL":"tptst15@gmail.com",
"IPAD":"127.0.0.1",
"MACK":"Y",
"MERC":"555555",
"MODE":"Q",
"PTOK":"4111111111111111",
"PTYP":"CARD",
"SESS":"-86ae-e111f23009fb-208152759",
"SITE":"DEFAULT",
"VERS":"0630",
"TOTL":"90000",
"PROD_DESC[0]":"FlightBooking",
"PROD_ITEM[0]":"Online Flight Booking",
"PROD_PRICE[0]":"699",
"PROD_QUANT[0]":1,
"PROD_TYPE[0]":"Flight Trip Booking",
}
    );
var options = {
  host: 'risk.test.kount.net',
  path: '/',
  port: '443',
  method: 'POST',
  headers: {'X-Kount-Api-Key': 'InsertAPIKeyHere',
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': Buffer.byteLength(data)
    }
};
callback = function(response) {
  var str = ''
  response.on('data', function (chunk) {
    str += chunk;
  });
  response.on('end', function () {
    console.log(str);
  });
}
var req = https.request(options, function(res) {
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
        console.log("body: " + chunk);
    });
});
req.write(data);
req.end();
Was this article helpful?
1 out of 1 found this helpful