question

garybarnes avatar image
garybarnes asked garybarnes answered

Network Pay Disconnect Recovery

My setup:

Clover Flex with Network Pay integration.

C# with version 4.0.6.0 (latest) of the SDK.

Clover device is connect to our network via the ambilocal cord to a network cable and power supply.

When I send the transaction the the Clover device, the device displays the amount owning to the customer. If I unplug and plug in the network cord and the customer then process their credit card the OnSaleResponse response is not called. The credit card is processed and then the Clover device displays a never ending rotating circle.

My understanding is it should call the OnSaleReponse with a status of Disconnected and void the payment.

If I am incorrect then how should this be handled.

Here is a very simple version of the code to repeat this issue:

public class CloverFlexExample

{

private static ICloverConnector _cloverConnector;

public CloverFlexExample()

{

}


public void Process()

{

var endpoint = "wss://10.0.1.109:12345/remote_pay";

var websocketConfiguration = new WebSocketCloverDeviceConfiguration(endpoint, //endpoint

"com.cloverconnector.windows.simple.sample:1.3.1", //remoteApplicationID

false, //enableLogging

1, //pingSleepSeconds

"Aisle 2", //posName

"ABC123", //serialNumber

null, //pairingAuthToken

OnPairingCode, //pairingCodeHandler

OnPairingSuccess, //pairingSuccessHandler

OnPairingState); //pairingStateHandler


_cloverConnector = CloverConnectorFactory.createICloverConnector(websocketConfiguration);

var listener = new SomeCloverConnectorListener(_cloverConnector);

_cloverConnector.AddCloverConnectorListener(listener);

_cloverConnector.InitializeConnection();


while (!listener.DeviceReady)

{

System.Threading.Thread.Sleep(1000);

}


var pendingSale = new SaleRequest();

pendingSale.ExternalId = 999 + " - " + ExternalIDUtil.GenerateRandomString(12);

pendingSale.Amount = 100;

pendingSale.AutoAcceptSignature = true;

pendingSale.DisableDuplicateChecking = true;

pendingSale.DisableReceiptSelection = true;

pendingSale.DisablePrinting = true;


_cloverConnector.Sale(pendingSale);

}


private void OnPairingCode(string pairingCode)

{

MessageBox.Show($"paring code: {pairingCode}");

}


private void OnPairingState(string state, string message)

{

}


private void OnPairingSuccess(string authToken)

{

}

}


public class SomeCloverConnectorListener : DefaultCloverConnectorListener

{

private readonly ICloverConnector _cloverConnector;

public bool DeviceReady { get; set; }

public bool SaleDone { get; set; }


public SomeCloverConnectorListener(ICloverConnector cloverConnector) : base(cloverConnector)

{

_cloverConnector = cloverConnector;

}


public override void OnDeviceReady(MerchantInfo merchantInfo)

{

base.OnDeviceReady(merchantInfo);

DeviceReady = true;

}


public override void OnDeviceError(CloverDeviceErrorEvent error)

{

base.OnDeviceError(error);

}


public override void OnDeviceConnected()

{

base.OnDeviceConnected();

}


public override void OnDeviceDisconnected()

{

base.OnDeviceDisconnected();

}


public override void OnDeviceActivityStart(CloverDeviceEvent deviceEvent)

{

}


public override void OnConfirmPaymentRequest(ConfirmPaymentRequest request)

{

_cloverConnector.AcceptPayment(request.Payment);

}


public override void OnSaleResponse(SaleResponse response)

{

base.OnSaleResponse(response);

SaleDone = true;

}

}

secure network pay displaySaledisaster recovery
10 |2000

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

tanaybh avatar image
tanaybh answered

You need to reconnect and follow the things mentioned here in the docs (checkPaymentStatus)

https://docs.clover.com/docs/payment-reconciliation-and-recovery#implementation-examples


10 |2000

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

garybarnes avatar image
garybarnes answered

Thank you tanaybh for pointing me to this page. I guess I knew I could query for the status of the payment. However I figured that clover would handle this situation more elegantly. It should know that it could not post back to OnSaleReponse and then void the transaction. That way we know it is safe to post the payment request again. Instead the customer has to wait for the OnDeviceDisconnected event to be raised which takes up to 30 seconds. During this time the clover device is displaying a rotating circle. Like it is expecting something to occur even though it has taken the payment at the same time we have no response from the device that payment was taken.

If we add code to OnDeviceReady which will get call when the device reconnects some 30 seconds later it will look up of the last event. If the payment taken is not a duplicate payment the last status will be Success / IDLE event through OnSaleReponse was never called. However if the payment is a duplicate payment then it will have status of Success / Waiting For POS, which then calls OnConfirmpaymentRequest followed by OnSaleReponse.

If we do not add the code to OnDeviceReady then OnConfirmationpaymentRequest is not called which may be better. So we are not processing a credit card some 30 seconds later...

10 |2000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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