use of com.kloia.sample.model.PaymentInformation in project eventapis by kloiasoft.
the class StockReservedEventHandler method execute.
@Override
@KafkaListener(topics = "StockReservedEvent", containerFactory = "eventsKafkaListenerContainerFactory")
public EventKey execute(StockReservedEvent dto) throws EventStoreException, ConcurrentEventException {
Orders order = orderQuery.queryEntity(dto.getOrderId());
if (order.getState() == OrderState.RESERVING_STOCK) {
PaymentProcessEvent paymentProcessEvent = new PaymentProcessEvent(order.getId(), dto.getSender().getVersion(), new PaymentInformation(order.getPaymentAddress(), order.getAmount(), order.getCardInformation()));
log.info("Payment is processing : " + dto);
return eventRepository.recordAndPublish(order, paymentProcessEvent);
} else
throw new EventStoreException("Order state is not valid for this Operation: " + dto);
}
Aggregations