Skip to content

Commit

Permalink
Fix BmpParser bug with 0x37 Trace-number
Browse files Browse the repository at this point in the history
Add unit test for Reversal
  • Loading branch information
tinohager committed Feb 1, 2022
1 parent 21501ac commit 26b1331
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/Portalum.Zvt.UnitTest/StatusInformationParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@ public void Parse_PaymentGood2_Successful()
Assert.AreEqual(671107177, statusInformation.TerminalIdentifier);
}

[TestMethod]
public void Parse_ReversalGood1_Successful()
{
var byteData = new byte[] { 0x04, 0x0F, 0xE2, 0x27, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x06, 0x07, 0x0C, 0x15, 0x48, 0x58, 0x0D, 0x02, 0x01, 0x0E, 0x25, 0x12, 0x17, 0x00, 0x01, 0x19, 0x70, 0x22, 0xF0, 0xF8, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0x47, 0x71, 0x29, 0x28, 0x00, 0x48, 0x69, 0x2A, 0x31, 0x30, 0x30, 0x34, 0x36, 0x31, 0x37, 0x36, 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x37, 0x00, 0x06, 0x06, 0x3B, 0x37, 0x31, 0x35, 0x36, 0x39, 0x31, 0x00, 0x00, 0x3C, 0xF0, 0xF1, 0xF4, 0x47, 0x45, 0x4E, 0x2E, 0x4E, 0x52, 0x2E, 0x3A, 0x37, 0x31, 0x35, 0x36, 0x39, 0x31, 0x49, 0x09, 0x78, 0x87, 0x06, 0x07, 0x88, 0x00, 0x06, 0x07, 0x8A, 0x2E, 0x8B, 0xF1, 0xF7, 0x44, 0x65, 0x62, 0x69, 0x74, 0x20, 0x4D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x63, 0x61, 0x72, 0x64, 0x00, 0x06, 0x65, 0x24, 0x10, 0x07, 0x0E, 0x47, 0x45, 0x4E, 0x2E, 0x4E, 0x52, 0x2E, 0x3A, 0x37, 0x31, 0x35, 0x36, 0x39, 0x31, 0x43, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x04, 0x10, 0x10, 0x46, 0x1F, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x31, 0x30, 0x31, 0x30, 0x20, 0x42, 0x31, 0x44, 0x37, 0x33, 0x34, 0x35, 0x43, 0x31, 0x46, 0x32, 0x44, 0x33, 0x35, 0x35, 0x42, 0x47, 0x1F, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x31, 0x30, 0x31, 0x30, 0x20, 0x42, 0x31, 0x44, 0x37, 0x33, 0x34, 0x35, 0x43, 0x31, 0x46, 0x32, 0x44, 0x33, 0x35, 0x35, 0x42, 0x1F, 0x10, 0x01, 0xFF, 0x1F, 0x12, 0x01, 0x02 };

var apduInfo = ApduHelper.GetApduInfo(byteData);
var data = byteData.AsSpan().Slice(apduInfo.DataStartIndex);

var statusInformationParser = this.GetStatusInformationParser();
var statusInformation = statusInformationParser.Parse(data);

Assert.AreEqual("GEN.NR.:715691", statusInformation.AdditionalText);
Assert.AreEqual("Debit Mastercard", statusInformation.CardName);
Assert.AreEqual(1M, statusInformation.Amount);
Assert.AreEqual(671107177, statusInformation.TerminalIdentifier);
Assert.AreEqual("NFC", statusInformation.CardTechnology);
Assert.AreEqual(607, statusInformation.TraceNumber);
}

[TestMethod]
public void Parse_TlvInfos1_Successful()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Portalum.Zvt/Parsers/BmpParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public BmpParser(
new BmpInfo { Id = 0x2A, DataLength = 15, Description = "VU-number", TryParse = this.ParseVuNumber },
new BmpInfo { Id = 0x2D, DataLength = 2, Description = "Track 1 data, without start and end markers", TryParse = null },
new BmpInfo { Id = 0x2E, DataLength = 3, CalculateDataLength = this.GetDataLengthLL, Description = "Synchronous chip data", TryParse = null },
new BmpInfo { Id = 0x37, DataLength = 3, CalculateDataLength = this.GetDataLengthLLL, Description = "Trace-number of the original transaction for reversal", TryParse = null },
new BmpInfo { Id = 0x37, DataLength = 3, Description = "Trace-number of the original transaction for reversal", TryParse = null },
new BmpInfo { Id = 0x3A, DataLength = 2, Description = "CVV/CVC value, right padded with ‘F’ if less than 4 digits", TryParse = null },
new BmpInfo { Id = 0x3B, DataLength = 8, Description = "AID authorisation-attribute", TryParse = this.ParseAuthorisationAttribute },
new BmpInfo { Id = 0x3C, DataLength = 3, CalculateDataLength = this.GetDataLengthLLL, Description = "Additional-data/additional-text", TryParse = this.ParseAdditionalText },
Expand Down
2 changes: 1 addition & 1 deletion src/Portalum.Zvt/Portalum.Zvt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>

<Version>2.7.0</Version>
<Version>2.8.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 26b1331

Please sign in to comment.