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 each OrderStockConfirmed of 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 generated OrderStateView.

  • onPaymentSucceeded: a payment the gateway approved pays its order: PayOrder goes 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.

  • onCancelRejected: an order that refuses its cancellation is already paid or shipped, so the failed payment has nothing left to undo: the handler accepts that code. Any other parks the payment.

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.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard

An order refuses its cancellation only once it is paid or shipped (EshopOrderingContract.Order.Errors.WRONG_STATUS): it was paid, so the failed payment cancels nothing, and its own failure is recorded on the payment already. The handler accepts that code and derives nothing; the acceptance is logged in the payment service. Any other code is one the saga does not expect, so the payment parks at once, its reason naming the code. Without this handler, the order's refusal, which comes back from the ordering context as a receipt, would park the payment too.

Link copied to clipboard

An order that refuses its payment has the payment refunded.