Skip to main content

Python SEPA XML implementations

Project description

https://travis-ci.org/raphaelm/python-sepaxml.svg?branch=master https://codecov.io/gh/raphaelm/python-sepaxml/branch/master/graph/badge.svg http://img.shields.io/pypi/v/sepaxml.svg

This is a python implementation to generate SEPA XML files.

Limitations

Supported standards:

  • SEPA PAIN.001.001.03

  • SEPA PAIN.008.001.02

Usage

Direct debit

Example:

from sepaxml import SepaDD
import datetime, uuid

config = {
    "name": "Test von Testenstein",
    "IBAN": "NL50BANK1234567890",
    "BIC": "BANKNL2A",
    "batch": True,
    "creditor_id": "DE26ZZZ00000000000",  # supplied by your bank or financial authority
    "currency": "EUR",  # ISO 4217
    # "instrument": "B2B",  # - default is CORE (B2C)
    "address": {
        # The address and all of its fields are optional but in some countries they are required
        "address_type": "ADDR",  # valid: ADDR, PBOX, HOME, BIZZ, MLTO, DLVY
        "department": "Head Office",
        "subdepartment": None,
        "street_name": "Musterstr.",
        "building_number": "1",
        "postcode": "12345",
        "town": "Berlin",
        "country": "DE",
        "country_subdivision": None,
        "lines": ["Line 1", "Line 2"],
    },
}
sepa = SepaDD(config, schema="pain.008.001.02", clean=True)

payment = {
    "name": "Test von Testenstein",
    "IBAN": "NL50BANK1234567890",
    "BIC": "BANKNL2A",
    "amount": 5000,  # in cents
    "type": "RCUR",  # FRST,RCUR,OOFF,FNAL
    "collection_date": datetime.date.today(),
    "mandate_id": "1234",
    "mandate_date": datetime.date.today(),
    "description": "Test transaction",
    # "endtoend_id": str(uuid.uuid1()).replace("-", ""),  # autogenerated if obmitted
    "address": {
        # The address and all of its fields are optional but in some countries they are required
        "address_type": "ADDR",  # valid: ADDR, PBOX, HOME, BIZZ, MLTO, DLVY
        "department": "Head Office",
        "subdepartment": None,
        "street_name": "Musterstr.",
        "building_number": "1",
        "postcode": "12345",
        "town": "Berlin",
        "country": "DE",
        "country_subdivision": None,
        "lines": ["Line 1", "Line 2"],
    },
}
sepa.add_payment(payment)

print(sepa.export(validate=True))

Credit transfer

Example:

from sepaxml import SepaTransfer
import datetime, uuid

config = {
    "name": "Test von Testenstein",
    "IBAN": "NL50BANK1234567890",
    "BIC": "BANKNL2A",
    "batch": True,
    # For non-SEPA transfers, set "domestic" to True, necessary e.g. for CH/LI
    "currency": "EUR",  # ISO 4217
    "address": {
        # The address and all of its fields are optional but in some countries they are required
        "address_type": "ADDR",  # valid: ADDR, PBOX, HOME, BIZZ, MLTO, DLVY
        "department": "Head Office",
        "subdepartment": None,
        "street_name": "Musterstr.",
        "building_number": "1",
        "postcode": "12345",
        "town": "Berlin",
        "country": "DE",
        "country_subdivision": None,
        "lines": ["Line 1", "Line 2"],
    },
}
sepa = SepaTransfer(config, clean=True)

payment = {
    "name": "Test von Testenstein",
    "IBAN": "NL50BANK1234567890",
    "BIC": "BANKNL2A",
    "amount": 5000,  # in cents
    "execution_date": datetime.date.today() + datetime.timedelta(days=2),
    "description": "Test transaction",
    # "endtoend_id": str(uuid.uuid1()).replace("-", ""),  # optional
    "address": {
        # The address and all of its fields are optional but in some countries they are required
        "address_type": "ADDR",  # valid: ADDR, PBOX, HOME, BIZZ, MLTO, DLVY
        "department": "Head Office",
        "subdepartment": None,
        "street_name": "Musterstr.",
        "building_number": "1",
        "postcode": "12345",
        "town": "Berlin",
        "country": "DE",
        "country_subdivision": None,
        "lines": ["Line 1", "Line 2"],
    },
}
sepa.add_payment(payment)

print(sepa.export(validate=True))

Development

To run the included tests:

pip install -r requirements_dev.txt
py.test tests

To automatically sort your Imports as required by CI:

pip install isort
isort -rc .

Credits and License

Maintainer: Raphael Michel <mail@raphaelmichel.de>

This basically started as a properly packaged, python 3 tested version of the PySepaDD implementation that was released by The Congressus under the MIT license. Thanks for your work!

The source code is released under MIT license.

Not part of the MIT-licensed project are the XML schemas in the sepaxml/schemas/ folder which are copyrighted by the ISO 20022 organization but allowed to be reproduced freely.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sepaxml-2.6.2.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

sepaxml-2.6.2-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file sepaxml-2.6.2.tar.gz.

File metadata

  • Download URL: sepaxml-2.6.2.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for sepaxml-2.6.2.tar.gz
Algorithm Hash digest
SHA256 1f6f747bb4e15a12af1034964424c9cc17481127229e8d95693a5a96a3267561
MD5 dc40763eebe12fbd847a9131078086fb
BLAKE2b-256 ad896ebe206cc660d840183183a940c7d39c134c28841de4f2126584f6aa54a9

See more details on using hashes here.

File details

Details for the file sepaxml-2.6.2-py3-none-any.whl.

File metadata

  • Download URL: sepaxml-2.6.2-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for sepaxml-2.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2713adcc4e4d7893166382837351e7bd34cefebd9dab702389a1c051e2ee7066
MD5 c14d680ee6a3783a6c01e946788c54c7
BLAKE2b-256 b1e2976ab01d28a0e4e25dc35e166b88eceb1bbcf2bd3b6ca85a7ebe3ad2faa3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page