imohsenb.iso8583 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package imohsenb.iso8583 --version 1.0.3                
NuGet\Install-Package imohsenb.iso8583 -Version 1.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="imohsenb.iso8583" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add imohsenb.iso8583 --version 1.0.3                
#r "nuget: imohsenb.iso8583, 1.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install imohsenb.iso8583 as a Cake Addin
#addin nuget:?package=imohsenb.iso8583&version=1.0.3

// Install imohsenb.iso8583 as a Cake Tool
#tool nuget:?package=imohsenb.iso8583&version=1.0.3                

ISO-8583 .Net Lib

ISO8583 Message Packer and Unpakcer with ISOClient for communication with iso server

A lightweight ISO8583 (is an international standard for financial transaction card originated interchange messaging - wikipedia ) library for DotNet based on builder pattern and provide very simple use as you will see later.

Usage

Library is available in Nuget

ISOMessage

Create and pack an ISO message

To create an ISO message you must use ISOMessageBuilder which produce iso message for you:


ISOMessage isoMessage = ISOMessageBuilder.Packer(VERSION.V1987)
                .NetworkManagement()
                .MTI(MESSAGE_FUNCTION.Request, MESSAGE_ORIGIN.Acquirer)
                .ProcessCode("930000")
                .SetField(FIELDS.F11_STAN, "385629")
                .SetField(FIELDS.F22_EntryMode, "1234")
                .SetField(FIELDS.F24_NII_FunctionCode, "4321")
                .SetField(FIELDS.F25_POS_ConditionCode, "12")
                .SetField(FIELDS.F41_CA_TerminalID, "12345678")
                .SetField(FIELDS.F42_CA_ID, "123456789876543")
                .GenerateMac(data => {
			byte[] mac = MacCalculator(data);
			return mac;
		})
                .SetHeader("1234567890")
                .Build();
				
                

with ISOMessageBuilder.Packer(VERSION.V1987) you can build iso message as you can see above. the 'Packer' method return 8 method for 8 iso message class (authorization, financial, networkManagment, ...) based on ISO8583 after that you can set message function and message origin by MTI method. MTI method accept string and enums as parameter, and I think enums are much clear and readable. As you know an iso message need a 'Processing Code' and you can set it's value by ProcessCode method, and then we can start setting required fields by SetField method and accept String and enums as field number parameter. After all, you must call build method to generate iso message object.

Unpack a buffer and parse it to ISO message

For unpacking a buffer received from server you need to use ISOMessageBuilder.Unpacker():

ISOMessage isoMessage = ISOMessageBuilder.Unpacker()
                                    .SetMessage(SAMPLE_HEADER + SAMPLE_MSG)
                                    .Build();
Working with ISOMessage object

ISOMessage object has multiple method provide fields, message body, header and ... for security reason they will return byte array exept .ToString and .GetStringField method, because Strings stay alive in memory until a garbage collector will come to collect that. but you can clear byte or char arrays after use and calling garbage collector is not important anymore. If you use Strings, taking memory dumps will be dangerous.

    byte[] body = isoMessage.GetBody();
    byte[] trace = isoMessage.GetField(11);
    string trace = isoMessage.GetStringField(FIELDS.F11_STAN);

ISOClient

Sending message to iso server

Sending message to iso server and received response from server can be done with ISOClient in many ways:

IISOClient client = ISOClientBuilder.CreateSocket(HOST, PORT)
                .Build();

        ISOMessage respIso = client.SendMessageSync(reqIso);
        client.Disconnect();

License

Copyright 2018 Mohsen Beiranvand

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 1,812 1/1/2019
1.0.4.2 718 11/11/2018
1.0.3 718 10/17/2018
1.0.2 747 10/13/2018
1.0.1 725 9/26/2018
1.0.0 753 9/22/2018

First release