Ejemplo n.º 1
0
        public void WhenPaymentMessageReceivedWithRecipientUriRegisteredMeCodeMessageCountIs1()
        {
            _userService = new UserService(_ctx);
            _messageService = new MessageServices(_ctx);
            _paymentAccountService = new PaymentAccountService(_ctx);

            var application = _ctx.Applications.Add(new Application()
            {
                ApiKey = Guid.NewGuid(),
                ApplicationName = "Test",
                IsActive = true,
                Url = "http://www.test.com"
            });

            var securityPin = "2589";

            var sender = _userService.AddUser(application.ApiKey, "*****@*****.**",
                "james123", "*****@*****.**", "");

            sender.MobileNumber = "804-387-9693";
            _userService.UpdateUser(sender);

            var senderAccount = _paymentAccountService.AddPaymentAccount(sender.UserId.ToString(), "James G Rhodes", "053000219",
                "1234123412", "Checking");

            sender.PaymentAccounts = new System.Collections.ObjectModel.Collection<PaymentAccount>();
            sender.PaymentAccounts.Add(senderAccount);

            var recipient = _userService.AddUser(application.ApiKey, "*****@*****.**",
                "james123", "*****@*****.**", "");

            var recipientAccount = _paymentAccountService.AddPaymentAccount(sender.UserId.ToString(), "James G Rhodes", "053000219",
                "1234123412", "Checking");

            recipient.PaymentAccounts = new System.Collections.ObjectModel.Collection<PaymentAccount>();
            recipient.PaymentAccounts.Add(recipientAccount);

            var meCodeValue = "$therealjamesrhodes";

            var meCode = _ctx.MECodes.Add(
                new MECode()
                {
                    ApprovedDate = System.DateTime.Now,
                    CreateDate = System.DateTime.Now,
                    Id = Guid.NewGuid(),
                    IsActive = true,
                    IsApproved = true,
                    LastUpdatedDate = System.DateTime.Now,
                    MeCode = meCodeValue,
                    UserId = recipient.UserId
                });

            sender.SecurityPin = securityPin;
            _userService.UpdateUser(sender);

            var message = _messageService.AddMessage(application.ApiKey.ToString(), sender.MobileNumber, "$therealjamesrhodes", senderAccount.Id.ToString(),
                10.00, "Test Payment", "Payment", securityPin);

            Assert.AreEqual(_ctx.Messages.Count(), 1);
        }
Ejemplo n.º 2
0
        public void WhenNewAccountIsAddedPaymentVerificationDepositAmountsAreDifferent()
        {
            _ctx = new FakeDbContext();

            UserService userService = new UserService(_ctx);
            IEmailService emailService = null;
            PaymentAccountService paymentAccountService = new PaymentAccountService(_ctx);
            SubmittedPaymentAccountProcessor processor = new SubmittedPaymentAccountProcessor(_ctx, emailService);

            Guid userId = Guid.NewGuid();

            var user = userService.AddUser(userId, "jrhodes621", "james123", "*****@*****.**", "1234");
            var paymentAccount = paymentAccountService.AddPaymentAccount(userId.ToString(), "James G Rhodes", "053000219", "1234123412",
                "Checking");

            processor.Process(paymentAccount);

            var paymentAccountVerification = _ctx.PaymentAccountVerifications.ElementAt(0);

            Assert.AreNotEqual(paymentAccountVerification.DepositAmount1, paymentAccountVerification.DepositAmount2);
        }
