/// <summary> /// Ensures that only applicable payment options are displayed in selector. /// </summary> /// <param name="ds">Dataset with payment options.</param> protected override DataSet OnAfterRetrieveData(DataSet ds) { if (DataHelper.IsEmpty(ds) || (ShoppingCart == null)) { return(ds); } foreach (DataRow paymentRow in ds.Tables[0].Select()) { PaymentOptionInfo paymentOptionInfo; if (UseNameForSelection) { var paymentName = DataHelper.GetStringValue(paymentRow, "PaymentOptionName"); paymentOptionInfo = PaymentOptionInfoProvider.GetPaymentOptionInfo(paymentName, ShoppingCart.SiteName); } else { var paymentID = DataHelper.GetIntValue(paymentRow, "PaymentOptionID"); paymentOptionInfo = PaymentOptionInfoProvider.GetPaymentOptionInfo(paymentID); } // Do not remove already selected item even if the option is not applicable anymore // The user would see a different value in UI as is actually stored in the database var canBeRemoved = !EnsureSelectedItem || (ShoppingCart.ShoppingCartPaymentOptionID != paymentOptionInfo.PaymentOptionID); if (canBeRemoved && !PaymentOptionInfoProvider.IsPaymentOptionApplicable(ShoppingCart, paymentOptionInfo)) { // Remove not applicable payment methods from the selector ds.Tables[0].Rows.Remove(paymentRow); } } return(ds); }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "edit") { URLHelper.Redirect("PaymentOption_Edit.aspx?paymentOptionId=" + Convert.ToString(actionArgument) + "&siteId=" + SelectSite.SiteID); } else if (actionName == "delete") { PaymentOptionInfo paymentInfoObj = PaymentOptionInfoProvider.GetPaymentOptionInfo(ValidationHelper.GetInteger(actionArgument, 0)); // Nothing to delete if (paymentInfoObj == null) { return; } // Check permissions CheckConfigurationModification(paymentInfoObj.PaymentOptionSiteID); if (PaymentOptionInfoProvider.CheckDependencies(paymentInfoObj.PaymentOptionID)) { // Show error message ShowError(GetString("Ecommerce.DeleteDisabled")); return; } // Delete PaymentOptionInfo object from database PaymentOptionInfoProvider.DeletePaymentOptionInfo(paymentInfoObj); } }
protected void InitPaymentShipping() { if (currentSite != null) { // Get shipping option name ShippingOptionInfo shippingObj = ShoppingCart.ShippingOption; if (shippingObj != null) { mAddressCount++; tdShippingAddress.Visible = true; plcShipping.Visible = true; plcShippingOption.Visible = true; lblShippingOptionValue.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(shippingObj.ShippingOptionDisplayName)); lblShippingValue.Text = CurrencyInfoProvider.GetFormattedPrice(ShoppingCart.TotalShipping, ShoppingCart.Currency); } else { tdShippingAddress.Visible = false; plcShippingOption.Visible = false; plcShipping.Visible = false; } } // Get payment method name PaymentOptionInfo paymentObj = PaymentOptionInfoProvider.GetPaymentOptionInfo(ShoppingCart.ShoppingCartPaymentOptionID); if (paymentObj != null) { lblPaymentMethodValue.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(paymentObj.PaymentOptionDisplayName)); } // Total price initialization lblTotalPriceValue.Text = CurrencyInfoProvider.GetFormattedPrice(ShoppingCart.GrandTotal, ShoppingCart.Currency); lblTotalTaxValue.Text = CurrencyInfoProvider.GetFormattedPrice(ShoppingCart.TotalTax, ShoppingCart.Currency); }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "edit") { var editElementName = IsMultiStoreConfiguration ? "edit.configuration.GlobalPaymentoption" : "edit.configuration.paymentoption"; URLHelper.Redirect(UIContextHelper.GetElementUrl("cms.ecommerce", editElementName, false, ValidationHelper.GetInteger(actionArgument, 0))); } else if (actionName == "delete") { var paymentInfoObj = PaymentOptionInfoProvider.GetPaymentOptionInfo(ValidationHelper.GetInteger(actionArgument, 0)); // Nothing to delete if (paymentInfoObj == null) { return; } // Check permissions CheckConfigurationModification(paymentInfoObj.PaymentOptionSiteID); if (paymentInfoObj.Generalized.CheckDependencies()) { // Show error message ShowError(ECommerceHelper.GetDependencyMessage(paymentInfoObj)); return; } // Delete PaymentOptionInfo object from database PaymentOptionInfoProvider.DeletePaymentOptionInfo(paymentInfoObj); } }
public PaymentMethod GetPaymentMethod(int id) { var paymentInfo = PaymentOptionInfoProvider.GetPaymentOptionInfo(id); var method = mapper.Map <PaymentMethod>(paymentInfo); method.Title = resources.ResolveMacroString(method.DisplayName); return(method); }
private bool CheckPaymentIsGateway(string paymentID) { bool result = false; int paymentid = int.Parse(paymentID); PaymentOptionInfo payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(paymentid); result = string.Equals(payment.PaymentOptionDescription, "PAYMENTGATEWAY"); return(result); }
/// <summary> /// Returns a payment method with the specified identifier. /// </summary> /// <param name="paymentMethodId">Payment method's identifier.</param> /// <returns><see cref="PaymentOptionInfo"/> object representing a payment method with the specified identifier. Returns <c>null</c> if not found.</returns> public PaymentOptionInfo GetById(int paymentMethodId) { var paymentInfo = PaymentOptionInfoProvider.GetPaymentOptionInfo(paymentMethodId); if (paymentInfo?.PaymentOptionSiteID == SiteID) { return(paymentInfo); } if (paymentInfo?.PaymentOptionSiteID == 0 && ECommerceSettings.AllowGlobalPaymentMethods(SiteID)) { return(paymentInfo); } return(null); }
protected void InitPaymentShipping() { // shipping option and payment method lblShippingOption.Text = GetString("Ecommerce.CartContent.ShippingOption"); lblPaymentMethod.Text = GetString("Ecommerce.CartContent.PaymentMethod"); lblShipping.Text = GetString("Ecommerce.CartContent.Shipping"); if (IsShippingNeeded && currentSite != null) { // get shipping option name ShippingOptionInfo shippingObj = ShoppingCart.ShippingOption; if (shippingObj != null) { mAddressCount++; //plcShippingAddress.Visible = true; tdShippingAddress.Visible = true; plcShipping.Visible = true; plcShippingOption.Visible = true; lblShippingOptionValue.Text = HTMLHelper.HTMLEncode(shippingObj.ShippingOptionDisplayName); lblShippingValue.Text = CurrencyInfoProvider.GetFormattedPrice(ShoppingCart.TotalShipping, ShoppingCart.Currency); } else { //plcShippingAddress.Visible = false; tdShippingAddress.Visible = false; plcShippingOption.Visible = false; lblShippingValue.Text = CurrencyInfoProvider.GetFormattedPrice(ShoppingCart.TotalShipping, ShoppingCart.Currency); //plcShipping.Visible = false; } } // get payment method name PaymentOptionInfo paymentObj = PaymentOptionInfoProvider.GetPaymentOptionInfo(ShoppingCart.ShoppingCartPaymentOptionID); if (paymentObj != null) { lblPaymentMethodValue.Text = HTMLHelper.HTMLEncode(paymentObj.PaymentOptionDisplayName); } // total price initialization lblTotalPrice.Text = GetString("ecommerce.cartcontent.totalprice"); lblTotalPriceValue.Text = CurrencyInfoProvider.GetFormattedPrice(ShoppingCart.RoundedTotalPrice, ShoppingCart.Currency); }
/// <summary> /// Sets the payment result to the <see cref="Order"/> object. /// </summary> /// <remarks> /// In case the <see cref="PaymentResultInfo.PaymentIsCompleted"/> property of <paramref name="paymentResult"/> is true, the order is marked as paid and the order status is set according to <see cref="PaymentOptionInfo.PaymentOptionSucceededOrderStatusID"/>. /// The <paramref name="paymentFailed"/> parameter indicates if the order is marked as unpaid and the order status is set according to <see cref="PaymentOptionInfo.PaymentOptionFailedOrderStatusID"/>. /// </remarks> /// <param name="paymentResult"><see cref="PaymentResultInfo"/> object representing an original Kentico payment result object from which the model is created.</param> /// <param name="paymentFailed">Indicates if the payment failed.</param> public void SetPaymentResult(PaymentResultInfo paymentResult, bool paymentFailed = false) { if (paymentResult == null) { throw new ArgumentNullException(nameof(paymentResult)); } if (paymentResult.PaymentIsCompleted && paymentFailed) { throw new InvalidOperationException("Order payment failed but paymentResult.PaymentIsCompleted is true"); } OriginalOrder.OrderPaymentResult = paymentResult; var payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(OriginalOrder.OrderPaymentOptionID); if (paymentResult.PaymentIsCompleted) { var successStatusId = payment?.PaymentOptionSucceededOrderStatusID ?? 0; if (successStatusId > 0) { OriginalOrder.OrderStatusID = successStatusId; } OriginalOrder.OrderIsPaid = true; } if (paymentFailed) { var failedStatusId = payment?.PaymentOptionFailedOrderStatusID ?? 0; if (failedStatusId > 0) { OriginalOrder.OrderStatusID = failedStatusId; } OriginalOrder.OrderIsPaid = false; } Save(); }
protected void OnBeforeSave(object sender, EventArgs e) { if ((Order == null) || (ShippingAddressSelector == null) || (ShippingOptionSelector == null)) { return; } // Get current values int addressID = ValidationHelper.GetInteger(ShippingAddressSelector.Value, 0); int shippingOptionID = ValidationHelper.GetInteger(ShippingOptionSelector.Value, 0); // Is shipping needed? bool isShippingNeeded = ((ShoppingCartFromOrder != null) && ShoppingCartFromOrder.IsShippingNeeded); // If shipping address is required if (isShippingNeeded || IsTaxBasedOnShippingAddress) { // If shipping address is not set if (addressID <= 0) { // Show error message ShowError(GetString("Order_Edit_Shipping.NoAddress")); return; } } try { // Shipping option changed if ((ShoppingCartFromOrder != null) && (Order.OrderShippingOptionID != shippingOptionID)) { // Shipping option and payment method combination is not allowed if (PaymentShippingInfoProvider.GetPaymentShippingInfo(Order.OrderPaymentOptionID, shippingOptionID) == null) { PaymentOptionInfo payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(Order.OrderPaymentOptionID); // Check if payment is allowed with no shipping if ((payment != null) && !(payment.PaymentOptionAllowIfNoShipping && shippingOptionID == 0)) { // Set payment method to none and display warning ShoppingCartFromOrder.ShoppingCartPaymentOptionID = 0; string paymentMethodName = ResHelper.LocalizeString(payment.PaymentOptionDisplayName, null, true); string shippingOptionName = HTMLHelper.HTMLEncode(ShippingOptionSelector.ValueDisplayName); ShowWarning(String.Format(ResHelper.GetString("com.shippingoption.paymentsetnone"), paymentMethodName, shippingOptionName)); } } // Set order new properties ShoppingCartFromOrder.ShoppingCartShippingOptionID = shippingOptionID; // Evaluate order data ShoppingCartInfoProvider.EvaluateShoppingCart(ShoppingCartFromOrder); // Update order data ShoppingCartInfoProvider.SetOrder(ShoppingCartFromOrder, true); } // Update tracking number Order.OrderTrackingNumber = ValidationHelper.GetString(orderShippingForm.FieldEditingControls["OrderTrackingNumber"].DataValue, String.Empty).Trim(); OrderInfoProvider.SetOrderInfo(Order); // Show message ShowChangesSaved(); // Stop automatic saving action orderShippingForm.StopProcessing = true; } catch (Exception ex) { // Show error message ShowError(ex.Message); } }
/// <summary> /// Returns where condition based on webpart fields. /// </summary> private string GetWhereCondition() { // Orders from current site string where = "OrderSiteID = " + CMSContext.CurrentSiteID; // Order status filter OrderStatusInfo status = OrderStatusInfoProvider.GetOrderStatusInfo(OrderStatus, SiteContext.CurrentSiteName); if (status != null) { where = SqlHelper.AddWhereCondition(where, "OrderStatusID = " + status.StatusID); } // Customer or company like filter if (!string.IsNullOrEmpty(CustomerOrCompany)) { string safeQueryStr = SecurityHelper.GetSafeQueryString(CustomerOrCompany); where = SqlHelper.AddWhereCondition(where, "OrderCustomerID IN (SELECT CustomerID FROM COM_Customer WHERE ((CustomerFirstName + ' ' + CustomerLastName + ' ' + CustomerFirstName) LIKE N'%" + safeQueryStr + "%') OR (CustomerCompany LIKE N'%" + safeQueryStr + "%'))"); } // Filter for orders with note if (HasNote) { where = SqlHelper.AddWhereCondition(where, "(OrderNote != '') AND (OrderNote IS NOT NULL)"); } // Payment method filter PaymentOptionInfo payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(PaymentMethod, SiteContext.CurrentSiteName); if (payment != null) { where = SqlHelper.AddWhereCondition(where, "OrderPaymentOptionID = " + payment.PaymentOptionID); } // Payment status filter switch (PaymentStatus.ToLowerCSafe()) { case PAY_STATUS_NOT_PAID: where = SqlHelper.AddWhereCondition(where, "(OrderIsPaid = 0) OR (OrderIsPaid IS NULL)"); break; case PAY_STATUS_PAID: where = SqlHelper.AddWhereCondition(where, "OrderIsPaid = 1"); break; } // Currency filter CurrencyInfo currencyObj = CurrencyInfoProvider.GetCurrencyInfo(Currency, SiteContext.CurrentSiteName); if (currencyObj != null) { where = SqlHelper.AddWhereCondition(where, "OrderCurrencyID = " + currencyObj.CurrencyID); } // Min price in main currency filter if (MinPriceInMainCurrency > 0) { where = SqlHelper.AddWhereCondition(where, "OrderTotalPriceInMainCurrency >= " + MinPriceInMainCurrency); } // Max price in main currency filter if (MaxPriceInMainCurrency > 0) { where = SqlHelper.AddWhereCondition(where, "OrderTotalPriceInMainCurrency <= " + MaxPriceInMainCurrency); } // Shipping option filter ShippingOptionInfo shipping = ShippingOptionInfoProvider.GetShippingOptionInfo(ShippingOption, SiteContext.CurrentSiteName); if (shipping != null) { where = SqlHelper.AddWhereCondition(where, "OrderShippingOptionID = " + shipping.ShippingOptionID); } // Shipping country filter where = SqlHelper.AddWhereCondition(where, GetCountryWhereCondition()); // Date filter where = SqlHelper.AddWhereCondition(where, GetDateWhereCondition()); return(where); }
protected void OnBeforeSave(object sender, EventArgs e) { if ((Order == null) || (ShippingAddressSelector == null) || (ShippingOptionSelector == null) || (ShoppingCartFromOrder == null)) { return; } // Get current values var addressID = ValidationHelper.GetInteger(ShippingAddressSelector.Value, 0); var shippingOptionID = ValidationHelper.GetInteger(ShippingOptionSelector.Value, 0); // Is shipping needed? var isShippingNeeded = ShoppingCartFromOrder.IsShippingNeeded; // If shipping address is required if (isShippingNeeded || IsTaxBasedOnShippingAddress) { // If shipping address is not set if (addressID <= 0) { // Show error message ShowError(GetString("Order_Edit_Shipping.NoAddress")); return; } } try { // Check if original order shipping option was changed, the check cannot be done on edited object because edited object contains current value (not the original one) if (ShoppingCartFromOrder.ShoppingCartShippingOptionID != shippingOptionID) { PaymentOptionInfo payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(Order.OrderPaymentOptionID); // Check if payment is allowed with no shipping if ((payment != null) && (!payment.PaymentOptionAllowIfNoShipping && shippingOptionID == 0)) { // Set payment method to none and display warning ShoppingCartFromOrder.ShoppingCartPaymentOptionID = 0; var paymentMethodName = ResHelper.LocalizeString(payment.PaymentOptionDisplayName, null, true); var shippingOptionName = HTMLHelper.HTMLEncode(ShippingOptionSelector.ValueDisplayName); ShowWarning(String.Format(GetString("com.shippingoption.paymentsetnone"), paymentMethodName, shippingOptionName)); } // Set order new properties ShoppingCartFromOrder.ShoppingCartShippingOptionID = shippingOptionID; // Evaluate order data ShoppingCartFromOrder.Evaluate(); // Update order data ShoppingCartInfoProvider.SetOrder(ShoppingCartFromOrder, true); } var newTrackingNumber = ValidationHelper.GetString(orderShippingForm.FieldEditingControls["OrderTrackingNumber"].DataValue, String.Empty).Trim(); if (!newTrackingNumber.Equals(ShoppingCartFromOrder.Order.OrderTrackingNumber, StringComparison.InvariantCulture)) { // Update on the current order instance var order = ShoppingCartFromOrder.Order; order.OrderTrackingNumber = newTrackingNumber; OrderInfoProvider.SetOrderInfo(Order); } // Show message ShowChangesSaved(); // Stop automatic saving action orderShippingForm.StopProcessing = true; } catch (Exception ex) { // Show error message ShowError(ex.Message); } }
/// <summary> /// Convert given payment option name to its ID for specified site. /// </summary> /// <param name="name">Name of the payment option to be converted.</param> /// <param name="siteName">Name of the site of the payment option.</param> protected override int GetID(string name, string siteName) { var payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(name, siteName); return((payment != null) ? payment.PaymentOptionID : 0); }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check input values from textboxes and other contrlos string errorMessage = new Validator() .NotEmpty(txtPaymentOptionDisplayName.Text.Trim(), GetString("paymentoption_edit.errorEmptyDisplayName")) .NotEmpty(txtPaymentOptionName.Text.Trim(), GetString("paymentoption_edit.errorEmptyCodeName")).Result; if (!ValidationHelper.IsCodeName(txtPaymentOptionName.Text.Trim())) { errorMessage = GetString("General.ErrorCodeNameInIdentifierFormat"); } if (errorMessage == "") { // PaymentOptionName must be unique PaymentOptionInfo paymentOptionObj = null; string siteWhere = (mSiteId > 0) ? " AND (PaymentOptionSiteID = " + mSiteId + " OR PaymentOptionSiteID IS NULL)" : ""; DataSet ds = PaymentOptionInfoProvider.GetPaymentOptions("PaymentOptionName = '" + txtPaymentOptionName.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null); if (!DataHelper.DataSourceIsEmpty(ds)) { paymentOptionObj = new PaymentOptionInfo(ds.Tables[0].Rows[0]); } if ((paymentOptionObj == null) || (paymentOptionObj.PaymentOptionID == mPaymentOptionId)) { // Get the object if (paymentOptionObj == null) { paymentOptionObj = PaymentOptionInfoProvider.GetPaymentOptionInfo(mPaymentOptionId); if (paymentOptionObj == null) { paymentOptionObj = new PaymentOptionInfo(); paymentOptionObj.PaymentOptionSiteID = mSiteId; } } // Fill object paymentOptionObj.PaymentOptionID = mPaymentOptionId; paymentOptionObj.PaymentOptionDisplayName = txtPaymentOptionDisplayName.Text.Trim(); paymentOptionObj.PaymentOptionDescription = txtDescription.Text.Trim(); paymentOptionObj.PaymentOptionName = txtPaymentOptionName.Text.Trim(); paymentOptionObj.PaymentOptionEnabled = chkPaymentOptionEnabled.Checked; paymentOptionObj.PaymentOptionPaymentGateUrl = txtGateUrl.Text.Trim(); paymentOptionObj.PaymentOptionClassName = txtPaymentClassName.Text.Trim(); paymentOptionObj.PaymentOptionAssemblyName = txtPaymentAssemblyName.Text.Trim(); paymentOptionObj.PaymentOptionSucceededOrderStatusID = succeededElem.OrderStatusID; paymentOptionObj.PaymentOptionFailedOrderStatusID = failedElem.OrderStatusID; paymentOptionObj.PaymentOptionAllowIfNoShipping = chkAllowIfNoShipping.Checked; CheckConfigurationModification(paymentOptionObj.PaymentOptionSiteID); bool isNew = (paymentOptionObj.PaymentOptionID <= 0); PaymentOptionInfoProvider.SetPaymentOptionInfo(paymentOptionObj); // Upload image teaser if (isNew) { file.ObjectID = paymentOptionObj.PaymentOptionID; file.UploadFile(); } URLHelper.Redirect("PaymentOption_Edit.aspx?paymentOptionId=" + Convert.ToString(paymentOptionObj.PaymentOptionID) + "&saved=1&siteId=" + SiteID); } else { // Show error message ShowError(GetString("PaymentOption_Edit.PaymentOptionNameExists")); } } else { // Show error message ShowError(errorMessage); } }
private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView dr = null; bool orderCurrencyIsMain = false; switch (sourceName.ToLowerCSafe()) { case "idandinvoice": dr = (DataRowView)parameter; int orderId = ValidationHelper.GetInteger(dr["OrderID"], 0); string invoiceNumber = ValidationHelper.GetString(dr["OrderInvoiceNumber"], ""); // Show OrderID and invoice number in brackets if InvoiceNumber is different from OrderID if (!string.IsNullOrEmpty(invoiceNumber) && (invoiceNumber != orderId.ToString())) { return(HTMLHelper.HTMLEncode(orderId + " (" + invoiceNumber + ")")); } return(orderId); case "customer": dr = (DataRowView)parameter; string customerName = dr["CustomerFirstName"] + " " + dr["CustomerLastName"]; string customerCompany = ValidationHelper.GetString(dr["CustomerCompany"], ""); // Show customer name and company in brakcets, if company specified if (!string.IsNullOrEmpty(customerCompany)) { return(HTMLHelper.HTMLEncode(customerName + " (" + customerCompany + ")")); } return(HTMLHelper.HTMLEncode(customerName)); // case "email": dr = (DataRowView)parameter; string mailCustomer = ValidationHelper.GetString(dr["CustomerEmail"], ""); // Show customer mail return(HTMLHelper.HTMLEncode(mailCustomer)); // case "totalpriceinmaincurrency": dr = (DataRowView)parameter; double totalPriceInMainCurrency = ValidationHelper.GetDouble(dr["OrderTotalPriceInMainCurrency"], 0); orderCurrencyIsMain = ValidationHelper.GetBoolean(dr["CurrencyIsMain"], false); // Format currency string priceInMainCurrencyFormatted = ""; if (orderCurrencyIsMain) { priceInMainCurrencyFormatted = String.Format(dr["CurrencyFormatString"].ToString(), totalPriceInMainCurrency); } else { int siteId = ValidationHelper.GetInteger(dr["OrderSiteID"], 0); priceInMainCurrencyFormatted = CurrencyInfoProvider.GetFormattedPrice(totalPriceInMainCurrency, siteId); } return(HTMLHelper.HTMLEncode(priceInMainCurrencyFormatted)); case "totalpriceinorderprice": dr = (DataRowView)parameter; orderCurrencyIsMain = ValidationHelper.GetBoolean(dr["CurrencyIsMain"], false); if (orderCurrencyIsMain) { return("-"); } // If order is not in main currency, show order price double orderTotalPrice = ValidationHelper.GetDouble(dr["OrderTotalPrice"], 0); string priceFormatted = String.Format(dr["CurrencyFormatString"].ToString(), orderTotalPrice); // Formated currency return(HTMLHelper.HTMLEncode(priceFormatted)); case "orderpaymentoptionid": // Tranform to display name and localize int paymentOptionId = ValidationHelper.GetInteger(parameter, 0); PaymentOptionInfo paymentOption = PaymentOptionInfoProvider.GetPaymentOptionInfo(paymentOptionId); if (paymentOption != null) { return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(paymentOption.PaymentOptionDisplayName))); } break; case "ordershippingoptionid": // Tranform to display name and localize int shippingOptionId = ValidationHelper.GetInteger(parameter, 0); ShippingOptionInfo shippingOption = ShippingOptionInfoProvider.GetShippingOptionInfo(shippingOptionId); if (shippingOption != null) { return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(shippingOption.ShippingOptionDisplayName))); } break; case "note": string note = ValidationHelper.GetString(parameter, ""); if (string.IsNullOrEmpty(note)) { return("-"); } // Display link, note is in tooltip return("<a>" + GetString("general.view") + "</a>"); } return(parameter); }
/// <summary> /// Returns where condition based on webpart fields. /// </summary> private WhereCondition GetWhereCondition() { // Orders from current site var where = new WhereCondition() .WhereEquals("OrderSiteID", SiteContext.CurrentSiteID); // Order status filter var status = OrderStatusInfoProvider.GetOrderStatusInfo(OrderStatus, SiteContext.CurrentSiteName); if (status != null) { where.WhereEquals("OrderStatusID", status.StatusID); } // Customer or company like filter if (!string.IsNullOrEmpty(CustomerOrCompany)) { where.WhereIn("OrderCustomerID", new IDQuery <CustomerInfo>() .Where("CustomerFirstName + ' ' + CustomerLastName + ' ' + CustomerFirstName LIKE N'%" + SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(CustomerOrCompany)) + "%'") .Or() .WhereContains("CustomerCompany", CustomerOrCompany)); } // Filter for orders with note if (HasNote) { where.WhereNotEmpty("OrderNote"); } // Payment method filter var payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(PaymentMethod, SiteContext.CurrentSiteName); if (payment != null) { where.WhereEquals("OrderPaymentOptionID", payment.PaymentOptionID); } // Payment status filter switch (PaymentStatus.ToLowerCSafe()) { case PAY_STATUS_NOT_PAID: where.Where(new WhereCondition().WhereFalse("OrderIsPaid").Or().WhereNull("OrderIsPaid")); break; case PAY_STATUS_PAID: where.WhereTrue("OrderIsPaid"); break; } // Currency filter var currencyObj = CurrencyInfoProvider.GetCurrencyInfo(Currency, SiteContext.CurrentSiteName); if (currencyObj != null) { where.WhereEquals("OrderCurrencyID", currencyObj.CurrencyID); } // Min price in main currency filter if (MinPriceInMainCurrency > 0) { where.Where("OrderTotalPriceInMainCurrency", QueryOperator.LargerOrEquals, MinPriceInMainCurrency); } // Max price in main currency filter if (MaxPriceInMainCurrency > 0) { where.Where("OrderTotalPriceInMainCurrency", QueryOperator.LessOrEquals, MaxPriceInMainCurrency); } // Shipping option filter var shipping = ShippingOptionInfoProvider.GetShippingOptionInfo(ShippingOption, SiteContext.CurrentSiteName); if (shipping != null) { where.WhereEquals("OrderShippingOptionID", shipping.ShippingOptionID); } // Shipping country filter if (!string.IsNullOrEmpty(ShippingCountry) && ShippingCountry != "0") { AddCountryWhereCondition(where); } // Date filter AddDateWhereCondition(where); return(where); }
protected void Page_Load(object sender, EventArgs e) { // Field validator error messages initialization rfvDisplayName.ErrorMessage = GetString("paymentoption_edit.errorEmptyDisplayName"); rfvCodeName.ErrorMessage = GetString("paymentoption_edit.errorEmptyCodeName"); // Control initializations lblPaymentOptionName.Text = GetString("PaymentOption_Edit.PaymentOptionNameLabel"); lblPaymentOptionDisplayName.Text = GetString("PaymentOption_Edit.PaymentOptionDisplayNameLabel"); // Gateway lblPaymentGateway.Text = GetString("PaymentOption_Edit.GatewaySettings"); lblGateUrl.Text = GetString("PaymentOption_Edit.GateUrl"); lblPaymentAssemblyName.Text = GetString("PaymentOption_Edit.PaymentAssemblyName"); lblPaymentClassName.Text = GetString("PaymentOption_Edit.PaymentClassName"); // Statuses lblStatusFailed.Text = GetString("PaymentOption_Edit.PaymentFailedStatus"); lblStatusSucceed.Text = GetString("PaymentOption_Edit.PaymentSucceedStatus"); btnOk.Text = GetString("General.OK"); string currentPaymentOption = GetString("PaymentOption_Edit.NewItemCaption"); // Get paymentOption id from querystring mPaymentOptionId = QueryHelper.GetInteger("paymentOptionId", 0); mSiteId = ConfiguredSiteID; if (mPaymentOptionId > 0) { PaymentOptionInfo paymentOptionObj = PaymentOptionInfoProvider.GetPaymentOptionInfo(mPaymentOptionId); EditedObject = paymentOptionObj; if (paymentOptionObj != null) { currentPaymentOption = ResHelper.LocalizeString(paymentOptionObj.PaymentOptionDisplayName); mSiteId = paymentOptionObj.PaymentOptionSiteID; CheckEditedObjectSiteID(mSiteId); // Fill editing form if (!RequestHelper.IsPostBack()) { LoadData(paymentOptionObj); // Show that the paymentOption was created or updated successfully if (QueryHelper.GetString("saved", "") == "1") { lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } } } this.CurrentMaster.Title.TitleText = GetString("PaymentOption_Edit.HeaderCaption"); this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_PaymentOption/object.png"); } else // Add new { this.CurrentMaster.Title.TitleText = GetString("PaymentOption_New.HeaderCaption"); this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_PaymentOption/new.png"); } this.succeededElem.SiteID = mSiteId; this.failedElem.SiteID = mSiteId; // Initializes page title control string[,] pageTitleTabs = new string[2, 3]; pageTitleTabs[0, 0] = GetString("PaymentOption_Edit.ItemListLink"); pageTitleTabs[0, 1] = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/PaymentOptions/PaymentOption_List.aspx?siteId=" + SiteID; pageTitleTabs[0, 2] = ""; pageTitleTabs[1, 0] = FormatBreadcrumbObjectName(currentPaymentOption, mSiteId); pageTitleTabs[1, 1] = ""; pageTitleTabs[1, 2] = ""; this.CurrentMaster.Title.Breadcrumbs = pageTitleTabs; this.CurrentMaster.Title.HelpTopicName = "newedit_payment_method"; this.CurrentMaster.Title.HelpName = "helpTopic"; }