emmy-payment-generator v0.0.1
A payment transaction xml file generator
Can be used for
- Transforming an Emmy proprietary csv format into a bank-compatible XML import file and
- Validating such a file.
Currently only supports Nordea and Emmy proprietary data.
Works either as a library or as a cli tool.
CLI mode
In order to use the cli mode, please install the package using your favourite package manager. Necessary symlinks should be created automatically for command line usage.
XML generation.
Only reads actual comma separated files with compulsory headers:
endToEndIdString
, sellerId
, sellerName
, instructedAmount
and sellerIBAN
.
Usage:
csv2NordeaXml -t <type> -d <payment-date> -i <batch-id> -m <message> [-f <input csv file>] > result.xml
Example:
csv2NordeaXml -t return -d 2019-12-23 -i "20191223-emmy-returns" -m "Emmy asiakaspalautukset" -f palautukset.csv > 20191223_palautukset.xml
where:
- (string) equals
return
orseller
. This will make resulting payment ids's prefixed differently (A = remittance, B = return). - (string) in YYYY-MM-DD format. Must be a date today or in the future; past dates will be disregarded by the bank.
- (string) is a unique identifier for this payment batch. The bank will fail to process subsequent files with the same id.
- (string) is the default message for all payments.
The resulting xml file will be printed to stdout and should hence be redirected to a file. Any errors will be printed to stderr.
Note: the generator will rectify iban account number letter capitalization (i.e. result will always be all caps).
XML validation
Will validate files generated by us or someone else using a bank provided xsd schema. NOTE! The schema has been modified slighly in order to catch non-capital letters in IBAN codes, which at some point caused the payments to fail.
Usage:
validateNordeaXml -f <input xml file>
Library mode API
The conversion library can be imported to any software for transfer file generation (from json data with field names as described earlier).
createNordeaXml(config, jsonArray)
Creates an xml string from json data and validates it against the xsd schema.
Function returns a promise, which resolves to the xml string or rejects with an error message.
const { createNordeaXml } = require('./index.js');
//Equal to cli sample above
const config = {
// Prefix for transaction ids; A = remittances, B = returns
e2ePrefix: "B",
// Batch id string
idString: ""20191223-emmy-returns",
// the wanted payment date; must be in the future
executionDate: "2019-12-23",
// An override message if set
messageOverride: "Emmy asiakaspalautukset"
};
// Array of payment directives
const jsonarray = [{
endToEndIdString: "105384",
sellerId: 88253,
sellerName: "Test Customer",
instructedAmount": "2.83",
sellerIban: "FI65 5790 1220 0098 57"
}];
// Prints the xml to stdout or the error message to stderr.
createNordeaXml(config, jsonarray)
.then(console.log)
.catch(console.error)
;
validateNordeaXml(xmlstring)
Validates the given xml string against the xsd schema.
Returns a promise that resolves to the xml string or rejects to an error message.
const { validateNordeaXml } = require('./index.js');
const xml = ...;
// Prints an encouraging message to stdout or an error message to stderr.
validateNordeaXml(config, jsonarray)
.then((xml) => console.log("Validation successful"))
.catch(console.error)
;
4 years ago