mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 17:46:28 +00:00
Compare commits
163 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f97c9e6c66 | |||
| 625ad19907 | |||
| f1e659c64a | |||
| df7d6909a3 | |||
| c5b75058d3 | |||
| 18cab4b93b | |||
| 40990b3498 | |||
| fa43d34c90 | |||
| 5a0d579405 | |||
| 8e9f9dca82 | |||
| c8755f9e2d | |||
| f2e6b31b82 | |||
| 751191e10e | |||
| 33039fab21 | |||
| 2c31a4e425 | |||
| b5b72ecf6c | |||
| b7e5d0c426 | |||
| 82bd1c5276 | |||
| c39675b1ac | |||
| 146e64fc63 | |||
| 058cd6edfc | |||
| 3fb2124534 | |||
| c4f276289a | |||
| f8aacae0ea | |||
| 0e237bd66d | |||
| 8e8704a1a2 | |||
| 25c3d03761 | |||
| 3be8c88db4 | |||
| 983902d08e | |||
| 7a09320404 | |||
| ff245148f6 | |||
| 5a4870408c | |||
| e3ef16753e | |||
| 90aaf3f6f6 | |||
| 0437eaab25 | |||
| 4a98a1c5cd | |||
| 3c927b6385 | |||
| 41bdf42bac | |||
| 986f2de372 | |||
| be1c3c179b | |||
| 1df38dbdf0 | |||
| aae040e908 | |||
| 37a81c826a | |||
| 34ee6cc703 | |||
| 7476de9ebe | |||
| 094d9809ff | |||
| 74993b5e26 | |||
| 5ceb25c892 | |||
| 2c744a350c | |||
| 270f859e0d | |||
| ba46437d11 | |||
| 255fb13ab7 | |||
| 7685916b19 | |||
| 0d1e4869be | |||
| 052c71220f | |||
| 6234fb5e36 | |||
| 4f72e83710 | |||
| 10f9f3a0bb | |||
| 8a5127a9e8 | |||
| bb666ee512 | |||
| 9ba2e03187 | |||
| f39c92f28d | |||
| 0f36b9f264 | |||
| c7334aa084 | |||
| e714540970 | |||
| dd52e4ce01 | |||
| c22d1b3596 | |||
| e41fa25c05 | |||
| 659531d908 | |||
| 8f8da98f6e | |||
| c8f01db5e9 | |||
| 1be5cc8d0c | |||
| 352ec2822f | |||
| 9910d4d834 | |||
| a2eb984658 | |||
| eac57a3821 | |||
| f4451aaea2 | |||
| 837d1c5d77 | |||
| 74825d277b | |||
| 8c231e9901 | |||
| 56cbc627a2 | |||
| a2a9a8c72f | |||
| 1af459fc4e | |||
| 47dc7eecc9 | |||
| a8d32ada48 | |||
| f7c5cf33f6 | |||
| 870d8aea46 | |||
| b46d3a5b25 | |||
| 5408639d80 | |||
| 9b2ab48e99 | |||
| a35492c124 | |||
| e1f0c60b37 | |||
| 16afd42876 | |||
| 3722be6eeb | |||
| 493f131779 | |||
| f10ff80284 | |||
| f30ee86552 | |||
| e8de33b663 | |||
| 68ebfb0ac2 | |||
| 96c46ad49c | |||
| 10e38babcd | |||
| 8bc68493cf | |||
| 2b1b14548a | |||
| 240bb5fa17 | |||
| 7676ec54ef | |||
| de0a8847b5 | |||
| 4df41a426c | |||
| 3401e425b4 | |||
| 0d29175942 | |||
| 4f03433bb2 | |||
| 1df5f97543 | |||
| a222714bcb | |||
| 2249bbbbaf | |||
| 16fbfdcae1 | |||
| 6b5f92e597 | |||
| baf99a975d | |||
| 70b9ef78cb | |||
| 4169b40e97 | |||
| 3566f63bea | |||
| 066fd49173 | |||
| 2c0ffbd9d6 | |||
| ee46232c7a | |||
| 15131cebb1 | |||
| 6ff785de5a | |||
| 8e997346d2 | |||
| 80dda817fb | |||
| 410ef5ac53 | |||
| d9d5be8921 | |||
| 574092e015 | |||
| 5ece7912f4 | |||
| 2540b1c6c0 | |||
| 4feb7a7724 | |||
| 4994278078 | |||
| c6488f7f69 | |||
| f0bbf54afc | |||
| 7c6ab450be | |||
| 1524d643c6 | |||
| 36b61697dd | |||
| 8366d9b38b | |||
| ed7e0ce127 | |||
| 8d1e2075c3 | |||
| 5df52be111 | |||
| 6e0627fb86 | |||
| 0235cdb7c0 | |||
| a64c38b928 | |||
| 99f004adf2 | |||
| 3e5d73dd56 | |||
| 4481079289 | |||
| 9bc1260bc0 | |||
| df8ad92eba | |||
| 3b8d9d20ff | |||
| 5197966807 | |||
| 966c7b1f60 | |||
| 002f1375e4 | |||
| ada8358c07 | |||
| b587640684 | |||
| 7d56ebbe77 | |||
| 015832c683 | |||
| 79a5c5951b | |||
| c54a030519 | |||
| 775b36cfd2 | |||
| b796bfdd5c | |||
| 25f66afa7b |
@@ -0,0 +1,293 @@
|
||||
const winston = require("winston");
|
||||
require("winston-daily-rotate-file");
|
||||
const expressWinston = require("express-winston");
|
||||
const fs = require("fs");
|
||||
const moment = require("moment");
|
||||
const winstonLoki = require("../helpers/loki");
|
||||
const knex = require("../../infrastructure/database/knex");
|
||||
const {
|
||||
topuponline_metrics,
|
||||
topuponline_metrics_response_time,
|
||||
topuponline_metrics_load_balance,
|
||||
} = require("../helpers/prometheusmetrics");
|
||||
|
||||
const filename = () => {
|
||||
if (!fs.existsSync(`./expresswinstonlog`)) {
|
||||
fs.mkdirSync(`./expresswinstonlog`);
|
||||
}
|
||||
if (!fs.existsSync(`./expresswinstonlog/${moment().format("YYYY")}`)) {
|
||||
fs.mkdirSync(`./expresswinstonlog/${moment().format("YYYY")}`);
|
||||
}
|
||||
if (
|
||||
!fs.existsSync(
|
||||
`./expresswinstonlog/${moment().format("YYYY")}/${moment().format("MM")}`
|
||||
)
|
||||
) {
|
||||
fs.mkdirSync(
|
||||
`./expresswinstonlog/${moment().format("YYYY")}/${moment().format("MM")}`
|
||||
);
|
||||
}
|
||||
|
||||
return `expresswinstonlog/${moment().format("YYYY")}-${moment().format(
|
||||
"MM"
|
||||
)}-${moment().format("DD")}.log`;
|
||||
};
|
||||
|
||||
filename();
|
||||
|
||||
const routes = [
|
||||
"/api/reservation",
|
||||
"/api/reservation/v2",
|
||||
"/api/loadbalance/request",
|
||||
"/api/topup1",
|
||||
"/api/topup2",
|
||||
"/api/topup3",
|
||||
"/api/topup4",
|
||||
"/api/topup5",
|
||||
"/api/topup6",
|
||||
"/api/topup7",
|
||||
"/api/topup8",
|
||||
];
|
||||
|
||||
const logger = {
|
||||
response: expressWinston.logger({
|
||||
transports: [
|
||||
new winston.transports.DailyRotateFile({
|
||||
filename: "./expresswinstonlog/%DATE%.log",
|
||||
frequency: "24h",
|
||||
datePattern: "YYYY/MM/DD",
|
||||
maxFiles: "1d",
|
||||
}),
|
||||
],
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp(),
|
||||
winston.format.printf(async (info) => {
|
||||
let body = {};
|
||||
body.id = info.meta.req.id;
|
||||
body.tag = "RES";
|
||||
body.from = info.meta.req.ip;
|
||||
body.method = info.meta.req.method;
|
||||
body.endpoint = info.meta.req.originalUrl;
|
||||
body.time = moment().format();
|
||||
body.responseTime = `${info.meta.responseTime} ms`;
|
||||
|
||||
let issuerName;
|
||||
|
||||
let partnerId = info.meta.req.partner_id_token;
|
||||
|
||||
if (!partnerId) {
|
||||
issuerName = "UNDEFINED";
|
||||
} else {
|
||||
let getIssuerName = await getPartner(info.meta.req.partner_id_token);
|
||||
if (!getIssuerName.c_name) {
|
||||
issuerName = "UNDEFINED";
|
||||
} else {
|
||||
issuerName = getIssuerName.c_name;
|
||||
}
|
||||
}
|
||||
|
||||
let statusCode = info.meta.res.body.code;
|
||||
let message = info.meta.res.body.message;
|
||||
let url = info.meta.req.originalUrl;
|
||||
|
||||
let date = moment().format("D");
|
||||
let month = moment().format("M");
|
||||
let year = moment().format("Y");
|
||||
|
||||
// Topup Metrics
|
||||
if (
|
||||
url == "/api/topup1" ||
|
||||
url == "/api/topup2" ||
|
||||
url == "/api/topup3" ||
|
||||
url == "/api/topup4" ||
|
||||
url == "/api/topup5" ||
|
||||
url == "/api/topup6" ||
|
||||
url == "/api/topup7" ||
|
||||
url == "/api/topup8"
|
||||
) {
|
||||
let trxId = info.meta.res.body.data.trxID;
|
||||
if (!trxId) {
|
||||
trxId = "UNDEFINED";
|
||||
}
|
||||
|
||||
topuponline_metrics_load_balance
|
||||
.labels({
|
||||
trxId: trxId,
|
||||
route: url,
|
||||
issuer_name: issuerName,
|
||||
date: date,
|
||||
month: month,
|
||||
year: year,
|
||||
})
|
||||
.observe(info.meta.responseTime);
|
||||
}
|
||||
|
||||
// Reservation Loki Logs
|
||||
if (url == "/api/reservation" || url == "/api/reservation/v2") {
|
||||
if (
|
||||
statusCode != "00" &&
|
||||
statusCode != "01" &&
|
||||
statusCode != "02" &&
|
||||
statusCode != "03" &&
|
||||
statusCode != "04"
|
||||
) {
|
||||
console.log(statusCode);
|
||||
winstonLoki.log.error({
|
||||
message: message,
|
||||
labels: {
|
||||
route: url,
|
||||
status_code: statusCode,
|
||||
issuer_name: issuerName,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
let reservation_number = info.meta.res.body.data.reservation_number;
|
||||
let card_number = info.meta.res.body.data.card_number;
|
||||
winstonLoki.log.info({
|
||||
message: message,
|
||||
labels: {
|
||||
route: url,
|
||||
status_code: statusCode,
|
||||
issuer_name: issuerName,
|
||||
reservation_number: reservation_number,
|
||||
card_number: card_number,
|
||||
},
|
||||
});
|
||||
}
|
||||
} else if (url == "/api/topup6" || url == "/api/topup7") {
|
||||
let card_number = info.meta.req.body.card_number;
|
||||
let uid = info.meta.req.body.uid;
|
||||
let trxID = info.meta.res.body.data.trxID;
|
||||
if (
|
||||
statusCode != "00" &&
|
||||
statusCode != "01" &&
|
||||
statusCode != "02" &&
|
||||
statusCode != "03" &&
|
||||
statusCode != "04"
|
||||
) {
|
||||
winstonLoki.log.error({
|
||||
message: message,
|
||||
labels: {
|
||||
route: url,
|
||||
status_code: statusCode,
|
||||
issuer_name: issuerName,
|
||||
card_number: card_number,
|
||||
uid: uid,
|
||||
trxID: trxID,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
winstonLoki.log.info({
|
||||
message: message,
|
||||
labels: {
|
||||
route: url,
|
||||
status_code: statusCode,
|
||||
issuer_name: issuerName,
|
||||
card_number: card_number,
|
||||
uid: uid,
|
||||
trxID: trxID,
|
||||
},
|
||||
});
|
||||
}
|
||||
} else {
|
||||
let trxID = info.meta.res.body.data.trxID;
|
||||
if (
|
||||
statusCode != "00" &&
|
||||
statusCode != "01" &&
|
||||
statusCode != "02" &&
|
||||
statusCode != "03" &&
|
||||
statusCode != "04"
|
||||
) {
|
||||
winstonLoki.log.error({
|
||||
message: message,
|
||||
labels: {
|
||||
route: url,
|
||||
status_code: statusCode,
|
||||
issuer_name: issuerName,
|
||||
trxID: trxID,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
winstonLoki.log.info({
|
||||
message: message,
|
||||
labels: {
|
||||
route: url,
|
||||
status_code: statusCode,
|
||||
issuer_name: issuerName,
|
||||
trxID: trxID,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
topuponline_metrics
|
||||
.labels({
|
||||
issuer_name: issuerName,
|
||||
route: url,
|
||||
status_code: statusCode,
|
||||
date: date,
|
||||
month: month,
|
||||
year: year,
|
||||
})
|
||||
.observe(info.meta.responseTime);
|
||||
|
||||
topuponline_metrics_response_time
|
||||
.labels({
|
||||
issuer_name: issuerName,
|
||||
route: url,
|
||||
status_code: statusCode,
|
||||
date: date,
|
||||
month: month,
|
||||
year: year,
|
||||
response_time: info.meta.responseTime,
|
||||
})
|
||||
.observe(info.meta.responseTime);
|
||||
|
||||
return `[${moment().format()}] | ${JSON.stringify(body)}`;
|
||||
})
|
||||
),
|
||||
skip: (req, res) => {
|
||||
return routes.indexOf(req.originalUrl) === -1;
|
||||
},
|
||||
responseWhitelist: [...expressWinston.responseWhitelist, "body"],
|
||||
requestWhitelist: [
|
||||
...expressWinston.requestWhitelist,
|
||||
"body",
|
||||
"id",
|
||||
"ip",
|
||||
"partner_id_token",
|
||||
],
|
||||
}),
|
||||
request: expressWinston.logger({
|
||||
transports: [
|
||||
new winston.transports.DailyRotateFile({
|
||||
filename: "./expresswinstonlog/%DATE%.log",
|
||||
frequency: "24h",
|
||||
datePattern: "YYYY/MM/DD",
|
||||
maxFiles: "1d",
|
||||
}),
|
||||
],
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp(),
|
||||
winston.format.printf((info) => {
|
||||
let body = {};
|
||||
body.id = info.meta.req.id;
|
||||
body.tag = "REQ";
|
||||
body.from = info.meta.req.ip;
|
||||
body.method = info.meta.req.method;
|
||||
body.endpoint = info.meta.req.originalUrl;
|
||||
body.time = moment().format();
|
||||
return `[${moment().format()}] | ${JSON.stringify(body)}`;
|
||||
})
|
||||
),
|
||||
requestWhitelist: [...expressWinston.requestWhitelist, "body", "id", "ip"],
|
||||
}),
|
||||
};
|
||||
|
||||
const getPartner = async (id) => {
|
||||
let result = await knex("t_m_partner").where("i_partner", "=", id).first();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = { logger, filename };
|
||||
+137
-99
@@ -1,4 +1,4 @@
|
||||
const CryptoJS = require("crypto-js");
|
||||
const CryptoJS = require('crypto-js');
|
||||
|
||||
// ENCRYPT TEXT
|
||||
const encryptText = (text) => {
|
||||
@@ -20,6 +20,15 @@ const decryptText = (cipherText) => {
|
||||
}
|
||||
};
|
||||
|
||||
// CREATE HMAC
|
||||
const createHMAC = async (payload) => {
|
||||
let hash = await CryptoJS.HmacSHA256(
|
||||
payload,
|
||||
process.env.SECRET_KEY
|
||||
).toString();
|
||||
return hash;
|
||||
};
|
||||
|
||||
// RANDOM UNIQUE CODE
|
||||
function getUniqueCode() {
|
||||
const maxDate = Date.now();
|
||||
@@ -36,48 +45,64 @@ function randomNumberInt() {
|
||||
while (result.length !== 3) {
|
||||
let random = getRandomArbitrary(0, 9);
|
||||
if (!result.includes(random)) result.push(random);
|
||||
|
||||
|
||||
// To check if the first no is not zero
|
||||
if (result.length === 1 && random === 0) result.pop();
|
||||
}
|
||||
return parseInt( result.join("") );
|
||||
return parseInt(result.join(''));
|
||||
}
|
||||
|
||||
// GENERATE XML REQUEST
|
||||
function generateXMLRequest(urn, headers, items) {
|
||||
let xmlRequest = ''
|
||||
|
||||
let xmlRequest = '';
|
||||
|
||||
switch (urn.toUpperCase()) {
|
||||
case 'ZFMCMS_FI_001':
|
||||
|
||||
let xmlItem = ''
|
||||
let xmlItem = '';
|
||||
|
||||
items.map((item, index) => {
|
||||
xmlItem += `<item>
|
||||
<!--Optional:-->
|
||||
<ITEMNO_ACC>${String(index+1).padStart(10, '0')}</ITEMNO_ACC>
|
||||
<ITEMNO_ACC>${String(index + 1).padStart(
|
||||
10,
|
||||
'0'
|
||||
)}</ITEMNO_ACC>
|
||||
<!--Optional:-->
|
||||
<CUSTOMER>${item.c_account_code_topup ? item.c_account_code_topup : ""}</CUSTOMER>
|
||||
<CUSTOMER>${
|
||||
item.c_account_code_topup
|
||||
? item.c_account_code_topup
|
||||
: ''
|
||||
}</CUSTOMER>
|
||||
<!--Optional:-->
|
||||
<GL_ACCOUNT>${item.c_account_topup ? item.c_account_topup : ""}</GL_ACCOUNT>
|
||||
<GL_ACCOUNT>${
|
||||
item.c_account_topup ? item.c_account_topup : ''
|
||||
}</GL_ACCOUNT>
|
||||
<!--Optional:-->
|
||||
<BUS_AREA>${item.ba ? item.ba : ""}</BUS_AREA>
|
||||
<BUS_AREA>${item.ba ? item.ba : ''}</BUS_AREA>
|
||||
<!--Optional:-->
|
||||
<AMT_DOCCUR>${item.amount ? item.amount : ""}</AMT_DOCCUR>
|
||||
<AMT_DOCCUR>${
|
||||
item.amount ? item.amount : ''
|
||||
}</AMT_DOCCUR>
|
||||
<!--Optional:-->
|
||||
<BLINE_DATE>${item.posting_date ? item.posting_date : ""}</BLINE_DATE>
|
||||
<BLINE_DATE>${
|
||||
item.posting_date ? item.posting_date : ''
|
||||
}</BLINE_DATE>
|
||||
<!--Optional:-->
|
||||
<COSTCENTER></COSTCENTER>
|
||||
<!--Optional:-->
|
||||
<PROFITCENTER></PROFITCENTER>
|
||||
<!--Optional:-->
|
||||
<ALLOC_NMBR>${item.c_invoice_no ? item.c_invoice_no : ""}</ALLOC_NMBR>
|
||||
<ALLOC_NMBR>${
|
||||
item.c_invoice_no ? item.c_invoice_no : ''
|
||||
}</ALLOC_NMBR>
|
||||
<!--Optional:-->
|
||||
<ITEM_TEXT>${item.item_text ? item.item_text : ""}</ITEM_TEXT>
|
||||
<ITEM_TEXT>${
|
||||
item.item_text ? item.item_text : ''
|
||||
}</ITEM_TEXT>
|
||||
<!--Optional:-->
|
||||
<DE_CRE_IND>${item.de_cre}</DE_CRE_IND>
|
||||
</item>`
|
||||
})
|
||||
</item>`;
|
||||
});
|
||||
|
||||
xmlRequest = `<SOAP:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'
|
||||
xmlns:urn='urn:sap-com:document:sap:rfc:functions'>
|
||||
@@ -144,144 +169,157 @@ function generateXMLRequest(urn, headers, items) {
|
||||
</C_T_RETURN>
|
||||
</urn:${urn}>
|
||||
</SOAP:Body>
|
||||
</SOAP:Envelope>`
|
||||
</SOAP:Envelope>`;
|
||||
break;
|
||||
default:
|
||||
console.log('Sorry, we are out of ' + urn + '.');
|
||||
}
|
||||
|
||||
return xmlRequest
|
||||
|
||||
return xmlRequest;
|
||||
}
|
||||
|
||||
// POSTING SAP
|
||||
async function postingSAP(url, body, credential){
|
||||
async function postingSAP(url, body, credential) {
|
||||
try {
|
||||
const axios = require('axios');
|
||||
|
||||
const axios = require("axios");
|
||||
|
||||
const config = {
|
||||
headers : {
|
||||
const config = {
|
||||
headers: {
|
||||
'Content-Type': 'text/xml',
|
||||
'responseType': 'text',
|
||||
responseType: 'text',
|
||||
},
|
||||
auth: {
|
||||
username: credential.username,
|
||||
password: credential.password
|
||||
}
|
||||
}
|
||||
password: credential.password,
|
||||
},
|
||||
};
|
||||
|
||||
const resp = await axios.post(url, body, config)
|
||||
const resp = await axios.post(url, body, config);
|
||||
|
||||
return {
|
||||
status : resp.status,
|
||||
message: "Success",
|
||||
data : resp.data
|
||||
}
|
||||
|
||||
status: resp.status,
|
||||
message: 'Success',
|
||||
data: resp.data,
|
||||
};
|
||||
} catch (error) {
|
||||
// Error 😨
|
||||
// Error 😨
|
||||
|
||||
if (error.response) {
|
||||
/*
|
||||
* The request was made and the server responded with a
|
||||
* status code that falls out of the range of 2xx
|
||||
*/
|
||||
return {
|
||||
status : error.response.status,
|
||||
message: error.message,
|
||||
data : []
|
||||
}
|
||||
} else if (error.request) {
|
||||
/*
|
||||
* The request was made but no response was received, `error.request`
|
||||
* is an instance of XMLHttpRequest in the browser and an instance
|
||||
* of http.ClientRequest in Node.js
|
||||
*/
|
||||
return {
|
||||
status : 500,
|
||||
message: "can't connect to sap network".toUpperCase(),
|
||||
data : []
|
||||
}
|
||||
} else {
|
||||
// Something happened in setting up the request and triggered an Error
|
||||
return {
|
||||
status : 500,
|
||||
message: error.message,
|
||||
data : []
|
||||
}
|
||||
}
|
||||
if (error.response) {
|
||||
/*
|
||||
* The request was made and the server responded with a
|
||||
* status code that falls out of the range of 2xx
|
||||
*/
|
||||
return {
|
||||
status: error.response.status,
|
||||
message: error.message,
|
||||
data: [],
|
||||
};
|
||||
} else if (error.request) {
|
||||
/*
|
||||
* The request was made but no response was received, `error.request`
|
||||
* is an instance of XMLHttpRequest in the browser and an instance
|
||||
* of http.ClientRequest in Node.js
|
||||
*/
|
||||
return {
|
||||
status: 500,
|
||||
message: "can't connect to sap network".toUpperCase(),
|
||||
data: [],
|
||||
};
|
||||
} else {
|
||||
// Something happened in setting up the request and triggered an Error
|
||||
return {
|
||||
status: 500,
|
||||
message: error.message,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GET SOAP RESPONSE DATA
|
||||
function getXMLData(response) {
|
||||
const xml2js = require('xml2js');
|
||||
// console.log(xmlString)
|
||||
// console.log(xmlString)
|
||||
let resSAP = {
|
||||
type: '',
|
||||
message : '',
|
||||
data : {
|
||||
message: '',
|
||||
data: {
|
||||
E_DOCUMENTYEAR: '',
|
||||
E_DOCUMENTNUMBER: '',
|
||||
// ITEM: [],
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
if(response.status == 200){
|
||||
|
||||
if (response.status == 200) {
|
||||
const options = {
|
||||
explicitArray: false,
|
||||
tagNameProcessors: [xml2js.processors.stripPrefix]
|
||||
}
|
||||
tagNameProcessors: [xml2js.processors.stripPrefix],
|
||||
};
|
||||
|
||||
xml2js.parseString(response.data, options, (err, result) => {
|
||||
|
||||
if (err) throw err
|
||||
if (err) throw err;
|
||||
|
||||
let soapBody = result.Envelope.Body;
|
||||
|
||||
if (soapBody.$) delete soapBody.$
|
||||
if (soapBody.$) delete soapBody.$;
|
||||
|
||||
resSAP.data.E_DOCUMENTYEAR = soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTYEAR'] ? soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTYEAR'] : "0000"
|
||||
resSAP.data.E_DOCUMENTNUMBER = soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTNUMBER'] ? soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTNUMBER'] : ""
|
||||
resSAP.data.E_DOCUMENTYEAR = soapBody['ZFMCMS_FI_001.Response'][
|
||||
'E_DOCUMENTYEAR'
|
||||
]
|
||||
? soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTYEAR']
|
||||
: '0000';
|
||||
resSAP.data.E_DOCUMENTNUMBER = soapBody['ZFMCMS_FI_001.Response'][
|
||||
'E_DOCUMENTNUMBER'
|
||||
]
|
||||
? soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTNUMBER']
|
||||
: '';
|
||||
|
||||
if(soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']){
|
||||
if (!Array.isArray(soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'])) {
|
||||
if (soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']) {
|
||||
if (
|
||||
!Array.isArray(
|
||||
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']
|
||||
)
|
||||
) {
|
||||
// resSAP.data.ITEM.push(soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'])
|
||||
resSAP.type = soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']['TYPE']
|
||||
resSAP.message = "[SAP] " + soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']['MESSAGE_1']
|
||||
resSAP.type =
|
||||
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']['TYPE'];
|
||||
resSAP.message =
|
||||
'[SAP] ' +
|
||||
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'][
|
||||
'MESSAGE_1'
|
||||
];
|
||||
} else {
|
||||
// resSAP.data.ITEM = soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']
|
||||
resSAP.type = soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'][0]['TYPE']
|
||||
|
||||
const indexMessage = soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'].length - 1
|
||||
let message = "[SAP] "+ soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'][indexMessage]['MESSAGE_1']
|
||||
resSAP.type =
|
||||
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'][0]['TYPE'];
|
||||
|
||||
resSAP.message = message
|
||||
const indexMessage =
|
||||
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'].length - 1;
|
||||
let message =
|
||||
'[SAP] ' +
|
||||
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'][
|
||||
indexMessage
|
||||
]['MESSAGE_1'];
|
||||
|
||||
resSAP.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}else {
|
||||
|
||||
resSAP.type = 'E'
|
||||
resSAP.message = response.message ? response.message : "aa"
|
||||
|
||||
} else {
|
||||
resSAP.type = 'E';
|
||||
resSAP.message = response.message ? response.message : 'aa';
|
||||
}
|
||||
|
||||
|
||||
return resSAP
|
||||
|
||||
return resSAP;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
encryptText,
|
||||
decryptText,
|
||||
createHMAC,
|
||||
getUniqueCode,
|
||||
randomNumberInt,
|
||||
generateXMLRequest,
|
||||
postingSAP,
|
||||
getXMLData
|
||||
getXMLData,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
const moment = require("moment");
|
||||
const winston = require("winston");
|
||||
const loki = require("winston-loki");
|
||||
require("winston-daily-rotate-file");
|
||||
require("dotenv").config();
|
||||
const { combine, timestamp, printf, colorize, align, json } = winston.format;
|
||||
let lokiUrl = process.env.LOKI_URL;
|
||||
|
||||
const logLevels = {
|
||||
fatal: 0,
|
||||
error: 1,
|
||||
warn: 2,
|
||||
info: 3,
|
||||
debug: 4,
|
||||
trace: 5,
|
||||
};
|
||||
var log;
|
||||
|
||||
const fileRotateTransport = new winston.transports.DailyRotateFile({
|
||||
filename: `./lokiLog/%DATE%-onlinetopup.log`,
|
||||
datePattern: "YYYY-MM-DD",
|
||||
maxFiles: "1d",
|
||||
});
|
||||
|
||||
if (
|
||||
process.env.NODE_ENV == "production" ||
|
||||
process.env.NODE_ENV == "PRODUCTION"
|
||||
) {
|
||||
log = winston.createLogger({
|
||||
levels: logLevels,
|
||||
level: process.env.LOG_LEVEL || "info",
|
||||
exitOnError: false,
|
||||
// format: combine(timestamp(), json()),
|
||||
format: combine(
|
||||
// colorize({ all: true }),
|
||||
timestamp({
|
||||
format: "YYYY-MM-DD HH:mm:ss.SSS",
|
||||
}),
|
||||
align(),
|
||||
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
|
||||
),
|
||||
defaultMeta: { service: "topuponline" },
|
||||
transports: [
|
||||
new loki({
|
||||
host: lokiUrl,
|
||||
labels: { app: "topuponline" },
|
||||
json: true,
|
||||
format: json(),
|
||||
replaceTimestamp: true,
|
||||
onConnectionError: (err) => console.error(err),
|
||||
}),
|
||||
new transports.Console({
|
||||
format: format.combine(format.simple(), format.colorize()),
|
||||
}),
|
||||
],
|
||||
});
|
||||
} else {
|
||||
log = winston.createLogger({
|
||||
transports: [
|
||||
new loki({
|
||||
host: lokiUrl,
|
||||
labels: { app: "topuponline" },
|
||||
handleExceptions: true,
|
||||
handleRejections: true,
|
||||
clearOnError: true,
|
||||
json: true,
|
||||
format: json(),
|
||||
replaceTimestamp: true,
|
||||
onConnectionError: (err) => console.log(`Loki error ${err}`),
|
||||
}),
|
||||
new winston.transports.Console({
|
||||
format: combine(colorize()),
|
||||
}),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV != "testing" && process.env.NODE_ENV != "TESTING") {
|
||||
log.add(
|
||||
new winston.transports.Console({
|
||||
// format: winston.format.cli(),
|
||||
format: combine(
|
||||
colorize({ all: true }),
|
||||
timestamp({
|
||||
format: "YYYY-MM-DD HH:mm:ss.SSS",
|
||||
}),
|
||||
align(),
|
||||
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
|
||||
),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
log,
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
const client = require("prom-client");
|
||||
|
||||
const topuponline_metrics = new client.Histogram({
|
||||
name: "topuponline",
|
||||
help: "this is the metric for getting request data based on code status",
|
||||
labelNames: ["route", "status_code", "issuer_name", "date", "month", "year"],
|
||||
});
|
||||
|
||||
const topuponline_metrics_response_time = new client.Histogram({
|
||||
name: "topuponline_response_time",
|
||||
help: "this is the metric for getting request data based on response time",
|
||||
labelNames: [
|
||||
"route",
|
||||
"status_code",
|
||||
"issuer_name",
|
||||
"date",
|
||||
"month",
|
||||
"year",
|
||||
"response_time",
|
||||
],
|
||||
});
|
||||
|
||||
const topuponline_metrics_load_balance = new client.Histogram({
|
||||
name: "topuponline_load_balance",
|
||||
help: "this is the metric for getting request data based on response time",
|
||||
labelNames: [
|
||||
"route",
|
||||
"status_code",
|
||||
"issuer_name",
|
||||
"date",
|
||||
"month",
|
||||
"year",
|
||||
"trxId",
|
||||
],
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
topuponline_metrics,
|
||||
topuponline_metrics_response_time,
|
||||
topuponline_metrics_load_balance,
|
||||
};
|
||||
@@ -0,0 +1,126 @@
|
||||
require('dotenv').config();
|
||||
const redis = require('redis');
|
||||
const moment = require('moment');
|
||||
moment.locale('id');
|
||||
|
||||
let redisClient;
|
||||
(async () => {
|
||||
let redisUrl = process.env.REDIS_URL || 'redis://127.0.0.1:6379';
|
||||
let redisPass = process.env.REDIS_PASSWORD || '';
|
||||
|
||||
redisClient = redis.createClient({
|
||||
url: redisUrl,
|
||||
password: '',
|
||||
});
|
||||
|
||||
redisClient.on('error', (error) =>
|
||||
process.env.NODE_ENV.toUpperCase() != 'PRODUCTION'
|
||||
? console.error(`Error : ${error}`)
|
||||
: ''
|
||||
);
|
||||
|
||||
redisClient.on('connect', () => console.log('Redis is Connected'));
|
||||
|
||||
redisClient.on('ready', () => console.log('Redis is Ready'));
|
||||
|
||||
redisClient.on('reconnecting', () =>
|
||||
process.env.NODE_ENV.toUpperCase() != 'PRODUCTION'
|
||||
? console.log('Redis is Reconnecting')
|
||||
: ''
|
||||
);
|
||||
|
||||
await redisClient.connect();
|
||||
})();
|
||||
|
||||
const redisMiddleware = async (req, res, next) => {
|
||||
let isRedisReady = await redisClient.isReady;
|
||||
if (!isRedisReady) {
|
||||
next();
|
||||
} else {
|
||||
let getValue = await redisClient.get('cardproduct');
|
||||
let parsedValue = JSON.parse(getValue);
|
||||
|
||||
if (getValue) {
|
||||
res.status(200).json({
|
||||
code: 200,
|
||||
message: 'Success get from redis',
|
||||
data: parsedValue,
|
||||
});
|
||||
} else {
|
||||
res.on('finish', async () => {
|
||||
await redisClient.set('cardproduct', JSON.stringify(res.body), {
|
||||
EX: 10,
|
||||
NX: false,
|
||||
});
|
||||
});
|
||||
}
|
||||
next();
|
||||
}
|
||||
};
|
||||
|
||||
const getReservationNumberSequence = async (req, res, next) => {
|
||||
// set default reservation_number_sequence dari partner apapun is null
|
||||
req.reservation_number_sequence = null;
|
||||
|
||||
// cek jika redis is connect
|
||||
let isRedisReady = await redisClient.isReady;
|
||||
// jika tidak connect
|
||||
if (isRedisReady) {
|
||||
// jika connect maka cari sequence dari reservation number sesuai partner yg merequest
|
||||
// format value nya harusnya seperti ini = { date: '2023-01-01', sequence: 1 }
|
||||
// data req.partner_id_token di dapat dari authenticateToken di jwt middleware
|
||||
let getValue = await redisClient.GET(
|
||||
'reservation_number_sequence_' + req.partner_id_token
|
||||
);
|
||||
|
||||
if (getValue) {
|
||||
// parsing data menjadi json format
|
||||
let parsedValue = JSON.parse(getValue);
|
||||
|
||||
// cek apakah tanggal sequence yang di redis sama dengan hari ini atau bukan
|
||||
if (parsedValue.date == moment().format('YYYY-MM-DD')) {
|
||||
// jika tanggal nya sama dengan hari ini maka ambil sequence untuk reservation number yang di generate dari redis
|
||||
req.reservation_number_sequence = parseInt(parsedValue.sequence);
|
||||
|
||||
// langsung update sequence walaupun transaksi insert nya belum selesai
|
||||
// impact menggunakan redis, untuk nomor sequence bisa saja ada yg loncat karena bisa saja ada transaksi insert reservation yang gagal
|
||||
let setValue = {
|
||||
date: moment().format('YYYY-MM-DD'),
|
||||
sequence: parseInt(parsedValue.sequence) + 1,
|
||||
};
|
||||
|
||||
await redisClient.SET(
|
||||
`reservation_number_sequence_${req.partner_id_token}`,
|
||||
JSON.stringify(setValue)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
next();
|
||||
};
|
||||
|
||||
const setReservationNumberSequence = async (partner_id, sequence) => {
|
||||
// cek jika redis is connect
|
||||
let isRedisReady = await redisClient.isReady;
|
||||
// jika tidak connect
|
||||
if (isRedisReady) {
|
||||
// jika connect maka cari sequence dari reservation number sesuai partner yg merequest
|
||||
// format value nya harusnya seperti ini = { date: '2023-01-01', sequence: 1 }
|
||||
|
||||
let setValue = {
|
||||
date: moment().format('YYYY-MM-DD'),
|
||||
sequence: parseInt(sequence),
|
||||
};
|
||||
|
||||
await redisClient.SET(
|
||||
`reservation_number_sequence_${partner_id}`,
|
||||
JSON.stringify(setValue)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
redisMiddleware,
|
||||
getReservationNumberSequence,
|
||||
setReservationNumberSequence,
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,30 +1,30 @@
|
||||
const { param, body, validationResult } = require("express-validator");
|
||||
const helper = require("../../helpers/helper");
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const model = require("./history.model");
|
||||
const moment = require("moment");
|
||||
moment.locale("id");
|
||||
const { param, body, validationResult } = require('express-validator');
|
||||
const helper = require('../../helpers/helper');
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const model = require('./history.model');
|
||||
const moment = require('moment');
|
||||
moment.locale('id');
|
||||
|
||||
// VALIDATION
|
||||
const validate = (method) => {
|
||||
switch (method) {
|
||||
case "cardHistory":
|
||||
case 'cardHistory':
|
||||
return [
|
||||
body("data")
|
||||
body('data')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage("Data is required")
|
||||
.withMessage('Data is required')
|
||||
.isArray()
|
||||
.withMessage("Data is invalid request format"),
|
||||
.withMessage('Data is invalid request format'),
|
||||
];
|
||||
case "history":
|
||||
case 'history':
|
||||
return [
|
||||
body("mid").not().isEmpty().withMessage("MID is required"),
|
||||
body("tid").not().isEmpty().withMessage("TID is required"),
|
||||
body("card_number")
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
body('card_number')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage("Card Number is required"),
|
||||
.withMessage('Card Number is required'),
|
||||
];
|
||||
|
||||
default:
|
||||
@@ -32,33 +32,38 @@ const validate = (method) => {
|
||||
}
|
||||
};
|
||||
|
||||
// HISTORY FROM CARD
|
||||
// ================================================================= HISTORY FROM CARD =================================================================
|
||||
// *Created By: Mohamad Ihsan*
|
||||
// *Description:*
|
||||
// proses yang digunakan untuk menampilkan history kartu berdasrkan data / content yang tersimpan di dalam kartu
|
||||
|
||||
const cardHistory = async (req, res) => {
|
||||
try {
|
||||
// generate unique code
|
||||
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
||||
let uniqueCode = await helper.getUniqueCode();
|
||||
let result = {};
|
||||
let result = [];
|
||||
|
||||
// param
|
||||
let { data } = req.body;
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} REQUEST card history: ${JSON.stringify(req.body)}`
|
||||
`${uniqueCode} [ REQUEST CARD-HISTORY ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// check validator
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
result = {
|
||||
code: "400",
|
||||
code: '400',
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
data: [],
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE card history: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE CARD-HISTORY ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
@@ -76,44 +81,66 @@ const cardHistory = async (req, res) => {
|
||||
let indexHistory = 0;
|
||||
let checkReskaFormat;
|
||||
let checkKCIFormat;
|
||||
|
||||
// lakukan perulangan data array yang dikirim dari client
|
||||
for (let index = 0; index < data.length; index++) {
|
||||
element = data[index];
|
||||
|
||||
if (element != "00000000000000000000000000000000") {
|
||||
if (element != '00000000000000000000000000000000') {
|
||||
date = moment(
|
||||
new Date((parseInt(element.slice(0, 8), 16) + 946684800) * 1000)
|
||||
).format("YYYY-MM-DD HH:mm:ss");
|
||||
).format('YYYY-MM-DD HH:mm:ss');
|
||||
nominal = parseInt(element.slice(8, 16), 16);
|
||||
mid = element.slice(16, 20);
|
||||
tid = element.slice(20, 24);
|
||||
|
||||
// blok yang menandakan konten untuk reska
|
||||
checkReskaFormat = element.slice(14, 20);
|
||||
|
||||
// blok yang menandakan konten untuk KCI
|
||||
checkKCIFormat = element.slice(26, 28);
|
||||
|
||||
if (checkReskaFormat == "000000") {
|
||||
istopup = "Deduct";
|
||||
// jika blok untuk reska itu 000000 maka state bahwa itu transaki deduct dari sistem reska
|
||||
if (checkReskaFormat == '000000') {
|
||||
istopup = 'Deduct';
|
||||
|
||||
// get nominal dari blok konten yang dikirim
|
||||
nominal = parseInt(element.slice(20, 24), 16);
|
||||
|
||||
date = element.slice(4, 8) + '-' + element.slice(2, 4) + '-' + element.slice(0, 2) + ' ' + element.slice(8, 10) + ':' + element.slice(10, 12) + ':' + element.slice(12, 14);
|
||||
// get date dari blok konten yang dikirim
|
||||
date =
|
||||
element.slice(4, 8) +
|
||||
'-' +
|
||||
element.slice(2, 4) +
|
||||
'-' +
|
||||
element.slice(0, 2) +
|
||||
' ' +
|
||||
element.slice(8, 10) +
|
||||
':' +
|
||||
element.slice(10, 12) +
|
||||
':' +
|
||||
element.slice(12, 14);
|
||||
|
||||
// get terminal name
|
||||
terminalName = "PARKIR RESKA";
|
||||
console.log('HAHAHHAHAHAHHAHAHAHAHAHHA');
|
||||
} else if (checkKCIFormat == "00") {
|
||||
terminalName = 'PARKIR RESKA';
|
||||
} else if (checkKCIFormat == '00') {
|
||||
// jika blok untuk KCI itu 00 maka state bahwa itu transaksi dari sistem KCI
|
||||
// ambil konten di blok ke 25 dan 26, jika konten nya == 0 maka itu transaksi topup, dan jika bukan 0 maka itu transaksi deduct
|
||||
istopup =
|
||||
parseInt(element.slice(24, 26), 16) == 0 ? "Topup" : "Deduct";
|
||||
parseInt(element.slice(24, 26), 16) == 0 ? 'Topup' : 'Deduct';
|
||||
|
||||
// get terminal name
|
||||
terminalName = await model.getTerminalKCIExisting(mid);
|
||||
terminalName = terminalName ? terminalName.merchant_name : "";
|
||||
terminalName = terminalName ? terminalName.merchant_name : '';
|
||||
} else {
|
||||
// jika bukan blok reska dan KCI maka cek dari tid mid dari sistem CMS
|
||||
// ambil konten di blok ke 25 dan 26, jika konten nya == 0 maka itu transaksi topup, dan jika bukan 0 maka itu transaksi deduct
|
||||
istopup =
|
||||
parseInt(element.slice(24, 26), 16) == 0 ? "Topup" : "Deduct";
|
||||
parseInt(element.slice(24, 26), 16) == 0 ? 'Topup' : 'Deduct';
|
||||
|
||||
// get terminal name
|
||||
terminalName = await model.getPartnerPartialMIDTID(mid, tid);
|
||||
terminalName = terminalName ? terminalName.merchant_name : "";
|
||||
terminalName = terminalName ? terminalName.merchant_name : '';
|
||||
}
|
||||
|
||||
history[indexHistory] = {
|
||||
@@ -128,74 +155,132 @@ const cardHistory = async (req, res) => {
|
||||
}
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "success",
|
||||
code: '00',
|
||||
message: 'success',
|
||||
data: history,
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} RESPONSE card history: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE CARD-HISTORY ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
`[ RESPONSE CARD-HISTORY ]: 500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: "500",
|
||||
code: '500',
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
: '500 internal server error - backend server.',
|
||||
data: [],
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// HISTORY FROM CMS
|
||||
// ================================================================= HISTORY FROM CMS =================================================================
|
||||
// *Created By: Mohamad Ihsan*
|
||||
// *Description:*
|
||||
// proses yang digunakan untuk menampilkan history kartu berdasrkan log di sistem CMS
|
||||
|
||||
const history = async (req, res) => {
|
||||
try {
|
||||
// check validator
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
return res.status(200).json({
|
||||
code: "400",
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
// generate unique code
|
||||
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
||||
let uniqueCode = await helper.getUniqueCode();
|
||||
let result = {};
|
||||
|
||||
// param
|
||||
let { mid, tid, card_number, start_date, end_date } = req.body;
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ REQUEST CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
|
||||
// check validator
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
result = {
|
||||
code: '400',
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// time
|
||||
let now = moment().format("YYYY-MM-DD HH:mm:ss");
|
||||
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING CARD-HISTORY-FROM-CMS ]: checking parameter start date and end date...`
|
||||
);
|
||||
|
||||
// validation inquiry date
|
||||
if ((!start_date && end_date) || (start_date && !end_date)) {
|
||||
return res.status(200).json({
|
||||
code: "400",
|
||||
message: "bad request. please check the date!",
|
||||
result = {
|
||||
code: '400',
|
||||
message: 'bad request. please check the date!',
|
||||
data: {},
|
||||
});
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING CARD-HISTORY-FROM-CMS ]: checking mid and tid is valid or not...`
|
||||
);
|
||||
|
||||
// get partner, merchant, terminal from tid
|
||||
let getPartner = await model.getPartner(mid, tid);
|
||||
if (!getPartner) {
|
||||
return res.status(200).json({
|
||||
code: "412",
|
||||
message: "terminal id is not valid",
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'terminal id is not valid',
|
||||
data: {},
|
||||
});
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// card history and load balance transaction
|
||||
let result = await model.historyByCardNumber(
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING CARD-HISTORY-FROM-CMS ]: getting history card from log CMS...`
|
||||
);
|
||||
|
||||
// get data history kartu di log sistem CMS
|
||||
let history = await model.historyByCardNumber(
|
||||
mid,
|
||||
tid,
|
||||
card_number,
|
||||
@@ -203,26 +288,50 @@ const history = async (req, res) => {
|
||||
end_date
|
||||
);
|
||||
|
||||
if (!result) {
|
||||
return res.status(200).json({
|
||||
code: "422",
|
||||
// jika history tidak ditemukan di log sistem CMS
|
||||
if (!history) {
|
||||
result = {
|
||||
code: '422',
|
||||
message: "history doesn't exist",
|
||||
data: [],
|
||||
});
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
return res.json({
|
||||
code: "00",
|
||||
message: "history has been found.",
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'history has been found.',
|
||||
data: result,
|
||||
});
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.json(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE CARD-HISTORY-FROM-CMS ]: 500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: "500",
|
||||
code: '500',
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
const helper = require("../../helpers/helper");
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const helper = require('../../helpers/helper');
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require("dotenv").config();
|
||||
require('dotenv').config();
|
||||
|
||||
let useClient;
|
||||
var counterDirect = 0;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -31,11 +31,11 @@ const controller = async (req, res) => {
|
||||
let { body } = req;
|
||||
// uniqueCode = body.unique_code;
|
||||
let uniqueCode = await helper.getUniqueCode();
|
||||
uniqueCode = uniqueCode+''+counterDirect;
|
||||
uniqueCode = uniqueCode + '' + counterDirect;
|
||||
let result = {};
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -74,11 +74,15 @@ const controller = async (req, res) => {
|
||||
}
|
||||
|
||||
// log info
|
||||
winston.logger.info(`${uniqueCode} REQUEST load balance - STARTING...`);
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-1 ]: STARTING TOP UP...`
|
||||
);
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} request HSM - auth1v2: ${JSON.stringify(req.body)}`
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-1 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
|
||||
let felicaPollingResponse = Buffer.from(
|
||||
@@ -107,7 +111,7 @@ const controller = async (req, res) => {
|
||||
_timeOut = true;
|
||||
}, 10000);
|
||||
|
||||
useClient.ws.on("message", (message) => {
|
||||
useClient.ws.on('message', (message) => {
|
||||
let __validasi = generate.buf2hex(message).slice(14, 30);
|
||||
while (
|
||||
message[2] == 1 &&
|
||||
@@ -119,7 +123,9 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - message Auth1v2: ${generate.buf2hex(message)}`
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-1 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
|
||||
respData = message;
|
||||
@@ -155,8 +161,8 @@ const controller = async (req, res) => {
|
||||
|
||||
if (respData1) {
|
||||
result = {
|
||||
code: "00",
|
||||
message: "Request Authenticate 1 Success",
|
||||
code: '00',
|
||||
message: 'Request Authenticate 1 Success',
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -167,8 +173,8 @@ const controller = async (req, res) => {
|
||||
};
|
||||
} else {
|
||||
result = {
|
||||
code: "5004",
|
||||
message: "Empty Data from HSM",
|
||||
code: '5004',
|
||||
message: 'Empty Data from HSM',
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -181,22 +187,24 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} response HSM - auth1v2: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-1 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-1 ]: 500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: "5001",
|
||||
code: '5001',
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require("dotenv").config();
|
||||
require('dotenv').config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -27,11 +27,13 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} request HSM - auth2v2: ${JSON.stringify(req.body)}`
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-2 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -60,14 +62,16 @@ const controller = async (req, res) => {
|
||||
|
||||
if (auth2v2requestData[0] != 0x41) {
|
||||
result = {
|
||||
code: "5003",
|
||||
message: "Wrong Respone from Card",
|
||||
code: '5003',
|
||||
message: 'Wrong Respone from Card',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} response HSM - auth2v2: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-2 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
@@ -84,7 +88,7 @@ const controller = async (req, res) => {
|
||||
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
useClient.ws.on("message", (message) => {
|
||||
useClient.ws.on('message', (message) => {
|
||||
while (
|
||||
message[2] == 2 &&
|
||||
message[0] == _validationTrxID[0] &&
|
||||
@@ -96,7 +100,9 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - message Auth2v2: ${generate.buf2hex(message)}`
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-2 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
|
||||
respData = message;
|
||||
@@ -116,8 +122,8 @@ const controller = async (req, res) => {
|
||||
respData1 = generate.getResponseData(respData);
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "Request Authenticate 2 Success",
|
||||
code: '00',
|
||||
message: 'Request Authenticate 2 Success',
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -128,22 +134,24 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} response HSM - auth2v2: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-2 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-2 ]: 500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: "5001",
|
||||
code: '5001',
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require("dotenv").config();
|
||||
require('dotenv').config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -27,11 +27,13 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} request auth2v2 Resp: ${JSON.stringify(req.body)}`
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-3 ]: request to HSM ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -62,14 +64,16 @@ const controller = async (req, res) => {
|
||||
|
||||
if (auth2v2responseSetData[0] != 0x43) {
|
||||
result = {
|
||||
code: "5003",
|
||||
message: "Wrong Respone from Card",
|
||||
code: '5003',
|
||||
message: 'Wrong Respone from Card',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} response HSM - auth2v2 resp: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-3 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
@@ -87,7 +91,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on("message", (message) => {
|
||||
useClient.ws.on('message', (message) => {
|
||||
while (
|
||||
message[2] == 3 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -99,7 +103,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - message auth2v2 Resp: ${generate.buf2hex(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-3 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
@@ -121,8 +125,8 @@ const controller = async (req, res) => {
|
||||
respData1 = generate.getResponseData(respData);
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "Request Authenticate Resp Success",
|
||||
code: '00',
|
||||
message: 'Request Authenticate Resp Success',
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -133,22 +137,24 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} response HSM - auth2v2 resp: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-3 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-3 ]: 500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: "5001",
|
||||
code: '5001',
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require("dotenv").config();
|
||||
require('dotenv').config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -27,11 +27,13 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} request HSM - end transaction: ${JSON.stringify(req.body)}`
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-8 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -70,7 +72,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on("message", (message) => {
|
||||
useClient.ws.on('message', (message) => {
|
||||
while (
|
||||
message[2] == 6 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -82,7 +84,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - message end transaction: ${generate.buf2hex(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-8 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
@@ -104,35 +106,34 @@ const controller = async (req, res) => {
|
||||
respData1 = generate.getResponseData(respData);
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "End Transaction Success",
|
||||
code: '00',
|
||||
message: 'End Transaction Success',
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
},
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(`${uniqueCode} RESPONSE load balance - END...`);
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} response HSM - end transaction: ${JSON.stringify(result)}`
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-8 ]: ENDING TOP UP... ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-8 ]: 500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: "5001",
|
||||
code: '5001',
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require("dotenv").config();
|
||||
require('dotenv').config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -27,11 +27,13 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} request HSM - read data: ${JSON.stringify(req.body)}`
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-4 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -70,7 +72,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on("message", (message) => {
|
||||
useClient.ws.on('message', (message) => {
|
||||
while (
|
||||
message[2] == 4 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -84,7 +86,9 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - message read data: ${generate.buf2hex(message)}`
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-4 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
|
||||
respData = message;
|
||||
@@ -104,8 +108,8 @@ const controller = async (req, res) => {
|
||||
respData1 = generate.getResponseData(respData);
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "Read Succeess",
|
||||
code: '00',
|
||||
message: 'Read Succeess',
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -116,22 +120,24 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} response HSM - read data: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-4 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-4 ]: 500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: "5001",
|
||||
code: '5001',
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require("dotenv").config();
|
||||
require('dotenv').config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -27,11 +27,13 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} request HSM - read data resp: ${JSON.stringify(req.body)}`
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-5 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -58,14 +60,16 @@ const controller = async (req, res) => {
|
||||
let _stopMessage = 1;
|
||||
if (packet[0] != 0x45) {
|
||||
result = {
|
||||
code: "03",
|
||||
message: "Respone Card Wrong",
|
||||
code: '03',
|
||||
message: 'Respone Card Wrong',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} response HSM - read data resp: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-5 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
@@ -79,7 +83,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on("message", (message) => {
|
||||
useClient.ws.on('message', (message) => {
|
||||
while (
|
||||
message[2] == 5 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -93,7 +97,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - message read data resp: ${generate.buf2hex(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-5 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
@@ -115,8 +119,8 @@ const controller = async (req, res) => {
|
||||
respData1 = generate.getResponseData(respData);
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "Read Succeess",
|
||||
code: '00',
|
||||
message: 'Read Succeess',
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -127,22 +131,24 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} response HSM - read data resp: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-5 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-5 ]: 500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: "5001",
|
||||
code: '5001',
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,6 +98,13 @@ const controller = async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-6 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
|
||||
// check validator
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -109,17 +116,14 @@ const controller = async (req, res) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} response HSM - write topup: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-6 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} request HSM - write topup: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
let transactionId = Buffer.from(generate.hexToBytes(trxID));
|
||||
let trxrequestData = Buffer.from(generate.hexToBytes(requestData));
|
||||
let _stopMessage = 1;
|
||||
@@ -159,7 +163,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - message write topup: ${generate.buf2hex(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-6 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
@@ -182,7 +186,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - inserting load balance transaction...`
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-6 ]: inserting load balance transaction...`
|
||||
);
|
||||
|
||||
let data = {
|
||||
@@ -232,14 +236,16 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} response HSM - write topup: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-6 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-6 ]: 500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
const { param, body, validationResult } = require("express-validator");
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const loadBalance = require("../loadbalance/loadbalance.controller");
|
||||
const { param, body, validationResult } = require('express-validator');
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const loadBalance = require('../loadbalance/loadbalance.controller');
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require("dotenv").config();
|
||||
require('dotenv').config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
}
|
||||
|
||||
// VALIDATION
|
||||
const validate = (method) => {
|
||||
switch (method) {
|
||||
case "topupResponse":
|
||||
case 'topupResponse':
|
||||
return [
|
||||
body("mid").not().isEmpty().withMessage("MID is required"),
|
||||
body("tid").not().isEmpty().withMessage("TID is required"),
|
||||
body("uid").not().isEmpty().withMessage("UID is required"),
|
||||
body("flag").not().isEmpty().withMessage("Flag is required"),
|
||||
body("card_number")
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
body('uid').not().isEmpty().withMessage('UID is required'),
|
||||
body('flag').not().isEmpty().withMessage('Flag is required'),
|
||||
body('card_number')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage("Card Number is required"),
|
||||
body("amount")
|
||||
.withMessage('Card Number is required'),
|
||||
body('amount')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage("Amount is required")
|
||||
.withMessage('Amount is required')
|
||||
.isNumeric()
|
||||
.withMessage("Amount is invalid format"),
|
||||
body("reservation_number")
|
||||
.withMessage('Amount is invalid format'),
|
||||
body('reservation_number')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage("Reservation Number is required")
|
||||
.withMessage('Reservation Number is required')
|
||||
.isArray()
|
||||
.withMessage("Reservation Number is invalid request format"),
|
||||
body("load_balance_number")
|
||||
.withMessage('Reservation Number is invalid request format'),
|
||||
body('load_balance_number')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage("Load Balance Number is required"),
|
||||
.withMessage('Load Balance Number is required'),
|
||||
];
|
||||
default:
|
||||
break;
|
||||
@@ -79,7 +79,7 @@ const controller = async (req, res) => {
|
||||
let result = {};
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -111,7 +111,9 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} request HSM - topup resp: ${JSON.stringify(req.body)}`
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-7 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
|
||||
let transactionId = Buffer.from(generate.hexToBytes(trxID));
|
||||
@@ -119,14 +121,16 @@ const controller = async (req, res) => {
|
||||
let _stopMessage = 1;
|
||||
if (packet[0] != 0x47) {
|
||||
result = {
|
||||
code: "03",
|
||||
message: "Respone Card Wrong",
|
||||
code: '03',
|
||||
message: 'Respone Card Wrong',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} response HSM - topup resp: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-7 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
@@ -140,7 +144,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on("message", (message) => {
|
||||
useClient.ws.on('message', (message) => {
|
||||
while (
|
||||
message[2] == 5 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -154,7 +158,9 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - message topup resp: ${generate.buf2hex(message)}`
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-7 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
|
||||
respData = message;
|
||||
@@ -186,7 +192,7 @@ const controller = async (req, res) => {
|
||||
amount: amount,
|
||||
reservation_number: reservation_number,
|
||||
ref_no: ref_no,
|
||||
write_status: "FW",
|
||||
write_status: 'FW',
|
||||
uid: uid,
|
||||
balance: parseInt(balance) + parseInt(amount),
|
||||
flag: parseInt(flag),
|
||||
@@ -196,15 +202,15 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - updating load balance transaction...`
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-7 ]: updating load balance transaction is FW...`
|
||||
);
|
||||
|
||||
// update data load balance
|
||||
await loadBalance.loadingBalanceUpdate(data);
|
||||
|
||||
result = {
|
||||
code: "5002",
|
||||
message: "failed from HSM",
|
||||
code: '5002',
|
||||
message: 'failed from HSM',
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respData1.slice(6, 10),
|
||||
@@ -213,6 +219,11 @@ const controller = async (req, res) => {
|
||||
},
|
||||
};
|
||||
} else {
|
||||
// jika sudah mencapai maksimum counting flag, maka reset flag ke awal
|
||||
if (flag >= 255) {
|
||||
flag = -1;
|
||||
}
|
||||
|
||||
data = {
|
||||
mid: mid,
|
||||
tid: tid,
|
||||
@@ -230,16 +241,16 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - updating load balance transaction...`
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-7 ]: updating load balance transaction...`
|
||||
);
|
||||
|
||||
// update data load balance
|
||||
let update = await loadBalance.loadingBalanceUpdate(data);
|
||||
if (update) {
|
||||
if (update.code == "00") {
|
||||
if (update.code == '00') {
|
||||
result = {
|
||||
code: "00",
|
||||
message: "Topup Succeess",
|
||||
code: '00',
|
||||
message: 'Topup Succeess',
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -257,8 +268,8 @@ const controller = async (req, res) => {
|
||||
}
|
||||
} else {
|
||||
result = {
|
||||
code: "423",
|
||||
message: "update/insert failed",
|
||||
code: '423',
|
||||
message: 'update/insert failed',
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
@@ -266,22 +277,24 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} HSM - message topup resp: ${JSON.stringify(result)}`
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-7 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-7 ]: 500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: "5001",
|
||||
code: '5001',
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,23 @@
|
||||
const knex = require("../../../infrastructure/database/knex");
|
||||
const knex = require('../../../infrastructure/database/knex');
|
||||
|
||||
// CHECK CARD NUMBER
|
||||
const checkCardNumber = (cardNumber) => {
|
||||
let result = knex("t_m_card_product")
|
||||
.where("c_card_number", cardNumber)
|
||||
.where("c_status", "!=", "X")
|
||||
let result = knex('t_m_card_product')
|
||||
.where('c_card_number', cardNumber)
|
||||
.where('c_status', '!=', 'X')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET RESERVATION
|
||||
const getReservationNumberSequence = (data, date) => {
|
||||
console.log('AKU DIPANGGIL');
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.select("i_reservation_no_seq")
|
||||
.orderBy("i_reservation_no_seq", "desc")
|
||||
.whereNotNull("i_reservation_no_seq")
|
||||
.where("i_partner", data.i_partner)
|
||||
.where("i_merchant", data.i_merchant)
|
||||
.whereRaw("??::date = ?", ["d_reservation", date])
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.select('i_reservation_no_seq')
|
||||
.orderBy('i_reservation_no_seq', 'desc')
|
||||
.whereNotNull('i_reservation_no_seq')
|
||||
.where('i_partner', data.i_partner)
|
||||
.where('i_merchant', data.i_merchant)
|
||||
.whereRaw('??::date = ?', ['d_reservation', date])
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
@@ -27,236 +26,310 @@ const getReservationNumberSequence = (data, date) => {
|
||||
const getPartner = (mid, tid) => {
|
||||
let result = knex
|
||||
.select(
|
||||
"t_m_partner.i_partner",
|
||||
"t_m_partner.c_code as partner_code",
|
||||
"t_m_partner.c_name as partner_name",
|
||||
"t_m_merchant.i_merchant",
|
||||
"t_m_merchant.c_code as merchant_code",
|
||||
"t_m_merchant.c_name as merchant_name",
|
||||
"t_m_merchant.e_mid as mid",
|
||||
"t_m_terminal.i_terminal",
|
||||
"t_m_terminal.c_code as terminal_code",
|
||||
"t_m_terminal.c_name as terminal_name",
|
||||
"t_m_terminal.e_tid as tid"
|
||||
't_m_partner.i_partner',
|
||||
't_m_partner.c_code as partner_code',
|
||||
't_m_partner.c_name as partner_name',
|
||||
't_m_merchant.i_merchant',
|
||||
't_m_merchant.c_code as merchant_code',
|
||||
't_m_merchant.c_name as merchant_name',
|
||||
't_m_merchant.e_mid as mid',
|
||||
't_m_terminal.i_terminal',
|
||||
't_m_terminal.c_code as terminal_code',
|
||||
't_m_terminal.c_name as terminal_name',
|
||||
't_m_terminal.e_tid as tid'
|
||||
)
|
||||
.from("t_m_terminal")
|
||||
.from('t_m_terminal')
|
||||
.leftJoin(
|
||||
"t_m_merchant",
|
||||
"t_m_terminal.i_merchant",
|
||||
"t_m_merchant.i_merchant"
|
||||
't_m_merchant',
|
||||
't_m_terminal.i_merchant',
|
||||
't_m_merchant.i_merchant'
|
||||
)
|
||||
.leftJoin("t_m_partner", "t_m_merchant.i_partner", "t_m_partner.i_partner")
|
||||
.where("t_m_merchant.e_mid", mid)
|
||||
.where("t_m_terminal.e_tid", tid)
|
||||
.where("t_m_terminal.c_status", "A")
|
||||
.where("t_m_merchant.c_status", "A")
|
||||
.where("t_m_partner.c_status", "A")
|
||||
.leftJoin('t_m_partner', 't_m_merchant.i_partner', 't_m_partner.i_partner')
|
||||
.where('t_m_merchant.e_mid', mid)
|
||||
.where('t_m_terminal.e_tid', tid)
|
||||
.where('t_m_terminal.c_status', 'A')
|
||||
.where('t_m_merchant.c_status', 'A')
|
||||
.where('t_m_partner.c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET ISSUER FEE
|
||||
const getIssuer = (id, time) => {
|
||||
let result = knex("t_c_partner_fee")
|
||||
.select("i_issuer_fee_perc", "i_channel_fee_perc", "i_amount")
|
||||
.where("i_partner", id)
|
||||
.where("c_status", "A")
|
||||
.where("d_valid", "<=", time)
|
||||
.orderBy("d_valid", "desc")
|
||||
let result = knex('t_c_partner_fee')
|
||||
.select('i_issuer_fee_perc', 'i_channel_fee_perc', 'i_amount')
|
||||
.where('i_partner', id)
|
||||
.where('c_status', 'A')
|
||||
.where('d_valid', '<=', time)
|
||||
.orderBy('d_valid', 'desc')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET RESERVATION EXPIRATION DATE FROM GLOBAL PARAMETER
|
||||
const getReservationExpirationDateValue = () => {
|
||||
let result = knex("t_m_global_parameter")
|
||||
.select("c_value")
|
||||
.where("c_code", "HSM_EXP_RSV_VAL")
|
||||
.where("c_status", "A")
|
||||
let result = knex('t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', 'HSM_EXP_RSV_VAL')
|
||||
.where('c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET RESERVATION EXPIRATION DATE MEASURE FROM GLOBAL PARAMETER
|
||||
const getReservationExpirationDateMeasure = () => {
|
||||
let result = knex("t_m_global_parameter")
|
||||
.select("c_value")
|
||||
.where("c_code", "HSM_EXP_RSV_MEA")
|
||||
.where("c_status", "A")
|
||||
let result = knex('t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', 'HSM_EXP_RSV_MEA')
|
||||
.where('c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET CHECKING CARD PRODUCT FROM GLOBAL PARAMETER
|
||||
const getCheckByCardProductStatusValue = () => {
|
||||
let result = knex("t_m_global_parameter")
|
||||
.select("c_value")
|
||||
.where("c_code", "HSM_CHECK_BY_CARD_PRODUCT_STAT")
|
||||
.where("c_status", "A")
|
||||
let result = knex('t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', 'HSM_CHECK_BY_CARD_PRODUCT_STAT')
|
||||
.where('c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET BI REGULATION STATUS FROM GLOBAL PARAMETER
|
||||
const getBIRegulationStatus = () => {
|
||||
let result = knex("t_m_global_parameter")
|
||||
.select("c_value")
|
||||
.where("c_code", "HSM_BI_REGULATION_STAT")
|
||||
.where("c_status", "A")
|
||||
let result = knex('t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', 'HSM_BI_REGULATION_STAT')
|
||||
.where('c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET MAX AMOUNT ON THE CARD FROM GLOBAL PARAMETER
|
||||
const getMaxAmountOnTheCard = () => {
|
||||
let result = knex("t_m_global_parameter")
|
||||
.select("c_value")
|
||||
.where("c_code", "HSM_BI_MAX_AMOUNT_ON_THE_CARD")
|
||||
.where("c_status", "A")
|
||||
let result = knex('t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', 'HSM_BI_MAX_AMOUNT_ON_THE_CARD')
|
||||
.where('c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET MAX TOPUP PER MONTH FROM GLOBAL PARAMETER
|
||||
const getMaxTopupPerMonth = () => {
|
||||
let result = knex("t_m_global_parameter")
|
||||
.select("c_value")
|
||||
.where("c_code", "HSM_BI_MAX_TOPUP_PER_MONTH")
|
||||
.where("c_status", "A")
|
||||
let result = knex('t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', 'HSM_BI_MAX_TOPUP_PER_MONTH')
|
||||
.where('c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET MAX RESERVATION FROM GLOBAL PARAMETER
|
||||
const getMaxReservation = () => {
|
||||
let result = knex("t_m_global_parameter")
|
||||
.select("c_value")
|
||||
.where("c_code", "HSM_MAX_RSV_PEN")
|
||||
.where("c_status", "A")
|
||||
let result = knex('t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', 'HSM_MAX_RSV_PEN')
|
||||
.where('c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// INQUIRY BY RESERVATION NUMBER
|
||||
let inquiryByReservationNumber = (reservationNumber) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.select(
|
||||
"c_reservation_no as reservation_number",
|
||||
"d_reservation as reservation_date",
|
||||
"c_ref_no as ref_no",
|
||||
"c_partner_name as partner_name",
|
||||
"c_merchant_name as merchant_name",
|
||||
"c_terminal_name as terminal_name",
|
||||
"c_card_number as card_number",
|
||||
"i_reservation_amount as reservation_amount",
|
||||
"i_issuer_fee as issuer_fee",
|
||||
"i_channel_fee as channel_fee",
|
||||
"c_payment_recon_no as payment_recon_no",
|
||||
"d_payment_recon as recon_date",
|
||||
"c_status as status_code",
|
||||
"c_status_name as description"
|
||||
)
|
||||
.where("c_reservation_no", reservationNumber)
|
||||
let inquiryByReservationNumber = (reservationNumber, show_complete_data) => {
|
||||
let result = knex('trx.t_d_reservation_balance');
|
||||
if (show_complete_data === true) {
|
||||
result.select(
|
||||
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||
'trx.t_d_reservation_balance.c_merchant_name as merchant_name_reservation',
|
||||
'trx.t_d_reservation_balance.c_terminal_name as terminal_name_reservation',
|
||||
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||
'trx.t_d_load_balance.c_merchant_name as merchant_name_load',
|
||||
'trx.t_d_load_balance.c_terminal_name as terminal_name_load',
|
||||
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||
'trx.t_d_reservation_balance.i_issuer_fee as issuer_fee',
|
||||
'trx.t_d_reservation_balance.i_channel_fee as channel_fee',
|
||||
'trx.t_d_reservation_balance.c_payment_recon_no as payment_recon_no',
|
||||
'trx.t_d_reservation_balance.d_payment_recon as recon_date',
|
||||
'trx.t_d_reservation_balance.c_status as status_code',
|
||||
'trx.t_d_reservation_balance.c_status_name as description'
|
||||
);
|
||||
} else {
|
||||
result.select(
|
||||
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||
'trx.t_d_reservation_balance.c_status as status_code',
|
||||
'trx.t_d_reservation_balance.c_status_name as description'
|
||||
);
|
||||
}
|
||||
|
||||
result.leftJoin('trx.t_d_load_balance', function () {
|
||||
this.on(
|
||||
'trx.t_d_reservation_balance.c_load_balance_no',
|
||||
'=',
|
||||
'trx.t_d_load_balance.c_load_balance_no'
|
||||
);
|
||||
});
|
||||
|
||||
result
|
||||
.where('trx.t_d_reservation_balance.c_reservation_no', reservationNumber)
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// INQUIRY LIST RESERVATION
|
||||
let inquiryListReservation = (partnerID, startDate, endDate) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.select(
|
||||
"c_reservation_no as reservation_number",
|
||||
"d_reservation as reservation_date",
|
||||
"c_ref_no as ref_no",
|
||||
"c_partner_name as partner_name",
|
||||
"c_merchant_name as merchant_name",
|
||||
"c_terminal_name as terminal_name",
|
||||
"c_card_number as card_number",
|
||||
"i_reservation_amount as reservation_amount",
|
||||
"i_issuer_fee as issuer_fee",
|
||||
"i_channel_fee as channel_fee",
|
||||
"c_payment_recon_no as payment_recon_no",
|
||||
"d_payment_recon as recon_date",
|
||||
"c_status as status_code",
|
||||
"c_status_name as description"
|
||||
)
|
||||
.where("i_partner", partnerID);
|
||||
|
||||
if (startDate && endDate) {
|
||||
result.whereRaw("??::date >= ?", ["d_reservation", startDate]);
|
||||
result.whereRaw("??::date <= ?", ["d_reservation", endDate]);
|
||||
}
|
||||
let result = knex('trx.t_d_reservation_balance');
|
||||
result.select(
|
||||
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||
'trx.t_d_reservation_balance.c_merchant_name as merchant_name_reservation',
|
||||
'trx.t_d_reservation_balance.c_terminal_name as terminal_name_reservation',
|
||||
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||
'trx.t_d_load_balance.c_merchant_name as merchant_name_load',
|
||||
'trx.t_d_load_balance.c_terminal_name as terminal_name_load',
|
||||
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||
'trx.t_d_reservation_balance.i_issuer_fee as issuer_fee',
|
||||
'trx.t_d_reservation_balance.i_channel_fee as channel_fee',
|
||||
'trx.t_d_reservation_balance.c_payment_recon_no as payment_recon_no',
|
||||
'trx.t_d_reservation_balance.d_payment_recon as recon_date',
|
||||
'trx.t_d_reservation_balance.c_status as status_code',
|
||||
'trx.t_d_reservation_balance.c_status_name as description'
|
||||
);
|
||||
|
||||
result.leftJoin('trx.t_d_load_balance', function () {
|
||||
this.on(
|
||||
'trx.t_d_reservation_balance.c_load_balance_no',
|
||||
'=',
|
||||
'trx.t_d_load_balance.c_load_balance_no'
|
||||
);
|
||||
});
|
||||
|
||||
result.where('trx.t_d_reservation_balance.i_partner', partnerID);
|
||||
|
||||
if (startDate && endDate) {
|
||||
result.whereRaw('??::date >= ?', [
|
||||
'trx.t_d_reservation_balance.d_reservation',
|
||||
startDate,
|
||||
]);
|
||||
result.whereRaw('??::date <= ?', [
|
||||
'trx.t_d_reservation_balance.d_reservation',
|
||||
endDate,
|
||||
]);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// INQUIRY BY CARD NUMBER
|
||||
let inquiryByCardNumber = (cardNumber, startDate, endDate) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.select(
|
||||
"c_reservation_no as reservation_number",
|
||||
"d_reservation as reservation_date",
|
||||
"c_ref_no as ref_no",
|
||||
"c_partner_name as partner_name",
|
||||
"c_merchant_name as merchant_name",
|
||||
"c_terminal_name as terminal_name",
|
||||
"c_card_number as card_number",
|
||||
"i_reservation_amount as reservation_amount",
|
||||
"i_issuer_fee as issuer_fee",
|
||||
"i_channel_fee as channel_fee",
|
||||
"c_status as status_code",
|
||||
"c_status_name as description"
|
||||
'c_reservation_no as reservation_number',
|
||||
'd_reservation as reservation_date',
|
||||
'c_ref_no as ref_no',
|
||||
'c_partner_name as partner_name',
|
||||
'c_merchant_name as merchant_name',
|
||||
'c_terminal_name as terminal_name',
|
||||
'c_card_number as card_number',
|
||||
'i_reservation_amount as amount',
|
||||
'i_issuer_fee as issuer_fee',
|
||||
'i_channel_fee as channel_fee',
|
||||
'c_status as status_code',
|
||||
'c_status_name as description'
|
||||
)
|
||||
.where("c_card_number", cardNumber);
|
||||
.where('c_card_number', cardNumber);
|
||||
|
||||
if (startDate && endDate) {
|
||||
result.whereRaw("??::date >= ?", ["d_reservation", startDate]);
|
||||
result.whereRaw("??::date <= ?", ["d_reservation", endDate]);
|
||||
result.whereRaw('??::date >= ?', ['d_reservation', startDate]);
|
||||
result.whereRaw('??::date <= ?', ['d_reservation', endDate]);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET RESERVATION PENDING
|
||||
const getReservationPending = (cardNumber, time) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.count("* as total_reservation")
|
||||
.sum("i_reservation_amount as total_nominal_reservation")
|
||||
.where("c_card_number", cardNumber)
|
||||
.where("c_status", "P")
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.count('* as total_reservation')
|
||||
.sum('i_reservation_amount as total_nominal_reservation')
|
||||
.where('c_card_number', cardNumber)
|
||||
.where('c_status', 'P')
|
||||
.whereRaw(
|
||||
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
|
||||
)
|
||||
// .where("d_expired", ">=", time)
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
const getReservationPendingV2 = (cardNumber, time) => {
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
// .sum("i_reservation_amount as total_reservation_amount")
|
||||
// .count("* as total_reservation")
|
||||
.select(
|
||||
'i_reservation_amount',
|
||||
'c_reservation_no',
|
||||
'c_partner_name',
|
||||
'c_flag',
|
||||
'd_reservation',
|
||||
'c_ref_no',
|
||||
'c_card_number',
|
||||
'c_status'
|
||||
)
|
||||
.where('c_card_number', cardNumber)
|
||||
.where('c_status', 'P')
|
||||
.whereRaw(
|
||||
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
|
||||
);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET RESERVATION WITH FLAG
|
||||
const getReservationWithFlag = (cardNumber, time) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.count("* as total_reservation")
|
||||
.where("c_card_number", cardNumber)
|
||||
.whereIn("c_status", ["P", "I"])
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.count('* as total_reservation')
|
||||
.where('c_card_number', cardNumber)
|
||||
.whereIn('c_status', ['P', 'I'])
|
||||
// .where("d_expired", ">=", time)
|
||||
.whereNotNull("c_flag")
|
||||
.whereNotNull('c_flag')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// INSERT RESERVATION
|
||||
const insertReservation = (data) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.insert(data)
|
||||
.onConflict("c_ref_no")
|
||||
.onConflict('c_ref_no')
|
||||
.ignore();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET LAST BALANCE FROM CARD HISTORY
|
||||
const getLastBalanceFromCardHistory = (cardNumber) => {
|
||||
let result = knex("log.t_log_card")
|
||||
.select("m_balance_after")
|
||||
.where("c_card_number", cardNumber)
|
||||
.where("c_status", "S")
|
||||
.where("m_balance_after", ">", 0)
|
||||
.orderBy("d_log", "desc")
|
||||
let result = knex('log.t_log_card')
|
||||
.select('m_balance_after')
|
||||
.where('c_card_number', cardNumber)
|
||||
.where('c_status', 'S')
|
||||
.where('m_balance_after', '>', 0)
|
||||
.orderBy('d_log', 'desc')
|
||||
.limit(1)
|
||||
.first();
|
||||
return result;
|
||||
@@ -268,66 +341,194 @@ const getAccumulationBalanceInThisMonthFromCardHistory = (
|
||||
year,
|
||||
month
|
||||
) => {
|
||||
let result = knex("log.t_log_card")
|
||||
.sum("m_amount as accumulation_balance")
|
||||
.where("c_card_number", cardNumber)
|
||||
.where("c_status", "S")
|
||||
.where("m_balance_after", ">", 0)
|
||||
.whereRaw("DATE_PART('YEAR', ??) = ?", ["d_log", year])
|
||||
.whereRaw("DATE_PART('MONTH', ??) = ?", ["d_log", month])
|
||||
.whereIn("i_log_name", [21])
|
||||
.groupBy("c_card_number")
|
||||
let result = knex('log.t_log_card')
|
||||
.sum('m_amount as accumulation_balance')
|
||||
.where('c_card_number', cardNumber)
|
||||
.where('c_status', 'S')
|
||||
.where('m_balance_after', '>', 0)
|
||||
.whereRaw("DATE_PART('YEAR', ??) = ?", ['d_log', year])
|
||||
.whereRaw("DATE_PART('MONTH', ??) = ?", ['d_log', month])
|
||||
.whereIn('i_log_name', [21])
|
||||
.groupBy('c_card_number')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// CREATE LOG FOR CARD HISTORY
|
||||
const createReserveBalanceLog = (data) => {
|
||||
let result = knex("log.t_log_card").insert(data);
|
||||
let result = knex('log.t_log_card').insert(data);
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET RESERVATION PENDING AND IN PROGRESS
|
||||
const getReservationWithPendingAndInProgressStatus = (cardNumber) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.count("* as total_reservation_pending")
|
||||
.where("c_card_number", cardNumber)
|
||||
.whereIn("c_status", ["P", "I"])
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.count('* as total_reservation_pending')
|
||||
.where('c_card_number', cardNumber)
|
||||
.whereIn('c_status', ['P', 'I'])
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET RESERVATION PENDING AND NOT YET PAYMENT RECON
|
||||
const getReservationCanBeCanceled = (reservation_number) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.where("c_reservation_no", reservation_number)
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.where('c_reservation_no', reservation_number)
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET RESERVATION PENDING AND NOT YET PAYMENT RECON
|
||||
const getReservationCanBeCanceledByRefno = (ref_no) => {
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.where('c_ref_no', ref_no)
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
const insertReservationNumber = (reservationNumber) => {
|
||||
let result = knex("trx.t_d_reservation_no_validate")
|
||||
let result = knex('trx.t_d_reservation_no_validate')
|
||||
.insert({
|
||||
c_reservation_no: reservationNumber,
|
||||
})
|
||||
.onConflict("c_reservation_no")
|
||||
.onConflict('c_reservation_no')
|
||||
.ignore();
|
||||
return result;
|
||||
};
|
||||
|
||||
const cancelReservation = (data, reservationNumber) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.update(data)
|
||||
.where("c_reservation_no", reservationNumber);
|
||||
.where('c_reservation_no', reservationNumber);
|
||||
return result;
|
||||
};
|
||||
const deleteReservationNumberValidate = (reservationNumber) => {
|
||||
let result = knex("trx.t_d_reservation_no_validate")
|
||||
.where("c_reservation_no", reservationNumber)
|
||||
let result = knex('trx.t_d_reservation_no_validate')
|
||||
.where('c_reservation_no', reservationNumber)
|
||||
.del();
|
||||
return result;
|
||||
};
|
||||
|
||||
// INQUIRY BY REF NUMBER
|
||||
let inquiryListByRefNumber = (refNumber, show_complete_data) => {
|
||||
let result = knex('trx.t_d_reservation_balance');
|
||||
if (show_complete_data === true) {
|
||||
result.select(
|
||||
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||
'trx.t_d_reservation_balance.c_merchant_name as merchant_name_reservation',
|
||||
'trx.t_d_reservation_balance.c_terminal_name as terminal_name_reservation',
|
||||
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||
'trx.t_d_load_balance.c_merchant_name as merchant_name_load',
|
||||
'trx.t_d_load_balance.c_terminal_name as terminal_name_load',
|
||||
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||
'trx.t_d_reservation_balance.i_issuer_fee as issuer_fee',
|
||||
'trx.t_d_reservation_balance.i_channel_fee as channel_fee',
|
||||
'trx.t_d_reservation_balance.c_status as status_code',
|
||||
'trx.t_d_reservation_balance.c_status_name as description'
|
||||
);
|
||||
} else {
|
||||
result.select(
|
||||
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||
'trx.t_d_reservation_balance.c_status as status_code',
|
||||
'trx.t_d_reservation_balance.c_status_name as description'
|
||||
);
|
||||
}
|
||||
|
||||
result.leftJoin('trx.t_d_load_balance', function () {
|
||||
this.on(
|
||||
'trx.t_d_reservation_balance.c_load_balance_no',
|
||||
'=',
|
||||
'trx.t_d_load_balance.c_load_balance_no'
|
||||
);
|
||||
});
|
||||
|
||||
result.where('trx.t_d_reservation_balance.c_ref_no', refNumber).first();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// ================================================================= INQUIRY LOAD BALANCE =================================================================
|
||||
// *Created By: Teddy Setiawan*
|
||||
// *Description:*
|
||||
//
|
||||
|
||||
// INQUIRY BY LOAD BALANCE NUMBER
|
||||
const inquiryListByLoadNumber = (load_balance_number, show_complete_data) => {
|
||||
let result = knex('trx.t_d_reservation_balance');
|
||||
|
||||
if (show_complete_data === true) {
|
||||
result.select(
|
||||
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||
'trx.t_d_reservation_balance.c_merchant_name as merchant_name_reservation',
|
||||
'trx.t_d_reservation_balance.c_terminal_name as terminal_name_reservation',
|
||||
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||
'trx.t_d_load_balance.c_merchant_name as merchant_name_load',
|
||||
'trx.t_d_load_balance.c_terminal_name as terminal_name_load',
|
||||
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||
'trx.t_d_reservation_balance.i_issuer_fee as issuer_fee',
|
||||
'trx.t_d_reservation_balance.i_channel_fee as channel_fee',
|
||||
'trx.t_d_reservation_balance.c_payment_recon_no as payment_recon_no',
|
||||
'trx.t_d_reservation_balance.d_payment_recon as recon_date',
|
||||
'trx.t_d_reservation_balance.c_status as status_code',
|
||||
'trx.t_d_reservation_balance.c_status_name as description'
|
||||
);
|
||||
} else {
|
||||
result.select(
|
||||
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||
'trx.t_d_reservation_balance.c_status as status_code',
|
||||
'trx.t_d_reservation_balance.c_status_name as description'
|
||||
);
|
||||
}
|
||||
|
||||
result
|
||||
.leftJoin('trx.t_d_load_balance', function () {
|
||||
this.on(
|
||||
'trx.t_d_reservation_balance.c_load_balance_no',
|
||||
'=',
|
||||
'trx.t_d_load_balance.c_load_balance_no'
|
||||
);
|
||||
})
|
||||
.where(
|
||||
'trx.t_d_reservation_balance.c_load_balance_no',
|
||||
load_balance_number
|
||||
);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const getGlobalParameter = () => {
|
||||
let result = knex('t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', '=', 'HSM_CANCEL_RESERVATION_LEVEL')
|
||||
.first();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
checkCardNumber,
|
||||
getReservationNumberSequence,
|
||||
@@ -344,6 +545,7 @@ module.exports = {
|
||||
inquiryListReservation,
|
||||
inquiryByCardNumber,
|
||||
getReservationPending,
|
||||
getReservationPendingV2,
|
||||
getReservationWithFlag,
|
||||
insertReservation,
|
||||
getLastBalanceFromCardHistory,
|
||||
@@ -351,7 +553,11 @@ module.exports = {
|
||||
createReserveBalanceLog,
|
||||
getReservationWithPendingAndInProgressStatus,
|
||||
getReservationCanBeCanceled,
|
||||
getReservationCanBeCanceledByRefno,
|
||||
insertReservationNumber,
|
||||
cancelReservation,
|
||||
deleteReservationNumberValidate,
|
||||
inquiryListByRefNumber,
|
||||
getGlobalParameter,
|
||||
inquiryListByLoadNumber,
|
||||
};
|
||||
|
||||
@@ -1,26 +1,13 @@
|
||||
const express = require("express");
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const auth = require("../middlewares/jwt.middleware");
|
||||
const controller = require("../modules/loadbalance/loadbalance.controller");
|
||||
const auth = require('../middlewares/jwt.middleware');
|
||||
const controller = require('../modules/loadbalance/loadbalance.controller');
|
||||
|
||||
router.post(
|
||||
"/loadbalance/request",
|
||||
'/loadbalance/request',
|
||||
auth.authenticateToken,
|
||||
controller.validate("loadingBalanceRequest"),
|
||||
controller.validate('loadingBalanceRequest'),
|
||||
controller.loadingBalanceRequest
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/loadbalance",
|
||||
auth.authenticateToken,
|
||||
controller.validate("loadingBalance"),
|
||||
controller.loadingBalance
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/loadbalance/inquiry",
|
||||
auth.authenticateToken,
|
||||
controller.inquiryLoadingBalance
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -1,25 +1,13 @@
|
||||
const express = require("express");
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const auth = require("../middlewares/jwt.middleware");
|
||||
const controller = require("../modules/paymentrecon/paymentrecon.controller");
|
||||
const auth = require('../middlewares/jwt.middleware');
|
||||
const controller = require('../modules/paymentrecon/paymentrecon.controller');
|
||||
|
||||
router.post(
|
||||
"/payment-recon",
|
||||
'/payment-recon',
|
||||
auth.authenticateToken,
|
||||
controller.validate("paymentRecon"),
|
||||
controller.validate('paymentRecon'),
|
||||
controller.paymentRecon
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/payment-recon/semi-topup-online",
|
||||
auth.authenticateToken,
|
||||
controller.validate("paymentReconSemiTopupOnline"),
|
||||
controller.paymentReconSemiTopupOnline
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/payment-recon/to-cms",
|
||||
controller.paymentReconToCMS
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -1,59 +1,101 @@
|
||||
const express = require("express");
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const auth = require("../middlewares/jwt.middleware");
|
||||
const controller = require("../modules/reservebalance/reservebalance.controller");
|
||||
const auth = require('../middlewares/jwt.middleware');
|
||||
const {
|
||||
getReservationNumberSequence,
|
||||
} = require('../middlewares/redis.middleware');
|
||||
const controller = require('../modules/reservebalance/reservebalance.controller');
|
||||
|
||||
// ================================================================= ROUTE V1 =================================================================
|
||||
router.post(
|
||||
"/reservation/check",
|
||||
'/reservation/check',
|
||||
auth.authenticateToken,
|
||||
controller.validate("checkReservation"),
|
||||
controller.validate('checkReservation'),
|
||||
controller.checkReservation
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/reservation/validate",
|
||||
'/reservation/validate',
|
||||
auth.authenticateToken,
|
||||
controller.validate("reservationValidate"),
|
||||
controller.validate('reservationValidate'),
|
||||
controller.reservationValidate
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/reservation",
|
||||
'/reservation',
|
||||
auth.authenticateToken,
|
||||
controller.validate("reservation"),
|
||||
getReservationNumberSequence,
|
||||
controller.validate('reservation'),
|
||||
controller.reservation
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/reservation/cancel/validate",
|
||||
'/reservation/cancel/validate',
|
||||
auth.authenticateToken,
|
||||
controller.validate("cancelReservation"),
|
||||
controller.validate('cancelReservation'),
|
||||
controller.cancelReservationValidate
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/reservation/cancel",
|
||||
'/reservation/cancel',
|
||||
auth.authenticateToken,
|
||||
controller.validate("cancelReservation"),
|
||||
controller.validate('cancelReservation'),
|
||||
controller.cancelReservation
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/reservation/inquiry-hold",
|
||||
'/reservation/inquiry-hold',
|
||||
auth.authenticateToken,
|
||||
controller.inquiryReservation
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/reservation/inquiry/v1",
|
||||
'/reservation/inquiry/v1',
|
||||
auth.authenticateToken,
|
||||
controller.inquiryReservationByReservation
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/list-reservation/inquiry/v1",
|
||||
'/list-reservation/inquiry/v1',
|
||||
auth.authenticateToken,
|
||||
controller.inquiryListReservationByReservation
|
||||
);
|
||||
|
||||
// ================================================================= ROUTE V2 =================================================================
|
||||
router.post(
|
||||
'/reservation/validate/v2',
|
||||
auth.authenticateToken,
|
||||
controller.validate('reservationValidate'),
|
||||
controller.reservationValidateV2
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/reservation/v2',
|
||||
auth.authenticateToken,
|
||||
getReservationNumberSequence,
|
||||
controller.validate('reservationV2'),
|
||||
controller.reservationV2
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/reservation/cancel/validate/v2',
|
||||
auth.authenticateToken,
|
||||
controller.validate('cancelReservationValidateV2'),
|
||||
controller.cancelReservationValidateV2
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/reservation/cancel/v2',
|
||||
auth.authenticateToken,
|
||||
controller.validate('cancelReservationV2'),
|
||||
controller.cancelReservationV2
|
||||
);
|
||||
|
||||
// router.post(
|
||||
// '/reservation/cancel/v2.1',
|
||||
// auth.authenticateToken,
|
||||
// controller.validate('cancelReservation'),
|
||||
// controller.cancelReservationV2_1
|
||||
// );
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -1,57 +1,112 @@
|
||||
# environment
|
||||
# ================================= ENVIRONMENT =================================
|
||||
#NODE_ENV=production
|
||||
NODE_ENV=development
|
||||
#NODE_ENV=testing
|
||||
PORT=3000
|
||||
|
||||
# database
|
||||
DB_URL=postgresql://postgres:postgres@localhost:5432/CMS_DEV
|
||||
# =========================== KONFIGURASI UNTUK SERVER ===========================
|
||||
# SERVER_FOR=development
|
||||
#SERVER_FOR=production
|
||||
SERVER_FOR=local
|
||||
|
||||
# crypto
|
||||
SECRET_KEY=U2FsdGVkX19keaNhiBfdNSWnKA2a8Z5deBu/KkU6BNg=
|
||||
# =============================== DATABASE LOCAL =================================
|
||||
# DB_URL=postgresql://postgres:postgres@localhost:5432/CMS_DEV
|
||||
DB_HOST_LOCAL=localhost
|
||||
DB_NAME_LOCAL=CMS_DEV
|
||||
DB_PORT_LOCAL=5432
|
||||
DB_USER_LOCAL=postgres
|
||||
DB_PASSWORD_LOCAL=postgres
|
||||
|
||||
# jwt
|
||||
# ==================================== REDIS =====================================
|
||||
REDIS_URL=redis://localhost:6379
|
||||
REDIS_PASSWORD=
|
||||
|
||||
# ==================================== LOKI =====================================
|
||||
LOKI_URL=http://10.20.14.30:3100
|
||||
|
||||
# ==================================== APP PROMETHEUS =====================================
|
||||
PROM_APP = topuponline
|
||||
|
||||
# ================================== SECRET KEY ==================================
|
||||
# FOR PRODUCTION
|
||||
#SECRET_KEY=U2FsdGVkX19keaNhiBfdNSWnKA2a8Z5deBu/KkU6BNg=
|
||||
# FOR DEVELOPMENT
|
||||
SECRET_KEY=U2FsdGVkX18tPlf9nVJEx7KwTdFsGPO/RK6A0HRYDeg=
|
||||
|
||||
# ===================================== JWT =======================================
|
||||
JWT_EXPIRATION=30d
|
||||
JWT_REFRESH_EXPIRATION=40d
|
||||
TOKEN_SECRET=U2FsdGVkX1/hnA2S3l0Evi+whG73WiOrplJA5fcfe2o=
|
||||
REFRESH_TOKEN_SECRET=U2FsdGVkX18LvuBcY6prEGXDZhDoBa7O0GAUSzTWzdk=
|
||||
# FOR PRODUCTION
|
||||
#TOKEN_SECRET=101001D00C2001D0483001D0
|
||||
#REFRESH_TOKEN_SECRET=101001D00C2001D0483001D0800082008300800081008200
|
||||
# FOR DEVELOPMENT
|
||||
TOKEN_SECRET=101001A00C2001A0483001A0883001A0
|
||||
REFRESH_TOKEN_SECRET=101001A00C2001A0483001A0883001A0800082008300800081008200
|
||||
|
||||
# CHANGE TO DRC SERVER (YES or NO)
|
||||
|
||||
# ===================== CHANGE TO DRC SERVER (YES or NO) ===========================
|
||||
CHANGE_TO_DRC=YES
|
||||
|
||||
# HIGH AVABILITY (1 = SERVER_HSM_1 ONLY RUNNING, 2 = SERVER_HSM_2 ONLY RUNNING, 12 = SERVER_HSM_1 && SERVER_HSM_2 RUNNING)
|
||||
NUMBER_SERVER_ACTIVE=12
|
||||
NUMBER_SERVER_ACTIVE=1
|
||||
|
||||
# =================================== KCI =================================
|
||||
# ================================ KONFIGURASI HSM =================================
|
||||
|
||||
# system code kci profile
|
||||
# FOR PRODUCTION & DEVELOPMENT
|
||||
SYSTEM_CODE=90B7
|
||||
|
||||
#SERVICE BLOCK
|
||||
SERVICEBLOCK_SERVICE_MUTUAL="101001A00C2001A0483001A0"
|
||||
SERVICEBLOCK_BLOCK_READ="80008200"
|
||||
# FOR PRODUCTION
|
||||
# SERVICEBLOCK_SERVICE_MUTUAL="101001D00C2001D0483001D0"
|
||||
# FOR DEVELOPMENT
|
||||
SERVICEBLOCK_SERVICE_MUTUAL="101001A00C2001A0483001A0883001A0"
|
||||
|
||||
SERVICEBLOCK_BLOCK_READ="800082008300"
|
||||
SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
||||
|
||||
# HSM DC (DATA CENTER)
|
||||
# KCI PCI
|
||||
URL_HSM_SERVER_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||
# HSM SERVER
|
||||
# URL_HSM_SERVER_1="ws://182.253.34.129/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
# URL_HSM_SERVER_2="ws://182.253.34.129:88/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
# # HSM DRC (DISASTER RECOVERY CENTER)
|
||||
# # HSM SERVER
|
||||
# URL_HSM_SERVER_BACKUP_1="ws://182.253.34.129/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
# URL_HSM_SERVER_BACKUP_2="ws://182.253.34.129:88/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
# HSM DC (DATA CENTER)
|
||||
# HSM SERVER
|
||||
IP_HSM_SERVER_1="10.1.201.222"
|
||||
URL_HSM_SERVER_1="ws://10.1.201.222/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
IP_HSM_SERVER_2="10.1.201.215"
|
||||
URL_HSM_SERVER_2="ws://10.1.201.215:88/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
# HSM DRC (DISASTER RECOVERY CENTER)
|
||||
# KCI PCI
|
||||
# HSM SERVER
|
||||
IP_HSM_SERVER_BACKUP_1="10.1.201.222"
|
||||
URL_HSM_SERVER_BACKUP_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_BACKUP_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_BACKUP_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
IP_HSM_SERVER_BACKUP_2="10.1.201.215"
|
||||
URL_HSM_SERVER_BACKUP_2="ws://10.1.201.215:88/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_BACKUP_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
|
||||
# =================================== NUTECH =================================
|
||||
# ============================= KONFIGURASI HSM NUTECH =============================
|
||||
|
||||
# SYSTEM CODE IN HEXA STRING
|
||||
# system code nutech profile
|
||||
@@ -63,17 +118,20 @@ SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
# SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
||||
|
||||
# HSM DC (DATA CENTER)
|
||||
# KCI PCI
|
||||
# HSM SERVER
|
||||
# URL_HSM_SERVER_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_1="d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC"
|
||||
# SECRETKEY_HSM_SERVER_1="W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY="
|
||||
# JEPANG
|
||||
# URL_HSM_SERVER_1="wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_1="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||
# SECRETKEY_HSM_SERVER_1="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||
# URL_HSM_SERVER_2="wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_2="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||
# SECRETKEY_HSM_SERVER_2="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||
|
||||
# HSM DRC (DISASTER RECOVERY CENTER)
|
||||
# KCI PCI
|
||||
# HSM SERVER
|
||||
# URL_HSM_SERVER_BACKUP_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_1="d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_1="W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY="
|
||||
@@ -82,3 +140,5 @@ SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
# APIKEY_HSM_SERVER_BACKUP_2="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_2="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
# ================================= ENVIRONMENT =================================
|
||||
#NODE_ENV=production
|
||||
NODE_ENV=development
|
||||
#NODE_ENV=testing
|
||||
PORT=3000
|
||||
VERSION=v1.3.7
|
||||
|
||||
# =========================== KONFIGURASI UNTUK SERVER ===========================
|
||||
# SERVER_FOR=development
|
||||
#SERVER_FOR=production
|
||||
SERVER_FOR=local
|
||||
|
||||
# =============================== DATABASE LOCAL =================================
|
||||
# DB_URL=postgresql://postgres:postgres@localhost:5432/CMS_DEV
|
||||
DB_HOST_LOCAL=localhost
|
||||
DB_NAME_LOCAL=CMS_DEV
|
||||
DB_PORT_LOCAL=5432
|
||||
DB_USER_LOCAL=postgres
|
||||
DB_PASSWORD_LOCAL=postgres
|
||||
|
||||
# ==================================== REDIS =====================================
|
||||
REDIS_URL=redis://localhost:6379
|
||||
REDIS_PASSWORD=
|
||||
|
||||
# ==================================== LOKI =====================================
|
||||
LOKI_URL=http://localhost:3100
|
||||
|
||||
# =============================== APP PROMETHEUS =================================
|
||||
PROM_APP = topuponline
|
||||
|
||||
# ================================== SECRET KEY ==================================
|
||||
# FOR PRODUCTION
|
||||
#SECRET_KEY=U2FsdGVkX19keaNhiBfdNSWnKA2a8Z5deBu/KkU6BNg=
|
||||
# FOR DEVELOPMENT
|
||||
SECRET_KEY=U2FsdGVkX18tPlf9nVJEx7KwTdFsGPO/RK6A0HRYDeg=
|
||||
|
||||
# ===================================== JWT =======================================
|
||||
JWT_EXPIRATION=30d
|
||||
JWT_REFRESH_EXPIRATION=40d
|
||||
# FOR PRODUCTION
|
||||
#TOKEN_SECRET=101001D00C2001D0483001D0
|
||||
#REFRESH_TOKEN_SECRET=101001D00C2001D0483001D0800082008300800081008200
|
||||
# FOR DEVELOPMENT
|
||||
TOKEN_SECRET=101001A00C2001A0483001A0883001A0
|
||||
REFRESH_TOKEN_SECRET=101001A00C2001A0483001A0883001A0800082008300800081008200
|
||||
|
||||
|
||||
# ===================== CHANGE TO DRC SERVER (YES or NO) ===========================
|
||||
CHANGE_TO_DRC=YES
|
||||
|
||||
# HIGH AVABILITY (1 = SERVER_HSM_1 ONLY RUNNING, 2 = SERVER_HSM_2 ONLY RUNNING, 12 = SERVER_HSM_1 && SERVER_HSM_2 RUNNING)
|
||||
NUMBER_SERVER_ACTIVE=1
|
||||
|
||||
# ================================ KONFIGURASI HSM =================================
|
||||
|
||||
# system code kci profile
|
||||
# FOR PRODUCTION & DEVELOPMENT
|
||||
SYSTEM_CODE=90B7
|
||||
|
||||
#SERVICE BLOCK
|
||||
# FOR PRODUCTION
|
||||
# SERVICEBLOCK_SERVICE_MUTUAL="101001D00C2001D0483001D0"
|
||||
# FOR DEVELOPMENT
|
||||
SERVICEBLOCK_SERVICE_MUTUAL="101001A00C2001A0483001A0883001A0"
|
||||
|
||||
SERVICEBLOCK_BLOCK_READ="800082008300"
|
||||
SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
||||
|
||||
# HSM DC (DATA CENTER)
|
||||
# HSM SERVER
|
||||
# URL_HSM_SERVER_1="ws://182.253.34.129/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
# URL_HSM_SERVER_2="ws://182.253.34.129:88/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
# # HSM DRC (DISASTER RECOVERY CENTER)
|
||||
# # HSM SERVER
|
||||
# URL_HSM_SERVER_BACKUP_1="ws://182.253.34.129/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
# URL_HSM_SERVER_BACKUP_2="ws://182.253.34.129:88/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
# HSM DC (DATA CENTER)
|
||||
# HSM SERVER
|
||||
IP_HSM_SERVER_1="10.1.201.222"
|
||||
URL_HSM_SERVER_1="ws://10.1.201.222/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
IP_HSM_SERVER_2="10.1.201.215"
|
||||
URL_HSM_SERVER_2="ws://10.1.201.215:88/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
# HSM DRC (DISASTER RECOVERY CENTER)
|
||||
# HSM SERVER
|
||||
IP_HSM_SERVER_BACKUP_1="10.1.201.222"
|
||||
URL_HSM_SERVER_BACKUP_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_BACKUP_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_BACKUP_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
IP_HSM_SERVER_BACKUP_2="10.1.201.215"
|
||||
URL_HSM_SERVER_BACKUP_2="ws://10.1.201.215:88/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_BACKUP_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
|
||||
# ============================= KONFIGURASI HSM NUTECH =============================
|
||||
|
||||
# SYSTEM CODE IN HEXA STRING
|
||||
# system code nutech profile
|
||||
# SYSTEM_CODE=939E
|
||||
|
||||
#SERVICE BLOCK
|
||||
# SERVICEBLOCK_SERVICE_MUTUAL="102001A04C2001A0882001A0"
|
||||
# SERVICEBLOCK_BLOCK_READ="80008200"
|
||||
# SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
||||
|
||||
# HSM DC (DATA CENTER)
|
||||
# HSM SERVER
|
||||
# URL_HSM_SERVER_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_1="d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC"
|
||||
# SECRETKEY_HSM_SERVER_1="W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY="
|
||||
# JEPANG
|
||||
# URL_HSM_SERVER_1="wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_1="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||
# SECRETKEY_HSM_SERVER_1="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||
# URL_HSM_SERVER_2="wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_2="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||
# SECRETKEY_HSM_SERVER_2="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||
|
||||
# HSM DRC (DISASTER RECOVERY CENTER)
|
||||
# HSM SERVER
|
||||
# URL_HSM_SERVER_BACKUP_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_1="d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_1="W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY="
|
||||
# JEPANG
|
||||
# URL_HSM_SERVER_BACKUP_2="wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_2="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_2="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||
|
||||
|
||||
|
||||
@@ -1,33 +1,35 @@
|
||||
require("dotenv").config();
|
||||
const winston = require("./application/helpers/winston.logger");
|
||||
const server = require("./server");
|
||||
require('dotenv').config();
|
||||
const winston = require('./application/helpers/winston.logger');
|
||||
const server = require('./server');
|
||||
|
||||
// set port, listen for requests
|
||||
const PORT = process.env.PORT || 3000;
|
||||
var serverHSMStatus = "HSM SERVER NOT CONNECTED";
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var serverHSMStatus = 'HSM SERVER NOT CONNECTED';
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
serverHSMStatus = `SERVER 1 CONNECTED on ip ${process.env.IP_HSM_SERVER_1}`;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
serverHSMStatus = `SERVER 2 CONNECTED on ip ${process.env.IP_HSM_SERVER_2}`;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
serverHSMStatus = `SERVER 1 on ip ${process.env.IP_HSM_SERVER_1} AND SERVER 2 on ip ${process.env.IP_HSM_SERVER_2} CONNECTED`;
|
||||
}
|
||||
|
||||
var serverActive = "DC (DATA CENTER)";
|
||||
if (process.env.CHANGE_TO_DRC == "YES" || process.env.CHANGE_TO_DRC == "yes") {
|
||||
serverActive = "DRC (DISASTER RECOVERY CENTER)";
|
||||
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var serverActive = 'DC (DATA CENTER)';
|
||||
if (process.env.CHANGE_TO_DRC == 'YES' || process.env.CHANGE_TO_DRC == 'yes') {
|
||||
serverActive = 'DRC (DISASTER RECOVERY CENTER)';
|
||||
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
serverHSMStatus = `SERVER 1 CONNECTED on ip ${process.env.IP_HSM_SERVER_BACKUP_1}`;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
serverHSMStatus = `SERVER 2 CONNECTED on ip ${process.env.IP_HSM_SERVER_BACKUP_2}`;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
serverHSMStatus = `SERVER 1 on ip ${process.env.IP_HSM_SERVER_BACKUP_1} AND SERVER 2 on ip ${process.env.IP_HSM_SERVER_BACKUP_2} CONNECTED`;
|
||||
}
|
||||
}
|
||||
|
||||
server.listen(PORT, () => {
|
||||
winston.logger.info(
|
||||
`Server is running on environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `
|
||||
`Server is running on version ${
|
||||
process.env.VERSION
|
||||
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `
|
||||
);
|
||||
});
|
||||
|
||||
+66
-66
@@ -1,4 +1,4 @@
|
||||
require("dotenv").config();
|
||||
require('dotenv').config();
|
||||
|
||||
let host;
|
||||
let database;
|
||||
@@ -6,77 +6,77 @@ let port;
|
||||
let user;
|
||||
let password;
|
||||
|
||||
if (process.env.SERVER_FOR == "local") {
|
||||
host = "localhost";
|
||||
database = "postgres";
|
||||
if (process.env.SERVER_FOR == 'local') {
|
||||
host = process.env.DB_HOST_LOCAL;
|
||||
database = process.env.DB_NAME_LOCAL;
|
||||
port = process.env.DB_PORT_LOCAL;
|
||||
user = process.env.DB_USER_LOCAL;
|
||||
password = process.env.DB_PASSWORD_LOCAL;
|
||||
} else if (process.env.SERVER_FOR == 'development') {
|
||||
host = '10.20.14.14';
|
||||
database = 'postgres';
|
||||
port = 5432;
|
||||
user = "postgres";
|
||||
password = "postgres";
|
||||
} else if (process.env.SERVER_FOR == "development") {
|
||||
host = "10.20.14.14";
|
||||
database = "postgres";
|
||||
user = 'postgres';
|
||||
password = 'inhc0mmute_cms';
|
||||
} else if (process.env.SERVER_FOR == 'production') {
|
||||
host = '10.1.201.75';
|
||||
database = 'postgres';
|
||||
port = 5432;
|
||||
user = "cms";
|
||||
password = "Cm5kc1#2021";
|
||||
} else if (process.env.SERVER_FOR == "production") {
|
||||
host = "10.1.201.75";
|
||||
database = "postgres";
|
||||
port = 5432;
|
||||
user = "postgres";
|
||||
password = "inhc0mmute_cms";
|
||||
user = 'postgres';
|
||||
password = 'inhc0mmute_cms';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
// development: {
|
||||
// client: "pg",
|
||||
// connection: process.env.DB_URL,
|
||||
// migrations: {
|
||||
// directory: "./infrastructure/database/migrations",
|
||||
// },
|
||||
// seeds: { directory: "./infrastructure/database/seeds" },
|
||||
// },
|
||||
development: {
|
||||
client: "pg",
|
||||
connection: {
|
||||
host: host,
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
},
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10,
|
||||
},
|
||||
migrations: {
|
||||
directory: "./infrastructure/database/migrations",
|
||||
},
|
||||
module.exports = {
|
||||
// development: {
|
||||
// client: "pg",
|
||||
// connection: process.env.DB_URL,
|
||||
// migrations: {
|
||||
// directory: "./infrastructure/database/migrations",
|
||||
// },
|
||||
// seeds: { directory: "./infrastructure/database/seeds" },
|
||||
// },
|
||||
development: {
|
||||
client: 'pg',
|
||||
connection: {
|
||||
host: host,
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
},
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10,
|
||||
},
|
||||
migrations: {
|
||||
directory: './infrastructure/database/migrations',
|
||||
},
|
||||
},
|
||||
|
||||
testing: {
|
||||
client: "pg",
|
||||
connection: process.env.DB_URL,
|
||||
migrations: {
|
||||
directory: "./infrastructure/database/migrations",
|
||||
},
|
||||
seeds: { directory: "./infrastructure/database/seeds" },
|
||||
testing: {
|
||||
client: 'pg',
|
||||
connection: process.env.DB_URL,
|
||||
migrations: {
|
||||
directory: './infrastructure/database/migrations',
|
||||
},
|
||||
seeds: { directory: './infrastructure/database/seeds' },
|
||||
},
|
||||
|
||||
production: {
|
||||
client: "pg",
|
||||
connection: {
|
||||
host: host,
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
},
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10,
|
||||
},
|
||||
migrations: {
|
||||
directory: "./infrastructure/database/migrations",
|
||||
},
|
||||
production: {
|
||||
client: 'pg',
|
||||
connection: {
|
||||
host: host,
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
},
|
||||
};
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10,
|
||||
},
|
||||
migrations: {
|
||||
directory: './infrastructure/database/migrations',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Generated
+5455
-2023
File diff suppressed because it is too large
Load Diff
@@ -31,14 +31,19 @@
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"express-validator": "^6.10.0",
|
||||
"express-winston": "^4.2.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"knex": "^0.95.4",
|
||||
"moment": "^2.29.3",
|
||||
"node-cron": "^3.0.1",
|
||||
"pg": "^8.6.0",
|
||||
"pm2": "^5.2.0",
|
||||
"prom-client": "^14.2.0",
|
||||
"redis": "^4.6.5",
|
||||
"response-time": "^2.3.2",
|
||||
"winston": "^3.7.2",
|
||||
"winston-daily-rotate-file": "^4.7.1",
|
||||
"winston-loki": "^6.0.6",
|
||||
"ws": "^8.5.0",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
|
||||
+202
-162
@@ -1,28 +1,47 @@
|
||||
const express = require("express");
|
||||
const bodyParser = require("body-parser");
|
||||
const cors = require("cors");
|
||||
const helper = require("../application/helpers/helper");
|
||||
const winston = require("../application/helpers/winston.logger");
|
||||
const authRoute = require("../application/routes/auth.routes");
|
||||
const dongleOrderRoute = require("../application/routes/dongleorder.routes");
|
||||
const reservationRoute = require("../application/routes/reservebalance.routes");
|
||||
const loadBalanceRoute = require("../application/routes/loadbalance.routes");
|
||||
const hsmRoute = require("../application/routes/hsm.routes");
|
||||
const historyRoute = require("../application/routes/history.routes");
|
||||
const paymentReconRoute = require("../application/routes/paymentrecon.routes");
|
||||
const invoiceRoute = require("../application/routes/invoiceonline.routes");
|
||||
const cashinRoute = require("../application/routes/cahsin.routes");
|
||||
const cron = require("node-cron");
|
||||
const moment = require("moment");
|
||||
require("dotenv").config();
|
||||
moment.locale("id");
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const cors = require('cors');
|
||||
const helper = require('../application/helpers/helper');
|
||||
const winston = require('../application/helpers/winston.logger');
|
||||
const authRoute = require('../application/routes/auth.routes');
|
||||
const dongleOrderRoute = require('../application/routes/dongleorder.routes');
|
||||
const reservationRoute = require('../application/routes/reservebalance.routes');
|
||||
const loadBalanceRoute = require('../application/routes/loadbalance.routes');
|
||||
const hsmRoute = require('../application/routes/hsm.routes');
|
||||
const historyRoute = require('../application/routes/history.routes');
|
||||
const paymentReconRoute = require('../application/routes/paymentrecon.routes');
|
||||
const invoiceRoute = require('../application/routes/invoiceonline.routes');
|
||||
const cashinRoute = require('../application/routes/cahsin.routes');
|
||||
const cron = require('node-cron');
|
||||
const moment = require('moment');
|
||||
require('dotenv').config();
|
||||
moment.locale('id');
|
||||
const responseTime = require('response-time');
|
||||
const { logger } = require('../application/helpers/getbodyrequest');
|
||||
const client = require('prom-client');
|
||||
const register = new client.Registry();
|
||||
const {
|
||||
topuponline_metrics, topuponline_metrics_response_time,topuponline_metrics_load_balance
|
||||
} = require('../application/helpers/prometheusmetrics');
|
||||
|
||||
const app = express();
|
||||
|
||||
let promApp = process.env.PROM_APP || "topuponline";
|
||||
register.setDefaultLabels({ app: promApp });
|
||||
client.collectDefaultMetrics({ register });
|
||||
register.registerMetric(topuponline_metrics);
|
||||
register.registerMetric(topuponline_metrics_response_time);
|
||||
register.registerMetric(topuponline_metrics_load_balance);
|
||||
|
||||
app.get('/metrics', (req, res) => {
|
||||
res.setHeader('Content-Type', register.contentType);
|
||||
register.metrics().then((data) => res.send(data));
|
||||
});
|
||||
|
||||
var corsOptions = {
|
||||
origin: [
|
||||
"http://localhost:" + process.env.PORT || 3000,
|
||||
"http://localhost:3000",
|
||||
'http://localhost:' + process.env.PORT || 3000,
|
||||
'http://localhost:3000',
|
||||
],
|
||||
};
|
||||
|
||||
@@ -35,174 +54,195 @@ app.use(bodyParser.json());
|
||||
// parse requests of content-type - application/x-www-form-urlencoded
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
app.use(responseTime());
|
||||
|
||||
// ============================== ROUTES API ==============================
|
||||
app.get("/", (req, res) => {
|
||||
app.get('/', async (req, res) => {
|
||||
let data = {
|
||||
card_number: '1234567890',
|
||||
amount: 10000,
|
||||
};
|
||||
|
||||
let chipperData = helper.encryptText(JSON.stringify(data));
|
||||
let decrypData = JSON.parse(helper.decryptText(chipperData));
|
||||
res.json({
|
||||
message: "Welcome to Topup Online Service.",
|
||||
// data: {
|
||||
// text: "0nlinet0pupkci",
|
||||
// chiper_text: helper.encryptText("0nlinet0pupkci"),
|
||||
// },
|
||||
message: 'Welcome to Topup Online Service.',
|
||||
data: {
|
||||
text: '0nlinet0pupkci',
|
||||
chiper_text: helper.encryptText('0nlinet0pupkci'),
|
||||
chipper_data: chipperData,
|
||||
decrypt_data: decrypData,
|
||||
date: moment().format('YYYYMMDDHHmm'),
|
||||
secret_key: helper.encryptText('0nlinetopupDev'),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
app.use("/api/", authRoute);
|
||||
app.use("/api/", dongleOrderRoute);
|
||||
app.use("/api/", historyRoute);
|
||||
app.use("/api/", hsmRoute);
|
||||
app.use("/api/", loadBalanceRoute);
|
||||
app.use("/api/", paymentReconRoute);
|
||||
app.use("/api/", reservationRoute);
|
||||
app.use("/api/", invoiceRoute);
|
||||
app.use("/api/", cashinRoute);
|
||||
app.use(logger.request);
|
||||
app.use(logger.response);
|
||||
|
||||
app.use('/api/', authRoute);
|
||||
app.use('/api/', dongleOrderRoute);
|
||||
app.use('/api/', historyRoute);
|
||||
app.use('/api/', hsmRoute);
|
||||
app.use('/api/', loadBalanceRoute);
|
||||
app.use('/api/', paymentReconRoute);
|
||||
app.use('/api/', reservationRoute);
|
||||
app.use('/api/', invoiceRoute);
|
||||
app.use('/api/', cashinRoute);
|
||||
|
||||
// ============================== SAP SCHEDULLER =============================
|
||||
|
||||
// if (process.env.NODE_ENV.toUpperCase() == "PRODUCTION") {
|
||||
|
||||
// ===================================================
|
||||
// SCHEDULER FOR GENERATE INVOICE
|
||||
// ===================================================
|
||||
// ===================================================
|
||||
// SCHEDULER FOR GENERATE INVOICE
|
||||
// ===================================================
|
||||
|
||||
const {
|
||||
_generateInvoice,
|
||||
_postingInvoice,
|
||||
} = require("../application/modules/invoiceonline/invoice.controller");
|
||||
|
||||
// GENERATE + POSTING INVOICE
|
||||
cron.schedule("0 1 * * *", async () => {
|
||||
try {
|
||||
// let ivoiceDate = moment().add(1, 'days').format("YYYY-MM-DD");
|
||||
let ivoiceDate = moment().format("YYYY-MM-DD");
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(
|
||||
`STARTING SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} `
|
||||
);
|
||||
const generate = await _generateInvoice(ivoiceDate, uniqueCode, false);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} : ${JSON.stringify(
|
||||
generate
|
||||
)}`
|
||||
);
|
||||
const reGenerate = await _generateInvoice(ivoiceDate, uniqueCode, true);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-GENERATE INVOICE THAT HAVE BEEN DELETED ${ivoiceDate} : ${JSON.stringify(
|
||||
generate
|
||||
)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
const {
|
||||
_generateInvoice,
|
||||
_postingInvoice,
|
||||
} = require('../application/modules/invoiceonline/invoice.controller');
|
||||
|
||||
// RE-TRY POSTING
|
||||
cron.schedule("0 7 * * *", async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
const posting = await _postingInvoice(uniqueCode);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
// GENERATE + POSTING INVOICE
|
||||
cron.schedule('0 1 * * *', async () => {
|
||||
try {
|
||||
// let ivoiceDate = moment().add(1, 'days').format("YYYY-MM-DD");
|
||||
let ivoiceDate = moment().format('YYYY-MM-DD');
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(
|
||||
`STARTING SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} `
|
||||
);
|
||||
const generate = await _generateInvoice(ivoiceDate, uniqueCode, false);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} : ${JSON.stringify(
|
||||
generate
|
||||
)}`
|
||||
);
|
||||
const reGenerate = await _generateInvoice(ivoiceDate, uniqueCode, true);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-GENERATE INVOICE THAT HAVE BEEN DELETED ${ivoiceDate} : ${JSON.stringify(
|
||||
generate
|
||||
)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
cron.schedule("0 12 * * *", async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
const posting = await _postingInvoice(uniqueCode);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
// RE-TRY POSTING
|
||||
cron.schedule('0 7 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
const posting = await _postingInvoice(uniqueCode);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
cron.schedule("0 17 * * *", async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
const posting = await _postingInvoice(uniqueCode);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
cron.schedule('0 12 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
const posting = await _postingInvoice(uniqueCode);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// ===================================================
|
||||
// SCHEDULER FOR GENERATE INVOICE
|
||||
// ===================================================
|
||||
// cash in
|
||||
const {
|
||||
_generateCashIn,
|
||||
} = require("../application/modules/cashin/cahsin.controller");
|
||||
cron.schedule('0 17 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
const posting = await _postingInvoice(uniqueCode);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
cron.schedule('30 7 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.info(`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`);
|
||||
const posting = await _generateCashIn(uniqueCode);
|
||||
winston.logger.info(
|
||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// ===================================================
|
||||
// SCHEDULER FOR GENERATE INVOICE
|
||||
// ===================================================
|
||||
// cash in
|
||||
const {
|
||||
_generateCashIn,
|
||||
} = require('../application/modules/cashin/cahsin.controller');
|
||||
|
||||
cron.schedule('30 7 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.info(
|
||||
`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||
);
|
||||
const posting = await _generateCashIn(uniqueCode);
|
||||
winston.logger.info(
|
||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
cron.schedule('30 12 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.info(`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`);
|
||||
const posting = await _generateCashIn(uniqueCode);
|
||||
winston.logger.info(
|
||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
cron.schedule('30 12 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.info(
|
||||
`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||
);
|
||||
const posting = await _generateCashIn(uniqueCode);
|
||||
winston.logger.info(
|
||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
cron.schedule('30 17 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.info(`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`);
|
||||
const posting = await _generateCashIn(uniqueCode);
|
||||
winston.logger.info(
|
||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
cron.schedule('30 17 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.info(
|
||||
`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||
);
|
||||
const posting = await _generateCashIn(uniqueCode);
|
||||
winston.logger.info(
|
||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user