Ìtọ́kasí

Ìtọ́kasí Ìmọ̀-ẹ̀rọ Pain001: CLI, Python API àti REST

Gbogbo àsíá, endpoint, àti ìhùwàsí pain001 v0.0.91, láti inú kóòdù tí a ti tú jáde, kì í ṣe láti inú ìfẹ́-ọkàn.

Ìtọ́kasí yìí ṣàlàyé ojú-ìbáṣepọ̀ ìlà àṣẹ, Python API, iṣẹ́ kékeré REST, àti ìlànà ìṣàyẹ̀wò fún pain001 v0.0.91. Gbogbo àsíá, endpoint, àti ìhùwàsí tí a kọ síbí wá láti inú kóòdù tí a ti tú jáde, kì í ṣe láti inú ìfẹ́-ọkàn.

Pain001 ń ṣe àtìlẹ́yìn fún ìtumọ̀ ìránṣẹ́ ISO 20022 mẹ́tàlá: láti pain.001.001.03 dé pain.001.001.13 (ìbẹ̀rẹ̀ ìfiránṣẹ́ owó ti oníbàárà, ẹ̀yà mọ́kànlá) àti pain.008.001.02 / pain.008.001.08 (ìbẹ̀rẹ̀ ìgbà owó tààrà ti oníbàárà).


1. Ojú-ìbáṣepọ̀ Ìlà Àṣẹ#

Fáìlì ìṣiṣẹ́ pain001 pín àwọn iṣẹ́ rẹ̀ sí àwọn àṣẹ-abẹ́. Bí ẹ bá ń lò ó pẹ̀lú àwọn àsíá ìṣẹ̀dá nìkan, ó ń pe generate lọ́nà tí kò hàn, nítorí náà àwọn ètò aládàáṣiṣẹ́ tí ẹ ti ní yóò máa bá iṣẹ́ rẹ̀ lọ.

Àṣẹ-abẹ́ Ìdí
generate Yí fáìlì dátà padà sí XML ISO 20022 tí a ti ṣàyẹ̀wò pẹ̀lú schema (àṣẹ ìpìlẹ̀).
validate Ṣàyẹ̀wò dátà ìtẹ̀wọlé láìkọ XML.
check <file>... [--scheme] [--format] Check pain.001 or pain.008 files you already have: the XSD of the message type each file declares, the message definition's cross-element rules, and any scheme profiles, policy or Schematron rulebook you name.
verify-signature <file>... --cert <PEM> Verify the XML-DSig signature on each file against the signer's certificate or public key; --trust-embedded-cert checks integrity only (requires the sign extra).
versions [--format json] Ṣe àkójọ gbogbo ìtumọ̀ ìránṣẹ́ mẹ́tàlá tí a ń ṣe àtìlẹ́yìn fún.
inspect <type> [--format json] Ó ń fi àwòṣe tí ó wà pẹ̀lú rẹ̀ hàn, ètò schema, dátà àpẹẹrẹ àti àwọn ọ̀nà ìtẹ̀wọlé tí a gbà fún irú ìfiránṣẹ́ kan.
init <type> [-o FILE] Ṣẹ̀dá àwòṣe CSV ìbẹ̀rẹ̀ fún irú ìránṣẹ́ kan.
serve [--host] [--port] [--reload] Tú iṣẹ́ kékeré REST FastAPI jáde (ó nílò àfikún api).
mcp Ó ń bẹ̀rẹ̀ sáfà Model Context Protocol tí ó wà nínú ilé-ìkàwé àkọ́kọ́ nípasẹ̀ stdio (ó nílò àfikún mcp); sáfà kíkún ń jáde gẹ́gẹ́ bí pain001-mcp.
plugins list / show / disable Ó ń ṣe àkójọ àwọn plugin olùgbé, olùṣàyẹ̀wò, ètò àti olùkọ̀wé tí a rí, ó ń fi ọ̀kan hàn, tàbí ó ń sọ bí a ṣe ń pa wíwá plugin ẹgbẹ́ kẹta.
face <file> [--face] [--bindings] [-o] [--loss-report] Project a pain.001 XML file into another standard's JSON shape, with a report of every element not carried.
upload [<file>] --sftp <url> Deliver a file atomically to an SFTP server you trust explicitly (requires the upload extra).

Àwọn àṣàyàn generate

