Coder Social home page Coder Social logo

iso_8583_elixir's Introduction

ISO8583

An ISO 8583 messaging library for Elixir. Supports message validation, encoding and decoding. See the docs

This project is still in early stages. If you have feature suggestions you can do two things.

  • Push a PR and I will be happy to review.
  • Suggest using new issue and I will be happy to implement.
iex> message
%{
  "0": "0800",
  "11": "646465",
  "12": "160244",
  "13": "0818",
  "7": "0818160244",
  "70": "001"
}
iex> {:ok, encoded} = ISO8583.encode(message)
{:ok,
 <<0, 49, 48, 56, 48, 48, 130, 56, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 48,
   56, 49, 56, 49, 54, 48, 50, 52, 52, 54, 52, 54, 52, 54, 53, 49, 54, 48, 50,
   52, 52, 48, 56, 49, 56, ...>>}
iex> {:ok, decoded} = ISO8583.decode(encoded)
{:ok,
 %{
   "0": "0800",
   "11": "646465",
   "12": "160244",
   "13": "0818",
   "7": "0818160244",
   "70": "001"
 }}
iex>

Installation

def deps do
  [
    {:iso_8583, "~> 0.1.2"}
  ]
end

Customization and configuration

All exposed API functions take options with the following configurable options.

TCP Length Indicator

This is used to specify whether or not to include the 2 byte hexadecimal encoded byte length of the whole message whe encoding or to consider it when decoding. This value is set to true by default. Example:

ISO8583.encode(message, tcp_len_header: false)

Bitmap encoding

Primary and SecondaryBitmap encoding bitmap for fields 0-127 is configurable like below.

Examples:

ISO8583.encode(bitmap_encoding: :ascii) # will result in 32 byte length bitmap
ISO8583.encode() # will default to :hex result in 16 byte length bitmap

Custom formats

Custom formats for data type, data length and length type for all fields including special bitmaps like for 127.1 and 127.25.1 are configurable through custom formats. The default formats will be replaced by the custom one.

To see the default formats check here

Example:

Here we override field 2 to have maximum of 30 characters.

custome_format = %{
      "2": %{
        content_type: "n",
        label: "Primary account number (PAN)",
        len_type: "llvar",
        max_len: 30,
        min_len: 1
      }
    }

    {:ok, message} =
      fixture_message(:"0100")
      |> Map.put(:"2", "444466668888888888888888")
      |> ISO8583.encode(formats: custome_format)

    refute message |> ISO8583.valid?()
  end

Roadmap

  • Optimizations
  • More customizations
  • Message composition
  • Support for compsable validators.
  • More tests.

iso_8583_elixir's People

Contributors

zemuldo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.