iso8583

package module
v0.0.0-...-ad2634f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

README

Fork of the go iso8583 library by moov.io

Documentation

Overview

Version will be automatically set during the build

Index

Constants

This section is empty.

Variables

View Source
var DefaultFilters = func() []FieldFilter {
	filters := []FieldFilter{
		FilterField("2", PANFilter),
		FilterField("20", PANFilter),
		FilterField("35", Track2Filter),
		FilterField("36", Track3Filter),
		FilterField("45", Track1Filter),
		FilterField("52", PINFilter),
		FilterField("55", EMVFilter),
	}
	return filters
}
View Source
var DoNotFilterFields = func() []FieldFilter {
	filters := []FieldFilter{
		FilterField("-1", NoOpFilter),
	}
	return filters
}
View Source
var EMVFilter = func(in string, data field.Field) string {
	if utf8.RuneCountInString(in) < emvFirstIndex+emvLastIndex {
		return in
	}

	return in[0:emvFirstIndex] + emvPattern + in[len(in)-emvLastIndex:]
}
View Source
var NoOpFilter = func(in string, data field.Field) string {
	return in
}
View Source
var PANFilter = func(in string, data field.Field) string {
	if utf8.RuneCountInString(in) < panFistIndex+panLastIndex {
		return in
	}
	return in[0:panFistIndex] + panPattern + in[len(in)-panLastIndex:]
}
View Source
var PINFilter = func(in string, data field.Field) string {
	if utf8.RuneCountInString(in) < pinFirstIndex+pinLastIndex {
		return in
	}
	return in[0:pinFirstIndex] + pinPattern + in[len(in)-pinLastIndex:]
}
View Source
var Track1Filter = func(in string, data field.Field) string {
	track := field.Track1{}
	if err := newTrackData(data, &track); err != nil {
		return in
	}

	track.PrimaryAccountNumber = PANFilter(track.PrimaryAccountNumber, nil)
	return getTrackDataString(in, &track)
}
View Source
var Track2Filter = func(in string, data field.Field) string {
	track := field.Track2{}
	if err := newTrackData(data, &track); err != nil {
		return in
	}

	track.PrimaryAccountNumber = PANFilter(track.PrimaryAccountNumber, nil)
	return getTrackDataString(in, &track)
}
View Source
var Track3Filter = func(in string, data field.Field) string {
	track := field.Track3{}
	if err := newTrackData(data, &track); err != nil {
		return in
	}
	track.PrimaryAccountNumber = PANFilter(track.PrimaryAccountNumber, nil)

	return getTrackDataString(in, &track)
}
View Source
var Version string

Functions

func Describe

func Describe(message *Message, w io.Writer, filters ...FieldFilter) error

func DescribeFieldContainer

func DescribeFieldContainer(container FieldContainer, w io.Writer, filters ...FieldFilter) error

DescribeFieldContainer describes the FieldContainer (e.g. Wrapped Message or CompositeField)

Types

type ContainerWithBitmap

type ContainerWithBitmap interface {
	Bitmap() *field.Bitmap
}

type FieldContainer

type FieldContainer interface {
	GetSubfields() map[string]field.Field
}

FieldContainer should be implemented by the type to be described we use GetSubfields() as a common method to get subfields while Message doesn't implement FieldContainer interface directly we use MessageWrapper to wrap Message and implement FieldContainer

type FieldFilter

type FieldFilter func(fieldFilters map[string]FilterFunc)

func FilterField

func FilterField(id string, filterFn FilterFunc) FieldFilter

type FilterFunc

type FilterFunc func(in string, data field.Field) string

type Message

