Пример #1
0
        public ActionResult MakePayment(MakePaymentViewModel makePaymentViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("MakePayment", makePaymentViewModel));
            }
            if (makePaymentViewModel == null)
            {
                throw new ArgumentNullException("makePaymentViewModel");
            }

            if (makePaymentViewModel.Amount == 0M)
            {
                ModelState.AddModelError("Amount", "A payment of zero? That's not nice.");
                return(View("MakePayment", makePaymentViewModel));
            }

            var parent = userService.CurrentUser as Parent;
            var child  = userService.GetUserByUserName(makePaymentViewModel.ChildId) as Child;

            if (userService.AreNullOrNotRelated(parent, child))
            {
                return(StatusCode.NotFound);
            }

            parent.MakePaymentTo(child, makePaymentViewModel.Amount, makePaymentViewModel.Description);

            return(View("PaymentConfirmation", makePaymentViewModel));
        }
Пример #2
0
        public ActionResult MakePayment(string type, string payel, string cardNumber = "")
        {
            if (string.IsNullOrEmpty(payel))
            {
                return(RedirectToAction("Index", new { id = type }));
            }
            var response = new List <BouquetModel>();

            try
            {
                var url = ApiConstantService.BASE_URL + type + "/bouquet";
                response = _request.MakeRequest <List <BouquetModel> >(url);
            }
            catch (Exception exception)
            {
                ShowMessage(exception.Message, AlertType.Danger);
                response = new List <BouquetModel>();
                //return RedirectToAction("Index");
            }

            var vm = new MakePaymentViewModel {
                Type = type, Bouquets = response, PayEl = payel, CardNumber = cardNumber
            };

            return(View($"MakePayment_{payel}", vm));
        }
Пример #3
0
        public JsonResult MakePayment(MakePaymentViewModel viewModel)
        {
            try
            {
                LoggingService.Info(GetType());

                if (string.IsNullOrEmpty(viewModel.CurrentPageNodeId))
                {
                    throw new ApplicationException("Current Page Id Not Set");
                }

                IPublishedContent publishedContent = GetContentById(viewModel.CurrentPageNodeId);

                string url = paymentManager.MakePayment(
                    UmbracoContext,
                    publishedContent,
                    viewModel,
                    Members.CurrentUserName);

                return(Json(url));
            }
            catch (Exception e)
            {
                LoggingService.Error(GetType(), "Payment Error", e);
                return(Json("/Error"));
            }
        }
Пример #4
0
        public IActionResult CreateAccountTransaction(string accountNickname)
        {
            var transaction = new MakePaymentViewModel()
            {
                SenderAccountName = accountNickname,
            };

            return(View(transaction));
        }
        public async Task <IActionResult> MakePayment(int?bookingId)
        {
            //get booking from database
            var booking = await _context.Bookings
                          .Where(b => b.BookingId == bookingId)
                          .Include(b => b.Persons).FirstOrDefaultAsync();

            //instatiate the fields required to load future payments
            double initialPay;
            Dictionary <DateTime, double> futurePayments = new Dictionary <DateTime, double>();

            //if paying in full, set initial pay to booking total
            if (booking.PaymentType.Equals(PaymentType.FULL))
            {
                initialPay = booking.TotalPrice;
            }

            //if low deposit, charge £25 per person
            else if (booking.PaymentType.Equals(PaymentType.LOW))
            {
                initialPay     = (booking.Persons.Count() * 25);
                futurePayments = findLowDeposit(booking, initialPay);
            }

            //if standard deposit, charge half of the total booking
            else if (booking.PaymentType.Equals(PaymentType.STANDARD))
            {
                initialPay     = (booking.TotalPrice / 2);
                futurePayments = findStandardDeposit(booking, initialPay);
            }

            //if pay monthly, charge £25 per person
            else if (booking.PaymentType.Equals(PaymentType.MONTHLY))
            {
                initialPay     = (booking.Persons.Count() * 25);
                futurePayments = findMonthlyPayments(booking, initialPay);
            }
            //else return error
            else
            {
                return(NotFound());
            }

            //populate model
            var model = new MakePaymentViewModel
            {
                BookingId      = booking.BookingId,
                TotalPrice     = booking.TotalPrice,
                PaymentType    = booking.PaymentType,
                InitialPay     = initialPay,
                FuturePayments = futurePayments
            };

            //load make payment page
            return(View(model));
        }
        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"));
        }
