Skip to content

Payment Process

This document describes the end-to-end flow of how payments are processed within the Brekz platform.
It covers customer interactions, service responsibilities, external integrations, and payment status tracking.


Purpose

The payment process ensures that customer orders are securely and efficiently paid before fulfillment starts.
It integrates with external payment service providers (PSPs) and provides clear feedback to both customers and internal systems.


Payment Flow

Customer-Facing Payment Flow
flowchart TD
    A[Shopping Cart] --> B[Login check]
    B -->|Logged in| C[Address & Payment Selection]
    B -->|Not logged in| D{Account type}
    D -->|Register| E[Create Account Form]
    D -->|Guest Checkout| F[Enter Email & Address]
    E --> C
    F --> C
    C --> G[Review & Confirm Page]
    G --> H["Nu Betalen" clicked]
    H --> I[CM.com Payment Interface]
    I --> J[Customer completes or cancels payment]
    J --> K[Redirect back to Brekz]
    K --> L{Payment API Type}
    L -->|REST API| M[Validation URL]
    L -->|SOAP API| N[Waiting Page]
    M --> O{Payment Result}
    N --> O
    O -->|Success| P[Thank You Page + Email]
    O -->|Failure or Cancelled| Q[Retry Page]

Click to view the user payment flow
flowchart TD
    A[Select product] --> B[Add to cart]
    B --> C[Checkout]
    C --> D{Logged in?}
    D -- Yes --> F[Delivery & payment]
    D -- No --> E[Enter info & create account]
    E --> F
    F --> G[Select delivery]
    G --> H[Select payment]
    H --> I{Credit Card / Bancontact?}
    I -- Yes --> J[Handle card]
    I -- No --> K[Redirect to provider]
    J --> L[Show waiting page]
    K --> L
    L --> M[Check payment]
    M --> N{Success?}
    N -- No --> R[Reset cart & back to select payment]
    R --> H
    N -- Yes --> P[Show thank you page]
Click to view the technical overflow payment flow (developer view)
sequenceDiagram
    participant User
    participant brekz-prestashop
    participant Payment Service
    participant PSP (Payment Provider)
    participant Order Service

    User->>brekz-prestashop: Add product to cart
    User->>brekz-prestashop: Proceed to checkout
    brekz-prestashop->>brekz-prestashop: Check if user is logged in
    brekz-prestashop-->>User: Prompt login or account creation (if needed)
    User->>brekz-prestashop: Submit user information / create account

    brekz-prestashop-->>User: Show available payment methods
    User->>brekz-prestashop: Select payment method

    brekz-prestashop->>Payment Service: Create payment request (with selected method)
    Payment Service->>PSP (Payment Provider): Redirect/initiate payment
    PSP (Payment Provider)-->>User: Show payment interface
    User-->>PSP (Payment Provider): Complete payment
    PSP (Payment Provider)->>Payment Service: Send webhook (success/failure)
    Payment Service->>brekz-prestashop: Update payment status
    brekz-prestashop->>Order Service: Mark order as paid or failed
    brekz-prestashop-->>User: Show thank you page or payment failed message

````
Click to view the SOAP API payment flow (developer view) ```mermaid sequenceDiagram participant User participant Brekz Website participant CM/Docdata API participant Payment Provider User->>Brekz Website: Add items to cart User->>Brekz Website: Enter user details User->>Brekz Website: Select payment method User->>Brekz Website: Click "Pay" button Brekz Website->>CM/Docdata API: createOrder (send customer info) Brekz Website->>CM/Docdata API: startPayment (start payment flow) CM/Docdata API->>Payment Provider: Redirect user to payment interface User-->>Payment Provider: Complete payment Payment Provider->>Brekz Website: Redirect back to Brekz validation URL Brekz Website->>CM/Docdata API: checkPayment (check if payment succeeded) alt Payment successful Brekz Website-->>User: Show thank you page else Payment cancelled Brekz Website-->>User: Show payment cancelled page end ````
--- ## Background Processes In addition to the synchronous customer payment flow, multiple asynchronous background processes ensure data consistency and order reliability. ### Webhook Handling The PSP (Payment Provider) sends asynchronous callbacks (webhooks) to notify the system of payment status changes. - Payment Service updates the payment record and triggers updates in brekz-prestashop. - If a webhook indicates success, the order is automatically marked as paid and processing starts. - If a webhook is called, a background job will mark the order as paid or cancelled. - If a webhook indicates failure or cancellation, the order remains unpaid or is cancelled. ```mermaid sequenceDiagram participant PSP (Payment Provider) participant Payment Service (CM) participant brekz-prestashop participant Order Service PSP (Payment Provider)->>Payment Service (CM): Send payment status webhook Payment Service (CM)->>brekz-prestashop: Update payment record brekz-prestashop->>Order Service: Mark order as paid or cancelled --- ## Involved Services | Service | Responsibility | | --------------- | ---------------------------------------------------------------- | | brekz-prestashop | Initiates payment requests and shows payment status to customer. | | brekz-mobile-payment | Handles mobile Updates the order status based on payment results. | | Payment Service | Handles communication with PSPs and processes payment callbacks. | | PSP (External) | Processes the actual financial transaction. | | Order Service | Updates the order status based on payment results. | --- ## Payment Providers (PSPs) Currently we are strictly using **CM.com Payments** to handle online transactions. We integrate with both their **SOAP API** (legacy flows) and **REST API** (modern flows) to manage different payment types, including Credit Card and Bancontact. ### CM.com Payments Documentation You can find their official documentation here: [CM Payments Developer Docs](https://developers.cm.com/payments-platform/docs/cm-payments) Additional useful links: - [CM.com Developer Portal](https://developers.cm.com/) - [Payments API Reference](https://developers.cm.com/payments-platform/docs/cm-payments)
Click to view CM.com contact information ### CM.com Contact Information - **Company Name:** CM.com - **Headquarters:** Breda, The Netherlands - **Website:** [https://www.cm.com/](https://www.cm.com/) - **Support Email:** support.payments@cm.com (or via brekz team their partner portal) - **Phone (HQ):** +31 (0)76 572 7000 ### CM.com Direct Contact person - **name:** Kevin Blommesteijn - **phone number:** +31762012719 - **email:** kevin.blommestein@cm.com
### Notes - Always use the **REST API** for new implementations. The **SOAP API** is maintained for legacy services only. - We recommend subscribing to CM.com's service status updates for proactive outage notifications: [CM.com Status Page](https://status.cm.com/). - Ensure webhooks and callback URLs are properly configu --- ## Business Rules - An order cannot be fulfilled before a successful payment confirmation. - Payment links expire after X minutes/hours. - If a payment fails, the order is canceled and the user has given a new cart and can try to process the order again - Refunds must always be initiated via the Payment Service to ensure traceability. - Partial refunds should be supported. ## Feature Dependencies This feature is part of the **Order Management Process**. **Upstream:** [Order Management](order-management.md) → creates the initial order before payment starts. **Downstream:** [Order Shipment](order-shipment.md) → starts after successful payment confirmation.
flowchart LR
    Order_Management --> Payment_Process
    Payment_Process --> Order_Shipment