iamtorsten / libfintx

Moved to https://github.com/libfintx/libfintx - please use the new repository!
https://github.com/libfintx/libfintx
GNU Lesser General Public License v3.0
115 stars 40 forks source link

Nachricht ungueltig.:Validierung fehlgeschlagen with DKB in current version #94

Open korneliuscode opened 2 years ago

korneliuscode commented 2 years ago

I get an error with DKB on the most current version. Right with synchronization:

HNHBK:1:3+000000000137+300+0+1+0:1'
HIRMG:2:2+9010::Nachricht ungueltig.:Validierung fehlgeschlagen.+9800::Dialog abgebrochen'
HNHBS:3:1+1'

This is the trace of the sent message.

HNSHA:6:2+2146045886951968++XXXXXX'
HNHBK:1:3+000000000407+300+0+1'
HNVSK:998:3+PIN:1+998+1+1::0+1:20211211:140736+2:2:13:@8@00000000:5:1+280:12030000:XXXXXXXX:V:0:0+0'
HNVSD:999:1+@246@HNSHK:2:4+PIN:1+999+2146045886951968+1+1+1::0+1+1:20211211:140736+1:999:1+6:10:16+280:12030000:XXXXXXXX:S:0:0'
HKIDN:3:2+280:12030000+XXXXXXXX+0+1'
HKVVB:4:3+0+0+0+9FA6681DEC0CF3046BFC2F8A6+1.0.0'
HKSYN:5:3+0'
HNSHA:6:2+2146045886951968++XXXXXXXXXXX''
HNHBS:7:1+1'

Does anyone have an idea what this could be?

leschbenedikt commented 2 years ago

There is an error in the message creation. In line 705 and 726 in FinTsMessage.cs a StringBuilder is reused which results in a faulty message.

But even if I fix that I'm running into other issues later when trying the get the account balance.

party-pansen commented 2 years ago

I see the same issue with the latest version. But probably there is also something else:

@leschbenedikt Is this something you see after your fix?

Anyone else available to look into the DKB issue? I'll try to have a more detailed look within the next days at least to reproduce the old error message, but I am not really familiar with this bank communication stuff...

thisistorsten commented 2 years ago

Ich habe versucht die Library upzudaten. Scheinbar ist mir hier ein Fehler unterlaufen. Die Bibliothek benötigt jedoch ein komplettes Redesign/Refactoring.

leschbenedikt commented 2 years ago

@party-pansen I just checked my local code, the only othes changes I found were in HKKAZ.cs But the change is only related to transaction retrieval. I'm not sure what use case your are talking about.

But anyway this are the changes:

At first I added the segment Id to the call in line 147 segments = HKTAN.Init_HKTAN(client, segments, "HKKAZ");

In addition I replace every client.HICAZS with client.HIKAZS like in the commented rows below. But if I remenber it correctly this resolved problems with one bank but had issues with other banks. Maybe you try the first change at first and only try the second one if it's still not working.

party-pansen commented 2 years ago

Ok, I had some time to analyse:

There is a major bug in the new implementation as you already pointed out:
In line 705 and 726 in FinTsMessage.cs the following line needs to be added:
sb = new StringBuilder();

After that I get back to my original error message regarding "9955: Auftrag nicht ausgeführt - Die Gerätebezeichnung ist unbekannt."

After some research I found the following article: https://medium.com/@subsembly/leitfaden-deutsche-kreditbank-dkb-bbd2d23fb6b9

So there was indeed an issue with my TAN devices which I could solve online @ DKB by removing a second, old pushTan device...

Back to the program, it still did not work. I needed to provide a pushtan, but the generated HKTAN message has failures: HIRMG:3:2+9050::Die Nachricht enthält Fehler.+9800::Dialog abgebrochen+9000::Konvertierung in das/aus dem Format des Verarbeitungssystems fehlgeschlagen.'

Luckily I had an old trace which gave me a hint on the bug. It's simple: Just uncomment line 151 from Tan.cs That's again a bug when switching to sb.Append from old string concatenation

With that I am now able to get a correct answer from DKB. Unfortunately my accounts are not accessible as before switching to latest version. I need to analyze this...

Currently I have not yet github correctly setup to simply push the bugfixes, but I think these are extreme simple for you to incorporate @thisistorsten

I'll probably open up a new issue for the other bugs when anlzying them in the next days...

party-pansen commented 2 years ago

