From c4fe58ef24441b452d33ab6f20e6da67cf6674bb Mon Sep 17 00:00:00 2001 From: Mahdi Date: Mon, 10 Jun 2024 18:21:41 +0330 Subject: [PATCH] Parse MTIs other than 0300. --- CHANGELOG.md | 4 ++++ lib/src/message.dart | 6 +++++- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9311b72..7b7c71f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.4 + +* Parse MTIs other than 0300. + ## 0.3.3 * Cleanup ISO-9797 code. diff --git a/lib/src/message.dart b/lib/src/message.dart index 0595928..b874e01 100644 --- a/lib/src/message.dart +++ b/lib/src/message.dart @@ -7,11 +7,13 @@ class Message { /// Parses a [Message] from the input byte-array. factory Message.parse(Uint8List data) { + final mti = hex.encode(data.take(2).toList()).toUpperCase(); + final bitmap = data.sublist(2, 10); final hexmap = hex.encode(bitmap); final v = int.parse(hexmap, radix: 16); final pb = v.toRadixString(2).padLeft(64, '0'); - final message = Message('0300'); + final message = Message(mti); final parser = _MessageParser(data); @@ -273,6 +275,8 @@ class Message { Map toJson() { final map = {}; + map['MTI'] = mti; + for (var i = 1; i <= 64; i++) { final f = _data[i]; diff --git a/pubspec.yaml b/pubspec.yaml index 19e12d8..3cce2ca 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pos description: Dart Implementation of the ISO-8583 banking protocol for Point of Sale (POS) Devices. -version: 0.3.3 +version: 0.3.4 repository: https://github.com/xclud/dart_pos homepage: https://pwa.ir