protected void SaveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { try { PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(this.PaymentMethodID); if (paymentMethod != null) { paymentMethod = PaymentMethodManager.UpdatePaymentMethod(paymentMethod.PaymentMethodID, txtName.Text, txtVisibleName.Text, txtDescription.Text, txtConfigureTemplatePath.Text, txtUserTemplatePath.Text, txtClassName.Text, txtSystemKeyword.Text, cbActive.Checked, txtDisplayOrder.Value); IConfigurePaymentMethodModule configureModule = GetConfigureModule(); if (configureModule != null) { configureModule.Save(); } Response.Redirect("PaymentMethodDetails.aspx?PaymentMethodID=" + paymentMethod.PaymentMethodID.ToString()); } else { Response.Redirect("PaymentMethods.aspx"); } } catch (Exception exc) { ProcessException(exc); } } }
protected void btnNextStep_Click(object sender, EventArgs e) { if (Page.IsValid) { int paymentMethodID = this.SelectedPaymentMethodID; PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(paymentMethodID); PaymentInfo pi = new PaymentInfo(); pi.PaymentMethodID = paymentMethodID; PaymentInfo = pi; if (paymentMethod != null && paymentMethod.IsActive) { NopContext.Current.User = CustomerManager.SetLastPaymentMethodID(NopContext.Current.User.CustomerID, paymentMethodID); Response.Redirect(string.Format("~/CheckoutConfirm.aspx{0}", Request["OrderId"] != null ? "?OrderId=" + Request["OrderId"] : "")); } } }
private void CreateChildControlsTree() { PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(this.PaymentMethodID); if (paymentMethod != null) { Control child = null; try { child = base.LoadControl(paymentMethod.ConfigureTemplatePath); this.ConfigureMethodHolder.Controls.Add(child); } catch (Exception exc) { } } }
private static void StartPaymentMethod(IndividualOrderCollection indOrders, Order order) { PaymentMethod pm = PaymentMethodManager.GetPaymentMethodByID(order.PaymentMethodID); if (pm.ClassName.Equals("Nop.Payment.WebPay.WebPayPaymentProcessor, Nop.Payment.WebPay")) { var webPayMethod = new Nop.Payment.WebPay.WebPayPaymentProcessor(); webPayMethod.PostProcessPayment(order, indOrders); } else if (pm.ClassName.Equals("Nop.Payment.Assist.AssistPaymentProcessor, Nop.Payment.Assist")) { var assistPaymentProcessor = new Nop.Payment.Assist.AssistPaymentProcessor(); assistPaymentProcessor.PostProcessPayment(order, indOrders, NopContext.Current.User); } else { PaymentManager.PostProcessPayment(order); } }
private void BindData() { PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(this.PaymentMethodID); if (paymentMethod != null) { this.txtName.Text = paymentMethod.Name; this.txtVisibleName.Text = paymentMethod.VisibleName; this.txtDescription.Text = paymentMethod.Description; this.txtConfigureTemplatePath.Text = paymentMethod.ConfigureTemplatePath; this.txtUserTemplatePath.Text = paymentMethod.UserTemplatePath; this.txtClassName.Text = paymentMethod.ClassName; this.txtSystemKeyword.Text = paymentMethod.SystemKeyword; this.cbActive.Checked = paymentMethod.IsActive; this.txtDisplayOrder.Value = paymentMethod.DisplayOrder; } else { Response.Redirect("PaymentMethods.aspx"); } }
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("Во время обработки заказа произошла ошибка. Для выполнения заказа, пожалуйста, свяжитесь с администратором. Контактную информацию можно найти на странице Контакты."); } } }
private void BindData() { this.lnkPrint.NavigateUrl = Page.ResolveUrl("~/PrintOrderDetails.aspx?OrderID=" + this.OrderID); this.lblOrderID.Text = order.OrderID.ToString(); this.lblCreatedOn.Text = DateTimeHelper.ConvertToUserTime(order.CreatedOn).ToString("D"); this.lblOrderStatus.Text = OrderManager.GetOrderStatusName(order.OrderStatusID); if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { this.pnlShipping.Visible = true; this.lShippingFirstName.Text = Server.HtmlEncode(order.ShippingFirstName); this.lShippingLastName.Text = Server.HtmlEncode(order.ShippingLastName); this.lShippingPhoneNumber.Text = Server.HtmlEncode(order.ShippingPhoneNumber); this.lShippingEmail.Text = Server.HtmlEncode(!string.IsNullOrEmpty(NopContext.Current.User.BillingAddress.Email) ? NopContext.Current.User.BillingAddress.Email : NopContext.Current.User.Email); this.lShippingFaxNumber.Text = Server.HtmlEncode(order.ShippingFaxNumber); if (!String.IsNullOrEmpty(order.ShippingCompany)) { this.lShippingCompany.Text = Server.HtmlEncode(order.ShippingCompany); } else { pnlShippingCompany.Visible = false; } this.lShippingAddress1.Text = Server.HtmlEncode(order.ShippingAddress1); if (!String.IsNullOrEmpty(order.ShippingAddress2)) { this.lShippingAddress2.Text = Server.HtmlEncode(order.ShippingAddress2); } else { pnlShippingAddress2.Visible = false; } this.lShippingCity.Text = Server.HtmlEncode(order.ShippingCity); this.lShippingStateProvince.Text = Server.HtmlEncode(order.ShippingStateProvince); this.lShippingZipPostalCode.Text = Server.HtmlEncode(order.ShippingZipPostalCode); if (!String.IsNullOrEmpty(order.ShippingCountry)) { this.lShippingCountry.Text = Server.HtmlEncode(order.ShippingCountry); } else { pnlShippingCountry.Visible = false; } this.lblShippingMethod.Text = Server.HtmlEncode(order.ShippingMethod); this.lblOrderWeight.Text = string.Format("{0} [{1}]", order.OrderWeight, MeasureManager.BaseWeightIn.Name); //TODO use order.ShippingStatus if (order.ShippedDate.HasValue) { this.lblShippedDate.Text = DateTimeHelper.ConvertToUserTime(order.ShippedDate.Value).ToString(); } else { this.lblShippedDate.Text = GetLocaleResourceString("Order.NotYetShipped"); } } else { this.pnlShipping.Visible = false; } this.lBillingFirstName.Text = Server.HtmlEncode(order.BillingFirstName); this.lBillingLastName.Text = Server.HtmlEncode(order.BillingLastName); this.lBillingPhoneNumber.Text = Server.HtmlEncode(order.BillingPhoneNumber); this.lBillingEmail.Text = Server.HtmlEncode(!string.IsNullOrEmpty(NopContext.Current.User.BillingAddress.Email) ? NopContext.Current.User.BillingAddress.Email : NopContext.Current.User.Email); this.lBillingFaxNumber.Text = Server.HtmlEncode(order.BillingFaxNumber); if (!String.IsNullOrEmpty(order.BillingCompany)) { this.lBillingCompany.Text = Server.HtmlEncode(order.BillingCompany); } else { pnlBillingCompany.Visible = false; } this.lBillingAddress1.Text = Server.HtmlEncode(order.BillingAddress1); if (!String.IsNullOrEmpty(order.BillingAddress2)) { this.lBillingAddress2.Text = Server.HtmlEncode(order.BillingAddress2); } else { pnlBillingAddress2.Visible = false; } this.lBillingCity.Text = Server.HtmlEncode(order.BillingCity); this.lBillingStateProvince.Text = Server.HtmlEncode(order.BillingStateProvince); this.lBillingZipPostalCode.Text = Server.HtmlEncode(order.BillingZipPostalCode); if (!String.IsNullOrEmpty(order.BillingCountry)) { this.lBillingCountry.Text = Server.HtmlEncode(order.BillingCountry); } else { pnlBillingCountry.Visible = false; } PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(order.PaymentMethodID); if (paymentMethod != null) { this.lPaymentMethod.Text = paymentMethod.VisibleName; } else { this.lPaymentMethod.Text = order.PaymentMethodName; } switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { this.lblOrderSubtotal.Text = PriceHelper.FormatPrice(order.OrderSubtotalExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); this.lblOrderShipping.Text = PriceHelper.FormatShippingPrice(order.OrderShippingExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); this.lblPaymentMethodAdditionalFee.Text = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); } break; case TaxDisplayTypeEnum.IncludingTax: { this.lblOrderSubtotal.Text = PriceHelper.FormatPrice(order.OrderSubtotalInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); this.lblOrderShipping.Text = PriceHelper.FormatShippingPrice(order.OrderShippingInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); this.lblPaymentMethodAdditionalFee.Text = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); } break; } bool displayPaymentMethodFee = true; if (order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency == decimal.Zero) { displayPaymentMethodFee = false; } phPaymentMethodAdditionalFee.Visible = displayPaymentMethodFee; bool displayTax = true; if (TaxManager.HideTaxInOrderSummary && order.CustomerTaxDisplayType == TaxDisplayTypeEnum.IncludingTax) { displayTax = false; } else { if (order.OrderTax == 0 && TaxManager.HideZeroTax) { displayTax = false; } else { string taxStr = PriceHelper.FormatPrice(order.OrderTaxInCustomerCurrency, true, order.CustomerCurrencyCode, false); this.lblOrderTax.Text = taxStr; } } phTaxTotal.Visible = displayTax; string orderTotalStr = PriceHelper.FormatPrice(order.OrderTotalInCustomerCurrency, true, order.CustomerCurrencyCode, false); this.lblOrderTotal.Text = orderTotalStr; this.lblOrderTotal2.Text = orderTotalStr; OrderProductVariantCollection orderProductVariants = order.OrderProductVariants; bool hasDownloadableItems = false; foreach (OrderProductVariant orderProductVariant in orderProductVariants) { ProductVariant productVariant = orderProductVariant.ProductVariant; if (productVariant != null) { if (productVariant.IsDownload && OrderManager.AreDownloadsAllowed(order)) { hasDownloadableItems = true; break; } } } gvOrderProductVariants.Columns[2].Visible = hasDownloadableItems; gvOrderProductVariants.DataSource = orderProductVariants; gvOrderProductVariants.DataBind(); }