forked from KalaiselvanMahendran/ccavenue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccavResponseHandler.js
30 lines (27 loc) · 1.19 KB
/
ccavResponseHandler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var http = require('http'),
fs = require('fs'),
ccav = require('./ccavutil.js'),
qs = require('querystring');
exports.postRes = function(request,response){
var ccavEncResponse='',
ccavResponse='',
workingKey = '********************', //Put in the 32-Bit key shared by CCAvenues.
ccavPOST = '';
request.on('data', function (data) {
ccavEncResponse += data;
ccavPOST = qs.parse(ccavEncResponse);
var encryption = ccavPOST.encResp;
ccavResponse = ccav.decrypt(encryption,workingKey);
});
request.on('end', function () {
var pData = '';
pData = '<table border=1 cellspacing=2 cellpadding=2><tr><td>'
pData = pData + ccavResponse.replace(/=/gi,'</td><td>')
pData = pData.replace(/&/gi,'</td></tr><tr><td>')
pData = pData + '</td></tr></table>'
htmlcode = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Response Handler</title></head><body><center><font size="4" color="blue"><b>Response Page</b></font><br>'+ pData +'</center><br></body></html>';
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(htmlcode);
response.end();
});
};