Àsíá Àpèjúwe
-t, --xml-message-type <TYPE> Ìtumọ̀ ìránṣẹ́, fún àpẹẹrẹ pain.001.001.09.
-d, --data <FILE> Dátà ìtẹ̀wọlé: .csv, .json, .jsonl, .db / .sqlite, .parquet, tàbí .gpg / .asc tí a fi PGP dí.
-o, --output-dir <DIR> Fódà tí ó ń gba XML tí a ṣẹ̀dá.
-m, --template <FILE> / -s, --schema <FILE> Rọ́pò àwòṣe Jinja2 tàbí schema XSD tí a kó wọlé.
-c, --config <FILE> Kó àwọn iye ìpìlẹ̀ láti inú profáìlì ìṣètò (--profile, --show-config).
--dry-run (orúkọ mìíràn --validate-only) Ṣàyẹ̀wò dátà ìtẹ̀wọlé lòdì sí JSON Schema, XSD, àti ìwé òfin ètò láìkọ àbájáde jáde.
--scheme <NAME[,NAME]> Ó ń fi ìwé òfin ètò kan tàbí jù bẹ́ẹ̀ lọ múlẹ̀, tí a fi àmì ìdánudúró yà sọ́tọ̀. pain001 plugins list ń dárúkọ gbogbo ìwé òfin tí a fi sí.
--explain / --format json Pẹ̀lú --scheme, ó ń tẹ ìmọ̀ràn àtúnṣe fún ìrúfin kọ̀ọ̀kan, gẹ́gẹ́ bí ọ̀rọ̀ tàbí JSON.
--rules <FILE> Enforce a private YAML CEL policy before generation (requires the rules extra).
--schematron <PRESET or FILE> Apply Schematron business rules: the sepa, fednow or cbpr preset, or your own .sch file.
--decrypt-key <FILE> / --decrypt-passphrase-env <VAR> Import a GPG private key, and name the variable that holds its passphrase, for .gpg / .asc input (requires the gpg extra).
--streaming / --chunk-size <N> Ìṣiṣẹ́ ní àwọn ìdìpọ̀ pẹ̀lú ààlà ìrántí fún àwọn àkójọ ńlá (ìpìlẹ̀: ìdúnàádúrà 1,000 fún ìdìpọ̀ kọ̀ọ̀kan; ìdìpọ̀ kọ̀ọ̀kan yóò di fáìlì XML tirẹ̀ pẹ̀lú NbOfTxs àti CtrlSum tí a tún ṣírò).
--emit-metrics Tú àwọn ìwọ̀n iṣẹ́ tí ẹ̀rọ lè kà jáde fún àwọn ìlànà àbójútó.
--envelop-bah Wrap generated payment XML into an ISO 20022 Business Application Header (head.001.001.03) and BizData (head.003.001.01) envelope.
--bah-sender <BIC/ID> Sender financial institution BIC or organisation identifier for BAH <Fr>.
--bah-receiver <BIC/ID> Receiver financial institution BIC or organisation identifier for BAH <To>.
--bah-msg-id <ID> Business Message Identifier for BAH <BizMsgIdr> (defaults to generated UUID).
--xml-sign-key <FILE> PEM private key (RSA, or EC P-256/P-384) for a W3C XML Digital Signature (XML-DSig); the algorithm follows the key.
--xml-sign-cert <FILE> Optional PEM X.509 certificate to embed in XML-DSig <ds:KeyInfo>.
--xml-sign-alg <ALG> rsa-sha256, rsa-pss-sha256, ecdsa-sha256 or ecdsa-sha384; by default an RSA key signs rsa-sha256.
--xml-sign-passphrase-env <VAR> Environment variable holding the passphrase for --xml-sign-key.
--list-templates / --show-template <TYPE> List the bundled templates, or show one template's metadata, and exit.

Àwọn kóòdù ìjáde bá CI mu: 0 àṣeyọrí, 1 ìkùnà ìṣàyẹ̀wò, 2 àṣìṣe ìlò.

XML signing and verify-signature need the sign extra (pip install "pain001[sign]", which installs cryptography and lxml).

Signatures: pain001 verify-signature

pain001 verify-signature checks the signature on files you received or wrote. Pass the signer's certificate or public key with --cert; that is the trust anchor. --trust-embedded-cert verifies with each file's own certificate instead, which proves the file is unchanged since it was signed but not who signed it. It exits 0 when every file verifies, 1 when any does not, and 2 when it cannot run; --format json prints one report per file. Verification uses exclusive C14N 1.0 and accepts only RSA-SHA256, RSA-PSS and ECDSA signatures with SHA-256 to SHA-512 digests over the whole document; the certificate's chain and validity dates are not checked.

Faces: pain001 face

A face projects a validated pain.001 document into another standard's JSON request body. --face uk_open_banking targets the Open Banking Read/Write API v4.0.1 domestic payment, --face berlin_group targets NextGenPSD2 v1.3.16 payment initiation, and --face iso_2018 renames every element to its ISO 20022 name in snake_case. A face refuses a document that lacks an element its target requires instead of inventing a value; --loss-report lists every source element it did not carry. Faces are outbound only.

Delivery: pain001 upload

