Merge branch 'development' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into devops-staging
This commit is contained in:
commit
0c7a9a68ab
|
@ -8,24 +8,54 @@ const irs_user = 'D10BD0';
|
||||||
const irs_pass = '6251F3';
|
const irs_pass = '6251F3';
|
||||||
|
|
||||||
export const doTransaction = async (
|
export const doTransaction = async (
|
||||||
productCode,
|
productCode,
|
||||||
destination,
|
destination,
|
||||||
idtrx,
|
idtrx,
|
||||||
supplier,
|
supplier,
|
||||||
authorization,
|
authorization,
|
||||||
typePaid,
|
typePaid,
|
||||||
billTrxId,
|
billTrxId,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
if (supplier.code == 'IRS') {
|
if (supplier.code == 'IRS') {
|
||||||
const res = await axios.get(
|
axios.get(`${irs_url}?id=${irs_id}&pin=${irs_pin}&user=${irs_user}&pass=${irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`)
|
||||||
`${irs_url}?id=${irs_id}&pin=${irs_pin}&user=${irs_user}&pass=${irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`,
|
.then(res => {
|
||||||
);
|
// Handle successful response
|
||||||
|
if (res.data.includes('saldo tidak cukup')) {
|
||||||
return res.data;
|
throw new HttpException(
|
||||||
|
{
|
||||||
|
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
error: 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali',
|
||||||
|
},
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
// Handle error
|
||||||
|
if (e.error.includes('saldo tidak cukup')) {
|
||||||
|
throw new HttpException(
|
||||||
|
{
|
||||||
|
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
error: 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali',
|
||||||
|
},
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new HttpException(
|
||||||
|
{
|
||||||
|
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
error: e.error,
|
||||||
|
},
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (supplier.code == 'NIRS') {
|
} else if (supplier.code == 'NIRS') {
|
||||||
const res = await axios.get(
|
const res = await axios.get(
|
||||||
`${supplier.url}?id=${supplier.irs_id}&pin=${supplier.irs_pin}&user=${supplier.irs_user}&pass=${supplier.irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`,
|
`${supplier.url}?id=${supplier.irs_id}&pin=${supplier.irs_pin}&user=${supplier.irs_user}&pass=${supplier.irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return res.data;
|
return res.data;
|
||||||
|
@ -114,9 +144,9 @@ export const doTransaction = async (
|
||||||
type: `${typePaid}`,
|
type: `${typePaid}`,
|
||||||
};
|
};
|
||||||
const res = await axios.post(
|
const res = await axios.post(
|
||||||
`${supplier.url}/v1/transaction/request`,
|
`${supplier.url}/v1/transaction/request`,
|
||||||
data,
|
data,
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
|
|
||||||
return res.data;
|
return res.data;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user