aaa-report-sender.js
895 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
var request = require('request');
var moment = require('moment');
var config;
var monitorUtil;
function init(options) {
config = options.config;
monitorUtil = options.monitorUtil;
}
function _resend(requestId, cb) {
monitorUtil.getTrx(requestId, function(err, trx) {
if (err) {
cb(err);
return;
}
var options = {
url: config.aaa_url + '/topup',
qs: {
trans_id: requestId,
trans_date: moment().format('YYYYMMDDHHmmss'),
resp_code: trx.rc,
ussd_msg: trx.supplier + '$' + trx.lastResponse.parsed.MESSAGE
}
};
cb(null);
});
}
function resend(req, res, next) {
_resend(req.params.id, function(err) {
res.redirect("/trx/view/" + req.params.id);
});
}
exports.init = init;
exports.resend = resend;