Compare commits

...

96 Commits

Author SHA1 Message Date
ihsan c8f01db5e9 update 2023-03-03 17:33:01 +07:00
ihsan 1be5cc8d0c update 2023-03-03 17:31:43 +07:00
ihsan 352ec2822f update 2023-03-03 17:31:02 +07:00
ihsan 9910d4d834 update 2023-03-03 17:28:29 +07:00
ihsan a2eb984658 update 2023-03-03 17:25:24 +07:00
ihsan eac57a3821 update 2023-03-03 17:21:07 +07:00
ihsan f4451aaea2 update 2023-03-03 17:11:50 +07:00
ihsan 837d1c5d77 update 2023-03-03 16:33:20 +07:00
ihsan 74825d277b update 2023-03-03 16:26:01 +07:00
ihsan 8c231e9901 update 2023-03-03 16:16:14 +07:00
ihsan f7c5cf33f6 update 2023-03-03 16:03:34 +07:00
ihsan 870d8aea46 skip check amount topup 2023-02-27 12:40:48 +07:00
ihsan b46d3a5b25 update 2023-02-24 16:53:38 +07:00
ihsan 5408639d80 update reservation amount total 2023-02-24 15:56:52 +07:00
ihsan 9b2ab48e99 update 2023-02-22 10:24:24 +07:00
ihsan a35492c124 update 2023-02-22 08:20:55 +07:00
ihsan e1f0c60b37 update 2023-02-22 01:24:46 +07:00
ihsan 16afd42876 update 2023-02-22 00:59:36 +07:00
ihsan 3722be6eeb update 2023-02-22 00:44:59 +07:00
ihsan 493f131779 update 2023-02-22 00:36:24 +07:00
ihsan f10ff80284 update 2023-02-22 00:32:01 +07:00
ihsan f30ee86552 update 2023-02-22 00:26:49 +07:00
ihsan e8de33b663 update 2023-02-22 00:13:41 +07:00
ihsan 68ebfb0ac2 update 2023-02-21 20:02:33 +07:00
ihsan 96c46ad49c update 2023-02-21 19:56:53 +07:00
ihsan 10e38babcd update 2023-02-21 19:54:06 +07:00
ihsan 8bc68493cf update 2023-02-21 19:49:42 +07:00
ihsan 2b1b14548a update 2023-02-21 19:46:28 +07:00
ihsan 240bb5fa17 update 2023-02-21 19:44:37 +07:00
ihsan 7676ec54ef update 2023-02-21 19:42:22 +07:00
ihsan de0a8847b5 update 2023-02-21 19:39:57 +07:00
ihsan 4df41a426c update 2023-02-21 19:36:51 +07:00
ihsan 3401e425b4 updaye 2023-02-21 19:33:43 +07:00
ihsan 0d29175942 update 2023-02-21 19:19:07 +07:00
ihsan 4f03433bb2 update 2023-02-21 19:17:07 +07:00
ihsan 1df5f97543 update 2023-02-21 19:08:11 +07:00
ihsan a222714bcb update 2023-02-21 19:07:02 +07:00
ihsan 2249bbbbaf update 2023-02-21 19:01:02 +07:00
ihsan 16fbfdcae1 update 2023-02-21 18:02:58 +07:00
ihsan 6b5f92e597 update 2023-02-21 14:52:28 +07:00
ihsan baf99a975d update bugs 2023-02-21 14:40:05 +07:00
ihsan 70b9ef78cb update 2023-02-20 23:54:54 +07:00
ihsan 4169b40e97 update 2023-02-20 23:52:36 +07:00
ihsan 3566f63bea update 2023-02-20 23:50:21 +07:00
ihsan 066fd49173 update 2023-02-20 23:49:00 +07:00
ihsan 2c0ffbd9d6 update 2023-02-20 23:47:30 +07:00
ihsan ee46232c7a update 2023-02-20 23:46:38 +07:00
ihsan 15131cebb1 update 2023-02-20 23:31:42 +07:00
ihsan 6ff785de5a Merge branch 'nuranggi' into feature_fraud 2023-02-20 23:26:52 +07:00
Nuranggi Hermawan 8e997346d2 UPdate 2023-02-20 23:25:33 +07:00
Nuranggi Hermawan 80dda817fb Update 2023-02-20 23:24:55 +07:00
Nuranggi Hermawan 410ef5ac53 Update 2023-02-20 23:24:07 +07:00
ihsan d9d5be8921 update 2023-02-20 23:24:01 +07:00
ihsan 574092e015 update 2023-02-20 23:18:09 +07:00
ihsan 5ece7912f4 update 2023-02-20 23:15:38 +07:00
ihsan 2540b1c6c0 update 2023-02-20 23:12:29 +07:00
ihsan 4feb7a7724 update 2023-02-20 23:10:14 +07:00
ihsan 4994278078 UPDATE 2023-02-20 23:09:31 +07:00
ihsan c6488f7f69 update 2023-02-20 23:06:20 +07:00
ihsan f0bbf54afc update 2023-02-20 22:53:16 +07:00
ihsan 7c6ab450be update 2023-02-20 22:51:09 +07:00
ihsan 1524d643c6 update 2023-02-20 22:49:18 +07:00
ihsan 36b61697dd update 2023-02-20 22:46:25 +07:00
ihsan 8366d9b38b update 2023-02-20 22:42:35 +07:00
ihsan ed7e0ce127 update 2023-02-20 22:39:46 +07:00
ihsan 8d1e2075c3 update 2023-02-20 22:38:24 +07:00
ihsan 5df52be111 update 2023-02-20 22:37:15 +07:00
ihsan 6e0627fb86 update 2023-02-20 22:34:40 +07:00
ihsan 0235cdb7c0 update 2023-02-20 22:31:14 +07:00
ihsan a64c38b928 update 2023-02-20 22:27:40 +07:00
ihsan 99f004adf2 update 2023-02-20 22:22:55 +07:00
Nuranggi Hermawan 3e5d73dd56 Merge branch 'feature_fraud' of https://github.com/mohamadihsan/topuponline into nuranggi 2023-02-20 22:18:19 +07:00
Nuranggi Hermawan 4481079289 Update 2023-02-20 22:18:02 +07:00
ihsan 9bc1260bc0 update 2023-02-20 22:13:50 +07:00
ihsan df8ad92eba update 2023-02-20 22:10:55 +07:00
ihsan 3b8d9d20ff update merge 2023-02-20 22:08:03 +07:00
Nuranggi Hermawan 5197966807 Udpate 2023-02-20 22:06:22 +07:00
ihsan 966c7b1f60 update 2023-02-20 21:49:33 +07:00
ihsan 002f1375e4 merge 2023-02-20 21:39:20 +07:00
ihsan ada8358c07 merge 2023-02-20 21:37:17 +07:00
Nuranggi Hermawan b587640684 Update 2023-02-20 21:35:43 +07:00
Nuranggi Hermawan 7d56ebbe77 Update 2023-02-20 21:32:12 +07:00
Nuranggi Hermawan 015832c683 Update 2023-02-20 21:23:47 +07:00
Nuranggi Hermawan 79a5c5951b Update 2023-02-20 21:19:59 +07:00
ihsan c54a030519 update fraud 2023-02-20 21:16:12 +07:00
Nuranggi Hermawan 775b36cfd2 Update 2023-02-20 21:03:02 +07:00
ihsan b796bfdd5c update 2023-02-20 17:15:09 +07:00
ihsan 25f66afa7b change update status to in progress to last statement 2023-02-14 06:26:04 +07:00
ihsan 162c742e76 update bug load balance 2023-01-19 13:32:42 +07:00
ihsan e60e38d28b update 2023-01-13 17:34:05 +07:00
ihsan 47072d156d update 2023-01-13 17:00:06 +07:00
ihsan c60b00dbcf update 2023-01-13 16:33:38 +07:00
ihsan 089fb2131a update 2023-01-13 16:23:29 +07:00
ihsan 40a408ab9d update 2023-01-13 16:03:16 +07:00
ihsan a89f84fc18 update 2023-01-13 15:29:21 +07:00
ihsan 95ab81bcc6 update 2023-01-13 15:23:16 +07:00
5 changed files with 1715 additions and 1007 deletions
+46 -36
View File
@@ -1,51 +1,51 @@
const { param, body, validationResult } = require("express-validator"); const { param, body, validationResult } = require('express-validator');
const winston = require("../../helpers/winston.logger"); const winston = require('../../helpers/winston.logger');
const generate = require("./utils/utils"); const generate = require('./utils/utils');
const loadBalance = require("../loadbalance/loadbalance.controller"); const loadBalance = require('../loadbalance/loadbalance.controller');
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
require("dotenv").config(); require('dotenv').config();
let useClient; let useClient;
// set connection HSM server // set connection HSM server
if (process.env.NUMBER_SERVER_ACTIVE == "1") { if (process.env.NUMBER_SERVER_ACTIVE == '1') {
var { client } = require("./services/webSocket"); var { client } = require('./services/webSocket');
useClient = client; useClient = client;
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") { } else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
var { client2 } = require("./services/webSocket2"); var { client2 } = require('./services/webSocket2');
useClient = client2; useClient = client2;
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") { } else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
var { client } = require("./services/webSocket"); var { client } = require('./services/webSocket');
var { client2 } = require("./services/webSocket2"); var { client2 } = require('./services/webSocket2');
} }
// VALIDATION // VALIDATION
const validate = (method) => { const validate = (method) => {
switch (method) { switch (method) {
case "topup": case 'topup':
return [ return [
body("mid").not().isEmpty().withMessage("MID is required"), body('mid').not().isEmpty().withMessage('MID is required'),
body("tid").not().isEmpty().withMessage("TID is required"), body('tid').not().isEmpty().withMessage('TID is required'),
body("uid").not().isEmpty().withMessage("UID is required"), body('uid').not().isEmpty().withMessage('UID is required'),
body("flag").not().isEmpty().withMessage("Flag is required"), body('flag').not().isEmpty().withMessage('Flag is required'),
body("card_number") body('card_number')
.not() .not()
.isEmpty() .isEmpty()
.withMessage("Card Number is required"), .withMessage('Card Number is required'),
body("amount") body('amount')
.not() .not()
.isEmpty() .isEmpty()
.withMessage("Amount is required") .withMessage('Amount is required')
.isNumeric() .isNumeric()
.withMessage("Amount is invalid format"), .withMessage('Amount is invalid format'),
body("reservation_number") body('reservation_number')
.not() .not()
.isEmpty() .isEmpty()
.withMessage("Reservation Number is required") .withMessage('Reservation Number is required')
.isArray() .isArray()
.withMessage("Reservation Number is invalid request format"), .withMessage('Reservation Number is invalid request format'),
]; ];
default: default:
break; break;
@@ -66,6 +66,7 @@ const controller = async (req, res) => {
uid, uid,
balance, balance,
flag, flag,
execution_id,
unique_code, unique_code,
trxID, trxID,
requestData, requestData,
@@ -75,7 +76,7 @@ const controller = async (req, res) => {
let result = {}; let result = {};
// set connection HSM server // set connection HSM server
if (process.env.NUMBER_SERVER_ACTIVE == "12") { if (process.env.NUMBER_SERVER_ACTIVE == '12') {
// set request to HSM server 2 // set request to HSM server 2
if (uniqueCode) { if (uniqueCode) {
if (parseInt(uniqueCode) % 2 == 0) { if (parseInt(uniqueCode) % 2 == 0) {
@@ -101,7 +102,7 @@ const controller = async (req, res) => {
const err = validationResult(req, res); const err = validationResult(req, res);
if (!err.isEmpty()) { if (!err.isEmpty()) {
result = { result = {
code: "400", code: '400',
message: err.errors[0].msg, message: err.errors[0].msg,
data: {}, data: {},
}; };
@@ -122,6 +123,14 @@ const controller = async (req, res) => {
let transactionId = Buffer.from(generate.hexToBytes(trxID)); let transactionId = Buffer.from(generate.hexToBytes(trxID));
let trxrequestData = Buffer.from(generate.hexToBytes(requestData)); let trxrequestData = Buffer.from(generate.hexToBytes(requestData));
let _stopMessage = 1; let _stopMessage = 1;
let execID;
if (execution_id) {
execID = execution_id;
} else {
let execByte = Buffer.alloc(2);
trxrequestData.copy(execByte, 0, 24, 26);
execID = generate.buf2hex(execByte);
}
let apiId = Buffer.from([0x04]); let apiId = Buffer.from([0x04]);
let reqData = generate.makeRequestData( let reqData = generate.makeRequestData(
@@ -136,7 +145,7 @@ const controller = async (req, res) => {
let respData = null; let respData = null;
let respData1 = null; let respData1 = null;
useClient.ws.on("message", (message) => { useClient.ws.on('message', (message) => {
while ( while (
message[2] == 4 && message[2] == 4 &&
message[0] == transactionId[0] && message[0] == transactionId[0] &&
@@ -188,15 +197,16 @@ const controller = async (req, res) => {
balance: balance, balance: balance,
flag: flag, flag: flag,
unique_code: unique_code, unique_code: unique_code,
execution_id: execID,
}; };
// insert data load balance // insert data load balance
let insert = await loadBalance.loadingBalanceInsert(data); let insert = await loadBalance.loadingBalanceInsert(data);
if (insert) { if (insert) {
if (insert.code == "00") { if (insert.code == '00') {
result = { result = {
code: "00", code: '00',
message: "Generate Write Succeess", message: 'Generate Write Succeess',
data: { data: {
trxID: generate.buf2hex(transactionId), trxID: generate.buf2hex(transactionId),
responseCode: respCode, responseCode: respCode,
@@ -214,8 +224,8 @@ const controller = async (req, res) => {
} }
} else { } else {
result = { result = {
code: "423", code: '423',
message: "update/insert failed", message: 'update/insert failed',
data: {}, data: {},
}; };
} }
@@ -233,11 +243,11 @@ const controller = async (req, res) => {
); );
return res.status(200).send({ return res.status(200).send({
code: "5001", code: '5001',
message: message:
process.env.NODE_ENV != "production" process.env.NODE_ENV != 'production'
? error.message ? error.message
: "500 internal server error - backend server.", : '500 internal server error - backend server.',
data: {}, 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
+65 -65
View File
@@ -1,4 +1,4 @@
require("dotenv").config(); require('dotenv').config();
let host; let host;
let database; let database;
@@ -6,77 +6,77 @@ let port;
let user; let user;
let password; let password;
if (process.env.SERVER_FOR == "local") { if (process.env.SERVER_FOR == 'local') {
host = "localhost"; host = 'localhost';
database = "postgres"; database = 'postgres';
port = 5432; port = 5432;
user = "postgres"; user = 'postgres';
password = "postgres"; password = 'postgres';
} else if (process.env.SERVER_FOR == "development") { } else if (process.env.SERVER_FOR == 'development') {
host = "10.20.14.14"; host = '10.20.14.14';
database = "postgres"; database = 'postgres';
port = 5432; port = 5432;
user = "cms"; user = 'postgres';
password = "Cm5kc1#2021"; password = 'inhc0mmute_cms';
} else if (process.env.SERVER_FOR == "production") { } else if (process.env.SERVER_FOR == 'production') {
host = "10.1.201.75"; host = '10.1.201.75';
database = "postgres"; database = 'postgres';
port = 5432; port = 5432;
user = "postgres"; user = 'postgres';
password = "inhc0mmute_cms"; password = 'inhc0mmute_cms';
} }
module.exports = { module.exports = {
// development: { // development: {
// client: "pg", // client: "pg",
// connection: process.env.DB_URL, // connection: process.env.DB_URL,
// migrations: { // migrations: {
// directory: "./infrastructure/database/migrations", // directory: "./infrastructure/database/migrations",
// }, // },
// seeds: { directory: "./infrastructure/database/seeds" }, // seeds: { directory: "./infrastructure/database/seeds" },
// }, // },
development: { development: {
client: "pg", client: 'pg',
connection: { connection: {
host: host, host: host,
database: database, database: database,
user: user, user: user,
password: password, password: password,
},
// connection: process.env.DB_URL,
pool: {
min: 2,
max: 10,
},
migrations: {
directory: "./infrastructure/database/migrations",
},
}, },
// connection: process.env.DB_URL,
pool: {
min: 2,
max: 10,
},
migrations: {
directory: './infrastructure/database/migrations',
},
},
testing: { testing: {
client: "pg", client: 'pg',
connection: process.env.DB_URL, connection: process.env.DB_URL,
migrations: { migrations: {
directory: "./infrastructure/database/migrations", directory: './infrastructure/database/migrations',
},
seeds: { directory: "./infrastructure/database/seeds" },
}, },
seeds: { directory: './infrastructure/database/seeds' },
},
production: { production: {
client: "pg", client: 'pg',
connection: { connection: {
host: host, host: host,
database: database, database: database,
user: user, user: user,
password: password, password: password,
},
// connection: process.env.DB_URL,
pool: {
min: 2,
max: 10,
},
migrations: {
directory: "./infrastructure/database/migrations",
},
}, },
}; // connection: process.env.DB_URL,
pool: {
min: 2,
max: 10,
},
migrations: {
directory: './infrastructure/database/migrations',
},
},
};