@adamfrostt/bill-acceptor

Bill Acceptor

Usage no npm install needed!

<script type="module">
  import adamfrosttBillAcceptor from 'https://cdn.skypack.dev/@adamfrostt/bill-acceptor';
</script>

README

Bill Acceptor

Setup and running

Install node v12.13.x (MUST be v12.13.x otherwise serial library will cause an error) [https://scotch.io/@vishalbiradar/how-to-install-specific-version-of-nodejs]

Also serial library must be installed with sudo and globally. Use sudo npm install -g serialport --unsafe-perm in order to circumvent the errors that can (and will) appear.

Install all npm dependencies with sudo npm install

Run witn sudo node srv-proto.js

Must be used with sudo because of serial/USB device access

Session is started by POST /api/init on localhost:8081 (port can be changed in config.js) The POST json is the same that the init service on the backend returns (i.e. After it is executed on backend, it should automatically call node's /api/init, but for testing we trigger it via postman manually)

Then the 60 sec session is started and within that period the money can be inserted It will automatically call callbackCashPayIn and callbackCashPaymentConfirm on the backend (as defined in init call) every time the money is inserted successfully (if it is not rejected by the acceptor, in which case we may log the error but the session continues to count down where it left off)

The session is reset to default (60 sec) every time a new bill is inserted

To get the amount use /api/get/current/amount which also returns the remaining session time In case of an error 'expired session' a call to finish session should be made from the site

The inserted bills are all stored in the session

The session is returned when called /api/finish/session together with all inserted banknotes' data and the amount

Logs are being placed in the apps directory in form bill-acceptor.YYYY-MM-DD.log Old logs are zipped. Logs older than 30 days (can be changed in config.js are automatically deleted).

Running The Compiled Version

The compiled version is provided in executable form for linux (bin/app). config.js MUST be placed in the same directory where the executable is, otherwise it won't work. Then just run with sudo ./app from the app's folder.

In case of the changes a new compiled version can be made by installing pkg package (sudo npm i -g pkg) on a system where the code can run (all npm dependencies present etc), and then compiling with sudo pkg --targets=linux app.js from the app folder. It will complain about the path for config.js but that can be ignored as it will be placed in the same folder.

List of Required npm Libraries:

  • encrypted-smiley-secure-protocol
  • express
  • body-parser
  • moment
  • hashmap
  • request
  • winston
  • winston-daily-rotate-file