pain001 upload sends a finished file to an SFTP server you name, and only after you have trusted its host key: from a known_hosts file (--known-hosts) or an OpenSSH SHA256 fingerprint you verified independently (--accept-host-key). --print-host-key shows the server's fingerprint without logging in. It logs in with a private key (--identity-file, with --passphrase-env), a password read from an environment variable (--password-env), or your SSH agent. The file is written under a temporary name and renamed on the server, so the receiving side never sees a partial file.


2. Python API#

from pain001.core.core import process_files

# Generate a validated pain.001.001.09 file from CSV
process_files(
    xml_message_type="pain.001.001.09",
    xml_template_file_path="template.xml",
    xsd_schema_file_path="schema.xsd",
    data_file_path="payments.csv",
    output_path="out/payments.xml",
)

Gbogbo àkọsílẹ̀ tí a ṣẹ̀dá ń gba ipele mẹ́ta kọjá kí a tó kọ ọ́:

  1. Ìṣàyẹ̀wò dátà ìtẹ̀wọlé: a ń ṣàyẹ̀wò àkọsílẹ̀ kọ̀ọ̀kan lòdì sí JSON Schema ti irú ìránṣẹ́ náà, pẹ̀lú ìmúdọ́gba orúkọ pápá àti àyẹ̀wò ìlànà IBAN/BIC.
  2. Ìwé òfin ètò (àṣàyàn): àwọn òfin ètò ìsanwó tí ẹ dárúkọ, láti SEPA (SCT, Instant, SDD Core, B2B) dé àwọn ètò orílẹ̀-èdè bíi UK Faster Payments, CHAPS àti Bacs, ACH àti ìfiránṣẹ́ owó ti US, àti Swift CBPR+; pain001 plugins list ń dárúkọ gbogbo wọn.
  3. Ìṣàyẹ̀wò XSD: a ń ṣàyẹ̀wò XML tí a ṣẹ̀dá lòdì sí schema ISO 20022 òṣìṣẹ́ nípasẹ̀ xmlschema kí a tó kọ báìtì kan sórí diskì. Tí a bá fi àfikún àṣàyàn fast (lxml) sí i, libxml2 ń gba àwọn ìwé tó tọ̀nà kíákíá; ìwé tí ó bá kọ̀ ni xmlschema tún ń ṣàyẹ̀wò, ìdájọ́ rẹ̀ sì ni ìkẹyìn.

A ń ṣàkóso iye owó gẹ́gẹ́ bí decimal.Decimal nígbà ìṣẹ̀dá XML àti ìṣàyẹ̀wò ètò (kì í ṣe float IEEE 754 láé), a sì ń tún ṣírò àpapọ̀ ìdarí NbOfTxs / CtrlSum láti inú àwọn àkọsílẹ̀ tí a ti ṣàyẹ̀wò dípò gbígbẹ́kẹ̀lé dátà ìtẹ̀wọlé.

Yàtọ̀ sí ìṣẹ̀dá pain.001, ilé-ìkàwé ìpìlẹ̀ tún ní olùkàwé àti olùṣẹ̀dá ìròyìn ipò pain.002 (kí ẹ lè ka ìdáhùn ìtẹ́wọ́gbà tàbí ìkọ̀sílẹ̀ báńkì yín) àti olùkàwé àti olùṣẹ̀dá ìsọ̀rọ̀ àkọọ́lẹ̀ camt.053 fún ìbáradọ́gba ní òpin ọjọ́, pẹ̀lú VersionMapper tí ó ń gbé àwọn àkọsílẹ̀ láàrin àwọn ẹ̀yà ìránṣẹ́.

pain001.faces.project_face is the Python entry point for faces. sign_xml_document signs a document with XML-DSig, and verify_signature(signed_xml, trust_anchor=cert_pem) verifies one and returns a SignatureReport (valid, trust, algorithm, signer, reason); both need the sign extra. verify_xml_signature without a key or certificate still trusts the certificate inside the document, with a DeprecationWarning; pain001 0.0.91 refuses it.

Runnable, self-checking scripts for the public API and the CLI live in the library's examples/ directory.


3. Iṣẹ́ Kékeré REST#

pip install "pain001[api]"
pain001 serve --host 0.0.0.0 --port 8000

A gbé gbogbo endpoint kalẹ̀ lábẹ́ /api/v1 (pẹ̀lú orúkọ mìíràn /api tí kò ní ẹ̀yà):

