Skip to content
Sequence & interaction templates

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.

Template previewSequence & interaction
Checkout — card authorisation14 messages · deepest 4 openaltauth.code · 00"51","91"parpostnotifyplace orderPOST /ordersbegin(orderId)authorize(token, 4200)approved(authId)debit(4200)postedreceipt.readycaptured(authId)authorize(token, 4200)declined(code)failed(code)201 CreatedconfirmationShopperStorefrontOrder serviceLedgerconcurrentCard vaultPayment sagaAll 17 checks ran over 6 lifelines and 14 messages and every one came back clean.INFO6 lifelines, 14 messages, 2 fragments. 6 synchronous calls, 6 answered; the deepest point of the interaction has 4 calls open at once. Every message states whether it is a call, a reply or afire-and-forget, so the stack above was simulated rather than guessed at.OK17 of the 17 checks ran over every instance of their subject and found nothing: misdirected-reply, orphan-reply, conditional-reply, unreturned-call, deadlock, after-destroy, before-create,double-create, double-destroy, par-interference, guard-overlap, guard-incomplete, activation-claim, unused-participant, undeclared-lifeline, duplicate-id, fragment-unclosed.

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