Skip to content

An easy to use, yet flexible marshaler for ISO-8583

License

Notifications You must be signed in to change notification settings

jattento/go-iso8583

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codecov Maintainability License: MIT Last release

Version Build
Go 1.19 Build Status
Go 1.18 Build Status
Go 1.17 Build Status
Go 1.16 Build Status
Go 1.15 Build Status
Go 1.14 Build Status
Go 1.13 Build Status

go-iso8583

An easy to use, yet flexible marshaler for ISO-8583.

API godoc documentation.

This library provides:

  • Marshal and Unmarshal functions with his respective interfaces including MTI, VAR, LLVAR, LLLVAR and bitmaps fields ready for use but with the possibility to easily add new field types.
  • Inbuid Support for ASCII and EBCDIC but not limited to them

Installation

To install go-iso8583 package, you need to install Go and set your Go workspace first.

  1. First you need Go installed, then you can use the below Go command to install go-iso8583.
$ go get -u github.com/jattento/go-iso8583/iso8583
  1. Import it in your code:
import "github.com/jattento/go-iso8583/pkg/iso8583"

Quick start

The API of this package is inspired in the go native json package therefore it's pretty intuitive to use. Take a look at this!

import "github.com/jattento/go-iso8583/pkg/iso8583"

type exampleMessage struct {
	MessageTypeIdentifier                     iso8583.MTI       `iso8583:"mti,length:4,encoding:ebcdic"`
	Bitmap                                    iso8583.BITMAP    `iso8583:"bitmap"`
	SecondaryBitmap                           iso8583.BITMAP    `iso8583:"1,omitempty"`
	PrimaryAccountNumber                      iso8583.LLVAR     `iso8583:"2,length:64,encoding:ebcdic,omitempty"`
	ProcessingCode                            iso8583.VAR       `iso8583:"3,length:6,encoding:ebcdic,omitempty"` 
	AmountTransaction                         iso8583.VAR       `iso8583:"4,length:12,encoding:ebcdic,omitempty"`
	AmountSettlement                          iso8583.VAR       `iso8583:"5,length:12,encoding:ebcdic,omitempty"`
	AmountCardholderBilling                   iso8583.VAR       `iso8583:"6,length:12,encoding:ebcdic,omitempty"`
	AcquiringInstitutionIDCode                iso8583.LLVAR     `iso8583:"32,length:11,encoding:ebcdic,omitempty"`
	ForwardingInstitutionIDCode               iso8583.LLVAR     `iso8583:"33,length:11,encoding:ebcdic,omitempty"`
	PrimaryAccountNumberExtended              iso8583.LLVAR     `iso8583:"34,length:28,encoding:ebcdic,omitempty"`
	Track2Data                                iso8583.LLVAR     `iso8583:"35,length:37,encoding:ebcdic,omitempty"`
	Track3Data                                iso8583.LLLVAR    `iso8583:"36,length:104,encoding:ebcdic,omitempty"`
	AdditionalResponseData                    iso8583.LLVAR     `iso8583:"44,length:25,encoding:ebcdic,omitempty"`
	Track1Data                                iso8583.LLVAR     `iso8583:"45,length:76,encoding:ebcdic,omitempty"`
	ExpandedAdditionalAmounts                 iso8583.LLLVAR    `iso8583:"46,length:999,encoding:ebcdic,omitempty"`
	AdditionalDataNationalUse                 iso8583.LLLVAR    `iso8583:"47,length:999,encoding:ebcdic,omitempty"`
	AdditionalDataPrivateUse                  iso8583.LLLVAR    `iso8583:"48,length:999,encoding:ebcdic,omitempty"`
	CurrencyCodeTransaction                   iso8583.VAR       `iso8583:"49,length:3,encoding:ebcdic,omitempty"`
	CurrencyCodeSettlement                    iso8583.VAR       `iso8583:"50,length:3,encoding:ebcdic,omitempty"`
	CurrencyCodeCardholderBilling             iso8583.VAR       `iso8583:"51,length:3,encoding:ebcdic,omitempty"`
	PersonalIDNumberData                      iso8583.BINARY    `iso8583:"52,length:8,omitempty"`
	SecurityRelatedControlInformation         iso8583.VAR       `iso8583:"53,length:16,encoding:ebcdic,omitempty"`
	AdditionalAmounts                         iso8583.LLLVAR    `iso8583:"54,length:120,encoding:ebcdic,omitempty"`
	IntegratedCircuitCardSystemRelatedData    iso8583.LLLBINARY `iso8583:"55,length:999,encoding:ebcdic,omitempty"`
	MessageSecurityCode                       iso8583.VAR       `iso8583:"96,length:8,encoding:ebcdic,omitempty"`
}
func GenerateStaticReqBytes() ([]byte, error) {
	req := exampleMessage{
		MTI: "0100",
		// FirstBitmap is generated by library
		// SecondBitmap is generated by library
		PAN: "54000000000000111", // LL part is added by library!
		ProcessingCode: "1000",
		Amount: "000000000100",
		MessageNumber: "1",
	}
	
	byt, err := iso8583.Marshal(req)
	if err != nil {
		return nil, err
	}

	return byt, nil
}
import "github.com/jattento/go-iso8583/pkg/iso8583"

func ReadResp(byt []byte) (exampleMessage,error){
	var resp exampleMessage

	_, err :=iso8583.Unmarshal(byt,&resp)
	if err != nil{
		return exampleMessage{}, err
	}

	return resp,nil
}

About

An easy to use, yet flexible marshaler for ISO-8583

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages