Documentation ¶
Index ¶
- Constants
- Variables
- func NextBytes(buf *bytes.Buffer, n int) ([]byte, error)
- func ReadSpecs(specDir string) error
- type Assembler
- type AssemblerConfig
- type Bitmap
- func (bmp *Bitmap) BinaryString() string
- func (bmp *Bitmap) Bytes() []byte
- func (bmp *Bitmap) Copy() *Bitmap
- func (bmp *Bitmap) Get(pos int) *FieldData
- func (bmp *Bitmap) IsOn(position int) bool
- func (bmp *Bitmap) Set(pos int, val string) error
- func (bmp *Bitmap) SetOff(position int)
- func (bmp *Bitmap) SetOn(position int)
- type Encoding
- type EnumValue
- type Field
- type FieldConstraints
- type FieldData
- type FieldType
- type Hint
- type HintType
- type Iso
- type MacAlgo
- type MacGenProps
- type Message
- type MetaInfo
- type PaddingType
- type ParsedMsg
- type Parser
- type ParserConfig
- type PinFormat
- type PinGenProps
- type Spec
- type Specs
Constants ¶
const ( Fixed = "fixed" Variable = "variable" Bitmapped = "bitmap" )
const ( // IsoMessageType is a constant that indicates the Message Type or the MTI // (This name has special meaning within the context of ISO8583 and cannot be named anything else. The same restrictions apply for 'Bitmap') IsoMessageType = "Message Type" IsoBitmap = "Bitmap" )
const ( FixedType FieldType = "Fixed" VariableType FieldType = "Variable" BitmappedType FieldType = "Bitmapped" ASCII Encoding = "ASCII" EBCDIC Encoding = "EBCDIC" BINARY Encoding = "BINARY" BCD Encoding = "BCD" ContentTypeAny = "Any" // Mli2I is a message length indicator that is 2 bytes binary that includes the length of indicator itself Mli2I = "2I" // Mli2E is 2 bytes binary with length of the indicator not included Mli2E = "2E" )
const ( ISO0 PinFormat = "ISO0" ISO1 PinFormat = "ISO1" ISO3 PinFormat = "ISO3" IBM3264 PinFormat = "IBM3264" ANSIX9_19 MacAlgo = "ANSIX9_19" )
const HighBitMask = uint64(1) << 63
Variables ¶
var ErrInsufficientData = errors.New("isosim: Insufficient data to parse field")
ErrInsufficientData is an error when there is not enough data in the raw message to parse it
var ErrInvalidEncoding = errors.New("isosim: Invalid encoding")
ErrInvalidEncoding is when an unsupported encoding is used for a field
var ErrLargeLengthIndicator = errors.New("isosim: Too large length indicator size. ")
ErrLargeLengthIndicator is an error that could happen when a large lenght indicator is used in a variable field
var ErrUnknownField = errors.New("isosim: Unknown field")
ErrUnknownField is an error when a unknown field is referenced
var ErrUnreadDataRemaining = errors.New("isosim: Unprocessed data remaining")
ErrUnreadDataRemaining to represent a condition where data remain post parsing
var NumericRegexPattern = regexp.MustCompile("^[0-9]+$")
Functions ¶
Types ¶
type Assembler ¶ added in v2.0.1
type Assembler struct {
// contains filtered or unexported fields
}
Assembler defines a ISO8583 message assembler
func NewAssembler ¶ added in v2.0.1
func NewAssembler(assemblerCfg *AssemblerConfig) *Assembler
NewAssembler creates a new assembler
type AssemblerConfig ¶ added in v2.0.1
type AssemblerConfig struct {
LogEnabled bool
}
AssemblerConfig defines all configuration options for the assembler
type Bitmap ¶
type Bitmap struct {
// contains filtered or unexported fields
}
Bitmap represents a bitmap in the ISO8583 specification
func (*Bitmap) BinaryString ¶
BinaryString returns a binary string representing the Bitmap
type Field ¶
type Field struct { Name string `yaml:"name"` ID int `yaml:"id"` Type FieldType `yaml:"type"` Size int `yaml:"size"` Position int `yaml:"position"` DataEncoding Encoding `yaml:"data_encoding"` LengthIndicatorSize int `yaml:"length_indicator_size"` LengthIndicatorMultiplier int `yaml:"length_indicator_multiplier"` LengthIndicatorEncoding Encoding `yaml:"length_indicator_encoding"` Constraints FieldConstraints `yaml:"constraints"` Padding PaddingType `yaml:"padding"` Children []*Field `yaml:"children"` ParentId int ValueGeneratorType string `yaml:"gen_type"` PinGenProps *PinGenProps `yaml:"pin_gen_props,omitempty"` MacGenProps *MacGenProps `yaml:"mac_gen_props,omitempty"` Key bool `yaml:"key"` Hint Hint `yaml:"hint"` // contains filtered or unexported fields }
Field represents a field in the ISO message
func (*Field) GetChildren ¶
Children returns a []Field of its children
func (*Field) HasChildren ¶
HasChildren returns a boolean that indicates if the field has children (nested fields)
func (*Field) ValueFromString ¶
ValueFromString constructs the value for a field from a raw form
func (*Field) ValueToString ¶
ValueToString returns the value of the field to a string representation
type FieldConstraints ¶
type FieldData ¶
type FieldData struct { Field *Field Data []byte // Bitmap is only used for bitmapped fields to keep track of // what bits are on Bitmap *Bitmap }
FieldData represents the data associated with a field in a ISO message
type Hint ¶
type Hint struct { //Type is the type of hint - date_time, currency_code and others Type string `yaml:"type"` //Format is an optional qualifier to add more context to the hint Format string `yaml:"format"` //Enumerated values are a array of values for enumerated hint type Values []EnumValue `yaml:"values"` }
Hint represents metadata associated with a field that could be useful for the UI to aid the user to provide value for the field
type Iso ¶
type Iso struct {
// contains filtered or unexported fields
}
Iso is a handle into accessing the details of a ISO message(via the parsedMsg)
func FromParsedMsg ¶
FromParsedMsg constructs a new Iso from a parsedMsg
type MacGenProps ¶
type Message ¶
type Message struct { Name string `yaml:"name"` ID int `yaml:"id"` Fields []*Field `yaml:"fields"` // HeaderMatch HeaderMatch []string `yaml:"header_match"` // contains filtered or unexported fields }
Message represents a message within a specification (auth/reversal etc)
type MetaInfo ¶
type MetaInfo struct { // OpTime is time taken by an operation OpTime time.Duration // MessageKey is a key that can be used to uniquely identify a transaction MessageKey string }
MetaInfo provides additional information about an operation performed For example, in response to a parse or assemble op
type PaddingType ¶
type PaddingType string
const ( LeadingZeroes PaddingType = "LEADING_ZEROES" LeadingSpaces PaddingType = "LEADING_SPACES" LeadingF PaddingType = "LEADING_F" TrailingZeroes PaddingType = "TRAILING_ZEROES" TrailingSpaces PaddingType = "TRAILING_SPACES" TrailingF PaddingType = "TRAILING_F" )
type ParsedMsg ¶
type ParsedMsg struct { IsRequest bool Msg *Message //A map of Id to FieldData FieldDataMap map[int]*FieldData // MessageKey is a value that unique identifies a transaction // (usually a combination of fields like STAN, PAN etc) MessageKey string }
ParsedMsg is a type that represents a parsed form of a ISO8583 message
type Parser ¶ added in v2.0.1
type Parser struct {
// contains filtered or unexported fields
}
Parser defines a ISO8583 message parser
func NewParser ¶ added in v2.0.1
func NewParser(parserCfg *ParserConfig) *Parser
NewParser creates and returns a new parser
type ParserConfig ¶ added in v2.0.1
type ParserConfig struct {
LogEnabled bool
}
ParserConfig defines the various configurations of the Parser
type PinGenProps ¶
type PinGenProps struct { PINClear string `yaml:"pin_clear",json:"pin_clear"` PINFormat PinFormat `yaml:"pin_format",json:"pin_format"` PINKey string `yaml:"pin_key",json:"pin_key"` PANFieldID int `yaml:"pan_field_id",json:"pan_field_id"` PANExtractParams string `yaml:"pan_extract_params",json:"pan_extract_params"` PAN string `yaml:"pan",json:"pan"` }
func (*PinGenProps) Generate ¶
func (pgp *PinGenProps) Generate() ([]byte, error)
type Spec ¶
type Spec struct { Name string `yaml:"name"` ID int `yaml:"id"` HeaderFields []*Field `yaml:"header_fields"` Messages []*Message `yaml:"messages"` }
Spec represents an ISO8583 specification
func (*Spec) FindTargetMsg ¶
FindTargetMsg parses any defined header fields and returns a message
func (*Spec) GetMessages ¶
Messages returns a list of all messages defined for the spec
func (*Spec) GetOrAddMsg ¶
GetOrAddMsg returns (or adds and returns) a msg - This is usually called during initialization
func (*Spec) MessageByID ¶
MessageByID returns a message given its id
func (*Spec) MessageByName ¶
MessageByName returns a message given its name