public void ReturnSuccessStateTransferWhenCallCredit()
        {
            uint amountToBeDebited = 100;
            var  creditBankAccount = new CreditBankAccount(300);

            var actualState = creditBankAccount.Credit(amountToBeDebited);

            actualState.ShouldBe(StateTransfer.Success);
        }
        public void AddAmountToSoldWhenCallCredit()
        {
            uint expectedSold      = 400;
            uint amountToBeDebited = 100;
            var  creditBankAccount = new CreditBankAccount(300);

            creditBankAccount.Credit(amountToBeDebited);

            creditBankAccount.Sold.ShouldBe(expectedSold);
        }
Esempio n. 3
0
        private static void TestWithdrawal()
        {
            List <BankAccount> accounts = new List <BankAccount>();

            BankAccount accountA = new CreditBankAccount("USD", -1000);

            accountA.Deposit(500);
            BankAccount accountB = new CurrentBankAccount("USD");

            accountB.Deposit(1200);


            accounts.Add(accountA);
            accounts.Add(accountB);


            while (true)
            {
                Console.WriteLine("********************");
                Console.WriteLine("Please choose account:");
                for (int i = 0; i < accounts.Count; i++)
                {
                    Console.WriteLine("{0}: {1}", i + 1, accounts[i]);
                }
                if (int.TryParse(Console.ReadLine(), out int selectedIndex) &&
                    accounts.Count >= selectedIndex &&
                    selectedIndex > 0
                    )
                {
                    BankAccount selectedAccount = accounts[selectedIndex - 1];
                    Console.WriteLine("Select the amount to withdraw from this account: {0}", selectedAccount);

                    if (int.TryParse(Console.ReadLine(), out int amount))
                    {
                        selectedAccount.Withdraw(amount);

                        XmlSerializer serializer = new XmlSerializer(typeof(List <BankAccount>));
                        TextWriter    writer     = new StreamWriter("c:\\test\\bankaccounts.xml");

                        serializer.Serialize(writer, accounts);
                        writer.Close();

                        Console.WriteLine("Account after withdraw: {0}", selectedAccount);
                    }
                }
                else
                {
                    Console.WriteLine("Error. Please select one of the above");
                }
            }
        }
Esempio n. 4
0
        private static List <Customer> GenerateCustomers()
        {
            List <string> names = new List <string>
            {
                "John Lennon",
                "Paul McCartney",
                "Christiano Ronaldo",
                "Firas Hamdan"
            };

            Random rnd = new Random();

            List <Customer> customers = new List <Customer>();

            int id = 1;

            foreach (string name in names)
            {
                Customer customer = new Customer();
                customer.Id       = id;
                customer.FullName = name;
                customer.Accounts = new List <BankAccount>();
                customers.Add(customer);

                int numberOfAccounts = rnd.Next(2, 5);
                for (int i = 0; i < numberOfAccounts; i++)
                {
                    var isCredit = rnd.Next(0, 10) % 2 == 0;
                    var isDollar = rnd.Next(0, 10) % 2 == 0;
                    if (isCredit)
                    {
                        var limit       = rnd.Next(500, 1300) * (isDollar ? 1 : 1500);
                        var bankAccount = new CreditBankAccount(isDollar ? "USD" : "LBP", limit);
                        customer.Accounts.Add(bankAccount);
                    }
                    else
                    {
                        var bankAccount = new CurrentBankAccount(isDollar ? "USD" : "LBP");
                        customer.Accounts.Add(bankAccount);
                    }
                }

                id++;
            }

            return(customers);
        }
Esempio n. 5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var selectedAccount = (string)AccountTypeCombo.SelectedItem;

            if (selectedAccount == "Current")
            {
                BankAccount acc = new CurrentBankAccount(this.CurrerncyTxt.Text);
                _accounts.Add(acc);
                //this.AccountsList.ItemsSource = _accounts;
            }

            else if (selectedAccount == "Credit")
            {
                BankAccount acc = new CreditBankAccount(this.CurrerncyTxt.Text, int.Parse(LimitTxt.Text));
                _accounts.Add(acc);
                //this.AccountsList.ItemsSource = _accounts;
            }
        }
Esempio n. 6
0
 public ANetApiResponse TestCreditBankAccount()
 {
     return(CreditBankAccount.Run(apiLoginId, transactionKey, TransactionID));
 }
 public void GivenJAiUnCompteEpargneAvecUnSoldeDe(uint soldInitial)
 {
     this.creditBankAccount = new CreditBankAccount(soldInitial);
 }
