예제 #1
0
 public bool Pay(ICard card, int pin, double amount, string currency)
 {
     if (isAvailableCard(card) && card.GetCardType().Equals(PhysicalCard.PHYSICAL) && isValidCard(card))
     {
         if (!card.IsBlocked() && card.CheckPin(pin))
         {
             return(takeMoneyFromAccountIfExists(amount, currency));
         }
     }
     return(false);
 }
예제 #2
0
 public bool PayOnline(ICard card, int pin, double amount, string currency, string shopURL)
 {
     if (!isShopURLBanned(shopURL))
     {
         if (isAvailableCard(card) && isValidCard(card))
         {
             if (!card.IsBlocked() && card.CheckPin(pin))
             {
                 if (card.GetCardType().Equals(VirtualOneTimeCard.VIRTUAL_ONE_TIME_CARD))
                 {
                     card.Block();
                 }
                 return(takeMoneyFromAccountIfExists(amount, currency));
             }
         }
     }
     return(false);
 }
예제 #3
0
        private void ShowInstanceMenu(ICard sendingCard)
        {
            bool showMenu = true;

            while (showMenu)
            {
                PrintCardOperations(sendingCard);
                bool converted = Int32.TryParse(Console.ReadLine(), out int input);

                if (converted)
                {
                    switch (input)
                    {
                    case 0:
                        showMenu = false;
                        break;

                    case 1:
                        Console.WriteLine("Type in your PIN code");
                        converted = Int32.TryParse(Console.ReadLine(), out int pin);

                        if (!sendingCard.CheckPin(pin))
                        {
                            TransactionResult(CardInfo.TransactionStatus.WrongPin);
                            break;
                        }

                        if (SendingMoney(sendingCard) == null)
                        {
                            TransactionResult(CardInfo.TransactionStatus.UnknownFailure);
                            break;
                        }

                        TransactionResult(SendingMoney(sendingCard).Status);

                        break;

                    case 2:
                        Console.WriteLine(sendingCard.GetBalance());
                        break;
                    }
                }
            }
        }