protected void btnSaveOrder_Click(object sender, EventArgs e)
        {
            InventoryBL bl    = new InventoryBL();
            tbl_Orders  order = new tbl_Orders()
            {
                Order_Id         = 0,
                Product_Id       = Convert.ToInt32(ddlProducts.SelectedItem.Value),
                Items_Count      = Convert.ToInt32(ddlNumberOfItems.SelectedItem.Value),
                Product_Cost     = Convert.ToInt32(txtCost.Text),
                Amount           = Convert.ToInt32(txtAmount.Text),
                Customer_Name    = txtCustName.Text,
                Customer_Address = txtAddress.Text,
                Customer_Phone   = txtCustPhone.Text,
                Gross_Amount     = Convert.ToInt32(txtGrossAmount.Text),
                Service_Charge   = Convert.ToInt32(txtServiceCharge.Text),
                Vat_Charge       = Convert.ToInt32(txtVat.Text),
                NetAmount        = Convert.ToInt32(txtNetAmount.Text)
            };

            //if (!bl.ValidateProduct(product))
            //{
            bool result = bl.SaveOrder(order);

            if (result == true)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "product error", "alert('Order placed successfully!');", true);
                Response.Redirect("Orders.aspx");
            }
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            tbl_Orders             tbl_orders = db.tbl_Orders.Find(id);
            List <tbl_OrderDetail> arr        = tbl_orders.tbl_OrderDetail.ToList();

            if (tbl_orders.Status == OrderStatus.Delivery)
            {
                foreach (var item in arr)
                {
                    tbl_Items sp = db.tbl_Items.Find(item.ItemID);
                    if (sp != null)
                    {
                        sp.ItemCount      += item.Qty.Value;
                        db.Entry(sp).State = EntityState.Modified;
                    }
                }
            }

            foreach (var item in arr)
            {
                db.tbl_OrderDetail.Remove(item);
            }

            db.tbl_Orders.Remove(tbl_orders);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        private static Tuple <decimal, decimal> GetOrderPriceAndTax(tbl_Orders table)
        {
            if (table == null || table.tbl_OrderContent.Count == 0)
            {
                return(new Tuple <decimal, decimal>(0, 0));
            }

            decimal totalPrice = 0, totalTaxAmount = 0;

            foreach (var content in table.tbl_OrderContent)
            {
                Tuple <decimal, decimal> priceAndTax = PriceManager.GetPrice(content.OC_Price.GetValueOrDefault(), content.OC_Tax.GetValueOrDefault(0), (int)content.OC_Quantity.GetValueOrDefault(0), table.O_DomainID);
                totalPrice     += priceAndTax.Item1;
                totalTaxAmount += priceAndTax.Item2;
            }

            if (table.tbl_Discount != null)
            {
                Tuple <decimal, decimal> priceAndTax = PriceManager.AddDiscountToPrice(table.tbl_Discount, totalPrice, totalTaxAmount, table.O_DomainID);
                totalPrice     = priceAndTax.Item1;
                totalTaxAmount = priceAndTax.Item2;
            }

            if (table.tbl_Postage != null)
            {
                decimal maxTax = table.tbl_OrderContent.Max(bc => bc.GetTaxValue());
                Tuple <decimal, decimal> postagePriceAndTax = PriceManager.GetPostagePriceAndTax(table.tbl_Postage, maxTax, table.O_DomainID);
                totalPrice     += postagePriceAndTax.Item1;
                totalTaxAmount += postagePriceAndTax.Item2;
            }

            return(new Tuple <decimal, decimal>(totalPrice, totalTaxAmount));
        }
