diff --git a/application/modules/paymentrecon/paymentrecon.controller.js b/application/modules/paymentrecon/paymentrecon.controller.js index 735c50b..1ae1427 100644 --- a/application/modules/paymentrecon/paymentrecon.controller.js +++ b/application/modules/paymentrecon/paymentrecon.controller.js @@ -73,8 +73,6 @@ const validate = (method) => { } }; - - const paymentRecon = async (req, res) => { try { // generate unique code @@ -213,6 +211,48 @@ const paymentRecon = async (req, res) => { return res.status(200).json(result); } + // check reservation status + let checkReservationCanceledStatus = + await model.checkReservationCanceledStatus(reservation_number); + if (checkReservationCanceledStatus) { + result = { + code: "431", + message: "transaction has been canceled", + data: { + payment_recon_no: PaymentReconNumber, + recon_date: moment().format("YYYY-MM-DD HH:mm:ss"), + }, + }; + + // log debug + winston.logger.debug( + `${uniqueCode} inserting payment recon transaction...` + ); + + // insert payment recon transaction + await model.insertPaymentReconTransaction( + date, + moment().format("YYYY-MM-DD HH:mm:ss"), + getPartner.partner_code, + PaymentReconNumber, + bank_ref, + reservation_number, + amount, + "F", + "FAILED", + result.code, + result.message.toUpperCase(), + result.data + ); + + // log warn + winston.logger.warn( + `${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}` + ); + + return res.status(200).json(result); + } + // check ref no and amount let check = await model.checkReservationNumberAndAmount(reservation_number); if (!check) {