zumm / posterminal

module to interact with sb_pilot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation

Install using yarn:

yarn add https://github.com/zumm/posterminal

Or npm:

npm install https://github.com/zumm/posterminal

Testing

Tests and testing tools are not part of package, so you need to clone repository first:

git clone https://github.com/zumm/posterminal
cd posterminal

Now you can install testing tools and test this package using yarn:

yarn install
yarn test

Or npm:

npm install
npm run test

Using

import { Terminal, TerminalError } from 'posterminal'

const SBP = '/path/to/sbp'
const E = '/path/to/e'
const P = '/path/to/p'

try {
  const terminal = new Terminal(SBP, E, P)

  // all methods return:
  // {
  //   status: 'ok',
  //   description: '<content of E file represented in JSON>',
  //   slip: '<content of P file as is>'
  // }
  await terminal.checkConnection()
  await terminal.processPayment(127) 
  await terminal.checkResults()
  await terminal.getLastResult()
} catch (exception) {
  if (exception instanceof TerminalError) {
    // some error handling
  }
  
  console.log(exception)
}

About

module to interact with sb_pilot


Languages

Language:JavaScript 100.0%