Exemplo n.º 1
0
        async void Payment(string paymentType)
        {
            PaymentCommand payment = new PaymentCommand()
            {
                TotalDiscount = TotalDiscount,
                ItemList      = CurrentTicket.ToList(),
                ShiftId       = App.OpenShiftId,
                StoreEmail    = App.Email,
                Total         = TotalPrice
            };

            switch (paymentType)
            {
            case "Debit":
                payment.PaymentType = Api.ViewModels.Enixer_Enumerations.EP_PaymentTypeEnum.Debit;
                ReceiptViewModel result = _service.AddPayment(payment);
                if (result != null)
                {
                    PopupNavigation.PushAsync(new Error(new ErrorViewModel("Payment Completed", 3)));
                    Application.Current.MainPage.Navigation.PushAsync(new ReceiptPage(this));
                }
                else
                {
                    Application.Current.MainPage.DisplayAlert("Payment Error", "Payment not completed please try again.", "Ok");
                }
                return;

            case "Credit":
                payment.PaymentType = Api.ViewModels.Enixer_Enumerations.EP_PaymentTypeEnum.Credit;
                ReceiptViewModel resultC = _service.AddPayment(payment);

                if (resultC != null)
                {
                    PopupNavigation.PushAsync(new Error(new ErrorViewModel("Payment Completed", 3)));
                    Application.Current.MainPage.Navigation.PushAsync(new ReceiptPage(this));
                }
                else
                {
                    Application.Current.MainPage.DisplayAlert("Payment Error", "Payment not completed please try again.", "Ok");
                }
                break;

            case "Wallet":
                Int32 unixTimestamp        = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                GeneratePaymentModel model = new GeneratePaymentModel()
                {
                    Amount               = TotalPrice,
                    AccountNumber        = App.AccountNumber,
                    FirstName            = App.StoreName,
                    TransactionReference = unixTimestamp.ToString() + App.User,
                };
                QrValue = JsonConvert.SerializeObject(model);
                await PopupNavigation.PushAsync(new QrPage(this));

                await Task.Delay(2000);

                PollCode(unixTimestamp.ToString() + App.User);
                break;

            default:
                break;
            }
        }