protected int GetCount() { int cartCount = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart).Count; int indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders().Count; return(cartCount + indOrders); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } if (!Page.IsPostBack) { OrderCollection orderCollection = NopContext.Current.User.Orders; if (orderCollection.Count == 0) { Response.Redirect("~/Default.aspx"); } Order lastOrder = orderCollection[0]; lblOrderNumber.Text = lastOrder.OrderID.ToString(); hlOrderDetails.NavigateUrl = string.Format("{0}OrderDetails.aspx?OrderID={1}", CommonHelper.GetStoreLocation(), lastOrder.OrderID); var shoppingCart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); foreach (ShoppingCartItem sc in shoppingCart) { ShoppingCartManager.DeleteShoppingCartItem(sc.ShoppingCartItemID, false); } var indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); foreach (BusinessLogic.Orders.IndividualOrder indOrder in indOrders) { IndividualOrderManager.DeleteIndividualOrder(indOrder.IndividualOrderID); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int sentMessage = CommonHelper.QueryStringInt("sentMessage"); int indOrderID = CommonHelper.QueryStringInt("orderID", -1); if (sentMessage == 0 && indOrderID == -1) { this.indivOrderControl.Visible = true; this.sentMessageLabel.Visible = false; this.orderSenrTopic.Visible = false; } else { this.indivOrderControl.Visible = false; this.sentMessageLabel.Visible = true; this.orderSenrTopic.Visible = true; String order = String.Empty; String startText = String.Empty; if (indOrderID == -1) { order = (String)Session["quickOrderMessage"]; startText = "Ваш индивидуальный заказ цветов отправлен. Вы заказали "; } else { BusinessLogic.Orders.IndividualOrder indOrder = IndividualOrderManager.GetIndividualOrderByID(indOrderID); order = indOrder != null ? indOrder.OrderText: "удален."; startText = "Ваш индивидуальный заказ "; } this.sentMessageLabel.Text = String.Format("{0}{1}", startText, order); } } }
private decimal CalculatePriceWithFee(Order order, IndividualOrderCollection indOrders, out object shippingPrice) { var prodVars = order.OrderProductVariants.Select(opv => ProductManager.GetProductVariantByID(opv.ProductVariantID)).ToList(); decimal totalWithFee = CalculateTotalOrderServiceFee(order.OrderProductVariants, prodVars, order, out shippingPrice); ShippingPrice = (decimal)shippingPrice; totalWithFee += AddServiceFee(IndividualOrderManager.GetTotalPriceIndOrders(indOrders), ConvertToUsd); return(totalWithFee); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart); if (!shoppingCartRequiresShipping) { NopContext.Current.User.LastShippingOption = null; Response.Redirect("~/CheckoutPaymentMethod.aspx"); } if (!Page.IsPostBack) { if (shoppingCartRequiresShipping) { //ShipmentPackage shipmentPackage = ShippingManager.CreateShipmentPackage(Cart, NopContext.Current.User.ShippingAddress); string error = string.Empty; ShippingOptionCollection shippingOptions = ShippingManager.GetShippingOptions(Cart, NopContext.Current.User, NopContext.Current.User.ShippingAddress, ref error); if (!String.IsNullOrEmpty(error)) { LogManager.InsertLog(LogTypeEnum.ShippingErrror, error, error); lError.Text = Server.HtmlEncode(error); } else { if (shippingOptions.Count > 0) { dlShippingOptions.DataSource = shippingOptions; dlShippingOptions.DataBind(); } else { phSelectShippingMethod.Visible = false; phShippingIsNotAllowed.Visible = true; } } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CommonHelper.EnsureSSL(); } Response.CacheControl = "private"; Response.Expires = 0; Response.AddHeader("pragma", "no-cache"); ShoppingCart cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } if (NopContext.Current.User == null && CustomerManager.AnonymousCheckoutAllowed) { //create anonymous record string email = "*****@*****.**"; string password = string.Empty; MembershipCreateStatus status = MembershipCreateStatus.UserRejected; Customer guestCustomer = CustomerManager.AddCustomer(email, email, password, false, true, true, out status); if (guestCustomer != null && status == MembershipCreateStatus.Success) { NopContext.Current.User = guestCustomer; if (NopContext.Current.Session == null) { NopContext.Current.Session = NopContext.Current.GetSession(true); } NopContext.Current.Session = CustomerManager.SaveCustomerSession(NopContext.Current.Session.CustomerSessionGUID, guestCustomer.CustomerID, DateTime.Now, NopContext.Current.Session.IsExpired); } } if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } string title = GetLocaleResourceString("PageTitle.Checkout"); SEOHelper.RenderTitle(this, title, true); Response.Redirect("~/CheckoutBillingAddress.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } btnNextStep.Attributes.Add("onclick", "this.disabled = true;" + Page.ClientScript.GetPostBackEventReference(this.btnNextStep, "")); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } if (!Page.IsPostBack) { CustomerManager.ResetCheckoutData(NopContext.Current.User.CustomerID, false); } bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart); if (!shoppingCartRequiresShipping) { SelectAddress(null); Response.Redirect("~/CheckoutBillingAddress.aspx"); } if (!Page.IsPostBack) { AddressCollection addresses = getAllowedShippingAddresses(NopContext.Current.User); if (addresses.Count > 0) { dlAddress.DataSource = addresses; dlAddress.DataBind(); lEnterShippingAddress.Text = GetLocaleResourceString("Checkout.OrEnterNewAddress"); } else { pnlSelectShippingAddress.Visible = false; lEnterShippingAddress.Text = GetLocaleResourceString("Checkout.EnterShippingAddress"); } } }
protected void fastOrderShCart_Click(object sender, EventArgs e) { String message = GetMessage(false); if (NopContext.Current.Session == null) { return; } Guid CustomerSessionGUID = NopContext.Current.Session.CustomerSessionGUID; long price = 0; Int64.TryParse(this.Price.Text, out price); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { price = PriceConverter.ToBYR(price); } IndividualOrderManager.InsertIndividualOrder(CustomerSessionGUID, price, message); Response.Redirect("~/ShoppingCart.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } if (!Page.IsPostBack) { Address shippingAddress = NopContext.Current.User.ShippingAddress; pnlTheSameAsShippingAddress.Visible = CustomerManager.CanUseAddressAsBillingAddress(shippingAddress); AddressCollection addresses = getAllowedBillingAddresses(NopContext.Current.User); if (addresses.Count > 0) { //bind data //if (addresses.Count > 1) // addresses.RemoveRange(1, addresses.Count - 1); dlAddress.DataSource = addresses; dlAddress.DataBind(); lEnterBillingAddress.Text = GetLocaleResourceString("Checkout.OrEnterNewAddress"); } else { pnlSelectBillingAddress.Visible = false; lEnterBillingAddress.Text = GetLocaleResourceString("Checkout.EnterBillingAddress"); } } }
protected string GetShoppingCartSum() { ShoppingCart cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); bool isUsd = Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD"; decimal indOrderTotal = 0; IndividualOrderCollection indOrders = new IndividualOrderCollection(); if (NopContext.Current.Session != null) { Guid customerSessionGuid = NopContext.Current.Session.CustomerSessionGUID; indOrders = IndividualOrderManager.GetIndividualOrderByCurrentUserSessionGuid(customerSessionGuid); indOrderTotal = IndividualOrderManager.GetTotalPriceIndOrders(indOrders); if (isUsd) { indOrderTotal = Math.Round(PriceConverter.ToUsd(indOrderTotal)); } } if (cart.Count > 0 || indOrders.Count > 0) { //subtotal string subTotalError = string.Empty; decimal shoppingCartSubTotalDiscountBase; decimal shoppingCartSubTotalBase = ShoppingCartManager.GetShoppingCartSubTotal(cart, NopContext.Current.User, out shoppingCartSubTotalDiscountBase, ref subTotalError); if (String.IsNullOrEmpty(subTotalError)) { decimal shoppingCartSubTotal = CurrencyManager.ConvertCurrency(shoppingCartSubTotalBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); shoppingCartSubTotal += indOrderTotal; return(AddCurrency(PriceHelper.FormatPrice(shoppingCartSubTotal), isUsd)); } } return(AddCurrency("0", isUsd)); }
public void BindData() { ShoppingCart Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { pnlEmptyCart.Visible = true; pnlCart.Visible = false; } else { pnlEmptyCart.Visible = false; pnlCart.Visible = true; phCoupon.Visible = DiscountManager.HasDiscountsWithCouponCode(); rptShoppingCart.DataSource = Cart; rptShoppingCart.DataBind(); ValidateCart(); } this.ctrlOrderTotals.BindData(); }
public void BindData() { ShoppingCart Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); decimal indOrderTotal = 0; IndividualOrderCollection indOrders = new IndividualOrderCollection(); if (NopContext.Current.Session != null) { Guid CustomerSessionGUID = NopContext.Current.Session.CustomerSessionGUID; indOrders = IndividualOrderManager.GetIndividualOrderByCurrentUserSessionGuid(CustomerSessionGUID); indOrderTotal = IndividualOrderManager.GetTotalPriceIndOrders(indOrders); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { indOrderTotal = Math.Round(PriceConverter.ToUsd(indOrderTotal)); } } if (Cart.Count > 0 || indOrders.Count > 0) { //payment method (if already selected) int paymentMethodID = 0; if (NopContext.Current.User != null) { paymentMethodID = NopContext.Current.User.LastPaymentMethodID; } //subtotal string SubTotalError = string.Empty; decimal shoppingCartSubTotalDiscountBase; decimal shoppingCartSubTotalBase = ShoppingCartManager.GetShoppingCartSubTotal(Cart, NopContext.Current.User, out shoppingCartSubTotalDiscountBase, ref SubTotalError); if (String.IsNullOrEmpty(SubTotalError)) { decimal shoppingCartSubTotal = CurrencyManager.ConvertCurrency(shoppingCartSubTotalBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); shoppingCartSubTotal += indOrderTotal; lblSubTotalAmount.Text = PriceHelper.FormatPrice(shoppingCartSubTotal); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { lblSubTotalAmount.Text += "$"; } lblSubTotalAmount.CssClass = "productPrice"; if (shoppingCartSubTotalDiscountBase > decimal.Zero) { decimal shoppingCartSubTotalDiscount = CurrencyManager.ConvertCurrency(shoppingCartSubTotalDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblSubTotalDiscountAmount.Text = PriceHelper.FormatPrice(shoppingCartSubTotalDiscount, true, false); phSubTotalDiscount.Visible = true; } else { phSubTotalDiscount.Visible = false; } } else { lblSubTotalAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblSubTotalAmount.CssClass = string.Empty; } //shipping info bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart) && Session["SelfOrder"] == null; if (shoppingCartRequiresShipping) { decimal?shoppingCartShippingBase = ShippingManager.GetShoppingCartShippingTotal(Cart, NopContext.Current.User); if (shoppingCartShippingBase.HasValue) { decimal shoppingCartShipping = CurrencyManager.ConvertCurrency(shoppingCartShippingBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblShippingAmount.Text = PriceHelper.FormatShippingPrice(shoppingCartShipping, true); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { lblShippingAmount.Text += "$"; } lblShippingAmount.CssClass = "productPrice"; } else { lblShippingAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblShippingAmount.CssClass = string.Empty; } } else { lblShippingAmount.Text = GetLocaleResourceString("ShoppingCart.ShippingNotRequired"); lblShippingAmount.CssClass = string.Empty; } //payment method fee bool displayPaymentMethodFee = true; decimal paymentMethodAdditionalFee = PaymentManager.GetAdditionalHandlingFee(paymentMethodID); decimal paymentMethodAdditionalFeeWithTaxBase = TaxManager.GetPaymentMethodAdditionalFee(paymentMethodAdditionalFee, NopContext.Current.User); if (paymentMethodAdditionalFeeWithTaxBase > decimal.Zero) { decimal paymentMethodAdditionalFeeWithTax = CurrencyManager.ConvertCurrency(paymentMethodAdditionalFeeWithTaxBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblPaymentMethodAdditionalFee.Text = PriceHelper.FormatPaymentMethodAdditionalFee(paymentMethodAdditionalFeeWithTax, true); } else { displayPaymentMethodFee = false; } phPaymentMethodAdditionalFee.Visible = displayPaymentMethodFee; //tax bool displayTax = true; if (TaxManager.HideTaxInOrderSummary && NopContext.Current.TaxDisplayType == TaxDisplayTypeEnum.IncludingTax) { displayTax = false; } else { string TaxError = string.Empty; decimal shoppingCartTaxBase = TaxManager.GetTaxTotal(Cart, paymentMethodID, NopContext.Current.User, ref TaxError); decimal shoppingCartTax = CurrencyManager.ConvertCurrency(shoppingCartTaxBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); //if (String.IsNullOrEmpty(TaxError)) //{ // if (shoppingCartTaxBase == 0 && TaxManager.HideZeroTax) // { // displayTax = false; // } // else // { // lblTaxAmount.Text = PriceHelper.FormatPrice(shoppingCartTax, true, false); // lblTaxAmount.CssClass = "productPrice"; // } //} //else //{ // lblTaxAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); // lblTaxAmount.CssClass = string.Empty; //} } phTaxTotal.Visible = false;// displayTax; //total decimal?shoppingCartTotalBase = ShoppingCartManager.GetShoppingCartTotal(Cart, paymentMethodID, NopContext.Current.User); if (shoppingCartTotalBase.HasValue) { decimal shoppingCartTotal = CurrencyManager.ConvertCurrency(shoppingCartTotalBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (Session["SelfOrder"] != null) { shoppingCartTotal -= ShippingManager.GetShoppingCartShippingTotal(Cart).Value; } shoppingCartTotal += indOrderTotal; lblTotalAmount.Text = PriceHelper.FormatPrice(shoppingCartTotal); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { lblTotalAmount.Text += "$"; } lblTotalAmount.CssClass = "productPrice"; } else { lblTotalAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblTotalAmount.CssClass = string.Empty; } } else { this.Visible = false; } }
public string PostProcessPayment(Order order, IndividualOrderCollection indOrders) { bool convertToUsd = HttpContext.Current.Request.Cookies["Currency"] != null && HttpContext.Current.Request.Cookies["Currency"].Value == "USD"; shippingRate = SettingManager.GetSettingValueDecimalNative("ShippingRateComputationMethod.FixedRate.Rate"); freeShippingBorder = SettingManager.GetSettingValueDecimalNative("Shipping.FreeShippingOverX.Value"); if (convertToUsd) { freeShippingBorder = Math.Round(PriceConverter.ToUsd(freeShippingBorder)); } var prodVars = new List <ProductVariant>(); foreach (var opv in order.OrderProductVariants) { prodVars.Add(ProductManager.GetProductVariantByID(opv.ProductVariantID)); } decimal totalWithFee = (int)CalculateTotalServiceFee(order.OrderProductVariants, prodVars, order, convertToUsd, out shippingPrice); totalWithFee += AddServiceFee(IndividualOrderManager.GetTotalPriceIndOrders(indOrders), convertToUsd); var remotePostHelper = new RemotePost { FormName = "WebPeyForm", Url = GetWebPayUrl() }; OrderManager.UpdateOrder(order.OrderID, order.OrderGUID, order.CustomerID, order.CustomerLanguageID, order.CustomerTaxDisplayType, order.OrderSubtotalInclTax, order.OrderSubtotalExclTax, order.OrderShippingInclTax, order.OrderShippingExclTax, order.PaymentMethodAdditionalFeeInclTax, order.PaymentMethodAdditionalFeeExclTax, order.OrderTax, order.OrderTotal, order.OrderDiscount, order.OrderSubtotalInclTaxInCustomerCurrency, order.OrderShippingExclTaxInCustomerCurrency, order.OrderShippingInclTaxInCustomerCurrency, order.OrderShippingExclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency, order.OrderTaxInCustomerCurrency, order.OrderTotalInCustomerCurrency, order.CustomerCurrencyCode, order.OrderWeight, order.AffiliateID, order.OrderStatus, order.AllowStoringCreditCardNumber, order.CardType, order.CardName, order.CardNumber, order.MaskedCreditCardNumber, order.CardCVV2, order.CardExpirationMonth, order.CardExpirationYear, order.PaymentMethodID, order.PaymentMethodName, order.AuthorizationTransactionID, order.AuthorizationTransactionCode, order.AuthorizationTransactionResult, order.CaptureTransactionID, order.CaptureTransactionResult, order.PurchaseOrderNumber, order.PaymentStatus, order.BillingFirstName, order.BillingLastName, order.BillingPhoneNumber, order.BillingEmail, order.BillingFaxNumber, order.BillingCompany, order.BillingAddress1, order.BillingAddress2, order.BillingCity, order.BillingStateProvince, order.BillingStateProvinceID, order.BillingZipPostalCode, order.BillingCountry, order.BillingCountryID, order.ShippingStatus, order.ShippingFirstName, order.ShippingLastName, order.ShippingPhoneNumber, order.ShippingEmail, order.ShippingFaxNumber, order.ShippingCompany, order.ShippingAddress1, order.ShippingAddress2, order.ShippingCity, order.ShippingStateProvince, order.ShippingStateProvinceID, order.ShippingZipPostalCode, order.ShippingCountry, order.ShippingCountryID, order.ShippingMethod, order.ShippingRateComputationMethodID, order.ShippedDate, order.Deleted, order.CreatedOn); remotePostHelper.Add("*scart", ""); remotePostHelper.Add("wsb_storeid", StoreId); remotePostHelper.Add("wsb_store", "voobrazi.by"); remotePostHelper.Add("wsb_order_num", order.OrderID.ToString()); remotePostHelper.Add("wsb_currency_id", convertToUsd ? "USD" : CurrencyId); remotePostHelper.Add("wsb_version", "2"); remotePostHelper.Add("wsb_language_id", "russian"); string seed = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds).ToString(); remotePostHelper.Add("wsb_seed", seed); var signatureBulder = new StringBuilder(seed); signatureBulder.Append(StoreId); signatureBulder.Append(order.OrderID); signatureBulder.Append(UseSandBox ? "1" : "0"); signatureBulder.Append(convertToUsd ? "USD" : CurrencyId); signatureBulder.Append(totalWithFee.ToString()); signatureBulder.Append(Sk); byte[] buffer = Encoding.Default.GetBytes(signatureBulder.ToString()); var sha1 = new SHA1CryptoServiceProvider(); string signature = BitConverter.ToString(sha1.ComputeHash(buffer)).Replace("-", "").ToLower(); remotePostHelper.Add("wsb_signature", signature); remotePostHelper.Add("wsb_return_url", string.Format(SettingManager.GetSettingValue("PaymentMethod.WebPay.ReturnUrl"), order.OrderID)); remotePostHelper.Add("wsb_cancel_return_url", string.Format(SettingManager.GetSettingValue("PaymentMethod.WebPay.CancelUrl"), order.OrderID)); remotePostHelper.Add("wsb_notify_url", string.Format(SettingManager.GetSettingValue("PaymentMethod.WebPay.NotifyUrl"), order.OrderID)); remotePostHelper.Add("wsb_test", UseSandBox ? "1" : "0"); for (int i = 0; i < order.OrderProductVariants.Count; i++) { var opv = order.OrderProductVariants[i]; remotePostHelper.Add(string.Format("wsb_invoice_item_name[{0}]", i), opv.ProductVariant.Product.Name); remotePostHelper.Add(string.Format("wsb_invoice_item_quantity[{0}]", i), opv.Quantity.ToString()); var prodVar = ProductManager.GetProductVariantByID(opv.ProductVariantID); decimal prodPrice = !convertToUsd ? prodVar.Price : Math.Round(PriceConverter.ToUsd(prodVar.Price)); remotePostHelper.Add(string.Format("wsb_invoice_item_price[{0}]", i), AddServiceFee(prodPrice, convertToUsd).ToString()); } int cartCount = order.OrderProductVariants.Count; for (int i = order.OrderProductVariants.Count; i < indOrders.Count + cartCount; i++) { var opv = indOrders[i - cartCount]; remotePostHelper.Add(string.Format("wsb_invoice_item_name[{0}]", i), "Индивидуальный заказ"); remotePostHelper.Add(string.Format("wsb_invoice_item_quantity[{0}]", i), "1"); decimal prodPrice = !convertToUsd ? opv.Price : Math.Round(PriceConverter.ToUsd(opv.Price)); remotePostHelper.Add(string.Format("wsb_invoice_item_price[{0}]", i), AddServiceFee(prodPrice, convertToUsd).ToString()); } remotePostHelper.Add("wsb_tax", "0"); remotePostHelper.Add("wsb_shipping_name", "Доставка курьером"); remotePostHelper.Add("wsb_shipping_price", AddServiceFee(shippingPrice, convertToUsd).ToString()); remotePostHelper.Add("wsb_total", totalWithFee.ToString()); if (!string.IsNullOrEmpty(order.ShippingEmail)) { remotePostHelper.Add("wsb_email", order.ShippingEmail); } remotePostHelper.Add("wsb_phone", order.ShippingPhoneNumber); remotePostHelper.Post(); return(string.Empty); }
protected void btnNextStep_Click(object sender, EventArgs e) { if (Page.IsValid) { try { PaymentInfo paymentInfo = this.PaymentInfo; //if (paymentInfo == null) // Response.Redirect("~/CheckoutPaymentInfo.aspx"); paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress; paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress; paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage; paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency; int orderId = 0; string result = ""; if (Request["OrderId"] == null) { result = OrderManager.PlaceOrder(paymentInfo, NopContext.Current.User, out orderId); } else { orderId = int.Parse(Request["OrderId"]); } this.PaymentInfo = null; Order order = OrderManager.GetOrderByID(orderId); if (!String.IsNullOrEmpty(result)) { lError.Text = Server.HtmlEncode(result); return; } if (Request["OrderId"] != null) { order.PaymentMethodID = paymentInfo.PaymentMethodID; order.PaymentMethodName = PaymentMethodManager.GetPaymentMethodByID(paymentInfo.PaymentMethodID).Name; } Guid customerSessionGUID = NopContext.Current.Session.CustomerSessionGUID; IndividualOrderCollection indOrders = IndividualOrderManager.GetIndividualOrderByCurrentUserSessionGuid(customerSessionGUID); string subj = "Заказ в магазине Voobrazi.by"; StringBuilder body = new StringBuilder(); body.AppendFormat("Доставка: {0}<br /><br />", ((bool)Session["Delivery"]) ? "Курьером" : "Самовывоз").AppendLine(); body.AppendFormat("<b>Заказчик</b><br />").AppendLine(); body.AppendFormat("ФИО: {0} {1}<br />", paymentInfo.BillingAddress.FirstName, paymentInfo.BillingAddress.LastName).AppendLine(); body.AppendFormat("Телефоны: {0} {1}<br />", paymentInfo.BillingAddress.PhoneNumber, !string.IsNullOrEmpty(paymentInfo.BillingAddress.FaxNumber) ? ", " + paymentInfo.BillingAddress.FaxNumber : "").AppendLine(); body.AppendFormat("Адрес: {0} {1}<br />", paymentInfo.BillingAddress.City, paymentInfo.BillingAddress.Address1).AppendLine(); body.AppendFormat("Email: {0}<br /><br />", !string.IsNullOrEmpty(NopContext.Current.User.BillingAddress.Email) ? NopContext.Current.User.BillingAddress.Email : NopContext.Current.User.Email).AppendLine(); body.AppendFormat("Комментарии: {0}<br /><br />", tbComments.Text).AppendLine(); PaymentMethod pm = PaymentMethodManager.GetPaymentMethodByID(order.PaymentMethodID); if (pm != null) { body.AppendFormat("Способ оплаты: {0}<br /><br />", pm.Name).AppendLine(); } decimal total = 0; decimal indOrderTotal = IndividualOrderManager.GetTotalPriceIndOrders(indOrders); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { indOrderTotal = Math.Round(PriceConverter.ToUsd(indOrderTotal)); } total += indOrderTotal; body.AppendFormat("Индивидуальные заказы:<br />"); foreach (var indOrder in indOrders) { body.Append(indOrder.OrderText + "<br />"); } if (Session["fn"] != null) { body.AppendLine(); body.Append("<b>Получатель не заказчик</b><br />").AppendLine(); body.AppendFormat("ФИО: {0} {1}<br />", Session["fn"], Session["ln"]).AppendLine(); body.AppendFormat("Телефон: {0}<br />", Session["pn"]).AppendLine(); body.AppendFormat("Адрес: {0}<br />", Session["address"]).AppendLine(); body.AppendFormat("Дополнительная информация: {0}<br />", Session["ai"]).AppendLine(); } body.AppendFormat("Уведомление о доставке: {0} | {1}<br />", chbByMail.Checked ? "Письмом на Email" : "", chbSMS.Checked ? "СМС сообщение" : "").AppendLine(); body.AppendFormat("<br /><br /> Заказано:<br />"); foreach (OrderProductVariant variant in order.OrderProductVariants) { body.AppendFormat(" - {0} ({1}) x {2}шт. -- {3}; <br />", variant.ProductVariant.Product.Name, PriceHelper.FormatShippingPrice(variant.ProductVariant.Price, true), variant.Quantity, PriceHelper.FormatShippingPrice(variant.ProductVariant.Price * variant.Quantity, true)); total += variant.ProductVariant.Price * variant.Quantity; } string shipping = GetLocaleResourceString("ShoppingCart.ShippingNotRequired"); bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart) && Session["SelfOrder"] == null; if (shoppingCartRequiresShipping) { decimal?shoppingCartShippingBase = ShippingManager.GetShoppingCartShippingTotal(Cart, NopContext.Current.User); if (shoppingCartShippingBase.HasValue) { decimal shoppingCartShipping = CurrencyManager.ConvertCurrency(shoppingCartShippingBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); shipping = PriceHelper.FormatShippingPrice(shoppingCartShipping, true); total += shoppingCartShipping; } } body.AppendFormat("Доставка: {0}<br />", shipping).AppendLine(); body.AppendFormat("<b>Итого:</b> {0}<br />", total).AppendLine(); body.AppendFormat("<br />Дополнительная информация: {0}<br />", Session["ai"]).AppendLine(); MessageManager.SendEmail(subj, body.ToString(), MessageManager.AdminEmailAddress, MessageManager.AdminEmailAddress); StartPaymentMethod(indOrders, order); Session.Remove("SelfOrder"); Response.Redirect("~/CheckoutCompleted.aspx"); } catch (Exception exc) { Session.Remove("SelfOrder"); LogManager.InsertLog(LogTypeEnum.OrderError, exc.Message, exc); lError.Text = Server.HtmlEncode("Во время обработки заказа произошла ошибка. Для выполнения заказа, пожалуйста, свяжитесь с администратором. Контактную информацию можно найти на странице Контакты."); } } }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } if (!Page.IsPostBack) { PaymentMethodCollection paymentMethods = PaymentMethodManager.GetAllPaymentMethods(); PaymentMethod paypalExpressPaymentMethod = null; foreach (PaymentMethod pm in paymentMethods) { if (pm.SystemKeyword == "PayPalExpress") { paypalExpressPaymentMethod = pm; } } PaymentMethod googleCheckoutPaymentMethod = null; foreach (PaymentMethod pm in paymentMethods) { if (pm.SystemKeyword == "GoogleCheckout") { googleCheckoutPaymentMethod = pm; } } bool hasButtonMethods = false; if (paypalExpressPaymentMethod != null && paypalExpressPaymentMethod.IsActive) { hasButtonMethods = true; } PaymentMethodCollection boundPaymentMethods = new PaymentMethodCollection(); foreach (PaymentMethod pm in paymentMethods) { if (pm != paypalExpressPaymentMethod && pm != googleCheckoutPaymentMethod) { boundPaymentMethods.Add(pm); } } if (boundPaymentMethods.Count == 0) { if (hasButtonMethods) { phSelectPaymentMethod.Visible = false; phNoPaymentMethods.Visible = false; } else { phSelectPaymentMethod.Visible = false; phNoPaymentMethods.Visible = true; } } else if (boundPaymentMethods.Count == 1) { if (hasButtonMethods) { phSelectPaymentMethod.Visible = true; phNoPaymentMethods.Visible = false; dlPaymentMethod.DataSource = boundPaymentMethods; dlPaymentMethod.DataBind(); } else { phSelectPaymentMethod.Visible = false; phNoPaymentMethods.Visible = false; NopContext.Current.User = CustomerManager.SetLastPaymentMethodID(NopContext.Current.User.CustomerID, paymentMethods[0].PaymentMethodID); Response.Redirect("~/CheckoutConfirm.aspx"); } } else { phSelectPaymentMethod.Visible = true; phNoPaymentMethods.Visible = false; dlPaymentMethod.DataSource = boundPaymentMethods; dlPaymentMethod.DataBind(); } } divAdditionalPaymentInfo.Visible = Request["OrderId"] != null; }