Esempio n. 1
0
        public ViewResult CreatePayment(int id)
        {
            Student std = _er.GetStudent(id);
            CreatePaymentViewModel pvm = new CreatePaymentViewModel()
            {
                StudentId     = id,
                AmountPaid    = 0.00,
                PaymentDate   = DateTime.Now,
                PaymentMethod = PayMethod.BankTransfer
            };

            return(View(pvm));
        }
Esempio n. 2
0
        public IActionResult Create(Order order)
        {
            //var order = _context.Orders.FirstOrDefault(o => o.OrderId == id);
            var model = new CreatePaymentViewModel
            {
                OrderId    = order.OrderId,
                Order      = order,
                CardHolder = order.Name,
                Amount     = order.TotalAmount
            };

            return(View(model));
        }
Esempio n. 3
0
        public async Task <IActionResult> Payment(CreatePaymentViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            PaymentDetails paymentDetails = _db.GetDetails(model.PayKey);

            if (paymentDetails == null)
            {
                _logger.LogWarning("Payment details are null.");
                return(RedirectToArcadier(model.InvoiceNo));
            }

            IBraintreeGateway gateway = _braintreeConfig.GetGateway();

            decimal adminFee = paymentDetails.Amount * _arcadierSettings.Value.Commission / 100;
            decimal amount   = paymentDetails.Amount - adminFee;

            var request = new TransactionRequest
            {
                Amount             = amount,
                PaymentMethodNonce = model.PaymentMethodNonce,
                Options            = new TransactionOptionsRequest
                {
                    SubmitForSettlement = true
                }
            };

            Result <Transaction> result = await gateway.Transaction.SaleAsync(request);

            paymentDetails.TransactionStatus = Models.TransactionStatus.Success;
            if (!result.IsSuccess() && result.Transaction == null)
            {
                paymentDetails.TransactionStatus = Models.TransactionStatus.Failure;
            }

            string statusText      = paymentDetails.TransactionStatus == Models.TransactionStatus.Success ? Success : Failure;
            bool   arcadierSuccess = await SetArcadierTransactionStatusAsync(statusText, paymentDetails);

            paymentDetails.ArcadierTransactionStatus = Models.TransactionStatus.Success;
            if (!arcadierSuccess)
            {
                paymentDetails.ArcadierTransactionStatus = Models.TransactionStatus.Failure;
            }

            _db.SaveDetails(model.PayKey, paymentDetails);
            return(RedirectToArcadier(paymentDetails.InvoiceNo));
        }
Esempio n. 4
0
 public IActionResult CreatePayment(CreatePaymentViewModel model)
 {
     if (ModelState.IsValid)
     {
         Payment newPayment = new Payment
         {
             EmployeeId    = model.EmployeeId,
             AmouontPaid   = model.AmouontPaid,
             PaymentMethod = model.PaymentMethod,
             PaymentDate   = model.PaymentDate
         };
         _payment.AddPayment(newPayment);
         return(RedirectToAction("index", "home"));
     }
     return(View());
 }
Esempio n. 5
0
        public ViewResult CreatePayment(int id)
        {
            Employee std               = _student.GetEmployee(id);
            string   firstname         = std.FirstName;
            string   lastname          = std.LastName;
            string   Fullname          = firstname + " " + lastname;
            CreatePaymentViewModel pvm = new CreatePaymentViewModel()
            {
                EmployeeId    = id,
                StudentName   = Fullname,
                AmouontPaid   = 0.00,
                PaymentDate   = DateTime.Now,
                PaymentMethod = Selector.PayMethod.BankTransfer
            };

            return(View(pvm));
        }
        public async Task <CreatedPaymentViewModel> AddAsync(CreatePaymentViewModel model)
        {
            var entity = await _paymentService.CreateAsync(model.Value, model.Installments, model.DebitAccountNumber, model.CreditAccountNumber);

            if (entity != null)
            {
                var debitAccount = await _checkingAccountService.GetByNumberAsync(entity.DebitAccountNumber);

                var creditAccount = await _checkingAccountService.GetByNumberAsync(entity.CreditAccountNumber);

                return(new CreatedPaymentViewModel
                {
                    CreditAccountBalance = creditAccount.Balance,
                    DebitAccountBalance = debitAccount.Balance,
                    NetValue = entity.NetValue
                });
            }

            return(await Task.FromResult <CreatedPaymentViewModel>(null));
        }
