The client object
=================
+.. _client-state:
+
Storing and restoring client state
----------------------------------
* The User Parameter Data (UPD) with information about the user account and allowed actions
.. autoclass:: fints.client.FinTS3Client
- :members: __init__, deconstruct, set_data
+ :members: deconstruct, set_data
:noindex:
:undoc-members:
within the same dialog. In this case it's mandatory to use a standing dialog, because otherwise each
step would be issued in its own, implicit, dialog.
+.. _client-dialog-state:
Storing and restoring dialog state
----------------------------------
You should then enter a TAN, read our chapter :ref:`tans` to find out more.
-Example
--------
+Full example
+------------
You can easily generate XML using the ``sepaxml`` python library:
"description": "FinTS Test transaction",
})
pain_message = sepa.export().decode()
+
+ client = FinTS3PinTanClient(...)
+
+ accounts = client.get_sepa_accounts()
+ account = accounts[0]
+
+ mechanisms = client.get_tan_mechanisms()
+ mechanism = mechanisms[client.get_current_tan_mechanism()]
+ if mechanism.description_required == fints.formals.DescriptionRequired.MUST:
+ usage_option, media = client.get_tan_media()
+
+ client.set_tan_medium(media[0])
+
+ 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(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)
Working with TANs
=================
+Many operations in FinTS will require a form of two-step authentication, called TANs. TANs are
+mostly required for operations that move money or change details of a bank account. TANs can be
+generated with a multidue of methods, including paper lists, smartcard readers, SMS messages, and
+smartphone apps.
+
TAN methods
-----------
:func:`~fints.formals.TwoStepParametersCommon` subclass with varying fields, depending on the
version of the two-step process and the bank.
-.. autoclass:: fints.formals.TwoStepParameters3
- :noindex:
- :undoc-members:
- :members:
- :inherited-members:
- :member-order: bysource
- :exclude-members: is_unset, naive_parse, print_nested
+The `name` field of theese objects provides a user-friendly name of the TAN mechanism that you
+can display to the user to choose from. To select a TAN mechanism, you can use
+:func:`~fints.client.FinTS3PinTanClient.set_tan_mechanism`, which takes the identifier used as
+key in the :func:`~fints.client.FinTS3PinTanClient.get_tan_mechanisms` return value.
-.. autoclass:: fints.formals.TwoStepParameters5
- :noindex:
- :undoc-members:
- :members:
- :inherited-members:
- :member-order: bysource
- :exclude-members: is_unset, naive_parse, print_nested
-
-The `name` field provides a user-friendly name of the TAN mechanism that you can display to the user
-to choose from.
-
-To select a TAN mechanism/query the currently selected TAN mechanism use the appropriate functions which
-take/return the identifier used as key in the `get_tan_mechanisms` return value.
-
-.. autoclass:: fints.client.FinTS3PinTanClient
- :members: get_tan_mechanisms, set_tan_mechanism, get_current_tan_mechanism
- :noindex:
- :undoc-members:
+If the ``description_required`` attribute for the TAN mechanism is :attr:`~fints.formals.DescriptionRequired.MUST`,
+you will need to get a list of TAN media with :func:`~fints.client.FinTS3PinTanClient.get_tan_media` and select the
+appropriate one with :func:`~fints.client.FinTS3PinTanClient.set_tan_medium`.
-.. warning:: If the ``description_required`` attribute for the TAN mechanism is :attr:`~fints.formals.DescriptionRequired.MUST`,
- you will need to get a list of TAN media with `get_tan_media()` and select the appropriate
- one with `set_tan_medium()`.
+You may not change the active TAN mechanism or TAN medium within a standing dialog (see :ref:`client-dialog-state`).
-## FIXME The TAN media stuff is probably wrongly documented (and badly tested)
+The selection of the active TAN mechanism/medium is stored with the persistent client data (see :ref:`client-state`).
.. autoclass:: fints.client.FinTS3PinTanClient
- :members: get_tan_media, set_tan_medium
+ :members: get_tan_mechanisms, set_tan_mechanism, get_current_tan_mechanism, get_tan_media, set_tan_medium
:noindex:
:undoc-members:
-
-You may not change the active TAN mechanism or TAN medium within a standing dialog. (See XXX)
-The selection of the active TAN mechanism/medium is stored with the persistent client data. (See XXX)
-
TAN challenges
--------------
.. code-block:: python
- tan = input('Bitte die TAN eingeben.')
+ tan = input('Please enter the TAN code: ')
result = client.send_tan(result, tan)
tan_request = NeedRetryResponse.from_data(tan_data)
print("TAN request: {}".format(tan_request.challenge))
- tan = input('Enter TAN')
+ tan = input('Enter TAN: ')
.. code-block:: python
:caption: Third step
print(response.status)
print(response.responses)
+
+
+Reference
+---------
+
+.. autoclass:: fints.formals.TwoStepParameters3
+ :noindex:
+ :undoc-members:
+ :members:
+ :inherited-members:
+ :member-order: bysource
+ :exclude-members: is_unset, naive_parse, print_nested
+
+.. autoclass:: fints.formals.TwoStepParameters5
+ :noindex:
+ :undoc-members:
+ :members:
+ :inherited-members:
+ :member-order: bysource
+ :exclude-members: is_unset, naive_parse, print_nested