PaymentGatewaySaga

Charges the gateway for each requested payment and records its answer on the payment: ConfirmPayment when it approves, FailPayment when it declines.

The classic eShop's PaymentProcessor is an event handler that calls the gateway; here it is a saga, since a processor that sends commands is a saga, and a reactor cannot send one. The charge is the saga's outside call: its idempotency key is the call's invocationKey, the same each time the same commit is handled, so a handling retried after a failure does not charge twice. A gateway that fails is retried, then the payment is parked for this saga.

The charge says what it is for, the order's items, which the saga reads from the ordering context's shared cache of its orders (orders, StateViewCache<OrderStateView>, wow-cocache): the ordering service writes each order into it after its commits, and a miss reads the ordering service. That is a trusted read for the saga's own use, the charge's description: the order is never decided by it, and an order the cache cannot give is charged by its id. The saga keeps no state: the cache says when it cannot serve, once per outage.

Constructors

Link copied to clipboard
constructor(gateway: PaymentGateway, orders: StateViewCache<OrderStateView>)