Skip to content

Commit

Permalink
refactor: clean stuff
Browse files Browse the repository at this point in the history
Took 8 seconds
  • Loading branch information
vianneynara committed Dec 9, 2024
1 parent 2b1be89 commit 59f1492
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public void processNotification(MidtransNotification notification) {
}

// Validate merchant id
if (!notification.getMerchantId().equals(properties.midtrans().getMerchantId())) {
if (notification.getMerchantId() == null || !notification.getMerchantId().equals(properties.midtrans().getMerchantId())) {
log.warn("Merchant id is not valid, expected: {}, actual: {}", properties.midtrans().getMerchantId(), notification.getMerchantId());
throw new InvalidRequestBodyValue("Merchant id is not valid");
}

// Validate transaction amount, round the decimal to 0 fractional digits
final var actualAmount = transaction.getAmount().setScale(0, RoundingMode.UNNECESSARY);
if (!notification.getGrossAmount().equals(actualAmount.toString())) {
if (notification.getGrossAmount() == null || !notification.getGrossAmount().equals(actualAmount.toString())) {
log.warn("Gross amount is not valid, expected: {}, actual: {}", transaction.getAmount(), notification.getGrossAmount());
throw new InvalidRequestBodyValue("Gross amount is invalid");
}
Expand Down

0 comments on commit 59f1492

Please sign in to comment.