Exemplo n.º 4
0
        public ActionResult UpdateStatusOrder(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_Orders tbl_Orders = db.tbl_Orders.Find(id);

            if (tbl_Orders == null)
            {
                return(HttpNotFound());
            }
            else
            {
                if (tbl_Orders.TrangThai)
                {
                    tbl_Orders.TrangThai = false;
                }
                else
                {
                    tbl_Orders.TrangThai = true;
                }
                db.SaveChanges();
            }
            var model = db.tbl_Orders.ToList().OrderByDescending(x => x.NgayDat);

            return(View("OrderList", model));
        }
Exemplo n.º 5
0
        public ActionResult Payment(int orderID = 0)
        {
            if (orderID > 0)
            {
                tbl_Orders order = ECommerceService.GetOrderByID(orderID);
                if (order == null)
                {
                    throw new Exception("No order has been found");
                }
                else
                {
                    string currencyCode = DomainService.GetSettingsValue(BL.SettingsKey.payPalCurrencyCode, this.DomainID);
                    ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.Initialized, currencyCode);
                    string payPalUrl = SetExpressCheckout(order, PayPalLandingPageUrl, PayPalLandingPageUrl,
                                                          DomainService.GetSettingsValue(BL.SettingsKey.payPalUsername, this.DomainID),
                                                          DomainService.GetSettingsValue(BL.SettingsKey.payPalPassword, this.DomainID),
                                                          DomainService.GetSettingsValue(BL.SettingsKey.payPalSignature, this.DomainID),
                                                          currencyCode,
                                                          PayPalApiUrlNvp,
                                                          DomainService.GetSettingsValue(BL.SettingsKey.payPalCgiUrl, this.DomainID),
                                                          order.OrderID.ToString(),
                                                          DomainService.GetSettingsValue(BL.SettingsKey.payPalLanguageCode, this.DomainID));

                    if (!string.IsNullOrEmpty(payPalUrl))
                    {
                        return(new RedirectResult(payPalUrl));
                    }
                }
            }

            return(RedirectToRoute("Website", new { action = "PaymentError", orderID = orderID.ToString() }));
        }
 public HttpResponseMessage put(int id, [FromBody] tbl_Orders tbl_Orders)
 {
     try
     {
         using (OrderDBEntities entities = new OrderDBEntities())
         {
             var entity = entities.tbl_Orders.FirstOrDefault(e => e.OrderID == id);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Order with id = " + id.ToString() + "Not found to update"));
             }
             else
             {
                 entity.Buyer_Name      = tbl_Orders.Buyer_Name;
                 entity.Buyer_Mobileno  = tbl_Orders.Buyer_Mobileno;
                 entity.OrderStatus     = tbl_Orders.OrderStatus;
                 entity.ShippingAddress = tbl_Orders.ShippingAddress;
                 entity.Orderitems      = tbl_Orders.Orderitems;
                 entity.OrderitemID     = tbl_Orders.OrderitemID;
                 entity.Orderdate       = tbl_Orders.Orderdate;
                 entity.Email           = tbl_Orders.Email;
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK, entity));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
        public HttpResponseMessage Post(int id, [FromBody] tbl_Orders tbl_Orders)
        {
            try
            {
                using (OrderDBEntities entities = new OrderDBEntities())
                {
                    var entity = entities.tbl_Orders.FirstOrDefault(e => e.OrderID == id);
                    if (tbl_Orders.Email == "Placed")
                    {
                        MailMessage mm         = new MailMessage();
                        SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                        entity.Email = tbl_Orders.Email;
                        //tbl_Orders.Subject = "Order Plased..";
                        //tbl_Orders.Body = "Your Order Have been plased...";

                        SmtpServer.Port        = 25;
                        SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "38jduw@@1#");
                        SmtpServer.EnableSsl   = false;
                        SmtpServer.Send(mm);
                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.BadGateway));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadGateway));
            }
        }
Exemplo n.º 8
0
        private string UrlConstructor(tbl_Orders order)
        {
            string   currencyCode = DomainService.GetSettingsValue(SettingsKey.secureTradingCurrencyCode, this.DomainID);
            NVPCodec encoder      = InitializeEncoder(order, currencyCode);

            return("https://payments.securetrading.net/process/payments/choice?" + encoder.Encode());
        }
