fix: HKWPD v6 depot requests use IBAN-based account format + add FinTS 4 holdings support#43
fix: HKWPD v6 depot requests use IBAN-based account format + add FinTS 4 holdings support#43
Conversation
- Add buildHoldingsSegment() to v4/segments/index.ts - Add mt535Data field to FinTS4Response in v4/types.ts - Add Holdings segment parsing to v4/xml-parser.ts - Add supportsHoldings and holdingsVersion to v4/dialog.ts - Update capabilities() to return supportsHoldings - Add holdings() method to v4/client.ts using MT535Parser - Add TEST_DEPOT_ACCOUNTS and buildTestMt535() to test-server test-data - Add handleHoldings() handler to mock bank server - Export buildHoldingsSegment from v4/index.ts - Add unit and integration tests for holdings All 548 tests pass. Agent-Logs-Url: https://github.com/larsdecker/fints/sessions/01321a03-38c4-4154-90a5-9dc02b5f76f2 Co-authored-by: larsdecker <1968186+larsdecker@users.noreply.github.com>
Agent-Logs-Url: https://github.com/larsdecker/fints/sessions/01321a03-38c4-4154-90a5-9dc02b5f76f2 Co-authored-by: larsdecker <1968186+larsdecker@users.noreply.github.com>
ING-DiBa (and other banks) advertise HIWPDS version 6, which per the FinTS 3.0 spec requires KTIN (international account: IBAN+BIC+accountNumber+subAccount+ countryCode+BLZ) instead of the legacy KTV format (accountNumber+subAccount+ countryCode+BLZ) used by version 5. Sending the old KTV format to a v6 endpoint caused ING to return: 9050 - Nachrichtensignatur fehlerhaft oder fehlt 9210 - Diese Auftragsart ist mit diesem Konto nicht möglich Matches the same pattern already used by HKSAL v7 and HKKAZ v7. Fixes the depot query error for ING customers. Agent-Logs-Url: https://github.com/larsdecker/fints/sessions/420dc763-42fb-4910-8df7-a10f511ee431 Co-authored-by: larsdecker <1968186+larsdecker@users.noreply.github.com>
Agent-Logs-Url: https://github.com/larsdecker/fints/sessions/420dc763-42fb-4910-8df7-a10f511ee431 Co-authored-by: larsdecker <1968186+larsdecker@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes FinTS 3 HKWPD v6 depot-request serialization for IBAN-based KTIN accounts and adds end-to-end holdings (MT535) support to the FinTS 4.1 XML client, including mock server + tests.
Changes:
- Adjust HKWPD v6 account serialization to KTIN (IBAN/BIC-based) and add coverage for v5 vs v6 serialization.
- Add FinTS 4.1 holdings support: segment builder, capability detection, response parsing (
mt535Data), and a newFinTS4Client.holdings()API. - Extend FinTS 4.1 mock server/test data and update docs formatting.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/fints/src/v4/xml-parser.ts | Parses <Mt535Data> from Holdings response segments into mt535Data. |
| packages/fints/src/v4/types.ts | Adds mt535Data?: string to FinTS4Response. |
| packages/fints/src/v4/test-server/test-data.ts | Adds depot account fixtures, holdings capabilities, and an MT535 fixture generator. |
| packages/fints/src/v4/test-server/mock-bank-server.ts | Adds Holdings request handling and returns MT535 payloads. |
| packages/fints/src/v4/segments/index.ts | Adds buildHoldingsSegment() request builder. |
| packages/fints/src/v4/index.ts | Exports buildHoldingsSegment. |
| packages/fints/src/v4/dialog.ts | Tracks holdings support/version via segment capabilities and exposes via capabilities. |
| packages/fints/src/v4/client.ts | Introduces FinTS4Client.holdings() with touchdown pagination and MT535 parsing. |
| packages/fints/src/v4/tests/test-segments.ts | Unit tests for the new Holdings segment builder. |
| packages/fints/src/v4/tests/test-mock-bank-integration.ts | Integration tests covering holdings response parsing + capabilities. |
| packages/fints/src/v4/tests/test-client.ts | Client-level tests for holdings parsing and unsupported-bank behavior. |
| packages/fints/src/segments/hkwpd.ts | Switches HKWPD v6 to KTIN serialization while keeping v5 as KTV. |
| packages/fints/src/segments/tests/test-hkwpd.ts | New tests verifying HKWPD v5 vs v6 serialization formats. |
| packages/fints/README.md | Formatting tweaks to code examples. |
| README.md | Formatting tweaks to code examples and troubleshooting section spacing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| account: { | ||
| iban: TEST_ACCOUNTS[0].iban, | ||
| bic: TEST_ACCOUNTS[0].bic, | ||
| accountNumber: TEST_ACCOUNTS[0].accountNumber, | ||
| blz: TEST_ACCOUNTS[0].blz, | ||
| }, | ||
| }), |
There was a problem hiding this comment.
The holdings integration test uses TEST_ACCOUNTS[0] (a giro account) as the target for a depot/holdings query. Since this feature is explicitly for depot accounts and you introduced TEST_DEPOT_ACCOUNTS, it would be better to use a depot account fixture here to ensure the test exercises the intended account type and the new depot data path.
|
@copilot apply changes based on the comments in this thread |
- FinTS4Client.holdings(): attach TAN segment (process "4") on the first request when tanVersion >= 1 and tanMethods are available, matching the pattern already used by camtStatements() for SCA-required banks - Integration test: switch from TEST_ACCOUNTS[0] (giro) to TEST_DEPOT_ACCOUNTS[0] (Wertpapierdepot) for holdings test fixture Agent-Logs-Url: https://github.com/larsdecker/fints/sessions/16b6bd0e-c388-4af1-9aae-380520d6d801 Co-authored-by: larsdecker <1968186+larsdecker@users.noreply.github.com>
Both review comments addressed in commit
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Two related changes: a bug fix for ING-DiBa depot queries failing with
9050/9210errors, and new depot/holdings support in the FinTS 4 XML client.Bug fix: HKWPD version 6 account format
HKWPD(Depotaufstellung) used the legacy KTV format (accountNumber::280:blz) for both v5 and v6. The FinTS 3.0 spec requires version 6 to use the KTIN international format (iban:bic:accountNumber::280:blz) — the same patternHKSALv7 andHKKAZv7 already follow.ING-DiBa advertises
HIWPDSv6. Sending KTV to a v6 endpoint caused:Fix in
hkwpd.ts:New
test-hkwpd.tscovers both serialization paths.FinTS 4 holdings support
The FinTS 4 XML client (
FinTS4Client) had no equivalent of the v3holdings()method —supportsHoldingswas hardcodedfalse.buildHoldingsSegment()— new XML segment builder (typeHoldings, analogous to v3HKWPD)FinTS4Response.mt535Data— populated from<Mt535Data>in aHoldingsresponse segmentFinTS4Dialog— newsupportsHoldings/holdingsVersionproperties;updateCapabilities()detectsHoldingsorHIWPDSin BPDFinTS4Client.holdings(account)— pagination-aware, reuses the existingMT535Parser, throws when capability is absentHoldingshandler + synthetic MT535 depot fixture