new Clover(configurationINopt)
Clover API for external Systems
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
configurationIN |
CloverConfig |
<optional> |
the device that sends and receives messages |
Methods
acceptSignature(signatureVerifyRequest, completionCallback)
Sends a message to accept the passed signature on the payment.
Parameters:
Name | Type | Description |
---|---|---|
signatureVerifyRequest |
SignatureVerifyRequest | the signature verification request. |
completionCallback |
auth(saleInfo, saleRequestCallback) → {string}
Auth
Parameters:
Name | Type | Description |
---|---|---|
saleInfo |
TransactionRequest | the information for the sale |
saleRequestCallback |
Clover~transactionRequestCallback | the callback that receives the sale completion information. |
Returns:
paymentId - identifier used for the payment once the transaction is completed. This may be
passed in as part of the saleInfo. If it is not passed in then this will be a new generated value.
- Type
- string
capturePreAuth(request, completionCallback)
Capture a previously made preauthorization.
Parameters:
Name | Type | Description |
---|---|---|
request |
CapturePreAuthRequest | |
completionCallback |
close()
Closes the connection to the Clover device.
closeout(request, completionCallback)
Send a closeout request to the device.
Parameters:
Name | Type | Description |
---|---|---|
request |
CloseoutRequest | |
completionCallback |
displayOrder(order, completionCallback)
Display the passed order.
Parameters:
Name | Type | Description |
---|---|---|
order |
DisplayOrder | |
completionCallback |
displayOrderDiscountAdded(order, discount, completionCallback)
Tells the device to redisplay the passed order, and that a discount
has been added to it. The discount should already be incorperated
to the order before calling this function.
Parameters:
Name | Type | Description |
---|---|---|
order |
DisplayOrder | the order to display |
discount |
DisplayDiscount | the discount that has been added to the order |
completionCallback |
displayOrderDiscountRemoved(order, discount, completionCallback)
Tells the device to redisplay the passed order, and that a discount
has been removed from it. The discount should already be disincorperated
from the order before calling this function.
Parameters:
Name | Type | Description |
---|---|---|
order |
DisplayOrder | the order to display |
discount |
DisplayDiscount | the discount that has been removed from the order |
completionCallback |
displayOrderLineItemAdded(order, lineItem, completionCallback)
Tells the device to redisplay the passed order, and that a lineItem
has been added to it. The lineItem should already be incorperated
to the order before calling this function.
Parameters:
Name | Type | Description |
---|---|---|
order |
DisplayOrder | the order to display |
lineItem |
DisplayLineItem | the line item that has been added to the order |
completionCallback |
displayOrderLineItemRemoved(order, lineItem, completionCallback)
Tells the device to redisplay the passed order, and that a lineItem
has been removed from it. The lineItem should already be disincorperated
from the order before calling this function.
Parameters:
Name | Type | Description |
---|---|---|
order |
DisplayOrder | the order to display |
lineItem |
DisplayLineItem | the line item that has been removed to the order |
completionCallback |
getLastMessage(completionCallback)
Retreive the last transactional message made to the device.
Parameters:
Name | Type | Description |
---|---|---|
completionCallback |
requestCallback |
incompleteConfiguration(message, configurationopt, callback)
This can be overridden to provide any missing configuration information to this.configuration (
through a UI or a call to the server, etc...), after which a call to
Clover.initDeviceConnection would need to be made to continue attempting to connect to the device.
Note that if an overridden implementation does NOT properly provide configuration, and a call is made to
Clover.initDeviceConnection, there is the possibility of creating a recursive loop that would
impact the performance of the application, and could make the browser unstable.
Any override of this function should ensure that configuration information is complete before making
the call to Clover.initDeviceConnection.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | an error message. This could be ignored. | |
configuration |
CloverConfig |
<optional> |
the configuration that is incomplete. |
callback |
the error first callback. If defined, then it will be called with the first parameter as a CloverError. If not defined, then the CloverError will be thrown. |
initDeviceConnection(callBackOnDeviceReady)
Called to initialize the device for communications.
The device connection is NOT made on completion of this call. The device connection
will be made once the WebSocketDevice.onopen is called.
If there is no active configuration, then this will try to load the configuration using
Clover.loadPersistedConfiguration. Once the deviceURL has been derived, an attempt will be made to persist
the configuration using Clover.persistConfiguration.
If there is not enough configuration information to connect to the device, then Clover.incompleteConfiguration
will be called.
If the device is not connected to the push server, the callback will be called with the first parameter of a
CloverError with a code of CloverError.DEVICE_OFFLINE.
If there is a communication error retrieving the device websocket connection point or device info, the callback
will be called with the first parameter of a CloverError with a code of CloverError.COMMUNICATION_ERROR.
If the configuration of the device is incomplete, the callback will be called with the first parameter of a
CloverError with a code of CloverError.INCOMPLETE_CONFIGURATION.
If the device is contacted, but does not respond to a discovery request, the callback will be called with the first parameter of a
CloverError with a code of CloverError.DISCOVERY_TIMEOUT.
Parameters:
Name | Type | Description |
---|---|---|
callBackOnDeviceReady |
callback function called when the device is ready for operations. The callback function can be called with several possible results. Adheres to error first paradigm. |
isOpen() → {boolean}
Returns:
true if the device is open and ready for communications,
false if the device is closed, or has an error.
- Type
- boolean
loadPersistedConfiguration(callback) → {boolean}
Loads the configuration that was stored. This implementation just grabs the
configuration from a cookie. Reimplementation of this function could provide
configuration from a server or even a UI.
Parameters:
Name | Type | Description |
---|---|---|
callback |
the error first callback that will be passed to Clover.incompleteConfiguration if no configuration could be loaded. |
Returns:
true if the configuration was loaded.
- Type
- boolean
openCashDrawer(reason, completionCallbackopt)
Opens the cash drawer
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
reason |
string | the reason the cash drawer was opened. | |
completionCallback |
requestCallback |
<optional> |
persistConfiguration()
Stores the configuration for later retrieval. This implementation just drops the
configuration into a cookie. Reimplementation of this function could provide
server or some other type of cloud persistence.
preAuth(saleInfo, saleRequestCallback) → {string}
Pre Auth
Parameters:
Name | Type | Description |
---|---|---|
saleInfo |
TransactionRequest | the information for the sale |
saleRequestCallback |
Clover~transactionRequestCallback | the callback that receives the sale completion information. |
Returns:
paymentId - identifier used for the payment once the transaction is completed. This may be
passed in as part of the saleInfo. If it is not passed in then this will be a new generated value.
- Type
- string
print(textLines, completionCallbackopt)
Print an array of strings on the device
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
textLines |
Array.<string> | an array of strings to print | |
completionCallback |
requestCallback |
<optional> |
printImage(img, completionCallbackopt)
Prints an image on the receipt printer of the device.
The size of the image should be limited, and the optimal
width of the image is 384 pixals.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
img |
an HTML DOM IMG object. | ||
completionCallback |
requestCallback |
<optional> |
printImageFromURL(img, completionCallbackopt)
Prints an image on the receipt printer of the device.
The size of the image should be limited, and the optimal
width of the image is 384 pixals.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
img |
an HTML DOM IMG object. | ||
completionCallback |
requestCallback |
<optional> |
printReceipt(printRequest, completionCallback)
Print a receipt from a previous transaction.
Parameters:
Name | Type | Description |
---|---|---|
printRequest |
||
completionCallback |
refund(refundInfo, refundRequestCallback)
Refund AKA credit
Parameters:
Name | Type | Description |
---|---|---|
refundInfo |
TransactionRequest | amount is refunded |
refundRequestCallback |
Clover~transactionRequestCallback |
refundPayment(refundRequest, completionCallback)
Refund from a previous payment.
Parameters:
Name | Type | Description |
---|---|---|
refundRequest |
RefundRequest | the refund request |
completionCallback |
requestCallback |
rejectSignature(signatureVerifyRequest, completionCallback)
Sends a message to reject the passed signature on the payment.
Parameters:
Name | Type | Description |
---|---|---|
signatureVerifyRequest |
SignatureVerifyRequest | the signature verification request. |
completionCallback |
resetDevice(completionCallbackopt)
Sends a break message to the device to reset
the state of the device.
Warning: this will cause any pending transaction messages to be lost!
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
completionCallback |
requestCallback |
<optional> |
sale(saleInfo, saleRequestCallback) → {string}
Sale AKA purchase
Parameters:
Name | Type | Description |
---|---|---|
saleInfo |
TransactionRequest | the information for the sale |
saleRequestCallback |
Clover~transactionRequestCallback | the callback that receives the sale completion information. |
Returns:
paymentId - identifier used for the payment once the transaction is completed. This may be
passed in as part of the saleInfo. If it is not passed in then this will be a new generated value.
- Type
- string
sendCancel(completionCallbackopt)
Sends an escape code to the device. The behavior of the device when this is called is
dependant on the current state of the device.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
completionCallback |
requestCallback |
<optional> |
showMessage(message, completionCallbackopt)
Puts a message on the device screen
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | the message to put on the device screen. | |
completionCallback |
requestCallback |
<optional> |
showThankYouScreen(completionCallbackopt)
Puts the device in the 'thank you' screen
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
completionCallback |
requestCallback |
<optional> |
showWelcomeScreen(completionCallbackopt)
Puts the device in the welcome screen
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
completionCallback |
requestCallback |
<optional> |
tipAdjust(tipAdjustRequest, completionCallback)
Parameters:
Name | Type | Description |
---|---|---|
tipAdjustRequest |
TipAdjustRequest | the refund request |
completionCallback |
requestCallback |
vaultCard(cardEntryMethods, completionCallback)
Capture a card for future usage in a sale or auth request.
Parameters:
Name | Type | Description |
---|---|---|
cardEntryMethods |
||
completionCallback |
requestCallback |
voidTransaction(payment, voidReason, completionCallback)
Parameters:
Name | Type | Description |
---|---|---|
payment |
Payment | the payment information returned from a call to 'sale'. this can be truncated to be only { "id": paymentId, "order": {"id": orderId}} |
voidReason |
VoidReason | the reason for the void. |
completionCallback |
requestCallback |
Type Definitions
transactionRequestCallback(erroropt, result)
The callback on a sale
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
error |
Error |
<optional> |
null iff there was no error, else an object that contains a code and a message text |
result |
TransactionResponse | data that results from the function. |