SEPA direct debit testing is harder than testing a credit transfer because a collection is not a single message. It depends on a mandate signed earlier, on a Creditor Identifier, on a sequence type that has to be right for that mandate's history, and on a set of return messages that can arrive weeks after the money moved. This post lists what the European Payments Council (EPC) rulebooks require, so that you can turn each rule into a test, and ends with where to get IBANs for the debtor accounts in your fixtures.
Terminology first. The creditor collects the money (a subscription service, a utility, an insurer). The debtor pays. Each has a payment service provider (PSP), the bank. A collection is one debit instruction; a mandate is the debtor's authorisation to collect.
Core and B2B: two schemes, different tests
The EPC runs two direct debit schemes with separate rulebooks. The 2025 editions have been in force since 5 October 2025.
| SDD Core | SDD B2B | |
|---|---|---|
| Debtor | Consumers and businesses | Businesses only; the debtor PSP must make sure the debtor is not a consumer |
| Refund of an authorised collection | Yes, no questions asked, within eight weeks of the debit | None |
| Mandate check by the debtor PSP | Not required by the scheme | Required: the debtor PSP checks the first and every later collection against mandate data confirmed by the debtor |
| Reachability | All PSPs that offer euro direct debits must be reachable under the SEPA Regulation | Not assumed; participation is optional |
| Local Instrument code in the message | CORE |
B2B |
For a test suite this means two things. A product that collects from consumers cannot use B2B at all, and a B2B collection sent against a consumer account is rejected with the reason code AC13. And B2B's missing refund right is paid for with the debtor PSP's mandate check, so B2B integrations fail at a different point: a collection whose mandate the debtor has not confirmed with their bank comes back as MD01.
Mandates: the data your tests must get right
The combination of the Creditor Identifier and the Unique Mandate Reference (UMR) is the unique key of a mandate across SEPA. The Core rulebook does not limit the UMR's length, but the ISO 20022 message carries it as MndtId with at most 35 characters, and the implementation guidelines declare it case-insensitive: 123AAa45678 and 123aaa45678 are the same mandate. A test that creates two mandates differing only in case should fail.
The rulebook lists what a mandate must contain: the UMR, the debtor's name and IBAN (address and BIC only in specific non-EEA cases), the creditor's name, address and Creditor Identifier, the type of payment (one-off or recurrent), and the signature with its date. The date of signing (attribute AT-M008) travels in every collection as DtOfSgntr and must not change over the life of the mandate.
Three rules deserve their own test cases:
- Sequence types. Each collection declares
FRST,RCUR,FNALorOOFF. A one-off mandate allows onlyOOFF; a recurrent one starts withFRSTorRCUR, continues withRCURand may end withFNAL. A recurrent collection after a one-off, or a one-off after a recurrent, is rejected withAG02. The rulebook treatsFRSTas a recurrent collection, so a mandate's first collection may be sent asRCUR. - Dormancy. If the creditor presents no collection under a mandate for 36 months, counted from the last collection presented even if that one was rejected, returned or refunded, the creditor must cancel the mandate. A collection on an older mandate is a scheduler bug, and the debtor PSP may answer
MD01. - Amendments. When the debtor changes account, the collection carries the amendment indicator and, for a new account at the same or another PSP, the value
SMNDA(same mandate with a new debtor account). Changes of UMR, creditor identifier or creditor name are amendments too. Test that an amended mandate keeps its original signing date.
Two timing rules also apply. The creditor must pre-notify the debtor at the latest 14 calendar days before the due date unless they agreed otherwise, and the collection must reach the debtor PSP at the latest one inter-PSP business day before the due date (D-1) and not earlier than 14 calendar days before it. Generate collections at the boundaries and one day past them.
The Creditor Identifier and its check digits
The Creditor Identifier (CI) identifies the creditor independently of any bank account, so it survives a change of bank. Its general structure, from the EPC's Creditor Identifier Overview:
| Positions | Content |
|---|---|
| 1 to 2 | ISO country code of the issuing country |
| 3 to 4 | Check digits, ISO 7064 MOD 97-10 |
| 5 to 7 | Creditor Business Code, ZZZ when not used |
| 8 onwards | National identifier, structure defined per country |
The national part varies: Germany's CI is 18 characters long with an 11-digit consecutive number issued by the Deutsche Bundesbank; Belgium uses a ten-digit enterprise number; France has a six-character national part. The Creditor Business Code is the creditor's own extension (a business line, a region) and is excluded from the check-digit calculation. The CI without its business code is what identifies the creditor, so DE98ZZZ09999999999 and DE98ABC09999999999 belong to the same creditor and both have valid check digits.
Worked example
Take DE98ZZZ09999999999 and verify the 98.
- Drop positions 5 to 7 (
ZZZ). The national part is09999999999. - Append the country code and
00:09999999999DE00. - Replace each letter with its number, A=10 through Z=35 (D=13, E=14):
09999999999131400. - Take the remainder modulo 97. For this 17-digit number it is 0.
- Check digits = 98 minus the remainder =
98.
To validate an existing CI, do the same with the real check digits in place of 00: 09999999999DE98 becomes 09999999999131498, and a remainder of 1 means the CI is valid. Our implementation gives the EPC's own examples back correctly (BE68ZZZ0123456789, FR72ZZZ123456), and the Bundesbank example above checks out.
Use arbitrary-precision arithmetic or the step-by-step remainder, exactly as for IBAN check digits: https://generaterandomiban.com/en/ibanpedia/iban-check-digits shows the technique, and the CI calculation differs only in which characters you include. In the pain.008 message the CI goes into CdtrSchmeId/Id/PrvtId/Othr/Id, with SchmeNm/Prtry set to SEPA. A wrong or changed CI comes back as BE05.
pain.008 at a high level
The collection file is an ISO 20022 CustomerDirectDebitInitiation message; the 2025 EPC implementation guidelines are based on pain.008.001.08. You do not need the full schema to write good tests, but you do need the shape:
- The group header (
GrpHdr): a message identification of up to 35 characters that must be unique towards your bank, the creation timestamp, the number of transactions and the control sum. - Payment information (
PmtInf), one block per due date and scheme: payment methodDD, service levelSEPA, local instrumentCOREorB2B, the sequence type, the requested collection date, the creditor's name and IBAN, and usually the creditor scheme identification with the CI. - Direct debit transaction information (
DrctDbtTxInf), one per collection: the instructed amount in euro, the mandate-related information (MndtId,DtOfSgntr, amendment indicator and details), the debtor's name, the debtor account as an IBAN, and remittance information.
Mixing local instruments in one message is not allowed. Validate every file you produce against the XSD in CI, then against your bank's own guidelines, which restrict the ISO schema further than the EPC baseline. Structured or hybrid addresses become mandatory in EPC scheme messages in November 2026, so fixtures should already use the structured form.
R-transactions: what comes back
Collections that cannot be processed normally produce "R-transactions". The rulebook defines them by who acts and when:
| R-transaction | Who | When | Typical reasons |
|---|---|---|---|
| Reject | Creditor PSP, clearing system or debtor PSP | Before settlement | Invalid format, wrong IBAN check digits, account closed, no mandate |
| Refusal | Debtor | Before settlement | The debtor tells their bank not to pay; processed as a reject (or as a return if handled after settlement) |
| Return | Debtor PSP | After settlement, settled at the latest five inter-PSP business days after the collection | Insufficient funds, account closed, no mandate |
| Refund | Debtor | After settlement: eight weeks for any Core collection, 13 months for an unauthorised one | Disputed authorised collection (MD06), unauthorised collection (MD01) |
| Reversal | Creditor or creditor PSP | After settlement, within five inter-PSP business days | The creditor collected in error, for instance a duplicate |
Refunds for authorised transactions do not exist in B2B. The 13-month window for unauthorised transactions comes from Article 71 of the Payment Services Directive.
Each R-transaction carries an ISO reason code. The EPC's guidance on reason codes (EPC173-14, version 8.0) is the reference; the codes you will meet first:
| Code | Meaning | Used in |
|---|---|---|
AC01 |
Incorrect account number (invalid IBAN, or IBAN unknown at the debtor PSP) | Reject, return |
AC04 |
Account closed | Reject, return |
AC06 |
Account blocked | Reject, return |
AC13 |
Debtor account is a consumer account (B2B only) | Reject, return |
AG01 |
Direct debit forbidden on this account (for example a savings account) | Reject, return |
AG02 |
Invalid sequence type or transaction code | Reject, return |
AM04 |
Insufficient funds | Reject, return |
AM05 |
Duplicate collection | Reject, return, reversal |
BE05 |
Creditor Identifier incorrect or changed without amendment | Reject, return |
FF01 |
Invalid file format | Reject |
MD01 |
No valid mandate (also refunds of unauthorised Core collections) | Reject, return, refund |
MD02 |
Mandate data missing or inconsistent with the stored mandate | Reject |
MD06 |
Refund requested by the debtor (Core, within eight weeks) | Refund |
MD07 |
Debtor deceased | Reject, return |
MS02 |
Refused by the debtor, no reason given | Reject, return, reversal, refusal |
MS03 |
Reason not specified, used where data protection law forbids the precise code | Reject, return, reversal |
SL01 |
Specific service of the debtor PSP (creditor blocked, amount or frequency limits) | Reject, return |
Two traps in that table. AC04, AM04, MD07 and the RR codes cannot be used in some countries for data-protection reasons, and MS03 arrives instead, so your retry logic cannot rely on seeing AM04 for every insufficient-funds case. And MD01 means different things depending on the transaction: no mandate on a reject, but an unauthorised-transaction refund when it arrives up to 13 months later.
What to cover in tests
A checklist drawn from the rules above, roughly in the order a collection goes through them:
- Mandate creation: UMR uniqueness per CI, case-insensitive; CI check digits; signing date stored and never changed; type one-off or recurrent.
- Debtor account: IBAN normalised to electronic format and validated (length, pattern, MOD-97) before the mandate is accepted, with per-country lengths; the https://generaterandomiban.com/en/iban-validator shows which of these layers an input fails. B2B: the account belongs to a business.
- Sequence logic: first, following, last and one-off collections, and the illegal transitions that produce
AG02. - Timing: pre-notification 14 calendar days before the due date; submission inside the D-14 to D-1 window; due dates on non-business days.
- Message generation: XSD-valid pain.008 with the right local instrument, the CI in the creditor scheme identification, unique message and end-to-end identifications, control sums that add up, structured addresses.
- R-transaction handling: parse each code in the table, including
MS03as a stand-in, apply the right follow-up (retry, contact the customer, cancel the mandate), and handle the same reason code as a reject, a return and a refund. - Refund windows: an
MD06refund seven weeks after the debit, anMD01refund twelve months after it, and a B2B integration that expects neither. - Dormancy and amendments: a scheduler that stops after 36 months without collections; a change of debtor account that sets the amendment indicator and keeps the original signing date.
- Duplicates: catch a collection submitted twice before the clearing system answers
AM05.
Test IBANs for debtor accounts
Every mandate in your fixtures needs a debtor IBAN, and these should not be real accounts: an IBAN is all it takes to set up a direct debit mandate, which is one reason real customer data has no place in a test database. Generated IBANs pass the structural checks a direct debit system applies before the file leaves the building, which is what you are testing at that stage.
Our generator covers 91 countries, so a fixture set can mix German, Dutch, French and Spanish debtors, with the national check digits that French and Spanish banks verify. By default the bank code is that of a real bank with a random account number, so bank-directory lookups in your mandate flow succeed. The export endpoint delivers up to 100 IBANs per country as CSV, JSON, SQL or plain text, with one column per segment:
curl -o debtors-de.csv "https://generaterandomiban.com/export/de?format=csv&count=100"
curl -o debtors-nl.json "https://generaterandomiban.com/export/nl.json?count=50"
Two limits to keep in mind. A generated IBAN was not issued by any bank, so it cannot be used to test what happens after submission: for end-to-end tests of returns and refunds, use the test IBANs your bank or payment provider publishes for its sandbox, which trigger specific reason codes on purpose. And never submit a collection against a generated IBAN in production; a realistic one could match a real account by chance.
Sources
- EPC016-06, SEPA Direct Debit Core Scheme Rulebook 2025: mandate attributes, time cycles, refund rules, exception handling (sections 4.1 to 4.8).
- EPC222-07, SEPA Direct Debit Business-to-Business Scheme Rulebook 2025: the B2B differences (consumer check, no refund for authorised collections, mandatory mandate check, reachability).
- EPC173-14, Guidance on Reason Codes for SDD R-transactions, version 8.0: the reason code table and the data-protection exceptions.
- EPC262-08, Creditor Identifier Overview: the CI structure, the exclusion of the Creditor Business Code from the check digits, and the national formats.
- EPC131-08, SEPA Direct Debit B2B Customer-to-PSP Implementation Guidelines 2025: pain.008.001.08 element rules (local instrument, sequence type, creditor scheme identification, mandate identification).
- ISO/IEC 7064: the MOD 97-10 check character system.
- Directive (EU) 2015/2366 (PSD2), Articles 71 and 76: the 13-month notification period and the refund right for authorised direct debits.