mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 10:56:27 +00:00
compare partner token and partner request
This commit is contained in:
+16
-16
@@ -1,8 +1,8 @@
|
||||
const moment = require("moment");
|
||||
const winston = require("winston");
|
||||
const loki = require("winston-loki");
|
||||
require("winston-daily-rotate-file");
|
||||
require("dotenv").config();
|
||||
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;
|
||||
|
||||
@@ -18,32 +18,32 @@ var log;
|
||||
|
||||
const fileRotateTransport = new winston.transports.DailyRotateFile({
|
||||
filename: `./lokiLog/%DATE%-onlinetopup.log`,
|
||||
datePattern: "YYYY-MM-DD",
|
||||
maxFiles: "1d",
|
||||
datePattern: 'YYYY-MM-DD',
|
||||
maxFiles: '1d',
|
||||
});
|
||||
|
||||
if (
|
||||
process.env.NODE_ENV == "production" ||
|
||||
process.env.NODE_ENV == "PRODUCTION"
|
||||
process.env.NODE_ENV == 'production' ||
|
||||
process.env.NODE_ENV == 'PRODUCTION'
|
||||
) {
|
||||
log = winston.createLogger({
|
||||
levels: logLevels,
|
||||
level: process.env.LOG_LEVEL || "info",
|
||||
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",
|
||||
format: 'YYYY-MM-DD HH:mm:ss.SSS',
|
||||
}),
|
||||
align(),
|
||||
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
|
||||
),
|
||||
defaultMeta: { service: "topuponline" },
|
||||
defaultMeta: { service: 'topuponline' },
|
||||
transports: [
|
||||
new loki({
|
||||
host: lokiUrl,
|
||||
labels: { app: "topuponline" },
|
||||
labels: { app: 'topuponline' },
|
||||
json: true,
|
||||
format: json(),
|
||||
replaceTimestamp: true,
|
||||
@@ -59,7 +59,7 @@ if (
|
||||
transports: [
|
||||
new loki({
|
||||
host: lokiUrl,
|
||||
labels: { app: "topuponline" },
|
||||
labels: { app: 'topuponline' },
|
||||
handleExceptions: true,
|
||||
handleRejections: true,
|
||||
clearOnError: true,
|
||||
@@ -75,14 +75,14 @@ if (
|
||||
});
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV != "testing" && process.env.NODE_ENV != "TESTING") {
|
||||
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",
|
||||
format: 'YYYY-MM-DD HH:mm:ss.SSS',
|
||||
}),
|
||||
align(),
|
||||
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
|
||||
|
||||
@@ -530,6 +530,16 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// get parameter setting pengecekkan nomor kartu dengan card product di CMS
|
||||
let getCheckByCardProductStatusValue =
|
||||
await model.getCheckByCardProductStatusValue();
|
||||
@@ -1251,6 +1261,16 @@ const loadingBalanceInsert = async (req, param) => {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log warn
|
||||
// winston.logger.warn(
|
||||
// `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking reservation status...`
|
||||
@@ -1761,6 +1781,16 @@ const loadingBalanceUpdate = async (param) => {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let data = {
|
||||
d_load_balance: now,
|
||||
c_ref_no: ref_no,
|
||||
|
||||
@@ -119,6 +119,9 @@ const checkReservation = async (req, res) => {
|
||||
`${uniqueCode} [ REQUEST RESERVATION-CHECK ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// trim card number
|
||||
card_number = card_number.trim();
|
||||
|
||||
// check validator
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -209,6 +212,16 @@ const checkReservation = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// lakukan pencarian ke table reservasion, apakah nomor kartu yang di request masih mempunyai transaksi reservasi saldo yang status nya masih pending atau in progress
|
||||
// winston.logger.debug(
|
||||
@@ -288,6 +301,9 @@ const reservationValidate = async (req, res) => {
|
||||
)}`
|
||||
);
|
||||
|
||||
// trim card number
|
||||
card_number = card_number.trim();
|
||||
|
||||
// check validator
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -388,6 +404,16 @@ const reservationValidate = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// get settingan dari parameter apakah nomor kartu yang di request harus di cek dengan data card product CMS atau tidak
|
||||
// winston.logger.debug(
|
||||
@@ -708,6 +734,9 @@ const reservationValidateV2 = async (req, res) => {
|
||||
)}`
|
||||
);
|
||||
|
||||
// trim card number
|
||||
card_number = card_number.trim();
|
||||
|
||||
// check validator
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -808,6 +837,16 @@ const reservationValidateV2 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// get settingan dari parameter apakah nomor kartu yang di request harus di cek dengan data card product CMS atau tidak
|
||||
// winston.logger.debug(
|
||||
@@ -1179,6 +1218,9 @@ const reservation = async (req, res) => {
|
||||
`${uniqueCode} [ REQUEST RESERVATION ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// trim card number
|
||||
card_number = card_number.trim();
|
||||
|
||||
// check validator
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -1269,6 +1311,16 @@ const reservation = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// get settingan dari parameter apakah nomor kartu yang di request harus di cek dengan data card product CMS atau tidak
|
||||
// winston.logger.debug(
|
||||
@@ -1829,6 +1881,9 @@ const reservationV2 = async (req, res) => {
|
||||
`${uniqueCode} [ REQUEST RESERVATION-V2 ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// trim card number
|
||||
card_number = card_number.trim();
|
||||
|
||||
// check validator
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -2057,6 +2112,16 @@ const reservationV2 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// get settingan dari parameter apakah nomor kartu yang di request harus di cek dengan data card product CMS atau tidak
|
||||
// winston.logger.debug(
|
||||
@@ -2697,6 +2762,16 @@ const cancelReservationValidate = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// proses pengecekkan status reservation number yang di request
|
||||
// winston.logger.debug(
|
||||
@@ -2882,6 +2957,16 @@ const cancelReservation = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// proses pengecekkan status reservation number yang di request
|
||||
// winston.logger.debug(
|
||||
@@ -3358,6 +3443,16 @@ const cancelReservationValidateV2 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let getReservationCanBeCanceled;
|
||||
|
||||
// jika cancelation reservation dilakukan dengan menggunakan ref no
|
||||
@@ -3776,6 +3871,16 @@ const cancelReservationV2 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// proses pengecekkan status reservation number yang di request
|
||||
// winston.logger.debug(
|
||||
@@ -4022,6 +4127,16 @@ const cancelReservationV2_1 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// proses pengecekkan status reservation number yang di request
|
||||
// winston.logger.debug(
|
||||
@@ -4279,6 +4394,16 @@ const getFeeSharing = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// set default issuer fee
|
||||
let issuerFee = 0;
|
||||
let channelFee = 0;
|
||||
@@ -4333,6 +4458,51 @@ const getFeeSharing = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
const decrpytRequest = 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 { reservation_data } = req.body;
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ REQUEST DECRYPT ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
reservationData = helper.decryptText(reservation_data);
|
||||
// parsing data to json format
|
||||
parseData = JSON.parse(reservationData);
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'decrypted successfully.',
|
||||
data: parseData,
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE DECRYPT ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
result = {
|
||||
code: '500',
|
||||
message: 'decrypted failed.',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.error(
|
||||
`${uniqueCode} [ RESPONSE DECRYPT ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
validate,
|
||||
checkReservation,
|
||||
@@ -4349,4 +4519,5 @@ module.exports = {
|
||||
cancelReservationV2,
|
||||
cancelReservationV2_1,
|
||||
getFeeSharing,
|
||||
decrpytRequest,
|
||||
};
|
||||
|
||||
@@ -98,6 +98,12 @@ router.post(
|
||||
controller.getFeeSharing
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/reservation/decrypt',
|
||||
auth.authenticateToken,
|
||||
controller.decrpytRequest
|
||||
);
|
||||
|
||||
// router.post(
|
||||
// '/reservation/cancel/v2.1',
|
||||
// auth.authenticateToken,
|
||||
|
||||
Reference in New Issue
Block a user