question

Devendra avatar image
Devendra asked ·

Can we Initialize connection without Prompting for Pairing Code?

Hi Team,

When we call cloverConnector#initializeConnection() method it asks for Pairing Code if device is not paired and if it is already paired it return device is ready . Is there any way to check the connection without showing pairing prompt on Clover device, if not paired earlier then we dont want to show pairing prompt?

Thanks,
Devendra
Clover Minisecure network pay display
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

justin.a avatar image
justin.a answered ·
@Devendra

You can initialize a connection to the device without having to prompt for a pairing code each time. Anytime you successfully pair the device, the WebSocketCloverDeviceConfiguration onPairingSuccess callback will receive an authToken that can be consumed during the next pairing event (one-time use).

The default shelf life of a Clover Device Server authToken is 30 days, but can be configured in Secure Network Pay Display settings. The device will not prompt for a pairing code if an authToken is provided when initializing the config given that it is not expired or rejected for any other reason. If an authToken is not provided, onPairingCode will continue to trigger the on device prompt for a new code.

Example (remote-pay-java):
String authToken = Preferences.userNodeForPackage(ExamplePOS.class).get("AUTH_TOKEN", null);

config = new WebSocketCloverDeviceConfiguration(endpoint, APP_ID, trustStore, POS_NAME, DEVICE_NAME, authToken) {
    @Override
    public void onPairingCode(String pairingCode) {
        System.out.println("Enter pairing code on device: " + pairingCode);
    }

    @Override
    public void onPairingSuccess(String authToken) {
        Preferences.userNodeForPackage(ExamplePOS.class).put("AUTH_TOKEN", authToken);
        System.out.println("Pairing success");
    }
};

If you are looking to check whether or not a connection has already been established with a device, the retreiveDeviceStatus method can be used to send a message requesting the status of a device.

-- Justin
Share
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community