safe-sepa-xml
v0.2.2
Published
A simple XML generator for SEPA transactions using money-math for safe summations.
Downloads
4
Readme
SEPA-XML
This is a fork from the perfect mgmco/sepa-xml library. The only change is that for the summation of money, money-math is used instead of floating point calculations.
This module gives you a wrapper around generating a SEPA XML file. It works by using Handlebars to generate the file instead of using the conventional XML tree approach used by other plugins.
It does, however, run the final result through a validator and will throw an error if there's an issue with it!
Formats
These can be found in the formats
folders, and are simple Handlebars files representing the XML schema.
pain.001.001.03
pain.001.001.02
(thanks @PierrickP)- Want to add one? Send us a pull request!
Usage
var SepaXML = require('sepa-xml');
var XMLFile = new SepaXML(); // takes a single argument which is the format, default is 'pain.001.001.03'
// This sets the header data in the file
XMLFile.setHeaderInfo({
messageId: '123/1',
initiator: 'XML Corp.'
});
XMLFile.setPaymentInfo({
id: '123/1',
method: 'TRF',
senderName: 'Acme Co.',
senderIBAN: 'NL39 RABO 0300 0652 64',
batchBooking: false, // optional (default: false)
bic: 'RABONL2U'
});
// Add one of these for every transaction
XMLFile.addTransaction({
id: 'endToEndID',
amount: 10.00,
name: 'My Name',
iban: 'NL39 RABO 0300 0652 64',
bic: 'RABONL2U', // optional can be auto-found it
description: 'My great payment'
});
XMLFile.compile(function (err, out) {
// your XML data gets output here
});
Contributing
- Would be nice if someone wrote more templates for some of the other formats used for SEPA.
- The BICS lookup list is probably not complete - it would be great if someone could add that data into the map
- Anything else you can think of