Skip to main content

API

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

Setters

listenOnPort

Warning

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

serialFilters

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

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

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

username

Set the integration username

machine.username = 'username';

password

Set the integration password

machine.password = 'password';

environment

Set the integration environment

Tips

Available environments are production, qa, development

machine.environment = 'production';

timeoutPinPad

You can change the timeout of the PinPad

Information

By default, the timeout are 100 seconds

machine.timeoutPinPad = 100;

reference

This is the reference of purchase

Tips

This is only required if you consult the payment, because when you use makeSale is required as parameter

Information

Only accepts alphanumeric characters A-Z, a-z, 0-9 and -

machine.reference = 'TEST-001';

amount

This is the reference of purchase

Tips

This is only required if you consult the payment, because when you use makeSale is required as parameter

Information

Only accepts numeric characters 0-9 and .

machine.amount = 50.0;

Getters

listenOnPort

Address of the machine

Warning

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

console.log(machine.listenOnPort);

serialFilters

get the filters that apply when require a serial device

console.log(machine.serialFilters);

serialConfigPort

get the configuration of the serial port

console.log(machine.serialConfigPort);

isConnected

Check if the machine is connected

console.log(machine.isConnected);

isDisconnected

Check if the machine is disconnected

console.log(machine.isDisconnected);

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

uuid

Get the uuid of the connection

When you create a new instance of the class, the uuid is generated

console.log(machine.uuid);

typeDevice

Get the type of the device each class has a different type, in this case is locker

console.log(machine.typeDevice);

queue

Get the queue of commands that are waiting to be executed

console.log(machine.queue);

isDispensing

Check if the machine is dispensing

console.log(machine.isDispensing);

username

Get the username of the integration

console.log(machine.username);

password

Get the password of the integration

console.log(machine.password);

amount

Get the amount of the purchase

console.log(machine.amount);

reference

Get the reference of the purchase

console.log(machine.reference);

url

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

console.log(machine.url);

version

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"
// }

defaultEnvironment

Get the default environment of the integration

Information

Available environments are production, qa, development

console.log(machine.defaultEnvironment);

environment

Get the current environment of the integration

Information

Available environments are production, qa, development

console.log(machine.environment);

latitudeLongitude

Get the current latitude and longitude of pc

console.log(machine.latitudeLongitude);

timeoutPinPad

Get the timeout of the PinPad

console.log(machine.timeoutPinPad);

Methods

softReload

Soft reload the machine

await machine.softReload();

sendConnect

Send connect to the machine

await machine.sendConnect();

sendCustomCode

Send custom code to the machine

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

login

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

checkPositionPermission

Check if it has permission to geolocation

Information

Help to validate payments with card

await machine.checkPositionPermission();

cancelReadCard

Cancel the read card process

await machine.cancelReadCard();

print

Print voucher

Information

type is an optional parameter, by default is client

available types are client, commerce

await machine.print('client');

consult

Consult the payment

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

rePrint

Reprint the voucher

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

cancelPurchase

Cancel the purchase

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

makeSale

Make a sale (purchase)

Tips

amount and reference are required parameters

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

await machine.makeSale({ amount: 50.0, reference: 'TEST-001' });

clearSession

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

getClientVoucher

Get the client voucher after a sale

machine.getClientVoucher();

getCommerceVoucher

Get the commerce voucher after a sale

machine.getCommerceVoucher();