Source:
public void handleNotificationFor(String payload) { logger.info("Parsing notification", PAYMENT_GATEWAY_NAME); EpdqNotification notification; try { notification = new EpdqNotification(payload); logger.info("Parsed notification: {}", PAYMENT_GATEWAY_NAME, notification); } catch (EpdqParseException e) { logger.error("{} notification parsing failed: {}", PAYMENT_GATEWAY_NAME, e); return; } logger.info("Verifying notification {}", PAYMENT_GATEWAY_NAME, notification); if (isBlank(notification.getTransactionId())) { logger.error("{} notification failed verification because it has no transaction ID", PAYMENT_GATEWAY_NAME, notification); return; } Optional<Charge> maybeCharge = chargeService.findByProviderAndTransactionIdFromDbOrLedger( PAYMENT_GATEWAY_NAME, notification.getTransactionId()); if (maybeCharge.isEmpty()) { logger.error("{} notification could not be verified (associated charge entity not found)", PAYMENT_GATEWAY_NAME, notification); return; } Charge charge = maybeCharge.get(); GatewayAccountEntity gatewayAccountEntity = gatewayAccountService.getGatewayAccount(charge.getGatewayAccountId()).get(); if (!isValidNotificationSignature(notification, gatewayAccountEntity)) { return; } logger.info("Evaluating notification {}", PAYMENT_GATEWAY_NAME, notification); final Optional<ChargeStatus> newChargeStatus = newChargeStateForChargeNotification(notification.getStatus(), ChargeStatus.fromString(charge.getStatus())); if (newChargeStatus.isPresent()) { chargeNotificationProcessor.invoke(notification.getTransactionId(), charge, newChargeStatus.get(), null); } else { final Optional<RefundStatus> newRefundStatus = newRefundStateForRefundNotification(notification.getStatus()); newRefundStatus.ifPresent(refundStatus -> refundNotificationProcessor.invoke( PaymentGatewayName.EPDQ, refundStatus, gatewayAccountEntity, notification.getReference(), notification.getTransactionId(), charge)); } }

Target:
public void handleNotificationFor(String payload) { logger.info("Parsing notification", PAYMENT_GATEWAY_NAME); EpdqNotification notification; try { notification = new EpdqNotification(payload); logger.info("Parsed notification: {}", PAYMENT_GATEWAY_NAME, notification); } catch (EpdqParseException e) { logger.error("{} notification parsing failed: {}", PAYMENT_GATEWAY_NAME, e); return; } logger.info("Verifying notification {}", PAYMENT_GATEWAY_NAME, notification); if (isBlank(notification.getTransactionId())) { logger.error("{} notification failed verification because it has no transaction ID", PAYMENT_GATEWAY_NAME, notification); return; } Optional<Charge> maybeCharge = chargeService.findByProviderAndTransactionIdFromDbOrLedger( PAYMENT_GATEWAY_NAME, notification.getTransactionId()); if (maybeCharge.isEmpty()) { logger.error("{} notification could not be verified (associated charge entity not found)", PAYMENT_GATEWAY_NAME, notification); return; } Charge charge = maybeCharge.get(); GatewayAccountEntity gatewayAccountEntity = gatewayAccountService.getGatewayAccount(charge.getGatewayAccountId()).get(); if (!isValidNotificationSignature(notification, gatewayAccountEntity)) { return; } logger.info("Evaluating notification {}", PAYMENT_GATEWAY_NAME, notification); final Optional<ChargeStatus> newChargeStatus = newChargeStateForChargeNotification(notification.getStatus(), charge); if (newChargeStatus.isPresent()) { chargeNotificationProcessor.invoke(notification.getTransactionId(), charge, newChargeStatus.get(), null); } else { final Optional<RefundStatus> newRefundStatus = newRefundStateForRefundNotification(notification.getStatus()); newRefundStatus.ifPresent(refundStatus -> refundNotificationProcessor.invoke( PaymentGatewayName.EPDQ, refundStatus, gatewayAccountEntity, notification.getReference(), notification.getTransactionId(), charge)); } }