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",}username
Section titled “username”Set the integration username
machine.username = 'username';password
Section titled “password”Set the integration password
machine.password = 'password';environment
Section titled “environment”Set the integration environment
machine.environment = 'production';timeoutPinPad
Section titled “timeoutPinPad”You can change the timeout of the PinPad
machine.timeoutPinPad = 100;reference
Section titled “reference”This is the reference of purchase
machine.reference = 'TEST-001';amount
Section titled “amount”This is the reference of purchase
machine.amount = 50.0;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);username
Section titled “username”Get the username of the integration
console.log(machine.username);password
Section titled “password”Get the password of the integration
console.log(machine.password);amount
Section titled “amount”Get the amount of the purchase
console.log(machine.amount);reference
Section titled “reference”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);version
Section titled “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
Section titled “defaultEnvironment”Get the default environment of the integration
console.log(machine.defaultEnvironment);environment
Section titled “environment”Get the current environment of the integration
console.log(machine.environment);latitudeLongitude
Section titled “latitudeLongitude”Get the current latitude and longitude of pc
console.log(machine.latitudeLongitude);timeoutPinPad
Section titled “timeoutPinPad”Get the timeout of the PinPad
console.log(machine.timeoutPinPad);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'});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
Section titled “checkPositionPermission”Check if it has permission to geolocation
await machine.checkPositionPermission();cancelReadCard
Section titled “cancelReadCard”Cancel the read card process
await machine.cancelReadCard();Print voucher
await machine.print('client');consult
Section titled “consult”Consult the payment
await machine.consult({reference: 'TEST-001'});rePrint
Section titled “rePrint”Reprint the voucher
await machine.rePrint({folio: 123456789});cancelPurchase
Section titled “cancelPurchase”Cancel the purchase
await machine.cancelPurchase({ amount: 50.0, authorization: '123456789', folio: '123456789' });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 });clearSession
Section titled “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
Section titled “getClientVoucher”Get the client voucher after a sale
machine.getClientVoucher();getCommerceVoucher
Section titled “getCommerceVoucher”Get the commerce voucher after a sale
machine.getCommerceVoucher();