Exemplo n.º 9
0
        public static string GetDeliveryAmountString(this tbl_Orders table, bool hideTax = false)
        {
            IDomain domainService = (IDomain)DependencyResolver.Current.GetService <IDomain>();

            bool useTax           = domainService.GetSettingsValueAsBool(SettingsKey.useTax, table.O_DomainID);
            bool priceIncludesVat = domainService.GetSettingsValueAsBool(SettingsKey.priceDisplayIncludesVAT, table.O_DomainID);

            return(PriceManager.FormatPrice((useTax && priceIncludesVat) ? table.TotalDeliveryAmount : table.DeliveryCharge.GetValueOrDefault(0), table.DeliveryTax.GetValueOrDefault(0), table.O_DomainID, hideTax));
        }
Exemplo n.º 10
0
        public ActionResult Delete(int id = 0)
        {
            tbl_Orders tbl_orders = db.tbl_Orders.Find(id);

            if (tbl_orders == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_orders));
        }
Exemplo n.º 11
0
        public static decimal GetDeliveryAmount(this tbl_Orders table)
        {
            IDomain domainService = (IDomain)DependencyResolver.Current.GetService <IDomain>();

            bool useTax           = domainService.GetSettingsValueAsBool(SettingsKey.useTax, table.O_DomainID);
            bool priceIncludesVat = domainService.GetSettingsValueAsBool(SettingsKey.priceDisplayIncludesVAT, table.O_DomainID);

            return((useTax && priceIncludesVat) ?
                   table.TotalDeliveryAmount :
                   table.DeliveryCharge.GetValueOrDefault(0));
        }
Exemplo n.º 12
0
        public ActionResult PaymentSuccess(SagePayResponse response)
        {
            tbl_Orders order = null;

            if (response != null)
            {
                order = ECommerceService.GetOrderByVendorCode(response.VendorTxCode, DomainID);
            }

            return(RedirectToAction("ThankYou", "Website", new { orderID = order != null ? order.OrderID : 0 }));
        }
Exemplo n.º 13
0
        public ActionResult PaymentFailed(SagePayResponse response)
        {
            tbl_Orders order = null;

            if (response != null)
            {
                order = ECommerceService.GetOrderByVendorCode(response.VendorTxCode, this.DomainID);
            }

            return(RedirectToAction("PaymentError", "Website", new { orderID = order != null ? order.OrderID : 0, errorMessage = order.Status }));
        }
