SEPA XML Python Library

2.7.0 · active · verified Thu Apr 16

sepaxml is a Python library for creating and parsing SEPA (Single Euro Payments Area) XML files, specifically supporting pain.001.001.03 (Credit Transfer), pain.008.001.02 (Direct Debit), and pain.002.001.03 (Return File) standards. It provides an intuitive API to construct payment instructions and handles XML serialization and deserialization. The current version is 2.7.0, and the library is actively maintained with regular updates to support standards and fix bugs.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to create a basic SEPA Credit Transfer (pain.001) XML file using `sepaxml`. It initializes a `CreditTransfer` object with creditor details and then adds a single payment transaction. Finally, it exports the payment instructions as an XML string.

import datetime
from sepaxml import CreditTransfer

# Prepare payment details
# NOTE: For real use, ensure valid IBANs, BICs, and amounts
creditor_name = "My Company Ltd"
creditor_iban = "DE98765432109876543210"
creditor_bic = "COBADEFFXXX" # BIC is often optional for domestic payments

payment = CreditTransfer(
    schema="pain.001.001.03",
    iban=creditor_iban,
    bic=creditor_bic,
    name=creditor_name,
    currency="EUR"
)

# Add a transaction
payment.add_payment(
    iban="AT123456789012345678",
    bic="RZSTAT2SXXX",
    name="Recipient Name",
    amount=123.45,
    description="Invoice 12345",
    collection_date=datetime.date.today()
)

# Generate XML
xml_string = payment.export()

print(xml_string[:500]) # Print first 500 characters of the generated XML

# Optional: Save to a file
# with open('sepa_credit_transfer.xml', 'w') as f:
#     f.write(xml_string)

view raw JSON →