File: debits.rst

package info (click to toggle)
python-fints 4.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 700 kB
  • sloc: python: 5,021; makefile: 196
file content (83 lines) | stat: -rw-r--r-- 2,408 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
.. _debits:

Creating SEPA debits
====================

You can submit a SEPA debit XML file to the bank with the ``sepa_debit`` method:

.. autoclass:: fints.client.FinTS3Client
   :members: sepa_debit
   :noindex:

You should then enter a TAN, read our chapter :ref:`tans` to find out more.

Full example
------------

You can easily generate XML using the ``sepaxml`` python library:

.. code-block:: python

    from sepaxml import SepaDD

    config = {
        "name": "Test Company",
        "IBAN": "DE12345",
        "BIC": "BIC12345",
        "batch": False,
        "creditor_id": "TESTCORPID",
        "currency": "EUR",
    }

    sepa = SepaDD(config, schema="pain.008.002.02")
    sepa.add_payment({
        "name": "Customer",
        "IBAN": "DE12345",
        "BIC": "BIC12345",
        "amount": 100,
        "type": "OOFF",  # FRST, RCUR, OOFF, FNAL
        "collection_date": datetime.date.today() + datetime.timedelta(days=3),
        "mandate_id": "FINTSTEST1",
        "mandate_date": datetime.date(2018, 7, 26),
        "description": "FinTS Test transaction",
    })
    pain_message = sepa.export().decode()

    client = FinTS3PinTanClient(...)
    minimal_interactive_cli_bootstrap(client)

    with client:
        if client.init_tan_response:
            print("A TAN is required", client.init_tan_response.challenge)

            if getattr(client.init_tan_response, 'challenge_hhduc', None):
                try:
                    terminal_flicker_unix(client.init_tan_response.challenge_hhduc)
                except KeyboardInterrupt:
                    pass

            tan = input('Please enter TAN:')
            client.send_tan(client.init_tan_response, tan)

        res = client.sepa_debit(
            account=accounts[0],
            data=pain_message,
            multiple=False,
            control_sum=Decimal('1.00'),
            pain_descriptor='urn:iso:std:iso:20022:tech:xsd:pain.008.002.02'
        )

        if isinstance(res, NeedTANResponse):
            print("A TAN is required", res.challenge)

            if getattr(res, 'challenge_hhduc', None):
                try:
                    terminal_flicker_unix(res.challenge_hhduc)
                except KeyboardInterrupt:
                    pass

            tan = input('Please enter TAN:')
            res = client.send_tan(res, tan)

        print(res.status)
        print(res.responses)