Skip to content

Commit a266cfc

Browse files
committed
feat: add support for CBPR+ based ISO20022 XSDs
Implement support for Central Bank Payment Regulation Plus (CBPR+) compliant ISO20022 message schemas, including migration to pacs.008.001.08 and addition of new CAMT modules for enhanced payment processing capabilities.
1 parent 187b8f1 commit a266cfc

19 files changed

+27630
-4205
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ target/
1919
# Added by cargo
2020

2121
/target
22+
.DS_Store

README.md

Lines changed: 87 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# MX Message - ISO20022 Parser Library
22

3-
A Rust library for parsing, validating, and serializing ISO20022 financial messages, with initial support for pacs.008 (FI to FI Customer Credit Transfer) messages.
3+
A Rust library for parsing, validating, and serializing ISO20022 financial messages with support for CBPR+ (Central Bank Payment Regulation Plus) compliant schemas.
44

55
## Features
66

7-
- **Full pacs.008.001.13 Support**: Complete implementation of the FI to FI Customer Credit Transfer message format
8-
- **Validation**: Built-in validation for all message fields according to ISO20022 specifications
7+
- **CBPR+ Compliance**: Full support for Central Bank Payment Regulation Plus based ISO20022 XSD schemas
8+
- **Multiple Message Types**: Support for pacs.008, pacs.009, and camt message families
9+
- **Validation**: Built-in validation for all message fields according to ISO20022 and CBPR+ specifications
910
- **Serialization**: Support for JSON and XML serialization/deserialization using serde
1011
- **Type Safety**: Strongly typed Rust structures for all message components
1112
- **Error Handling**: Comprehensive error reporting with specific validation codes
@@ -27,51 +28,74 @@ quick-xml = { version = "0.31", features = ["serialize"] } # For XML serializat
2728

2829
```rust
2930
use mx_message::document::Document;
30-
use mx_message::pacs_008_001_13::*;
31+
use mx_message::pacs_008_001_08::*;
3132

3233
fn create_payment_message() -> Document {
3334
// Create group header
34-
let group_header = GroupHeader131 {
35+
let group_header = GroupHeader93 {
3536
msg_id: "MSG123456789".to_string(),
3637
cre_dt_tm: "2024-01-15T10:30:00Z".to_string(),
38+
btch_bookg: Some(false),
3739
nb_of_txs: "1".to_string(),
38-
sttlm_inf: SettlementInstruction15 {
40+
ctrl_sum: Some(1000.00),
41+
ttl_intr_bk_sttlm_amt: Some(ActiveCurrencyAndAmount {
42+
ccy: "EUR".to_string(),
43+
value: 1000.00,
44+
}),
45+
intr_bk_sttlm_dt: Some("2024-01-15".to_string()),
46+
sttlm_inf: SettlementInstruction7 {
3947
sttlm_mtd: SettlementMethod1Code::CodeCLRG,
48+
sttlm_acct: None,
49+
clr_sys: Some(ClearingSystemIdentification3Choice {
50+
cd: Some("T2".to_string()),
51+
prtry: None,
52+
}),
4053
// ... other fields
4154
},
42-
// ... other fields
55+
pmt_tp_inf: None,
56+
instg_agt: None,
57+
instd_agt: None,
4358
};
4459

4560
// Create credit transfer transaction
46-
let credit_transfer_tx = CreditTransferTransaction70 {
47-
pmt_id: PaymentIdentification13 {
61+
let credit_transfer_tx = CreditTransferTransaction39 {
62+
pmt_id: PaymentIdentification7 {
63+
instr_id: Some("INSTR123".to_string()),
4864
end_to_end_id: "E2E123456789".to_string(),
49-
// ... other fields
65+
tx_id: Some("TXN123456789".to_string()),
66+
uetr: Some("12345678-1234-4567-8901-123456789012".to_string()),
67+
clr_sys_ref: None,
5068
},
5169
intr_bk_sttlm_amt: ActiveCurrencyAndAmount {
5270
ccy: "EUR".to_string(),
5371
value: 1000.00,
5472
},
73+
intr_bk_sttlm_dt: Some("2024-01-15".to_string()),
74+
sttlm_prty: Some(Priority3Code::CodeNORM),
75+
accptnc_dt_tm: None,
76+
poolg_adjstmnt_dt: None,
5577
chrg_br: ChargeBearerType1Code::CodeSHAR,
56-
dbtr: PartyIdentification272 {
78+
dbtr: PartyIdentification135 {
5779
nm: Some("ACME Corporation".to_string()),
80+
ctry_of_res: Some("DE".to_string()),
5881
// ... other fields
5982
},
60-
cdtr: PartyIdentification272 {
83+
cdtr: PartyIdentification135 {
6184
nm: Some("Global Suppliers Ltd".to_string()),
85+
ctry_of_res: Some("FR".to_string()),
6286
// ... other fields
6387
},
6488
// ... other required fields
6589
};
6690

6791
// Create the complete message
68-
let fi_to_fi_msg = FIToFICustomerCreditTransferV13 {
92+
let fi_to_fi_msg = FIToFICustomerCreditTransferV08 {
6993
grp_hdr: group_header,
7094
cdt_trf_tx_inf: vec![credit_transfer_tx],
7195
splmtry_data: None,
7296
};
7397

74-
Document::FIToFICustomerCreditTransferV13(Box::new(fi_to_fi_msg))
98+
Document::FIToFICustomerCreditTransferV08(Box::new(fi_to_fi_msg))
7599
}
76100
```
77101

