]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
get_sepa_accounts() working
authorHenryk Plötz <henryk@ploetzli.ch>
Sat, 11 Aug 2018 18:55:28 +0000 (20:55 +0200)
committerRaphael Michel <mail@raphaelmichel.de>
Mon, 3 Dec 2018 18:34:17 +0000 (19:34 +0100)
fints/client.py
fints/connection.py
fints/formals.py
fints/message.py
fints/models.py
fints/segments/__init__.py

index 6aa40d28be838332458d3fc32ac48f080d94b0e6..2718b934137b8e9b97740bfb90784cf31a9071b7 100644 (file)
@@ -10,13 +10,14 @@ from fints.segments.debit import HKDSE, HKDME
 from .connection import FinTSHTTPSConnection
 from .dialog import FinTSDialog
 from .message import FinTSMessage
-from .models import SEPAAccount, TANMethod, TANChallenge6, TANChallenge5, TANChallenge3, TANChallenge4, TANChallenge
+from .models import SEPAAccount, TANChallenge6, TANChallenge5, TANChallenge3, TANChallenge4, TANChallenge
 from .segments.accounts import HKSPA
 from .segments.auth import HKTAN, HKTAB
 from .segments.depot import HKWPD
 from .segments.saldo import HKSAL
 from .segments.statement import HKKAZ
 from .segments.transfer import HKCCS, HKCCM
+from .formals import TwoStepParametersCommon
 from .utils import mt940_to_array, MT535_Miniparser, Password
 
 logger = logging.getLogger(__name__)
@@ -56,12 +57,9 @@ class FinTS3Client:
         logger.debug('Got HKSPA response: {}'.format(resp))
         dialog.end()
 
-        seg = resp._find_segment('HISPA')
         self.accounts = []
-        for arr in seg[1:]:
-            self.accounts.append(SEPAAccount(
-                iban=arr[1], bic=arr[2], accountnumber=arr[3], subaccount=arr[4], blz=arr[6]
-            ))
+        for seg in resp.find_segments('HISPA'):
+            self.accounts.extend(seg.accounts)
 
         return self.accounts
 
@@ -290,7 +288,7 @@ class FinTS3Client:
 
         challenge.dialog.end()
 
