From: Raphael Michel Date: Mon, 23 Jul 2018 18:18:18 +0000 (+0200) Subject: Use English terminology X-Git-Tag: v1.0.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2ef98d7b9a7f9c3259d8cfd0e0cafa87e42b3d5;p=thirdparty%2Fpython-fints.git Use English terminology --- diff --git a/fints/client.py b/fints/client.py index 8f4f56e..1b19d4d 100644 --- a/fints/client.py +++ b/fints/client.py @@ -6,14 +6,12 @@ from .connection import FinTSHTTPSConnection from .dialog import FinTSDialog from .message import FinTSMessage from .models import SEPAAccount +from .segments.auth import HKTAN, HKTAB from .segments.accounts import HKSPA from .segments.statement import HKKAZ from .segments.saldo import HKSAL from .segments.depot import HKWPD -from .segments.sepaueb import HKCCS -from .segments.sepaueb import HKTAN -from .segments.sepaueb import HKTAB -from .segments.message import HNHBK +from .segments.transfer import HKCCS from .message import FinTSResponse from .utils import mt940_to_array, MT535_Miniparser, split_for_data_groups, split_for_data_elements, Password from mt940.models import Balance @@ -223,7 +221,7 @@ class FinTS3Client: if hversion in (1, 2, 3, 4, 5, 6): acc = ':'.join([ - account.accountnumber, account.subaccount, str(280), account.blz + account.accountnumber, account.subaccount, str(280), account.blz ]) elif hversion == 7: acc = ':'.join([ @@ -240,9 +238,7 @@ class FinTS3Client: ) ]) - # D. Nowak - def put_sepa_tan(self, arg): - + def send_tan(self, arg): data = str(arg['response']) res = FinTSResponse(data) @@ -269,8 +265,7 @@ class FinTS3Client: return 'Ok' - # D. Nowak - def put_sepa_ueberweisung(self, account, arg): + def create_sepa_transfer(self, account, arg): # Diese Funktion erstellt eine neue SEPA-Überweisung self.tan_bezeichnung = arg['TAN-Bezeichnung'] dialog = self._new_dialog() @@ -292,8 +287,6 @@ class FinTS3Client: with self.pin.protect(): logger.debug('Sending HKCCS: {}'.format(_get_msg())) - - resp = None resp = dialog.send(_get_msg()) logger.debug('Got HKCCS response: {}'.format(resp)) @@ -303,30 +296,28 @@ class FinTS3Client: return response - # D. Nowak - def get_tan_verfahren(self): - # Diese Funktion ermittelt die zugelassenen TAN-Verfahren und deren Parameter + def get_tan_methods(self): dialog = self._new_dialog() dialog.init() - # TAN-Verfahren ermitteln - res = FinTSResponse(str(dialog.bpd) ) + # Get tan methods + res = FinTSResponse(str(dialog.bpd)) seg = res._find_segment('HIRMS') deg = split_for_data_groups(seg) + tan_methods = [] for de in deg: if de[0:4] == '3920': - tan_verf = [] d = split_for_data_elements(de) - for i in range (3, len(d)): - tan_verf.append(d[i]) + for i in range(3, len(d)): + tan_methods.append(d[i]) - # Parameter der TAN-Verfahren ermitteln + # Get parameters for tan methods seg = res._find_segments('HITANS') verfahren = [] - for t in tan_verf: + for t in tan_methods: for s in seg: ct = s.find(t) - c0 = s[ct:].find(':00:') # Initialisierungsverfahren mit Klartext-PIN ohne TAN + c0 = s[ct:].find(':00:') # Initialisierungsverfahren mit Klartext-PIN ohne TAN if ct != -1 and c0 != -1: deg = s[ct:ct + c0 + 7] de = split_for_data_elements(deg) @@ -342,8 +333,7 @@ class FinTS3Client: return verfahren - # D. Nowak - def get_tan_bezeichnung(self): + def get_tan_description(self): dialog = self._new_dialog() dialog.sync() dialog.init() diff --git a/fints/dialog.py b/fints/dialog.py index 0b6a565..1dc58b9 100644 --- a/fints/dialog.py +++ b/fints/dialog.py @@ -23,6 +23,7 @@ class FinTSDialog: self.hksalversion = 6 self.hkkazversion = 6 self.tan_mechs = [] + self.bpd = None # Bank Parameter Data def _get_msg_sync(self): seg_identification = HKIDN(3, self.blz, self.username, 0) @@ -78,15 +79,12 @@ class FinTSDialog: with self.pin.protect(): logger.debug('Sending INIT: {}'.format(self._get_msg_init())) - resp = self.send(self._get_msg_init()) - logger.debug('Got INIT response: {}'.format(resp)) + self.bpd = self.send(self._get_msg_init()) + logger.debug('Got INIT response: {}'.format(self.bpd)) - self.dialogid = resp.get_dialog_id() + self.dialogid = self.bpd.get_dialog_id() logger.info('Received dialog ID: {}'.format(self.dialogid)) - # D. Nowak: BPD sichern - self.bpd = resp - return self.dialogid def end(self): diff --git a/fints/segments/auth.py b/fints/segments/auth.py index 16dc791..51d29b7 100644 --- a/fints/segments/auth.py +++ b/fints/segments/auth.py @@ -59,3 +59,43 @@ class HKSYN(FinTS3Segment): mode ] super().__init__(segmentno, data) + + +class HKTAN(FinTS3Segment): + """ + HKTAN (TAN-Verfahren festlegen) + Section C.2.1.2 + """ + type = 'HKTAN' + + def __init__(self, segno, process, aref, medium): + self.version = 3 + if process == 4: + if medium == '': + data = [ + process + ] + else: + data = [ + process, '', '', '', '', '', '', '', medium + ] + else: + data = [ + process, '', aref, '', 'N' + ] + super().__init__(segno, data) + + +class HKTAB(FinTS3Segment): + """ + HKTAB (Verfügbarre TAN-Medien ermitteln) + Section C.2.1.2 + """ + type = 'HKTAB' + + def __init__(self, segno): + self.version = 4 + data = [ + '0', 'A' + ] + super().__init__(segno, data) diff --git a/fints/segments/sepaueb.py b/fints/segments/transfer.py similarity index 67% rename from fints/segments/sepaueb.py rename to fints/segments/transfer.py index 576b767..cec70aa 100644 --- a/fints/segments/sepaueb.py +++ b/fints/segments/transfer.py @@ -1,6 +1,7 @@ from . import FinTS3Segment import datetime + class HKCCS(FinTS3Segment): """ HKCCS (SEPA Überweisung übertragen) @@ -10,17 +11,17 @@ class HKCCS(FinTS3Segment): def __init__(self, segno, account, arg): self.version = 1 - sepadescriptor = 'urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.03' - painmsg = self.create_pain(account, arg) - laenge = '@' + str(len(painmsg)) + '@' + sepa_descriptor = 'urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.03' + pain_msg = self.create_pain(account, arg) + length = '@{}@'.format(len(pain_msg)) msg = ':'.join([ account.iban, account.bic ]) data = [ msg, - sepadescriptor, - '@{}@{}'.format(len(painmsg), painmsg) + sepa_descriptor, + '@{}@{}'.format(len(pain_msg), pain_msg) ] super().__init__(segno, data) @@ -35,7 +36,7 @@ class HKCCS(FinTS3Segment): pain += '' + datetime.datetime.now().replace(microsecond=0).isoformat() + '' pain += '1' pain += '' + arg['CtrlSum'] + '' - pain += '' + arg['Nm']+ '' + pain += '' + arg['Nm'] + '' pain += '' pain += '' pain += '' + datetime.datetime.now().isoformat()[:-2] + '' @@ -60,41 +61,3 @@ class HKCCS(FinTS3Segment): pain += '' return pain - -class HKTAN(FinTS3Segment): - """ - HKTAN (TAN-Verfahren festlegen) - Section C.2.1.2 - """ - type = 'HKTAN' - - def __init__(self, segno, prozess, aref, medium): - self.version = 3 - if prozess == 4: - if medium == '': - data = [ - prozess - ] - else: - data = [ - prozess,'','','','','','','', medium - ] - else: - data = [ - prozess,'', aref, '', 'N' - ] - super().__init__(segno, data) - -class HKTAB(FinTS3Segment): - """ - HKTAB (Verfügbarre TAN-Medien ermitteln) - Section C.2.1.2 - """ - type = 'HKTAB' - - def __init__(self, segno): - self.version = 4 - data = [ - '0','A' - ] - super().__init__(segno, data)