Exemplo n.º 14
0
        private NVPCodec InitializeEncoder(tbl_Orders order)
        {
            decimal totalItemsPrice = order.tbl_OrderContent.Sum(oc => oc.OC_TotalPrice) + order.DependentOrders.Sum(o => o.TotalAmount);

            string totalAmount         = Math.Round(order.TotalAmountToPay, 2).ToString().Replace(',', '.');
            string totalTaxAmount      = Math.Round(order.TotalTaxAmount, 2).ToString().Replace(',', '.');
            string totalItemsAmount    = order.O_IsCustomAmount ? order.TotalAmountToPay.ToString().Replace(',', '.') : Math.Round(totalItemsPrice, 2).ToString().Replace(',', '.');
            string totalShippingAmount = Math.Round(order.TotalDeliveryAmount, 2).ToString().Replace(',', '.');

            NVPCodec encoder = new NVPCodec();

            encoder[PayPalConsts.Version]          = "98.0";
            encoder[PayPalConsts.TotalAmount]      = totalAmount;
            encoder[PayPalConsts.DeliveryAmount]   = totalShippingAmount;
            encoder[PayPalConsts.ItemsTotalAmount] = totalItemsAmount;

            if (order.DiscountAmount != 0)
            {
                decimal discount = order.DiscountAmount > totalItemsPrice ? totalItemsPrice : order.DiscountAmount;
                encoder[PayPalConsts.DiscountAmount] = Math.Round(-Math.Abs(discount), 2).ToString().Replace(',', '.');
            }

            // if order items should be listed in order details displayed on PayPal account
            if (DomainService.GetSettingsValueAsBool(BL.SettingsKey.payPalSendOrderItems, this.DomainID) && !order.O_IsCustomAmount)
            {
                int i = 0;
                foreach (var oc in order.tbl_OrderContent)
                {
                    encoder[PayPalConsts.GetItemNumberKey(i)] = oc.tbl_Products == null?oc.tbl_ProductPrice.PR_ProductID.ToString() : oc.tbl_Products.P_ProductCode;

                    encoder[PayPalConsts.GetItemNameKey(i)]         = oc.OC_Title ?? "";
                    encoder[PayPalConsts.GetItemDescriptionKey(i)]  = oc.OC_Description ?? "";
                    encoder[PayPalConsts.GetItemQuantityKey(i)]     = oc.OC_Quantity.ToString();
                    encoder[PayPalConsts.GetItemsTotalAmountKey(i)] = Math.Round(oc.OC_TotalPrice / oc.OC_Quantity.GetValueOrDefault(1), 2).ToString().Replace(',', '.');

                    i++;
                }
                if (order.DependentOrders.Any())
                {
                    foreach (var donation in order.DependentOrders)
                    {
                        encoder[PayPalConsts.GetItemNumberKey(i)]       = donation.OrderID.ToString();
                        encoder[PayPalConsts.GetItemNameKey(i)]         = String.Format("Donation to order {0}", order.OrderID);
                        encoder[PayPalConsts.GetItemDescriptionKey(i)]  = "donation";
                        encoder[PayPalConsts.GetItemQuantityKey(i)]     = "1";
                        encoder[PayPalConsts.GetItemsTotalAmountKey(i)] = Math.Round(donation.TotalAmount, 2).ToString().Replace(',', '.');

                        i++;
                    }
                }
            }

            return(encoder);
        }