Пример #7
0
        public ActionResult MakePayment(MakePaymentViewModel viewModel)
        {
            if (viewModel is null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    DebitCard card    = context.DebitCards.Find(viewModel.SelectedDebitCardId);
                    Booking   booking = context.Bookings.Find(viewModel.BookingId);
                    if (card is null || booking is null)
                    {
                        this.AddNotification("Error: card cannot be found in database", NotificationType.ERROR);
                        return(RedirectToAction("MakePayment", new { userId = User.Identity.GetUserId(), bookingId = viewModel.BookingId }));
                    }

                    Payment payment = new Payment
                    {
                        Date         = DateTime.Now,
                        Total        = booking.Total,
                        IsSuccessful = true,
                        BookingId    = booking.Id,
                        Booking      = booking
                    };

                    if (payment is null)
                    {
                        this.AddNotification("Error: could not accept payment", NotificationType.ERROR);
                        return(RedirectToAction("MakePayment", new { userId = User.Identity.GetUserId(), bookingId = viewModel.BookingId }));
                    }

                    // Success
                    context.Bookings.Find(viewModel.BookingId).IsPaid = true;
                    context.Payments.Add(payment);
                    context.SaveChanges();
                    return(RedirectToAction("ViewAllCustomersBookings", "Booking", new { id = User.Identity.GetUserId() }));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message);
                    return(RedirectToAction("MakePayment", new { userId = User.Identity.GetUserId(), bookingId = viewModel.BookingId }));
                }
            }
            return(RedirectToAction("MakePayment", new { userId = User.Identity.GetUserId(), bookingId = viewModel.BookingId }));
        }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionMadeMessage" /> class.
 /// </summary>
 /// <param name="umbracoContext">The umbraco context.</param>
 /// <param name="transaction">The transaction.</param>
 /// <param name="paymentViewModel">The payment view model.</param>
 /// <param name="createdUser">The created user.</param>
 /// <param name="emailTemplateName">Name of the email template.</param>
 /// <param name="paymentProvider">The payment provider.</param>
 /// <param name="environment">The environment.</param>
 public TransactionMadeMessage(
     UmbracoContext umbracoContext,
     Transaction transaction,
     MakePaymentViewModel paymentViewModel,
     string createdUser,
     string emailTemplateName,
     string paymentProvider,
     string environment)
 {
     Transaction       = transaction;
     UmbracoContext    = umbracoContext;
     PaymentViewModel  = paymentViewModel;
     CreatedUser       = createdUser;
     EmailTemplateName = emailTemplateName;
     PaymentProvider   = paymentProvider;
     Environment       = environment;
 }
Пример #9
0
        public ActionResult MakePayment(string userId, int bookingId)
        {
            if (userId is null)
            {
                throw new ArgumentNullException(nameof(userId));
            }
            if (bookingId <= 0)
            {
                return(RedirectToAction("ViewAllCustomersBookings", "Booking", new { id = userId }));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    List <DebitCard>      debitCards           = context.DebitCards.Where(d => d.CustomerId == userId).ToList();
                    List <SelectListItem> debitCardsSelectList = new List <SelectListItem>();
                    Booking             booking             = context.Bookings.Find(bookingId);
                    DebitCardController debitCardController = new DebitCardController();

                    foreach (DebitCard card in debitCards)
                    {
                        debitCardsSelectList.Add(new SelectListItem()
                        {
                            Value = card.Id.ToString(),
                            Text  = debitCardController.MaskFirstTwelveCharacters(card.CardNumber) // Masking card number
                        });
                    }

                    MakePaymentViewModel viewModel = new MakePaymentViewModel
                    {
                        DebitCards = debitCardsSelectList,
                        BookingId  = booking.Id,
                        Total      = booking.Total
                    };

                    // Success
                    return(View(viewModel));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message);
                    return(RedirectToAction("ViewAllCustomersBookings", "Booking", new { id = userId }));
                }
            }
            return(RedirectToAction("ViewAllCustomersBookings", "Booking", new { id = userId }));
        }
