mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 10:46:28 +00:00
Compare commits
3 Commits
297c3d7323
...
85fa8843d8
| Author | SHA1 | Date | |
|---|---|---|---|
| 85fa8843d8 | |||
| 005746e29f | |||
| 34610e9515 |
@@ -295,8 +295,20 @@ const validateReplacement = async (req, res) => {
|
||||
|
||||
// if (is_warranty == true) {
|
||||
let result = {};
|
||||
const ctsUrl = process.env.CTS_URL?.trim();
|
||||
if (!ctsUrl) {
|
||||
return res.status(200).json({
|
||||
code: '500',
|
||||
message: 'CTS connection has not been configured.',
|
||||
data: {
|
||||
status: false,
|
||||
detail: {},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// const baseUrl = 'https://appdev.kci.id/cts/v2/api/info/last-balance'
|
||||
const baseUrl = `${process.env.CTS_URL}/v2/api/info/last-balance`;
|
||||
const baseUrl = `${ctsUrl}/v2/api/info/last-balance`;
|
||||
const payload = {
|
||||
card_number: card_number,
|
||||
};
|
||||
@@ -306,7 +318,22 @@ const validateReplacement = async (req, res) => {
|
||||
},
|
||||
};
|
||||
const url = baseUrl;
|
||||
const response = await postWithDeadline(url, payload, config);
|
||||
let response;
|
||||
try {
|
||||
response = await postWithDeadline(url, payload, config);
|
||||
} catch (error) {
|
||||
winston.logger.warn(
|
||||
`${logCorrelation(uniqueCode)} [ CTS REQUEST FAILED ] error_code=${logErrorCode(error)}`
|
||||
);
|
||||
return res.status(200).json({
|
||||
code: '415',
|
||||
message: 'Failed to retrieve last balance from CTS.',
|
||||
data: {
|
||||
status: false,
|
||||
detail: {},
|
||||
},
|
||||
});
|
||||
}
|
||||
if (response.data.code == undefined || response.data.code != 200) {
|
||||
if (response.data.code == 404) {
|
||||
result = {
|
||||
@@ -324,7 +351,7 @@ const validateReplacement = async (req, res) => {
|
||||
}
|
||||
result = {
|
||||
code: '415',
|
||||
message: 'Last Balance not updated.',
|
||||
message: 'Failed to retrieve last balance from CTS.',
|
||||
data: {
|
||||
status: false,
|
||||
detail: {},
|
||||
@@ -391,7 +418,6 @@ const validateReplacement = async (req, res) => {
|
||||
unique_code: uniqueCode,
|
||||
card_category: {
|
||||
id: dataCardReplacement.card_category_id,
|
||||
code: dataCardReplacement.card_category_code,
|
||||
name: dataCardReplacement.card_category_name
|
||||
}
|
||||
},
|
||||
|
||||
@@ -20,25 +20,25 @@ auth:bearer {
|
||||
|
||||
body:json {
|
||||
{
|
||||
"card_number": "0000000000000001",
|
||||
"station_code": "TEST01"
|
||||
"card_number": "1003012302000000",
|
||||
"station_code": "BOO"
|
||||
}
|
||||
}
|
||||
|
||||
docs {
|
||||
### Deskripsi
|
||||
Memeriksa kelayakan kartu untuk penggantian dan menyiapkan data konfirmasi.
|
||||
|
||||
|
||||
### Request
|
||||
- Endpoint POST /api/pos/cardreplacement/validate
|
||||
- Kirim Authorization: Bearer dengan accessToken dari login.
|
||||
- Contoh JSON tersedia di tab Body.
|
||||
- Route tidak membaca query atau path parameter tambahan.
|
||||
|
||||
|
||||
### Respons
|
||||
|
||||
|
||||
Handler umumnya mengembalikan HTTP 200. Untuk hasil aplikasi, periksa field code, message, dan data. Gunakan header X-Request-Id untuk pencarian log.
|
||||
|
||||
|
||||
| Code | Message |
|
||||
| --- | --- |
|
||||
| 00 | Successfully. |
|
||||
@@ -60,10 +60,10 @@ docs {
|
||||
| 494 | No data found in CTS for the given card number |
|
||||
| 500 | *Pesan kegagalan dapat berasal dari exception atau dependensi.* |
|
||||
| 500 | 500 internal server error - backend server. |
|
||||
|
||||
|
||||
**Pesan validasi yang dapat dikembalikan**
|
||||
- Card number is required
|
||||
- Station Code is required
|
||||
|
||||
|
||||
Pesan yang dicetak miring bersifat dinamis. Nilai aktual dapat mengikuti input atau hasil dari service lain.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
vars {
|
||||
baseUrl: https://dev-topup.kci.id/api
|
||||
reservationData: ISI_DARI_LINGKUNGAN_UJI
|
||||
cancelReservationData: ISI_DARI_LINGKUNGAN_UJI
|
||||
replacementUniqueCode: SAMPLE-HSM-01
|
||||
replacementSecurityCode: ISI_DARI_LINGKUNGAN_UJI
|
||||
redeemSecurityCode: ISI_DARI_LINGKUNGAN_UJI
|
||||
topupStep1Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
topupStep2Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
topupUniqueCode: SAMPLE-HSM-01
|
||||
topupTrxId: 0001
|
||||
topupStep3Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
topupStep4Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
topupStep5Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
topupStep6Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
topupStep7Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
topupLoadBalanceNumber: ISI_DARI_LINGKUNGAN_UJI
|
||||
clearStep1Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
clearStep2Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
clearUniqueCode: SAMPLE-HSM-01
|
||||
clearTrxId: 0001
|
||||
clearStep3Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
clearStep4Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
clearStep5Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
clearStep6Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
clearStep7Data: ISI_DARI_LINGKUNGAN_UJI
|
||||
}
|
||||
vars:secret [
|
||||
accessToken,
|
||||
refreshToken
|
||||
]
|
||||
Reference in New Issue
Block a user