API Reference
Here you will find the methods that you can use to interact with the Locker device.
Setters
Section titled “Setters”listenOnPort
Section titled “listenOnPort”Warning
This device can’t support the listenOnPort setter, but is on Kernel class
serialFilters
Section titled “serialFilters”usbVendorId usbProductId are the filters that you can use to connect to the device
machine.serialFilters = [ { usbVendorId: 0x04d8, usbProductId: 0x0053, },];serialConfigPort
Section titled “serialConfigPort”Warning
This is better don’t use once constructor was called
machine.serialConfigPort = { baudRate: 9600, dataBits: 8, stopBits: 1, parity: "none", bufferSize: 32768, flowControl: "none",};server
Section titled “server”Set the integration data for server
machine.server = "SOMETHING_HERE";businessId
Section titled “businessId”Set the integration data for businessId
machine.businessId = "SOMETHING_HERE";encryptionKey
Section titled “encryptionKey”Set the integration data for encryptionKey
machine.encryptionKey = "SOMETHING_HERE";apiKey
Section titled “apiKey”Set the integration data for apiKey
machine.apiKey = "SOMETHING_HERE";Getters
Section titled “Getters”listenOnPort
Section titled “listenOnPort”Address of the machine
Warning
This device can’t support the listenOnPort getter, but is on Kernel class
console.log(machine.listenOnPort);serialFilters
Section titled “serialFilters”get the filters that apply when require a serial device
console.log(machine.serialFilters);serialConfigPort
Section titled “serialConfigPort”get the configuration of the serial port
console.log(machine.serialConfigPort);isConnected
Section titled “isConnected”Check if the machine is connected
console.log(machine.isConnected);isDisconnected
Section titled “isDisconnected”Check if the machine is disconnected
console.log(machine.isDisconnected);deviceNumber
Section titled “deviceNumber”Get the number of device, isn’t the same of the address.
Warning
Number of device is util if you have more than one machine in the same pc
console.log(machine.deviceNumber);Get the uuid of the connection
When you create a new instance of the class, the uuid is generated
console.log(machine.uuid);typeDevice
Section titled “typeDevice”Get the type of the device each class has a different type, in this case is locker
console.log(machine.typeDevice);Get the queue of commands that are waiting to be executed
console.log(machine.queue);isDispensing
Section titled “isDispensing”Check if the machine is dispensing
console.log(machine.isDispensing);server
Section titled “server”console.log(machine.server);businessId
Section titled “businessId”console.log(machine.businessId);encryptionKey
Section titled “encryptionKey”console.log(machine.encryptionKey);apiKey
Section titled “apiKey”console.log(machine.apiKey);Methods
Section titled “Methods”softReload
Section titled “softReload”Soft reload the machine
await machine.softReload();sendConnect
Section titled “sendConnect”Send connect to the machine
await machine.sendConnect();sendCustomCode
Section titled “sendCustomCode”Send custom code to the machine
await machine.sendCustomCode({ code: "CODEPPCUSTOM" });connectMessage
Section titled “connectMessage”Send connect message to device
await machine.connectMessage();readProductionQR
Section titled “readProductionQR”Login with provider QR for production
await machine.readProductionQR();readQualityAssuranceQR
Section titled “readQualityAssuranceQR”Login with provider QR for QA
await machine.readQualityAssuranceQR();Exit app in device
await machine.exit();Init device process
await machine.init();makeSale
Section titled “makeSale”Make a sale (purchase)
This is the most important method, because with this you can make a sale
Example #1 Simple way
Section titled “Example #1 Simple way”await machine.makeSale({ amount: 15.0, reference: "TEST-001",});Example #2 Verbose data
Section titled “Example #2 Verbose data”const makeDateFormatReference = () => { const date = new Date(); return date .toISOString() .replaceAll(" ", "-") .replaceAll(":", "-") .replaceAll(".", "-");};
function getRandomNumber(max) { return Math.random() * max;}
const amount = getRandomNumber(50).toFixed(2);const reference = "DEV-TEST-" + makeDateFormatReference();
await machine.makeSale({ amount, reference });getVoucher
Section titled “getVoucher”Get the last purchase voucher, you can wait for the response or
listen the event voucher as decribed on listeners section
const response = await machine.getVoucher();console.log(response)Get information about device PAX
await machine.info();keepAlive
Section titled “keepAlive”Just to keepAlive the connection with pax
await machine.keepAlive();restartApp
Section titled “restartApp”Restart aplication e.g. when stuck
await machine.restartApp();getConfig
Section titled “getConfig”Get config data from PAX device
await machine.getConfig();hideButtons
Section titled “hideButtons”Hide android buttons
await machine.hideButtons();showButtons
Section titled “showButtons”Show android buttons
await machine.showButtons();Enter in the demo application
await machine.demo();refund
Section titled “refund”Refund some sale transaction
await machine.refund({ amount: 100, folio: '123123', auth: '111222',});Cancel some transaction when stills processing (not approved)
await machine.stop();verifyNetwork
Section titled “verifyNetwork”Check internet connection
await machine.verifyNetwork();