Skip to content

API Reference

Here you will find the methods that you can use to interact with the Locker device.

Warning

This device can’t support the listenOnPort setter, but is on Kernel class

usbVendorId usbProductId are the filters that you can use to connect to the device

machine.serialFilters = [
{
usbVendorId: 0x04d8,
usbProductId: 0x0053,
},
];

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",
};

Set the integration data for server

machine.server = "SOMETHING_HERE";

Set the integration data for businessId

machine.businessId = "SOMETHING_HERE";

Set the integration data for encryptionKey

machine.encryptionKey = "SOMETHING_HERE";

Set the integration data for apiKey

machine.apiKey = "SOMETHING_HERE";

Address of the machine

Warning

This device can’t support the listenOnPort getter, but is on Kernel class

console.log(machine.listenOnPort);

get the filters that apply when require a serial device

console.log(machine.serialFilters);

get the configuration of the serial port

console.log(machine.serialConfigPort);

Check if the machine is connected

console.log(machine.isConnected);

Check if the machine is disconnected

console.log(machine.isDisconnected);

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);

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);

Check if the machine is dispensing

console.log(machine.isDispensing);
console.log(machine.server);
console.log(machine.businessId);
console.log(machine.encryptionKey);
console.log(machine.apiKey);

Soft reload the machine

await machine.softReload();

Send connect to the machine

await machine.sendConnect();

Send custom code to the machine

await machine.sendCustomCode({ code: "CODEPPCUSTOM" });

Send connect message to device

await machine.connectMessage();

Login with provider QR for production

await machine.readProductionQR();

Login with provider QR for QA

await machine.readQualityAssuranceQR();

Exit app in device

await machine.exit();

Init device process

await machine.init();

Make a sale (purchase)

This is the most important method, because with this you can make a sale

await machine.makeSale({
amount: 15.0,
reference: "TEST-001",
});
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 });

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();

Just to keepAlive the connection with pax

await machine.keepAlive();

Restart aplication e.g. when stuck

await machine.restartApp();

Get config data from PAX device

await machine.getConfig();

Hide android buttons

await machine.hideButtons();

Show android buttons

await machine.showButtons();

Enter in the demo application

await machine.demo();

Refund some sale transaction

await machine.refund({
amount: 100,
folio: '123123',
auth: '111222',
});

Cancel some transaction when stills processing (not approved)

await machine.stop();

Check internet connection

await machine.verifyNetwork();