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 username

machine.username = 'username';

Set the integration password

machine.password = 'password';

Set the integration environment

machine.environment = 'production';

You can change the timeout of the PinPad

machine.timeoutPinPad = 100;

This is the reference of purchase

machine.reference = 'TEST-001';

This is the reference of purchase

machine.amount = 50.0;

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

Get the username of the integration

console.log(machine.username);

Get the password of the integration

console.log(machine.password);

Get the amount of the purchase

console.log(machine.amount);

Get the reference of the purchase

console.log(machine.reference);

Get the url of base of the integration related to the environment

console.log(machine.url);

Get the url of base of the integration related to the environment

console.log(machine.version);
// {
// "name": "XXX",
// "version": "1.X.X",
// "environment": "development",
// "type": "pinpad"
// }

Get the default environment of the integration

console.log(machine.defaultEnvironment);

Get the current environment of the integration

console.log(machine.environment);

Get the current latitude and longitude of pc

console.log(machine.latitudeLongitude);

Get the timeout of the PinPad

console.log(machine.timeoutPinPad);

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

Login with provider using username and password

Warning

force is an optional parameter, by default is false this is only if you change the user or password

await machine.login({force: false});

Check if it has permission to geolocation

await machine.checkPositionPermission();

Cancel the read card process

await machine.cancelReadCard();

Print voucher

await machine.print('client');

Consult the payment

await machine.consult({reference: 'TEST-001'});

Reprint the voucher

await machine.rePrint({folio: 123456789});

Cancel the purchase

await machine.cancelPurchase({ amount: 50.0, authorization: '123456789', folio: '123456789' });

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

To prevent a lot of request to provider when login, only is done once each 24 hours so is necessary to clear the session if you need a fresh login and RSA keys

machine.clearSession();

Get the client voucher after a sale

machine.getClientVoucher();

Get the commerce voucher after a sale

machine.getCommerceVoucher();