OrderPaymentSaga
The payment of an order between the ordering and the payment contexts, after the classic eShop's integration events (OrderStatusChangedToStockConfirmed, OrderPaymentSucceeded, OrderPaymentFailed):
onOrderStockConfirmed: an order whose stock the ordering context confirmed requests its payment. The saga reads the order stream the ordering context publishes,
wow.eshop-ordering.order.state, and takes eachOrderStockConfirmedof it, as the ordering api's class: the class names the stream, as the ordering's contract lists the event under its order. The order's state is the ordering api's generatedOrderStateView.onPaymentSucceeded: a payment the gateway approved pays its order:
PayOrdergoes to the ordering context's command topic,wow.eshop-ordering.commands.onPaymentFailed: a payment the gateway declined cancels its order; the cancelled order releases its stock, as any cancelled order does (the ordering's order-process saga).
onPayRejected: an order that refuses its payment (it was cancelled meanwhile, its grace period passed, say) comes back as a receipt on
wow.eshop-payment.receipts, and the payment is refunded.
A CancelOrder the order rejects has no handler: only a paid order rejects it, and a failed payment paid nothing, so such a rejection parks the payment for onPaymentFailed, to be looked at.
Each handler names only its target's id: the contract the ordering api's jar carries assigns PayOrder and CancelOrder to the ordering's order, the payment's own Manifest assigns RequestPayment and RefundPayment to the payment, and each command is in the tenant of the commit or receipt it answers.
Functions
An order that refuses its payment has the payment refunded.