Skip to main content

Convert legacy SWIFT MT103 customer credit transfers to ISO 20022 pacs.008 flat records.

Project description

pacs008-loader-mt103: MT103 → pacs.008 loader

Convert legacy SWIFT MT103 single customer credit transfers into the flat records that the pacs008 library validates and turns into ISO 20022 pacs.008 XML. A single parse_mt103(text) call returns a one-element list[dict] ready to feed straight into pacs.008 generation.

Latest release: v0.0.1. The first deliverable of the MT→MX converter project. SWIFT MT-MX coexistence for cross-border payments ends in November 2025; this loader bridges the window where upstream systems still emit MT103 but downstream tooling expects pacs.008.

Contents

Overview

pacs008-loader-mt103 is a small, focused companion to the pacs008 ISO 20022 FI-to-FI Customer Credit Transfer library. It does one thing well: parse the mandatory + common-denominator MT103 grammar and hand back a flat record whose keys are exactly the ones pacs008 validates against the pacs.008.001.08 JSON schema. The correctness proof is that a realistic MT103 maps to a record that passes SchemaValidator("pacs.008.001.08").validate_batch(...) with zero errors.

Install

pacs008-loader-mt103 requires Python 3.10+ and pulls in pacs008 automatically.

pip install pacs008-loader-mt103

Quick Start

from pacs008_loader_mt103 import parse_mt103

mt103 = """:20:REF20240712001
:23B:CRED
:32A:260712EUR12345,67
:50K:/DE89370400440532013000
JOHN DOE
123 MAIN STREET
BERLIN
:52A:DEUTDEFF
:57A:CHASUS33
:59:/GB29NWBK60161331926819
ACME TRADING LTD
1 CORPORATE AVENUE
LONDON
:70:INVOICE 998877
:71A:SHA
"""

records = parse_mt103(mt103)
print(records[0]["interbank_settlement_amount"])   # 12345.67
print(records[0]["charge_bearer"])                 # SHAR

# Validate against the real pacs.008 schema:
from pacs008.validation.schema_validator import SchemaValidator
total, valid, errors = SchemaValidator("pacs.008.001.08").validate_batch(records)
assert valid == 1 and not errors

Field Mapping

parse_mt103(text: str) -> list[dict] — an MT103 is a single transfer, so the list always holds exactly one record.

MT103 field Meaning pacs.008 key Notes
:20: Sender's Reference msg_id Also fills end_to_end_id when :21: is absent
:21: Related Reference end_to_end_id Falls back to :20:
:32A: Value Date + Currency + Amount creation_date_time, interbank_settlement_currency, interbank_settlement_amount Date → ISO datetime at midnight; amount comma-decimal → float
:50A/50F/50K: Ordering Customer debtor_name Name from option A (BIC), F (1/ sub-field) or K (name+address)
:52A/52D: Ordering Institution debtor_agent_bic BIC from option A (or a BIC in option D)
:57A/57D: Account With Institution creditor_agent_bic BIC from option A (or a BIC in option D)
:59/59A/59F: Beneficiary Customer creditor_name Name from plain 59, option A (BIC) or F (1/)
:71A: Details of Charges charge_bearer OURDEBT, BENCRED, SHASHAR
(synthesised) nb_of_txs Always 1
(synthesised) settlement_method Defaults to CLRG

Assumptions and defaults

  • settlement_method = "CLRG" — a bank-to-bank MT103 typically settles through a clearing system. Override downstream for cover payments (COVE) or correspondent-account settlement (INDA / INGA).
  • nb_of_txs = 1 — an MT103 carries exactly one customer transfer.
  • creation_date_time — MT103 has no message timestamp, so the :32A: value date at 00:00:00 is used. Two-digit years follow the SWIFT sliding window (00–79 → 20YY, 80–99 → 19YY).
  • Absent optional fields are omitted, not guessed. A schema-valid pacs.008 record needs the debtor agent BIC (:52a:), creditor agent BIC (:57a:) and charge bearer (:71A:); a well-formed interbank MT103 carries all three. When block 4 lacks an ordering / account-with institution, real pacs.008 generation falls back to the Sender / Receiver BIC in the application header (blocks 1/2) — that fallback is the caller's responsibility; this loader reads block 4 only.
  • Hard requirements — only :20:, :32A: and a beneficiary (:59:/:59A:/:59F:) raise ValueError. Everything else is best-effort. The loader never crashes on unexpected input.

Out of scope

This is the correct core MT103 → pacs.008 mapping, not every optional field. Deliberately excluded in v0.0.1:

  • :33B: instructed currency/amount and :36: exchange rate (FX legs).
  • :70: remittance information and :72: sender-to-receiver info.
  • :23B: / :23E: operation and instruction codes, :26T:, :77B: regulatory reporting, :77T: envelope contents.
  • :53a: / :54a: / :55a: / :56a: correspondent and intermediary institutions.
  • The SWIFT application header (blocks 1/2) as an agent-BIC fallback.

Examples

Two runnable scripts live in examples/, exercised in CI:

Development

git clone https://github.com/sebastienrousseau/pacs008-loader-mt103
cd pacs008-loader-mt103
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest                          # 100% line + branch coverage gate
interrogate pacs008_loader_mt103  # 100% docstring gate
mypy pacs008_loader_mt103       # strict

Security

pacs008-loader-mt103 parses a flat text format with no XML envelope — the XXE / billion-laughs surface lives upstream. Field regexes are anchored and bounded, so catastrophic backtracking is not a concern. See SECURITY.md.

License

Licensed under the Apache License, Version 2.0. Any contribution submitted for inclusion shall be licensed as above, without additional terms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pacs008_loader_mt103-0.0.1.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pacs008_loader_mt103-0.0.1-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file pacs008_loader_mt103-0.0.1.tar.gz.

File metadata

  • Download URL: pacs008_loader_mt103-0.0.1.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pacs008_loader_mt103-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4d3fbf8d20c62481e259779ce67f2d4488fd7742a8346d2057786bf61e0e84b6
MD5 7529da9c091d8cc19ac18bf29a5b8239
BLAKE2b-256 e92b2f03ec817503a4c2c8731b02013a5912270106ca148a744de03e22ad5d0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pacs008_loader_mt103-0.0.1.tar.gz:

Publisher: release.yml on sebastienrousseau/pacs008-loader-mt103

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pacs008_loader_mt103-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pacs008_loader_mt103-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e321f394e9b9981575328d30a98064f663b4327c7163daec53fe104f9f4c26f
MD5 cac428721874b498573b370e5f6c38f4
BLAKE2b-256 85ed9740b22877c42afe5443e1a4b0d96086520885d77280a52d67d95a18c964

See more details on using hashes here.

Provenance

The following attestation bundles were made for pacs008_loader_mt103-0.0.1-py3-none-any.whl:

Publisher: release.yml on sebastienrousseau/pacs008-loader-mt103

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page