https://github.com/oastuff/iso8583
A golang Implementation of Iso8583 protocol
https://github.com/oastuff/iso8583
Last synced: 9 months ago
JSON representation
A golang Implementation of Iso8583 protocol
- Host: GitHub
- URL: https://github.com/oastuff/iso8583
- Owner: oaStuff
- License: mit
- Created: 2016-01-06T11:23:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-03-19T16:34:53.000Z (over 8 years ago)
- Last Synced: 2024-06-21T07:46:22.642Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 20
- Watchers: 4
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is an implementation of the ISO8583 standard in GO.
#### Getting the library
```
go get github.com/oaStuff/Iso8583
```
#### Using default Iso8583 implementation
```go
func main() {
// Creates a new Iso8583 message
msg := NewIso8583()
//Set various fields as required
msg.SetFieldValue(4,"4000")
msg.SetFieldValue(70,"677")
//You can even set a sub field on field 127 (this conforms to the Postilion switch standard)
msg.SetSubFieldValue(127,2,"999999999")
msg.SetSubFieldValue(127,6,"p1")
msg.SetSubFieldValue(127,34,"98")
//You can get the raw bytes of the message
data := msg.ToMsg()
//Print out the message in the default formatted message style
log.Printf("\n%s",msg.ToString(""))
//retrieve values from the message
log.Println("Data stored is ", msg.GetFieldValue(2))
//View the hex dump of the message also
log.Println("hex dump data is ")
log.Printf("\n%v",hex.Dump(data))
}
```
#### Specifying your own template
```go
func main() {
//Define the template
tmplDef := TemplateDef{
2 : AsciiVar(2,20,fieldValidator.N()),
4 : AsciiNumeric(12),
70 : AsciiAlphaNumeric(3),
}
//Create the template and use it in creating the message
tmpl:= NewTemplate(tmplDef)
msg := NewAMessage(tmpl)
//Set various fields as required
//You can only set values for the field you have defined in the template
msg.SetFieldValue(4,"4000")
msg.SetFieldValue(70,"677")
//You can get the raw bytes of the message
data := msg.ToMsg()
//Print out the message in the default formatted message style
log.Printf("\n%s",msg.ToString(""))
//retrieve values from the message
log.Println("Data stored is ", msg.GetFieldValue(2))
//View the hex dump of the message also
log.Println("hex dump data is ")
log.Printf("\n%v",hex.Dump(data))
}
```
##### LICENSE
MIT