Пример #10
0
        public async Task <IActionResult> CreateTransaction(MakePaymentViewModel paymentModel)
        {
            if (Request.Form["submitbutton1"] != (string)null)
            {
                if (!this.ModelState.IsValid)
                {
                    return(View(paymentModel));
                }
                try
                {
                    var transaction = await this.transactionService.MakePayment(paymentModel.SenderAccountName,
                                                                                paymentModel.Ammount, paymentModel.RecieverAccountName, paymentModel.Description, false);

                    return(RedirectToAction("AllTransactions", "Transaction"));
                }
                catch (ArgumentException ex)
                {
                    this.ModelState.AddModelError("Error", ex.Message);
                    return(View(paymentModel));
                }
            }
            else if (Request.Form["submitButton2"] != (string)null)
            {
                if (!this.ModelState.IsValid)
                {
                    return(View(paymentModel));
                }
                try
                {
                    var transaction = await this.transactionService.MakePayment(paymentModel.SenderAccountName,
                                                                                paymentModel.Ammount, paymentModel.RecieverAccountName, paymentModel.Description, true);

                    return(RedirectToAction("AllTransactions", "Transaction"));
                }
                catch (ArgumentException ex)
                {
                    this.ModelState.AddModelError("Error", ex.Message);
                    return(View(paymentModel));
                }
            }

            return(View(paymentModel));
        }
Пример #11
0
        public async Task <IActionResult> SaveAccountTransaction([FromBody] MakePaymentViewModel paymentModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(paymentModel));
            }
            try
            {
                var transaction = await this.transactionService.MakePayment(paymentModel.SenderAccountName,
                                                                            paymentModel.Ammount, paymentModel.RecieverAccountName, paymentModel.Description, true);

                this.TempData["Success-Message"] = "Successful payment";

                return(new JsonResult(paymentModel));
                //return RedirectToAction("Index", "Home");
            }
            catch (ArgumentException ex)
            {
                this.ModelState.AddModelError("Error", ex.Message);
                return(View(paymentModel));
            }
        }
Пример #12
0
        /// <inheritdoc />
        /// <summary>
        /// Makes the payment.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="viewModel">The view model.</param>
        /// <returns>Payment Id</returns>
        public Result <Transaction> MakePayment(
            PaymentSettingsModel model,
            MakePaymentViewModel viewModel)
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount             = viewModel.Amount,
                PaymentMethodNonce = viewModel.Nonce,
                Options            = new TransactionOptionsRequest
                {
                    SubmitForSettlement = true
                }
            };

            Result <Transaction> result = GetGateway(model).Transaction.Sale(request);

            if (result.IsSuccess() &&
                result.Target != null)
            {
                return(result);
            }

            return(null);
        }
Пример #13
0
        /// <summary>
        /// Handles the payment.
        /// </summary>
        /// <param name="umbracoContext">The umbraco context.</param>
        /// <param name="publishedContent">Content of the published.</param>
        /// <param name="viewModel">The view model.</param>
        /// <param name="currentUser">The current user.</param>
        /// <returns></returns>
        /// <inheritdoc />
        public string MakePayment(
            UmbracoContext umbracoContext,
            IPublishedContent publishedContent,
            MakePaymentViewModel viewModel,
            string currentUser)
        {
            loggingService.Info(GetType());

            PageModel pageModel = new PageModel(publishedContent);

            if (string.IsNullOrEmpty(pageModel.NextPageUrl))
            {
                throw new ApplicationException("Next Page Url Not Set");
            }

            if (string.IsNullOrEmpty(pageModel.ErrorPageUrl))
            {
                throw new ApplicationException("Error Page Url Not Set");
            }

            PaymentSettingsModel paymentSettingsModel = paymentProvider.GetPaymentSettingsModel(umbracoContext);

            if (paymentSettingsModel.Provider != Constants.PaymentProviders.Braintree)
            {
                //// we currently only support Braintree
                throw new ApplicationException("Unsupported Payment Provider");
            }

            Result <Transaction> transaction = paymentProvider.MakePayment(paymentSettingsModel, viewModel);

            if (transaction != null)
            {
                //// at this point the payment has worked
                //// so need to be careful from here as to what we raise as errors etc.

                //// make sure we clear the cache!
                transactionsRepository.SetKey(umbracoContext);
                transactionsRepository.Clear();

                string paymentId = transaction.Target.Id;

                loggingService.Info(GetType(), "Payment Succesful Id=" + paymentId);

                try
                {
                    eventPublisher.Publish(new TransactionMadeMessage(
                                               umbracoContext,
                                               transaction.Target,
                                               viewModel,
                                               currentUser,
                                               pageModel.EmailTemplateName,
                                               paymentSettingsModel.Provider,
                                               paymentSettingsModel.Environment));
                }
                catch (Exception exception)
                {
                    loggingService.Error(GetType(), "Publish of payment Failed", exception);
                }

                return(pageModel.NextPageUrl);
            }

            loggingService.Info(GetType(), "Payment Failed");

            return(pageModel.ErrorPageUrl);
        }
