public ActionResult CreatePayment(long orderId)
        {
            if (paymentProvider.IsPaid(orderId))
            {
                return(RedirectToAction("Index", "Home", new { area = String.Empty }));
            }

            Order order = orderProvider.GetOrder(orderId);
            var   model = new CreatePaymentViewModel();

            var payableOrders = paymentProvider.CreatePaymentFromOrder(orderId);

            model.OrderDetails = payableOrders;

            //decimal serviceChargePercent = configurationProvider.GetConfiguration<decimal>(ConfigurationKeys.ServiceChargePercent);
            //model.ServiceChargeValue = (serviceChargePercent / 100) * model.TotalOrders;

            decimal taxPercent = configurationProvider.GetConfiguration <decimal>(ConfigurationKeys.TaxPercent);

            model.TaxValue = (taxPercent / 100) * (model.TotalOrders - order.DiscValue);

            model.DeliveryCharge = order.DeliveryCharge;
            model.DiscValue      = order.DiscValue;
            model.DiscPercent    = order.DiscPercent;

            return(View(model));
        }
Beispiel #2
0
        public ActionResult Edit(int id)
        {
            var model = new CreateEditViewModel();

            model.SelectedOrder        = orderProvider.GetOrder(id);
            model.SelectedOrderDetails = orderProvider.GetOrderDetails(id);
            model.PaymentConfirmation  = orderProvider.GetPaymentConfirmation(id);
            //model.StatusHistories = orderProvider.GetOrderStatusHistories(id, true);
            return(View(model));
        }
        public ActionResult OrderHistoryDetail(int orderId)
        {
            var viewModel = new OrderHistoryDetailViewModel();
            var order     = orderProvider.GetOrder(orderId);

            viewModel.SelectedOrder        = order;
            viewModel.SelectedOrderDetails = orderProvider.GetOrderDetails(orderId);
            viewModel.DeliveryTimeName     = deliveryTimeProvider.GetDeliveryTime(order.DeliveryTime).Name;
            //viewModel.StatusHistories = orderProvider.GetOrderStatusHistories(orderId);
            viewModel.PaymentConfirmation = orderProvider.GetPaymentConfirmation(orderId);
            if (!orderProvider.ValidateOrderOwner(orderId, CurrentUserName))
            {
                return(RedirectToAction("OrderHistory"));
            }

            return(PartialView(viewModel));
        }
        public ActionResult Edit(long id)
        {
            var orderViewModel       = new CreateEditViewModel();
            var orderDetailViewModel = new List <OrderDetailEntryViewModel>();
            var order = orderProvider.GetOrder(id);

            if (order != null)
            {
                var orderDetail = orderProvider.GetOrderDetail(order.Id);
                if (orderDetail != null)
                {
                    mapper.Map(order, orderViewModel);
                    mapper.Map(orderDetail, orderDetailViewModel);
                    OrderDetailSessionWrapper.Initialize(orderDetailViewModel);
                    return(View("CreateEdit", orderViewModel));
                }
            }
            return(View("Index"));
        }
        /// <summary>
        /// Creates the post request.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="connector">The connector.</param>
        /// <param name="paymentId">The payment id.</param>
        /// <returns></returns>
        private static string CreatePostRequest(ConfigurationProvider configuration, CrmConnector connector, lss_payment payment)
        {
            OrderProvider   orderProvider   = new OrderProvider(connector);
            ContactProvider contactProvider = new ContactProvider(connector);
            PaymentProvider paymentProvider = new PaymentProvider(connector);

            var order   = orderProvider.GetOrder(payment.lss_orderid.Id);
            var contact = contactProvider.GetContact(order.CustomerId.Id);

            StringBuilder postRequest = new StringBuilder();

            payment.lss_vendortxcode = CreateVendorTransactionCode(order.Name);

            // Save the record so the payment has a name
            payment.lss_name = "Payment: " + payment.lss_vendortxcode + " - £" + payment.lss_amount.Value.ToString("#.##");
            paymentProvider.SavePayment(payment);

            // Check the Contact has the relevant details for a sucessful transaction
            if (String.IsNullOrEmpty(contact.FirstName) ||
                String.IsNullOrEmpty(contact.LastName) ||
                String.IsNullOrEmpty(contact.Address1_Line1) ||
                String.IsNullOrEmpty(contact.Address1_City) ||
                String.IsNullOrEmpty(contact.Address1_PostalCode))
            {
                return("INVALIDCONTACT");
            }

            postRequest.Append("VPSProtocol=2.23&TxType=PAYMENT&Vendor=");
            postRequest.Append(configuration.VendorName);
            postRequest.Append("&VendorTxCode=" + payment.lss_vendortxcode);
            postRequest.Append("&Amount=" + payment.lss_amount.Value.ToString("#.##"));
            postRequest.Append("&Currency=GBP");
            postRequest.Append("&Description=" + order.Name);
            postRequest.Append("&NotificationURL=" + configuration.NotificationUrl);
            postRequest.Append(BuildContactDetails(contact));
            postRequest.Append("&CustomerEMail=" + (String.IsNullOrEmpty(contact.EMailAddress1) ? String.Empty : contact.EMailAddress1.Trim()));
            postRequest.Append(BuildBasket(connector, orderProvider, order));
            postRequest.Append("&AllowGiftAid=0&ApplyAVSCV2=0&Apply3DSecure=0&Profile=NORMAL&AccountType=M");

            return(postRequest.ToString());
        }