Skip to content

Commit

Permalink
Allow to pass system ID (#172)
Browse files Browse the repository at this point in the history
* Allow to pass system ID

* Fix TAN handshake
  • Loading branch information
raphaelm authored Oct 26, 2024
1 parent 06d3a75 commit 435fe18
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions fints/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class FinTSClientMode(Enum):
class FinTS3Client:
def __init__(self,
bank_identifier, user_id, customer_id=None,
from_data: bytes=None,
from_data: bytes=None, system_id=None,
product_id=None, product_version=version[:5],
mode=FinTSClientMode.INTERACTIVE):
self.accounts = []
Expand All @@ -170,7 +170,7 @@ def __init__(self,
self.bank_identifier = BankIdentifier(BankIdentifier.COUNTRY_ALPHA_TO_NUMERIC['DE'], bank_identifier)
else:
raise TypeError("bank_identifier must be BankIdentifier or str (BLZ)")
self.system_id = SYSTEM_ID_UNASSIGNED
self.system_id = system_id or SYSTEM_ID_UNASSIGNED
if not product_id:
raise TypeError("The product_id keyword argument is mandatory starting with python-fints version 4. See "
"https://python-fints.readthedocs.io/en/latest/upgrading_3_4.html for more information.")
Expand Down Expand Up @@ -1158,8 +1158,15 @@ def _new_dialog(self, lazy_init=False):
)

def fetch_tan_mechanisms(self):
self.set_tan_mechanism('999')
self._ensure_system_id()
if self.system_id and not self.get_current_tan_mechanism():
# system_id was persisted and given to the client, but nothing else
self.set_tan_mechanism('999')
with self._get_dialog(lazy_init=True) as dialog:
response = dialog.init()
self.process_response_message(dialog, response, internal_send=True)
else:
self.set_tan_mechanism('999')
self._ensure_system_id()
if self.get_current_tan_mechanism():
# We already got a reply through _ensure_system_id
return self.get_current_tan_mechanism()
Expand Down

0 comments on commit 435fe18

Please sign in to comment.