type Message struct {
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage(spec *MessageSpec) *Message

func (*Message) BinaryField

func (m *Message) BinaryField(id int, val []byte) error

func (*Message) Bitmap

func (m *Message) Bitmap() *field.Bitmap

func (*Message) Clone

func (m *Message) Clone() (*Message, error)

Clone clones the message by creating a new message from the binary representation of the original message

func (*Message) Field

func (m *Message) Field(id int, val string) error

func (*Message) GetBytes

func (m *Message) GetBytes(id int) ([]byte, error)

func (*Message) GetField

func (m *Message) GetField(id int) field.Field

func (*Message) GetFields

func (m *Message) GetFields() map[int]field.Field

Fields returns the map of the set fields

func (*Message) GetMTI

func (m *Message) GetMTI() (string, error)

func (*Message) GetSpec

func (m *Message) GetSpec() *MessageSpec

func (*Message) GetString

func (m *Message) GetString(id int) (string, error)

func (*Message) MTI

func (m *Message) MTI(val string)

func (*Message) Marshal

func (m *Message) Marshal(v interface{}) error

Marshal populates message fields with v struct field values. It traverses through the message fields and calls Unmarshal(...) on them setting the v If v is not a struct or not a pointer to struct then it returns error.

func (*Message) MarshalJSON

func (m *Message) MarshalJSON() ([]byte, error)

func (*Message) Pack

func (m *Message) Pack() ([]byte, error)

func (*Message) SetData

func (m *Message) SetData(data interface{}) error

Deprecated. Use Marshal intead.

func (*Message) Unmarshal

func (m *Message) Unmarshal(v interface{}) error

Unmarshal populates v struct fields with message field values. It traverses through the message fields and calls Unmarshal(...) on them setting the v If v is nil or not a pointer it returns error.

func (*Message) UnmarshalJSON

func (m *Message) UnmarshalJSON(b []byte) error

func (*Message) Unpack

func (m *Message) Unpack(src []byte) error

type MessageSpec

type MessageSpec struct {
	Name   string
	Fields map[int]field.Field
}
var Spec87 *MessageSpec = &MessageSpec{
	Name: "ISO 8583 v1987 ASCII",
	Fields: map[int]field.Field{
		0: field.NewString(&field.Spec{
			Length:      4,
			Description: "Message Type Indicator",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		1: field.NewBitmap(&field.Spec{
			Length:      8,
			Description: "Bitmap",
			Enc:         encoding.BytesToASCIIHex,
			Pref:        prefix.Hex.Fixed,
		}),
		2: field.NewString(&field.Spec{
			Length:      19,
			Description: "Primary Account Number",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LL,
		}),
		3: field.NewNumeric(&field.Spec{
			Length:      6,
			Description: "Processing Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		4: field.NewString(&field.Spec{
			Length:      12,
			Description: "Transaction Amount",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
			Pad:         padding.Left('0'),
		}),
		5: field.NewString(&field.Spec{
			Length:      12,
			Description: "Settlement Amount",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
			Pad:         padding.Left('0'),
		}),
		6: field.NewString(&field.Spec{
			Length:      12,
			Description: "Billing Amount",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
			Pad:         padding.Left('0'),
		}),
		7: field.NewString(&field.Spec{
			Length:      10,
			Description: "Transmission Date & Time",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		8: field.NewString(&field.Spec{
			Length:      8,
			Description: "Billing Fee Amount",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		9: field.NewString(&field.Spec{
			Length:      8,
			Description: "Settlement Conversion Rate",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		10: field.NewString(&field.Spec{
			Length:      8,
			Description: "Cardholder Billing Conversion Rate",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		11: field.NewString(&field.Spec{
			Length:      6,
			Description: "Systems Trace Audit Number (STAN)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		12: field.NewString(&field.Spec{
			Length:      6,
			Description: "Local Transaction Time",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		13: field.NewString(&field.Spec{
			Length:      4,
			Description: "Local Transaction Date",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		14: field.NewString(&field.Spec{
			Length:      4,
			Description: "Expiration Date",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		15: field.NewString(&field.Spec{
			Length:      4,
			Description: "Settlement Date",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		16: field.NewString(&field.Spec{
			Length:      4,
			Description: "Currency Conversion Date",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		17: field.NewString(&field.Spec{
			Length:      4,
			Description: "Capture Date",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		18: field.NewString(&field.Spec{
			Length:      4,
			Description: "Merchant Type",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		19: field.NewString(&field.Spec{
			Length:      3,
			Description: "Acquiring Institution Country Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		20: field.NewString(&field.Spec{
			Length:      3,
			Description: "PAN Extended Country Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		21: field.NewString(&field.Spec{
			Length:      3,
			Description: "Forwarding Institution Country Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		22: field.NewString(&field.Spec{
			Length:      3,
			Description: "Point of Sale (POS) Entry Mode",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		23: field.NewString(&field.Spec{
			Length:      3,
			Description: "Card Sequence Number (CSN)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		24: field.NewString(&field.Spec{
			Length:      3,
			Description: "Function Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		25: field.NewString(&field.Spec{
			Length:      2,
			Description: "Point of Service Condition Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		26: field.NewString(&field.Spec{
			Length:      2,
			Description: "Point of Service PIN Capture Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		27: field.NewString(&field.Spec{
			Length:      1,
			Description: "Authorizing Identification Response Length",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		28: field.NewString(&field.Spec{
			Length:      9,
			Description: "Transaction Fee Amount",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		29: field.NewString(&field.Spec{
			Length:      9,
			Description: "Settlement Fee Amount",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		30: field.NewString(&field.Spec{
			Length:      9,
			Description: "Transaction Processing Fee Amount",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		31: field.NewString(&field.Spec{
			Length:      9,
			Description: "Settlement Processing Fee Amount",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		32: field.NewString(&field.Spec{
			Length:      11,
			Description: "Acquiring Institution Identification Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LL,
		}),
		33: field.NewString(&field.Spec{
			Length:      11,
			Description: "Forwarding Institution Identification Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LL,
		}),
		34: field.NewString(&field.Spec{
			Length:      28,
			Description: "Extended Primary Account Number",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LL,
		}),
		35: field.NewString(&field.Spec{
			Length:      37,
			Description: "Track 2 Data",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LL,
		}),
		36: field.NewString(&field.Spec{
			Length:      104,
			Description: "Track 3 Data",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		37: field.NewString(&field.Spec{
			Length:      12,
			Description: "Retrieval Reference Number",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		38: field.NewString(&field.Spec{
			Length:      6,
			Description: "Authorization Identification Response",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		39: field.NewString(&field.Spec{
			Length:      2,
			Description: "Response Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		40: field.NewString(&field.Spec{
			Length:      3,
			Description: "Service Restriction Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		41: field.NewString(&field.Spec{
			Length:      8,
			Description: "Card Acceptor Terminal Identification",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		42: field.NewString(&field.Spec{
			Length:      15,
			Description: "Card Acceptor Identification Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		43: field.NewString(&field.Spec{
			Length:      40,
			Description: "Card Acceptor Name/Location",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		44: field.NewString(&field.Spec{
			Length:      99,
			Description: "Additional Data",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LL,
		}),
		45: field.NewString(&field.Spec{
			Length:      76,
			Description: "Track 1 Data",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LL,
		}),
		46: field.NewString(&field.Spec{
			Length:      999,
			Description: "Additional data (ISO)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		47: field.NewString(&field.Spec{
			Length:      999,
			Description: "Additional data (National)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		48: field.NewString(&field.Spec{
			Length:      999,
			Description: "Additional data (Private)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		49: field.NewString(&field.Spec{
			Length:      3,
			Description: "Transaction Currency Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		50: field.NewString(&field.Spec{
			Length:      3,
			Description: "Settlement Currency Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		51: field.NewString(&field.Spec{
			Length:      3,
			Description: "Cardholder Billing Currency Code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		52: field.NewString(&field.Spec{
			Length:      8,
			Description: "PIN Data",
			Enc:         encoding.BytesToASCIIHex,
			Pref:        prefix.Hex.Fixed,
		}),
		53: field.NewString(&field.Spec{
			Length:      16,
			Description: "Security Related Control Information",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		54: field.NewString(&field.Spec{
			Length:      120,
			Description: "Additional Amounts",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		55: field.NewString(&field.Spec{
			Length:      999,
			Description: "ICC Data – EMV Having Multiple Tags",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		56: field.NewString(&field.Spec{
			Length:      999,
			Description: "Reserved (ISO)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		57: field.NewString(&field.Spec{
			Length:      999,
			Description: "Reserved (National)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		58: field.NewString(&field.Spec{
			Length:      999,
			Description: "Reserved (National)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		59: field.NewString(&field.Spec{
			Length:      999,
			Description: "Reserved (National)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		60: field.NewString(&field.Spec{
			Length:      999,
			Description: "Reserved (National)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		61: field.NewString(&field.Spec{
			Length:      999,
			Description: "Reserved (Private)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		62: field.NewString(&field.Spec{
			Length:      999,
			Description: "Reserved (Private)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		63: field.NewString(&field.Spec{
			Length:      999,
			Description: "Reserved (Private)",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.LLL,
		}),
		64: field.NewString(&field.Spec{
			Length:      8,
			Description: "Message Authentication Code (MAC)",
			Enc:         encoding.BytesToASCIIHex,
			Pref:        prefix.Hex.Fixed,
		}),
		70: field.NewString(&field.Spec{
			Length:      3,
			Description: "Network management information code",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
		90: field.NewString(&field.Spec{
			Length:      42,
			Description: "Original Data Elements",
			Enc:         encoding.ASCII,
			Pref:        prefix.ASCII.Fixed,
		}),
	},
}

keep it here for a little while for compatibility all new specs and updates to Spec87 should go to ./specs

func (*MessageSpec) CreateMessageFields

func (s *MessageSpec) CreateMessageFields() map[int]field.Field

Creates a map with new instances of Fields (Field interface) based on the field type in MessageSpec.

type MessageWrapper

type MessageWrapper struct {
	*Message
}

MessageWrapper implements FieldContainer interface for the iso8583.Message as currently it has GetFields() and not GetSubfields and it returns map[int]field.Field (key is int, not string)

func (*MessageWrapper) GetSubfields

func (m *MessageWrapper) GetSubfields() map[string]field.Field

type MesssageTypeIndicator

type MesssageTypeIndicator string

MesssageTypeIndicator message type indicator is a four-digit numeric field which indicates the overall function of the ISO 8583:1987 message

const (
	// AuthorizationRequest is a request from a point-of-sale terminal for authorization for a cardholder purchase
	AuthorizationRequest MesssageTypeIndicator = "0100"

	// AuthorizationResponse is a request response to a point-of-sale terminal for authorization for a cardholder purchase
	AuthorizationResponse MesssageTypeIndicator = "0110"

	// AuthorizationAdvice is when the point-of-sale device breaks down and you have to sign a voucher
	AuthorizationAdvice MesssageTypeIndicator = "0120"

	// AuthorizationAdviceRepeat used to repeat if the advice times out
	AuthorizationAdviceRepeat MesssageTypeIndicator = "0121"

	// IssuerResponseToAuthorizationAdvice is a confirmation of receipt of authorization advice
	IssuerResponseToAuthorizationAdvice MesssageTypeIndicator = "0130"

	// AuthorizationPositiveAcknowledgement indicates that an Authorization Response was received
	AuthorizationPositiveAcknowledgement MesssageTypeIndicator = "0180"

	// AuthorizationNegativeAcknowledgement indicates that an Authorization Response or Reversal Response was late or invalid
	AuthorizationNegativeAcknowledgement MesssageTypeIndicator = "0190"

	// AcquirerFinancialRequest is a request for funds, typically from an ATM or pinned point-of-sale device
	AcquirerFinancialRequest MesssageTypeIndicator = "0200"

	// IssuerResponseToFinancialRequest is a issuer response to request for funds
	IssuerResponseToFinancialRequest MesssageTypeIndicator = "0210"

	// AcquirerFinancialAdvice is used to complete transaction initiated with authorization request. e.g. Checkout at a hotel.
	AcquirerFinancialAdvice MesssageTypeIndicator = "0220"

	// AcquirerFinancialAdviceRepeat is used if the advice times out
	AcquirerFinancialAdviceRepeat MesssageTypeIndicator = "0221"

	// IssuerResponseToFinancialAdvice is a confirmation of receipt of financial advice
	IssuerResponseToFinancialAdvice MesssageTypeIndicator = "0230"

	// BatchUpload is a file update/transfer advice
	BatchUpload MesssageTypeIndicator = "0320"

	// BatchUploadResponse is a file update/transfer advice response
	BatchUploadResponse MesssageTypeIndicator = "0330"

	// AcquirerReversalRequest is used to reverse a transaction
	AcquirerReversalRequest MesssageTypeIndicator = "0400"

	// AcquirerReversalResponse is a response to a reversal request
	AcquirerReversalResponse MesssageTypeIndicator = "0410"

	// AcquirerReversalAdvice
	AcquirerReversalAdvice MesssageTypeIndicator = "0420"

	// AcquirerReversalAdviceResponse
	AcquirerReversalAdviceResponse MesssageTypeIndicator = "0430"

	// BatchSettlementResponse is a card acceptor reconciliation request response
	BatchSettlementResponse MesssageTypeIndicator = "0510"

	// AdministrativeRequest is a message delivering administrative data, often free-form and potentially indicating a failure message
	AdministrativeRequest MesssageTypeIndicator = "0600"

	// AdministrativeResponse is a response to an administrative request
	AdministrativeResponse MesssageTypeIndicator = "0610"

	// AdministrativeAdvice is an administrative request with stronger delivery guarantees
	AdministrativeAdvice MesssageTypeIndicator = "0620"

	// AdministrativeAdviceResponse is a response to an administrative advice
	AdministrativeAdviceResponse MesssageTypeIndicator = "0630"

	// NetworkManagementRequest is used in hypercom terminals initialize request. Echo test, logon, logoff etc
	NetworkManagementRequest MesssageTypeIndicator = "0800"

	// NetworkManagementResponse is a hypercom terminals initialize response. Echo test, logon, logoff etc.
	NetworkManagementResponse MesssageTypeIndicator = "0810"

	// NetworkManagementAdvice is a key change
	NetworkManagementAdvice MesssageTypeIndicator = "0820"
)

Directories

Path Synopsis
cmd
examples
exp
emv
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL