Crate pain

source ·
Expand description

A Rust library to manage ISO 20022 pain.001 payment initiation messages widely used for corporate to bank payments.

Rust

Rust Crates.io Lib.rs GitHub License

Overview

Payment Initiation (PI) is a library that provides a set of structs and enums that can be used to serialize and deserialize SEPA payment information using the serde library.

The structs include Payment, OriginalGroupInfoAndStatus, PaymentInfo, PaymentTypeInfo, ServiceLevel, Debtor, PostalAddress, DebtorAccount, AccountId, DebtorAgent, FinancialInstitutionId, CreditTransferTransactionInfo, PaymentId, Amount, InstructedAmount, Creditor, CreditorAccount, RemittanceInfo, and CreditorAgent.

The enum is PaymentFormat and has four variants: Pain001_001_02, Pain001_001_03, Pain001_001_04, and Pain001_001_05.

PaymentFormat

The PaymentFormat enum defines the different formats of payment supported by the system.

Payment

The Payment struct is the main data structure used to represent a payment. It contains the following fields:

  • payment_format: The format of the payment, represented by the PaymentFormat enum.
  • original_group_info_and_status: Information about the original group and its status, represented by the OriginalGroupInfoAndStatus struct.
  • payment_info: Information about the payment, represented by the PaymentInfo struct.

OriginalGroupInfoAndStatus

The OriginalGroupInfoAndStatus struct contains information about the original group and its status. It has the following fields:

  • original_message_id: The original message ID.
  • original_message_name_id: The original message name ID.
  • group_status: The status of the group.

PaymentInfo

The PaymentInfo struct contains information about the payment. It has the following fields:

  • payment_info_id: The ID of the payment information.
  • payment_method: The method used for the payment.
  • number_of_transactions: The number of transactions in the payment.
  • control_sum: The control sum of the payment.
  • payment_type_info: Information about the type of payment, represented by the PaymentTypeInfo struct.
  • requested_execution_date: The requested execution date of the payment.
  • debtor: Information about the debtor, represented by the Debtor struct.
  • debtor_account: Information about the debtor’s account, represented by the DebtorAccount struct.
  • debtor_agent: Information about the debtor’s agent, represented by the DebtorAgent struct.
  • credit_transfer_transaction_info: Information about the credit transfer transactions, represented by the CreditTransferTransactionInfo struct.

PaymentTypeInfo

The PaymentTypeInfo struct contains information about the type of payment. It has the following fields:

  • service_level: The service level of the payment, represented by the ServiceLevel struct.
  • local_instrument: The local instrument used for the payment.
  • payment_type_id: The ID of the payment type.

ServiceLevel

The ServiceLevel struct contains information about the service level of a payment. It has the following field:

  • code: The code representing the service level.

Debtor

The Debtor struct contains information about the debtor. It has the following fields:

  • name: The name of the debtor.
  • postal_address: The postal address of the debtor, represented by the PostalAddress struct.

PostalAddress

The PostalAddress struct contains information about a postal address. It has the following fields:

  • country: The country of the address.
  • address_line: The lines of the address. //!

DebtorAccount

The DebtorAccount struct contains information about the debtor’s account. It has the following fields:

  • id: The ID of the account, represented by the AccountId struct.

AccountId

The AccountId struct contains information about an account ID. It has the following fields:

  • IBAN: The International Bank Account Number (IBAN) of the account.
  • other: Information about other types of accounts, represented by the OtherAccountId struct.

OtherAccountId

The OtherAccountId struct contains information about other types of accounts. It has the following fields:

  • id: The ID of the account.
  • issuer: The issuer of the account.

DebtorAgent

The DebtorAgent struct contains information about the debtor’s agent. It has the following fields:

  • financial_institution_id: The ID of the financial institution.

CreditTransferTransactionInfo

The CreditTransferTransactionInfo struct contains information about the credit transfer transactions. It has the following fields:

  • amount: The amount of the transaction.
  • currency: The currency of the transaction.
  • remittance_information: The remittance information of the transaction.
  • creditor: Information about the creditor, represented by the Creditor struct.
  • creditor_account: Information about the creditor’s account, represented by the CreditorAccount struct.
  • creditor_agent: Information about the creditor’s agent, represented by the CreditorAgent struct.
  • ultimate_creditor: Information about the ultimate creditor, represented by the UltimateCreditor struct.

Creditor

The Creditor struct contains information about the creditor. It has the following fields:

  • name: The name of the creditor.
  • postal_address: The postal address of the creditor, represented by the PostalAddress struct.

CreditorAccount

The CreditorAccount struct contains information about the creditor’s account. It has the following fields:

  • id: The ID of the account, represented by the AccountId struct.

CreditorAgent

The CreditorAgent struct contains information about the creditor’s agent. It has the following fields:

  • financial_institution_id: The ID of the financial institution.

UltimateCreditor

The UltimateCreditor struct contains information about the ultimate creditor. It has the following fields:

  • name: The name of the ultimate creditor.
  • postal_address: The postal address of the ultimate creditor, represented by the PostalAddress struct.

Usage

  • serde: Enable serialization/deserialization via serde

Structs

Enums