Proposed Checkout FlowsΒΆ
Design Status
This document contains all proposed sequence diagrams for the new checkout flow. See Overview for the business rationale and Proposed Technical Specification for database schema and state machines.
LegendΒΆ
Sequence Diagram Legend
| Highlight | Color | Meaning |
|---|---|---|
| TODO | Green | Task that still needs to be completed |
| ROUGH | Fuchsia | Part that might not be complete or accurate |
| Go Back to -> | Orange | Reference to return to a previous step |
| π Link | Blue | Clickable link to another section or flow |
| π MT-X | - | Metric tracked at this step - click to view details in metrics tables |
Flow Icons
- π Main flow - Primary payment flows and major checkout steps
- π Sub-flow - Nested flows within a payment method (e.g., retry, method switching)
- βΉοΈ Optional - Optional flows that can be skipped
- β οΈ Incomplete - Flows that need implementation or are marked as TODO
Main FlowΒΆ
Flow - click to expand
Happy Path FlowsΒΆ
π Checkout step 0 - Cart ReviewΒΆ
Flow - click to expand
Cart removal metrics
When a user removes/updates items from the cart, the following metrics are tracked:
- π Metric: cart_item_remove (CartController)
- π Metric: cart_item_remove (My Account API)
- π Metric: cart_item_update (CartController)
- π Metric: cart_item_update (My Account API)
π Checkout step 1 - AuthenticationΒΆ
Flow - click to expand
π Authentication method - LoginΒΆ
Flow - click to expand
TODO (handle 'created' orders attached to either cart) B ->> B: Update customer session B -->> U: Redirect to /checkout/payment-selection else note right of U: Login failed note over B: π Track login failed (reason) B -->> U: Response with error message, stay on /checkout/auth end
π Authentication method - RegisterΒΆ
Flow - click to expand
address, phone, country selector (NL/FR/LU only) U ->> B: Submit registration - POST /checkout/auth?mode=register note over B: π Track register attempted alt Registration result note right of U: Registration successful note over B: π Track register success B ->> B: Create customer account (is_guest=false) B ->> B: Associate cart with new customer B ->> B: Update customer session B -->> U: Redirect to /checkout/payment-selection else note right of U: Registration failed note over B: π Track register failed (reason: email exists, validation, etc.) B -->> U: Response with error message, stay on /checkout/auth end
π Authentication method - GuestΒΆ
Flow - click to expand
phone, country selector (FR/LU only) U ->> B: Submit guest registration - POST /checkout/auth?mode=guest note over B: π Track guest register attempted alt Guest registration result note right of U: Guest registration successful note over B: π Track guest register success B ->> B: Create guest customer account (is_guest=true) B ->> B: Associate cart with guest customer B ->> B: Update customer session B -->> U: Redirect to /checkout/payment-selection else note right of U: Guest registration failed note over B: π Track guest register failed (reason) B -->> U: Response with error message, stay on /checkout/auth end
π Authentication method - Forgot PasswordΒΆ
Flow - click to expand
π Checkout step 2 - Payment Selection & Order CreationΒΆ
Flow - click to expand
π iDEAL, β οΈ PayPal, β οΈ Klarna, β οΈ Bank Transfer end deactivate B
Payment Method FlowsΒΆ
β οΈ Checkout step 2a - Creditcard SelectionΒΆ
Status: β οΈ To be detailed
Flow characteristics:
- Select existing saved card OR enter new card details
- Optional: Save card for future use
- Card tokenization via CM.com
- Redirect to
/checkout/paymentafter selection
β οΈ Checkout step 2b - Bancontact SelectionΒΆ
Status: β οΈ To be detailed
Flow characteristics:
- Choose payment option: QR Code, Mobile App, or Card
- If Card selected: Card selection/entry (similar to creditcard flow)
- QR code generation for desktop users
- Redirect to
/checkout/paymentafter selection
π iDEAL FlowΒΆ
Flow - click to expand
User selected iDEAL as payment method U ->> B: Initiate payment - GET /checkout/payment?method=ideal activate B note over B: π Track payment page viewed (method=ideal) B ->> B: Load order from cart (via session) B ->> B: Create payment attempt (status='initiated') note over B: Payment Attempt ID: 67890
Order ID: 12345
Method: ideal
Status: initiated B ->> B: Update order status to 'pending' (lock cart/prices) note over B: Order is now LOCKED - no more changes allowed B ->> CM: Create iDEAL transaction - POST /paymentmethods/ideal/v1/transactions activate CM note over CM: Request includes:
- amount
- returnUrls (success, cancelled, expired, failed)
- consumer info
- order reference CM -->> B: Response with transaction (status=OPEN)
+ redirect URL note over B: CM Transaction ID: abc123
Status: OPEN deactivate CM B ->> B: Store CM transaction ID in payment attempt note over B: π Track payment initiated (cm_transaction_id) B -->> U: Redirect to iDEAL (via CM.com) deactivate B U ->> Bank: User completes payment at iDEAL activate Bank note over U,Bank: User selects bank, authenticates, and confirms payment via mobile app Bank ->> CM: Payment result (SUCCESS/CANCELLED/EXPIRED/FAILURE) CM ->> B: Webhook notification with status Bank -->> U: Redirect to returnUrl: /checkout/validate?attempt_id=67890 deactivate Bank note over U,B: Go to -> π Checkout step 4 - Payment Validation
Backend will check webhook data to determine actual status
β οΈ PayPal FlowΒΆ
Status: β οΈ To be detailed
Flow characteristics:
- REST-based payment method
- Redirect to PayPal login
- External authentication
- Return callback
β οΈ Creditcard FlowΒΆ
Status: β οΈ To be detailed
Flow characteristics:
- Uses selected/entered card from step 2a
- 3D Secure authentication
- SOAP to REST migration needed
β οΈ Bancontact FlowΒΆ
Status: β οΈ To be detailed
Flow characteristics:
- Multiple sub-flows based on selection from step 2b
- QR code scanning (desktop)
- Mobile app redirect
- Card payment with 3D Secure
- SOAP to REST migration needed
β οΈ Klarna FlowΒΆ
Status: β οΈ To be detailed
Flow characteristics:
- Phone number requirement
- External redirect
- SOAP to REST migration needed
β οΈ Bank Transfer FlowΒΆ
Status: β οΈ To be detailed
Flow characteristics:
- No immediate payment
- Display payment instructions
- Manual confirmation
- SOAP to REST migration needed
π Checkout step 4 - Payment ValidationΒΆ
Flow - click to expand
Modal opens with error message else Payment Cancelled B ->> B: Update payment attempt (status='cancelled') note over B: Order remains status='pending' note over B: π Track payment cancelled B -->> U: Redirect to /checkout/payment-selection?cancelled=true note right of U: See: π Payment Method Switch flow
Modal opens with cancellation message end deactivate B
π Checkout step 5 - Order ConfirmationΒΆ
Flow - click to expand
Unhappy Path FlowsΒΆ
π Unhappy Path - Failed Payment RetryΒΆ
Failed Payment with Retry - click to expand
Modal-based Retry
When payment fails, user is redirected to /checkout/payment-selection?error=payment_failed. A modal opens showing the error message with two options:
- "Try Again" - Retry with the same payment method
- "Close" - Close modal and select a different method
Payment failed, redirected to /checkout/payment-selection?error=payment_failed Note over U: Modal opens: "Payment failed: insufficient funds"
Options: "Try Again" | "Close" alt User clicks "Try Again" U ->> B: Click "Try Again" - POST /checkout/payment-selection activate B B ->> B: Create new payment attempt
(order_id=12345, retry_count=1, status='initiated') note over B: Payment Attempt ID: 2
Same method as attempt 1 note over B: π Track payment retry B -->> U: Redirect to /checkout/payment?attempt_id=2 deactivate B note over U,B: Go Back to -> Payment method flow
Process attempt 2 (succeeds) note over U,B: Go Back to -> Checkout step 3 - Payment Validation note over U,B: Go Back to -> Checkout step 4 - Order Confirmation else User clicks "Close" (switch method) U -->> U: Close modal, stay on /checkout/payment-selection note over U: User can now select different payment method note over U,B: See: π Payment Method Switch flow end note over B: π‘ Result: Order 12345 has 2 payment attempts:
Attempt 1: failed | Attempt 2: success (or cancelled if switched)
π Unhappy Path - Payment Method SwitchΒΆ
Payment Method Switching - click to expand
Modal-based Method Switch
When payment is cancelled, user is redirected to /checkout/payment-selection?cancelled=true. A modal opens showing cancellation message with options to retry or switch.
Payment cancelled, redirected to /checkout/payment-selection?cancelled=true Note over U: Modal opens: "Payment cancelled"
Options: "Try Again" | "Close" U -->> U: Close modal (switching method) Note over U: User stays on /checkout/payment-selection U ->> B: Select different method (PayPal) - POST /checkout/payment-selection activate B B ->> B: Create new payment attempt
(order_id=12345, method='paypal', status='initiated') note over B: Payment Attempt ID: 2 note over B: π Track payment method switch (from=ideal, to=paypal) B -->> U: Redirect to /checkout/payment?attempt_id=2 deactivate B note over U,B: Go Back to -> New payment method flow (e.g., PayPal)
Process attempt 2 note over U,B: Go Back to -> Checkout step 3 - Payment Validation
Validate attempt 2 (succeeds) note over U,B: Go Back to -> Checkout step 4 - Order Confirmation note over B: π‘ Result: Order 12345 has 2 attempts:
Attempt 1: iDEAL, cancelled
Attempt 2: PayPal, success
π Order Handling FlowΒΆ
Order Creation and Re-evaluation - click to expand
When This Flow Triggers
This flow runs every time a user navigates to /checkout/payment-selection:
- No order exists: First time visiting β create new order
- Order in 'created' state: User returns (refresh, back from cart) β re-evaluate cart changes
- Order in 'pending' state: User returns after failed/cancelled payment β retry or switch method
User is retrying/switching payment method B ->> B: Load existing order note over U,B: Go to -> Continue with payment selection (retry/switch) else note over U,B: Order exists (status='created') note over B: Order can still be modified - cart not locked B ->> B: Load existing order B ->> B: Compare order with current cart state end alt Cart comparison note over U,B: Cart unchanged note over U,B: Go to -> Continue with payment selection else note over U,B: Cart has changed B ->> B: Validate stock availability B ->> B: Recalculate totals (prices, tax, shipping) end alt Validation result note over U,B: Validation successful B ->> B: Update order line items and totals note over B: π Track order updated note over U: Notification: "Your order has been updated" note over U,B: Go to -> Continue with payment selection else note over U,B: Out of stock or validation failed note over B: π Track order validation failed B -->> U: Redirect to /cart with error message note over U: "Some items are no longer available" end
State machinesΒΆ
Order State MachineΒΆ
stateDiagram-v2
[*] --> Created: Order Created (at payment-selection)
note right of Created
Customer can still modify cart/address
Order gets updated when they return to payment-selection page
---
Prices re-validated on return
end note
Created --> Pending: First Payment Attempt (at /checkout/payment)
note right of Pending
Order is LOCKED - no changes allowed
Prices locked
Can have multiple payment attempts
---
30-minute timeout β Abandoned
end note
Pending --> Confirmed: Payment Success
Pending --> Failed: Payment Failed (max retries exceeded)
Pending --> Cancelled: User Cancels
Pending --> Abandoned: Timeout (30 min, lazy evaluation)
note left of Abandoned
Customer left during payment
---
If customer returns: create new order with current prices/stock
end note
note left of Cancelled
Customer actively clicked cancel during the payment process
end note
Confirmed --> Shipped: Order Shipped
Confirmed --> Refunded: Refund Issued
Shipped --> Delivered: Delivery Confirmed
Abandoned --> [*]
Cancelled --> [*]
Failed --> [*]
Refunded --> [*]
Delivered --> [*]
Payment Attempt State MachineΒΆ
stateDiagram-v2
[*] --> Initiated: Create Payment Attempt
Initiated --> Cancelled: User Cancels (before processing)
Initiated --> Processing: Sent to CM.com
Processing --> Cancelled: Timeout/User Cancel
Processing --> Failed: Payment Rejected
Processing --> Success: Payment Approved
Cancelled --> [*]: Allow Retry
Failed --> [*]: Allow Retry
Success --> [*]: Update Order
note left of Cancelled
***Failed and Cancelled***
Both states allow creating
a new payment attempt
end note