Esempio n. 8
0
        private static void RunMethod(string methodName)
        {
            // These are default transaction keys.
            // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/
            string apiLoginId     = "5KP3u95bQpv";
            string transactionKey = "4Ktq966gC55GAX7S";

            string transactionAmount;
            string transactionId = string.Empty;

            switch (methodName)
            {
            case "ValidateCustomerPaymentProfile":
                ValidateCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "UpdateCustomerShippingAddress":
                UpdateCustomerShippingAddress.Run(apiLoginId, transactionKey);
                break;

            case "UpdateCustomerProfile":
                UpdateCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "UpdateCustomerPaymentProfile":
                UpdateCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "GetCustomerShippingAddress":
                GetCustomerShippingAddress.Run(apiLoginId, transactionKey);
                break;

            case "GetCustomerProfileIds":
                GetCustomerProfileIds.Run(apiLoginId, transactionKey);
                break;

            case "GetCustomerProfile":
                GetCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "GetCustomerPaymentProfile":
                GetCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "DeleteCustomerShippingAddress":
                DeleteCustomerShippingAddress.Run(apiLoginId, transactionKey);
                break;

            case "DeleteCustomerProfile":
                DeleteCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "DeleteCustomerPaymentProfile":
                DeleteCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerShippingAddress":
                CreateCustomerShippingAddress.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerProfileFromTransaction":
                CreateCustomerProfileFromTransaction.Run(apiLoginId, transactionKey);
                break;

            case "GetTransactionDetails":
                GetTransactionDetails.Run(apiLoginId, transactionKey);
                break;

            case "GetTransactionList":
                GetTransactionList.Run(apiLoginId, transactionKey);
                break;

            //case "CreateAnApplePayTransaction":
            //    CreateAnApplePayTransaction.Run(apiLoginId, transactionKey);
            //    break;
            case "DecryptVisaCheckoutData":
                DecryptVisaCheckoutData.Run(apiLoginId, transactionKey);
                break;

            case "CreateVisaCheckoutTransaction":
                CreateVisaCheckoutTransaction.Run(apiLoginId, transactionKey);
                break;

            case "ChargeCreditCard":
                ChargeCreditCard.Run(apiLoginId, transactionKey);
                break;

            case "CaptureOnly":
                CaptureOnly.Run(apiLoginId, transactionKey);
                break;

            case "CapturePreviouslyAuthorizedAmount":
                Console.WriteLine("Enter An Transaction Amount");
                transactionAmount = Console.ReadLine();

                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                CapturePreviouslyAuthorizedAmount.Run(apiLoginId, transactionKey, Convert.ToDecimal(transactionAmount), transactionId);
                break;

            case "CaptureFundsAuthorizedThroughAnotherChannel":
                CaptureFundsAuthorizedThroughAnotherChannel.Run(apiLoginId, transactionKey);
                break;

            case "AuthorizeCreditCard":
                AuthorizeCreditCard.Run(apiLoginId, transactionKey);
                break;

            case "Refund":
                Console.WriteLine("Enter An Transaction Amount");
                transactionAmount = Console.ReadLine();

                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                RefundTransaction.Run(apiLoginId, transactionKey, Convert.ToDecimal(transactionAmount), transactionId);
                break;

            case "Void":
                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                VoidTransaction.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "DebitBankAccount":
                DebitBankAccount.Run(apiLoginId, transactionKey);
                break;

            case "CreditBankAccount":
                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                CreditBankAccount.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "ChargeCustomerProfile":
                ChargeCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "ChargeTokenizedCard":
                ChargeTokenizedCreditCard.Run(apiLoginId, transactionKey);
                break;

            case "PayPalVoid":
                PayPalVoid.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalAuthorizeCapture":
                PayPalAuthorizeCapture.Run(apiLoginId, transactionKey);
                break;

            case "PayPalAuthorizeCaptureContinue":
                PayPalAuthorizeCaptureContinue.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalAuthorizeOnly":
                PayPalAuthorizeOnly.Run(apiLoginId, transactionKey);
                break;

            case "PayPalAuthorizeOnlyContinue":
                PayPalAuthorizeCaptureContinue.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalCredit":
                PayPalCredit.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalGetDetails":
                PayPalGetDetails.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalPriorAuthorizationCapture":
                PayPalPriorAuthorizationCapture.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "CancelSubscription":
                CancelSubscription.Run(apiLoginId, transactionKey);
                break;

            case "CreateSubscription":
                CreateSubscription.Run(apiLoginId, transactionKey);
                break;

            case "GetSubscriptionList":
                GetListSubscriptions.Run(apiLoginId, transactionKey);
                break;

            case "GetSubscriptionStatus":
                GetSubscriptionStatus.Run(apiLoginId, transactionKey);
                break;

            case "UpdateSubscription":
                UpdateSubscription.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerProfile":
                CreateCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerPaymentProfile":
                CreateCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "GetUnsettledTransactionList":
                GetUnsettledTransactionList.Run(apiLoginId, transactionKey);
                break;

            case "GetBatchStatistics":
                GetBatchStatistics.Run(apiLoginId, transactionKey);
                break;

            case "GetSettledBatchList":
                GetSettledBatchList.Run(apiLoginId, transactionKey);
                break;

            default:
                ShowUsage();
                break;
            }
        }