| 1 |
SEPA XML Generator |
| 2 |
================== |
| 3 |
|
| 4 |
.. image:: https://travis-ci.org/raphaelm/python-sepaxml.svg?branch=master |
| 5 |
:target: https://travis-ci.org/raphaelm/python-sepaxml |
| 6 |
|
| 7 |
.. image:: https://codecov.io/gh/raphaelm/python-sepaxml/branch/master/graph/badge.svg |
| 8 |
:target: https://codecov.io/gh/raphaelm/python-sepaxml |
| 9 |
|
| 10 |
.. image:: http://img.shields.io/pypi/v/sepaxml.svg |
| 11 |
:target: https://pypi.python.org/pypi/sepaxml |
| 12 |
|
| 13 |
This is a python implementation to generate SEPA XML files. |
| 14 |
|
| 15 |
Limitations |
| 16 |
----------- |
| 17 |
|
| 18 |
Supported standards: |
| 19 |
|
| 20 |
* SEPA PAIN.001.001.03 |
| 21 |
* SEPA PAIN.001.001.09 |
| 22 |
* SEPA PAIN.001.001.10 |
| 23 |
* SEPA PAIN.001.001.11 |
| 24 |
* SEPA PAIN.008.001.02 |
| 25 |
* SEPA PAIN.008.001.08 |
| 26 |
* SEPA PAIN.008.001.09 |
| 27 |
* SEPA PAIN.008.001.10 |
| 28 |
|
| 29 |
Usage |
| 30 |
----- |
| 31 |
|
| 32 |
Direct debit |
| 33 |
"""""""""""" |
| 34 |
|
| 35 |
Example: |
| 36 |
|
| 37 |
.. code:: python |
| 38 |
|
| 39 |
from sepaxml import SepaDD |
| 40 |
import datetime, uuid |
| 41 |
|
| 42 |
config = { |
| 43 |
"name": "Test von Testenstein", |
| 44 |
"IBAN": "NL50BANK1234567890", |
| 45 |
"BIC": "BANKNL2A", |
| 46 |
"batch": True, |
| 47 |
"creditor_id": "DE26ZZZ00000000000", # supplied by your bank or financial authority |
| 48 |
"currency": "EUR", # ISO 4217 |
| 49 |
# "instrument": "B2B", # - default is CORE (B2C) |
| 50 |
"address": { |
| 51 |
# The address and all of its fields are optional but in some countries they are required |
| 52 |
"address_type": "ADDR", # valid: ADDR, PBOX, HOME, BIZZ, MLTO, DLVY |
| 53 |
"department": "Head Office", |
| 54 |
"subdepartment": None, |
| 55 |
"street_name": "Musterstr.", |
| 56 |
"building_number": "1", |
| 57 |
"postcode": "12345", |
| 58 |
"town": "Berlin", |
| 59 |
"country": "DE", |
| 60 |
"country_subdivision": None, |
| 61 |
"lines": ["Line 1", "Line 2"], |
| 62 |
}, |
| 63 |
} |
| 64 |
sepa = SepaDD(config, schema="pain.008.001.02", clean=True) |
| 65 |
|
| 66 |
payment = { |
| 67 |
"name": "Test von Testenstein", |
| 68 |
"IBAN": "NL50BANK1234567890", |
| 69 |
"BIC": "BANKNL2A", |
| 70 |
"amount": 5000, # in cents |
| 71 |
"type": "RCUR", # FRST,RCUR,OOFF,FNAL |
| 72 |
"collection_date": datetime.date.today(), |
| 73 |
"mandate_id": "1234", |
| 74 |
"mandate_date": datetime.date.today(), |
| 75 |
"description": "Test transaction", |
| 76 |
# "endtoend_id": str(uuid.uuid1()).replace("-", ""), # autogenerated if obmitted |
| 77 |
"address": { |
| 78 |
# The address and all of its fields are optional but in some countries they are required |
| 79 |
"address_type": "ADDR", # valid: ADDR, PBOX, HOME, BIZZ, MLTO, DLVY |
| 80 |
"department": "Head Office", |
| 81 |
"subdepartment": None, |
| 82 |
"street_name": "Musterstr.", |
| 83 |
"building_number": "1", |
| 84 |
"postcode": "12345", |
| 85 |
"town": "Berlin", |
| 86 |
"country": "DE", |
| 87 |
"country_subdivision": None, |
| 88 |
"lines": ["Line 1", "Line 2"], |
| 89 |
}, |
| 90 |
} |
| 91 |
sepa.add_payment(payment) |
| 92 |
|
| 93 |
print(sepa.export(validate=True)) |
| 94 |
|
| 95 |
|
| 96 |
Credit transfer |
| 97 |
""""""""""""""" |
| 98 |
|
| 99 |
Example: |
| 100 |
|
| 101 |
.. code:: python |
| 102 |
|
| 103 |
from sepaxml import SepaTransfer |
| 104 |
import datetime, uuid |
| 105 |
|
| 106 |
config = { |
| 107 |
"name": "Test von Testenstein", |
| 108 |
"IBAN": "NL50BANK1234567890", |
| 109 |
"BIC": "BANKNL2A", |
| 110 |
"batch": True, |
| 111 |
# For non-SEPA transfers, set "domestic" to True, necessary e.g. for CH/LI |
| 112 |
"currency": "EUR", # ISO 4217 |
| 113 |
"address": { |
| 114 |
# The address and all of its fields are optional but in some countries they are required |
| 115 |
"address_type": "ADDR", # valid: ADDR, PBOX, HOME, BIZZ, MLTO, DLVY |
| 116 |
"department": "Head Office", |
| 117 |
"subdepartment": None, |
| 118 |
"street_name": "Musterstr.", |
| 119 |
"building_number": "1", |
| 120 |
"postcode": "12345", |
| 121 |
"town": "Berlin", |
| 122 |
"country": "DE", |
| 123 |
"country_subdivision": None, |
| 124 |
"lines": ["Line 1", "Line 2"], |
| 125 |
}, |
| 126 |
} |
| 127 |
sepa = SepaTransfer(config, clean=True) |
| 128 |
|
| 129 |
payment = { |
| 130 |
"name": "Test von Testenstein", |
| 131 |
"IBAN": "NL50BANK1234567890", |
| 132 |
"BIC": "BANKNL2A", |
| 133 |
"amount": 5000, # in cents |
| 134 |
"execution_date": datetime.date.today() + datetime.timedelta(days=2), |
| 135 |
"description": "Test transaction", |
| 136 |
# "endtoend_id": str(uuid.uuid1()).replace("-", ""), # optional |
| 137 |
"address": { |
| 138 |
# The address and all of its fields are optional but in some countries they are required |
| 139 |
"address_type": "ADDR", # valid: ADDR, PBOX, HOME, BIZZ, MLTO, DLVY |
| 140 |
"department": "Head Office", |
| 141 |
"subdepartment": None, |
| 142 |
"street_name": "Musterstr.", |
| 143 |
"building_number": "1", |
| 144 |
"postcode": "12345", |
| 145 |
"town": "Berlin", |
| 146 |
"country": "DE", |
| 147 |
"country_subdivision": None, |
| 148 |
"lines": ["Line 1", "Line 2"], |
| 149 |
}, |
| 150 |
} |
| 151 |
sepa.add_payment(payment) |
| 152 |
|
| 153 |
print(sepa.export(validate=True)) |
| 154 |
|
| 155 |
|
| 156 |
Development |
| 157 |
----------- |
| 158 |
|
| 159 |
To run the included tests:: |
| 160 |
|
| 161 |
pip install -r requirements_dev.txt |
| 162 |
py.test tests |
| 163 |
|
| 164 |
To automatically sort your Imports as required by CI:: |
| 165 |
|
| 166 |
pip install isort |
| 167 |
isort -rc . |
| 168 |
|
| 169 |
|
| 170 |
Security |
| 171 |
-------- |
| 172 |
|
| 173 |
If you discover a security issue, please contact us at [email protected] and see our `Responsible Disclosure Policy`_ further information. |
| 174 |
|
| 175 |
Credits and License |
| 176 |
------------------- |
| 177 |
|
| 178 |
Maintainer: Raphael Michel <[email protected]> |
| 179 |
|
| 180 |
This basically started as a properly packaged, python 3 tested version |
| 181 |
of the `PySepaDD`_ implementation that was released by The Congressus under the MIT license. |
| 182 |
Thanks for your work! |
| 183 |
|
| 184 |
The source code is released under MIT license. |
| 185 |
|
| 186 |
Not part of the MIT-licensed project are the XML schemas in the ``sepaxml/schemas/`` |
| 187 |
folder which are copyrighted by the ISO 20022 organization but `allowed to be reproduced`_ |
| 188 |
freely. |
| 189 |
|
| 190 |
.. _PySepaDD: https://github.com/congressus/PySepaDD |
| 191 |
.. _allowed to be reproduced: https://www.iso20022.org/terms-use |
| 192 |
.. _Responsible Disclosure Policy: https://docs.pretix.eu/trust/security/disclosure/ |