Beispiel #1
0
 public EmailResult ConfirmOrder(Order order)
 {
     To.Add(order.Customer.Email);
     From = "*****@*****.**";
     Subject = "Fashinon Order Confirmation";
     return Email("ConfirmOrder", order);
 }
Beispiel #2
0
        //TODO: This should be an order!
        public ConfirmPaymentResponse ConfirmPayment(Order order)
        {
            var executor = GetExecutor();

            ConfirmPaymentRequest request = new ConfirmPaymentRequest(executor);
            request.Currency = "GBP";
            return request.Execute(order);
        }
Beispiel #3
0
 public ActionResult Edit(Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(order);
 }
Beispiel #4
0
        public ActionResult Create(Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(order);
        }
Beispiel #5
0
        public ActionResult Create(Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "Title", order.CustomerID);
            return View(order);
        }
        public ConfirmPaymentResponse Execute(Order order)
        {
            NVPCodec encoder = new NVPCodec();
            if (order.Payment is PayPalPayment)
            {
                var payment = order.Payment as PayPalPayment;

                encoder["METHOD"] = METHOD;
                encoder["TOKEN"] = payment.Token;
                encoder["PAYMENTACTION"] = "Sale";
                encoder["PAYERID"] = payment.PayerID;
                encoder["AMT"] = order.GrandTotal.ToString("#.##");
                encoder["CURRENCYCODE"] = this.Currency;

                var decoder = executorService.Execute(encoder);

                string strAck = decoder["ACK"].ToLower();
                if (strAck != null && (strAck == "success" || strAck == "successwithwarning"))
                {
                    payment.CorrelationID = decoder["CORRELATIONID"];
                    payment.CurrencyCode = decoder["CURRENCYCODE"];
                    payment.FeeAmount = decimal.Parse(decoder["FEEAMT"]);
                    payment.PaymentAmount = decimal.Parse(decoder["AMT"]);
                    payment.Status = decoder["PAYMENTSTATUS"];
                    payment.PendingReason = decoder["PENDINGREASON"];
                    payment.ReasonCode = decoder["REASONCODE"];
                    payment.TransactionID = decoder["TRANSACTIONID"];
                    return new ConfirmPaymentResponse();
                }
                else
                {

                    throw new PayPalExeception(decoder["L_ERRORCODE0"], decoder["L_SHORTMESSAGE0"], decoder["L_LONGMESSAGE0"]);
                }
            }
            else
            {
                throw new PayPalExeception("The payment method on the order is not valid for paypal confirmation");
            }
        }
Beispiel #7
0
        public ActionResult Shipping(string token, string payerId)
        {
            // Get the address details from the paypal service
            var response = payPalService.ShippingDetails(token);
            var basket = basketService.GetBasket();

            var customer = dbContext.Customers.Where(x => x.ExternalReference == response.Customer.ExternalReference).SingleOrDefault();

            if (customer == null)
            {
                // We need to save the customer
                dbContext.Customers.Add(response.Customer);
                dbContext.SaveChanges();
            }
            else
            {
                response.Customer = customer;
            }

            // Creates a new paypal payment
            var payment = new PayPalPayment();
            payment.PayerID = payerId;
            payment.Token = token;
            payment.Status = "Pending";

            Order order = new Order();
            order.ShippingAddress = response.ShippingAddress;
            order.Customer = response.Customer;
            order.Items = basket.Items;
            order.Payment = payment;
            order.Status = "Initial";
            order.Created = DateTime.Now;
            order.Updated = DateTime.Now;

            // Selects the first shipping method the customer can select another later in order summary
            order.ShippingMethod = shippingService.GetShippingMethods(order.ShippingAddress, order.TotalWeight, 0, 0, 0).First();

            //TODO: Remove this it will not be needed much longer!
            orderService.SetCurrentOrder(order);

            //TODO: Establish the customer here
            customerService.EstablishCustomer(order.Customer);

            dbContext.Orders.Add(order);

            try
            {
                dbContext.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                var error = ex.ToString();
            }
            //var confirm = payPalService.ConfirmPayment(basket);

            return RedirectToAction("Shipping", "Order");
        }
Beispiel #8
0
 public void SetCurrentOrder(Order order)
 {
     HttpRuntime.Cache.Insert("order", order);
 }
Beispiel #9
0
 public void SaveOrder(Order order)
 {
     dbContext.Update(order);
 }
Beispiel #10
0
 public ActionResult Edit(Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "Title", order.CustomerID);
     return View(order);
 }