{"id":8632,"library":"sepaxml","title":"SEPA XML Python Library","description":"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.","status":"active","version":"2.7.0","language":"en","source_language":"en","source_url":"https://github.com/raphaelm/python-sepaxml","tags":["financial","sepa","xml","payments","iban","bic","finance"],"install":[{"cmd":"pip install sepaxml","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"XML processing and validation","package":"lxml"},{"reason":"Robust date parsing and manipulation","package":"python-dateutil"},{"reason":"IBAN and BIC validation","package":"schwifty"}],"imports":[{"symbol":"CreditTransfer","correct":"from sepaxml import CreditTransfer"},{"symbol":"DirectDebit","correct":"from sepaxml import DirectDebit"},{"symbol":"ReturnFile","correct":"from sepaxml import ReturnFile"}],"quickstart":{"code":"import datetime\nfrom sepaxml import CreditTransfer\n\n# Prepare payment details\n# NOTE: For real use, ensure valid IBANs, BICs, and amounts\ncreditor_name = \"My Company Ltd\"\ncreditor_iban = \"DE98765432109876543210\"\ncreditor_bic = \"COBADEFFXXX\" # BIC is often optional for domestic payments\n\npayment = CreditTransfer(\n    schema=\"pain.001.001.03\",\n    iban=creditor_iban,\n    bic=creditor_bic,\n    name=creditor_name,\n    currency=\"EUR\"\n)\n\n# Add a transaction\npayment.add_payment(\n    iban=\"AT123456789012345678\",\n    bic=\"RZSTAT2SXXX\",\n    name=\"Recipient Name\",\n    amount=123.45,\n    description=\"Invoice 12345\",\n    collection_date=datetime.date.today()\n)\n\n# Generate XML\nxml_string = payment.export()\n\nprint(xml_string[:500]) # Print first 500 characters of the generated XML\n\n# Optional: Save to a file\n# with open('sepa_credit_transfer.xml', 'w') as f:\n#     f.write(xml_string)\n","lang":"python","description":"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."},"warnings":[{"fix":"Migrate to standard Python `datetime` for date handling and generate IDs manually if needed. Refer to the current documentation for updated practices.","message":"The `sepaxml.utils` module was removed in version 2.0.0. Functions like `today`, `parse_date`, and `gen_id` are no longer available or have been refactored.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure all financial identifiers (IBAN, BIC) are valid using a library like `schwifty` (which `sepaxml` uses internally) and that dates are passed as `datetime.date` objects. Consult the SEPA specifications for mandatory fields for your specific message type.","message":"SEPA XML files are strictly validated against their XSD schemas. Common issues include incorrect IBAN/BIC formats, invalid date formats, or missing mandatory fields.","severity":"gotcha","affected_versions":"All"},{"fix":"Always provide a BIC unless you are certain it's not required for your specific payment scenario (e.g., using `is_bic_optional=True` for direct debits if allowed by your bank). Banks may reject files if an optional BIC is present but incorrect, or if a mandatory BIC is missing.","message":"BIC (Bank Identifier Code) is often optional for domestic SEPA payments (within the same country). However, it is still mandatory for cross-border payments outside the Eurozone and for some specific payment types.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Review your `add_payment` calls. Common causes are invalid IBANs/BICs, incorrect date formats, or empty mandatory fields. Ensure all required parameters are provided and correctly formatted. Try printing the raw XML string before `export()` to inspect it.","cause":"The generated XML is not valid or contains errors, leading to `lxml` failing to parse it during validation or export.","error":"lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1"},{"fix":"Verify the IBAN string. It must be case-insensitive, contain only alphanumeric characters, and have the correct length and structure for its country. Double-check for typos or leading/trailing spaces.","cause":"`sepaxml` uses `schwifty` internally for IBAN/BIC validation, and the provided string does not conform to the IBAN specification.","error":"ValueError: Invalid IBAN 'DE1234'"},{"fix":"Update your code to use standard Python modules for common utilities. For example, replace `sepaxml.utils.today()` with `datetime.date.today()`.","cause":"You are attempting to use functionality from the `sepaxml.utils` module, which was removed in version 2.0.0.","error":"AttributeError: module 'sepaxml.utils' has no attribute 'today'"}]}