static void Main(string[] args) { cloverConnector = CloverConnectorFactory.createICloverConnector(SampleUtils.GetNetworkConfiguration()); var ccl = new ExampleCloverConnectionListener(cloverConnector); cloverConnector.AddCloverConnectorListener(ccl); cloverConnector.InitializeConnection(); while (!ccl.deviceReady) { Thread.Sleep(1000); } var pendingSale = new SaleRequest(); pendingSale.ExternalId = ExternalIDUtil.GenerateRandomString(13); pendingSale.Amount = 1000; pendingSale.AutoAcceptSignature = true; pendingSale.AutoAcceptPaymentConfirmations = true; pendingSale.DisableDuplicateChecking = true; cloverConnector.Sale(pendingSale); while (!ccl.saleDone) { Thread.Sleep(1000); } Console.ReadKey(); }
/// <summary> /// Connect to the specified Clover device /// </summary> public bool Connect(string connectionString) { CloverDeviceConfiguration config = null; Address = connectionString; if (connectionString.Trim().ToUpper() == "USB") { // USB connected Clover Devices are directly connected to the machine and so don't need any extra identification or Pairing information config = new USBCloverDeviceConfiguration(RemoteAppId, true); Address = "USB"; } else { // Network connections require a pairing information and send extra identification to the device config = new WebSocketCloverDeviceConfiguration(connectionString, RemoteAppId, true, 1, PosName, SerialNumber, LoadPairingAuthToken(connectionString, RemoteAppId, PosName), OnPairingCode, OnPairingSuccess, OnPairingState); } if (config != null) { cloverConnector = CloverConnectorFactory.createICloverConnector(config); listener = new SimpleCloverConnectorListener(cloverConnector); listener.DeviceConnected += Listener_DeviceConnected; listener.DeviceReady += Listener_DeviceReady; listener.DeviceDisconnected += Listener_DeviceDisconnected; listener.DeviceError += Listener_DeviceError; listener.SaleResponse += Listener_SaleResponse; cloverConnector.AddCloverConnectorListener(listener); cloverConnector.InitializeConnection(); } return(config != null); }
/// <summary> /// Disconnect from a device /// Note: USB devices can only be connected to once per process in the current CloverConnector SDK. /// </summary> public void Disconnect() { if (cloverConnector != null) { cloverConnector.RemoveCloverConnectorListener(listener); cloverConnector.ResetDevice(); cloverConnector = null; } }
private void InitializeConnector(Dictionary <string, string> parameters) { string protocol; string port; bool testConfig = false; //string lanConfig = null; string testConfigString; if (!parameters.TryGetValue("/P", out port)) { port = "8889";// default } string certPath = null; if (!parameters.TryGetValue("/C", out certPath)) { protocol = "ws";// default } else { protocol = "wss"; } if (!parameters.TryGetValue("/T", out testConfigString)) { testConfig = false; } else { testConfig = true; // } //parameters.TryGetValue("/L", out lanConfig); server = new WebSocketServer(protocol + "://127.0.0.1:" + port); if (certPath != null) { server.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(certPath); } CloverDeviceConfiguration config = null; if (testConfig) { //config = new TestCloverDeviceConfiguration(); } else { config = new USBCloverDeviceConfiguration(null, getPOSNameAndVersion(), Debug, Timer); } cloverConnector = CloverConnectorFactory.createICloverConnector(config); cloverConnector.AddCloverConnectorListener(connectorListener); cloverConnector.InitializeConnection(); }
public PointOfSale() { var connector = CloverConnectorFactory.CreateUsbConnector("RAID", "Point of Sale", "Register101", false); connector.AddCloverConnectorListener(new Listener(this)); connector.InitializeConnection(); connector.RetrieveDeviceStatus(new RetrieveDeviceStatusRequest { sendLastMessage = true }); Connector = connector; }
public static void StartDirectRefund(ICloverConnector cloverConnector, string paymentId, string orderId) { //cloverConnector.ResetDevice(); RefundPaymentRequest refundRequest = new RefundPaymentRequest(); refundRequest.PaymentId = paymentId; refundRequest.OrderId = orderId; refundRequest.FullRefund = true; cloverConnector.RefundPayment(refundRequest); }
private void AppShutdown(object sender, EventArgs e) { if (cloverConnector != null) { try { cloverConnector.Dispose(); } catch (Exception) { cloverConnector = null; } } }
public static void Main(string[] args) { cloverConnector = CloverConnectorFactory.createICloverConnector(SampleUtils.GetNetworkConfiguration()); var ccl = new ExampleCloverConnectionListener(cloverConnector); cloverConnector.AddCloverConnectorListener(ccl); cloverConnector.InitializeConnection(); while (!ccl.deviceConnected) { Thread.Sleep(1000); } Console.ReadKey(); }
public void InitializeConnector(CloverDeviceConfiguration config) { if (cloverConnector != null) { cloverConnector.RemoveCloverConnectorListener(this); OnDeviceDisconnected(); // for any disabling, messaging, etc. //SaleButton.Enabled = false; // everything can work except Pay cloverConnector.Dispose(); } cloverConnector = new CloverConnector(config); cloverConnector.InitializeConnection(); cloverConnector.AddCloverConnectorListener(this); }
//Experimenting on displaying orders //NOT READY YET public static void StartOrder(ICloverConnector cloverConnector) { cloverConnector.ResetDevice(); DisplayOrder o = new DisplayOrder(); DisplayLineItem l = new DisplayLineItem(); DisplayPayment p = new DisplayPayment(); l.name = "hello"; l.price = "1234"; o.addDisplayLineItem(l); o.subtotal = l.price; //o.tax = "0"; o.total = o.subtotal + o.tax; o.currency = "USD"; o.title = "My Order"; p.amount = o.total; cloverConnector.ShowDisplayOrder(o); }
public static void StartSale(ICloverConnector cloverConnector, string invNum, int amt) { //cloverConnector.ResetDevice(); string invoiceNumber = invNum; SaleRequest sarequest = new SaleRequest(); sarequest.Amount = amt; sarequest.ExternalId = invoiceNumber; sarequest.CardEntryMethods = CloverConnector.CARD_ENTRY_METHOD_MANUAL; sarequest.CardEntryMethods |= CloverConnector.CARD_ENTRY_METHOD_MAG_STRIPE; sarequest.CardEntryMethods |= CloverConnector.CARD_ENTRY_METHOD_ICC_CONTACT; sarequest.CardEntryMethods |= CloverConnector.CARD_ENTRY_METHOD_NFC_CONTACTLESS; sarequest.DisablePrinting = true; sarequest.ApproveOfflinePaymentWithoutPrompt = true; sarequest.AllowOfflinePayment = true; cloverConnector.Sale(sarequest); }
public static void StartRefund(ICloverConnector cloverConnector, string invNum, int amt) { //cloverConnector.ResetDevice(); ManualRefundRequest request = new ManualRefundRequest(); request.ExternalId = invNum; request.Amount = amt; // Card Entry methods long CardEntry = 0; CardEntry |= CloverConnector.CARD_ENTRY_METHOD_MANUAL; CardEntry |= CloverConnector.CARD_ENTRY_METHOD_MAG_STRIPE; CardEntry |= CloverConnector.CARD_ENTRY_METHOD_ICC_CONTACT; CardEntry |= CloverConnector.CARD_ENTRY_METHOD_NFC_CONTACTLESS; request.CardEntryMethods = CardEntry; request.DisablePrinting = true; request.DisableRestartTransactionOnFail = true; cloverConnector.ManualRefund(request); }
protected DefaultCloverConnectorListener(ICloverConnector cloverConnector) { this.cloverConnector = cloverConnector; }
public SimpleCloverConnectorListener(ICloverConnector cloverConnector) : base(cloverConnector) { this.cloverConnector = cloverConnector; }
public DefaultCloverConnectorListener(ICloverConnector cloverConnector) { this.cloverConnector = cloverConnector; }
public void InitializeConnector(CloverDeviceConfiguration config) { if (cloverConnector != null) { cloverConnector.RemoveCloverConnectorListener(this); OnDeviceDisconnected(); // for any disabling, messaging, etc. SaleButton.Enabled = false; // everything can work except Pay cloverConnector.Dispose(); } if (config is RemoteRESTCloverConfiguration) { cloverConnector = new RemoteRESTCloverConnector(config); cloverConnector.InitializeConnection(); } else if (config is RemoteWebSocketCloverConfiguration) { cloverConnector = new RemoteWebSocketCloverConnector(config); cloverConnector.InitializeConnection(); } else { cloverConnector = new CloverConnector(config); cloverConnector.InitializeConnection(); } cloverConnector.AddCloverConnectorListener(this); //UI cleanup this.Text = OriginalFormTitle + " - " + config.getName(); CardEntryMethod = 34567; ManualEntryCheckbox.Checked = (CardEntryMethod & CloverConnector.CARD_ENTRY_METHOD_MANUAL) == CloverConnector.CARD_ENTRY_METHOD_MANUAL; MagStripeCheckbox.Checked = (CardEntryMethod & CloverConnector.CARD_ENTRY_METHOD_MAG_STRIPE) == CloverConnector.CARD_ENTRY_METHOD_MAG_STRIPE; ChipCheckbox.Checked = (CardEntryMethod & CloverConnector.CARD_ENTRY_METHOD_ICC_CONTACT) == CloverConnector.CARD_ENTRY_METHOD_ICC_CONTACT; ContactlessCheckbox.Checked = (CardEntryMethod & CloverConnector.CARD_ENTRY_METHOD_NFC_CONTACTLESS) == CloverConnector.CARD_ENTRY_METHOD_NFC_CONTACTLESS; }
public CloverCallbackService(ICloverConnector cloverConnector) { this.cloverConnector = cloverConnector; }
public Listener(ICloverConnector connector) : base(connector) { Connector = connector; }
public CallbackController(ICloverConnector cloverConnector) { connector = cloverConnector; }
public ExampleCloverConnectionListener(ICloverConnector cloverConnector) : base(cloverConnector) { }
public YourListener(ICloverConnector cc) : base(cc) { cloverConnector = cc; }
public CallbackController(ICloverConnector cloverConnector) { cloverCallbackService = new CloverCallbackService(cloverConnector); }