コード例 #1
0
        private static async Task Run()
        {
            var connector = CloverConnectorFactory.CreateUsbConnector("RAID", "POS", "Register1", false);
            var listener  = new Listener(connector);

            connector.AddCloverConnectorListener(listener);

            listener.DeviceReadyPromise = new TaskCompletionSource <MerchantInfo>();
            connector.InitializeConnection();
            await listener.DeviceReadyPromise.Task;

            listener.ResetDeviceResponsePromise = new TaskCompletionSource <ResetDeviceResponse>();
            connector.ResetDevice();
            await listener.ResetDeviceResponsePromise.Task;

            listener.SaleResponsePromise = new TaskCompletionSource <SaleResponse>();
            connector.Sale(new SaleRequest
            {
                ExternalId = ExternalIDUtil.GenerateRandomString(32),
                Amount     = 123
            });
            var sale = await listener.SaleResponsePromise.Task;

            await Task.Delay(100);

            connector.Dispose();
        }
コード例 #2
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();
        }
コード例 #3
0
        public static void testPaymentAndVoid(CloverConnector cloverConnector, TestConnectorListener connListener)
        {
            //BEGIN: Test Void
            SaleRequest paymentRequest = new SaleRequest();

            paymentRequest.ExternalId = ExternalIDUtil.GenerateRandomString(13);

            paymentRequest.Amount    = 1324;
            paymentRequest.TipAmount = 123;

            System.Console.WriteLine("Preparing To Test Sale: $" + paymentRequest.Amount * 100.00);
            System.Console.WriteLine("Press Any Key to Continue...");
            System.Console.ReadKey();

            //cloverConnector.Sales += paymentListener;
            cloverConnector.Sale(paymentRequest);

            while (!connListener.hasResponse)
            {
                System.Console.WriteLine("Waiting for paymentResponse");
                System.Threading.Thread.Sleep(1000);
            }

            SaleResponse response   = connListener.saleResponse;
            string       paymentId  = response.Payment.id;
            string       orderId    = response.Payment.order.id;
            string       employeeId = response.Payment.employee.id;

            VoidPaymentRequest voidRequest = new VoidPaymentRequest();

            voidRequest.OrderId    = orderId;
            voidRequest.PaymentId  = paymentId;
            voidRequest.EmployeeId = employeeId;
            voidRequest.VoidReason = VoidReason.USER_CANCEL.ToString();

            cloverConnector.VoidPayment(voidRequest);

            while (!connListener.hasResponse)
            {
                System.Console.WriteLine("Waiting for voidResponse");
                System.Threading.Thread.Sleep(1000);
            }

            VoidPaymentResponse voidResponse = connListener.voidPaymentResponse;

            System.Console.WriteLine(voidResponse.Result);
            //END: Test Void
        }
コード例 #4
0
 public static String GetNextId()
 {
     return(ExternalIDUtil.GenerateRandomString(13));
 }
コード例 #5
0
        public void Run()
        {
            var command = "help";

            while (true)
            {
                switch (command)
                {
                case "help":
                    Program.WriteLine(string.Join(Environment.NewLine,
                                                  "COMMANDS:",
                                                  "  help   - Displays help",
                                                  "  sale   - Performs a sale",
                                                  "  status - Retrieves the device status",
                                                  "  resend - Resends the last device message",
                                                  "  enter  - Sends 'ENTER' key to device",
                                                  "  esc    - Sends 'ESC' key to device",
                                                  "  reset  - Resets the device",
                                                  "  exit   - Exits the program"
                                                  ), ConsoleColor.White);
                    break;

                case "sale":
                    Connector.Sale(new SaleRequest {
                        Amount = 123, ExternalId = ExternalIDUtil.GenerateRandomString(32)
                    });
                    break;

                case "status":
                    Connector.RetrieveDeviceStatus(new RetrieveDeviceStatusRequest {
                        sendLastMessage = false
                    });
                    break;

                case "resend":
                    Connector.RetrieveDeviceStatus(new RetrieveDeviceStatusRequest {
                        sendLastMessage = true
                    });
                    break;

                case "enter":
                    // NOTE: The input option is listed in the 'timeout' CloverDeviceEvent in ICloverConnectorListener.OnDeviceActivityStart
                    Connector.InvokeInputOption(new InputOption {
                        description = "OK", keyPress = KeyPress.ENTER
                    });
                    break;

                case "esc":
                    Connector.InvokeInputOption(new InputOption {
                        description = "ESC", keyPress = KeyPress.ENTER
                    });
                    break;

                case "reset":
                    Connector.ResetDevice();
                    break;

                case "exit":
                    return;
                }
                command = Program.Prompt("Command?");
            }
        }