Esempio n. 7
0
        public IActionResult CreateGiving(CreatePaymentViewModel input)
        {
            var     context = new OnlineWebPortalDbContext();
            Payment payment = new Payment();

            if (ModelState.IsValid && (input.PaymentType != null))
            {
                var usr  = User.Identity.Name;
                var user = context.RegUsers.Where(u => u.FirstName + " " + u.LastName == usr).SingleOrDefault();


                payment.PaymentType = input.PaymentType;
                payment.PaymentDate = input.PaymentDate;
                payment.Amount      = input.Amount;
                payment.RegUserID   = user.ID;
                //payment.RegUserID = 2;


                context.Add(payment);
                context.SaveChanges();
                return(RedirectToAction("OnlineGiving", "Giving"));
            }
            return(View());
        }
        public async Task <ActionResult> CreateUpdate(string username, int month, int year, string paymentId)
        {
            int currentPaymentid = int.TryParse(paymentId, out int p) ? p : 0;
            var user             = await _employeeRepository.GetEmployeePaymentEventsAsync(username);

            PaymentStrategy strategy = new PaymentStrategy();

            strategy.SetPaymentStrategy(user.PayMethod);
            var payment = strategy.MakePayment(user, month, year);

            payment.PaymentId = currentPaymentid;

            CreatePaymentViewModel model = new CreatePaymentViewModel()
            {
                LoggedUser    = CurrentUser,    //BaseViewModel
                LoggedCompany = CurrentCompany, //BaseViewModel
                LogoUrl       = CurrentLogoUrl, //BaseViewModel

                Employee = user,
                Payment  = payment
            };

            return(View(model));
        }
Esempio n. 9
0
        public ActionResult CreatePayment(CreatePaymentViewModel model)
        {
            if (ModelState.IsValid)
            {
                var payment = new PaymentDTO
                {
                    Amount    = model.Amount,
                    Date      = DateTime.Now,
                    Details   = model.Details,
                    IsSent    = true,
                    Name      = model.Name,
                    Recipient = AccountService.FindByNumber(model.RecipientNumber),
                    SenderId  = model.SelectedAccountId,
                };
                OperationDetails operationDetails = PaymentService.Create(payment);

                if (operationDetails.Succedeed)
                {
                    return(Redirect("/Payment/Index"));
                }
                else
                {
                    var accounts = AccountService.FindUserAccounts(User.Identity.GetUserId()).ToList();
                    model.Accounts = new SelectList(accounts, "Id", "Name");
                    ModelState.AddModelError(operationDetails.Property, operationDetails.Message);
                }

                return(View(model));
            }
            else
            {
                var accounts = AccountService.FindUserAccounts(User.Identity.GetUserId()).ToList();
                model.Accounts = new SelectList(accounts, "Id", "Name");
                return(View(model));
            }
        }
Esempio n. 10
0
 internal CreatePaymentView()
 {
     InitializeComponent();
     DataContext = new CreatePaymentViewModel();
 }
