Example #1
0
        /// <summary>
        /// Attempt to pay with credit
        /// </summary>
        /// <param name="sender">Sending object</param>
        /// <param name="e">Event arguments</param>
        private void OnPayWithCredit(object sender, RoutedEventArgs e)
        {
            CardTerminal cardTerminal = new CardTerminal();

            ResultCode code = cardTerminal.ProcessTransaction(Transaction.Total);

            switch (code)
            {
            case ResultCode.Success:
                Transaction.PaymentMethod = PaymentMethod.Credit;
                Transaction.AmountPaid    = Transaction.Total;
                MessageBox.Text           = "";
                FinishTransaction();
                break;

            case ResultCode.CancelledCard:
                MessageBox.Text = "Error: Cancelled Card";
                break;

            case ResultCode.InsufficentFunds:
                MessageBox.Text = "Error: Insufficent Funds";
                break;

            case ResultCode.ReadError:
                MessageBox.Text = "Error: Read Error";
                break;

            case ResultCode.UnknownErrror:
                MessageBox.Text = "Error: Unknown Error";
                break;
            }
        }
Example #2
0
        /* HAHAHAHAHAHA going below here is confusing. I do alot of jumping through switch cases. If you go past here
         *  take your time to read line by line and follow the jumps. Its the only way you'll make it though :) */


        /// <summary>
        /// The consumer is wanting to pay by card
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PaybyCardButton_Click(object sender, RoutedEventArgs e)
        {
            CardTerminal ct = new CardTerminal();
            ResultCode   rc = ct.ProcessTransaction(TotalWithTax);

            switch (rc)
            {
            case ResultCode.Success:
                PrintReceipt(0);
                break;

            case ResultCode.InsufficentFunds:
                MessageBox.Show("Error: No funds on card\n\tPlease try swiping card again");
                ErrorText.Text = "Error: No funds";
                break;

            case ResultCode.CancelledCard:
                MessageBox.Show("Error: Cancelled Card\n\tPlease try swiping card again");
                ErrorText.Text = "Error: Card Cancelled";
                break;

            case ResultCode.ReadError:
                MessageBox.Show("Error: Card Read Error\n\tPlease try swiping card again");
                ErrorText.Text = "Error: Read Error";
                break;

            case ResultCode.UnknownErrror:
                MessageBox.Show("Error: Unknown Error\n\tPlease try swiping card again");
                ErrorText.Text = "Error: Unknown";
                break;

            default:
                throw new NotImplementedException("Should never be reached");
            }
        }
        private void CardPayment(object sender, RoutedEventArgs e)
        {
            var oc = this.FindAncestor<OrderControl>();
            if(oc.DataContext is Order order)
            {
                var reader = new CardTerminal();
                var printer = new ReceiptPrinter();
                var result = reader.ProcessTransaction(order.Total);

                switch (result)
                {
                    case ResultCode.Success:
                        Display.Text = "Success.";
                        printer.Print(CreateCardReceipt(order));
                        oc.SwapScreen(new MenuItemSelectionControl());
                        oc.DataContext = new Order();
                        break;

                    case ResultCode.CancelledCard:
                    case ResultCode.InsufficentFunds:
                    case ResultCode.ReadError:
                    case ResultCode.UnknownErrror:
                        string r = result.ToString();
                        Display.Text = r;
                        oc.SwapScreen(new TransactionControl());
                        break;
                }
            }
        }
 public void FillOutCertaintyApprovalAuto(string customerPostCode, string day, string month, string year, string industryType, string creditAmount, string cardProvider)
 {
     CompanyAddress.EnterAutoAddress(customerPostCode);
     EnterDOB.FillDOB(day, month, year);
     YourIndustry.SelectDirectorCompany(industryType);
     CardTerminal.SetCreditAmount(creditAmount, cardProvider);
     _seeCertainty.Click();
 }
 public void FillOutCertaintyApproval(string customerAddress1, string customerCity, string customerPostcode, string day, string month, string year, string industryType, string creditAmount, string cardProvider)
 {
     _bizAddress.SendText(Keys.Tab);
     CompanyAddress.EnterManualAddress(customerAddress1, customerCity, customerPostcode);
     EnterDOB.FillDOB(day, month, year);
     YourIndustry.SelectDirectorCompany(industryType);
     CardTerminal.SetCreditAmount(creditAmount, cardProvider);
     _seeCertainty.Click();
 }
Example #6
0
        /// <summary>
        /// Sends inputted payment value to charge the card.
        /// </summary>
        /// <param name="sender">Button</param>
        /// <param name="e">Event arguments</param>
        void onSendClick(object sender, RoutedEventArgs e)
        {
            if (DataContext is Order order)
            {
                if (sender is Button button)
                {
                    if (inputValue > order.Owed)
                    {
                        errorDisplay("OVERCHARGE");
                    }
                    else
                    {
                        var terminal    = new CardTerminal();
                        var swipeResult = terminal.ProcessTransaction(inputValue);
                        switch (swipeResult)
                        {
                        case ResultCode.Success:
                            order.Paid += inputValue;
                            printer.Print(order.FormatCardReceipt());
                            DisplayAmountOwed();
                            break;

                        case ResultCode.ReadError:
                            errorDisplay("READ ERROR");
                            break;

                        case ResultCode.InsufficentFunds:
                            errorDisplay("INSUFFICIENT FUNDS");
                            break;

                        case ResultCode.CancelledCard:
                            errorDisplay("CANCELLED CARD");
                            break;

                        case ResultCode.UnknownErrror:
                            errorDisplay("UNKNOWN ERROR");
                            break;
                        }
                    }
                }
            }
        }
Example #7
0
        void onPayWithCardButtonClicked(object sender, RoutedEventArgs e)
        {
            CardTerminal cardTerminal = new CardTerminal();

            if (DataContext is Order order)
            {
                ResultCode resultCode = cardTerminal.ProcessTransaction(order.total);

                switch (resultCode)
                {
                case ResultCode.Success:
                    PrintRecipt();
                    MessageBox.Show("Transaction Complete!");
                    SwapScreenOrderControl();
                    break;

                default:
                    MessageBox.Show(resultCode.ToString());
                    break;
                }
            }
        }