Exemplo n.º 15
0
        public ActionResult Create(tbl_Orders tbl_orders)
        {
            if (ModelState.IsValid)
            {
                db.tbl_Orders.Add(tbl_orders);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID = new SelectList(db.tbl_Customers, "CustomerID", "CustomerName", tbl_orders.CustomerID);
            return(View(tbl_orders));
        }
Exemplo n.º 16
0
        private string CreateRequestSecurityCode(tbl_Orders order, string currencyCode)
        {
            StringBuilder s = new StringBuilder();

            s.Append(order.TotalAmountToPay.ToString("C"))
            .Append(currencyCode)
            .Append(order.OrderID)
            .Append(GetReferenceSite(order.O_DomainID))
            .Append(DomainService.GetSettingsValue(SettingsKey.secureTradingRedirectPassword, this.DomainID));

            return(Sha256.GetSHA256Hash(s.ToString()));
        }
Exemplo n.º 17
0
        public ActionResult Edit(int id = 0)
        {
            tbl_Orders tbl_orders = db.tbl_Orders.Find(id);

            if (tbl_orders == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DeliveryDate = tbl_orders.DeliveryDate == null ? "" : tbl_orders.DeliveryDate.Value.ToString("dd/MM/yyyy");
            ViewBag.Customer     = db.tbl_Customers.Find(tbl_orders.CustomerID).CustomerName;
            ViewBag.Amount       = tbl_orders.tbl_OrderDetail.Sum(a => a.Amount).Value.ToString("#,###");
            //ViewBag.currStatus = tbl_orders.Status;
            return(View(tbl_orders));
        }
Exemplo n.º 18
0
 private int Insert(tbl_Orders order)
 {
     try
     {
         db.tbl_Orders.Add(order);
         db.SaveChanges();
         return(order.Id);
     }
     catch (Exception ex)
     {
         Console.Write(ex);
         throw;
     }
 }
Exemplo n.º 19
0
        public ActionResult OrderDetails(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_Orders tbl_Orders = db.tbl_Orders.Find(id);

            if (tbl_Orders == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_Orders));
        }
Exemplo n.º 20
0
        private string SetExpressCheckout(tbl_Orders order, string payPalReturnUrl, string payPalCancelUrl, string payPalUser, string payPalPassword, string payPalSignature, string payPalCurrencyCode, string payPalNvpSetExpressUrl, string payPalHost, string invoiceID, string languageCode)
        {
            string resultToLog;

            NVPCodec encoder = InitializeEncoder(order);

            encoder[PayPalConsts.Method]       = "SetExpressCheckout";
            encoder[PayPalConsts.NoShipping]   = "1";
            encoder[PayPalConsts.ReturnUrl]    = payPalReturnUrl;
            encoder[PayPalConsts.CancelUrl]    = payPalCancelUrl;
            encoder[PayPalConsts.User]         = payPalUser;
            encoder[PayPalConsts.Pwd]          = payPalPassword;
            encoder[PayPalConsts.Signature]    = payPalSignature;
            encoder[PayPalConsts.CurrencyCode] = payPalCurrencyCode;
            encoder[PayPalConsts.InvoiceID]    = invoiceID;

            if (!string.IsNullOrEmpty(languageCode))
            {
                encoder[PayPalConsts.LocaleCode] = languageCode;
            }

            string settings = encoder.GetSettings();

            Log.Info(settings);

            string encoded = encoder.Encode();
            string result  = resultToLog = HttpPost(payPalNvpSetExpressUrl, encoded, 30000);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(result);

            string token = decoder[PayPalConsts.Token];

            if (decoder[PayPalConsts.ACK].ToLower() == "success" || decoder[PayPalConsts.ACK].ToLower() == "successwithwarning")
            {
                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.PayPal_SetExpressCheckout_Success);
                ECommerceService.UpdateOrderSecurityKey(token, order.OrderID);
                return(String.Format("{0}?cmd=_express-checkout&{1}={2}&{3}={4}", payPalHost, PayPalConsts.Token.ToLower(), token, PayPalConsts.Useraction, PayPalConsts.Commit));
            }
            else
            {
                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.PayPal_SetExpressCheckout_Failure);
                resultToLog = Server.UrlDecode(resultToLog).Replace("&", Environment.NewLine);
                Log.Error(String.Format("PayPal payment - SetExpressCheckout failed: {0}", resultToLog));
            }

            return(String.Empty);
        }
        public tbl_Orders Create(tbl_Orders product)
        {
            return(new tbl_Orders()
            {
                OrderitemID = product.OrderitemID,
                Ordersdetails = product.Ordersdetails.Select(p => Create(p)),

                //Productname = product.Productname,
                //height = product.height,
                //Image = product.Image,
                //Barcode = product.Barcode,
                //SKU = product.SKU,
                //AvailableQuantity = product.AvailableQuantity
            });
        }
Exemplo n.º 22
0
        protected tbl_Orders FindOrder()
        {
            tbl_Orders order = null;

            if (Request.IsAuthenticated && !AdminUser.IsAdmn)
            {
                var customer = UserService.GetCustomerByID(this.AdminUser.UserID);
                if (customer != null)
                {
                    order = customer.tbl_Orders.OrderByDescending(c => c.OrderID).FirstOrDefault();
                }
            }

            return(order);
        }
Exemplo n.º 23
0
        public ActionResult Payment(int orderID = 0)
        {
            if (orderID <= 0)
            {
                return(RedirectToRoute("Website", new { action = "PaymentError", orderID = orderID.ToString() }));
            }

            tbl_Orders order = _eCommerceService.GetOrderByID(orderID);

            if (order == null)
            {
                throw new Exception("No order has been found");
            }

            return(View());
        }
Exemplo n.º 24
0
        public static void SendOrderCancelConfirmation(tbl_Orders order)
        {
            if (order != null && !string.IsNullOrEmpty(order.CustomerEMail))
            {
                var templateData = new Dictionary <string, object>();
                templateData.Add("$ORDERNO", order.OrderID.ToString());

                string template = GetTemplate(EmailVariables.OrderCancelConfirmation, templateData);

                var recipients = new List <string>()
                {
                    order.CustomerEMail
                };
                MailSender.Instance.SendEmail(recipients, null, null, "Order Canceled", template);
            }
        }
Exemplo n.º 25
0
        private StripeCustomer CreateStripeCustomer(string apiKey, tbl_Orders order, StripeCheckoutModel model)
        {
            var myCustomer = new StripeCustomerCreateOptions
            {
                Email               = order.CustomerEMail,
                Description         = order.BillingFullName,
                CardNumber          = model.CreditCardNumber,
                CardExpirationYear  = model.ExpiryYear.ToString(),
                CardExpirationMonth = model.ExpiryMonth.ToString()
            };

            var customerService = new StripeCustomerService(apiKey);
            var stripeCustomer  = customerService.Create(myCustomer);

            return(stripeCustomer);
        }
Exemplo n.º 26
0
        public ActionResult Edit(tbl_Orders tbl_orders, OrderStatus currStatus)
        {
            var date = DateTime.Now;

            tbl_orders.DeliveryDate = null;
            string[] s = (Request.Form["datepicker"] + "").Split('/');
            try
            {
                date = new DateTime(Convert.ToInt16(s[2]), Convert.ToInt16(s[1]), Convert.ToInt16(s[0]));
                tbl_orders.DeliveryDate = date;
            }
            catch (Exception e) { if (tbl_orders.Status == OrderStatus.Delivery)
                                  {
                                      ModelState.AddModelError("DeliveryDate", "Ngày giao hàng chưa đúng");
                                  }
            }
            if (ModelState.IsValid)
            {
                //tbl_Orders currOrder = db.tbl_Orders.Find(tbl_orders.OrderID);
                if (tbl_orders.Status == OrderStatus.Delivery && currStatus == OrderStatus.Order)
                {
                    foreach (var item in db.tbl_OrderDetail.Where(a => a.OrderID == tbl_orders.OrderID))
                    {
                        tbl_Items sp = db.tbl_Items.Find(item.ItemID);
                        sp.ItemCount      -= item.Qty.Value;
                        db.Entry(sp).State = EntityState.Modified;
                    }
                }
                if (tbl_orders.Status != OrderStatus.Delivery && currStatus == OrderStatus.Delivery)
                {
                    foreach (var item in db.tbl_OrderDetail.Where(a => a.OrderID == tbl_orders.OrderID))
                    {
                        tbl_Items sp = db.tbl_Items.Find(item.ItemID);
                        sp.ItemCount      += item.Qty.Value;
                        db.Entry(sp).State = EntityState.Modified;
                    }
                }
                db.Entry(tbl_orders).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            tbl_orders           = db.tbl_Orders.Find(tbl_orders.OrderID);
            ViewBag.Customer     = db.tbl_Customers.Find(tbl_orders.CustomerID).CustomerName;
            ViewBag.DeliveryDate = tbl_orders.DeliveryDate == null ? "" : tbl_orders.DeliveryDate.Value.ToString("dd/MM/yyyy");
            ViewBag.Amount       = tbl_orders.tbl_OrderDetail.Sum(a => a.Amount).Value.ToString("#,###");
            return(View(tbl_orders));
        }
Exemplo n.º 27
0
        public ActionResult Payment(int orderID = 0)
        {
            if (orderID > 0)
            {
                tbl_Orders order = ECommerceService.GetOrderByID(orderID);
                if (order == null)
                {
                    throw new Exception("No order has been found");
                }

                string currencyCode = DomainService.GetSettingsValue(SettingsKey.secureTradingCurrencyCode, this.DomainID);

                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, PaymentStatus.Initialized, currencyCode);
                return(new RedirectResult(UrlConstructor(order)));
            }
            return(RedirectToRoute("Website", new { action = "PaymentError", orderID = orderID.ToString() }));
        }
Exemplo n.º 28
0
        public PayPalPaymentStatus DoExpressCheckoutPayment(tbl_Orders order, string token, string payerId, string payPalCurrencyCode, string payPalReturnUrl, string payPalCancelUrl, string payPalUser, string payPalPassword, string payPalSignature, string payPalNvpSetExpressUrl, string invoiceID)
        {
            string resultToLog;

            NVPCodec encoder = InitializeEncoder(order);

            encoder[PayPalConsts.Method]        = "DoExpressCheckoutPayment";
            encoder[PayPalConsts.Token]         = token;
            encoder[PayPalConsts.PaymentAction] = "Sale";
            encoder[PayPalConsts.PayerId]       = payerId;
            encoder[PayPalConsts.CurrencyCode]  = payPalCurrencyCode;
            encoder[PayPalConsts.ReturnUrl]     = payPalReturnUrl;
            encoder[PayPalConsts.CancelUrl]     = payPalCancelUrl;
            encoder[PayPalConsts.User]          = payPalUser;
            encoder[PayPalConsts.Pwd]           = payPalPassword;
            encoder[PayPalConsts.Signature]     = payPalSignature;
            encoder[PayPalConsts.InvoiceID]     = invoiceID;

            string encoded = encoder.Encode();
            string result  = resultToLog = HttpPost(payPalNvpSetExpressUrl, encoded, 30000);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(result);

            PayPalPaymentStatus payPalStatus = new PayPalPaymentStatus();

            payPalStatus.TransactionID = decoder[PayPalConsts.TransactionID];
            payPalStatus.Token         = decoder[PayPalConsts.Token];
            payPalStatus.ACK           = decoder[PayPalConsts.ACK];
            payPalStatus.PaymentStatus = decoder[PayPalConsts.PaymentStatus];
            payPalStatus.PendingReason = decoder[PayPalConsts.PendingReason];
            payPalStatus.ErrorCode     = decoder[PayPalConsts.ErrorCode];
            payPalStatus.ErrorMessage  = decoder[PayPalConsts.ErrorMessage];

            if (payPalStatus.ACK.ToLower() != "success")
            {
                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.PayPal_DoExpressCheckout_Failure);
                resultToLog = Server.UrlDecode(resultToLog).Replace("&", Environment.NewLine);
                Log.Error(String.Format("PayPal payment - DoExpressCheckoutPayment failed: {0}", resultToLog));
            }

            return(payPalStatus);
        }
Exemplo n.º 29
0
        public ActionResult ThankYou(int id = 0)
        {
            tbl_Orders tbl_orders = db.tbl_Orders.Find(id);

            if (tbl_orders == null)
            {
                if (tbl_orders == null)
                {
                    return(HttpNotFound());
                }
            }
            var cus = new laca.Models.lacashop_dbEntities().tbl_Customers.Find(tbl_orders.CustomerID);

            ViewBag.cusName            = cus.CustomerName;
            Session[Session.SessionID] = null;

            //return View(tbl_orders);
            return(View());
        }
        public HttpResponseMessage Post([FromBody] tbl_Orders tbl_Orders)
        {
            try
            {
                using (OrderDBEntities entities = new OrderDBEntities())
                {
                    entities.tbl_Orders.Add(tbl_Orders);
                    entities.SaveChanges();

                    var Message = Request.CreateResponse(HttpStatusCode.Created, tbl_Orders);
                    Message.Headers.Location = new Uri(Request.RequestUri + tbl_Orders.OrderID.ToString());
                    return(Message);
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }