- added digiflazz supplier
This commit is contained in:
@@ -152,4 +152,25 @@ export class PpobCallbackController {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Post('/digiflazz')
|
||||
async getDigiflazz(@Req() request: FastifyRequest) {
|
||||
const response = request.body;
|
||||
console.log('responsehemat', response);
|
||||
console.log('responsehemat2', request.body);
|
||||
if (response['msg'] != 'Transaksi Sukses') {
|
||||
//TODO: UPDATE GAGAL
|
||||
await this.transactionService.checkCallbackOrderFailed(
|
||||
response['data']['ref_id'],
|
||||
response['data'],
|
||||
);
|
||||
} else {
|
||||
//TODO: UPDATE BERHASIL
|
||||
await this.transactionService.checkCallbackOrderSuccess(
|
||||
response['data']['ref_id'],
|
||||
response['data'],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,12 +614,14 @@ export class TransactionService {
|
||||
}
|
||||
|
||||
//HIT API SUPPLIER
|
||||
const trxId = Array(11)
|
||||
.fill(null)
|
||||
.map(() => {
|
||||
return Math.round(Math.random() * 16).toString(16);
|
||||
})
|
||||
.join('');
|
||||
let trxId;
|
||||
|
||||
trxId = Array(11)
|
||||
.fill(null)
|
||||
.map(() => {
|
||||
return Math.round(Math.random() * 16).toString(16);
|
||||
})
|
||||
.join('');
|
||||
|
||||
let hitLoginHemat;
|
||||
|
||||
@@ -635,6 +637,7 @@ export class TransactionService {
|
||||
supplier,
|
||||
hitLoginHemat.data,
|
||||
product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT',
|
||||
orderTransactionDto.bill_trx_id
|
||||
) : await doTransaction(
|
||||
orderTransactionDto.productCode,
|
||||
orderTransactionDto.destination,
|
||||
@@ -642,6 +645,7 @@ export class TransactionService {
|
||||
supplier,
|
||||
"",
|
||||
product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT',
|
||||
orderTransactionDto.bill_trx_id
|
||||
);
|
||||
|
||||
// let hitSupplier;
|
||||
@@ -677,6 +681,29 @@ export class TransactionService {
|
||||
|
||||
hitSupplier = newHitSupplier;
|
||||
|
||||
if (orderTransactionDto.bill_trx_id !== null) {
|
||||
hitSupplier.harga = product_price.price;
|
||||
}
|
||||
} else if (supplier.code == 'Digiflazz') {
|
||||
let newHitSupplier;
|
||||
|
||||
if (product.type == 'prepaid') {
|
||||
newHitSupplier= {
|
||||
success: hitSupplier.status.includes('Pending') || hitSupplier.status.includes('Sukses'),
|
||||
harga: hitSupplier.price,
|
||||
msg: hitSupplier.message,
|
||||
};
|
||||
} else {
|
||||
newHitSupplier= {
|
||||
success: hitSupplier.status.includes('Pending') || hitSupplier.status.includes('Sukses'),
|
||||
harga: hitSupplier.price,
|
||||
msg: hitSupplier.message,
|
||||
sn: hitSupplier.sn,
|
||||
};
|
||||
}
|
||||
|
||||
hitSupplier = newHitSupplier;
|
||||
|
||||
if (orderTransactionDto.bill_trx_id !== null) {
|
||||
hitSupplier.harga = product_price.price;
|
||||
}
|
||||
@@ -757,8 +784,18 @@ export class TransactionService {
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
} else {
|
||||
transactionData.status = statusTransaction.PENDING;
|
||||
status = statusTransaction[transactionData.status];
|
||||
if (
|
||||
hitSupplier.sn != null ||
|
||||
hitSupplier.sn != '' ||
|
||||
hitSupplier.sn != undefined
|
||||
) {
|
||||
transactionData.seri_number = hitSupplier.sn;
|
||||
transactionData.status = statusTransaction.SUCCESS;
|
||||
status = statusTransaction[transactionData.status];
|
||||
} else {
|
||||
transactionData.status = statusTransaction.PENDING;
|
||||
status = statusTransaction[transactionData.status];
|
||||
}
|
||||
}
|
||||
|
||||
await manager.insert(Transactions, transactionData);
|
||||
@@ -882,6 +919,7 @@ export class TransactionService {
|
||||
supplier,
|
||||
hitLoginHemat.data,
|
||||
product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT',
|
||||
orderTransactionDto.bill_trx_id
|
||||
) : await doTransaction(
|
||||
orderTransactionDto.productCode,
|
||||
orderTransactionDto.destination,
|
||||
@@ -889,6 +927,7 @@ export class TransactionService {
|
||||
supplier,
|
||||
"",
|
||||
product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT',
|
||||
orderTransactionDto.bill_trx_id
|
||||
);
|
||||
|
||||
if (supplier.code != 'IRS') {
|
||||
@@ -1030,21 +1069,39 @@ export class TransactionService {
|
||||
hitLoginHemat = await doAuthorizeHemat(supplier.irs_user, supplier.irs_pass, supplier);
|
||||
}
|
||||
|
||||
let hitSupplier = supplier.code == 'Hemat' ? await doTransaction(
|
||||
let hitSupplier;
|
||||
|
||||
if (supplier.code == 'Hemat') {
|
||||
hitSupplier = await doTransaction(
|
||||
orderTransactionDto.productCode,
|
||||
orderTransactionDto.destination,
|
||||
trxId,
|
||||
supplier,
|
||||
hitLoginHemat.data,
|
||||
'INQUIRY'
|
||||
) : await doTransaction(
|
||||
`CEK${orderTransactionDto.productCode.slice(3)}`,
|
||||
'INQUIRY',
|
||||
orderTransactionDto.bill_trx_id
|
||||
)
|
||||
} else if (supplier.code == 'Digiflazz') {
|
||||
hitSupplier = await doTransaction(
|
||||
orderTransactionDto.productCode,
|
||||
orderTransactionDto.destination,
|
||||
trxId,
|
||||
supplier,
|
||||
hitLoginHemat.data,
|
||||
'INQUIRY',
|
||||
orderTransactionDto.bill_trx_id
|
||||
)
|
||||
} else {
|
||||
await doTransaction(
|
||||
hitSupplier= `CEK${orderTransactionDto.productCode.slice(3)}`,
|
||||
orderTransactionDto.destination,
|
||||
trxId,
|
||||
supplier,
|
||||
"",
|
||||
'INQUIRY'
|
||||
'INQUIRY',
|
||||
orderTransactionDto.bill_trx_id
|
||||
);
|
||||
}
|
||||
// const parsingResponse = hitSupplier.split(' ');
|
||||
|
||||
if (supplier.code == 'Hemat') {
|
||||
@@ -1052,6 +1109,11 @@ export class TransactionService {
|
||||
success: hitSupplier.success == true,
|
||||
msg: hitSupplier.msg,
|
||||
};
|
||||
} else if (supplier.code == 'Digiflazz') {
|
||||
hitSupplier = {
|
||||
success: hitSupplier.status.includes('Sukses'),
|
||||
msg: hitSupplier.message,
|
||||
};
|
||||
} else {
|
||||
hitSupplier = {
|
||||
success: hitSupplier.includes('diproses') || hitSupplier.includes('dalam proses'),
|
||||
@@ -1500,6 +1562,10 @@ export class TransactionService {
|
||||
} else {
|
||||
dataProductHistoryPrice.price = parseInt(callback['data']['additional']['harga']);
|
||||
}
|
||||
} else if (supplier.code == 'Digiflazz') {
|
||||
if (callback['sn']) {
|
||||
dataTransaction.seri_number = callback['sn'];
|
||||
}
|
||||
} else {
|
||||
if (callback['sn']) {
|
||||
dataTransaction.seri_number = callback['sn'];
|
||||
|
||||
Reference in New Issue
Block a user