Source:
public void invoke(String gatewayTransactionId, Charge charge, ChargeStatus newStatus, ZonedDateTime gatewayEventDate) { ChargeEntity chargeEntity = chargeService.findChargeByExternalId(charge.getExternalId()); GatewayAccountEntity gatewayAccount = chargeEntity.getGatewayAccount(); String oldStatus = chargeEntity.getStatus(); try { chargeService.transitionChargeState(chargeEntity, newStatus, gatewayEventDate); } catch (InvalidStateTransitionException e) { if (!e.getCurrentState().equals(e.getTargetState())) { logger.error(String.format("%s (%s) notification '%s' could not be used to update charge: %s", gatewayAccount.getGatewayName(), gatewayAccount.getId(), gatewayTransactionId, e.getMessage()), kv(PAYMENT_EXTERNAL_ID, chargeEntity.getExternalId()), kv(PROVIDER_PAYMENT_ID, gatewayTransactionId), kv(GATEWAY_ACCOUNT_ID, gatewayAccount.getId()), kv(PROVIDER, gatewayAccount.getGatewayName())); } try { chargeService.forceTransitionChargeState(chargeEntity, newStatus); } catch (InvalidForceStateTransitionException ie) { logger.error(String.format("%s (%s) notification '%s' could not be used to force capture charge: %s", gatewayAccount.getGatewayName(), gatewayAccount.getId(), gatewayTransactionId, ie.getMessage()), kv(PAYMENT_EXTERNAL_ID, chargeEntity.getExternalId()), kv(PROVIDER_PAYMENT_ID, gatewayTransactionId), kv(GATEWAY_ACCOUNT_ID, gatewayAccount.getId()), kv(PROVIDER, gatewayAccount.getGatewayName())); return; } } logger.info("Notification received. Updating charge - " + "charge_external_id={}, " + "status={}, " + "status_to={}, " + "transaction_id={}, " + "account_id={}, " + "provider={}, " + "provider_type={}", chargeEntity.getExternalId(), oldStatus, newStatus, gatewayTransactionId, gatewayAccount.getId(), gatewayAccount.getGatewayName(), gatewayAccount.getType()); }

Target:
public void invoke(String gatewayTransactionId, Charge charge, ChargeStatus newStatus, ZonedDateTime gatewayEventDate) { ChargeEntity chargeEntity = chargeService.findChargeByExternalId(charge.getExternalId()); GatewayAccountEntity gatewayAccount = chargeEntity.getGatewayAccount(); String oldStatus = chargeEntity.getStatus(); if (newStatus.equals(oldStatus)) { return; } try { chargeService.transitionChargeState(chargeEntity, newStatus, gatewayEventDate); } catch (InvalidStateTransitionException e) { logger.error(String.format("%s (%s) notification '%s' could not be used to update charge: %s", gatewayAccount.getGatewayName(), gatewayAccount.getId(), gatewayTransactionId, e.getMessage()), kv(PAYMENT_EXTERNAL_ID, chargeEntity.getExternalId()), kv(PROVIDER_PAYMENT_ID, gatewayTransactionId), kv(GATEWAY_ACCOUNT_ID, gatewayAccount.getId()), kv(PROVIDER, gatewayAccount.getGatewayName())); boolean success = forceTransitionChargeState(gatewayAccount, gatewayTransactionId, chargeEntity, oldStatus, newStatus); if (!success) { return; } } logger.info("Notification received. Updating charge - " + "charge_external_id={}, " + "status={}, " + "status_to={}, " + "transaction_id={}, " + "account_id={}, " + "provider={}, " + "provider_type={}", chargeEntity.getExternalId(), oldStatus, newStatus, gatewayTransactionId, gatewayAccount.getId(), gatewayAccount.getGatewayName(), gatewayAccount.getType()); }