Skip to content

A golang implementation to marshal and unmarshal iso8583 message.

License

Notifications You must be signed in to change notification settings

mfdeveloper508/iso8583

 
 

Repository files navigation

moov-io/iso8583

GoDoc Build Status Coverage Status Go Report Card Apache 2 licensed

Package github.com/moov-io/iso8583 implements a file reader and writer written in Go decorated with a HTTP API for creating, parsing, and validating financial transaction card originated interchange messaging.

Project Status

Moov ISO8583 is under active development.

Please star the project if you are interested in its progress. If you have layers above ACH to simplify tasks or found bugs we would appreciate an issue or pull request. Thanks!

Usage

Length encode and MTI encode types:

  • bcd - BCD encoding of field length (only for Ll* and Lll* fields)
  • ascii - ASCII encoding of field length (only for Ll* and Lll* fields)

Encode types:

  • bcd - BCD encoding
  • rbcd - BCD encoding with "right-aligned" value with odd length (for ex. "643" as [6 67] == "0643"), only for Numeric, Llnumeric and Lllnumeric fields
  • ascii - ASCII encoding

Example

package main

import (
	"fmt"

	"github.com/moov-io/iso8583"
)

type Data struct {
	No   *iso8583.Numeric      `field:"3" length:"6" encode:"bcd"` // bcd value encoding
	Oper *iso8583.Numeric      `field:"26" length:"2" encode:"ascii"` // ascii value encoding
	Ret  *iso8583.Alphanumeric `field:"39" length:"2"`
	Sn   *iso8583.Llvar        `field:"45" length:"23" encode:"bcd,ascii"` // bcd length encoding, ascii value encoding
	Info *iso8583.Lllvar       `field:"46" length:"42" encode:"bcd,ascii"`
	Mac  *iso8583.Binary       `field:"64" length:"8"`
}

func main() {
	data := &Data{
		No:   iso8583.NewNumeric("001111"),
		Oper: iso8583.NewNumeric("22"),
		Ret:  iso8583.NewAlphanumeric("ok"),
		Sn:   iso8583.NewLlvar([]byte("abc001")),
		Info: iso8583.NewLllvar([]byte("你好 golang!")),
		Mac:  iso8583.NewBinary([]byte("a1s2d3f4")),
	}
	msg := iso8583.NewMessage("0800", data)
	msg.MtiEncode = iso8583.BCD
	b, err := msg.Bytes()
	if err != nil {
		fmt.Println(err.Error())
	}
	fmt.Printf("% x\n", b)
}

Then you will get:

08 00 20 00 00 40 02 0c 00 01 00 11 11 32 32 6f 6b 06 61 62 63 30 30 31 00 14 e4 bd a0 e5 a5 bd 20 67 6f 6c 61 6e 67 21 61 31 73 32 64 33 66 34

Guides

Supported and Tested Platforms

  • 64-bit Linux (Ubuntu, Debian), macOS, and Windows
  • Rasberry Pi

Contributing

Yes please! Please review our Contributing guide and Code of Conduct to get started! Checkout our issues for first time contributors for something to help out with.

This project uses Go Modules and uses Go 1.14 or higher. See Golang's install instructions for help setting up Go. You can download the source code and we offer tagged and released versions as well. We highly recommend you use a tagged release for production.

Releasing

To make a release of ach simply open a pull request with CHANGELOG.md and version.go updated with the next version number and details. You'll also need to push the tag (i.e. git push origin v1.0.0) to origin in order for CI to make the release.

License

Apache License 2.0 See LICENSE for details.

Work is derived from @ideazxy, @zmwilliam, @rdingwall

About

A golang implementation to marshal and unmarshal iso8583 message.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 98.5%
  • Makefile 1.5%