---
updatedAt: 2026-03-24T12:14:43.000Z
agentTools:
  projectIndex: https://docs.clover.com/dev/llms.txt
---

# In the Cloud

[block:html]
{
  "html": "<meta name=\"description\" content=\"Learn how to use the Clover Connector Browser SDK to enable your web-based point of sale (POS) software to interact with Clover’s customer-facing payment devices through the cloud.\">\n<!--DS-5944 02.29.2024 — In the IMPORTANT note and 5th bullet below the note, \nchanged https://www.clover.com. to  https://api.clover.com. "
}
[/block]

[block:html]
{
  "html": "<div class=\"container-top\">\n  <!-- North America -->\n  <div class=\"container-reg\">\n    <div class=\"pill-reg\">\n      <div class=\"label-reg\">North America</div>\n    </div>\n  </div>\n\n  <!-- Europe -->\n  <div class=\"container-reg\">\n    <div class=\"pill-reg\">\n      <div class=\"label-reg\">Europe</div>\n    </div>\n  </div>\n\n  <!-- Latin America -->\n  <div class=\"container-reg\">\n    <div class=\"pill-reg\">\n      <div class=\"label-reg\">Latin America</div>\n    </div>\n  </div>\n</div>\n\n<!-- CSS moved to global stylesheet-->\n"
}
[/block]

The Clover Connector Browser SDK provides an interface that lets you use your web-based point of sale (POS) software to interact with Clover customer-facing payment devices through the cloud.

You can use these instructions to connect to your Clover device, initiate a Sale request, and handle the response to your Sale request. The instructions cover the current version of the SDK.

