Madrid Energy is a company based in Spain that needs to send a SEPA payment to Kylian Mbappé, also in Spain. Madrid Energy’s bank, like most in Europe, can process SEPA messages via ISO20022 to move money programatically on their behalf. We’ll use iso20022.js to do this.

At the end of the tutorial, we’ll demonstrate how to store and send the payment message to the bank using Fiat Web Services.

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 payments@woodside.sh.

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

npm i iso20022.js

You should also install fiatwebservices to save and upload the payment message to the bank.

npm i fiatwebservices
import { FiatWebServices } from 'fiatwebservices';

const fiatWebServices = new Fiatwebservices({
    apiKey: process.env['FWS_API_KEY'],
});

Step 2. Initialize Your Initiating Party

import { ISO20022 } from 'iso20022.js';

const iso20022 = new ISO20022({
    initiatingParty: {
        name: 'Madrid Energy',
        id: 'ELECTRIC',
        account: {
            iban: 'ES9121000418450200051332'
        },
        agent: {
            bic: 'BSCHESMMXXX',
            bankAddress: {
                country: 'ES',
            }
        }
    }
});

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 SEPA Payment Initiation Message

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

const payment = iso20022.createSEPACreditPaymentInitiation({
    paymentInstructions: [{
        type: 'sepa',
        direction: 'credit',
        amount: 1000,
        currency: 'EUR',
        creditor: {
            name: 'Kylian Mbappé',
            account: {
                iban: 'ES8201822200150201504058'
            },
        }
    }]
});

Here we are structuring a payment instruction on the behalf of Kylian Mbappé. 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 the recipient’s bank.

Step 4: Save the Payment using Fiat Web Services and Upload to Bank

You can use Fiat Web Services to save, track, and send the XML file to your bank.

fiatWebServices.transfers.sepa.create(payment.serialize())

Sign up for Fiat Web Services here.

Talk to Us

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