pain001.core package#

Core processing package for pain001.

Submodules#

pain001.core.core module#

End-to-end orchestration of ISO 20022 payment file generation.

pain001.core.core.process_files(xml_message_type: str, xml_template_file_path: str, xsd_schema_file_path: str, data_file_path: str | list[dict[str, Any]] | dict[str, Any], output_path: str | None = None, envelop_bah: bool = False, bah_header: BusinessApplicationHeader | None = None, xml_sign_key: str | bytes | None = None, xml_sign_cert: str | bytes | None = None, xml_sign_passphrase: str | bytes | None = None, schematron: str | Any | None = None) → str[source]#

Generate an ISO 20022 payment message from various data sources.

Parameters:
  • xml_message_type – XML message type (e.g., ‘pain.001.001.03’).

  • xml_template_file_path – Path to the XML template file.

  • xsd_schema_file_path – Path to the XSD schema file.

  • data_file_path – File path (CSV/DB/JSON/Parquet) or Python data (list/dict).

  • output_path – Explicit path for the generated XML file. When omitted, the file is written next to the template (deprecated; requires the template to live under the current working directory).

  • envelop_bah – If True, wrap generated XML in an ISO 20022 BAH envelope.

  • bah_header – Optional customized BusinessApplicationHeader instance.

  • xml_sign_key – Optional RSA private key in PEM format to sign the XML.

  • xml_sign_cert – Optional X.509 certificate in PEM format for KeyInfo.

  • xml_sign_passphrase – Optional passphrase for the private key.

  • schematron – Optional Schematron rulebook preset or .sch path to validate.

Returns:

The path the generated XML file was written to.

Raises:
  • XMLGenerationError – If the message type is not supported or the XML file could not be written.

  • Exception – Any error raised while validating inputs, loading data, or generating XML (e.g. FileNotFoundError for missing files, PaymentValidationError for bad amounts) is logged and re-raised unchanged.

pain001.core.core.process_files_streaming(xml_message_type: str, xml_template_file_path: str, xsd_schema_file_path: str, data_file_path: str, chunk_size: int = 1000, output_dir: str | None = None, envelop_bah: bool = False, bah_header: BusinessApplicationHeader | None = None, xml_sign_key: str | bytes | None = None, xml_sign_cert: str | bytes | None = None, xml_sign_passphrase: str | bytes | None = None, schematron: str | Any | None = None) → list[str][source]#

Generate multiple XML files from streamed input chunks.

Parameters:
  • xml_message_type – XML message type (e.g., ‘pain.001.001.03’).

  • xml_template_file_path – Path to the XML template file.

  • xsd_schema_file_path – Path to the XSD schema file.

  • data_file_path – Path to the payment data file.

  • chunk_size – Rows per chunk; each chunk becomes one XML file.

  • output_dir – Directory to write chunked XML files to. When omitted, files are written next to the data file.

  • envelop_bah – If True, wrap each chunk XML in an ISO 20022 BAH envelope.

  • bah_header – Optional customized BusinessApplicationHeader instance.

  • xml_sign_key – Optional RSA private key in PEM format to sign each chunk.

  • xml_sign_cert – Optional X.509 certificate in PEM format for KeyInfo.

  • xml_sign_passphrase – Optional passphrase for the private key.

  • schematron – Optional Schematron rulebook preset or .sch path to validate.

Returns:

Paths of the generated chunk XML files, in chunk order.

Raises:

XMLGenerationError – If Schematron rulebook validation fails for any chunk.