initZKB = async () => {
const ebicsClient = await new ebics.Client({
url: 'https://testplattform.zkb.ch/ebicsweb/ebicsweb',
partnerId: 'XXX',
userId: 'XXX',
hostId: 'XXX',
passphrase: 'PASS',
keyStorage: ebics.fsKeysStorage('./src/keys-dev')
})
await ebicsClient
.send(ebics.Orders.INI)
.then((resp: any) => {
console.log('Response for INI order %j', resp);
return ebicsClient.send(ebics.Orders.HIA);
})
.then(async (resp: { technicalCode: string }) => {
console.log('Response for HIA order %j', resp);
if (resp.technicalCode !== '000000')
throw new Error('Something might went wrong');
console.log(
'Public keys should be sent to bank now. See examples/bankLetter.js'
);
});
const bankName = 'Zürcher Kantonalbank';
const template = fs.readFileSync('./src/ini_de.hbs').toString();
const bankLetterFile = path.join(os.homedir(), 'bankLetter_de.html');
const letter = await new ebics.BankLetter({
ebicsClient,
bankName,
template
});
// This serialize() function throws the error
await letter.serialize(bankLetterFile).then(() => {
console.log('Send your bank the letter (%s)', bankLetterFile);
});
}
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'keys' of undefined
at BankLetter.generate (/xxx/node_modules/ebics-client/lib/BankLetter.js:48:34)
at BankLetter.serialize (/xxx/node_modules/ebics-client/lib/BankLetter.js:63:29)