use of com.kloia.sample.dto.event.PaymentFailedEvent in project eventapis by kloiasoft.
the class DoPaymentEventHandler method execute.
@KafkaListener(topics = "PaymentProcessEvent", containerFactory = "eventsKafkaListenerContainerFactory")
public EventKey execute(PaymentProcessEvent dto) throws EventStoreException, EventPulisherException, ConcurrentEventException {
PaymentSuccessEvent paymentSuccessEvent = new PaymentSuccessEvent();
BeanUtils.copyProperties(dto.getPaymentInformation(), paymentSuccessEvent);
paymentSuccessEvent.setOrderId(dto.getSender().getEntityId());
if (dto.getPaymentInformation().getAmount() > 2000)
throw new RuntimeException("Bla Bla");
if (dto.getPaymentInformation().getAmount() > 1000) {
PaymentFailedEvent paymentFailedEvent = new PaymentFailedEvent();
BeanUtils.copyProperties(dto.getPaymentInformation(), paymentFailedEvent);
paymentFailedEvent.setOrderId(dto.getSender().getEntityId());
return eventRepository.recordAndPublish(paymentFailedEvent);
}
return eventRepository.recordAndPublish(paymentSuccessEvent);
}
Aggregations