Example #1
0
        public void Execute(string id)
        {
            Domain.PaymentAccount paymentAccount = _paymentAccountService.GetPaymentAccount(id);

            _logger.Log(LogLevel.Info, String.Format("Processing Payment Account {0} with Status {1}", paymentAccount.Id, paymentAccount.AccountStatus.ToString()));
            switch (paymentAccount.AccountStatus)
            {
            case Domain.AccountStatusType.Submitted:

                SubmittedPaymentAccountProcessor processor = new SubmittedPaymentAccountProcessor(_ctx, _emailService);

                processor.Process(paymentAccount);

                break;
            }
            _logger.Log(LogLevel.Info, String.Format("Finished Processing Payment Account {0} with Status {1}", paymentAccount.Id, paymentAccount.AccountStatus.ToString()));
        }
        public void WhenPendingPaymentMessageWithEmailAddressRecipientUriProcessedWithKnownRecipientTwoTransactionsAreCreated()
        {
            Guid messageId = Guid.NewGuid();
            Guid apiKey = Guid.NewGuid();
            Guid senderId = Guid.NewGuid();
            Guid senderAccountId = Guid.NewGuid();

            _ctx = new FakeDbContext();

            var application = _ctx.Applications.Add(new Domain.Application()
            {
                ApiKey = apiKey,
                ApplicationName = "Test App",
                IsActive = true,
                Url = "http:\\test.paidthx.com"
            });

            var sender = _ctx.Users.Add(new Domain.User()
            {
                Application = application,
                ApiKey = apiKey,
                CreateDate = System.DateTime.Now,
                EmailAddress = "*****@*****.**",
                Limit = 100,
                MobileNumber = "7082504915",
                Password = "******",
                PaymentAccounts = new System.Collections.ObjectModel.Collection<Domain.PaymentAccount>(),
                IsConfirmed = true,
                SecurityPin = "1234",
                SetupPassword = true,
                SetupSecurityPin = true,
                UserStatus = Domain.UserStatus.Verified,
                DeviceToken = "6b0bf548627aecffe1a87b3febf62c9f6eda50c35b6acce067a21b365dcc94b4"
            });

            var recipient = _ctx.Users.Add(new Domain.User()
            {
                Application = application,
                ApiKey = apiKey,
                CreateDate = System.DateTime.Now,
                EmailAddress = "*****@*****.**",
                Limit = 100,
                MobileNumber = "8043879693",
                Password = "******",
                PaymentAccounts = new System.Collections.ObjectModel.Collection<Domain.PaymentAccount>(),
                IsConfirmed = true,
                SecurityPin = "1234",
                SetupPassword = true,
                SetupSecurityPin = true,
                UserStatus = Domain.UserStatus.Verified,
                DeviceToken = "6b0bf548627aecffe1a87b3febf62c9f6eda50c35b6acce067a21b365dcc94b4"
            });

            _ctx.SaveChanges();

            var senderAccount = new Domain.PaymentAccount()
            {
                AccountNumber = "1234123412",
                AccountType = Domain.PaymentAccountType.Checking,
                IsActive = true,
                CreateDate = System.DateTime.Now,
                Id = senderAccountId,
                NameOnAccount = "Chris Magee",
                RoutingNumber = "053000219",
            };

            var recipientAccount = new Domain.PaymentAccount()
            {
                AccountNumber = "1010202030",
                AccountType = Domain.PaymentAccountType.Savings,
                IsActive = true,
                CreateDate = System.DateTime.Now,
                Id = senderAccountId,
                NameOnAccount = "Chris Magee",
                RoutingNumber = "053000211",
            };

            sender.PaymentAccounts.Add(senderAccount);
            recipient.PaymentAccounts.Add(recipientAccount);

            _ctx.SaveChanges();

            var message = _ctx.Messages.Add(new Domain.Message()
            {
                Amount = 1,
                Application = application,
                ApiKey = apiKey,
                Comments = "Test Payment",
                CreateDate = System.DateTime.Now,
                Id = messageId,
                MessageStatus = Domain.MessageStatus.Pending,
                MessageType = Domain.MessageType.Payment,
                RecipientUri = "*****@*****.**",
                Sender = sender,
                SenderId = senderId,
                SenderAccount = senderAccount,
                SenderAccountId = senderAccountId,
                SenderUri = "7082504915",
                Transactions = new System.Collections.ObjectModel.Collection<Domain.Transaction>(),
            });

            _ctx.SaveChanges();

            SubmittedPaymentMessageProcessor processor = new SubmittedPaymentMessageProcessor(_ctx);

            processor.Process(message);

            Assert.AreEqual(2, _ctx.Transactions.Count());
        }
