- added digiflazz supplier
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import axios from 'axios';
|
||||
import cryptoMd5 from "crypto";
|
||||
|
||||
const irs_url = 'http://h2h.elangpixiu.com/api/h2h';
|
||||
const irs_id = 'PT0005';
|
||||
@@ -7,32 +8,112 @@ const irs_user = 'D10BD0';
|
||||
const irs_pass = '6251F3';
|
||||
|
||||
export const doTransaction = async (
|
||||
productCode,
|
||||
destination,
|
||||
idtrx,
|
||||
supplier,
|
||||
authorization,
|
||||
typePaid,
|
||||
productCode,
|
||||
destination,
|
||||
idtrx,
|
||||
supplier,
|
||||
authorization,
|
||||
typePaid,
|
||||
billTrxId,
|
||||
) => {
|
||||
try {
|
||||
if (supplier.code == 'IRS') {
|
||||
const res = await 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}`,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
} else if (supplier.code == 'NIRS') {
|
||||
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;
|
||||
} else if (supplier.code == 'Hemat') {
|
||||
if (authorization != "") {
|
||||
console.log("initoken", authorization)
|
||||
} else if (supplier.code == 'Digiflazz') {
|
||||
if (typePaid == 'INQUIRY') {
|
||||
const md5HashDigiflazz = `${irs_user}${irs_pass}${idtrx}`;
|
||||
const cryptoMd5 = require('crypto');
|
||||
|
||||
cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex');
|
||||
|
||||
const options = {
|
||||
headers: {'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + authorization}
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
};
|
||||
const data = {
|
||||
commands: 'inq-pasca',
|
||||
username: irs_user,
|
||||
customer_no: `${destination}`,
|
||||
buyer_sku_code: `${productCode}`,
|
||||
ref_id: `${idtrx}`,
|
||||
sign: cryptoMd5,
|
||||
testing: true,
|
||||
};
|
||||
const res = await axios.post(
|
||||
`${supplier.url}/v1/transaction`,
|
||||
data,
|
||||
options,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
} else if (typePaid == 'PAYMENT') {
|
||||
const md5HashDigiflazz = `${irs_user}${irs_pass}${idtrx}`;
|
||||
const cryptoMd5 = require('crypto');
|
||||
|
||||
cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex');
|
||||
|
||||
const options = {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
};
|
||||
const data = {
|
||||
commands: 'pay-pasca',
|
||||
username: irs_user,
|
||||
customer_no: `${destination}`,
|
||||
buyer_sku_code: `${productCode}`,
|
||||
ref_id: `${billTrxId}`,
|
||||
sign: cryptoMd5,
|
||||
testing: true,
|
||||
};
|
||||
const res = await axios.post(
|
||||
`${supplier.url}/v1/transaction`,
|
||||
data,
|
||||
options,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
} else {
|
||||
const md5HashDigiflazz = `${irs_user}${irs_pass}${idtrx}`;
|
||||
const cryptoMd5 = require('crypto');
|
||||
|
||||
cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex');
|
||||
|
||||
const options = {
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
};
|
||||
const data = {
|
||||
username: irs_user,
|
||||
customer_no: `${destination}`,
|
||||
buyer_sku_code: `${productCode}`,
|
||||
ref_id: `${idtrx}`,
|
||||
sign: cryptoMd5,
|
||||
testing: true,
|
||||
};
|
||||
const res = await axios.post(
|
||||
`${supplier.url}/v1/transaction`,
|
||||
data,
|
||||
options,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
}
|
||||
} else if (supplier.code == 'Hemat') {
|
||||
if (authorization != '') {
|
||||
console.log('initoken', authorization);
|
||||
|
||||
const options = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${authorization}`,
|
||||
},
|
||||
};
|
||||
const data = {
|
||||
idtransaction: idtrx,
|
||||
@@ -40,25 +121,30 @@ export const doTransaction = async (
|
||||
code: `${productCode}`,
|
||||
type: `${typePaid}`,
|
||||
};
|
||||
const res = await axios.post(`${supplier.url}/v1/transaction/request`, data, options);
|
||||
const res = await axios.post(
|
||||
`${supplier.url}/v1/transaction/request`,
|
||||
data,
|
||||
options,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
}
|
||||
}
|
||||
|
||||
const res = await axios.get(
|
||||
`${supplier.url}?memberID=${supplier.irs_id}&pin=${supplier.irs_pin}&password=${supplier.irs_pass}&product=${productCode}&dest=${destination}&counter=1&refID=${idtrx}`,
|
||||
`${supplier.url}?memberID=${supplier.irs_id}&pin=${supplier.irs_pin}&password=${supplier.irs_pass}&product=${productCode}&dest=${destination}&counter=1&refID=${idtrx}`,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
|
||||
console.log('restranshemat', res)
|
||||
console.log('restranshemat', res);
|
||||
} catch (err) {
|
||||
console.log('errtranshemat', err);
|
||||
|
||||
if (err.includes('Maaf Saldo anda tidak mencukupi')) {
|
||||
throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali';
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user