1.0.2 • Published 7 months ago

europe-xml-dd-generator v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Direct Debit XML Generator

Overview

The Direct Debit XML Generator is a Node.js module designed for creating SEPA Direct Debit files in ISO20022 XML format. This module is ideal for automating payments across Europe, providing a simple and efficient way to generate compliant XML files for bank transactions.

Key Features

  • ISO20022 Compliance: Generates XML files that comply with the ISO20022 standard for direct debit transactions.
  • Flexible Configuration: Easily customize transaction details, creditor information, and message headers.
  • Batch Processing: Generate XML for multiple transactions in one go.
  • Error Handling: Built-in mechanisms to handle errors and invalid inputs.

Installation

To install the Direct Debit XML Generator, run the following command in your terminal:

npm install direct-debit-xml-generator

Usage

Import the generateXML function in your Node.js project

const generateXML = require('direct-debit-xml-generator');

Example

Here's how to generate an XML file:

const generateXML = require('direct-debit-xml-generator');

const transactions = [
    {
        endToEndId: "1",
        currency: "EUR",
        amount: "250.00",
        mandateId: "5678",
        mandateDate: "2024-11-02",
        creditorId: "ES1234567890", // Example NIF
        bic: "BANCOEXAMPLEXXX",
        debtorName: "Alice Example",
        debtorIBAN: "ES9121000418450200051332", // Example IBAN
        reference: "EXAMPLECORP - SUBSCRIPTION"
    },
    // Add more transactions as needed
];

const data = {
    msgId: "EXAMPLE CORP 2024-11",
    total: transactions.length,
    totalCuotas: "250.00",
    orgId: "ES1234567890", // Example NIF
    iban: "ES9121000418450200051332", // Example IBAN
    bic: "BANCOEXAMPLEXXX"
};

const xmlContent = generateXML(transactions, data);

Parameters

The generateXML function takes two parameters:

  • transactions (Array): An array of objects, each containing:

    • endToEndId (string): Unique transaction ID.
    • currency (string): Currency code (e.g., "EUR").
    • amount (string): Transaction amount.
    • mandateId (string): Mandate ID.
    • mandateDate (string): Date of mandate signature in YYYY-MM-DD format.
    • creditorId (string): Creditor's unique identification number.
    • bic (string): Bank Identifier Code (BIC) of the debtor's bank.
    • debtorName (string): Name of the debtor.
    • debtorIBAN (string): IBAN of the debtor's account.
    • reference (string): Payment reference or description.
  • data (Object): Contains general information for the SEPA file:

    • msgId (string): Unique message ID.
    • total (number): Total number of transactions.
    • totalCuotas (string): Total sum of the transaction amounts.
    • orgId (string): Organization ID (e.g., NIF or CIF for Spain).
    • iban (string): Creditor's IBAN.
    • bic (string): Creditor's BIC.

Output

The generateXML function returns a formatted XML string in ISO20022 format. You can save this XML string as a .xml file or process it further as needed.

Example Output

Here’s a snippet of the XML output:

<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02">
  <CstmrDrctDbtInitn>
    <GrpHdr>
      <MsgId>EXAMPLE CORP 2024-11</MsgId>
      <CreDtTm>2024-11-02T14:30:00</CreDtTm>
      <NbOfTxs>1</NbOfTxs>
      <CtrlSum>250.00</CtrlSum>
      <InitgPty>
        <Nm>Oelap Training SL</Nm>
        <Id>
          <OrgId>
            <Othr>
              <Id>ES1234567890</Id> <!-- NIF ficticio -->
            </Othr>
          </OrgId>
        </Id>
      </InitgPty>
    </GrpHdr>
    <PmtInf>
      <PmtInfId>1</PmtInfId>
      <PmtMtd>DD</PmtMtd>
      <CtrlSum>250.00</CtrlSum>
      <PmtTpInf>
        <SvcLvl>
          <Cd>SEPA</Cd>
        </SvcLvl>
        <LclInstrm>
          <Cd>CORE</Cd>
        </LclInstrm>
        <SeqTp>RCUR</SeqTp>
      </PmtTpInf>
      <ReqdColltnDt>2024-11-02</ReqdColltnDt>
      <Cdtr>
        <Nm>Oelap Training SL</Nm>
      </Cdtr>
      <CdtrAcct>
        <Id>
          <IBAN>ES9121000418450200051332</IBAN> <!-- IBAN ficticio -->
        </Id>
      </CdtrAcct>
      <CdtrAgt>
        <FinInstnId>
          <BIC>BANCOEXAMPLEXXX</BIC> <!-- BIC ficticio -->
        </FinInstnId>
      </CdtrAgt>
      <DrctDbtTxInf>
        <PmtId>
          <EndToEndId>1</EndToEndId>
        </PmtId>
        <InstdAmt Ccy="EUR">250.00</InstdAmt>
        <DrctDbtTx>
          <MndtRltdInf>
            <MndtId>5678</MndtId>
            <DtOfSgntr>2024-11-01</DtOfSgntr>
          </MndtRltdInf>
          <CdtrSchmeId>
            <Id>
              <PrvtId>
                <Othr>
                  <Id>ES30000B67170605</Id> <!-- ID del acreedor -->
                  <SchmeNm>
                    <Prtry>SEPA</Prtry>
                  </SchmeNm>
                </Othr>
              </PrvtId>
            </Id>
          </CdtrSchmeId>
          <DbtrAgt>
            <FinInstnId>
              <BIC>CAIXESBBXXX</BIC> <!-- BIC ficticio del deudor -->
            </FinInstnId>
          </DbtrAgt>
          <Dbtr>
            <Nm>Alice Example</Nm>
          </Dbtr>
          <DbtrAcct>
            <Id>
              <IBAN>ES1901824567140200363604</IBAN> <!-- IBAN ficticio del deudor -->
            </Id>
          </DbtrAcct>
          <Purp>
            <Cd>COMC</Cd>
          </Purp>
          <RmtInf>
            <Ustrd>EXAMPLECORP - SUBSCRIPTION</Ustrd>
          </RmtInf>
        </DrctDbtTx>
      </DrctDbtTxInf>
    </PmtInf>
  </CstmrDrctDbtInitn>
</Document>
1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago