Skip to content
/ ISO8583 Public

Swift package for iOS/macOS/Linux that helps to create and parse ISO8583 financial transaction messages

License

Notifications You must be signed in to change notification settings

ifau/ISO8583

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ISO8583

Swift package for iOS/macOS/Linux that helps to create and parse ISO8583 financial transaction messages.

Installation

Swift Package Manager

Add dependency to your Package.swift

dependencies: [
    .package(url: "https://github.com/ifau/ISO8583.git")
]

Or with Xcode 11 and above FileSwift PackagesAdd Package Dependency...

Usage

Define your custom processing scheme by adopting the ISOScheme protocol

class CustomProcessingScheme: ISOScheme {
    
    func numberOfBytesForLength() -> UInt {
        return 2
    }
    
    func lengthFormat() -> ISONumberFormat {
        return .bcd
    }
    
    func mtiFormat() -> ISONumberFormat {
        return .bcd
    }
    
    func fieldFormat(for fieldNumber: UInt) -> ISOFieldFormat {
        switch fieldNumber {
        case 3:
            return .numeric(length: 6)                          // Processing code
        case 24:
            return .numeric(length: 3)                          // Function code
        case 35:
            return .llvar(lengthFormat: .bcd, valueFormat:[.z]) // Track 2
        case 38:
            return .alpha(length: 6, valueFormat:[.a, .n, .p])  // Approval Code
        case 39:
            return .numeric(length: 3)                          // Response code
        case 64:
            return .binary(length: 8)                           // Message authentication code
        default:
            return .undefined
        }
    }
}

Then you can decode any binary message into the ISOMessage object

let message = try? ISOMessage(data: data, using: CustomProcessingScheme())

Or encode the ISOMessage object into a binary message

let message = ISOMessage(mti: 200, fields: [3:"000000", 24:"200", 35:"4000010000000001=991233000123410000"])
let data = try? message.data(using: CustomProcessingScheme())

A complete example is available here.

About

Swift package for iOS/macOS/Linux that helps to create and parse ISO8583 financial transaction messages

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages