/// <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);
        }
        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();
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        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);
        }
        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;
        }