Ejemplo n.º 3
0
        public void WhenPaymentMessageReceivedWithRecipientUriUnKnownMeCodeArgumentExceptionOccurs()
        {
            _userService = new UserService(_ctx);
            _messageService = new MessageServices(_ctx);
            _paymentAccountService = new PaymentAccountService(_ctx);

            var application = _ctx.Applications.Add(new Application()
            {
                ApiKey = Guid.NewGuid(),
                ApplicationName = "Test",
                IsActive = true,
                Url = "http://www.test.com"
            });

            var securityPin = "2589";

            var sender = _userService.AddUser(application.ApiKey, "*****@*****.**",
                "james123", "*****@*****.**", "");

            sender.MobileNumber = "804-387-9693";
            _userService.UpdateUser(sender);

            sender.SecurityPin = securityPin;
            _userService.UpdateUser(sender);

            var senderAccount = _paymentAccountService.AddPaymentAccount(sender.UserId.ToString(), "James G Rhodes", "053000219",
                "1234123412", "Checking");

            sender.PaymentAccounts = new System.Collections.ObjectModel.Collection<PaymentAccount>();
            sender.PaymentAccounts.Add(senderAccount);

            var recipient = _userService.AddUser(application.ApiKey, "*****@*****.**",
                "james123", "*****@*****.**", "");

            var recipientAccount = _paymentAccountService.AddPaymentAccount(sender.UserId.ToString(), "James G Rhodes", "053000219",
                "1234123412", "Checking");

            recipient.PaymentAccounts = new System.Collections.ObjectModel.Collection<PaymentAccount>();
            recipient.PaymentAccounts.Add(recipientAccount);

            var meCodeValue = "$therealjamesrhodes";

            var message = _messageService.AddMessage(application.ApiKey.ToString(), sender.MobileNumber, meCodeValue, senderAccount.Id.ToString(),
                10.00, "Test Payment", "Payment", securityPin);
        }
        public void WhenBatching3TransactionsWithOpenBatchTransactionsInBatchIs3()
        {
            ApplicationService applicationService = new ApplicationService(_ctx);
            MessageServices messageService = new MessageServices(_ctx);
            UserService userService = new UserService(_ctx);
            PaymentAccountService paymentAccountService = new PaymentAccountService(_ctx);
            TransactionBatchService transactionBatchService = new TransactionBatchService(_ctx, _logger);

            var transactionBatchGuid = Guid.NewGuid();
            var transactionAmount = 2.75;

            _ctx.TransactionBatches.Add(new TransactionBatch()
            {
                CreateDate = System.DateTime.Now,
                Id = transactionBatchGuid,
                IsClosed = true,
                TotalDepositAmount = 0,
                TotalNumberOfDeposits = 0,
                TotalWithdrawalAmount = 0,
                TotalNumberOfWithdrawals = 0,
                Transactions = new List<Transaction>()
            });
            _ctx.SaveChanges();

            var application = applicationService.AddApplication("Test", "http://www.test.com", true);
            var sender = userService.AddUser(application.ApiKey, "*****@*****.**", "pdthx123",
                "*****@*****.**", "1234");
            sender.SecurityPin = "2589";
            userService.UpdateUser(sender);

            var senderPaymentAccount = paymentAccountService.AddPaymentAccount(sender.UserId.ToString(), "Sender PaidThx",
                "053000219", "1234123412", "Checking");

            sender.PaymentAccounts = new System.Collections.ObjectModel.Collection<PaymentAccount>();
            sender.PaymentAccounts.Add(senderPaymentAccount);

            var transaction1 = new Domain.Transaction()
            {
                Amount = 1,
                Category = TransactionCategory.Payment,
                FromAccount = senderPaymentAccount,
                CreateDate = System.DateTime.Now,
                Id = Guid.NewGuid(),
                PaymentChannelType = PaymentChannelType.Single,
                StandardEntryClass = StandardEntryClass.Web,
                Status = TransactionStatus.Submitted,
                Type = TransactionType.Withdrawal,
                User = sender
            };
            var transaction2 = new Domain.Transaction()
            {
                Amount = 2,
                Category = TransactionCategory.Payment,
                FromAccount = senderPaymentAccount,
                CreateDate = System.DateTime.Now,
                Id = Guid.NewGuid(),
                PaymentChannelType = PaymentChannelType.Single,
                StandardEntryClass = StandardEntryClass.Web,
                Status = TransactionStatus.Submitted,
                Type = TransactionType.Withdrawal,
                User = sender
            };
            var transaction3 = new Domain.Transaction()
            {
                Amount = 3,
                Category = TransactionCategory.Payment,
                FromAccount = senderPaymentAccount,
                CreateDate = System.DateTime.Now,
                Id = Guid.NewGuid(),
                PaymentChannelType = PaymentChannelType.Single,
                StandardEntryClass = StandardEntryClass.Web,
                Status = TransactionStatus.Submitted,
                Type = TransactionType.Deposit,
                User = sender
            };

            transactionBatchService.BatchTransactions(new List<Transaction>()
            {
                transaction1,
                transaction2,
                transaction3
            });

            var transactionBatch = transactionBatchService.GetOpenBatch();

            Assert.AreEqual(3, transactionBatch.Transactions.Count);
            Assert.AreEqual(1, transactionBatch.TotalNumberOfDeposits);
            Assert.AreEqual(2, transactionBatch.TotalNumberOfWithdrawals);
        }
        public void WhenGettingOpenBatchWithNoOpenBatchesNewBatchIsCreated()
        {
            ApplicationService applicationService = new ApplicationService(_ctx);
            MessageServices messageService = new MessageServices(_ctx);
            UserService userService = new UserService(_ctx);
            PaymentAccountService paymentAccountService = new PaymentAccountService(_ctx);
            TransactionBatchService transactionBatchService = new TransactionBatchService(_ctx, _logger);

            var transactionBatchGuid = Guid.NewGuid();

            _ctx.TransactionBatches.Add(new TransactionBatch()
            {
                CreateDate = System.DateTime.Now,
                Id = transactionBatchGuid,
                IsClosed = true,
                TotalDepositAmount = 0,
                TotalNumberOfDeposits = 0,
                TotalWithdrawalAmount = 0,
                TotalNumberOfWithdrawals = 0,
                Transactions = new List<Transaction>()
            });

            var transactionBatch = transactionBatchService.GetOpenBatch();

            Assert.AreNotEqual(transactionBatchGuid, transactionBatch.Id);
        }
        public void WhenBatchingMessageWithOpenBatchWithWithdrawAndDepositTransactionThenTransactionsInBatchIs2()
        {
            ApplicationService applicationService = new ApplicationService(_ctx);
            MessageServices messageService = new MessageServices(_ctx);
            UserService userService = new UserService(_ctx);
            PaymentAccountService paymentAccountService = new PaymentAccountService(_ctx);
            TransactionBatchService transactionBatchService = new TransactionBatchService(_ctx, _logger);

            var transactionBatchGuid = Guid.NewGuid();
            var transactionAmount = 2.75;

            _ctx.TransactionBatches.Add(new TransactionBatch()
            {
                CreateDate = System.DateTime.Now,
                Id = transactionBatchGuid,
                IsClosed = false,
                TotalDepositAmount = 0,
                TotalNumberOfDeposits = 0,
                TotalWithdrawalAmount = 0,
                TotalNumberOfWithdrawals = 0,
                Transactions = new List<Transaction>()
            });
            _ctx.SaveChanges();

            var application = applicationService.AddApplication("Test", "http://www.test.com", true);
            var sender = userService.AddUser(application.ApiKey, "*****@*****.**", "pdthx123",
                "*****@*****.**", "1234");
            sender.SecurityPin = "2589";
            userService.UpdateUser(sender);

            var senderPaymentAccount = paymentAccountService.AddPaymentAccount(sender.UserId.ToString(), "Sender PaidThx",
                "053000219", "1234123412", "Checking");

            sender.PaymentAccounts = new System.Collections.ObjectModel.Collection<PaymentAccount>();
            sender.PaymentAccounts.Add(senderPaymentAccount);

            var recipient = userService.AddUser(application.ApiKey, "*****@*****.**", "pdthx123",
                "*****@*****.**", "1234");

            var recipientPaymentAccount = paymentAccountService.AddPaymentAccount(sender.UserId.ToString(), "Recipient PaidThx",
            "053000219", "1234123412", "Savings");

            recipient.PaymentAccounts = new System.Collections.ObjectModel.Collection<PaymentAccount>();
            recipient.PaymentAccounts.Add(recipientPaymentAccount);

            var message = messageService.AddMessage(application.ApiKey.ToString(), sender.EmailAddress, recipient.EmailAddress,
                senderPaymentAccount.Id.ToString(), transactionAmount, "Test Payment", "Payment", "2589");

            message.Recipient = userService.FindUserByEmailAddress(recipient.EmailAddress);

            transactionBatchService.BatchTransactions(message);

            var transactionBatch = transactionBatchService.GetOpenBatch();

            Assert.AreEqual(transactionBatchGuid, transactionBatch.Id);
            Assert.AreEqual(2, transactionBatch.Transactions.Count);
            Assert.AreEqual(1, transactionBatch.TotalNumberOfDeposits);
            Assert.AreEqual(1, transactionBatch.TotalNumberOfWithdrawals);
        }