Closed wadearnold closed 3 years ago
If that works, you guys are the best. :)
@Juniornewxt you can try it from this PR: https://github.com/moov-io/iso8583/pull/80
Do you have any examples? I tried it, to no avail :(
package main
import ( "fmt" "github.com/moov-io/iso8583" "github.com/moov-io/iso8583/encoding" "github.com/moov-io/iso8583/field" "github.com/moov-io/iso8583/padding" "github.com/moov-io/iso8583/prefix"
)
func NewSpec() *iso8583.MessageSpec {
return &iso8583.MessageSpec{
Fields: map[int]field.Field{
0: field.NewString(&field.Spec{
Length: 8,
Description: "Message Type Indicator",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
}),
1: field.NewBitmap(&field.Spec{
Description: "Bitmap",
Enc: encoding.Hex,
Pref: prefix.Hex.Fixed,
}),
3: field.NewNumeric(&field.Spec{
Length: 6,
Description: "Processing Code",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
Pad: padding.Left('0'),
}),
4: field.NewNumeric(&field.Spec{
Length: 12,
Description: "Transaction Amount",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
Pad: padding.Left('0'),
}),
7: field.NewNumeric(&field.Spec{
Length: 10,
Description: "Transaction Amount",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
Pad: padding.Left('0'),
}),
11: field.NewNumeric(&field.Spec{
Length: 6,
Description: "Transaction Amount",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
Pad: padding.Left('0'),
}),
12: field.NewNumeric(&field.Spec{
Length: 6,
Description: "Transaction Amount",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
Pad: padding.Left('0'),
}),
13: field.NewNumeric(&field.Spec{
Length: 4,
Description: "Transaction Amount",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
Pad: padding.Left('0'),
}),
32: field.NewString(&field.Spec{
Length: 11,
Description: "Field 32",
Enc: encoding.ASCII,
Pref: prefix.ASCII.LL,
}),
37: field.NewNumeric(&field.Spec{
Length: 12,
Description: "NSU",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
Pad: padding.Left('0'),
}),
39: field.NewString(&field.Spec{
Length: 2,
Description: "Field 39",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
Pad: padding.Left('0'),
}),
41: field.NewString(&field.Spec{
Length: 8,
Description: "Field 42",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
}),
42: field.NewString(&field.Spec{
Length: 15,
Description: "Field 42",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
}),
61: field.NewString(&field.Spec{
Length: 999,
Description: " ADC",
Enc: encoding.ASCII,
Pref: prefix.ASCII.LLL,
}),
},
}
}
func main() { test() }
func test() { want := "01150210323800010AC000080030000000000006630706101623000001101623070604008910162341603896JUNI0SIM00000000000999900504.10"
message := iso8583.NewMessage(iso8583.Spec87)
message.Unpack([]byte(want))
c, err := message.Pack()
if err != nil {
panic(err)
}
fmt.Printf("% x\n", c)
}
CLI with describe method is released in v0.4.1
.
Not included in the release:
@alovak can you add issues for those items that were not included for enhancements.
Create a function that dumps the iso8583 message into labels for debugging and logging.
<Property Name> <Field Length> <tab> :<Field Value>
I would like to name this "stringDump" or some variation so that we could add hexDump() and others in the future.
This function plus a simple string input CLI would be a nice tool utility tool. This would be like the achcli for describing a file. This should be a separate issue. https://github.com/moov-io/ach#command-line