> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nordiska.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SEPA Direct Debit

This guide provides an overview of how to integrate with our SEPA Direct Debit API to manage mandates for recurring payments from your customers.

## The Flow

Setting up a SEPA Direct Debit mandate involves a few steps. The customer must first agree to the mandate, after which you can register, manage, and, if necessary, cancel it.

Here is a diagram illustrating the process:

```mermaid theme={null}
sequenceDiagram
    participant User as Your Customer
    participant Merchant as You (Merchant)
    participant SepaAPI as SEPA API

    Merchant->>SepaAPI: 1. Get consent texts<br/>GET /api/sepa-direct-debit/consents
    activate SepaAPI
    SepaAPI-->>Merchant: Returns consent texts and consentId
    deactivate SepaAPI

    Merchant->>User: 2. Display consent texts
    User->>Merchant: 3. Agree to terms & provide IBAN

    Merchant->>SepaAPI: 4. Register mandate<br/>POST /api/sepa-direct-debit
    activate SepaAPI
    SepaAPI-->>Merchant: Returns mandateId
    deactivate SepaAPI

    Note over Merchant,SepaAPI: Mandate is now active

    loop Periodically
        Merchant->>SepaAPI: 5. Check mandate status (Optional)<br/>GET /api/sepa-direct-debit/mandate
        activate SepaAPI
        SepaAPI-->>Merchant: Returns mandate status
        deactivate SepaAPI
    end

    opt If needed
        Merchant->>SepaAPI: 6. Cancel mandate<br/>POST /api/sepa-direct-debit/cancel
        activate SepaAPI
        SepaAPI-->>Merchant: Confirms cancellation
        deactivate SepaAPI
    end
```

## Step-by-step Guide

### 1. Retrieve Consent Texts

Before you can register a mandate, you must display the necessary legal texts to your customer. You can retrieve these texts from our API. The response will also contain a `consentId` that you will need in the next step.

### 2. Register a Mandate

Once the customer has agreed to the terms and provided their IBAN, you can register the mandate. You'll need their `iban` and the `consentId` from the previous step. A successful registration will return a `mandateId`.

### 3. Manage the Mandate

With the `mandateId`, you can retrieve the status and other details of the mandate at any time. You can also cancel the mandate if it is no longer needed.
