mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 10:46:28 +00:00
add check balance to CTS
This commit is contained in:
@@ -1310,19 +1310,47 @@ const validateRedeem = async (req, res) => {
|
||||
|
||||
last_balance = dataCardReplacement.i_last_balance;
|
||||
if (last_balance == null) {
|
||||
result = {
|
||||
code: '415',
|
||||
message: 'Last Balance not updated.',
|
||||
data: {
|
||||
status: false,
|
||||
detail: {},
|
||||
let result = {};
|
||||
// const baseUrl = 'https://appdev.kci.id/cts/v2/api/info/last-balance'
|
||||
const baseUrl = `${process.env.CTS_URL}/v2/api/info/last-balance`
|
||||
const payload = {
|
||||
card_number: card_number,
|
||||
};
|
||||
let config = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
};
|
||||
//LOG-INFO
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE VALIDATE-REDEEM ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
return res.status(200).json(result);
|
||||
const url = baseUrl;
|
||||
const response = await axios.post(url, payload, config);
|
||||
if (response.data.code == undefined || response.data.code != 200) {
|
||||
if (response.data.code == 404) {
|
||||
result = {
|
||||
code: '494',
|
||||
message: 'No data found in CTS for the given card number',
|
||||
data: {
|
||||
status: false,
|
||||
detail: {}
|
||||
}
|
||||
};
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ FAILED HIT - card_number : ${card_number} ]: ${response.data.message}`
|
||||
);
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
result = {
|
||||
code: '415',
|
||||
message: 'Last Balance not updated.',
|
||||
data: {
|
||||
status: false,
|
||||
detail: {}
|
||||
},
|
||||
};
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ FAILED HIT - card_number : ${card_number} ]: ${response.data.message}`
|
||||
);
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
let security_code = await helper.createHMAC(card_number);
|
||||
|
||||
Reference in New Issue
Block a user