Git Product home page Git Product logo

jspos's Introduction

jsPOS

JavaScript ISO8583. JavaScript version of JPOS.

Installation

npm install jspos --save

Custom packager

    import { ISOBasePackager, packer } from 'jspos';

    let { IFB_NUMERIC, IFB_BITMAP, IFB_LLNUM, IFB_LLLNUM, IF_CHAR, IFB_LLCHAR, IFB_LLLCHAR, IFB_BINARY, IFB_LLBINARY, IFB_LLLBINARY, IFB_AMOUNT } = packer;
    const pad = false;
    let fld = [
        /*000*/ new IFB_NUMERIC(4, "Message Type Indicator", true),
        /*001*/ new IFB_BITMAP(8, "Bitmap"),
        /*002*/ new IFB_LLNUM(19, "Primary Account number", pad),
        /*003*/ new IFB_NUMERIC(6, "Processing Code", pad),
        /*004*/ new IFB_NUMERIC(12, "Amount, Transaction", pad),
        /*005*/ new IFB_NUMERIC(12, "Amount, Reconciliation", pad),
        /*006*/ new IFB_NUMERIC(12, "Amount, Cardholder billing", pad),
        /*007*/ new IFB_NUMERIC(10, "Date and time, transmission", pad),
        /*008*/ new IFB_NUMERIC(8, "Amount, Cardholder billing fee", pad)
    ];

    class MyPackager extends ISOBasePackager{
         constructor() {
            super();
              this.setFieldPackager(fld);
         }
    }

    export default new MyPackager();

Examples

import Packager from './MyPackager';
import { ISOUtil, ISOMsg } from 'jspos';


let msg:ISOMsg = Packager.createISOMsg();

msg.setMTI('0800');
msg.setField(11, '000105');
msg.setField(41, '00000764');
msg.setField(42, '111000001111002');
msg.setField(60, '00000001003');
msg.setField(63, '001');
console.log(ISOUtil.hexString(msg.pack()));

let msgStr = '08000020000000C00012000105303030303037363431313130303030303131313130303200110000000100300003303031';
let unpackMsg:ISOMsg = Packager.createISOMsg();
unpackMsg.unpack(ISOUtil.hex2byte(msgStr));
console.log(ISOUtil.hexString(unpackMsg.pack()));

run test.

npm install -g babel-cli
npm install
npm test

jspos's People

Contributors

sean-snow avatar bruno-camargos avatar gamaroff avatar

Watchers

James Cloos avatar  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.