Card Authorisation — the Reference Interaction
The one to copy. A checkout that calls out to a card vault, posts to a ledger and notifies the storefront, with a payment saga created for the transaction and destroyed when it ends. Every call is answered by the participant that made it, on every branch; the `alt` covers its declared domain exactly with no overlap; the two `par` branches address different lifelines; the saga is used only between its create and its destroy. Reports clean, and every one of the seventeen checks says what it covered.
Make it your own.
sequence "Checkout — card authorisation"
actor Shopper
participant Web "Storefront"
participant Orders "Order service"
participant Ledger "Ledger" concurrent
database Cards "Card vault"
Shopper -> Web : place order
Web -> Orders : POST /orders
Orders create Saga "Payment saga"
Orders -> Saga : begin(orderId)
alt on auth.code : "00","51","91"
when "00"
Saga -> Cards : authorize(token, 4200)
Cards reply Saga : approved(authId)
par
branch "post"
Saga -> Ledger : debit(4200)
Ledger reply Saga : posted
branch "notify"
Saga async Web : receipt.ready
end
Saga reply Orders : captured(authId)
when "51","91"
Saga -> Cards : authorize(token, 4200)
Cards reply Saga : declined(code)
Saga reply Orders : failed(code)
end
Orders destroy Saga
Orders reply Web : 201 Created
Web reply Shopper : confirmation