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 (EpdqNotification.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<ChargeEntity> maybeCharge = chargeDao.findByProviderAndTransactionId(PAYMENT_GATEWAY_NAME, notification.getTransactionId()); if (!maybeCharge.isPresent()) { logger.error("{} notification could not be verified (associated charge entity not found)", PAYMENT_GATEWAY_NAME, notification); return; } ChargeEntity charge = maybeCharge.get(); if (!verifyNotificationSignature(notification, charge)) { return; } logger.info("Evaluating notification {}", PAYMENT_GATEWAY_NAME, notification); final Optional<ChargeStatus> newChargeStatus = newChargeStateForChargeNotification(notification.getStatus(), ChargeStatus.fromString(charge.getStatus())); final Optional<RefundStatus> newRefundStatus = newRefundStateForRefundNotification(notification.getStatus()); if (newChargeStatus.isPresent()) { chargeNotificationProcessor.invoke(notification.getTransactionId(), charge, newChargeStatus.get(), null); } else if (newRefundStatus.isPresent()) { refundNotificationProcessor.invoke( PaymentGatewayName.EPDQ, newRefundStatus.get(), notification.getReference(), notification.getTransactionId() ); } }

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<ChargeEntity> maybeCharge = chargeDao.findByProviderAndTransactionId(PAYMENT_GATEWAY_NAME, notification.getTransactionId()); if (!maybeCharge.isPresent()) { logger.error("{} notification could not be verified (associated charge entity not found)", PAYMENT_GATEWAY_NAME, notification); return; } ChargeEntity charge = maybeCharge.get(); if (!isValidNotificationSignature(notification, charge)) { return; } logger.info("Evaluating notification {}", PAYMENT_GATEWAY_NAME, notification); final Optional<ChargeStatus> newChargeStatus = newChargeStateForChargeNotification(notification.getStatus(), ChargeStatus.fromString(charge.getStatus())); final Optional<RefundStatus> newRefundStatus = newRefundStateForRefundNotification(notification.getStatus()); if (newChargeStatus.isPresent()) { chargeNotificationProcessor.invoke(notification.getTransactionId(), charge, newChargeStatus.get(), null); } else if (newRefundStatus.isPresent()) { refundNotificationProcessor.invoke( PaymentGatewayName.EPDQ, newRefundStatus.get(), notification.getReference(), notification.getTransactionId() ); } }