Documentation ¶
Index ¶
- Variables
- func Arr[T any](v T) []*T
- func NewParseError(err error, msg string) error
- func NewValidationError(err error) error
- func Ptr[T any](v T) *T
- type BaseTxn
- type BaseTxnOpt
- type Credit
- func (c Credit) Build() (string, error)
- func (c Credit) GetAccountNo() string
- func (c Credit) GetAmount() int64
- func (c Credit) GetBaseTxn() BaseTxn
- func (c Credit) GetDate() *time.Time
- func (c Credit) GetName() string
- func (c Credit) GetOriginalAccountNo() string
- func (c Credit) GetOriginalInstitutionID() string
- func (c Credit) GetOriginalItemTraceNo() string
- func (c Credit) GetReturnAccountNo() string
- func (c Credit) GetReturnInstitutionID() string
- func (c Credit) GetType() RecordType
- func (c *Credit) Parse(data string) error
- func (c Credit) Validate() error
- type CreditReturn
- func (c CreditReturn) Build() (string, error)
- func (c CreditReturn) GetAccountNo() string
- func (c CreditReturn) GetAmount() int64
- func (c CreditReturn) GetBaseTxn() BaseTxn
- func (c CreditReturn) GetDate() *time.Time
- func (c CreditReturn) GetName() string
- func (c CreditReturn) GetOriginalAccountNo() string
- func (c CreditReturn) GetOriginalInstitutionID() string
- func (c CreditReturn) GetOriginalItemTraceNo() string
- func (c CreditReturn) GetReturnAccountNo() string
- func (c CreditReturn) GetReturnInstitutionID() string
- func (c CreditReturn) GetType() RecordType
- func (c *CreditReturn) Parse(data string) error
- func (c CreditReturn) Validate() error
- type CreditReverse
- func (c CreditReverse) Build() (string, error)
- func (c CreditReverse) GetAccountNo() string
- func (c CreditReverse) GetAmount() int64
- func (c CreditReverse) GetBaseTxn() BaseTxn
- func (c CreditReverse) GetDate() *time.Time
- func (c CreditReverse) GetName() string
- func (c CreditReverse) GetOriginalAccountNo() string
- func (c CreditReverse) GetOriginalInstitutionID() string
- func (c CreditReverse) GetOriginalItemTraceNo() string
- func (c CreditReverse) GetReturnAccountNo() string
- func (c CreditReverse) GetReturnInstitutionID() string
- func (c CreditReverse) GetType() RecordType
- func (c *CreditReverse) Parse(data string) error
- func (c CreditReverse) Validate() error
- type DCSign
- type Debit
- func (d Debit) Build() (string, error)
- func (d Debit) GetAccountNo() string
- func (d Debit) GetAmount() int64
- func (d Debit) GetBaseTxn() BaseTxn
- func (d Debit) GetDate() *time.Time
- func (d Debit) GetName() string
- func (d Debit) GetOriginalAccountNo() string
- func (d Debit) GetOriginalInstitutionID() string
- func (d Debit) GetOriginalItemTraceNo() string
- func (d Debit) GetReturnAccountNo() string
- func (d Debit) GetReturnInstitutionID() string
- func (d Debit) GetType() RecordType
- func (d *Debit) Parse(data string) error
- func (d Debit) Validate() error
- type DebitReturn
- func (d DebitReturn) Build() (string, error)
- func (dr DebitReturn) GetAccountNo() string
- func (d DebitReturn) GetAmount() int64
- func (dr DebitReturn) GetBaseTxn() BaseTxn
- func (dr DebitReturn) GetDate() *time.Time
- func (dr DebitReturn) GetName() string
- func (dr DebitReturn) GetOriginalAccountNo() string
- func (dr DebitReturn) GetOriginalInstitutionID() string
- func (dr DebitReturn) GetOriginalItemTraceNo() string
- func (dr DebitReturn) GetReturnAccountNo() string
- func (dr DebitReturn) GetReturnInstitutionID() string
- func (d DebitReturn) GetType() RecordType
- func (d *DebitReturn) Parse(data string) error
- func (d DebitReturn) Validate() error
- type DebitReverse
- func (d DebitReverse) Build() (string, error)
- func (d DebitReverse) GetAccountNo() string
- func (d DebitReverse) GetAmount() int64
- func (d DebitReverse) GetBaseTxn() BaseTxn
- func (c DebitReverse) GetDate() *time.Time
- func (d DebitReverse) GetName() string
- func (d DebitReverse) GetOriginalAccountNo() string
- func (d DebitReverse) GetOriginalInstitutionID() string
- func (d DebitReverse) GetOriginalItemTraceNo() string
- func (d DebitReverse) GetReturnAccountNo() string
- func (d DebitReverse) GetReturnInstitutionID() string
- func (d DebitReverse) GetType() RecordType
- func (d *DebitReverse) Parse(data string) error
- func (d DebitReverse) Validate() error
- type File
- type FileFooter
- type FileHeader
- type FileStreamer
- type HeaderOpts
- type ParseError
- type Reader
- type RecordHeader
- type RecordType
- type Transaction
- type TransactionType
- type Transactions
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ( // parse errors ErrInvalidRecordLength = fmt.Errorf("transaction record is not 240 characters") // Validation errors ErrMissingOriginatorId = fmt.Errorf("missing originator ID") ErrMissingCreationDate = fmt.Errorf("missing creation date") ErrInvalidRecordType = fmt.Errorf("invalid record type") ErrInvalidCurrencyCode = fmt.Errorf("invalid currency code") ErrInvalidOriginatorIdLength = fmt.Errorf("invalid originator ID length") ErrInvalidOriginatorId = fmt.Errorf("invalid originator ID not alpha numeric") ErrInvalidFileCreationNum = fmt.Errorf("invalid file creation number") ErrInvalidDestinationDataCenterNo = fmt.Errorf("invalid destination data center") ErrInvalidDirectClearerCommunicationArea = fmt.Errorf("invalid direct clearer communication area") ErrScanParseError = fmt.Errorf("failed to parse txn") )
Functions ¶
func NewParseError ¶
func NewValidationError ¶
Types ¶
type BaseTxn ¶
type BaseTxn struct { TxnType TransactionType `json:"txn_type" validate:"required,numeric,max=3"` Amount int64 `json:"amount" validate:"required,max=9999999999"` ItemTraceNo string `json:"item_trace_no" validate:"eft_num,max=22"` InstitutionID string `json:"institution_id" validate:"required,eft_num,max=9"` StoredTransactionType TransactionType `json:"stored_txn_type" validate:"eft_num,max=3"` OriginatorShortName string `json:"short_name" validate:"max=15"` OriginatorLongName string `json:"long_name" validate:"required,max=30"` UserID string `json:"user_id" validate:"eft_alpha,max=10"` CrossRefNo string `json:"cross_ref_no" validate:"eft_alpha,max=19"` SundryInfo string `json:"sundry_info" validate:"eft_alpha,max=15"` SettlementCode string `json:"settlement_code" validate:"eft_alpha,max=2"` InvalidDataElementID string `json:"invalid_data_element_id" validate:"eft_num,max=11"` RecordType RecordType `json:"type" validate:"rec_type"` }
BaseTxn represents the common fields of every Transaction record D, C, E, F, I and J
type BaseTxnOpt ¶
type BaseTxnOpt func(d *BaseTxn)
func WithCrossRefNo ¶
func WithCrossRefNo(s string) BaseTxnOpt
WithCrossRefNo sets the Originator'sCross Reference No. field 15
func WithInvalidDataElementID ¶
func WithInvalidDataElementID(s string) BaseTxnOpt
WithInvalidDataElementID sets the Invalid Data Element No. field 21 mainly used for returns to indicate which fields are incorrect
func WithSettlementCode ¶
func WithSettlementCode(s string) BaseTxnOpt
WithSettlementCode sets the Originator-Direct Clearer Settlement Code, field 20
func WithStoredTransactionType ¶
func WithStoredTransactionType(s string) BaseTxnOpt
WithStoredTransactionType sets the Stored Transaction Type, field 10 mainly used for returns and reversals (J, I, E and F records)
func WithSundryInfo ¶
func WithSundryInfo(s string) BaseTxnOpt
WithSundryInfo sets the Originator's Sundry Information, field 18
func WithUserID ¶
func WithUserID(s string) BaseTxnOpt
WithUserID sets the Originating DirectClearer's User's ID, field 14
type Credit ¶
type Credit struct { BaseTxn DateFundsAvailable *time.Time `json:"date_funds_available" validate:"required"` PayeeAccountNo string `json:"payee_account_no" validate:"required,max=12,numeric"` PayeeName string `json:"payee_name" validate:"required,max=30"` ReturnInstitutionID string `json:"return_institution_id" validate:"required,max=9,numeric"` ReturnAccountNo string `json:"return_account_no" validate:"required,max=12,eft_alpha"` }
Credit represents Logical Record Type C according to the EFT standard 005
func NewCredit ¶
func NewCredit( txnType TransactionType, amount int64, dateFundsAvailable *time.Time, institutionID string, payeeAccountNo string, itemTraceNo string, originatorShortName string, payeeName string, originatorLongName string, returnInstitutionID string, returnAccountNo string, opts ...BaseTxnOpt, ) Credit
func (Credit) Build ¶
Build serializes a Credit into a 240 length string that adheres to the EFT standard 005 standard. Numeric fields are padded with zeros to the left and alphanumeric fields are padded with spaces to the right any missing fields are filled with 0's or blanks
func (Credit) GetAccountNo ¶
func (Credit) GetBaseTxn ¶
func (Credit) GetOriginalAccountNo ¶
func (Credit) GetOriginalInstitutionID ¶
func (Credit) GetOriginalItemTraceNo ¶
func (Credit) GetReturnAccountNo ¶
func (Credit) GetReturnInstitutionID ¶
func (Credit) GetType ¶
func (c Credit) GetType() RecordType
type CreditReturn ¶
type CreditReturn struct { BaseTxn DateFundsAvailable *time.Time `json:"date_funds_available" validate:"required"` PayeeAccountNo string `json:"payee_account_no" validate:"required,max=12,numeric"` PayeeName string `json:"payee_name" validate:"required,max=30"` OriginalInstitutionID string `json:"original_institution_id" validate:"required,max=9,numeric"` OriginalAccountNo string `json:"original_account_no" validate:"required,max=12,eft_alpha"` OriginalItemTraceNo string `json:"original_item_trace_no" validate:"required,eft_num,max=22"` }
CreditReturn represents Logical Record Type I according to the EFT standard 005
func NewCreditReturn ¶
func NewCreditReturn( txnType TransactionType, amount int64, dateFundsAvailable *time.Time, institutionID string, payeeAccountNo string, itemTraceNo string, originatorShortName string, payeeName string, originatorLongName string, originalInstitutionID string, originalAccountNo string, originalItemTraceNo string, opts ...BaseTxnOpt) CreditReturn
func (CreditReturn) Build ¶
func (c CreditReturn) Build() (string, error)
Build serializes a CreditReturn into a 240 length string that adheres to the EFT standard 005 standard. Numeric fields are padded with zeros to the left and alphanumeric fields are padded with spaces to the right any missing fields are filled with 0's or blanks
func (CreditReturn) GetAccountNo ¶
func (c CreditReturn) GetAccountNo() string
func (CreditReturn) GetAmount ¶
func (c CreditReturn) GetAmount() int64
func (CreditReturn) GetBaseTxn ¶
func (c CreditReturn) GetBaseTxn() BaseTxn
func (CreditReturn) GetDate ¶
func (c CreditReturn) GetDate() *time.Time
func (CreditReturn) GetName ¶
func (c CreditReturn) GetName() string
func (CreditReturn) GetOriginalAccountNo ¶
func (c CreditReturn) GetOriginalAccountNo() string
func (CreditReturn) GetOriginalInstitutionID ¶
func (c CreditReturn) GetOriginalInstitutionID() string
func (CreditReturn) GetOriginalItemTraceNo ¶
func (c CreditReturn) GetOriginalItemTraceNo() string
func (CreditReturn) GetReturnAccountNo ¶
func (c CreditReturn) GetReturnAccountNo() string
func (CreditReturn) GetReturnInstitutionID ¶
func (c CreditReturn) GetReturnInstitutionID() string
func (CreditReturn) GetType ¶
func (c CreditReturn) GetType() RecordType
func (*CreditReturn) Parse ¶
func (c *CreditReturn) Parse(data string) error
Parse takes in a serialized transaction segment and populates a CreditReturn struct containing the relevant data. The data passed in should be of length 240, the transaction length associated with the EFT file spec.
func (CreditReturn) Validate ¶
func (c CreditReturn) Validate() error
Validate checks whether the fields of a CreditReturn struct contain the correct fields that are required when writing/reading an EFT file. The validation check can be found on Section D of EFT standard 005.
type CreditReverse ¶
type CreditReverse struct { BaseTxn DateFundsAvailable *time.Time `json:"date_funds_available" validate:"required"` PayeeAccountNo string `json:"payee_account_no" validate:"required,max=12,numeric"` PayeeName string `json:"payee_name" validate:"required,max=30"` ReturnInstitutionID string `json:"return_institution_id" validate:"required,max=9,numeric"` ReturnAccountNo string `json:"return_account_no" validate:"required,max=12,eft_alpha"` OriginalItemTraceNo string `json:"original_item_trace_no" validate:"required,eft_num,max=22"` }
CreditReverse represents Logical Record Type E according to the EFT standard 005
func NewCreditReverse ¶
func NewCreditReverse( txnType TransactionType, amount int64, dateFundsAvailable *time.Time, institutionID string, payeeAccountNo string, itemTraceNo string, originatorShortName string, payeeName string, originatorLongName string, returnInstitutionID string, returnAccountNo string, originalItemTraceNo string, opts ...BaseTxnOpt) CreditReverse
func (CreditReverse) Build ¶
func (c CreditReverse) Build() (string, error)
Build serializes a CreditReverse into a 240 length string that adheres to the EFT standard 005 standard. Numeric fields are padded with zeros to the left and alphanumeric fields are padded with spaces to the right any missing fields are filled with 0's or blanks
func (CreditReverse) GetAccountNo ¶
func (c CreditReverse) GetAccountNo() string
func (CreditReverse) GetAmount ¶
func (c CreditReverse) GetAmount() int64
func (CreditReverse) GetBaseTxn ¶
func (c CreditReverse) GetBaseTxn() BaseTxn
func (CreditReverse) GetDate ¶
func (c CreditReverse) GetDate() *time.Time
func (CreditReverse) GetName ¶
func (c CreditReverse) GetName() string
func (CreditReverse) GetOriginalAccountNo ¶
func (c CreditReverse) GetOriginalAccountNo() string
func (CreditReverse) GetOriginalInstitutionID ¶
func (c CreditReverse) GetOriginalInstitutionID() string
func (CreditReverse) GetOriginalItemTraceNo ¶
func (c CreditReverse) GetOriginalItemTraceNo() string
func (CreditReverse) GetReturnAccountNo ¶
func (c CreditReverse) GetReturnAccountNo() string
func (CreditReverse) GetReturnInstitutionID ¶
func (c CreditReverse) GetReturnInstitutionID() string
func (CreditReverse) GetType ¶
func (c CreditReverse) GetType() RecordType
func (*CreditReverse) Parse ¶
func (c *CreditReverse) Parse(data string) error
Parse takes in a serialized transaction segment and populates a CreditReverse struct containing the relevant data. The data passed in should be of length 240, the transaction length associated with the EFT file spec.
func (CreditReverse) Validate ¶
func (c CreditReverse) Validate() error
type Debit ¶
type Debit struct { BaseTxn DueDate *time.Time `json:"due_date" validate:"required"` PayorAccountNo string `json:"payor_account_no" validate:"required,max=12,numeric"` PayorName string `json:"payor_name" validate:"required,max=30"` ReturnInstitutionID string `json:"return_institution_id" validate:"required,max=9,numeric"` ReturnAccountNo string `json:"return_account_no" validate:"required,max=12,eft_alpha"` }
Debit represents Logical Record Type D according to the EFT standard 005
func (Debit) Build ¶
Build serializes a Debit into a 240 length string that adheres to the EFT standard 005 standard. Numeric fields are padded with zeros to the left and alphanumeric fields are padded with spaces to the right any missing fields are filled with 0's or blanks
func (Debit) GetAccountNo ¶
func (Debit) GetBaseTxn ¶
func (Debit) GetOriginalAccountNo ¶
func (Debit) GetOriginalInstitutionID ¶
func (Debit) GetOriginalItemTraceNo ¶
func (Debit) GetReturnAccountNo ¶
func (Debit) GetReturnInstitutionID ¶
func (Debit) GetType ¶
func (d Debit) GetType() RecordType
type DebitReturn ¶
type DebitReturn struct { BaseTxn DueDate *time.Time `json:"due_date" validate:"required"` PayorAccountNo string `json:"payor_account_no" validate:"required,max=12,numeric"` PayorName string `json:"payor_name" validate:"required,max=30"` OriginalInstitutionID string `json:"original_institution_id" validate:"required,max=9,numeric"` OriginalAccountNo string `json:"original_account_no" validate:"required,max=12,eft_alpha"` OriginalItemTraceNo string `json:"original_item_trace_no" validate:"required,eft_num,max=22"` }
DebitReturn represents Logical Record Type J according to the EFT standard 005
func NewDebitReturn ¶
func NewDebitReturn( txnType TransactionType, amount int64, dueDate *time.Time, institutionID string, payorAccountNo string, itemTraceNo string, originatorShortName string, payorName string, originatorLongName string, originalInstitutionID string, originalAccountNo string, originalItemTraceNo string, opts ...BaseTxnOpt, ) DebitReturn
func (DebitReturn) Build ¶
func (d DebitReturn) Build() (string, error)
Build serializes a DebitReturn into a 240 length string that adheres to the EFT standard 005 standard. Numeric fields are padded with zeros to the left and alphanumeric fields are padded with spaces to the right any missing fields are filled with 0's or blanks
func (DebitReturn) GetAccountNo ¶
func (dr DebitReturn) GetAccountNo() string
func (DebitReturn) GetAmount ¶
func (d DebitReturn) GetAmount() int64
func (DebitReturn) GetBaseTxn ¶
func (dr DebitReturn) GetBaseTxn() BaseTxn
func (DebitReturn) GetDate ¶
func (dr DebitReturn) GetDate() *time.Time
func (DebitReturn) GetName ¶
func (dr DebitReturn) GetName() string
func (DebitReturn) GetOriginalAccountNo ¶
func (dr DebitReturn) GetOriginalAccountNo() string
func (DebitReturn) GetOriginalInstitutionID ¶
func (dr DebitReturn) GetOriginalInstitutionID() string
func (DebitReturn) GetOriginalItemTraceNo ¶
func (dr DebitReturn) GetOriginalItemTraceNo() string
func (DebitReturn) GetReturnAccountNo ¶
func (dr DebitReturn) GetReturnAccountNo() string
func (DebitReturn) GetReturnInstitutionID ¶
func (dr DebitReturn) GetReturnInstitutionID() string
func (DebitReturn) GetType ¶
func (d DebitReturn) GetType() RecordType
func (*DebitReturn) Parse ¶
func (d *DebitReturn) Parse(data string) error
Parse takes in a serialized transaction segment and populates a DebitReturn struct containing the relevant data. The data passed in should be of length 240, the transaction length associated with the EFT file spec.
func (DebitReturn) Validate ¶
func (d DebitReturn) Validate() error
Validate checks whether the fields of a DebitReturn struct contain the correct fields that are required when writing/reading an EFT file. The validation check can be found on Section D of EFT standard 005.
type DebitReverse ¶
type DebitReverse struct { BaseTxn DueDate *time.Time `json:"due_date" validate:"required"` PayorAccountNo string `json:"payor_account_no" validate:"required,max=12,numeric"` PayorName string `json:"payor_name" validate:"required,max=30"` ReturnInstitutionID string `json:"return_institution_id" validate:"required,max=9,numeric"` ReturnAccountNo string `json:"return_account_no" validate:"required,max=12,eft_alpha"` OriginalItemTraceNo string `json:"original_item_trace_no" validate:"required,eft_num,max=22"` }
DebitReverse represents Logical Record Type F according to the EFT standard 005
func NewDebitReverse ¶
func NewDebitReverse( txnType TransactionType, amount int64, dueDate *time.Time, institutionID string, payorAccountNo string, itemTraceNo string, originatorShortName string, payorName string, originatorLongName string, returnInstitutionID string, returnAccountNo string, originalItemTraceNo string, opts ...BaseTxnOpt, ) DebitReverse
func (DebitReverse) Build ¶
func (d DebitReverse) Build() (string, error)
Build serializes a DebitReverse into a 240 length string that adheres to the EFT standard 005 standard. Numeric fields are padded with zeros to the left and alphanumeric fields are padded with spaces to the right any missing fields are filled with 0's or blanks
func (DebitReverse) GetAccountNo ¶
func (d DebitReverse) GetAccountNo() string
func (DebitReverse) GetAmount ¶
func (d DebitReverse) GetAmount() int64
func (DebitReverse) GetBaseTxn ¶
func (d DebitReverse) GetBaseTxn() BaseTxn
func (DebitReverse) GetDate ¶
func (c DebitReverse) GetDate() *time.Time
func (DebitReverse) GetName ¶
func (d DebitReverse) GetName() string
func (DebitReverse) GetOriginalAccountNo ¶
func (d DebitReverse) GetOriginalAccountNo() string
func (DebitReverse) GetOriginalInstitutionID ¶
func (d DebitReverse) GetOriginalInstitutionID() string
func (DebitReverse) GetOriginalItemTraceNo ¶
func (d DebitReverse) GetOriginalItemTraceNo() string
func (DebitReverse) GetReturnAccountNo ¶
func (d DebitReverse) GetReturnAccountNo() string
func (DebitReverse) GetReturnInstitutionID ¶
func (d DebitReverse) GetReturnInstitutionID() string
func (DebitReverse) GetType ¶
func (d DebitReverse) GetType() RecordType
func (*DebitReverse) Parse ¶
func (d *DebitReverse) Parse(data string) error
Parse takes in a serialized transaction segment and populates a DebitReverse struct containing the relevant data. The data passed in should be of length 240, the transaction length associated with the EFT file spec.
func (DebitReverse) Validate ¶
func (d DebitReverse) Validate() error
type File ¶
type File struct { Header *FileHeader `json:"file_header,omitempty"` Txns Transactions `json:"transactions,omitempty"` }
func NewFile ¶
func NewFile(header *FileHeader, txns []Transaction) File
func (*File) Create ¶
Create returns a serialized EFT file as a string or an error. The serialized file will adhere to the EFT 005 payments canada specification but depending on individual fields the file may be rejected. Use the Validate function to catch any validation errors. Make sure to add the appropriate FileHeader and Transactions via NewFile before calling Create.
func (File) GetAllCreditReturns ¶
func (f File) GetAllCreditReturns() []CreditReturn
Returns all credit return transactions or I records
func (File) GetAllCredits ¶
Returns all credit transactions or C records
func (File) GetAllDebitReturns ¶
func (f File) GetAllDebitReturns() []DebitReturn
Returns all debit return transactions or J records
func (File) GetAllDebitTxns ¶
Returns all debit transactions or D records
type FileFooter ¶
type FileFooter struct {}
FileFooter represents either Logical Record Type Z or V in the EFT 005 standard spec. FileFooter fields are populated from the Transaction entries and their counts and values. When building a file unless you really need to add a custom FileFooter allow the library to generate it for you via File.Create()
func NewFileFooter ¶
func NewFileFooter(recordHeader RecordHeader, txns []Transaction) *FileFooter
func (FileFooter) Build ¶
func (ff FileFooter) Build() (string, error)
Build takes the FileFooter struct, constructs a serialized string and returns it for writing
func (FileFooter) GetType ¶
func (ff FileFooter) GetType() RecordType
func (*FileFooter) Parse ¶
func (ff *FileFooter) Parse(line string) error
Parse will take in a serialized footer record of type Z and parse the amounts into a FileFooter struct
type FileHeader ¶
type FileHeader struct { RecordHeader CreationDate *time.Time `json:"creation_date" validate:"required"` DestinationDataCenterNo int64 `json:"destination_data_center" validate:"min=0,max=99999,numeric"` DirectClearerCommunicationArea string `json:"communication_area" validate:"max=20"` CurrencyCode string `json:"currency_code" validate:"required,eft_cur,len=3"` }
FileHeader represents Logical Record Type A in the EFT 005 spec. Every EFT file should have a header entry which contains information about the originator, currency and creation dates. the supported currency should be CAD or USD.
func NewFileHeader ¶
func NewFileHeader( originatorId string, fileCreationNum int64, creationDate *time.Time, destinationDataCenterNo int64, currencyCode string, opts ...HeaderOpts) *FileHeader
func (FileHeader) Validate ¶
func (fh FileHeader) Validate() error
Validate checks whether the fields of a FileHeader struct contain the correct fields that are required when writing/reading an EFT file. The validation check can be found on Section D of EFT standard 005.
type FileStreamer ¶
type FileStreamer struct {
// contains filtered or unexported fields
}
FileStreamer is used for stream parsing an EFT file. Instead of reading the whole file FileStreamer attempts to read segments of transactions line by line. The caller is responsible for handling/ignoring any errors that are encountered. FileStreamer stores the state of the parser and hence is not safe for concurrency usage. Main usage is via ScanTxn which attempts to parse a segment of the file, return a Transaction or an error and move the file pointer along.
func NewFileStream ¶
func NewFileStream(in io.ReadSeeker) FileStreamer
func (FileStreamer) GetFooter ¶
func (fs FileStreamer) GetFooter() (*FileFooter, error)
GetFooter attempts to seek to the end of the file in search of a Z record. If no footer record is found an error is returned. Once scanning is complete the file pointer is reset to the beginning of the file.
func (FileStreamer) GetHeader ¶
func (fs FileStreamer) GetHeader() (*FileHeader, error)
GetHeader scans the file for a A record and attempts to parse the record and return a FileHeader, an error is returned if parsing fails. the file pointer is then reset to the beginning of the file.
func (*FileStreamer) ScanTxn ¶
func (fs *FileStreamer) ScanTxn() (Transaction, error)
ScanTxn parses transaction records (D, C, I, J, E and F logical records) one at a time. Upon successfully parsing a transaction segment a Transaction struct is returned otherwise a non nil error is returned in both cases the file pointer is moved to the next transaction in the file. When parsing is complete (ether file has ended or a footer record is encountered) an io.EOF error is returned, the caller can use this to terminate parsing of the file. If ScanTxn returns an instance of ScanParseError the error can be ignored by the caller. ScanTxn() will return EOF if a Footer record is encountered or if a line is empty
type HeaderOpts ¶
type HeaderOpts func(*FileHeader)
func WithDirectClearerCommunicationArea ¶
func WithDirectClearerCommunicationArea(comm string) HeaderOpts
This option will add an optional direct clearer communication area field to the header
type ParseError ¶
func (*ParseError) Error ¶
func (p *ParseError) Error() string
func (*ParseError) UnWrap ¶
func (p *ParseError) UnWrap() error
type Reader ¶
type Reader struct { File File // contains filtered or unexported fields }
func (*Reader) ReadFile ¶
ReadFile will attempt to read the whole EFT file according to the 005 spec from payments canada. If no errors are encountered a populated File object is returned that contains the Header, Transactions and Footer. Use the FileStreamer object to be able ignore errors and proceed parsing the file.
type RecordHeader ¶
type RecordHeader struct { RecordType RecordType `json:"type" validate:"rec_type"` OriginatorID string `json:"originator_id" validate:"required,eft_alpha,len=10"` FileCreationNum int64 `json:"file_creation_number" validate:"required,max=9999"` // contains filtered or unexported fields }
RecordHeader represnts the common field that begins every Transaction line in an EFT file. The contents of this field are the RecordTpye the row count and originator id. This field is mostly internal and used for writing the file.
type RecordType ¶
type RecordType string
const ( HeaderRecord RecordType = "A" CreditRecord RecordType = "C" DebitRecord RecordType = "D" CreditReverseRecord RecordType = "E" DebitReverseRecord RecordType = "F" ReturnCreditRecord RecordType = "I" ReturnDebitRecord RecordType = "J" NoticeOfChangeRecord RecordType = "S" NoticeOfChangeHeader RecordType = "U" )
type Transaction ¶
type Transaction interface { Parse(string) error Build() (string, error) Validate() error GetType() RecordType GetAmount() int64 GetBaseTxn() BaseTxn GetAccountNo() string GetDate() *time.Time GetName() string GetReturnInstitutionID() string GetReturnAccountNo() string GetOriginalInstitutionID() string GetOriginalAccountNo() string GetOriginalItemTraceNo() string }
func NewTransaction ¶
func NewTransaction( recordType RecordType, txnType TransactionType, amount int64, date *time.Time, institutionID string, payorPayeeAccountNo string, itemTraceNo string, originatorShortName string, payorPayeeName string, originatorLongName string, originalOrReturnInstitutionID string, originalOrReturnAccountNo string, originalItemTraceNo string, opts ...BaseTxnOpt, ) Transaction
type TransactionType ¶
type TransactionType string
type Transactions ¶
type Transactions []Transaction
func (*Transactions) UnmarshalJSON ¶
func (f *Transactions) UnmarshalJSON(data []byte) error
type ValidationError ¶
type ValidationError struct {
Err error
}
func (*ValidationError) Error ¶
func (v *ValidationError) Error() string
func (*ValidationError) UnWrap ¶
func (v *ValidationError) UnWrap() error