Пример #14
0
        public static MakePaymentViewModel GetEmployerDueAmount(int emprAccountID)
        {
            MakePaymentViewModel          LocalPaymentViewModel           = new MakePaymentViewModel();
            EmployerAccountTransactionDto localEmployerAccountTransaction = new EmployerAccountTransactionDto();
            EmployerDto       localEmployerDto       = new EmployerDto();
            PaymentMainDto    localPaymentMainDto    = new PaymentMainDto();
            PaymentProfileDto localPaymentProfileDto = new PaymentProfileDto();

            using (DbContext context = new DbContext())
            {
                localEmployerDto = (from employerDetail in context.Employers
                                    where employerDetail.EmployerId == emprAccountID
                                    select new EmployerDto
                {
                    EmployerId = employerDetail.EmployerId,
                    EntityName = employerDetail.EntityName,
                }).FirstOrDefault();
                if (localEmployerDto != null)
                {
                    localEmployerAccountTransaction = (from emptranDetail in context.EmployerAccountTransactions
                                                       where emptranDetail.EmployerId == localEmployerDto.EmployerId
                                                       select new EmployerAccountTransactionDto
                    {
                        OwedAmount = emptranDetail.OwedAmount,
                        UnpaidAmount = emptranDetail.UnpaidAmount
                    }).FirstOrDefault();

                    localPaymentMainDto = (from pmtMainDetail in context.PaymentMains
                                           where pmtMainDetail.EmployerId == localEmployerAccountTransaction.EmployerId
                                           select new PaymentMainDto
                    {
                        RoutingTransitNumber = pmtMainDetail.RoutingTransitNumber,
                        BankAccountNumber = pmtMainDetail.BankAccountNumber,
                        BankAccountTypeCode = pmtMainDetail.BankAccountTypeCode,
                        PaymentAmount = pmtMainDetail.PaymentAmount,
                        PaymentTransactionDate = pmtMainDetail.PaymentTransactionDate,
                        PaymentMethodCode = pmtMainDetail.PaymentMethodCode,
                        PaymentStatusCode = pmtMainDetail.PaymentStatusCode,
                        PaymentMainId = pmtMainDetail.PaymentMainId
                    }).FirstOrDefault();
                    localPaymentProfileDto = (from pmtProfile in context.PaymentProfiles
                                              where pmtProfile.EmployerId == localPaymentMainDto.EmployerId && pmtProfile.BankAccountNumber == localPaymentMainDto.BankAccountNumber
                                              select new PaymentProfileDto
                    {
                        AgentId = pmtProfile.AgentId,
                        BankAccountNumber = pmtProfile.BankAccountNumber,
                        CreateDateTime = pmtProfile.CreateDateTime,
                        CreateUserId = pmtProfile.CreateUserId,
                        EmployerId = pmtProfile.EmployerId,
                        PaymentAccountTypeCode = pmtProfile.PaymentAccountTypeCode,
                        PaymentProfileId = pmtProfile.PaymentProfileId,
                        PaymentTypeCode = pmtProfile.PaymentTypeCode,
                        RoutingTransitNumber = pmtProfile.RoutingTransitNumber,
                        UpdateDateTime = pmtProfile.UpdateDateTime,
                        UpdateNumber = pmtProfile.UpdateNumber,
                        UpdateUserId = pmtProfile.UpdateUserId,
                    }).FirstOrDefault();
                }
            }
            LocalPaymentViewModel.EmployerAccountTransactionDto = localEmployerAccountTransaction;
            LocalPaymentViewModel.EmployerDto       = localEmployerDto;
            LocalPaymentViewModel.PaymentMainDto    = localPaymentMainDto;
            LocalPaymentViewModel.PaymentProfileDto = localPaymentProfileDto;
            return(LocalPaymentViewModel);
        }
Пример #15
0
 /// <inheritdoc />
 /// <summary>
 /// Makes the payment.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="viewModel">The view model.</param>
 /// <returns>Payment Id</returns>
 public Result <Transaction> MakePayment(
     PaymentSettingsModel model,
     MakePaymentViewModel viewModel)
 {
     return(braintreeService.MakePayment(model, viewModel));
 }