Class: WebSocketDevice

WebSocketDevice

new WebSocketDevice()

The object used to communicate with the device.
Source:

Members

(static) ALL_MESSAGES

Special message method type used to receive all messages received by this device interface. Used when registering a callback to the WebSocketDevice.on function
Source:

(static) CONNECTION_DENIED :string

Event emitter key for connection denied messages
Type:
  • string
Source:

(static) CONNECTION_ERROR :string

Event emitter key for connection error messages
Type:
  • string
Source:

(static) CONNECTION_OK :string

Event emitter key for connection ok messages
Type:
  • string
Source:

(static) CONNECTION_STOLEN :string

Event emitter key for connection stolen messages
Type:
  • string
Source:

(static) CONNECTION_WARNING :string

Event emitter key for connection warning messages
Type:
  • string
Source:

(static) DEVICE_CLOSE :string

Event emitter key for device close events
Type:
  • string
Source:

(static) DEVICE_ERROR :string

Event emitter key for device error events
Type:
  • string
Source:

(static) DEVICE_OPEN :string

Event emitter key for device open events
Type:
  • string
Source:

(static) LOCAL_EVENT :string

Prefix for events that are local to the device - right now just for device state events.
Type:
  • string
Source:

Methods

connectionDenied(terminalIdPairedTo)

Called when an initial connection is actively denied, typically because the device is already paired to another terminal.
Parameters:
Name Type Description
terminalIdPairedTo
Source:

connectionError(lag)

Called when the lag on communication has reached an error length Emits the WebSocketDevice.CONNECTION_ERROR message to registered listeners.
Parameters:
Name Type Description
lag Number the number of milliseconds between communication to and from the device. Measured as related to 'pong' responses to a 'ping'
Source:

connectionOK()

Called when the connection is OK. Emits the WebSocketDevice.CONNECTION_OK message to registered listeners.
Source:

connectionStolen(message)

The connection was taken away from us. Do NOT try to reconnect!
Parameters:
Name Type Description
message
Source:

connectionWarning(lag)

Called when the lag on communication has reached a warning length Emits the WebSocketDevice.CONNECTION_WARNING message to registered listeners.
Parameters:
Name Type Description
lag Number the number of milliseconds between communication to and from the device. Measured as related to 'pong' responses to a 'ping'
Source:

contactDevice(ws_address)

Initiates contact with the device.
Parameters:
Name Type Description
ws_address url the web service url to connect to to communicate with the clover device
Source:

disconnectFromDevice()

Called to initiate disconnect from the device
Source:

forceClose(skipSendShutdown)

Do not really want to ever have to do this, but it is sometimes needed. The above #WebSocketDevice.disconnectFromDevice is how this should be closed. That sends a message to the device to tell it that we are closing. But this may be needed if the device is not responsive.
Parameters:
Name Type Description
skipSendShutdown if true, then the shutdown message is NOT sent to the device.
Source:

on(eventName, callback)

Registers event callbacks for message method types, and device state.
Parameters:
Name Type Description
eventName string one of the LanMethod types, or one of the LOCAL_EVENT types for device state.
callback function the function called with the event data
Source:
See:

once(eventName, callback)

Registers event callbacks for message method types, and device state. The callback will be called at most once.
Parameters:
Name Type Description
eventName string one of the LanMethod types, or one of the LOCAL_EVENT types for device state.
callback function the function called with the event data
Source:
See:

onclose(event)

Called when the device is closed Emits the WebSocketDevice.DEVICE_CLOSE event to registered listeners.
Parameters:
Name Type Description
event
Source:

onerror(event)

Called on device error Emits the WebSocketDevice.DEVICE_ERROR event to registered listeners.
Parameters:
Name Type Description
event
Source:

onopen(event)

Called when the device is opened Emits the WebSocketDevice.DEVICE_OPEN event to registered listeners.
Parameters:
Name Type Description
event
Source:

reContactDevice(ws_address)

Initiates contact with the device.
Parameters:
Name Type Description
ws_address url the web service url to connect to to communicate with the clover device
Source:

removeListener(eventName, callback)

Unregisters an event callback.
Parameters:
Name Type Description
eventName
callback
Source:

removeListeners(listeners)

Unregisters a set of event callbacks.
Parameters:
Name Type Description
listeners Array an array of objects of the form {"event":LanMethod.FINISH_OK, "callback":finishOKCB}
Source:

sendBreak(ackIdopt)

Parameters:
Name Type Attributes Description
ackId <optional>
an optional id for the message. If set then the break will be acknowledged, otherwise there will be no response.
Source:

sendCapturePreAuth(orderId, paymentId, amount, tipAmountopt, ackIdopt)

Capture a preauthorization
Parameters:
Name Type Attributes Description
orderId string the id for the order the payment was against
paymentId string the id for the payment on the order the preauth is against
amount number the final amount for the payment, not including the tip
tipAmount number <optional>
the tip for the order
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendCloseout(allowOpenTabs, batchId, ackIdopt)

Capture a preauthorization
Parameters:
Name Type Attributes Description
allowOpenTabs
batchId
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendDiscoveryRequest(ackIdopt)

Send a message to ask the device if it is there.
Parameters:
Name Type Attributes Description
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendFinishCancel(ackIdopt)

Send a cancellation message
Parameters:
Name Type Attributes Description
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendKeyPress(keyCode, ackIdopt)

Parameters:
Name Type Attributes Description
keyCode KeyPress the KeyPress to send to the device
ackId <optional>
an optional id for the message. If set then the keypress will be acknowledged, otherwise there will be no response.
Source:

sendLastMessageRequest(ackIdopt)