Esempio n. 11
0
        public ActionResult MakePayment([Bind(Include = "PaymentNo,PaymentMethod,BillingAddress,Forename,Surname,CardNumber,SecurityCode,ExpiryDate,PatientId,InvoiceNo,SelectedMethod,InvoiceTotal")] CreatePaymentViewModel payment, string stripeEmail, string stripeToken)
        {
            //checks if model state is valid
            if (ModelState.IsValid)
            {
                //if stripe is choosen then redirect to stripe payment
                if (payment.SelectedMethod == "Stripe")
                {
                    try
                    {
                        return(RedirectToAction("StripePayment", "BillingInvoiceManagement", payment));
                    }
                    catch
                    {
                        ViewBag.ErrorMessage = "Unable to Redirect to stripe payment";
                        return(View(payment));
                    }
                }
                else
                {
                    //handles non stripe payments that can be directly recorded into the database

                    //transfers details from paymentviewmodel to payment
                    Payment temppayment = new Payment {
                        Forename = payment.Forename, Surname = payment.Surname, BillingAddress = payment.BillingAddress, PaymentMethod = payment.SelectedMethod
                    };
                    BillingInvoice billingInvoice = db.BillingInvoices.Find(payment.InvoiceNo);

                    Patient patient = db.Patients.Find(billingInvoice.PatientID);

                    //email process
                    if (patient.Email != null)
                    {
                        EmailService emailService = new EmailService();
                        emailService.SendAsync(new IdentityMessage {
                            Destination = patient.Email, Body = "Your Payment of £" + payment.InvoiceTotal + " for your treatments has been recived", Subject = "Confirmation of Payment"
                        });
                    }

                    //transfers invoice amount to payment amount
                    temppayment.PaymentAmount = billingInvoice.TotalDue;

                    //create payment
                    db.Payments.Add(temppayment);

                    db.SaveChanges();

                    //assosiated payment with invoice then updates
                    billingInvoice.PaymentRecived = true;
                    billingInvoice.PaymentNo      = temppayment.PaymentNo;

                    db.Entry(billingInvoice).State = EntityState.Modified;

                    db.SaveChanges();
                }

                return(RedirectToAction("Index", "BillingInvoiceManagement", new { payment.PatientId }));
            }
            //invalid model message
            ViewBag.ErrorMessage = "Invalid submittion, please enter all values";
            return(View(payment));
        }
Esempio n. 12
0
        public ActionResult StripePayment([Bind(Include = "PaymentNo,PaymentMethod,BillingAddress,Forename,Surname,CardNumber,SecurityCode,ExpiryDate,PatientId,InvoiceNo,SelectedMethod,InvoiceTotal")] CreatePaymentViewModel payment, string stripeEmail, string stripeToken)
        {
            try
            {
                //attributes
                StripeConfiguration.SetApiKey("sk_test_fHaiXwbfFo3YUowus0cFNdOR00HHNl42Yw");
                var customers = new CustomerService();
                var charges   = new ChargeService();

                //create customer
                var customer = customers.Create(new CustomerCreateOptions
                {
                    Email       = stripeEmail,
                    Description = "test purposes Charge",
                    SourceToken = stripeToken,
                });

                //creates charge, unable to correctly record charge as amount requires a long input which my entire project relises on double

                //most tiresome double to list of char to string to int64 casting ever, but succeeds in turing a double to a long compatable with stripe API
                //create list of char from invoice total
                List <char> chartotal = payment.InvoiceTotal.ToString("C2").ToList();

                //scans through char list removing all decimal points
                while (chartotal.Contains('.') || chartotal.Contains(',') || chartotal.Contains('£'))
                {
                    try
                    {
                        chartotal.Remove('.');
                        chartotal.Remove(',');
                        chartotal.Remove('£');
                    }
                    catch
                    {
                        continue;
                    }
                }

                //utalizes stringbuilder to build a string out of the list of char values
                string temptotal = null;
                var    builder   = new StringBuilder();

                foreach (char c in chartotal)
                {
                    builder.Append(c);
                }

                //final string product of the tiresome cast that now must be converted to long below
                temptotal = builder.ToString();
                //

                //create charge
                var charge = charges.Create(new ChargeCreateOptions
                {
                    Amount       = Int64.Parse(temptotal),
                    Description  = "test purposes Charge",
                    Currency     = "gbp",
                    CustomerId   = customer.Id,
                    ReceiptEmail = customer.Email,
                });

                //if charge and customer creation successfull and can be found on stripe then payment is recorded in database
                if (customers.Get(customer.Id) != null && charges.Get(charge.Id) != null)
                {
                    //transfers details from payment view model and finds invoice
                    Payment temppayment = new Payment {
                        Forename = payment.Forename, Surname = payment.Surname, BillingAddress = payment.BillingAddress, PaymentMethod = payment.SelectedMethod
                    };
                    BillingInvoice billingInvoice = db.BillingInvoices.Find(payment.InvoiceNo);

                    Patient patient = db.Patients.Find(billingInvoice.PatientID);

                    //email process
                    if (patient.Email != null)
                    {
                        EmailService emailService = new EmailService();
                        emailService.SendAsync(new IdentityMessage {
                            Destination = patient.Email, Body = "Your Payment of £" + payment.InvoiceTotal + " for your treatments has been recived", Subject = "Confirmation of Payment"
                        });
                    }

                    //transfers total to payment
                    temppayment.PaymentAmount = billingInvoice.TotalDue;

                    //creates payment
                    db.Payments.Add(temppayment);

                    db.SaveChanges();

                    //assosiates payment with invoice then updates
                    billingInvoice.PaymentRecived = true;
                    billingInvoice.PaymentNo      = temppayment.PaymentNo;

                    db.Entry(billingInvoice).State = EntityState.Modified;

                    db.SaveChanges();

                    return(RedirectToAction("Index", "BillingInvoiceManagement", new { payment.PatientId }));
                }
                else
                {
                    //stripe error message
                    ViewBag.ErrorMessage = "Unable to Process Stripe Payment";
                    return(View(payment));
                }
            }
            catch
            {
                //stripe fault error message
                ViewBag.ErrorMessage = "Error encountered during stripe payment";
                return(View(payment));
            }
        }
