Acme Corporation is a company based in the US that needs to send a SWIFT payment to Jane Smith in Germany. Acme’s bank, like most in the world, can process SWIFT messages via ISO20022 to move money programatically on their behalf. We’ll use iso20022.js to do this.

In order to transmit bank payments programatically, you must have direct transmission enabled with your corporate bank. If you have any questions about this, don’t hesitate to reach out to svapnil@woodside.sh.

Step 1. Install iso20022.js in your NPM project:

Step 2. Initialize your Client

import { ISO20022 } from 'iso20022.js';

const iso20022 = new ISO20022({
    initiatingParty: {
        name: 'Acme Corporation',
        id: 'ACMECORP',
        account: {
            accountNumber: '123456789012',
        },
        agent: {
            bic: 'CHASUS33',
            bankAddress: {
                country: 'US',
            }
        }
    }
});

The ISO20022 client represents the core information you need to send or receive structured ISO20022 messages correctly. We need to define the initiating party, ourselves, including the bank information from which we are sending the payment from.

Step 3: Create a SWIFT Payment Initiation Message

To send a SWIFT wire payment using iso20022.js, we need to create a creditPaymentInitiation object, which represents a payment initiation (PAIN) file.

const creditPaymentInitiation = iso20022.createSWIFTCreditPaymentInitiation({
    paymentInstructions: [{
        type: 'swift',
        direction: 'credit',
        amount: 1000,
        currency: 'USD',
        creditor: {
            name: 'Jane Smith',
            account: {
                iban: 'DE89370400440532013000'
            },
            agent: {
                bic: 'DEUTDEFF',
            },
            address: {
                streetName: "123 Main St",
                townName: "Funkytown",
                postalCode: "12345",
                country: "DE",
            }
        }
    }]
});

Here are structuring a payment instruction on the behalf of Jane Smith. If you’d like to see more about the data models iso20022.js supports, check out the Data Reference page.

The creditPaymentInitiation object contains the information we need to format and send our XML instruction. Our next step is to relay this to Jane’s bank.

Step 4: Send the Payment Initiation message to the bank

Payments transmission is not supported by iso20022.js yet, but we can use off the shelf SFTP libraries to send the XML file to Acme’s banking partner in the format they expect.

import Client from 'ssh2-sftp-client';

const sftp = new Client();

sftp.connect({
    host: process.env.SFTP_HOST,
    port: 22,
    username: process.env.SFTP_USERNAME,
    password: process.env.SFTP_PASSWORD
});

await sftp.put(creditPaymentInitiation.toString(), '/ACMECORP_20240804123456_001');

sftp.end();

Talk to Us

If you find iso20022.js useful, please reach out to us. We’d love to hear from you.