-    def start_simple_sepa_transfer(self, account: SEPAAccount, tan_method: TANMethod, iban: str, bic: str,
+    def start_simple_sepa_transfer(self, account: SEPAAccount, tan_method: TwoStepParametersCommon, iban: str, bic: str,
                                    recipient_name: str, amount: Decimal, account_name: str, reason: str,
                                    endtoend_id='NOTPROVIDED', tan_description=''):
         """
index 1f121f12b12afa333de02228585a824a3bdac27f..65d7fc323190eab88b83df7ce98d793a84354808 100644 (file)
@@ -27,6 +27,7 @@ class FinTSHTTPSConnection:
             raise FinTSConnectionError('Bad status code {}'.format(r.status_code))
         response = base64.b64decode(r.content.decode('iso-8859-1'))
         retval = FinTSResponse(response)
+        #import pprint; pprint.pprint(response)  FIXME Remove
         print("Received <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
         with Password.protect():
             retval.print_nested()
index 6004a394f3b904a5281afa3960d1f1577d24b9a7..aa2c53f53597c1d9095e8f13d19ae01f37de32c8 100644 (file)
@@ -806,3 +806,11 @@ class SupportedLanguages2(DataElementGroup):
 
 class SupportedHBCIVersions2(DataElementGroup):
     versions = DataElementField(type='code', max_length=3, min_count=1, max_count=9)
+
+class AccountInternational(DataElementGroup):
+    is_sepa = DataElementField(type='jn')
+    iban = DataElementField(type='an', max_length=34)
+    bic = DataElementField(type='an', max_length=11)
+    account_number = DataElementField(type='id')
+    subaccount_number = DataElementField(type='id')
+    bank_identifier = DataElementGroupField(type=BankIdentifier)
index eaa5def698afe4dc466e5662fd6948c46d86d359..a1a38c6d1dce7d01405ae78bffe49e4f0c6aa4d5 100644 (file)
@@ -19,9 +19,9 @@ class FinTSMessage:
         self.segments = []
         self.encrypted_segments = []
 
-        if tan_mechs and '999' not in [t.security_feature for t in tan_mechs]:
+        if tan_mechs and '999' not in [t.security_function for t in tan_mechs]:
             self.profile_version = 2
-            self.security_function = tan_mechs[0].security_feature
+            self.security_function = tan_mechs[0].security_function
         else:
             self.profile_version = 1
             self.security_function = '999'
index df4eb948adb31c793967d3257f4f47b5ba6726a1..6709df9b6c83a92299f3e9acd1b5c818c93cc017 100644 (file)
@@ -23,190 +23,6 @@ class DataClass:
         )
 
 
-class TANMethod(DataClass):
-    pass
-
-
-class TANMethod1(TANMethod):
-    """
-    :param security_feature:
-    :param tan_process:
-    :param tech_id:
-    :param name:
-    :param max_length_input:
-    :param allowed_format:
-    :param text_returnvalue:
-    :param max_length_returnvalue:
-    :param number_of_supported_lists:
-    :param multiple_tans_allowed:
-    :param tan_time_delayed_allowed:
-    """
-    # Source: PIN/TAN docs – Verfahrensparameter Zwei-Schritt-Verfahren, Elementversion #1
-    version = 1
-    args = ['security_feature', 'tan_process', 'tech_id', 'name', 'max_length_input', 'allowed_format',
-            'text_returnvalue', 'max_length_returnvalue', 'number_of_supported_lists', 'multiple_tans_allowed',
-            'tan_time_delayed_allowed']
-
-
-class TANMethod2(TANMethod):
-    """
-    :param security_feature:
-    :param tan_process:
-    :param tech_id:
-    :param name:
-    :param max_length_input:
-    :param allowed_format:
-    :param text_returnvalue:
-    :param max_length_returnvalue:
-    :param number_of_supported_lists:
-    :param multiple_tans_allowed:
-    :param tan_time_dialog_association:
-    :param tan_list_number_required:
-    :param cancel_allowed:
-    :param challenge_class_required:
-    :param challenge_value_required:
-    """
-    # Source: PIN/TAN docs – Verfahrensparameter Zwei-Schritt-Verfahren, Elementversion #2
-    version = 2
-    args = ['security_feature', 'tan_process', 'tech_id', 'name', 'max_length_input', 'allowed_format',
-            'text_returnvalue', 'max_length_returnvalue', 'number_of_supported_lists', 'multiple_tans_allowed',
-            'tan_time_dialog_association', 'tan_list_number_required', 'cancel_allowed', 'challenge_class_required',
-            'challenge_value_required']
-
-
-
-class TANMethod3(TANMethod):
-    """
-    :param security_feature:
-    :param tan_process:
-    :param tech_id:
-    :param name:
-    :param max_length_input:
-    :param allowed_format:
-    :param text_returnvalue:
-    :param max_length_returnvalue:
-    :param number_of_supported_lists:
-    :param multiple_tans_allowed:
-    :param tan_time_dialog_association:
-    :param tan_list_number_required:
-    :param cancel_allowed:
-    :param challenge_class_required:
-    :param challenge_value_required:
-    :param initialization_mode:
-    :param description_required:
-    :param supported_media_number:
-    """
-    # Source: PIN/TAN docs – Verfahrensparameter Zwei-Schritt-Verfahren, Elementversion #3
-    version = 3
-    args = ['security_feature', 'tan_process', 'tech_id', 'name', 'max_length_input', 'allowed_format',
-            'text_returnvalue', 'max_length_returnvalue', 'number_of_supported_lists', 'multiple_tans_allowed',
-            'tan_time_dialog_association', 'tan_list_number_required', 'cancel_allowed', 'challenge_class_required',
-            'challenge_value_required', 'initialization_mode', 'description_required', 'supported_media_number']
-
-
-class TANMethod4(TANMethod):
-    """
-    :param security_feature:
-    :param tan_process:
-    :param tech_id:
-    :param zka_id:
-    :param zka_version:
-    :param name:
-    :param max_length_input:
-    :param allowed_format:
-    :param text_returnvalue:
-    :param max_length_returnvalue:
-    :param number_of_supported_lists:
-    :param multiple_tans_allowed:
-    :param tan_time_dialog_association:
-    :param tan_list_number_required:
-    :param cancel_allowed:
-    :param sms_charge_account_required:
-    :param challenge_class_required:
-    :param challenge_value_required:
-    :param challenge_structured
-    :param initialization_mode:
-    :param description_required:
-    :param supported_media_number:
-    """
-    # Source: PIN/TAN docs – Verfahrensparameter Zwei-Schritt-Verfahren, Elementversion #4
-    version = 4
-    args = ['security_feature', 'tan_process', 'tech_id', 'zka_id', 'zka_version', 'name', 'max_length_input',
-            'allowed_format', 'text_returnvalue', 'max_length_returnvalue', 'number_of_supported_lists',
-            'multiple_tans_allowed', 'tan_time_dialog_association', 'tan_list_number_required', 'cancel_allowed',
-            'sms_charge_account_required', 'challenge_class_required', 'challenge_value_required',
-            'challenge_structured', 'initialization_mode', 'description_required', 'supported_media_number']
-
-
-
-class TANMethod5(TANMethod):
-    """
-    :param security_feature:
-    :param tan_process:
-    :param tech_id:
-    :param zka_id:
-    :param zka_version:
-    :param name:
-    :param max_length_input:
-    :param allowed_format:
-    :param text_returnvalue:
-    :param max_length_returnvalue:
-    :param number_of_supported_lists:
-    :param multiple_tans_allowed:
-    :param tan_time_dialog_association:
-    :param tan_list_number_required:
-    :param cancel_allowed:
-    :param sms_charge_account_required:
-    :param principal_account_required:
-    :param challenge_class_required:
-    :param challenge_value_required:
-    :param initialization_mode:
-    :param description_required:
-    :param supported_media_number:
-    """
-    # Source: PIN/TAN docs – Verfahrensparameter Zwei-Schritt-Verfahren, Elementversion #5
-    version = 5
-    args = ['security_feature', 'tan_process', 'tech_id', 'zka_id', 'zka_version', 'name', 'max_length_input',
-            'allowed_format', 'text_returnvalue', 'max_length_returnvalue', 'number_of_supported_lists',
-            'multiple_tans_allowed', 'tan_time_dialog_association', 'tan_list_number_required', 'cancel_allowed',
-            'sms_charge_account_required', 'principal_account_required', 'challenge_class_required',
-            'challenge_value_required', 'initialization_mode', 'description_required', 'supported_media_number']
-
-
-class TANMethod6(TANMethod):
-    # Source: PIN/TAN docs – Verfahrensparameter Zwei-Schritt-Verfahren, Elementversion #6
-    """
-    :param security_feature:
-    :param tan_process:
-    :param tech_id:
-    :param zka_id:
-    :param zka_version:
-    :param name:
-    :param max_length_input:
-    :param allowed_format:
-    :param text_returnvalue:
-    :param max_length_returnvalue:
-    :param number_of_supported_lists:
-    :param multiple_tans_allowed:
-    :param tan_time_dialog_association:
-    :param cancel_allowed:
-    :param sms_charge_account_required:
-    :param principal_account_required:
-    :param challenge_class_required:
-    :param challenge_value_required:
-    :param initialization_mode:
-    :param description_required:
-    :param hhd_uc_required:
-    :param supported_media_number:
-    """
-    version = 6
-    args = ['security_feature', 'tan_process', 'tech_id', 'zka_id', 'zka_version', 'name', 'max_length_input',
-            'allowed_format', 'text_returnvalue', 'max_length_returnvalue', 'multiple_tans_allowed',
-            'tan_time_dialog_association', 'cancel_allowed', 'sms_charge_account_required',
-            'principal_account_required',
-            'challenge_class_required', 'challenge_structured', 'initialization_mode', 'description_required',
-            'hhd_uc_required', 'supported_media_number']
-
 
 class TANChallenge(DataClass):
     def __init__(self, dialog, *args, **kwargs):
index 44bf1db864ca7511df3ac649e5191017b812295e..04fa53fc177d4b3d1b2f9b4305b3caae9bf8a0b9 100644 (file)
@@ -1,6 +1,6 @@
 import re
 
-from fints.formals import Container, ContainerMeta, SegmentHeader, DataElementGroupField, DataElementField, ReferenceMessage, SegmentSequenceField, SecurityProfile, SecurityIdentificationDetails, SecurityDateTime, EncryptionAlgorithm, KeyName, Certificate, HashAlgorithm, SignatureAlgorithm, UserDefinedSignature, Response, AccountInformation, AccountLimit, AllowedTransaction, ParameterTwostepTAN1, ParameterTwostepTAN2, ParameterTwostepTAN3, ParameterTwostepTAN4, ParameterTwostepTAN5, ParameterTwostepTAN6, ParameterPinTan, SupportedLanguages2, SupportedHBCIVersions2, BankIdentifier
+from fints.formals import Container, ContainerMeta, SegmentHeader, DataElementGroupField, DataElementField, ReferenceMessage, SegmentSequenceField, SecurityProfile, SecurityIdentificationDetails, SecurityDateTime, EncryptionAlgorithm, KeyName, Certificate, HashAlgorithm, SignatureAlgorithm, UserDefinedSignature, Response, AccountInformation, AccountLimit, AllowedTransaction, ParameterTwostepTAN1, ParameterTwostepTAN2, ParameterTwostepTAN3, ParameterTwostepTAN4, ParameterTwostepTAN5, ParameterTwostepTAN6, ParameterPinTan, SupportedLanguages2, SupportedHBCIVersions2, BankIdentifier, AccountInternational
 
 from fints.utils import classproperty, SubclassesMixin
 
@@ -187,3 +187,6 @@ class HIBPA3(FinTS3Segment):
     max_message_length = DataElementField(type='num', max_length=4, required=False)
     min_timeout = DataElementField(type='num', max_length=4, required=False)
     max_timeout = DataElementField(type='num', max_length=4, required=False)
+
+class HISPA1(FinTS3Segment):
+    accounts = DataElementGroupField(type=AccountInternational, max_count=999, required=False)