Pain001, A Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Or SQlite Data Files. 🐍
APACHE-2.0 License
Pain001 is an open-source Python Library that you can use to create ISO 20022-Compliant Payment Files directly from your CSV or SQLite Data Files.
The Python library focuses specifically on Payment Initiation and Advice Messages, commonly known as Pain. In a very simplified way, a pain.001 is a message that initiates the customer payment.
As of today, the library is designed to be compatible with the:
Payments usually start with a pain.001 payment initiation message. The payer sends it to the payee (or the payee’s bank) via a secure network. This network could be SWIFT or SEPA (Single Euro Payments Area) network, or other payment networks such as CHAPS, BACS, Faster Payments, etc. The message contains the payer’s and payee’s bank account details, payment amount, and other information required to process the payment.
The Pain001 library can reduce payment processing complexity and costs by generating ISO 20022-compliant payment files. These files automatically remove the need to create and validate them manually, making the payment process more efficient and cost-effective. It will save you time and resources and minimize the risk of errors, ensuring accurate and seamless payment processing.
Use the Pain001 library to simplify, accelerate, and automate your payment processing.
Pain001 works with macOS, Linux, and Windows and requires Python 3.9.0 and above.
We recommend creating a virtual environment to install Pain001. This will ensure that the package is installed in an isolated environment and will not affect other projects. To install Pain001 in a virtual environment, follow these steps:
virtualenv
python -m pip install virtualenv
python -m venv venv
Code | Explanation |
---|---|
-m |
executes module venv
|
env |
name of the virtual environment |
source venv/bin/activate
It takes just a few seconds to get up and running with Pain001. You can install Pain001 from PyPI with pip or your favourite package manager:
Open your terminal and run the following command to add the latest version:
python -m pip install pain001
Add the -U switch to update to the current version, if pain001
is already
installed.
python -m pip install -U pain001
After installation, you can run Pain001 directly from the command line. Simply call the main module pain001 with the paths of your:
Here’s how you would do that:
python3 -m pain001 \
-t <xml_message_type> \
-m <xml_template_file_path> \
-s <xsd_schema_file_path> \
-d <data_file_path>
When running Pain001, you will need to specify four arguments:
An xml_message_type
: This is the type of XML message you want to generate.
The currently supported types are:
An xml_template_file_path
: This is the path to the XML template file you are
using that contains variables that will be replaced by the values in your
Data file.
An xsd_schema_file_path
: This is the path to the XSD schema file you are
using to validate the generated XML file.
A data_file_path
: This is the path to the CSV or SQLite Data file you want
to convert to XML format.
The following examples demonstrate how to use Pain001 to generate a payment initiation message from a CSV file and a SQLite Data file.
python3 -m pain001 \
-t pain.001.001.03 \
-m /path/to/your/template.xml \
-s /path/to/your/pain.001.001.03.xsd \
-d /path/to/your/template.csv
python3 -m pain001 \
-t pain.001.001.03 \
-m /path/to/your/template.xml \
-s /path/to/your/pain.001.001.03.xsd \
-d /path/to/your/template.db
You can clone the source code and run the example code in your terminal/command-line. To check out the source code, clone the repository from GitHub:
git clone https://github.com/sebastienrousseau/pain001.git
This will generate a payment initiation message in the format of Pain.001.001.03.
python -m pain001 \
-t pain.001.001.03 \
-m pain001/templates/pain.001.001.03/template.xml \
-s pain001/templates/pain.001.001.03/pain.001.001.03.xsd \
-d pain001/templates/pain.001.001.03/template.csv
This will generate a payment initiation message in the format of Pain.001.001.04.
python -m pain001 \
-t pain.001.001.04 \
-m pain001/templates/pain.001.001.04/template.xml \
-s pain001/templates/pain.001.001.04/pain.001.001.04.xsd \
-d pain001/templates/pain.001.001.04/template.csv
This will generate a payment initiation message in the format of Pain.001.001.05.
python -m pain001 \
-t pain.001.001.05 \
-m pain001/templates/pain.001.001.05/template.xml \
-s pain001/templates/pain.001.001.05/pain.001.001.05.xsd \
-d pain001/templates/pain.001.001.05/template.csv
This will generate a payment initiation message in the format of Pain.001.001.06.
python -m pain001 \
-t pain.001.001.06 \
-m pain001/templates/pain.001.001.06/template.xml \
-s pain001/templates/pain.001.001.06/pain.001.001.06.xsd \
-d pain001/templates/pain.001.001.06/template.csv
This will generate a payment initiation message in the format of Pain.001.001.07.
python -m pain001 \
-t pain.001.001.07 \
-m pain001/templates/pain.001.001.07/template.xml \
-s pain001/templates/pain.001.001.07/pain.001.001.07.xsd \
-d pain001/templates/pain.001.001.07/template.csv
This will generate a payment initiation message in the format of Pain.001.001.08.
python -m pain001 \
-t pain.001.001.08 \
-m pain001/templates/pain.001.001.08/template.xml \
-s pain001/templates/pain.001.001.08/pain.001.001.08.xsd \
-d pain001/templates/pain.001.001.08/template.csv
This will generate a payment initiation message in the format of Pain.001.001.09.
python -m pain001 \
-t pain.001.001.09 \
-m pain001/templates/pain.001.001.09/template.xml \
-s pain001/templates/pain.001.001.09/pain.001.001.09.xsd \
-d pain001/templates/pain.001.001.09/template.csv
You can do the same with the sample SQLite Data file:
python3 -m pain001 \
-t pain.001.001.03 \
-m pain001/templates/pain.001.001.03/template.xml \
-s pain001/templates/pain.001.001.03/pain.001.001.03.xsd \
-d pain001/templates/pain.001.001.03/template.db
Note: The XML file that Pain001 generates will automatically be validated against the XSD template file before the new XML file is saved. If the validation fails, Pain001 will stop running and display an error message in your terminal.
To embed Pain001 in a new or existing application, import the main function and use it in your code.
Here's an example:
from pain001 import main
if __name__ == '__main__':
xml_message_type = 'pain.001.001.03'
xml_template_file_path = 'template.xml'
xsd_schema_file_path = 'schema.xsd'
data_file_path = 'data.csv'
main(
xml_message_type,
xml_template_file_path,
xsd_schema_file_path,
data_file_path
)
To validate the generated XML file against a given xsd schema, use the following method:
from pain001.core import validate_xml_against_xsd
xml_message_type = 'pain.001.001.03'
xml_file = 'generated.xml'
xsd_file = 'schema.xsd'
is_valid = validate_xml_against_xsd(
xml_message_type,
xml_file,
xsd_file
)
print(f"XML validation result: {is_valid}")
Info: Do check out our website for comprehensive documentation.
This section gives access to the documentation related to the ISO 20022 message definitions supported by Pain001.
Set of messages used to request and provide account information for reconciliation and cash positioning between an account servicer and its customer.
Status | Message type | Name |
---|---|---|
⏳ | camt.052.001.10 | Bank-to-Customer Account Statement |
⏳ | camt.053.001.10 | Customer Account Identification |
⏳ | camt.054.001.10 | Customer Account Statement Request |
⏳ | camt.060.001.10 | Customer Account Notification |
Set of messages used between financial institutions for the clearing and settlement of payment transactions.
Status | Message type | Name |
---|---|---|
⏳ | pacs.002.001.12 | Credit Transfer Notification |
⏳ | pacs.003.001.09 | Direct Debit Initiation |
⏳ | pacs.004.001.11 | Direct Debit Reversal |
⏳ | pacs.007.001.11 | Customer Direct Debit Confirmation |
⏳ | pacs.008.001.10 | Credit Transfer Initiation |
⏳ | pacs.009.001.10 | Credit Transfer Reversal |
⏳ | pacs.010.001.05 | Account Identification |
⏳ | pacs.028.001.05 | Account Statement Request |
Set of messages exchanged between a debtor (or buyer) and its bank or between a creditor (or seller) and its bank to initiate, collect, manage and monitor payments.
Status | Message type | Name |
---|---|---|
✅ | pain.001.001.03 | Customer Credit Transfer Initiation |
✅ | pain.001.001.04 | Customer Direct Debit Initiation |
✅ | pain.001.001.05 | Customer Direct Debit Reversal |
✅ | pain.001.001.06 | Customer Credit Transfer Reversal |
✅ | pain.001.001.07 | Customer Account Notification |
✅ | pain.001.001.08 | Customer Account Statement |
✅ | pain.001.001.09 | Customer Credit Transfer Initiation |
⏳ | pain.001.001.10 | Customer Account Closure Request |
⏳ | pain.001.001.11 | Customer Account Change Request |
The project is licensed under the terms of both the MIT license and the Apache License (Version 2.0).
We welcome contributions to Pain001. Please see the contributing instructions for more information.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
We would like to extend a big thank you to all the awesome contributors of Pain001 for their help and support.