Skip to content

ERROR: Buffer Message to string ascii contains invalid characters #146

@SimeonDominiq

Description

@SimeonDominiq

Hi @zemuldo ,
Thank you for this wonderful package.

I have this sample data format below:

const data = {
  0: "0800",
  3: "9C0000",
  7: currentDateTime.format("MMDDHHmmss"),
  11: "233456",
  12: currentDateTime.format("HHmmss"),
  13: currentDateTime.format("MMDD"),
  41: "5TSAD61",
};

const customFormats = {
  3: {
    ContentType: "an",
    Label: "Processing code",
    LenType: "fixed",
    MaxLen: 6,
  },
};

const iso8583 = new Iso8583(data, customFormats);
const bufferMsg = iso8583.getBufferMessage();

console.log(formattedData.toString("ascii"))

//Output - which contains these characters "<", '"'
<0800"89A0000012911091923345611091901292PSTAD61

//Expected Output
08009A0000012911135623345611135601292PSTAD61

Also, in the sample response that I got from the request, I am trying to get the response to JSON but I keep getting this error below:
// sample response:
01520810023800000280080001291120582334561120580129002PSTAD61347687EAB94DD02C889650483EFF57FE1F609246517A2D82CBA3DC9DD3AB1C6ECBA3DC9DD3AB1C6ECBA3DC9DD3AB1C6E

  const iso8583 = new Iso8583(Buffer.from(data, "utf-8"));
  console.log(iso8583.getIsoJSON(), "iso8583", data);

//Error
{ error: 'expecting buffer but got undefined' }

I would appreciate your kind help in resolving these issues that I have while using the package.

Thank you for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions