OnOrderInvoiceCreated
This hook runs after an actor message (either create or applyCommands) has produced one or more new invoices on the order — for example via the invoice order command. It is the right place to react to new invoicing activity, such as capturing payments, sending the customer a copy of the invoice, or pushing it to an external accounting system.
Firing semantics
The hook fires once per actor message that resulted in new invoices, regardless of how many invoices were created during that message. The invoices field carries only the new invoices for this message; previously-existing invoices (incl. the new ones) can all be accessed through order.invoices.
Rewind re-activation does not fire this hook
Invoices are never removed from an order — rewinding to a checkpoint that predates an invoice cancels it, which fires OnOrderInvoiceCancelled. Rewinding forward again, to a checkpoint after that rewind, flips the invoice back to isCancelled = false.
That re-activation deliberately does not fire OnOrderInvoiceCreated. The invoice was never re-created: it keeps its original invoiceId and invoiceNumber, so treating it as new would make apps create the same external document twice.
Type
{
hook: 'OnOrderInvoiceCreated'
order: Order // The order, including the newly created invoices
invoices: [Invoice] // Only the invoices that were created in this message
}