When an Order Created Event occurs, the Order Operation Service listens for it and goes through this workflow to validate the vouchers and generate voucher codes for them:
VoucherCodeGenerationOrderCreatedListener
receives the order created event, validates the Order#vouchers
and then generate voucher codes for them, and sends the event to the VoucherGenerationCompletionProducer.CHANNEL
channel with the Order
.
The vouchers are validated using OfferProvider
If the vouchers are still valid, it will generate voucher codes using CampaignProvider
.
If the CodeGenerationResult
is successful, generated voucher codes will be set onto the vouchers
If the CodeGenerationResult
is not successful, an error will be logged and set onto the vouchers. The VoucherGenerationCompletionEvent
will still be sent
A VoucherGenerationCompletion message is published, containing the order that has the vouchers.