public PaymentViewModel DestroyPayment(PaymentViewModel givenPayment) { this.Data.Payments.Delete(givenPayment.Id); this.Data.SaveChanges(); return givenPayment; }
public PaymentViewModel Get(PaymentsRequest request) { var payments = paymentsRepository.GetPayments(request.MinPrice, request.MaxPrice, request.PageSize); var model = new PaymentViewModel(); paymentsMapper.Map(payments, model); return model; }
public PaymentViewModel Get(PaymentsRequest request) { var payments = GetPayments(request); var model = new PaymentViewModel(); Map(payments, model); return model; }
public void RegisterCard(PaymentViewModel payment, SuccessCallback success, FailureCallback failure, UINavigationController navigationController) { var view = _viewLocator.GetRegisterCardView(); view.successCallback = success; view.failureCallback = failure; view.registerCardModel = payment; PresentView (navigationController, view); }
public JsonResult DestroyPayment([DataSourceRequest] DataSourceRequest request, PaymentViewModel paymentModel) { var deletedPayment = this.payments.DestroyPayment(paymentModel); var loggedUserId = User.Identity.GetUserId(); Base.CreateActivity(ActivityType.Delete, deletedPayment.Id.ToString(), ActivityTargetType.Payment, loggedUserId); return Json(new[] { paymentModel }, JsonRequestBehavior.AllowGet); }
public void PreAuth(PaymentViewModel preAuthorisation, SuccessCallback success, FailureCallback failure, UINavigationController navigationController) { var view = _viewLocator.GetPreAuthView(); // register card and pre Auth sharing same view so we need to set this property to false view.successCallback = success; view.failureCallback = failure; view.authorisationModel = preAuthorisation; PresentView (navigationController, view); }
public void Payment(PaymentViewModel payment, SuccessCallback success, FailureCallback failure, UINavigationController navigationController) { var view = _viewLocator.GetPaymentView(); view.successCallback = success; view.failureCallback = failure; view.cardPayment = payment; PresentView (navigationController, view); }
public void PreAuth(PaymentViewModel payment, SuccessCallback success, FailureCallback failure, UINavigationController navigationController) { try { _paymentService.PreAuthoriseCard(payment).ContinueWith(reponse => HandResponse(success, failure, reponse)); } catch (Exception ex) { // Failure HandleFailure (failure,ex); } }
public void IsRecurring_SetTrue_CreateRecurringViewModel() { // Arrange var vm = new PaymentViewModel(); vm.RecurringPayment.ShouldBeNull(); // Act vm.IsRecurring = true; // Assert. vm.RecurringPayment.ShouldNotBeNull(); }
public void IsRecurring_SetTrue_CreateRecurringViewModel() { // Arrange var vm = new PaymentViewModel(mediatorMock.Object, navigationService.Object); vm.RecurringPayment.ShouldBeNull(); // Act vm.IsRecurring = true; // Assert. vm.RecurringPayment.ShouldNotBeNull(); }
public ActionResult Create() { var user = _unitOfWork.Accounts.GetCurrentUserAccount(); PaymentViewModel viewModel = new PaymentViewModel(); viewModel.InitializePaymentFormResources(user.Profile.Beneficiaries, user.Profile.Currencies, EnumHelper.GetEnumSelectList <PaymentClass>(), _unitOfWork.Activities.GetActivityByName("Payment.Lock").IsUserAllowed(user.Roles), _unitOfWork.Activities.GetActivityByName("Payment.Edit").IsUserAllowed(user.Roles)); return(View("PaymentForm", viewModel)); }
public async Task <bool> CheckForRecurringPayment(PaymentViewModel payment) { if (!payment.IsRecurring) { return(false); } return (await dialogService.ShowConfirmMessage(Strings.ChangeSubsequentPaymentTitle, Strings.ChangeSubsequentPaymentMessage, Strings.RecurringLabel, Strings.JustThisLabel)); }
public ActionResult CreateCustomex(PaymentViewModel viewModel) { var payment_ = new Payment { BudgetNum = viewModel.BudgetNum, PurchaseNum = viewModel.PurchaseNum, CorporateAccountID = viewModel.CorporateAccountID, InvoiceDate = viewModel.InvoiceDate, InvoiceNum = viewModel.InvoiceNum, InvoiceTotal = viewModel.InvoiceTotal, PaymentDate = viewModel.PaymentDate, RequestIssueID = viewModel.RequestIssueID, Description = viewModel.Description }; db.Payments.Add(payment_); db.SaveChanges(); int _paymentid = payment_.PaymentID; int i = 0; foreach (var file_ in Request.Files) { PaymentFile file = RetrieveFileFromRequest(i); if (file.PaymentFileName != null && !db.PaymentFiles.Any(f => f.PaymentFileName.Equals(file.PaymentFileName)) && file.PaymentFileSize > 0) { file.Payment = payment_; db.PaymentFiles.Add(file); db.SaveChanges(); } i++; } // save product // var product = new Product { Name = viewModel.Name, Price = viewModel.Price }); // repo.Save(product); // now do something with the files //foreach (var file in viewModel.PaymentFiles) //{ // if (file.PaymentFileSize > 0) // { // var fileName = Path.GetFileName(file.PaymentFileName); // var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName); // file.SaveAs(path); // } //} return(RedirectToAction("Index")); }
public static void Update(PaymentViewModel payment) { PaymentHeader entity = getEntityByModel(payment); string result = string.Empty; if (entity.IsValid()) { if (payment.Id > 0) { result = service.Update(entity); } else { result = service.Insert(entity); } if (!string.IsNullOrEmpty(result)) { var savedLines = getpaymentLinesbyPaymentId(result); if (savedLines.Count() > payment.PaymentInvoiceLines.Count()) { var tobeDeleted = savedLines.Take(savedLines.Count() - payment.PaymentInvoiceLines.Count()); foreach (var item in tobeDeleted) { service.DeleteLine(item.Id, AuthenticationHelper.CompanyId.Value); } savedLines = getpaymentLinesbyPaymentId(result); } foreach (var line in payment.PaymentInvoiceLines) { PaymentInvoiceLines lineEntity = getEntityByModel(line); if (lineEntity.IsValid()) { lineEntity.PaymentId = Convert.ToInt64(result); if (savedLines.Count() > 0) { lineEntity.Id = savedLines.FirstOrDefault().Id; savedLines.Remove(savedLines.FirstOrDefault(rec => rec.Id == lineEntity.Id)); service.Update(lineEntity); } else { service.Insert(lineEntity); } } } } } }
//Automatic Parsing Rows private PaymentViewModel ParseAutomatic(string[] row) { try { PaymentViewModel payment = new PaymentViewModel(); DateTime dt; decimal number; foreach (var col in row) { if (col.Trim() == "") { continue; } if (Utils.IsDate(col, out dt)) { if (payment.DateOfPayment == null) { payment.DateOfPayment = dt.Date; continue; } continue; } else if (Utils.IsNumber(col, out number)) { if (payment.Sum == null) { payment.Sum = number; } else if (payment.Balance == null) { payment.Balance = number; } continue; } else if (payment.Description == null && payment.DateOfPayment != null) { payment.Description = col; } } payment.KeyId = MakeKeyIdFromPaymentObj(payment); return(payment); } catch (Exception ex) { throw ex; } }
public JsonResult GetAllByFilter(JQueryDataTableParams param, string filtros) { try { AuthUser authUser = Authenticator.AuthenticatedUser; NameValueCollection filtersValues = HttpUtility.ParseQueryString(filtros); filtersValues["UserId"] = "-1"; if (authUser.Role.Code != Constants.ROLE_ADMIN && authUser.Role.Code != Constants.ROLE_IT_SUPPORT) { filtersValues["UserId"] = Convert.ToString(authUser.Id); } var payments = _paymentService.FilterBy(filtersValues, param.iDisplayStart, param.iDisplayLength); IList <PaymentViewModel> dataResponse = new List <PaymentViewModel>(); foreach (var payment in payments.Item1) { PaymentViewModel resultData = new PaymentViewModel { Id = Convert.ToString(payment.Id), OrderId = payment.OrderId, Amount = payment.Amount, PaymentMethod = payment.Method, ProviderId = payment.ProviderId, Status = payment.Status, CreationDate = payment.CreationDate.ToString(Constants.DATE_FORMAT_CALENDAR), ConfirmationDate = payment.ConfirmationDate.HasValue?payment.ConfirmationDate.Value.ToString(Constants.DATE_FORMAT_CALENDAR) :"", User = payment.User.Email }; dataResponse.Add(resultData); } return(Json(new { success = true, param.sEcho, iTotalRecords = dataResponse.Count(), iTotalDisplayRecords = payments.Item2, aaData = dataResponse }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(new JsonResult { Data = new { Mensaje = new { title = "Error", message = ex.Message } }, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue }); } }
public async Task <OperationResult> UpdatePayment(PaymentViewModel newPaymentViewModel) { var payment = await CreatePaymentFromViewModel(newPaymentViewModel).ConfigureAwait(false); var result = await modifyPaymentAction.UpdatePayment(newPaymentViewModel.Id, payment) .ConfigureAwait(false); await context.SaveChangesAsync() .ConfigureAwait(false); return(!result.Success ? OperationResult.Failed(result.Message) : OperationResult.Succeeded()); }
public IActionResult PaymentList() { //select* from payment //INNER JOIN //StudentInClass //on payment.c_name = StudentInClass.c_name //and payment.Roll = StudentInClass.roll //inner join //Student //on StudentInClass.s_id = Student.s_id //var test = from s in _context.Student // join m in _context.StudentInClass on s.s_id equals m.s_id // join mo in _context.monthlyFee on m.c_name equals mo.c_id var test = from p in _context.Payment join s in _context.StudentInClass on new { A = p.c_name, B = p.roll } equals new { A = s.c_name, B = s.roll } join st in _context.Student on s.s_id equals st.s_id select new { p_id = p.id, s_name = st.s_name, c_name = s.c_name, roll = s.roll, fee = p.fee, dateOfPayment = p.date_of_payment }; var model = new List <PaymentViewModel>(); foreach (var i in test) { var s = new PaymentViewModel(); s.p_id = i.p_id; s.s_name = i.s_name; s.c_name = i.c_name; //s.Contect = i.Contact; //s.Fee = i.Fee; s.roll = i.roll; s.fee = i.fee; s.dateOfPayment = i.dateOfPayment; model.Add(s); } return(View(model)); }
/// <inheritdoc /> public async Task SavePayment(PaymentViewModel paymentViewModel) { var payment = await CreatePaymentFromViewModel(paymentViewModel); await context.AddAsync(payment); foreach (var e in context.ChangeTracker.Entries()) { logger.Info("entity: {e}", e); } var count = await context.SaveChangesAsync(); logger.Info("{count} entities saved.", count); }
public IActionResult СhooseQuantity(int id) { var product = db.Products.FirstOrDefault(i => i.Id == id); Rent rent = new Rent(); rent.Product = product; var obj = new PaymentViewModel() { Rent = rent }; ViewBag.ProductCount = shopCart.ProductCount(); return(View(obj)); }
private string CreateEmailBody(PaymentViewModel model, string email) { CultureInfo cul = CultureInfo.GetCultureInfo("vi-VN"); // Reading html template string body = string.Empty; string rootFolder = _hostingEnvironment.WebRootPath; body = System.IO.File.ReadAllText(rootFolder + "/SendMailTemplate/SendMailTemplate.cshtml"); // Replacing the required things body = body.Replace("{OrderID}", model.OrderId.ToString()); body = body.Replace("{OrderDate}", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")); body = body.Replace("{Email}", email); body = body.Replace("{ShippingAddress}", model.Shipping.Address); if (!model.IsRelative) { body = body.Replace("{UserName}", model.Shipping.Name); body = body.Replace("{PhoneNumber}", model.Shipping.PhoneNumber); } else { body = body.Replace("{UserName}", model.RelativeName); body = body.Replace("{PhoneNumber}", model.RelativePhoneNumber); } body = body.Replace("{ShippingDate}", model.DateText); body = body.Replace("{ShippingFee}", model.DisplayShippingFee); string products = ""; foreach (var item in model.Products.Cart) { double itemTempSum = (item.BuyedQuantity * item.ProductDetail.PriceText).GetValueOrDefault(); string displayPrice = string.Format(cul, "{0:c0}", itemTempSum); products += string.Format(@"<tr style=""background: #eee;""> <td>{0}</td> <td>{1}</td> <td>{2}</td> <td>{3}</td> </tr>", item.Product.Name, item.ProductDetail.DisplayPrice, item.BuyedQuantity, displayPrice); } body = body.Replace("{Products}", products); body = body.Replace("{TempSum}", model.DisplayTempPrice); body = body.Replace("{Sum}", model.DisplayFinalPrice); return(body); }
private void HandlePaymentViewModelAmount(PaymentViewModel paymentVm, Func <double, double> amountFunc, Func <PaymentViewModel, Account> getAccountFunc) { var account = getAccountFunc(paymentVm); if (account == null) { return; } account.CurrentBalance += amountFunc(paymentVm.Amount); Save(account); }
public async Task <IActionResult> Payment(PaymentViewModel model) { try { var order = await GetOrderAsync(model.CurrentOrderID); if (order != null) { if (ModelState.IsValid) { var customer = await _api.GetAsync <CustomerModel>($"/customers/{CustomerID.Value}"); customer.Email = model.Email; customer.FirstName = model.FirstName; customer.LastName = model.LastName; _api.Put($"/customers/{customer.ID}", customer); var amount = _api.Get <IEnumerable <LineItemModel> >("/lineitems") .Where(x => x.OrderID == order.ID).Sum(x => x.ItemAmount); //Create payment on order. var payment = new PaymentModel { OrderID = model.CurrentOrderID, PaymentTypeID = (int)PaymentTypeEnums.CreditCardManual, Amount = amount, PaymentStatusTypeID = (int)PaymentStatusTypeEnums.Paid }; _api.Post("/payments", payment); order.OrderStatusTypeID = (int)OrderStatusTypeEnums.Paid; _api.Put($"/orders/{order.ID}", order); return(RedirectToAction("Order", "Account", new { id = model.CurrentOrderID })); } } else { ModelState.AddModelError("CustomError", $"Order not found."); } var orderViewModel = GetOrderViewModel(order); model = new PaymentViewModel(orderViewModel, order.ID); return(View(model)); } catch (Exception ex) { return(RedirectToAction("Error")); } }
public IActionResult Payment(PaymentViewModel model, string Id) { var payment = new Payment() { PaymentId = model.PaymentId, PaymentDate = DateTime.Now, Amount = 10 }; context.payments.Add(payment); context.SaveChanges(); return(RedirectToAction("Appoint", new { Id })); }
public async Task <IActionResult> GenerateBulkInvoice(BulkPaymentViewModel model) { try { if (ModelState.IsValid) { Random rd = new Random(); byte[] bytes = new byte[4]; var invoices = await _businessManager.GetInvoices(model.Invoices.ToArray()); var invoiceList = _mapper.Map <List <InvoiceListViewModel> >(invoices); //if(subtotalRange != null) { // model.Header = $"{subtotalRange.From}-{subtotalRange.To}"; List <PaymentViewModel> payments = new List <PaymentViewModel>(); Random random = new Random(); foreach (var invoice in invoices) { rd.NextBytes(bytes); var date = random.NextDate(model.PaymentDateFrom, model.PaymentDateTo); var invoiceAmount = invoice.Subtotal * (1 + invoice.TaxRate / 100); var payment = new PaymentViewModel() { No = BitConverter.ToString(bytes).Replace("-", ""), CustomerId = invoice.Customer?.Id ?? 0, InvoiceId = invoice.Id, InvoiceNo = invoice.No, InvoiceAmount = invoiceAmount, Date = date, Amount = invoiceAmount - invoice.Payments.TotalAmount() }; payments.Add(payment); } model.Payments = payments; string html = _viewRenderService.RenderToStringAsync("_BulkPaymentPartial", model).Result; return(Ok(html)); //} else { // return BadRequest(); //} } } catch (Exception er) { Console.WriteLine(er.Message); } return(Ok(model)); }
public async Task <IActionResult> CreatePayment(Guid citationId, Guid accountId) { var accountDetail = await CommonContext.CommonAccounts.Include(m => m.Partition).SingleOrDefaultAsync(account => account.Id == accountId); _accountCtx = ContextsUtility.CreateAccountContext(Cryptography.Decrypt(accountDetail.Partition.ConnectionString)); var citation = await GetCitation(accountId, citationId); var model = new PaymentViewModel { CitationId = citationId, AccountId = accountId, CitationFineAmount = citation.Balance.HasValue? citation.Balance.Value : 0f }; return(View(model)); }
private void HandlePaymentAmount(PaymentViewModel payment, Func <double, double> amountFunc, Func <PaymentViewModel, AccountViewModel> getAccountFunc) { var account = getAccountFunc(payment); if (account == null) { return; } account.CurrentBalance += amountFunc(payment.Amount); accountRepository.Save(account); }
public void ConfirmPaymentEdit(int rentalId, int paymentId, float paymentValue, DateTime paymentDate, string paymentTitle) { var viewModel = new PaymentViewModel() { id_wynajmu = rentalId, cena = paymentValue, data_platnosci = paymentDate, id_platnosci = paymentId, tytul = paymentTitle }; paymentService.AddOrEditPayment(ViewModelMapper.Mapper.Map <PaymentModel>(viewModel)); }
public BillingViewModel() { LoadCommand = new DelegateCommand(new Action(LoadBillings)); ArchiveCommand = new DelegateCommand(new Action(Archive)); UnarchiveCommand = new DelegateCommand(new Action(Unarchive)); DeleteCommand = new DelegateCommand(new Action(DeleteBilling)); AddCommand = new DelegateCommand(new Action(GotoAddBilling)); EditCommand = new DelegateCommand(new Action(GotoEditBilling)); AddPaymentViewModel = new AddPaymentViewModel(); AddPaymentCommand = new DelegateCommand(new Action(AddPayment)); PaymentViewModel = new PaymentViewModel(); PatientViewModel = new PatientViewModel(); PatientViewModel.LoadPatients(); }
public async Task <IActionResult> Create() { UserEntity user = await _userHelper.GetUserAsync(this.User.Identity.Name); PaymentViewModel model = new PaymentViewModel { Date = DateTime.Today, Banks = _combosHelper.GetComboBanks(), User = user, }; return(View(model)); }
public IActionResult CreatePost(PaymentViewModel model) { var response = iPaymentBusiness.Create(model); if (response.ResponseCode > 0) { return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, response.ResponseMessage); return(View("Create", model)); } }
public PaymentViewModel createPaymentViewModel(bool savingOrder, int scheduleID, int totalTickets, string row, string chairs, int totalRegular, int totalChild, int totalStudent, int totalSenior, int totalPopcorn, int totalLadies, decimal totalPrice) { PaymentViewModel model = new PaymentViewModel(); model.schedule = scheduleRepo.Schedules.FirstOrDefault(s => s.Id == scheduleID); model.totalTickets = totalTickets; model.row = row; model.regularQuantity = totalRegular; model.childQuantity = totalChild; model.studentQuantity = totalStudent; model.seniorQuantity = totalSenior; model.popcornQuantity = totalPopcorn; model.ladiesQuantity = totalLadies; model.totalPrice = totalPrice; if (savingOrder) { model.generatedCode = generateRandomOrderNr(); } List <int> selectedChairs = new List <int>(); int newChair = 0; string currentChair = ""; string newChairString = chairs += " "; foreach (Char c in newChairString) { if (c.ToString() != " ") { if (currentChair != "") { currentChair = currentChair += c.ToString(); } else { currentChair = c.ToString(); } } else { newChair = int.Parse(currentChair); selectedChairs.Add(newChair); newChair = 0; currentChair = ""; } } model.chairs = selectedChairs.ToArray(); return(model); }
public ActionResult Index(PaymentViewModel vm, string buttonValue) { switch (buttonValue) { case "Save": if (vm.JobIsTimeCard) { if (vm.EditPayment.WorkDay == 0) { ModelState.AddModelError("EditPayment.WorkDay", "Please select Work Period"); } } if (ModelState.IsValid) { vm.EditPayment.ContractorId = vm.SelectedContractorId; vm.EditPayment.JobId = vm.SelectedJobId; _PaymentRepo.SavePayment(vm.EditPayment); vm.EditPayment = new TimeCard.Domain.Payment { PayDate = vm.EditPayment.PayDate }; ModelState.Clear(); } break; case "Delete": _PaymentRepo.DeletePayment(vm.EditPayment.PayId); vm.EditPayment = new TimeCard.Domain.Payment { PayDate = vm.EditPayment.PayDate }; ModelState.Clear(); break; case "Summary": vm.PaymentSummary = _PaymentRepo.GetSummary(vm.SelectedContractorId, DateRef.CurrentWorkCycle); vm.Payments = _PaymentRepo.GetPayments(vm.SelectedContractorId); prepPayment(vm); return(PartialView("_PaymentSummary", vm)); default: vm.EditPayment = new TimeCard.Domain.Payment { PayDate = vm.EditPayment.PayDate }; ModelState.Clear(); break; } prepPayment(vm); return(PartialView("_EditPayment", vm)); }
public ActionResult Payment(PaymentViewModel model) { var creditorAccount = model.Creditor.Account.Value; if (!UserCanAccessAccountData(creditorAccount)) { throw new Exception("Not Allowed"); } var apiManager = new NordeaAPIv3Manager(); var apiResult = apiManager.InitiatePayment(model.Creditor, model.Debtor, model.Amount, "DKK"); SetContextCulture(); return(View("PaymentStatus", apiResult)); }
/// <summary> /// Deletes a payment and if asks the user if the recurring payment shall be deleted as well. /// If the users says yes, delete recurring payment. /// </summary> /// <param name="payment">Payment to delete.</param> /// <returns>Returns if the operation was successful</returns> public async Task <bool> DeletePayment(PaymentViewModel payment) { paymentRepository.Delete(payment); if (!payment.IsRecurring || !await dialogService.ShowConfirmMessage(Strings.DeleteRecurringPaymentTitle, Strings.DeleteRecurringPaymentMessage)) { return(true); } // Delete all recurring payments if the user wants so. return(DeleteRecurringPaymentForPayment(payment)); }
public IActionResult SavePayment(PaymentViewModel paymentViewModel) { var validationResult = _humanPresentation.GetErrorsStringFromModelState(ModelState); if (validationResult != null) { return(Json(validationResult)); } if (!_humanPresentation.SavePayment(paymentViewModel, out string message)) { return(Json(message)); } return(RedirectToAction("Personnel")); }
public IActionResult Index() { if (_signInManager.IsSignedIn(User)) { var seedlings = _context.Seedlings.Where(s => s.Amount > 0).ToList(); var model = new PaymentViewModel(); model.Seedlings = seedlings; return(View(model)); } else { return(RedirectToAction("Login", "Account")); } }
/// <summary> /// Deletes the passed payment and removes the item from cache /// </summary> /// <param name="paymentVmToDelete">Payment to delete.</param> public void Delete(PaymentViewModel paymentVmToDelete) { var payments = Data.Where(x => x.Id == paymentVmToDelete.Id).ToList(); foreach (var payment in payments) { data.Remove(payment); dataAccess.Delete(paymentVmToDelete.GetPayment()); // If this accountToDelete was the last finacial accountToDelete for the linked recurring accountToDelete // delete the db entry for the recurring accountToDelete. DeleteRecurringPaymentIfLastAssociated(payment); } }
public JsonResult CreatePayment([DataSourceRequest] DataSourceRequest request, PaymentViewModel paymentModel) { if (paymentModel == null || !ModelState.IsValid) { return Json(new[] { paymentModel }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet); } var createdPayment = this.payments.CreatePayment(paymentModel); var loggedUserId = User.Identity.GetUserId(); Base.CreateActivity(ActivityType.Create, createdPayment.Id.ToString(), ActivityTargetType.Payment, loggedUserId); paymentModel.Id = createdPayment.Id; return Json(new[] { paymentModel }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet); }
public void Map(IEnumerable<Payment> payments, PaymentViewModel model) { var dtos = new List<PaymentDto>(); foreach (var p in payments) { var dto = new PaymentDto { Model = p.Model, Manufacturer = p.Manufacturer, Price = p.Price, NumberOfDoors = p.NumberOfDoors }; dtos.Add(dto); } model.Payments = dtos; }
protected override async void OnSubmit(CardViewModel card) { ShowLoading(); if (await _networkDetector.CanConnect()) { var payment = new PaymentViewModel(); payment.Card = card; payment.Amount = Judo.Amount; payment.JudoID = Judo.JudoId; payment.ConsumerReference = Judo.ConsumerReference; payment.Currency = Judo.Currency; Presenter.HandleResult(await PaymentService.Payment(payment)); } else { HideLoading(); OnDisplayConnectionError(); } }
protected override async void OnSubmit(CardViewModel card) { ShowLoading(); if (await _networkDetector.CanConnect()) { var payment = new PaymentViewModel(); payment.Card = card; payment.Amount = Judo.Amount; payment.JudoID = Judo.JudoId; payment.ConsumerReference = Judo.ConsumerReference; payment.Currency = Judo.Currency; Presenter.HandleResult(await PaymentService.PreAuth(payment)); } else { HideLoading(); await DisplayAlert("Can't connect", "Please check your internet connection", "OK"); } }
void PopulatePaymentModel(PaymentViewModel paymentViewModel) { _judo.Validate(); _sessionPaymentModel.JudoId = (string.IsNullOrWhiteSpace(paymentViewModel.JudoID) ? _judo.JudoId : paymentViewModel.JudoID); _sessionPaymentModel.YourConsumerReference = (string.IsNullOrWhiteSpace(paymentViewModel.ConsumerReference) ? ("Consumer:" + _judo.JudoId) : paymentViewModel.ConsumerReference); _sessionPaymentModel.Amount = paymentViewModel.Amount; _sessionPaymentModel.CardNumber = paymentViewModel.Card.CardNumber; _sessionPaymentModel.CV2 = paymentViewModel.Card.SecurityCode; _sessionPaymentModel.ExpiryDate = paymentViewModel.Card.ExpiryDate; _sessionPaymentModel.CardAddress = new CardAddressModel() { PostCode = paymentViewModel.Card.Postcode, CountryCode = paymentViewModel.Card.Country.GetISOCode() }; _sessionPaymentModel.StartDate = paymentViewModel.Card.StartDate; _sessionPaymentModel.IssueNumber = paymentViewModel.Card.IssueNumber; _sessionPaymentModel.YourPaymentMetaData = paymentViewModel.YourPaymentMetaData; _sessionPaymentModel.ClientDetails = clientService.GetClientDetails(); _sessionPaymentModel.Currency = paymentViewModel.Currency; }
public PaymentViewModel CreatePayment(PaymentViewModel givenPayment) { if (givenPayment == null) { return null; } var newPayment = new Payment { Date = givenPayment.Date, Expense = givenPayment.Expense, Payer = givenPayment.Payer, Invoice = givenPayment.Invoice, Amount = givenPayment.Amount, IsVisible = givenPayment.IsVisible }; this.Data.Payments.Add(newPayment); this.Data.SaveChanges(); givenPayment.Id = newPayment.Id; return givenPayment; }
public async Task<IResult<ITransactionResult>> Payment(PaymentViewModel paymentViewModel) { PopulatePaymentModel(paymentViewModel); Task<IResult<ITransactionResult>> task = _judoAPI.Payments.Create(_sessionPaymentModel); return await task; }
public async Task<IResult<ITransactionResult>> RegisterCard(PaymentViewModel payment) { PopulatePaymentModel(payment); Task<IResult<ITransactionResult>> task = _judoAPI.RegisterCards.Create(_sessionPaymentModel); return await task; }
private PaymentViewModel GetCardViewModel () { var cardPayment = new PaymentViewModel { Amount = 4.5m, ConsumerReference = consumerRef, Currency = "GBP", // Non-UI API needs to pass card detail Card = new CardViewModel { CardNumber = cardNumber, CV2 = cv2, ExpireDate = expiryDate, PostCode = addressPostCode, CountryCode = ISO3166CountryCodes.UK } }; return cardPayment; }
public PaymentViewModel UpdatePayment(PaymentViewModel givenPayment) { var paymentFromDb = this.Data.Payments .All() .FirstOrDefault(p => p.Id == givenPayment.Id); if (givenPayment == null || paymentFromDb == null) { return givenPayment; } paymentFromDb.Date = givenPayment.Date; paymentFromDb.Expense = givenPayment.Expense; paymentFromDb.Payer = givenPayment.Payer; paymentFromDb.Invoice = givenPayment.Invoice; paymentFromDb.Amount = givenPayment.Amount; paymentFromDb.IsVisible = givenPayment.IsVisible; this.Data.SaveChanges(); return givenPayment; }
public async Task<IResult<ITransactionResult>> PreAuth(PaymentViewModel authorisation) { PopulatePaymentModel(authorisation); Task<IResult<ITransactionResult>> task = _judoAPI.PreAuths.Create(_sessionPaymentModel); return await task; }