diff --git a/fints/client.py b/fints/client.py index 7e1d3c9..3d8ecc6 100644 --- a/fints/client.py +++ b/fints/client.py @@ -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 = [] @@ -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.") @@ -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()