I have test windows form the button that does this.
var cloverConnector = CloverConnectorFactory.CreateUsbConnector(
"123423482842", // remote application ID
"not yet", // POS name
"20200408" // serial number
);
var ccl = new CloverConnectionListener(cloverConnector);
cloverConnector.AddCloverConnectorListener(ccl);
cloverConnector.InitializeConnection();
while (!ccl.DeviceReady)
{
Thread.Sleep(1000);
}
try
{
var pendingSale = new SaleRequest
{
ExternalId = ExternalIDUtil.GenerateRandomString(13),
Amount = 1000
AutoAcceptSignature = true,
AutoAcceptPaymentConfirmations = true,
DisableDuplicateChecking = true
};
cloverConnector.Sale(pendingSale);
}
catch (Exception e)
{
textboxDisplay.AppendText(e.Message);
}
below is my connector, It works fine as long I do not press a BACK button or Cancel on the clover mini. Once the back button is pressed, the button do not works again. I have to restart my app for it to work again. how do I fix this problem, please? I have tried to follow "https://docs.clover.com/clover-platform/docs/windows " the instruction change method in a different section, it is hard for a newbie like me to follow. I see someone have the same problem but no answer to the question
https://community.clover.com/questions/361/cancel-onsaleresponse.html .
I am using the lasted SDK. 4.03. Any help will be great.
using System;
using com.clover.remotepay.sdk;
using com.clover.remotepay.transport;
using com.clover.sdk.v3.payments;
namespace test
{
// Create an implementation of ICloverConnectorListener
// Create an implementation of ICloverConnectorListener
public class CloverConnectionListener : DefaultCloverConnectorListener
{
public Boolean DeviceReady { get; set; }
public Boolean DeviceConnected { get; set; }
private bool saleDone;
public bool GetsaleDone()
{
return saleDone;
}
public void SetsaleDone(bool value)
{
saleDone = value;
}
public Boolean RefundDone { get; set; }
public String PaymentId { get; set; }
public String OrderId { get; set; }
public CloverConnectionListener(ICloverConnector cloverConnector) : base(cloverConnector)
{
}
public override void OnDeviceReady(MerchantInfo merchantInfo)
{
base.OnDeviceReady(merchantInfo);
//Connected and available to process requests
DeviceReady = true;
}
public override void OnDeviceConnected()
{
base.OnDeviceConnected();
DeviceConnected = true;
// Connected, but not available to process requests
}
public override void OnDeviceDisconnected()
{
base.OnDeviceDisconnected();
Console.WriteLine("Disconnected");
//Disconnected
}
public override void OnSaleResponse(SaleResponse response)
{
base.OnSaleResponse(response);
if ((response.Result).ToString() == "CANCEL")
{
SetsaleDone(true);
}
else
{
SetsaleDone(true);
PaymentId = response.Payment.id;
OrderId = response.Payment.order.id;
}
}
public override void OnConfirmPaymentRequest(ConfirmPaymentRequest request)
{
}
public override void OnRefundPaymentResponse(RefundPaymentResponse response)
{
base.OnRefundPaymentResponse(response);
try
{
if (response.Success)
{
Refund refund = response.Refund;
Console.WriteLine("Refund request successful");
Console.WriteLine(" ID: " + refund.id);
Console.WriteLine(" Amount: " + refund.amount);
Console.WriteLine(" Order ID: " + response.OrderId);
Console.WriteLine(" Payment ID: " + response.PaymentId);
}
else
{
Console.Error.WriteLine("Refund request failed - " + response.Reason);
}
}
catch
{
Console.Error.WriteLine("Error handling sale notification");
}
RefundDone = true;
}
}
}