@@ -83,7 +107,7 @@ use mx_message::document::Document;
83107
fn validate_message(document: &Document) -> Result<(), String> {
84108
match document.validate() {
85109
Ok(()) => {
86-
println!("✓ Message is valid");
110+
println!("✓ Message is valid and CBPR+ compliant");
87111
Ok(())
88112
}
89113
Err(e) => {
@@ -136,14 +160,24 @@ cargo run --example pacs008_example
136160
cargo run --example xml_serialization
137161
```
138162

163+
## CBPR+ Compliance
164+
165+
This library implements CBPR+ (Central Bank Payment Regulation Plus) compliant schemas, which provide enhanced payment processing capabilities including:
166+
167+
- **Enhanced Validation**: Stricter validation rules for regulatory compliance
168+
- **Extended Message Support**: Additional message types for comprehensive payment processing
169+
- **Improved Error Handling**: Detailed error reporting for regulatory requirements
170+
- **Central Bank Integration**: Support for central bank payment system requirements
171+
139172
## Validation
140173

141174
The library provides comprehensive validation including:
142175

143176
- **Field Length Validation**: Ensures all fields meet minimum and maximum length requirements
144177
- **Pattern Validation**: Validates formats like IBAN, BIC codes, and numeric patterns
145178
- **Required Field Validation**: Ensures all mandatory fields are present
146-
- **Business Rule Validation**: Implements ISO20022 business rules
179+
- **Business Rule Validation**: Implements ISO20022 and CBPR+ business rules
180+
- **Regulatory Compliance**: Validates against CBPR+ specific requirements
147181

148182
### Validation Error Codes
149183

@@ -169,23 +203,55 @@ cargo test test_json_serialization_roundtrip
169203

170204
## Supported Message Types
171205

172-
Currently supported:
173-
- **pacs.008.001.13**: FI to FI Customer Credit Transfer
206+
### Currently Supported (CBPR+ Compliant)
207+
208+
**Payment Messages (pacs)**
209+
- **pacs.008.001.08**: FI to FI Customer Credit Transfer
210+
- **pacs.009.001.08**: FI to FI Customer Direct Debit
174211

175-
Planned support:
212+
**Cash Management Messages (camt)**
213+
- **camt.029.001.09**: Resolution of Investigation
214+
- **camt.056.001.08**: FI to FI Payment Cancellation Request
215+
- **camt.057.001.06**: Notification to Receive
216+
217+
### Planned Support
176218
- pacs.002: FI to FI Payment Status Report
177219
- pacs.004: Payment Return
178220
- pain.001: Customer Credit Transfer Initiation
179221
- pain.002: Customer Payment Status Report
222+
- Additional CAMT message types
223+
224+
## Architecture
225+
226+
The library is structured around CBPR+ compliant schemas:
227+
228+
```
229+
src/
230+
├── lib.rs # Module declarations
231+
├── document.rs # Main document types and validation
232+
├── common.rs # Shared types and validation errors
233+
├── pacs_008_001_08.rs # FI to FI Customer Credit Transfer
234+
├── pacs_009_001_08.rs # FI to FI Customer Direct Debit
235+
├── camt_029_001_09.rs # Resolution of Investigation
236+
├── camt_056_001_08.rs # Payment Cancellation Request
237+
└── camt_057_001_06.rs # Notification to Receive
238+
```
180239

181240
## Contributing
182241

183-
Contributions are welcome! Please feel free to submit a Pull Request.
242+
Contributions are welcome! Please feel free to submit a Pull Request. When contributing:
243+
244+
1. Ensure all new message types follow CBPR+ compliance standards
245+
2. Add comprehensive tests for new functionality
246+
3. Update documentation for any new features
247+
4. Follow existing code style and validation patterns
184248

185249
## License
186250

187251
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.
188252

189253
## Acknowledgments
190254

191-
This library implements the ISO20022 standard as defined by the International Organization for Standardization (ISO).
255+
- This library implements the ISO20022 standard as defined by the International Organization for Standardization (ISO)
256+
- CBPR+ compliance ensures compatibility with Central Bank Payment Regulation Plus requirements
257+
- Thanks to the Rust community for excellent serialization and XML processing libraries

0 commit comments

Comments
 (0)