-add condition for ppob_callback can't hit 2 times if the transaction is already success or failed (only pending)
This commit is contained in:
parent
7aee976de6
commit
1fcc7ca8ad
|
@ -19,31 +19,17 @@ export class PpobCallbackController {
|
||||||
|
|
||||||
if (response['statuscode'] == 2) {
|
if (response['statuscode'] == 2) {
|
||||||
//TODO: UPDATE GAGAL
|
//TODO: UPDATE GAGAL
|
||||||
const updateTransaction =
|
|
||||||
await this.transactionService.callbackOrderFailed(
|
await this.transactionService.callbackOrderFailed(
|
||||||
response['clientid'],
|
response['clientid'],
|
||||||
response,
|
response,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
|
||||||
updateTransaction,
|
|
||||||
statusCode: HttpStatus.BAD_REQUEST,
|
|
||||||
message: 'failed to proccess',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: UPDATE BERHASIL
|
//TODO: UPDATE BERHASIL
|
||||||
const updateTransaction =
|
|
||||||
await this.transactionService.callbackOrderSuccess(
|
await this.transactionService.callbackOrderSuccess(
|
||||||
response['clientid'],
|
response['clientid'],
|
||||||
response,
|
response,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
|
||||||
updateTransaction,
|
|
||||||
statusCode: HttpStatus.OK,
|
|
||||||
message: 'success',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Public()
|
@Public()
|
||||||
|
|
|
@ -1064,6 +1064,17 @@ export class TransactionService {
|
||||||
relations: ['product_price'],
|
relations: ['product_price'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (dataTransaction.status == statusTransaction.FAILED) {
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.BAD_REQUEST,
|
||||||
|
message: 'failed to update, the transaction already failed',
|
||||||
|
};
|
||||||
|
} else if (dataTransaction.status == statusTransaction.SUCCESS) {
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.BAD_REQUEST,
|
||||||
|
message: 'failed to update, the transaction already success',
|
||||||
|
};
|
||||||
|
} else {
|
||||||
const dataMsg = callback.msg;
|
const dataMsg = callback.msg;
|
||||||
const failedReason = dataMsg.split('.');
|
const failedReason = dataMsg.split('.');
|
||||||
|
|
||||||
|
@ -1144,6 +1155,13 @@ export class TransactionService {
|
||||||
'-',
|
'-',
|
||||||
'gagal',
|
'gagal',
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.BAD_REQUEST,
|
||||||
|
message: 'failed to proccess',
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1155,6 +1173,19 @@ export class TransactionService {
|
||||||
relations: ['product_price'],
|
relations: ['product_price'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (dataTransaction.status == statusTransaction.FAILED) {
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.BAD_REQUEST,
|
||||||
|
message: 'failed to update, the transaction already failed',
|
||||||
|
};
|
||||||
|
} else if (dataTransaction.status == statusTransaction.SUCCESS) {
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.BAD_REQUEST,
|
||||||
|
message: 'failed to update, the transaction already success',
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
|
||||||
dataTransaction.status = statusTransaction.SUCCESS;
|
dataTransaction.status = statusTransaction.SUCCESS;
|
||||||
dataTransaction.seri_number = callback['sn'];
|
dataTransaction.seri_number = callback['sn'];
|
||||||
dataTransaction.callback_json = callback;
|
dataTransaction.callback_json = callback;
|
||||||
|
@ -1228,6 +1259,11 @@ export class TransactionService {
|
||||||
dataTransaction.seri_number,
|
dataTransaction.seri_number,
|
||||||
'berhasil',
|
'berhasil',
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.OK,
|
||||||
|
message: 'success',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user