public void WhenPaymentMessageReceivedWithRecipientUriUnRegisteredMobileNumberMessageCountIs1() { _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 = "2578"; 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 message = _messageService.AddMessage(application.ApiKey.ToString(), sender.MobileNumber, "804-350-9542", senderAccount.Id.ToString(), 10.00, "Test Payment", "Payment", securityPin); Assert.AreEqual(_ctx.Messages.Count(), 1); }
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 ActionResult EditPayment(int MemberPaidId) { GetStatusUser(); var svPaymentAccount = new PaymentAccountService(); var svOrder = new OrderService(); var Order = svOrder.SelectData <b2bOrder>(" * ", "MemberPaidID = " + MemberPaidId).First(); var PaymentAccount = svPaymentAccount.SelectData <b2bPaymentAccount>(" * ").First(); var MemberPaid = svOrder.SelectData <b2bMemberPaid>(" * ", "MemberPaidID = " + MemberPaidId + " AND CompID = " + LogonCompID).First(); MemberPaid.PaymentDate = DataManager.ConvertToDateTime(MemberPaid.PaymentDate); var BankName = svOrder.SelectData <emBank>(" * ", "IsDelete = 0 AND BankID = " + PaymentAccount.BankID).First(); var ListBanks = svOrder.SelectData <emBank>(" * ", "IsDelete = 0", "BankName asc"); var Count = svOrder.CountData <b2bOrder>(" * ", "IsDelete = 0 AND OrderStatus = 'N' AND CompID = " + LogonCompID); ViewBag.Count = Count; ViewBag.Order = Order; ViewBag.PaymentAccount = PaymentAccount; ViewBag.MemberPaid = MemberPaid; ViewBag.NBank = BankName; ViewBag.Bank = ListBanks; return(View()); }
public ActionResult ManagePaymentAccounts(string userId) { PaymentAccountService service = new PaymentAccountService(); var payments = service.GetPaymentAccountsByUserId(userId); return(View(payments)); }
public ActionResult PaymentAccountInfo(string paymentAccountId) { PaymentAccountService service = new PaymentAccountService(); var paymentAccount = service.GetPaymentAccountById(paymentAccountId); return(View(paymentAccount)); }
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); }
public ActionResult ViewPaymentAccounts() { PaymentAccountService service = new PaymentAccountService(); var accounts = service.GetPaymentAccountsByUserId(User.Identity.GetUserId()); return(View(accounts)); }
public ActionResult SortPaymentAccountsByBalance() { PaymentAccountService service = new PaymentAccountService(); var sortedAccounts = service.GetPaymentAccountsSortedByBalanceByUserId(User.Identity.GetUserId()); return(View("ViewPaymentAccounts", sortedAccounts)); }
public ActionResult BackPayment(int MemberPaidID, int OrderID) { var svOrder = new OrderService(); try { svOrder.BackPayment(MemberPaidID); } catch (Exception ex) { CreateLogFiles(ex); } GetStatusUser(); var svPaymentAccount = new PaymentAccountService(); var PaymentAccount = svPaymentAccount.SelectData <b2bPaymentAccount>(" * ").First(); var Order = svOrder.SelectData <b2bOrder>(" * ", "OrderID = " + OrderID + " AND CompID = " + LogonCompID).First(); var NBank = svOrder.SelectData <emBank>(" * ", "IsDelete = 0 AND BankID = " + PaymentAccount.BankID).First(); var Bank = svOrder.SelectData <emBank>(" * ", "IsDelete = 0", "BankName asc"); var Count = svOrder.CountData <b2bOrder>(" * ", "IsDelete = 0 AND OrderStatus = 'N' AND CompID = " + LogonCompID); ViewBag.Count = Count; ViewBag.PaymentAccount = PaymentAccount; ViewBag.Order = Order; ViewBag.NBank = NBank; ViewBag.Bank = Bank; return(Json(new { IsResult = svOrder.IsResult, MsgError = "" })); }
public ActionResult CreatePaymentAccount(string accountId) { PaymentAccountService service = new PaymentAccountService(); var account = service.CreatePaymentAccount(User.Identity.GetUserId()); return(View(account)); }
public ActionResult BlockPaymentAccount(string accountId) { PaymentAccountService service = new PaymentAccountService(); service.Block(accountId); return(RedirectToAction("ViewPaymentAccounts")); }
public ActionResult ReplenishPaymentAccount(ReplenishAccountViewModel model) { PaymentAccountService service = new PaymentAccountService(); service.Replenish(model.PaymentAccount.User.Id, model.Amount); return(RedirectToAction("ViewPaymentAccounts")); }
public ActionResult ReplenishPaymentAccount(string accountId) { PaymentAccountService service = new PaymentAccountService(); ViewBag.Account = service.GetPaymentAccountById(accountId); return(View()); }
public ActionResult BlockPaymentAccount(string accountId) { PaymentAccountService service = new PaymentAccountService(); service.Block(accountId); var id = service.GetPaymentAccountById(accountId).User.Id; return(RedirectToAction("ManagePaymentAccounts", new { userId = id })); }
public ActionResult UnblockPaymentAccount(string accountId) { PaymentAccountService service = new PaymentAccountService(); service.SetOnUnblocking(accountId); var account = service.GetPaymentAccountById(accountId); return(View("PaymentAccountInfo", account)); }
public ActionResult MakePayment() { PaymentAccountService service = new PaymentAccountService(); var paymentAccounts = service.GetPaymentAccountsByUserId(User.Identity.GetUserId()) .Select(a => new SelectListItem { Value = a.Id.ToString(), Text = a.AccountName }); return(View(new MakePaymentViewModel { PaymentAccounts = paymentAccounts })); }
public ActionResult UnblockPaymentAccount(string accountId) { PaymentAccountService service = new PaymentAccountService(); if (service.GetPaymentAccountById(accountId).OnUnblocking) { ViewBag.OnUnblocking = true; } service.Unblock(accountId); var id = service.GetPaymentAccountById(accountId).User.Id; return(RedirectToAction("ManagePaymentAccounts", new { userId = id })); }
public ActionResult MakePayment(MakePaymentViewModel model) { if (ModelState.IsValid) { PaymentAccountService service = new PaymentAccountService(); var paymentAccount = service.GetPaymentAccountById(model.PaymentAccountId); PaymentService paymentService = new PaymentService(); paymentService.Create(model.Amount, model.PaymentAccountId); var accounts = service.GetPaymentAccountsByUserId(User.Identity.GetUserId()); var payments = paymentService.GetPaymentsByUserId(User.Identity.GetUserId()); } return(RedirectToAction("Index", "Manage")); }
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 ActionResult Payment(int OrderID) { GetStatusUser(); var svPaymentAccount = new PaymentAccountService(); var svOrder = new OrderService(); var PaymentAccount = svPaymentAccount.SelectData <b2bPaymentAccount>(" * ").First(); var Order = svOrder.SelectData <b2bOrder>(" * ", "OrderID = " + OrderID + " AND CompID = " + LogonCompID).First(); var NBank = svOrder.SelectData <emBank>(" * ", "IsDelete = 0 AND BankID = " + PaymentAccount.BankID).First(); var Bank = svOrder.SelectData <emBank>(" * ", "IsDelete = 0", "BankName asc"); var Count = svOrder.CountData <b2bOrder>(" * ", "IsDelete = 0 AND OrderStatus = 'N' AND CompID = " + LogonCompID); ViewBag.Count = Count; ViewBag.PaymentAccount = PaymentAccount; ViewBag.Order = Order; ViewBag.NBank = NBank; ViewBag.Bank = Bank; return(View()); }
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); }
public ActionResult Summary(List <int> PackageID, List <int> Qty, List <bool> Package) { #region Using Service var svPaymentAcc = new PaymentAccountService(); var svCompany = new CompanyService(); var svPackage = new PackageService(); var svOrder = new OrderService(); #endregion #region Set Variable var model = new b2bOrder(); var OrderDetails = new List <b2bOrderDetail>(); var OrderNumber = 1; decimal OrderTotalPrice = 0; #endregion #region Set Model Order Detail for (var i = 0; i < Package.Count(); i++) { if (Package[i] == true) { var GetPackage = svPackage.SelectData <b2bPackage>(" PackageID,Price ", " PackageID = " + PackageID[i]).First(); #region วน Add Package เข้า List Order Detail ตามจำนวน ที่สั่งซื้อ for (var x = 1; x <= Qty[i]; x++) { var detail = new b2bOrderDetail(); detail.OrderType = 1; detail.PackageID = PackageID[i]; detail.RowFlag = 1; detail.IsDelete = true; detail.OrderDetailCode = AutoGenCode(CreateOrderDetialCode((int)PackageID[i]), OrderNumber); OrderNumber++; OrderDetails.Add(detail); } #endregion OrderTotalPrice += ((decimal)GetPackage.Price * Qty[i]); } } #endregion #region Set Model Order model.CompID = LogonCompID; model.OrderStatus = "C"; model.RowFlag = 1; model.IsDelete = true; model.TotalPrice = OrderTotalPrice; #endregion #region InsertOrder svOrder.InsertOrder(model, OrderDetails); #endregion #region Set ViewBag ViewBag.OrderID = model.OrderID; var Company = svCompany.SelectData <view_Company>(" * ", " CompID = " + LogonCompID).First(); ViewBag.Company = Company; //var PaymentAccounts = svPaymentAcc.SelectData<View_PaymentAccount>(" PaymentAccID, BankID, AccName, AccNo, BranchName, PaymentTypeID, BankName, LogoImgPath, PaymentTypeName", ""); //ViewBag.PaymentAccounts = PaymentAccounts; CommonService svCommon = new CommonService(); ViewBag.EnumServiceType = svCommon.SelectEnum(CommonService.EnumType.SearchByServiceType); #endregion ViewBag.EnumServiceType = svCommon.SelectEnum(CommonService.EnumType.SearchByServiceType); GetStatusUser(); return(View()); }
public void WhenBatching5TransactionsWithOpenBatchTransactionsInBatchIs5() { 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 }; var transaction4 = new Domain.Transaction() { Amount = 4, 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 }; var transaction5 = new Domain.Transaction() { Amount = 5, 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, transaction4, transaction5 }); var transactionBatch = transactionBatchService.GetOpenBatch(); Assert.AreEqual(5, transactionBatch.Transactions.Count); Assert.AreEqual(3, transactionBatch.TotalNumberOfDeposits); Assert.AreEqual(2, transactionBatch.TotalNumberOfWithdrawals); }