Skip to content

client.keys is undefined when creating a bankLetter #32

@FridgeWalaby

Description

@FridgeWalaby

I ran into the problem that my client.keys are undefined. And thus the bankLetter cannot be created.

Here is my code:

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);
      });

}

And this is the error:

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)

Does anyone have an idea why the keys are not set?
Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions