public object Put(AccountChargeRequest request) { var existing = _dao.FindByAccountNumber(request.AccountNumber); if (existing != null && existing.Id != request.Id) { throw new HttpError(HttpStatusCode.Conflict, ErrorCode.AccountCharge_AccountAlreadyExisting.ToString()); } var i = 0; foreach (var question in request.Questions) { question.Id = i++; question.AccountId = request.Id; } var addUpdateAccountCharge = new AddUpdateAccountCharge { AccountChargeId = request.Id, Name = request.Name, Number = request.AccountNumber, UseCardOnFileForPayment = request.UseCardOnFileForPayment, Questions = request.Questions, CompanyId = AppConstants.CompanyId }; _commandBus.Send(addUpdateAccountCharge); return(new { Id = addUpdateAccountCharge.AccountChargeId }); }
public void UpdatedAccountCharge() { var request = new AccountChargeRequest { Id = Guid.NewGuid(), Name = "1000", AccountNumber = "1000", Questions = new[] { new AccountChargeQuestion { Question = "Question?", Answer = "Answer" } } }; var account = _sut.GetAccountCharge(request.AccountNumber); if (account == null) { _sut.CreateAccountCharge(request); } request.Id = account.Id; request.Name = "VIP2"; _sut.UpdateAccountCharge(request); account = _sut.GetAccountCharge(request.AccountNumber); Assert.AreEqual(account.Name, request.Name); }
public async void ChargeBankAccount() { //Arrange var req = new AccountChargeRequest { User = new User { FirstName = "Vincent", LastName = "Nwonah", Email = "*****@*****.**", IP = "192.168.33.10", FingerPrint = "ddsdschhdghgshghdgshghcx" }, Account = new Account { AccountNumber = "0226197826", BankCode = "058" }, Amount = "100" }; //Act var res = await _gladepayService.PutAsync <AccountChargeRequest>(req); //Assert Assert.True(res.Data["message"].ToString() == "Error: This method is not avaialble in test mode"); Debug.WriteLine(res.Data); }
public object Delete(AccountChargeRequest request) { var existing = _dao.FindByAccountNumber(request.AccountNumber); if (existing == null) { throw new HttpError(HttpStatusCode.NotFound, "Account Not Found"); } var deleteAccountCharge = new DeleteAccountCharge { AccountChargeId = existing.Id, CompanyId = AppConstants.CompanyId }; _commandBus.Send(deleteAccountCharge); return(new HttpResult(HttpStatusCode.OK, "OK")); }
public void Add_Already_Existing_AccountCharge() { var request = new AccountChargeRequest { Id = Guid.NewGuid(), Name = "VIP", AccountNumber = "NUMBER" + new Random(DateTime.Now.Millisecond).Next(0, 5236985), Questions = new[] { new AccountChargeQuestion { Question = "Question?", Answer = "Answer" } } }; _sut.CreateAccountCharge(request); Assert.Throws <WebServiceException>(() => _sut.CreateAccountCharge(request)); }
public void DeleteAccountCharge() { var request = new AccountChargeRequest { Name = "VIP", AccountNumber = "NUMBER" + new Random(DateTime.Now.Millisecond).Next(0, 5236985), Questions = new[] { new AccountChargeQuestion { Question = "Question?", Answer = "Answer" } } }; _sut.CreateAccountCharge(request); _sut.DeleteAccountCharge(request.AccountNumber); Assert.Throws <WebServiceException>(() => _sut.GetAccountCharge(request.AccountNumber)); }
public void AddAndGetAccountCharge() { var request = new AccountChargeRequest { Id = Guid.NewGuid(), Name = "1000", AccountNumber = "1000", Questions = new[] { new AccountChargeQuestion { Question = "Question?", Answer = "Answer" } } }; _sut.CreateAccountCharge(request); var account = _sut.GetAccountCharge(request.AccountNumber); Assert.That(account, Is.Not.Null); }
public void UpdateAccountCharge(AccountChargeRequest request) { var req = string.Format("/admin/accountscharge"); Client.Put <string>(req, request); }
public string CreateAccountCharge(AccountChargeRequest request) { var req = string.Format("/admin/accountscharge"); return(Client.Post <string>(req, request)); }
public object Get(AccountChargeRequest request) { var isAdmin = SessionAs <AuthUserSession>().HasPermission(RoleName.Admin); if (!request.AccountNumber.HasValue()) { var allAccounts = _dao.GetAll(); if (request.HideAnswers || !isAdmin) { foreach (var account in allAccounts) { HideAnswers(account.Questions); } } return(allAccounts .Select(acc => new { acc.Name, AccountNumber = acc.Number, acc.Questions, acc.Id, acc.UseCardOnFileForPayment }) .ToArray()); } else { // Validate locally that the account exists var account = _dao.FindByAccountNumber(request.AccountNumber); if (account == null) { throw new HttpError(HttpStatusCode.NotFound, "Account Not Found"); } // Validate with IBS to make sure the account/customer is still active var ibsChargeAccount = _ibsServiceProvider.ChargeAccount().GetIbsAccount(request.AccountNumber, request.CustomerNumber ?? "0"); if (ibsChargeAccount == null || !ibsChargeAccount.IsValid()) { throw new HttpError(HttpStatusCode.NotFound, "Account Not Found"); } var customerSpecificQuestions = ibsChargeAccount.Prompts.ToArray(); var questionsToRemove = account.Questions.Where(question => question.Question.HasValueTrimmed() && customerSpecificQuestions.None(prompt => question.Question == prompt.Caption)) .ToArray(); account.Questions.Remove(p => questionsToRemove.Contains(p)); if (questionsToRemove.Any()) { foreach (var t in questionsToRemove) { account.Questions.Add(new AccountChargeQuestion { Id = t.Id, IsRequired = false, IsCaseSensitive = false, AccountId = account.Id }); } } if (request.HideAnswers || !isAdmin) { HideAnswers(account.Questions); } var currentUser = new Guid(this.GetSession().UserAuthId); LoadCustomerAnswers(account.Questions, currentUser); return(account); } }
public Task <WithdrawalResponse> TryBeginWithdraw(string accountId, AccountChargeRequest request) { throw new System.NotImplementedException(); }
public Task <string> BeginDeposit(string accountId, AccountChargeRequest request) { throw new System.NotImplementedException(); }