Skip to content
Learni
View all tutorials
Finance & Paiements

How to Configure SEPA Payments in 2026

12 minBEGINNER
Lire en français

Introduction

SEPA allows you to make euro transfers and direct debits throughout the eurozone in a standardized way. This tutorial guides you step by step to integrate SEPA into a web application. You will learn how to validate bank details and generate compliant XML files. This is essential for any European company that wants to automate its customer or supplier payments.

Prerequisites

  • Node.js 18 or higher
  • Basic knowledge of JavaScript
  • Bank account with valid IBAN
  • Code editor (VS Code recommended)

Project Setup

terminal
mkdir sepa-tutorial
cd sepa-tutorial
npm init -y
npm install iban

We initialize a Node project and install the iban library to easily validate European bank account numbers.

IBAN Validation

validateIban.js
const IBAN = require('iban');

function isValidIBAN(iban) {
  if (!IBAN.isValid(iban)) {
    console.error('IBAN invalide');
    return false;
  }
  console.log('IBAN valide:', IBAN.printFormat(iban));
  return true;
}

isValidIBAN('FR7630006000011234567890189');

This function checks IBAN validity using the official SEPA algorithm. It displays a clear error if the format is incorrect.

Create a SEPA Mandate

createMandate.js
const mandate = {
  id: 'MAND-2026-001',
  debtorName: 'Jean Dupont',
  debtorIban: 'FR7630006000011234567890189',
  debtorBic: 'AGRIFRPP',
  creditorName: 'MonEntreprise SAS',
  creditorIban: 'FR1420041010050500013M02606',
  amount: 45.00,
  currency: 'EUR',
  date: '2026-03-15'
};

console.log('Mandat créé:', JSON.stringify(mandate, null, 2));

We define a SEPA mandate object here with all required information. This model can be stored in a database.

Generate SEPA XML File

generateSepaXml.js
const fs = require('fs');

function generatePain008(mandate) {
  const xml = `<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02">
  <CstmrDrctDbtInitn>
    <GrpHdr>
      <MsgId>${mandate.id}</MsgId>
      <CreDtTm>${new Date().toISOString()}</CreDtTm>
    </GrpHdr>
    <PmtInf>
      <ReqdColltnDt>${mandate.date}</ReqdColltnDt>
      <Cdtr>
        <Nm>${mandate.creditorName}</Nm>
      </Cdtr>
      <CdtrAcct>
        <Id><IBAN>${mandate.creditorIban}</IBAN></Id>
      </CdtrAcct>
    </PmtInf>
  </CstmrDrctDbtInitn>
</Document>`;
  fs.writeFileSync('sepa.xml', xml);
  console.log('Fichier sepa.xml généré');
}

generatePain008({
  id: 'MAND-2026-001',
  creditorName: 'MonEntreprise SAS',
  creditorIban: 'FR1420041010050500013M02606',
  date: '2026-03-15'
});

This script generates a minimal, SEPA-compliant pain.008 file. The file can be sent directly to your bank.

Credential Configuration

config.json
{
  "creditorId": "FR12ZZZ123456",
  "bankEndpoint": "https://api.banque.fr/sepa",
  "apiKey": "votre-cle-api-2026"
}

Store your SEPA credentials and API keys in a separate configuration file for easy maintenance.

Best Practices

  • Always validate the IBAN before any operation
  • Keep signed mandates for at least 36 months
  • Use unique transaction identifiers
  • Test in a sandbox environment before production
  • Encrypt sensitive banking data

Common Errors to Avoid

  • Forgetting the FR prefix in French IBANs
  • Generating XML without ISO 20022 namespaces
  • Not checking the execution date (T+1 minimum)
  • Reusing the same mandate identifier

Going Further

Check the official EPC documentation and discover our complete courses on modern payments: https://learni-group.com/formations