- fix error metro
This commit is contained in:
Muhammad Fadli 2023-10-30 13:41:46 +07:00
parent cbeae3c404
commit b66b296292
2 changed files with 42 additions and 33 deletions

View File

@ -43,18 +43,18 @@ export class PpobCallbackController {
@Public() @Public()
@Get('/metro') @Get('/metro')
async getMetro(@Req() request: FastifyRequest) { async getMetro(@Req() request: FastifyRequest) {
// try { try {
const response = request.query; const response = request.query;
console.log('responsemetro', response['status'])
if (response['message'].toLowerCase().includes('cek')) { if (response['message'].toLowerCase().includes('CEK TAGIHAN')) {
if (response['status'] != 20) { if (response['status'] != 20) {
//TODO: UPDATE GAGAL //TODO: UPDATE GAGAL
await this.transactionService.updateBill( await this.transactionService.updateBill(
response['refid'], response['refid'],
null, null,
null, null,
false, false,
response['message'], response['message'],
); );
return { return {
@ -67,11 +67,11 @@ export class PpobCallbackController {
//TODO: UPDATE BERHASIL //TODO: UPDATE BERHASIL
await this.transactionService.updateBill( await this.transactionService.updateBill(
response['refid'], response['refid'],
Number(splitMessage[21].replace(/^\D+/g, '')), Number(splitMessage[21].replace(/^\D+/g, '')),
Number(splitMessage[17].replace(/^\D+/g, '')), Number(splitMessage[17].replace(/^\D+/g, '')),
true, true,
response['message'], response['message'],
); );
// //
} else { } else {
@ -79,22 +79,32 @@ export class PpobCallbackController {
console.log('statusapani2', response.toString()); console.log('statusapani2', response.toString());
if (response['status'].toString() != '20') { if (response['status'].toString() != '20') {
console.log('responsemetro1', response['status'])
console.log('metrogagalmessage', response['message'])
//TODO: UPDATE GAGAL //TODO: UPDATE GAGAL
await this.transactionService.checkCallbackOrderFailed( const updateTransaction =
await this.transactionService.callbackOrderFailed(
response['refid'], response['refid'],
response, response,
); );
return {
updateTransaction,
statusCode: HttpStatus.BAD_REQUEST,
message: 'failed to proccess',
};
} else { } else {
//TODO: UPDATE BERHASIL //TODO: UPDATE BERHASIL
await this.transactionService.checkCallbackOrderSuccess( const updateTransaction =
await this.transactionService.callbackOrderSuccess(
response['refid'], response['refid'],
response, response,
); );
return {
updateTransaction,
statusCode: HttpStatus.OK,
message: 'success',
};
} }
} }
@ -106,20 +116,20 @@ export class PpobCallbackController {
statusCode: HttpStatus.OK, statusCode: HttpStatus.OK,
message: 'success', message: 'success',
}; };
// } catch (e) { } catch (e) {
// if (e instanceof EntityNotFoundError) { if (e instanceof EntityNotFoundError) {
// throw new HttpException( throw new HttpException(
// { {
// statusCode: HttpStatus.NOT_FOUND, statusCode: HttpStatus.NOT_FOUND,
// error: 'Error callback', error: 'Error callback',
// message: e message: e
// }, },
// HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND,
// ); );
// } else { } else {
// throw e; throw e;
// } }
// } }
} }
@Public() @Public()

View File

@ -1502,7 +1502,6 @@ export class TransactionService {
if (callback['message'].includes('METRO')) { if (callback['message'].includes('METRO')) {
const response = callback['message']; const response = callback['message'];
const responseBaru = response.split('.'); const responseBaru = response.split('.');
console.log('masukmsgmetrofail', responseBaru[2])
dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal. ${responseBaru[2]}`; dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal. ${responseBaru[2]}`;
if (callback['price'] != dataTransaction.product_price.price) { if (callback['price'] != dataTransaction.product_price.price) {
dataTransaction.product_price.price = parseInt(callback['price']); dataTransaction.product_price.price = parseInt(callback['price']);