Ọ̀nà & Ipa-ọ̀nà Ìdí
GET /api/v1/health Àyẹ̀wò ìwàláàyè.
POST /api/v1/validate Ṣàyẹ̀wò àwọn àkọsílẹ̀; ó ń dá àwọn àṣìṣe ní ipele pápá padà.
POST /api/v1/generate Ìṣẹ̀dá XML lẹ́sẹ̀kẹsẹ̀.
POST /api/v1/generate/async Fi àkójọ ńlá sí ìlà fún ìṣẹ̀dá lẹ́yìn ìran.
GET /api/v1/status/{job_id} Ṣàyẹ̀wò ipò iṣẹ́ async.
GET /api/v1/download/{job_id} Ṣe àgbàsílẹ̀ XML tí ó ti parí.
DELETE /api/v1/jobs/{job_id} Nu iṣẹ́ tí ó ti parí kúrò.
GET /api/v1/faces List the faces and the binding keys each accepts.
POST /api/v1/faces/{face} Project a pain.001 document sent as XML text; returns the payload and the loss report, or 422 with the reason the face refused it.
GET /metrics Àwọn ìwọ̀n Prometheus.

A ń pèsè àkọsílẹ̀ ìbáṣepọ̀ ní /api/docs (Swagger UI), /api/redoc, àti /api/reference (Scalar), pẹ̀lú àkọsílẹ̀ OpenAPI ní /openapi.json.

When the PAIN001_API_KEY environment variable is set, every endpoint except /health and /metrics requires it as a bearer token; when it is unset, the API is open. pain001 serve binds to 127.0.0.1 unless you pass --host.


4. Ìmúdọ́gba Dátà Ìtẹ̀wọlé#

Pain001 ń yí àwọn fáìlì tí a tú jáde láti inú ètò gidi padà sí àwọn àkọsílẹ̀ tí ó tọ́ kí ìṣàyẹ̀wò tó bẹ̀rẹ̀:

  • Orúkọ mìíràn fún pápá: àwọn orúkọ kọ́lọ́mù ERP tí ó wọ́pọ̀ bá àwọn pápá ìpìlẹ̀ mu (fún àpẹẹrẹ amount → payment_amount).
  • Ìmúdọ́gba IBAN / BIC: a ń yọ àyè kúrò, a ń mú ìwọ̀n lẹ́tà dọ́gba, lẹ́yìn náà a ń ṣàyẹ̀wò (ISO 13616 mod-97 fún IBAN, ìlànà ISO 9362 fún BIC).
  • Àwọn ọjọ́: a ń kà àwọn ọjọ́ ìṣiṣẹ́ ní ìlànà ISO 8601 YYYY-MM-DD.
  • Iye owó: wọ́n ń gba decimal.Decimal kọjá; iye owó tí kò ní ìlànà tó tọ́ yóò kùnà ìṣàyẹ̀wò dípò kí a yí i ká ní ìdákẹ́jẹ́ẹ́.
  • Àkójọ lẹ́tà: àwọn irinṣẹ́ ìyípadà lẹ́tà ń dín àkóónú kù sí àkójọ lẹ́tà Látìn ISO 20022 tí SWIFT àti SEPA gbà.
  • Formula cells: CSV cells that start with =, +, - or @ are kept as supplied by default, so phone numbers and references survive; load_csv_data(path, sanitize_formula=True) escapes them with a leading quote instead.

5. Ìkọ́lé Plugin#

A lè fẹ̀ ètò yìí sí i nípasẹ̀ àwùjọ ojú-ọ̀nà mẹ́rin: pain001.loaders, pain001.validators, pain001.schemes, àti pain001.writers. pain001-loader-xlsx ń forúkọsílẹ̀ nípasẹ̀ ọ̀nà yìí, a sì ń ṣàwárí rẹ̀ fúnra rẹ̀ lẹ́yìn ìfìsínú; pain001-loader-mt101 jẹ́ ilé-ìkàwé ìtúpalẹ̀ tí ó dá dúró tí a ń lò tààrà (irinṣẹ́ convert_mt101 ti olùpèsè MCP náà sì ń lò ó). Bọ́tìnì ìpakúpa PAIN001_DISABLE_PLUGINS=1 ń pa ìṣàwárí plugin ẹnikẹta rẹ́ pátápátá nínú àwọn àyíká tí a ti dí mọ́lẹ̀.


6. Àwọn Ẹnu-ọ̀nà Ìdára#

A ń ṣe ìdàgbàsókè ilé-ìkàwé ìpìlẹ̀ lábẹ́ àwọn ẹnu-ọ̀nà líle tí a lè fẹ̀rí hàn: ìbòrí ìdánwò 100% fún ìlà àti ẹ̀ka tí a fi lélẹ̀ nínú CI (--cov-fail-under=100), ìtọ́kasí irú dátà mypy líle, ìbòrí docstring 100%, àti ìṣàyẹ̀wò ààbò (Bandit, pip-audit). A ń ṣẹ̀dá SBOM CycloneDX fún gbogbo ìtújáde.

Ẹ tẹ̀síwájú pẹ̀lú Ìtọ́sọ́nà Ìfìsínú, olùpèsè MCP fún àwọn aṣojú AI, tàbí àkójọ ìtumọ̀ ọ̀rọ̀ ìsanwó.