From 59f1492d8056a8e8c5da3c3ae4a98bd6e2f27c75 Mon Sep 17 00:00:00 2001 From: narwa Date: Mon, 9 Dec 2024 17:40:18 +0700 Subject: [PATCH] refactor: clean stuff Took 8 seconds --- .../kuenyawz/services/logic/MidtransWebhookServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/kons/kuenyawz/services/logic/MidtransWebhookServiceImpl.java b/src/main/java/dev/kons/kuenyawz/services/logic/MidtransWebhookServiceImpl.java index 7b20acef..22189980 100644 --- a/src/main/java/dev/kons/kuenyawz/services/logic/MidtransWebhookServiceImpl.java +++ b/src/main/java/dev/kons/kuenyawz/services/logic/MidtransWebhookServiceImpl.java @@ -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"); }