Documentation ¶
Index ¶
- Constants
- Variables
- func Bcd(src []byte) ([]byte, error)
- func BcdAscii(src []byte, length int) ([]byte, error)
- func BitmapToIndexArray(bitmap string, base int) []int
- func CheckAvailableEncoding(eType string, encoding string) bool
- func IsSecondBitmap(bitmap string) bool
- func IsThirdBitmap(bitmap string) bool
- func RBcd(src []byte) ([]byte, error)
- func RBcdAscii(src []byte, length int) ([]byte, error)
- func UTF8ToWindows1252(input []byte) ([]byte, error)
- type Attribute
- type Attributes
- type ElementType
- type EncodingDefinition
- type Specification
Constants ¶
View Source
const ( ElementTypeMti = "mti" // numeric characters ElementTypeBitmap = "bit" // numeric characters ElementTypeAlphabetic = "a" // alphabetic characters only ElementTypeNumeric = "n" // numeric characters only ElementTypeSpecial = "s" // special characters only ElementTypeMagnetic = "z" // magnetic stripe track-2 or track-3 data ElementTypeIndicate = "x" // character “C” or “D” to indicate “credit” or “debit” value of a dollar amount ElementTypeBinary = "b" // binary data ElementTypeAlphaNumeric = "an" // alpha and numeric characters ElementTypeAlphaSpecial = "as" // alpha and special characters ElementTypeNumericSpecial = "ns" // numeric and special characters ElementTypeAlphaNumericSpecial = "ans" // alpha, numeric, and special characters ElementTypeIndicateNumeric = "x+n" // Numeric (amount) values, where the first byte is either “C” or “D” ElementTypeNumberEncoding = "number" DataElementXmlName = "Element" DataElementAttrNumber = "Number" EncodingChar = "CHAR" EncodingHex = "HEX" EncodingEbcdic = "EBCDIC" EncodingAscii = "ASCII" EncodingBcd = "BCD" // packed bcd EncodingRBcd = "RBCD" EncodingCatNumber = "number" EncodingCatBinary = "binary" EncodingCatCharacter = "character" )
View Source
const ( // ErrInvalidEncoder is given when an invalid encoder is not supported ErrInvalidEncoder string = "invalid encoder" // ErrNonAvailableEncoding is given when encoding is non available ErrNonAvailableEncoding string = "non available encoding" // ErrInvalidLengthEncoder is given when the length of an encoder is invalid ErrInvalidLengthEncoder string = "invalid length encoder" // ErrInvalidLengthHead is given when the length of the head is invalid ErrInvalidLengthHead string = "invalid length head" // ErrValueTooLong is given when the length of the field is different from the length supplied ErrValueTooLong string = "length of value is longer than definition; type=%s, def_len=%d, len=%d" // ErrBadRaw is given when the raw data is malformed ErrBadRaw string = "bad raw data" // ErrBadElementData is given when the raw data is invalid data ErrBadElementData string = "bad element data" // ErrBadBinary is given when the length of the raw data is invalid ErrBadBinary string = "bad binary data" // ErrParseLengthFailed is given when the length of the binary data is invalid ErrParseLengthFailed string = "parse length head failed" // ErrNonExistSpecification is given when there is no specification ErrNonExistSpecification string = "don't exist specification" // ErrInvalidSpecification is given when there is invalid specification ErrInvalidSpecification string = "has invalid specification" // ErrInvalidBitmapArray is given when bitmap array is invalid ErrInvalidBitmapArray string = "invalid iso8583 bitmap array" // ErrInvalidElementLength is given when the length of the element is invalid ErrInvalidElementLength string = "invalid element length" // ErrInvalidElementType is given when the type of the element is invalid ErrInvalidElementType string = "invalid element type" // ErrMisMatchElementsBitmap is given when mismatch between bitmap and data elements ErrMisMatchElementsBitmap string = "don't match bitmap and data elements" // ErrNonInitializedMessage is given when message instance is not initialized ErrNonInitializedMessage string = "non initialized message" )
Variables ¶
View Source
var ( RegexAlphabetic = regexp.MustCompile(`^[a-z A-Z]+$`).MatchString RegexNumeric = regexp.MustCompile(`^[0-9]+$`).MatchString RegexSpecial = regexp.MustCompile(`^[$&+,:;=?@#|'<>.^*()%! -]+$`).MatchString RegexIndicate = regexp.MustCompile(`^[C|D]{1}$`).MatchString RegexAlphaNumeric = regexp.MustCompile(`^[a-z A-Z0-9]*$`).MatchString RegexIndicateNumeric = regexp.MustCompile(`^[C|D][0-9]+$`).MatchString RegexAlphaSpecial = regexp.MustCompile(`^[a-zA-Z$&+,:;=?@#|'<>.^*()%! -]+$`).MatchString RegexBinary = regexp.MustCompile(`^[0|1]+$`).MatchString RegexNumericSpecial = regexp.MustCompile(`^[0-9$&+,:;=?@#|'<>.^*()%! -]+$`).MatchString RegexAlphaNumericSpecial = regexp.MustCompile(`^[0-9a-zA-Z$&+,:;=?@#|'<>.^*()%! -]+$`).MatchString RegexTimeHHMMSS = regexp.MustCompile(`(2[0-3]|[01][0-9])[0-5][0-9][0-5][0-9]`).MatchString RegexDateYYMM = regexp.MustCompile(`((\d{2})(0[1-9]|10|12))`).MatchString RegexDateMMDD = regexp.MustCompile(`((0[1-9]|10|11|12)(0[1-9]|[12][0-9]|3[01]))`).MatchString RegexDateYYMMDD = regexp.MustCompile(`((\d{2})(0[1-9]|10|11|12)(0[1-9]|[12][0-9]|3[01]))`).MatchString RegexDateMMDDHHMMSS = regexp.MustCompile(`((0[1-9]|10|11|12)(0[1-9]|[12][0-9]|3[01])(2[0-3]|[01][0-9])[0-5][0-9][0-5][0-9])`).MatchString )
View Source
var ( DefaultMessageEncoding = &EncodingDefinition{ MtiEnc: EncodingChar, BitmapEnc: EncodingHex, LengthEnc: EncodingChar, NumberEnc: EncodingChar, CharacterEnc: EncodingAscii, BinaryEnc: EncodingHex, TrackEnc: EncodingChar, } ISO8583DataElementsVer1987 = Specification{ Encoding: DefaultMessageEncoding, Elements: &Attributes{ 1: {"b 64", "Second Bitmap"}, 2: {"n..19", "Primary account number (PAN)"}, 3: {"n 6", "Processing code"}, 4: {"n 12", "Amount, transaction"}, 5: {"n 12", "Amount, settlement"}, 6: {"n 12", "Amount, cardholder billing"}, 7: {"n 10; MMDDhhmmss", "Transmission date & time"}, 8: {"n 8", "Amount, cardholder billing fee"}, 9: {"n 8", "Conversion rate, settlement"}, 10: {"n 8", "Conversion rate, cardholder billing"}, 11: {"n 6", "System trace audit number (STAN)"}, 12: {"n 6; hhmmss", "Local transaction time (hhmmss)"}, 13: {"n 4; MMDD", "Local transaction date (MMDD)"}, 14: {"n 4; YYMM", "Expiration date"}, 15: {"n 4; MMDD", "Settlement date"}, 16: {"n 4; MMDD", "Currency conversion date"}, 17: {"n 4; MMDD", "Capture date"}, 18: {"n 4", "Merchant type, or merchant category code"}, 19: {"n 3", "Acquiring institution (country code)"}, 20: {"n 3", "PAN extended (country code)"}, 21: {"n 3", "Forwarding institution (country code)"}, 22: {"n 3", "Point of Sale (POS) entry mode"}, 23: {"n 3", "Application PAN sequence number"}, 24: {"n 3", "Function code (ISO 8583:1993), or network international identifier (NII)"}, 25: {"n 2", "Point of Sale (POS) condition code"}, 26: {"n 2", "Point of Sale (POS) capture code"}, 27: {"n 1", "Authorizing identification response length"}, 28: {"x+n 8", "Amount, transaction fee"}, 29: {"x+n 8", "Amount, settlement fee"}, 30: {"x+n 8", "Amount, transaction processing fee"}, 31: {"x+n 8", "Amount, settlement processing fee"}, 32: {"n..11", "Acquiring institution identification code"}, 33: {"n..11", "Forwarding institution identification code"}, 34: {"ns..28", "Primary account number, extended"}, 35: {"z..37", "Track 2 data"}, 36: {"n...104", "Track 3 data"}, 37: {"an 12", "Retrieval reference number"}, 38: {"an 6", "Authorization identification response"}, 39: {"an 2", "Response code"}, 40: {"an 3", "Service restriction code"}, 41: {"ans 8", "Card acceptor terminal identification"}, 42: {"ans 15", "Card acceptor identification code"}, 43: {"ans 40", "Card acceptor name/location (1–23 street address, –36 city, –38 state, 39–40 country)"}, 44: {"an..25", "Additional response data"}, 45: {"an..76", "Track 1 data"}, 46: {"an...999", "Additional data (ISO)"}, 47: {"an...999", "Additional data (national)"}, 48: {"an...999", "Additional data (private)"}, 49: {"n 3", "Currency code, transaction"}, 50: {"n 3", "Currency code, settlement"}, 51: {"n 3", "Currency code, cardholder billing"}, 52: {"b 64", "Personal identification number data"}, 53: {"n 16", "Security related control information"}, 54: {"an...120", "Additional amounts"}, 55: {"ans...999", "ICC data – EMV having multiple tags"}, 56: {"ans...999", "Reserved (ISO)"}, 57: {"ans...999", "Reserved (national)"}, 58: {"ans...999", "Reserved (national)"}, 59: {"ans...999", "Reserved (national)"}, 60: {"ans...999", "Reserved (national)"}, 61: {"ans...999", "Reserved (private) (e.g. CVV2/service code transactions)"}, 62: {"ans...999", "Reserved (private) (e.g. transactions: invoice number, key exchange transactions: TPK key, etc.)"}, 63: {"ans...999", "Reserved (private)"}, 64: {"b 64", "Message authentication code (MAC)"}, 65: {"b 1", "Extended bitmap indicator"}, 66: {"n 1", "Settlement code"}, 67: {"n 2", "Extended payment code"}, 68: {"n 3", "Receiving institution country code"}, 69: {"n 3", "Settlement institution country code"}, 70: {"n 3", "Network management information code"}, 71: {"n 4", "Message number"}, 72: {"n 4", "Last message's number"}, 73: {"n 6; YYMMDD", "Action date (YYMMDD)"}, 74: {"n 10", "Number of credits"}, 75: {"n 10", "Credits, reversal number"}, 76: {"n 10", "Number of debits"}, 77: {"n 10", "Debits, reversal number"}, 78: {"n 10", "Transfer number"}, 79: {"n 10", "Transfer, reversal number"}, 80: {"n 10", "Number of inquiries"}, 81: {"n 10", "Number of authorizations"}, 82: {"n 12", "Credits, processing fee amount"}, 83: {"n 12", "Credits, transaction fee amount"}, 84: {"n 12", "Debits, processing fee amount"}, 85: {"n 12", "Debits, transaction fee amount"}, 86: {"n 16", "Total amount of credits"}, 87: {"n 16", "Credits, reversal amount"}, 88: {"n 16", "Total amount of debits"}, 89: {"n 16", "Debits, reversal amount"}, 90: {"n 42", "Original data elements"}, 91: {"an 1", "File update code"}, 92: {"an 2", "File security code"}, 93: {"an 5", "Response indicator"}, 94: {"an 7", "Service indicator"}, 95: {"an 42", "Replacement amounts"}, 96: {"b 64", "Message security code"}, 97: {"x+n 16", "Net settlement amount"}, 98: {"ans 25", "Payee"}, 99: {"n..11", "Settlement institution identification code"}, 100: {"n..11", "Receiving institution identification code"}, 101: {"ans..17", "File name"}, 102: {"ans..28", "Account identification 1"}, 103: {"ans..28", "Account identification 2"}, 104: {"ans...100", "Transaction description"}, 105: {"ans...999", "Reserved for ISO use"}, 106: {"ans...999", "Reserved for ISO use"}, 107: {"ans...999", "Reserved for ISO use"}, 108: {"ans...999", "Reserved for ISO use"}, 109: {"ans...999", "Reserved for ISO use"}, 110: {"ans...999", "Reserved for ISO use"}, 111: {"ans...999", "Reserved for ISO use"}, 112: {"ans...999", "Reserved for national use"}, 113: {"ans...999", "Reserved for national use"}, 114: {"ans...999", "Reserved for national use"}, 115: {"ans...999", "Reserved for national use"}, 116: {"ans...999", "Reserved for national use"}, 117: {"ans...999", "Reserved for national use"}, 118: {"ans...999", "Reserved for national use"}, 119: {"ans...999", "Reserved for national use"}, 120: {"ans...999", "Reserved for private use"}, 121: {"ans...999", "Reserved for private use"}, 122: {"ans...999", "Reserved for private use"}, 123: {"ans...999", "Reserved for private use"}, 124: {"ans...999", "Reserved for private use"}, 125: {"ans...999", "Reserved for private use"}, 126: {"ans...999", "Reserved for private use"}, 127: {"ans...999", "Reserved for private use"}, 128: {"b 64", "Message authentication code"}, }, } )
View Source
var AvailableDateFormat = map[string]func(s string) bool{ "HHMMSS": RegexTimeHHMMSS, "YYMM": RegexDateYYMM, "MMDD": RegexDateMMDD, "YYMMDD": RegexDateYYMMDD, "MMDDHHMMSS": RegexDateMMDDHHMMSS, }
View Source
var AvailableEncodings = map[string][]string{ ElementTypeMti: {EncodingChar, EncodingBcd}, ElementTypeBitmap: {EncodingChar, EncodingHex}, ElementTypeAlphabetic: {EncodingAscii, EncodingEbcdic}, ElementTypeNumeric: {EncodingBcd, EncodingRBcd, EncodingChar}, ElementTypeSpecial: {EncodingAscii, EncodingEbcdic}, ElementTypeMagnetic: {EncodingAscii, EncodingEbcdic}, ElementTypeIndicate: {EncodingAscii, EncodingEbcdic}, ElementTypeBinary: {EncodingChar, EncodingHex}, ElementTypeAlphaNumeric: {EncodingAscii, EncodingEbcdic}, ElementTypeAlphaSpecial: {EncodingAscii, EncodingEbcdic}, ElementTypeNumericSpecial: {EncodingAscii, EncodingEbcdic}, ElementTypeAlphaNumericSpecial: {EncodingAscii, EncodingEbcdic}, ElementTypeIndicateNumeric: {EncodingAscii, EncodingEbcdic}, ElementTypeNumberEncoding: {EncodingChar, EncodingHex, EncodingRBcd, EncodingBcd}, }
data representation attributes
View Source
var AvailableTypeCategory = map[string]string{ ElementTypeMti: EncodingCatNumber, ElementTypeBitmap: EncodingCatBinary, ElementTypeAlphabetic: EncodingCatCharacter, ElementTypeNumeric: EncodingCatNumber, ElementTypeSpecial: EncodingCatCharacter, ElementTypeMagnetic: EncodingCatCharacter, ElementTypeIndicate: EncodingCatCharacter, ElementTypeBinary: EncodingCatBinary, ElementTypeAlphaNumeric: EncodingCatCharacter, ElementTypeAlphaSpecial: EncodingCatCharacter, ElementTypeNumericSpecial: EncodingCatCharacter, ElementTypeAlphaNumericSpecial: EncodingCatCharacter, ElementTypeIndicateNumeric: EncodingCatCharacter, }
View Source
var ElementDataTypes = []string{ ElementTypeAlphabetic, ElementTypeNumeric, ElementTypeSpecial, ElementTypeMagnetic, ElementTypeIndicate, ElementTypeBinary, ElementTypeAlphaNumeric, ElementTypeAlphaSpecial, ElementTypeNumericSpecial, ElementTypeAlphaNumericSpecial, ElementTypeIndicateNumeric, }
data representation attributes
Functions ¶
func BitmapToIndexArray ¶
HexToBitmapArray converts a hex string to a bit array
func CheckAvailableEncoding ¶
func IsSecondBitmap ¶
IsSecondBitmap return existence of sub bitmap
func IsThirdBitmap ¶
IsThirdBitmap return existence of sub bitmap
func UTF8ToWindows1252 ¶
UTF8ToWindows1252 converts text encoded in UTF-8 to Windows-1252 or CP-1252 encoding
Types ¶
type Attribute ¶
type Attribute struct { Describe string // [attribute(b 64, b-64, b..64)]; [format(MMDD, hhmmss)] Description string }
func (Attribute) Parse ¶
func (s Attribute) Parse() (*ElementType, error)
Parse return ElementType from attribute string
type Attributes ¶
func (Attributes) Keys ¶
func (s Attributes) Keys() (keys []int)
type ElementType ¶
type ElementType struct { Type string Length int Format string Encoding string Fixed bool LengthEncoding string }
general element type for all of the data representation attributes
func (*ElementType) SetEncoding ¶
func (t *ElementType) SetEncoding(encoding *EncodingDefinition)
SetEncoding will set encoders
func (*ElementType) Validate ¶
func (t *ElementType) Validate() error
type EncodingDefinition ¶
type Specification ¶
type Specification struct { Elements *Attributes `json:"elements,omitempty"` Encoding *EncodingDefinition `json:"encoding,omitempty"` }
Click to show internal directories.
Click to hide internal directories.