For me DKB is working again, besides the obvious bugfixes I already explained above, I needed to hack HKKAZ. I only did it for the relevant section for my bank and switched it back to some old HKKAZ string. I wonder what these changes in HKKAZ were all about?`It looked very different. Please review this in Branch bugfixes_dkb Regards party-pansen

thisistorsten commented 2 years ago

Can someone please retest?

party-pansen commented 2 years ago

the initial error is gone, but retrieving transactions via HKKAZ is not working for DKB. You did not honor my change to HKKAZ. At least for DKB this must be changed back to the old message...

iamtorsten commented 2 years ago

@party-pansen please recommend your changes here.

party-pansen commented 2 years ago

Please compare with my pushed branch bugfixing_pp. Since the segment now looks very different someone with some insight should have a look at it...

party-pansen commented 2 years ago

Within the same branch I also added 2 additional fixes for consorsbank, one regarding the consorsbank message format (6241d4e8b3f89f39396599b940b2a3e8608a0ee1) and the other also regarding the HKKAZ (8890b679415c245c2a6d74e84e2e0d278eb65489) Please have a look

korneliuscode commented 2 years ago

Is DKB working for you again? I also deleted my second pushTAN device, but still no luck on Master and also not on bugfixing_pp.

iamtorsten commented 1 year ago

@korneliuscode @party-pansen please retest with this PR. https://github.com/iamtorsten/libfintx/commit/0810e8fdbd3a942bc2899f3d0a18a94480d15cbb

korneliuscode commented 1 year ago

Sorry for the late reply. I was just trying but unfortunately it is not working for me still. I'm testing on the current version of master.

Code: 3060 | Typ: Warning | Nachricht: Bitte beachten Sie die enthaltenen Warnungen/Hinweise.
Code: 0020 | Typ: Success | Nachricht: Auftrag ausgeführt.
Code: 3050 | Typ: Warning | Nachricht: BPD nicht mehr aktuell, aktuelle Version enthalten.
Code: 3920 | Typ: Warning | Nachricht: Zugelassene Zwei-Schritt-Verfahren für den Benutzer.:xxx
Code: 0020 | Typ: Success | Nachricht: Der Auftrag wurde ausgeführt.
Code: 9050 | Typ: Error | Nachricht: Die Nachricht enthält Fehler.
Code: 9800 | Typ: Error | Nachricht: Dialog abgebrochen
Code: 9000 | Typ: Error | Nachricht: Konvertierung in das/aus dem Format des Verarbeitungssystems fehlgeschlagen.
Code: 9110 | Typ: Error | Nachricht: Ungültige Auftragsnachricht: Unbekannter Aufbau.
korneliuscode commented 1 year ago

I tested it again with the current master. It still does not work with DKB. The old version of the library works, but the results are somewhat malformed. Is there anything I can do to support?

leo-schick commented 11 months ago

Hi @korneliuscode ,

I think I had the same issue with DKB as you with. After running through code, I realized that I just typed in the IBAN and not the account number (Kontonummer) in the UI interface. Since DKB uses HKKAZ version 5, it still relyes on the account number and there seems to be no logic to extract the account number from the IBAN by default.

After entering the Kontonummer, all worked fine for me.

See as well HKKAZ.cs.

Log output with empty Kontonummer

Code: 3060 | Typ: Warning | Nachricht: Bitte beachten Sie die enthaltenen Warnungen/Hinweise.
Code: 0020 | Typ: Success | Nachricht: Auftrag ausgeführt.
Code: 3050 | Typ: Warning | Nachricht: BPD nicht mehr aktuell, aktuelle Version enthalten.
Code: 3920 | Typ: Warning | Nachricht: Zugelassene Zwei-Schritt-Verfahren für den Benutzer.:921
Code: 0020 | Typ: Success | Nachricht: Der Auftrag wurde ausgeführt.
Code: 9050 | Typ: Error | Nachricht: Die Nachricht enthält Fehler.
Code: 9110 | Typ: Error | Nachricht: Ungültige Auftragsnachricht: Unbekannter Aufbau.
Code: 9160 | Typ: Error | Nachricht: Pflichtfeld nicht gefunden
Code: 9010 | Typ: Error | Nachricht: Segment wegen anderer Fehler wirkungslos

Log output with filled Kontonummer

Code: 3060 | Typ: Warning | Nachricht: Bitte beachten Sie die enthaltenen Warnungen/Hinweise.
Code: 0020 | Typ: Success | Nachricht: Auftrag ausgeführt.
Code: 3050 | Typ: Warning | Nachricht: BPD nicht mehr aktuell, aktuelle Version enthalten.
Code: 3920 | Typ: Warning | Nachricht: Zugelassene Zwei-Schritt-Verfahren für den Benutzer.:921
Code: 0020 | Typ: Success | Nachricht: Der Auftrag wurde ausgeführt.
Code: 3060 | Typ: Warning | Nachricht: Bitte beachten Sie die enthaltenen Warnungen/Hinweise.
Code: 0020 | Typ: Success | Nachricht: Der Auftrag wurde ausgeführt.
Code: 0020 | Typ: Success | Nachricht: Die Umsätze wurden übermittelt.
Code: 3076 | Typ: Warning | Nachricht: Starke Kundenauthentifizierung nicht notwendig.
Datum: 01.11.2023 00:00:00 | Buchungsschlüssel: NDDT | GV-Code: 105 | Empfänger / Auftraggeber: ******* | Verwendungszweck: ************* | Betrag: -81,82
[ and more transactions ... ]
leo-schick commented 11 months ago

I would suggest to implement a test that required fields must be given before a message is send to the bank server.