Exemplo n.º 1
0
        public MainPage()
        {
            this.InitializeComponent();

            sessionPayment  = new SessionPayment();
            cashGenicSystem = new CashGenicSystem();
            uIState         = UIState.Startup;
            _inRefund       = false;

            cashGenicSystem.NewSystemConnected += sys_NewSystemConnection;
            cashGenicSystem.NewSystemError     += sys_NewSystemError;
            cashGenicSystem.NewSystemEvents    += sys_NewSystemEvents;
            _ = Connect();
        }
Exemplo n.º 2
0
        private async Task StartPayment()
        {
            sessionPayment = new SessionPayment();
            sessionPayment.PaymentRequest = Convert.ToInt32(requestValue);


            txtValueRequest.Foreground = App.Current.Resources["systemTextColor"] as SolidColorBrush;
            SystemResponse rsp = await cashGenicSystem.StartPaymentSession(Convert.ToInt32(requestValue));

            if (rsp != SystemResponse.OK)
            {
                double v = Convert.ToDouble(requestValue) / 100;
                txtValueRequest.Text       = rsp.ToString() + " " + v.ToString("C", CultureInfo.CurrentCulture);
                txtValueRequest.Foreground = App.Current.Resources["errorTextColor"] as SolidColorBrush;
            }
        }
Exemplo n.º 3
0
        private void SetUIEvents(Event ev)
        {
            Debug.WriteLine(ev.EventEvent + " " + ev.Value.ToString() + " " + ev.timestamp);

            switch (ev.EventEvent)
            {
            case "Idle":
                // show the key pad
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    SetUIState(UIState.Idle);
                });
                break;

            case "Waiting":

                // hide the key pad
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    if (sessionPayment == null)
                    {
                        sessionPayment = new SessionPayment();
                    }
                    sessionPayment.PaymentRequest = (int)ev.Value;
                    SetUIState(UIState.Waiting);
                });

                break;

            case "CancelPayment":
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    SetUIState(UIState.Cancelling);
                });
                break;

            case "PayOutError":
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    SetUIState(UIState.PayoutError);
                });
                break;

            case "PayOutFailed":
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    SetUIState(UIState.PayoutFailed);
                });
                break;

            case "Payment":
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    sessionPayment.PaymentMade = (int)ev.Value;
                    SetUIState(UIState.PaymentMade);
                });
                break;

            case "Refund":
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    sessionPayment.RefundMade = (int)ev.Value;
                    SetUIState(UIState.RefundMade);
                });
                break;

            case "Change":
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    sessionPayment.ChangeMade = (int)ev.Value;
                    SetUIState(UIState.ChangeMade);
                });
                break;

            case "PaymentComplete":
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    SetUIState(UIState.Complete);
                });
                break;

            case "RestoreTransaction":
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    sessionPayment.PaymentMade = (int)ev.Value;
                    SetUIState(UIState.Restore);
                });
                break;
            }
        }