Giter Site home page Giter Site logo

verenigingcampuskabel / python-sepa Goto Github PK

View Code? Open in Web Editor NEW
21.0 6.0 11.0 94 KB

Python library for parsing and building SEPA Direct Debit and SEPA eMandate schemas.

License: MIT License

Python 100.00%
python sepa direct-debits mandate transaction payment

python-sepa's Introduction

Python SEPA library

Python library for parsing and building SEPA Direct Debit and SEPA eMandate schemas.

The ultimate goal of this library is to support all ISO 20022 Payments messages, however in practice SEPA only uses a subset of these messages.

Supported messages

  • Cash Management (CAMT)
    • Bank To Customer Account Report v6 (camt.052.001.06)
    • Bank To Customer Statement v6 (camt.053.001.06)
    • Bank To Customer Debit Credit Notification v6 (camt.054.001.06)
    • Account Reporting Request v3 (camt.060.001.03)
  • Payments Initiation (PAIN)
    • Customer Credit Transfer Initiation v8 (pain.001.001.08)
    • Customer Payment Status Report v8 (pain.002.001.08)
    • Customer Payment Reversal v7 (pain.007.001.07)
    • Customer Direct Debit Initiation v7 (pain.008.001.07)
    • Mandate Initiation Request v5 (pain.009.001.05)
    • Mandate Amendment Request v5 (pain.010.001.05)
    • Mandate Cancellation Request v5 (pain.011.001.05)
    • Mandate Acceptance Report v5 (pain.012.001.05)
    • Creditor Payment Activation Request v6 (pain.013.001.06)
    • Creditor Payment Activation Request Status Report v6 (pain.014.001.06)
    • Mandate Copy Request v1 (pain.017.001.01)
    • Mandate Suspension Request v1 (pain.018.001.01)

Usage

Building messages

from sepa import builder

data_in = {
    'group_header': {},
    'mandate': [{
        'id': '78904536',
        'request_id': '9823701',
        'authentication': {
            'date': '2017-03-05',
            'channel': {
                'code': 'ABC'
            }
        }
    }]
}

# Returns an lxml etree object
data_out = builder.build(builder.mandate_initiation_request, data_in)

# Returns a byte string
str_data_out = builder.build_string(builder.mandate_initiation_request, data_in)
print(str_data_out)

Parsing messages

from sepa import parser

data_in = ('<MndtInitnReq>'
    '<GrpHdr></GrpHdr>'
    '<Mndt>'
        '<MndtId>78904536</MndtdId>'
        '<MndtReqId>9823701</MndtReqId>'
        '<Authntcn>'
            '<Dt>2017-03-05</Dt>'
            '<Chanl><Cd>ABC</Cd></Chanl>'
        '</Authntcn>'
    '</Mndt>'
'</MndtInitnReq>')

data_out = parser.parse_string(parser.mandate_initiation_request, data_in)
print(data_out)

Verifying messages

This feature is still work in progress.

Signing messages

This feature is still work in progress.

python-sepa's People

Contributors

bennierex avatar daniellehuisman avatar yoeori avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python-sepa's Issues

Use logging.debug instead of print in parser.py

Hi,

can you please get rid of the print statement in parser.py that prints "Unknown tag"?
It's kinda useless to see it all the time and pollutes the console.

In my repo/branch I fixed it myself and replaced it with logging.debug, see:
firepol@17874e3

Maybe you want to clean up also other commented print statements I've seen around and also replace them with logging.debug: logging is convenient as you can leave all logging statements uncommented, and activate only the debug level when you really need to debug.

Thx again for fixing the previous issue and for considering this one, cheers

Amount not parsed

Hi,

I'm parsing Swiss PostFinance camt.053 files (v4), your library works almost fine, except it doesn't parse the amount.

E.g.: in the XML, my balance elements look like this: <Amt Ccy="EUR">123.00</Amt>

In your example to get started I modified to get. instead of the mandate_initiation_request, the statement (bank_to_customer_statement):

data_out = parser.parse_string(parser.bank_to_customer_statement, data_in)
print(data_out)

Everything seems to be parsed correctly, except the amount that results in an empty dictionary:

'amount': {},

I spent already some time and I ended with my own "hack" in the parser.py in the parse_tree method:

    if tag.tag == 'Amt':
        return {'amount': tag.text,
                'currency': tag.attrib['Ccy']}

Probably for you a clean fix would be easier to do than for me. If you want I can provide an example of the PostFinance camt file, just let me know.

Wrong Tag in statement.py

After many hours of search I found the wrong written tag in the file 'statement.py', This had important consequences in my further data processing because of the lack of important text in the field 'AdditionalTransactionInformation'.

You have to change in the file 'statement.py' in line 208 and 409 the tag 'AddtTxInf' (wrong) to 'AddtlTxInf' (correct).

Greetings, David Rolli

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.