Send a message to the device to get the last message it received, along with the response returned (if any)
Parameters:
Name Type Attributes Description
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendMessage(message)

Send a message on the websocket. The parameter will be serialized to json
Parameters:
Name Type Description
message Object the message to send
Source:

sendOpenCashDrawer(reason, ackIdopt)

Open the cash drawer (if one is connected).
Parameters:
Name Type Attributes Description
reason string the reason the drawer was opened
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendPrintImage(img, ackIdopt)

Send a message with an image for the device to print.
Parameters:
Name Type Attributes Description
img an image. Can be obtained in a manner similar to :
var img = document.getElementById("img_id");
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendPrintImageFromURL(urlString, ackIdopt)

Send a message with an image url for the device to print.
Parameters:
Name Type Attributes Description
urlString a url to an image that is reachable from the device
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendPrintText(textLines, ackIdopt)

Send a message to ask the device to print some text
Parameters:
Name Type Attributes Description
textLines an array of strings
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendRefund(orderId, paymentId, amountopt, ackIdopt)

Refund a payment, partial or complete
Parameters:
Name Type Attributes Description
orderId string the id for the order the refund is against
paymentId string the id for the payment on the order the refund is against
amount number <optional>
the amount that will be refunded. If not included, the amount of the passed payment will be refunded.
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendRefundV2(orderId, paymentId, amountopt, fullRefundopt, ackIdopt)

Refund a payment, partial or complete
Parameters:
Name Type Attributes Description
orderId string the id for the order the refund is against
paymentId string the id for the payment on the order the refund is against
amount number <optional>
the amount that will be refunded.
fullRefund boolean <optional>
If true, the amount of the passed payment will be refunded.
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendShowOrderDiscountAdded(order, discountsAddedOperation, ackIdopt)

Sends an update to the order to the device, and causes it to display the change.
Parameters:
Name Type Attributes Description
order Object the entire order json object
discountsAddedOperation Operation
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendShowOrderDiscountRemoved(order, discountsDeletedOperation, ackIdopt)

Sends an update to the order to the device, and causes it to display the change.
Parameters:
Name Type Attributes Description
order Object the entire order json object
discountsDeletedOperation Operation
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendShowOrderLineItemAdded(order, lineItemsAddedOperation, ackIdopt)

Sends an update to the order to the device, and causes it to display the change.
Parameters:
Name Type Attributes Description
order Object the entire order json object
lineItemsAddedOperation Operation
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendShowOrderLineItemRemoved(order, lineItemsDeletedOperation, ackIdopt)

Sends an update to the order to the device, and causes it to display the change.
Parameters:
Name Type Attributes Description
order Object the entire order json object
lineItemsDeletedOperation Operation
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendShowOrderScreen(order, ackIdopt)

TElls the device to display the passed order.
Parameters:
Name Type Attributes Description
order Object the entire order json object
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendShowPaymentReceiptOptions(orderId, paymentId, ackIdopt)

Show the receipt options screen for a specific orderid/paymentid.
Parameters:
Name Type Attributes Description
orderId string the id for the order
paymentId string the id for the payment on the order
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Deprecated:
  • - this function will result in a Finish_OK message being returned. Use sendShowPaymentReceiptOptionsV2 instead. sendShowPaymentReceiptOptionsV2 results in only the UI_STATE messages, which is preferable.
Source:

sendShowPaymentReceiptOptionsV2(orderId, paymentId, ackIdopt)

Show the receipt options screen for a specific orderid/paymentid.
Parameters:
Name Type Attributes Description
orderId string the id for the order
paymentId string the id for the payment on the order
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendShowThankYouScreen(ackIdopt)

Send a message to show the 'Thank You' screen
Parameters:
Name Type Attributes Description
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendShowWelcomeScreen(ackIdopt)

Send a message to show the 'Welcome' screen
Parameters:
Name Type Attributes Description
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendShutdown()

Send a message to ask the device to shutdown the connection.
Source:

sendSignatureRejected(payment, ackIdopt)

Verify that the signature is NOT valid
Parameters:
Name Type Attributes Description
payment Object the payment object with signature verification fields populated (negatively)
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendSignatureVerified(payment, ackIdopt)

Verify that the signature is valid
Parameters:
Name Type Attributes Description
payment Object the payment object with signature verification fields populated (positively)
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendTerminalMessage(message, ackIdopt)

Send a message to show a custom message on the screen
Parameters:
Name Type Attributes Description
message string the message to display
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendTipAdjust(orderId, paymentId, tipAmount, ackIdopt)

Adjust a payment
Parameters:
Name Type Attributes Description
orderId string the id for the order the adjust is against
paymentId string the id for the payment on the order the adjust is against
tipAmount number the amount that will be adjusted.
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendTXStart(payIntent, suppressOnScreenTips, ackIdopt)

Send a message to start a transaction. This will make the device display the payment screen
Parameters:
Name Type Attributes Description
payIntent Object the payment intention object
suppressOnScreenTips boolean
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendVaultCard(cardEntryMethods, ackIdopt)

Vault a card
Parameters:
Name Type Attributes Description
cardEntryMethods int card entry methods, bitwise OR of CardEntryMethods constants
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source:

sendVoidPayment(payment, voidReason, ackIdopt)

Void a payment
Parameters:
Name Type Attributes Description
payment Object the payment object with signature verification fields populated (negatively)
voidReason
ackId string <optional>
an optional identifier that can be used to track an acknowledgement to this message. This should be a unique identifier, but this is NOT enforced in any way. A "ACK" message will be returned with this identifier as the message id if this parameter is included. This "ACK" message will be in addition to any other message that may be generated as a result of this message being sent.
Source: