From 9708f81242fc1ce83c332dd90bd5739393c08ee0 Mon Sep 17 00:00:00 2001 From: Mohamad Ihsan Date: Wed, 16 Oct 2024 18:03:22 +0700 Subject: [PATCH] remove validation card production or development --- .../loadbalance/loadbalance.controller.js | 70 ++-- .../modules/refundkmt/refundkmt.controller.js | 86 +++-- .../reservebalance.controller.js | 324 +++++++++--------- 3 files changed, 256 insertions(+), 224 deletions(-) diff --git a/application/modules/loadbalance/loadbalance.controller.js b/application/modules/loadbalance/loadbalance.controller.js index ad3cbe9..c935024 100644 --- a/application/modules/loadbalance/loadbalance.controller.js +++ b/application/modules/loadbalance/loadbalance.controller.js @@ -458,7 +458,7 @@ const loadingBalanceRequest = async (req, res) => { let cardBlacklist = await model.getCardBlacklist(card_number); if (cardBlacklist) { - if(cardBlacklist.c_status == 'B') { + if (cardBlacklist.c_status == 'B') { result = { code: '445', message: 'Card is Blacklisted', @@ -474,44 +474,44 @@ const loadingBalanceRequest = async (req, res) => { // ); // jika settingan untuk server adalah production - if (process.env.SERVER_FOR == 'production') { - // jika settingan production maka nomor kartu yang di request harus berawalan angka 1, jika bukan angka 1 maka ditolak - if (card_number.substring(0, 1) != '1') { - result = { - code: '400', - message: "It's not production card number.", - data: {}, - }; + // if (process.env.SERVER_FOR == 'production') { + // // jika settingan production maka nomor kartu yang di request harus berawalan angka 1, jika bukan angka 1 maka ditolak + // if (card_number.substring(0, 1) != '1') { + // result = { + // code: '400', + // message: "It's not production card number.", + // data: {}, + // }; - // log warn - winston.logger.warn( - `${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify( - result - )}` - ); + // // log warn + // winston.logger.warn( + // `${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify( + // result + // )}` + // ); - return res.status(200).json(result); - } - } else { - // jika settingan bukan production, bisa development atau local maka jika ada nomor kartu berawalan angka 1 maka ditolak - if (card_number.substring(0, 1) == '1') { - result = { - code: '400', - message: - "It's production card number. Please use the development card number.", - data: {}, - }; + // return res.status(200).json(result); + // } + // } else { + // // jika settingan bukan production, bisa development atau local maka jika ada nomor kartu berawalan angka 1 maka ditolak + // if (card_number.substring(0, 1) == '1') { + // result = { + // code: '400', + // message: + // "It's production card number. Please use the development card number.", + // data: {}, + // }; - // log warn - winston.logger.warn( - `${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify( - result - )}` - ); + // // log warn + // winston.logger.warn( + // `${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify( + // result + // )}` + // ); - return res.status(200).json(result); - } - } + // return res.status(200).json(result); + // } + // } // time let now = moment().format('YYYY-MM-DD HH:mm:ss'); diff --git a/application/modules/refundkmt/refundkmt.controller.js b/application/modules/refundkmt/refundkmt.controller.js index 8c5304f..c6d7c17 100644 --- a/application/modules/refundkmt/refundkmt.controller.js +++ b/application/modules/refundkmt/refundkmt.controller.js @@ -10,11 +10,20 @@ const validate = (method) => { switch (method) { case 'callbackOy': return [ - body('partner_trx_id').not().isEmpty().withMessage('Partner Trx Id is required'), + body('partner_trx_id') + .not() + .isEmpty() + .withMessage('Partner Trx Id is required'), body('trx_id').not().isEmpty().withMessage('Trx Id is required'), body('amount').not().isEmpty().withMessage('Amount is required'), - body('recipient_bank').not().isEmpty().withMessage('Recipient Bank is required'), - body('recipient_account').not().isEmpty().withMessage('Recipient Account is required'), + body('recipient_bank') + .not() + .isEmpty() + .withMessage('Recipient Bank is required'), + body('recipient_account') + .not() + .isEmpty() + .withMessage('Recipient Account is required'), ]; default: break; @@ -29,7 +38,18 @@ const callbackOy = async (req, res) => { let result = {}; // param - let { status, amount, recipient_name, recipient_bank, recipient_account, trx_id, partner_trx_id, timestamp, created_date, last_updated_date } = req.body; + let { + status, + amount, + recipient_name, + recipient_bank, + recipient_account, + trx_id, + partner_trx_id, + timestamp, + created_date, + last_updated_date, + } = req.body; // log info winston.logger.info( @@ -52,7 +72,7 @@ const callbackOy = async (req, res) => { return res.status(200).json(result); } - + // time let now = moment().format('YYYY-MM-DD HH:mm:ss'); winston.logger.warn( @@ -61,8 +81,14 @@ const callbackOy = async (req, res) => { let recipient_bank_code = recipient_bank.toLowerCase(); // check trx_id yang di request match - let checkRequest = await model.checkRedeem(partner_trx_id, trx_id, amount, recipient_bank_code, recipient_account); - + let checkRequest = await model.checkRedeem( + partner_trx_id, + trx_id, + amount, + recipient_bank_code, + recipient_account + ); + if (!checkRequest) { result = { code: '400', @@ -89,56 +115,62 @@ const callbackOy = async (req, res) => { `${uniqueCode} [ checkRequest ]: ${JSON.stringify(checkRequest)}` ); - if(status.code != '000') { + if (status.code != '000') { result = { code: '400', message: status.message, data: { trx_id: trx_id, partner_trx_id: partner_trx_id, - amount: amount, - recipient_bank: recipient_bank_code, + amount: amount, + recipient_bank: recipient_bank_code, recipient_account: recipient_account, }, }; } const unixTimeZero = Date.parse(last_updated_date); - const date_reimbursement = moment(unixTimeZero).format("YYYY-MM-DD HH:mm:ss") + const date_reimbursement = moment(unixTimeZero).format( + 'YYYY-MM-DD HH:mm:ss' + ); //Update Card Replacement - await model.updateReplacementComplete(checkRequest.i_card_replacement, checkRequest.c_request_no, date_reimbursement); + await model.updateReplacementComplete( + checkRequest.i_card_replacement, + checkRequest.c_request_no, + date_reimbursement + ); //Notif Email let urlCMS = ''; if (process.env.SERVER_FOR == 'production') { - urlCMS = 'https://cms.kci.id'; - } else if(process.env.SERVER_FOR == 'development') { - urlCMS = 'http://10.20.14.18'; + urlCMS = 'https://cms.kci.id'; + } else if (process.env.SERVER_FOR == 'development') { + urlCMS = 'http://10.20.14.69'; } else { urlCMS = 'http://localhost:8000'; } let axios = require('axios'); - - const url = urlCMS + '/api/redeem/notifemail' - console.log('urlCMS', url) + + const url = urlCMS + '/api/redeem/notifemail'; + console.log('urlCMS', url); // let resp = await axios.post(url, body, config); const responseMail = await axios({ method: 'post', url: url, headers: { - 'Content-Type': 'application/json' - }, + 'Content-Type': 'application/json', + }, data: { i_card_replacement: checkRequest.i_card_replacement?.trim(), c_request_no: checkRequest.c_request_no?.trim(), c_card_no: checkRequest.c_card_no?.trim(), - status: 'complete' - } + status: 'complete', + }, }); - console.log('urlCMS', url) + console.log('urlCMS', url); result = { code: '00', @@ -146,10 +178,10 @@ const callbackOy = async (req, res) => { data: { trx_id: trx_id, partner_trx_id: partner_trx_id, - amount: amount, - recipient_bank: recipient_bank, + amount: amount, + recipient_bank: recipient_bank, recipient_account: recipient_account, - last_updated_date: last_updated_date + last_updated_date: last_updated_date, }, }; @@ -178,5 +210,5 @@ const callbackOy = async (req, res) => { module.exports = { validate, - callbackOy + callbackOy, }; diff --git a/application/modules/reservebalance/reservebalance.controller.js b/application/modules/reservebalance/reservebalance.controller.js index d451d9c..6d5b4b1 100644 --- a/application/modules/reservebalance/reservebalance.controller.js +++ b/application/modules/reservebalance/reservebalance.controller.js @@ -162,42 +162,42 @@ const checkReservation = async (req, res) => { } // jika settingan diperuntukan untuk production - if (process.env.SERVER_FOR == 'production') { - // kartu yang di request bukan kartu production maka akan di tolak - if (card_number.substring(0, 1) != '1') { - result = { - code: '400', - message: "It's not production card number.", - data: {}, - }; + // if (process.env.SERVER_FOR == 'production') { + // // kartu yang di request bukan kartu production maka akan di tolak + // if (card_number.substring(0, 1) != '1') { + // result = { + // code: '400', + // message: "It's not production card number.", + // data: {}, + // }; - // log warn - // winston.logger.warn( - // `${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify( - // result - // )}` - // ); + // // log warn + // // winston.logger.warn( + // // `${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify( + // // result + // // )}` + // // ); - return res.status(200).json(result); - } - } else { - // jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak - if (card_number.substring(0, 1) == '1') { - result = { - code: '400', - message: - "It's production card number. Please use the development card number.", - data: {}, - }; - // log warn - // winston.logger.warn( - // `${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify( - // result - // )}` - // ); - return res.status(200).json(result); - } - } + // return res.status(200).json(result); + // } + // } else { + // // jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak + // if (card_number.substring(0, 1) == '1') { + // result = { + // code: '400', + // message: + // "It's production card number. Please use the development card number.", + // data: {}, + // }; + // // log warn + // // winston.logger.warn( + // // `${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify( + // // result + // // )}` + // // ); + // return res.status(200).json(result); + // } + // } // log debug // proses pengecekkan data partner berdasarkan mid dan tid yang di request, apakah terdaftar di sistem CMS atau tidak @@ -368,44 +368,44 @@ const reservationValidate = async (req, res) => { } // jika settingan diperuntukan untuk production - if (process.env.SERVER_FOR == 'production') { - // kartu yang di request bukan kartu production maka akan di tolak - if (card_number.substring(0, 1) != '1') { - result = { - code: '400', - message: "It's not production card number.", - data: {}, - }; + // if (process.env.SERVER_FOR == 'production') { + // // kartu yang di request bukan kartu production maka akan di tolak + // if (card_number.substring(0, 1) != '1') { + // result = { + // code: '400', + // message: "It's not production card number.", + // data: {}, + // }; - // log warn - winston.logger.warn( - `${uniqueCode} [ RESPONSE RESERVATION-VALIDATE ]: ${JSON.stringify( - result - )}` - ); + // // log warn + // winston.logger.warn( + // `${uniqueCode} [ RESPONSE RESERVATION-VALIDATE ]: ${JSON.stringify( + // result + // )}` + // ); - return res.status(200).json(result); - } - } else { - // jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak - if (card_number.substring(0, 1) == '1') { - result = { - code: '400', - message: - "It's production card number. Please use the development card number.", - data: {}, - }; + // return res.status(200).json(result); + // } + // } else { + // // jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak + // if (card_number.substring(0, 1) == '1') { + // result = { + // code: '400', + // message: + // "It's production card number. Please use the development card number.", + // data: {}, + // }; - // log warn - winston.logger.warn( - `${uniqueCode} [ RESPONSE RESERVATION-VALIDATE ]: ${JSON.stringify( - result - )}` - ); + // // log warn + // winston.logger.warn( + // `${uniqueCode} [ RESPONSE RESERVATION-VALIDATE ]: ${JSON.stringify( + // result + // )}` + // ); - return res.status(200).json(result); - } - } + // return res.status(200).json(result); + // } + // } // time let now = moment().format('YYYY-MM-DD HH:mm:ss'); @@ -813,44 +813,44 @@ const reservationValidateV2 = async (req, res) => { // ); // jika settingan diperuntukan untuk production - if (process.env.SERVER_FOR == 'production') { - // kartu yang di request bukan kartu production maka akan di tolak - if (card_number.substring(0, 1) != '1') { - result = { - code: '400', - message: "It's not production card number.", - data: {}, - }; + // if (process.env.SERVER_FOR == 'production') { + // // kartu yang di request bukan kartu production maka akan di tolak + // if (card_number.substring(0, 1) != '1') { + // result = { + // code: '400', + // message: "It's not production card number.", + // data: {}, + // }; - // log warn - winston.logger.warn( - `${uniqueCode} [ RESPONSE RESERVATION-VALIDATE-V2 ]: ${JSON.stringify( - result - )}` - ); + // // log warn + // winston.logger.warn( + // `${uniqueCode} [ RESPONSE RESERVATION-VALIDATE-V2 ]: ${JSON.stringify( + // result + // )}` + // ); - return res.status(200).json(result); - } - } else { - // jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak - if (card_number.substring(0, 1) == '1') { - result = { - code: '400', - message: - "It's production card number. Please use the development card number.", - data: {}, - }; + // return res.status(200).json(result); + // } + // } else { + // // jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak + // if (card_number.substring(0, 1) == '1') { + // result = { + // code: '400', + // message: + // "It's production card number. Please use the development card number.", + // data: {}, + // }; - // log warn - winston.logger.warn( - `${uniqueCode} [ RESPONSE RESERVATION-VALIDATE-V2 ]: ${JSON.stringify( - result - )}` - ); + // // log warn + // winston.logger.warn( + // `${uniqueCode} [ RESPONSE RESERVATION-VALIDATE-V2 ]: ${JSON.stringify( + // result + // )}` + // ); - return res.status(200).json(result); - } - } + // return res.status(200).json(result); + // } + // } // time let now = moment().format('YYYY-MM-DD HH:mm:ss'); @@ -1307,40 +1307,40 @@ const reservation = async (req, res) => { } // jika settingan diperuntukan untuk production - if (process.env.SERVER_FOR == 'production') { - // kartu yang di request bukan kartu production maka akan di tolak - if (card_number.substring(0, 1) != '1') { - result = { - code: '400', - message: "It's not production card number.", - data: {}, - }; + // if (process.env.SERVER_FOR == 'production') { + // // kartu yang di request bukan kartu production maka akan di tolak + // if (card_number.substring(0, 1) != '1') { + // result = { + // code: '400', + // message: "It's not production card number.", + // data: {}, + // }; - // log warn - winston.logger.warn( - `${uniqueCode} [ RESPONSE RESERVATION ]: ${JSON.stringify(result)}` - ); + // // log warn + // winston.logger.warn( + // `${uniqueCode} [ RESPONSE RESERVATION ]: ${JSON.stringify(result)}` + // ); - return res.status(200).json(result); - } - } else { - // jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak - if (card_number.substring(0, 1) == '1') { - result = { - code: '400', - message: - "It's production card number. Please use the development card number.", - data: {}, - }; + // return res.status(200).json(result); + // } + // } else { + // // jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak + // if (card_number.substring(0, 1) == '1') { + // result = { + // code: '400', + // message: + // "It's production card number. Please use the development card number.", + // data: {}, + // }; - // log warn - winston.logger.warn( - `${uniqueCode} [ RESPONSE RESERVATION ]: ${JSON.stringify(result)}` - ); + // // log warn + // winston.logger.warn( + // `${uniqueCode} [ RESPONSE RESERVATION ]: ${JSON.stringify(result)}` + // ); - return res.status(200).json(result); - } - } + // return res.status(200).json(result); + // } + // } // time let now = moment().format('YYYY-MM-DD HH:mm:ss'); @@ -2122,40 +2122,40 @@ const reservationV2 = async (req, res) => { // ); // jika settingan diperuntukan untuk production - if (process.env.SERVER_FOR == 'production') { - // kartu yang di request bukan kartu production maka akan di tolak - if (card_number.substring(0, 1) != '1') { - result = { - code: '400', - message: "It's not production card number.", - data: {}, - }; + // if (process.env.SERVER_FOR == 'production') { + // // kartu yang di request bukan kartu production maka akan di tolak + // if (card_number.substring(0, 1) != '1') { + // result = { + // code: '400', + // message: "It's not production card number.", + // data: {}, + // }; - // log warn - winston.logger.warn( - `${uniqueCode} [ RESPONSE RESERVATION-V2 ]: ${JSON.stringify(result)}` - ); + // // log warn + // winston.logger.warn( + // `${uniqueCode} [ RESPONSE RESERVATION-V2 ]: ${JSON.stringify(result)}` + // ); - return res.status(200).json(result); - } - } else { - // jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak - if (card_number.substring(0, 1) == '1') { - result = { - code: '400', - message: - "It's production card number. Please use the development card number.", - data: {}, - }; + // return res.status(200).json(result); + // } + // } else { + // // jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak + // if (card_number.substring(0, 1) == '1') { + // result = { + // code: '400', + // message: + // "It's production card number. Please use the development card number.", + // data: {}, + // }; - // log warn - winston.logger.warn( - `${uniqueCode} [ RESPONSE RESERVATION-V2 ]: ${JSON.stringify(result)}` - ); + // // log warn + // winston.logger.warn( + // `${uniqueCode} [ RESPONSE RESERVATION-V2 ]: ${JSON.stringify(result)}` + // ); - return res.status(200).json(result); - } - } + // return res.status(200).json(result); + // } + // } // time let now = moment().format('YYYY-MM-DD HH:mm:ss');