コード例 #1
0
        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();
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <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;
            }
        }
コード例 #4
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();
        }
コード例 #5
0
        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;
        }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: CloverConnection.cs プロジェクト: prix79/B4U_POS
 private void AppShutdown(object sender, EventArgs e)
 {
     if (cloverConnector != null)
     {
         try
         {
             cloverConnector.Dispose();
         }
         catch (Exception)
         {
             cloverConnector = null;
         }
     }
 }
コード例 #8
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();
        }
コード例 #9
0
ファイル: CloverConnection.cs プロジェクト: prix79/B4U_POS
        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);
        }
コード例 #10
0
        //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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
 protected DefaultCloverConnectorListener(ICloverConnector cloverConnector)
 {
     this.cloverConnector = cloverConnector;
 }
コード例 #14
0
 public SimpleCloverConnectorListener(ICloverConnector cloverConnector) : base(cloverConnector)
 {
     this.cloverConnector = cloverConnector;
 }
コード例 #15
0
 public DefaultCloverConnectorListener(ICloverConnector cloverConnector)
 {
     this.cloverConnector = cloverConnector;
 }
コード例 #16
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();
            }

            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;
        }
コード例 #17
0
 public CloverCallbackService(ICloverConnector cloverConnector)
 {
     this.cloverConnector = cloverConnector;
 }
コード例 #18
0
 public Listener(ICloverConnector connector) : base(connector)
 {
     Connector = connector;
 }
コード例 #19
0
ファイル: Callback.cs プロジェクト: clover/remote-pay-windows
 public CallbackController(ICloverConnector cloverConnector)
 {
     connector = cloverConnector;
 }
コード例 #20
0
 public DefaultCloverConnectorListener(ICloverConnector cloverConnector)
 {
     this.cloverConnector = cloverConnector;
 }
 public ExampleCloverConnectionListener(ICloverConnector cloverConnector) : base(cloverConnector)
 {
 }
コード例 #22
0
 public CallbackController(ICloverConnector cloverConnector)
 {
     connector = cloverConnector;
 }
コード例 #23
0
 public YourListener(ICloverConnector cc) : base(cc)
 {
     cloverConnector = cc;
 }
コード例 #24
0
 private void AppShutdown(object sender, EventArgs e)
 {
     if (cloverConnector != null)
     {
         try
         {
             cloverConnector.Dispose();
         }
         catch (Exception)
         {
             cloverConnector = null;
         }
     }
 }
コード例 #25
0
 public CallbackController(ICloverConnector cloverConnector)
 {
     cloverCallbackService = new CloverCallbackService(cloverConnector);
 }