Esempio n. 13
0
 public ActionResult StripePayment(CreatePaymentViewModel payment)
 {
     return(View(payment));
 }
Esempio n. 14
0
        public ActionResult CreatePayment(CreatePaymentViewModel model, FormCollection form)
        {
            long orderId = Convert.ToInt64(form["orderId"]);
            IEnumerable <PayableOrderViewModel> payableOrders = paymentProvider.CreatePaymentFromOrder(orderId);
            Order order = orderProvider.GetOrder(orderId);

            decimal deliveryCharge = order.DeliveryCharge;
            decimal discValue      = order.DiscValue;
            decimal totalOrder     = payableOrders.Sum(p => p.Quantity * p.UnitPrice - p.DiscValue);
            //decimal serviceChargePercent = configurationProvider.GetConfiguration<decimal>(ConfigurationKeys.ServiceChargePercent);
            //decimal serviceChargeValue = (serviceChargePercent / 100) * totalOrder;
            decimal taxPercent = configurationProvider.GetConfiguration <decimal>(ConfigurationKeys.TaxPercent);
            decimal taxValue   = (taxPercent / 100) * (totalOrder - discValue);

            decimal billableAmount = totalOrder + /*serviceChargeValue +*/ deliveryCharge - discValue + taxValue;
            decimal totalPayment   = PaymentDetailSessionWrapper.TotalPayment;

            if (totalPayment < billableAmount)
            {
                TempData["message"] = "Insufficient payment";
                return(RedirectToAction("CreatePayment", new { orderId = orderId }));
            }
            else
            {
                if (PaymentDetailSessionWrapper.TotalNonCash > billableAmount)
                {
                    TempData["message"] = "Non-cash payment(s) exceed billable amount";
                    return(RedirectToAction("CreatePayment", new { orderId = orderId }));
                }
            }

            var payment = new Payment()
            {
                BilledAmount = billableAmount,
                Date         = DateTime.Today,
                OrderId      = orderId,
                PaidAmount   = totalPayment
            };
            var paymentDetail = new List <PaymentDetail>();

            mapper.Map(PaymentDetailSessionWrapper.Detail, paymentDetail);

            if (totalPayment > billableAmount)
            {
                decimal change = totalPayment - billableAmount;
                var     paymentDetailChange = new PaymentDetail();
                paymentDetailChange.PaymentTypeId = 1;
                paymentDetailChange.Amount        = change * -1;
                paymentDetailChange.Notes         = "Change";
                paymentDetail.Add(paymentDetailChange);
            }

            payment.PaymentDetails.AddRange(paymentDetail);
            paymentProvider.AddPayment(order, payment);

            long paymentId = payment.Id;

            TempData["PaymentId"] = paymentId;

            OrderDetailSessionWrapper.Clear();
            PaymentDetailSessionWrapper.Clear();

            return(RedirectToAction("Detail", new { id = paymentId, mode = StringHelper.XorString("confirmation") }));
        }
Esempio n. 15
0
        public async Task <IActionResult> CreateAsync([FromBody] CreatePaymentViewModel model)
        {
            var response = await _paymentApplicationService.AddAsync(model);

            return(Response(response, (int)HttpStatusCode.Created));
        }