]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
Allow to pass system ID (#172)
authorRaphael Michel <michel@rami.io>
Sat, 26 Oct 2024 14:26:28 +0000 (16:26 +0200)
committerGitHub <noreply@github.com>
Sat, 26 Oct 2024 14:26:28 +0000 (16:26 +0200)
* Allow to pass system ID

* Fix TAN handshake

fints/client.py

index 7e1d3c9225af8d8722ad6b12c10f8d270a619649..3d8ecc6f14d6a53bb5759760fe8b8ec0b2ce69c9 100644 (file)
@@ -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 @@ class FinTS3Client:
             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 @@ class FinTS3PinTanClient(FinTS3Client):
         )
 
     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()