-fix transaction api error 401 for hemat

This commit is contained in:
Fadli 2022-09-26 22:12:55 +07:00
parent 7cd52a5998
commit a218b949b4
3 changed files with 21 additions and 23 deletions

View File

@ -28,18 +28,21 @@ export const doTransaction = async (
return res.data;
} else if (supplier.code == 'Hemat') {
const options = {
headers: { Authorization: `${authorization}` },
};
const data = {
idtransaction: idtrx,
destination: `${destination}`,
code: `${productCode}`,
type: `${typePaid}`,
};
const res = await axios.post(`${supplier.url}/v1/transaction/request`, data, options);
if (authorization != "") {
console.log("initoken", authorization)
const options = {
headers: {'Authorization': 'Bearer ' + authorization}
};
const data = {
idtransaction: idtrx,
destination: `${destination}`,
code: `${productCode}`,
type: `${typePaid}`,
};
const res = await axios.post(`${supplier.url}/v1/transaction/request`, data, options);
return res.data;
return res.data;
}
}
const res = await axios.get(
@ -47,7 +50,9 @@ export const doTransaction = async (
);
return res.data;
console.log('restranshemat', res)
} catch (err) {
console.log('errtranshemat', err)
throw err;
}
};

View File

@ -10,6 +10,7 @@ export const doAuthorizeHemat = async (user, pass, supplier) => {
return res.data;
} catch (err) {
console.log('errauthhemat', err)
throw err;
}
};

View File

@ -589,10 +589,7 @@ export class TransactionService {
})
.join('');
const hitLoginHemat =
supplier.code == 'Hemat' ?
await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier) :
'';
const hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier);
let hitSupplier = await doTransaction(
orderTransactionDto.productCode,
@ -604,6 +601,7 @@ export class TransactionService {
);
// let hitSupplier;
console.log('iniresponsupplier', hitSupplier)
if (supplier.code != 'IRS') {
const parsingResponse = hitSupplier.split(' ');
const newHitSupplier = {
@ -804,10 +802,7 @@ export class TransactionService {
})
.join('');
const hitLoginHemat =
supplier.code == 'Hemat' ?
await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier) :
'';
const hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier);
let hitSupplier = await doTransaction(
orderTransactionDto.productCode,
@ -950,10 +945,7 @@ export class TransactionService {
let status;
try {
const hitLoginHemat =
supplier.code == 'Hemat' ?
await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier) :
'';
const hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier);
let hitSupplier = await doTransaction(
`CEK${orderTransactionDto.productCode.slice(3)}`,