We're running Commerce 10.4.3 and I'm wondering what would be the recommended way to handle promotions when you can't publish the promotion data beforehand. In our specific case we have coupon codes that are validated through an api and may be personal. Lets say we have a fixed amount discount promotion but you can have multiple of them applied to the order (much like a payment, but should be calculated as a discount) through multiple codes.
You can produce a summary reward with the current structure but you don't get distinct promotioninformation records and only a single description text. I've wrecked various parts of the engine (including PromotionEngineContentLoader) to produce duplicates of the promotions to process but it's a bit beyond reasonable adaption.
I am not sure if it will work for you but there is an interface IAdditionalPromotionInformationCreator which is called in the engine and allows you to set AdditionalInformation. You could add what you need to be able to add additional entries for PromotionInformationEntry after the engine returns.
In what ways does it need to be counted as a discount?
The way we have solved vouchers and giftcards is that we add them as payments and the customized everything else, how those payments/discounts are shown at checkout, the tax calculations, all the calculators really, etc.
It is a lot of work to be honest but along the road we faced the fact that we needed to be able to handled cancelled orders with refunds on the vouchers/giftcards, attempting to build that kind of support on top of the discount system would also be a monumental effort.