A more comprehensive tutorial for this SDK is available on GitHub: [Remote Pay Cloud Codelab](https://github.com/clover/codelab-remote-pay-cloud).

# Prerequisites

* Read the [Overview of the Clover platform](https://docs.clover.com/dev/docs/clover-architecture)
* Set up a [developer account](https://docs.clover.com/docs/create-a-sandbox-account) (including your test merchant settings).
* Order and set up a [Clover Developer Kit (Dev Kit)](https://docs.clover.com/docs/clover-dev-kits).
* [Create a Remote App ID](https://docs.clover.com/dev/docs/create-your-remote-app-id) (`remoteApplicationID`) for your semi-integration POS. This is different from your App ID.

# Before you begin

* Install the [Cloud Pay Display app](https://docs.clover.com/dev/docs/pay-display-apps#section-cloud-pay-display) on the Clover device.
* Use the [Secure Network Pay Display app](https://docs.clover.com/dev/docs/pay-display-apps#section-secure-network-pay-display) for a local network connection on the Clover Flex, Clover Mini, and Clover Mobile.

# Connectivity

The JavaScript Cloud Connector uses WebSockets to communicate with the Clover device through a direct connection (using the [Secure Network Pay Display app](https://docs.clover.com/dev/docs/pay-display-apps#section-secure-network-pay-display)) or Clover servers (using the [Cloud Pay Display app](https://docs.clover.com/dev/docs/pay-display-apps#section-cloud-pay-display)).

Whether you use a direct or cloud configuration depends on several factors.

| Connectivity                                 | Advantages                                                                                                                                                                                                                                                                                                                  | Disadvantages                                                                                                                                                                                                                                                                                        |
| :------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Direct connection—Secure Network Pay Display | - Performance: A direct connection performs better than a cloud connection, which proxies requests through Clover servers. <br> - Simple connection configuration: The configuration for a direct connection is simpler than that for a cloud connection configuration.                                                     | Point of sale (POS) users need to install and trust the Clover device server certificate in any browser that runs your POS application.                                                                                                                                                              |
| Cloud connection—Cloud Pay Display           | - Flexibility: Cloud connections support connecting to devices that are not on the same network as the POS. <br> - No certificate requirements: The application connects to the device through Clover servers, eliminating the need for browsers running the POS to install and trust the Clover device server certificate. | - Performance: Cloud proxies make requests through Clover servers, so they may not perform as well as when directly connected to the Clover device.  - More complex connection configuration: Connection configuration for the cloud is more complex than the configuration for a direct connection. |

# 1. Configure a connection

Clover recommends that connections to the Clover device use the builder for a paired or cloud configuration. The builders reduce the amount of code needed to connect to the device. You can use the constructor directly.

## Option 1: Direct connection with Secure Network Pay Display

You need to install the Secure Network Pay Display and run the app on the Clover device before you can connect directly.

**Parameters for network connection**

Use the following parameters to configure network connections:

[block:parameters]
{
  "data": {
    "h-0": "Network connection parameters",
    "h-1": "",
    "0-0": "**Parameter**",
    "0-1": "**Description**",
    "1-0": "applicationId",
    "1-1": "Remote application ID (RAID) of the point of sale (POS) app.",
    "2-0": "uri",
    "2-1": "Endpoint of the Clover device, for example,  `wss://192.168.1.15:12345/remote_pay`. Displays on the screen when you first launch the Secure Network Pay Display app.",
    "3-0": "posName",
    "3-1": "Name displayed during pairing to identify the POS attempting to connect to the device.",
    "4-0": "serialNumber",
    "4-1": "Serial number/identifier of the POS, as displayed in the Secure Network Pay Display app.  \n**Note:** This is different from the Clover device serial number.",
    "5-0": "authToken",
    "5-1": "Authorization token retrieved from a previous pairing response and passed as an argument to `onPairingSuccess`. The `authToken` is null for the first connection. Store and use the `authToken` in subsequent requests to skip pairing.",
    "6-0": "onPairingCode",
    "6-1": "Device sends a pairing code to call the function.",
    "7-0": "onPairingSuccess",
    "7-1": "Paired POS and device call the function."
  },
  "cols": 2,
  "rows": 8,
  "align": [
    "left",
    "left"
  ]
}
[/block]

**Sample code**

The following is an example code of a direct connection using the paired configuration builder:

```javascript Direct connection builder
const clover = require ("remote-pay-cloud");
...

const networkConfigurationBuilder = new clover.WebSocketPairedCloverDeviceConfigurationBuilder(
  "SWDEFOTWBD7XT.9MGLGMDLSYWTV", // applicationId
  "wss://192.168.0.20:12345/remote_pay", // uri
  "myPOS", //posName
  "Register_1", //serialNumber
  null, //authToken
  onPairingCode, //onPairingCode
  onPairingSuccess //onPairingSuccess
);

const pairedConfiguration = networkConfigurationBuilder.build();
```

## Option 2: Cloud Pay Display

You need to install and start the Cloud Pay Display on the Clover device before you can connect.

**Set the CORS domain**

You need to configure the CORS domain using the Developer Dashboard to establish a connection between your app and the Clover device.

1. Log in to the <<glossary:Developer Dashboard>>.
2. On the Your Apps tab, find your app and click **Settings**.
3. On the Settings page, click **Web Configuration**.
4. In the CORS Domain field, enter your app's URL.
5. Click **Save**.

**Parameters to configure a cloud connection**

Use the following parameters to configure a cloud connection:

> 🚧 IMPORTANT
>
> When you configure the environment in production, set the `cloverServer` to `https://api.clover.com`. Be sure to enter the `www` subdomain.

[block:parameters]
{
  "data": {
    "h-0": "Cloud connection parameters",
    "h-1": "",
    "0-0": "**Parameter**",
    "0-1": "**Description**",
    "1-0": "applicationId",
    "1-1": "Remote application ID (RAID) of the point of sale (POS) app.",
    "2-0": "deviceId",
    "2-1": "retrieve an `accessToken` and your `merchantId` before you can get the`deviceId`. Then, make the following GET request to the Clover REST API:  \n`https://{cloverServer}/v3/merchants/{merchantId}/devices`",
    "3-0": "merchantId",
    "3-1": "Unique universal identifier (UUID) of the merchant. See how to [Use test merchant identifier and API token](https://docs.clover.com/dev/docs/merchant-id-and-api-token-for-development)  page.",
    "4-0": "accessToken",
    "4-1": "OAuth token is used to contact the Clover server. For more information, see [OAuth flows for Clover](https://docs.clover.com/docs/oauth-flows-in-clover).",
    "5-0": "cloverServer",
    "5-1": "Base URL for the Clover server used in the cloud connection, for example, `https://api.clover.com` or `https://sandbox.dev.clover.com/`.",
    "6-0": "friendlyId",
    "6-1": "Identifies the specific terminal connected to the Clover device. If you don't provide a unique ID, problems with reconnection logic may occur. Also, the SDK may return inaccurate error messages if another terminal is already connected to the Clover device."
  },
  "cols": 2,
  "rows": 7,
  "align": [
    "left",
    "left"
  ]
}
[/block]

**Sample code**

The following sandbox example code shows a cloud connection using the cloud configuration builder:

```javascript Cloud connection builder for sandbox
const clover = require ("remote-pay-cloud");
...

const cloudConfigurationBuilder = new clover.WebSocketCloudCloverDeviceConfigurationBuilder(
  "SWDEFOTWBD7XT.9MGLGMDLSYWTV", // applicationId
  "f0f00afd4bc9c55ef0733e7cb8c3da97", // deviceId
  "VKYQ0RVGMYHRR", // merchantId 
  "7aacbd26-d900-8e6a-80f0-ae55f5d1cae2", // accessToken
);

const cloudConfiguration = cloudConfigurationBuilder.setCloverServer("https://sandbox.dev.clover.com")
    .setFriendlyId("A unique ID for your POS terminal")
    .build();
```

# 2. Create a Clover Connector

Create a Clover Connector and pass in the configuration from the previous step.

```javascript Create Clover Connector
const clover = require ("remote-pay-cloud");
...
var builderConfiguration = {};
builderConfiguration[clover.CloverConnectorFactoryBuilder.FACTORY_VERSION] = clover.CloverConnectorFactoryBuilder.VERSION_12;
var cloverConnectorFactory = clover.CloverConnectorFactoryBuilder.createICloverConnectorFactory(builderConfiguration);

var cloverConnector = cloverConnectorFactory.createICloverConnector(connectorConfiguration);
```

# 3. Add a listener to the Clover Connector

1. Define an `ICloverConnectorListener` that will listen for callbacks when transactions finish and other events occur. Include the connection status methods that the listener calls:

* `onDeviceDisconnected()`—Clover device is not available.
* `onDeviceConnected()` —Clover device is connected but not available to process requests.
* `onDeviceReady()` —Device is connected and available to process requests. Once the device is ready, a `MerchantInfo` object with information about the device, merchant, and some potential merchant payment configuration data (such as `supportsAuths` or `supportsVaultCards`) is passed in.

> 📘 NOTE
>
> `onDeviceReady()` may be called multiple times.  For this reason, we do not recommend initiating sales or other transactions from `onDeviceReady()`.

```javascript Define a listener
const clover = require ("remote-pay-cloud");
...

var defaultCloverConnectorListener = Object.assign({}, clover.remotepay.ICloverConnectorListener.prototype, {

   onDeviceReady: function (merchantInfo) {
       updateStatus("Pairing successfully completed, your Clover device is ready to process requests.");
       console.log({message: "Device Ready to process requests!", merchantInfo: merchantInfo});
   },

   onDeviceDisconnected: function () {
       console.log({message: "Disconnected"});
   },

   onDeviceConnected: function () {
       console.log({message: "Connected, but not available to process requests"});
   }

});
```

2. Add the listener to the Clover Connector.

```javascript Add listener to Clover Connector
cloverConnector.addCloverConnectorListener(defaultCloverConnectorListener);
```

# 4. Initialize the connection

Initialize the connection to start communication with the Clover device before you call any methods (other than those that add or remove listeners).

```javascript Initialize the connection
cloverConnector.initializeConnection();
```

# 5. Display a message on the Clover device

Send a test message to the Clover device.

```javascript Show message on device
this.cloverConnector.showMessage("Welcome to Clover Connector!");
```

After you connect to the Clover device and send a successful test message, you can start making requests.

> 📘 NOTE
>
> Clover recommends that your app create, initialize, and maintain one Clover Connector for all transactions. A constant connection eliminates the overhead needed to re-open the connection.

# 6. Initiate a sale from your POS software

To make a `Sale()` request:

1. Define how to handle the `SaleResponse` in your `ICloverConnectorListener`. The truncated code below is an overview of the methods you need to use to get a response to a `Sale` request. A detailed interpretation of the `SaleResponse` appears in the [Handle the result of a Sale transaction section](https://docs.clover.com/docs/cloud-sdk-v3#handle-the-result-of-a-sale-transaction).

```javascript Handling a SaleResponse
var saleListener = Object.assign({}, defaultCloverConnectorListener, {
   onSaleResponse: function (response) {
      ….
   },

   onConfirmPaymentRequest: function (request) {
       ...
   },

   onVerifySignatureRequest: function (request) {
       ...
   }
});

 cloverConnector.addCloverConnectorListener(defaultCloverConnectorListener);
```

2. Create a `SaleRequest` and call the `Sale()` method.

```javascript Create a SaleRequest
const clover = require ("remote-pay-cloud");
const sdk = require ("remote-pay-cloud-api");
...
var saleRequest = new sdk.remotepay.SaleRequest();
saleRequest.setExternalId(clover.CloverID.getNewId());
saleRequest.setAmount(10);
console.log({message: "Sending sale", request: saleRequest});
this.cloverConnector.sale(saleRequest);
```

When you call the `Sale()` method, Clover contacts the payment gateway and returns information about the result of the transaction to your POS.

# 7. Handle the result of a sale transaction

After Clover processes the `Sale` transaction request, Clover calls `onSaleResponse()`. Transaction responses have a boolean `Success` property and an enum `Result` property that provides information on the success flag.

If the transaction is successful, the response also includes the `Payment` object, which may contain the full or partial amount of the `Sale` request.

A `Sale` transaction may return as a tip-adjustable `Auth`, depending on the payment gateway. The `SaleResponse` includes a boolean `isSale` variable that indicates whether the Sale is final or will be finalized during closeout.

```javascript Handling transaction results
console.log({message: "Sale response received", response: response});
if (!response.getIsSale()) {
   console.log({error: "Response is not a sale!"});
}
```

# 8. Sale transaction errors

`onSaleResponse()` returns one of the following codes:

[block:parameters]
{
  "data": {
    "h-0": "Error code",
    "h-1": "Description",
    "0-0": "`SUCCESS`",
    "0-1": "Call succeeded and was successfully queued or processed.",
    "1-0": "`FAIL`",
    "1-1": "Call failed due to an incorrect value being passed in, an invalid card, insufficient funds, or another reason.",
    "2-0": "`UNSUPPORTED`",
    "2-1": "Current merchant configuration doesn't support the capability.",
    "3-0": "`CANCEL`",
    "3-1": "Merchant or customer has pressed the Cancel or Back button on the Clover device.",
    "4-0": "`ERROR`",
    "4-1": "Unexpected or mishandled error. This code is returned when the SDK encounters one of the following problems:  \n  \n- `Device Connection Error`: Clover device is not connected.\n- `Request Validation Error`: Request that was passed in for processing is empty.\n- `Request Validation Error`: Request ExternalId cannot be null or blank.\n- `Request Validation Error`: Request amount cannot be zero.\n- `Request Validation Error`: Request tip amount cannot be less than zero.\n- `Merchant Configuration Validation Error`: Not offered by the merchant-configured gateway."
  },
  "cols": 2,
  "rows": 5,
  "align": [
    "left",
    "left"
  ]
}
[/block]

# 9. Test your app

Test your app using the test card numbers for declines and partial transactions. See [Test region-based payment flows](https://docs.clover.com/docs/testing-payment-flows).

# 10. Dispose of the Clover Connector

You can use `CloverConnector.dispose()` to close the connection before you initialize a new one. To handle page refreshes properly, you can do this for browser-based apps before the window unloads.

# Additional resources

* <a href="https://github.com/clover/remote-pay-cloud/" target="_blank">Clover Connector Browser SDK</a>
* <a href="https://clover.github.io/remote-pay-cloud/4.0.3/" target="_blank">Clover SDK for JavaScript Integration</a>
* <a href="https://clover.github.io/remote-pay-cloud-api/4.0.3/" target="_blank">Clover API Classes Documentation</a>
* <a href="https://github.com/clover/remote-pay-cloud-examples" target="_blank">Example Apps</a>