Example #3
0
        public void WhenPendingPaymentMessageWithMobileNumberRecipientUriProcessedWithUnknownRecipientOneTransactionIsCreated()
        {
            Guid messageId       = Guid.NewGuid();
            Guid apiKey          = Guid.NewGuid();
            Guid senderId        = Guid.NewGuid();
            Guid senderAccountId = Guid.NewGuid();

            _ctx = new FakeDbContext();

            var application = _ctx.Applications.Add(new Domain.Application()
            {
                ApiKey          = apiKey,
                ApplicationName = "Test App",
                IsActive        = true,
                Url             = "http:\\test.paidthx.com"
            });

            var sender = _ctx.Users.Add(new Domain.User()
            {
                Application      = application,
                ApiKey           = apiKey,
                CreateDate       = System.DateTime.Now,
                EmailAddress     = "*****@*****.**",
                Limit            = 100,
                MobileNumber     = "7082504915",
                Password         = "******",
                PaymentAccounts  = new System.Collections.ObjectModel.Collection <Domain.PaymentAccount>(),
                IsConfirmed      = true,
                SecurityPin      = "1234",
                SetupPassword    = true,
                SetupSecurityPin = true,
                UserStatus       = Domain.UserStatus.Verified,
                DeviceToken      = "6b0bf548627aecffe1a87b3febf62c9f6eda50c35b6acce067a21b365dcc94b4"
            });

            _ctx.SaveChanges();

            var senderAccount = new Domain.PaymentAccount()
            {
                AccountNumber = "1234123412",
                AccountType   = Domain.PaymentAccountType.Checking,
                IsActive      = true,
                CreateDate    = System.DateTime.Now,
                Id            = senderAccountId,
                NameOnAccount = "Chris Magee",
                RoutingNumber = "053000219",
            };

            sender.PaymentAccounts.Add(senderAccount);

            _ctx.SaveChanges();

            var message = _ctx.Messages.Add(new Domain.Message()
            {
                Amount          = 1,
                Application     = application,
                ApiKey          = apiKey,
                Comments        = "Test Payment",
                CreateDate      = System.DateTime.Now,
                Id              = messageId,
                MessageStatus   = Domain.MessageStatus.Pending,
                MessageType     = Domain.MessageType.Payment,
                RecipientUri    = "7082504915",
                Sender          = sender,
                SenderId        = senderId,
                SenderAccount   = senderAccount,
                SenderAccountId = senderAccountId,
                SenderUri       = "7082504915",
                Transactions    = new System.Collections.ObjectModel.Collection <Domain.Transaction>()
            });

            _ctx.SaveChanges();

            SubmittedPaymentMessageProcessor processor = new SubmittedPaymentMessageProcessor(_ctx);

            processor.Process(message);

            Assert.AreEqual(1, _ctx.Transactions.Count());
        }
        public void WhenPendingPaymentMessageWithEmailAddressRecipientUriProcessedWithUnknownRecipientOneTransactionIsCreated()
        {
            Guid messageId = Guid.NewGuid();
            Guid apiKey = Guid.NewGuid();
            Guid senderId = Guid.NewGuid();
            Guid senderAccountId = Guid.NewGuid();

            _ctx = new FakeDbContext();

            var application = _ctx.Applications.Add(new Domain.Application()
            {
                ApiKey = apiKey,
                ApplicationName = "Test App",
                IsActive = true,
                Url = "http:\\test.paidthx.com"
            });

            var sender = _ctx.Users.Add(new Domain.User()
            {
                Application = application,
                ApiKey = apiKey,
                CreateDate = System.DateTime.Now,
                EmailAddress = "*****@*****.**",
                Limit = 100,
                MobileNumber = "7082504915",
                Password = "******",
                PaymentAccounts = new System.Collections.ObjectModel.Collection<Domain.PaymentAccount>(),
                IsConfirmed = true,
                SecurityPin = "1234",
                SetupPassword = true,
                SetupSecurityPin = true,
                UserStatus = Domain.UserStatus.Verified
            });

            _ctx.SaveChanges();

            var senderAccount = new Domain.PaymentAccount()
            {
                AccountNumber = "1234123412",
                AccountType = Domain.PaymentAccountType.Checking,
                IsActive = true,
                CreateDate = System.DateTime.Now,
                Id = senderAccountId,
                NameOnAccount = "Chris Magee",
                RoutingNumber = "053000219",
            };

            sender.PaymentAccounts.Add(senderAccount);

            _ctx.SaveChanges();

            var message = _ctx.Messages.Add(new Domain.Message()
            {
                Amount = 4,
                Application = application,
                ApiKey = apiKey,
                Comments = "Test Payment",
                CreateDate = System.DateTime.Now,
                Id = messageId,
                MessageStatus = Domain.MessageStatus.Pending,
                MessageType = Domain.MessageType.Payment,
                RecipientUri = "*****@*****.**",
                Sender = sender,
                SenderId = senderId,
                SenderAccount = senderAccount,
                SenderAccountId = senderAccountId,
                SenderUri = "7082504915",
                Transactions = new System.Collections.ObjectModel.Collection<Domain.Transaction>()
            });

            _ctx.SaveChanges();

            SubmittedPaymentMessageProcessor processor = new SubmittedPaymentMessageProcessor(_ctx);

            processor.Process(message);

            Assert.AreEqual(1, _ctx.Transactions.Count());
        }