Mermaid code
sequenceDiagram
actor C as Customer
participant S as Storefront
participant G as Payment gateway
participant N as Card network
C->>S: Submit order with card details
S->>G: Create payment (amount, currency, card token)
G->>N: Authorization request
N-->>G: Approved or declined
alt Approved
G-->>S: Payment authorized
S->>S: Mark order as paid
S-->>C: Order confirmation
else Declined
G-->>S: Decline code
S-->>C: Ask for another payment method
end
Note over S,G: Capture happens later, when the order ships Paste this into any tool that renders Mermaid, or into the editor to change the theme and export PNG or SVG. Syntax reference: Sequence Diagram guide.
What this diagram shows
The actor C as Customer line draws a stick figure instead of a box, which separates the human from the systems. The alt Approved ... else Declined ... end block holds the two outcomes side by side so the decline path is as visible as the happy path. The closing Note over S,G records that capture is a separate step, a detail that explains why a customer can see a pending charge before the order ships.
How to adapt it
- Add a
participant F as Fraud checkbetween the storefront and the gateway if screening happens before authorization. - Insert a
loop Retry up to 3 timesaround the authorization call to show how timeouts are handled. - Replace
Card networkwithBankorWallet providerwhen documenting a non-card method; the shape of the flow stays the same. - Add
activateanddeactivateon the gateway to show how long the storefront waits for a response.
FAQ
Why do the replies use dashed arrows?
In Mermaid sequence diagrams -->> draws a dashed line, which is the convention for responses. Solid ->> arrows are requests. Keeping the two distinct makes a long flow readable without reading every label.
Where would a 3-D Secure challenge go in this diagram?
Between the authorization request and the network response. Add N-->>C: Challenge page and C->>N: Complete challenge inside an opt 3DS required block so it is clear the step does not always happen.