/// <summary> /// Executes the charge operation. /// </summary> /// <param name="paymentInfo">The payment info.</param> public void ExecuteCharge(Litium.Foundation.Modules.ECommerce.Payments.PaymentInfo paymentInfo) { bool isRedirected = false; try { // If the order is already reserved, CanCompleteTransaction will be true. // Call complete transaction on the already reserved order, else call direct charge customer account. if (paymentInfo.PaymentProvider.CanCompleteCurrentTransaction) paymentInfo.PaymentProvider.CompletePayment(new DirectPayCompletePaymentArgs(), FoundationContext.Token); else { DirectPayPaymentArgs args = new DirectPayPaymentArgs(); args.PaymentMode = ExecutePaymentMode.Charge; args.UserHostAddress = Request.UserHostAddress; paymentInfo.PaymentProvider.ExecutePayment(args, FoundationContext.Token); } } catch (PaymentProviderException) { } if (!isRedirected) { Response.Redirect(UrlConstants.VIEW_PAYMENT + "?" + ParameterConstants.ECOM_SELECTED_NAVBAR_PAGE + "=" + ((int)Litium.Studio.UI.ECommerce.Common.Enums.FilterType.Payments).ToString() + "&" + ParameterConstants.FROM_PAYMENT + "=true&" + ParameterConstants.ECOM_ORDER_ID + "=" + paymentInfo.OrderID + "&" + ParameterConstants.ECOM_PAYMENT_INFO_ID + "=" + paymentInfo.ID + "&" + ParameterConstants.QUERY_STRING_NAVIGATE_FROM + "=2"); } }
/// <summary> /// Initiate the delivery. /// </summary> /// <param name="delivery">The delivery.</param> public void InitDelivery(Litium.Foundation.Modules.ECommerce.Deliveries.Delivery delivery) { try { c_test.Text = Server.HtmlEncode(CreateXml(delivery, string.Empty).OuterXml).Replace("><", "><br /><"); } catch (Exception ex) { c_test.Text = ex.Message + " " + ex.StackTrace; } }
/// <summary> /// Executes the charge operation. /// </summary> /// <param name="paymentInfo">The payment info.</param> public void ExecuteCharge(Litium.Foundation.Modules.ECommerce.Payments.PaymentInfo paymentInfo) { try { // If the order is already reserved, CanCompleteTransaction will be true. // Call complete transaction on the already reserved order, else call direct charge customer account. if (paymentInfo.PaymentProvider.CanCompleteCurrentTransaction) { paymentInfo.PaymentProvider.CompletePayment(new PayExCompletePaymentArgs(), FoundationContext.Token); //redirect to view payment. Response.Redirect(UrlConstants.VIEW_PAYMENT + "?" + ParameterConstants.ECOM_SELECTED_NAVBAR_PAGE + "=" + ((int)Litium.Studio.UI.ECommerce.Common.Enums.FilterType.Payments).ToString() + "&" + ParameterConstants.FROM_PAYMENT + "=true&" + ParameterConstants.ECOM_ORDER_ID + "=" + paymentInfo.OrderID + "&" + ParameterConstants.ECOM_PAYMENT_INFO_ID + "=" + paymentInfo.ID + "&" + ParameterConstants.QUERY_STRING_NAVIGATE_FROM + "=2"); } else { PayExExecutePaymentArgs args = new PayExExecutePaymentArgs(string.Empty, UrlConstants.PAYMENT_SUCCESS, UrlConstants.PAYMENT_CANCEL, FoundationContext.Culture.Name); args.PaymentMode = ExecutePaymentMode.Charge; //add redirect script on success. args.ExecuteScript = new PayExExecutePaymentArgs.ExecuteScriptHandler(delegate(string scriptArgs, bool redirect) { if (redirect) Response.Redirect(scriptArgs, true); }); args.UserHostAddress = Request.UserHostAddress; PayExExecutePaymentResult result = (PayExExecutePaymentResult)paymentInfo.PaymentProvider.ExecutePayment(args, FoundationContext.Token); if (!result.Success) { Response.Redirect(UrlConstants.VIEW_PAYMENT + "?" + ParameterConstants.ECOM_SELECTED_NAVBAR_PAGE + "=" + ((int)Litium.Studio.UI.ECommerce.Common.Enums.FilterType.Payments).ToString() + "&" + ParameterConstants.FROM_PAYMENT + "=true&" + ParameterConstants.ECOM_ORDER_ID + "=" + paymentInfo.OrderID + "&" + ParameterConstants.ECOM_PAYMENT_INFO_ID + "=" + paymentInfo.ID + "&" + ParameterConstants.QUERY_STRING_NAVIGATE_FROM + "=2", true); } } } catch (PaymentProviderException) { } }
/// <summary> /// Processes the delivery. /// </summary> /// <param name="delivery">The delivery.</param> public void ProcessDelivery(Litium.Foundation.Modules.ECommerce.Deliveries.Delivery delivery) { try { ECommerce.Web.PacSoft.IntegrationService service = new ECommerce.Web.PacSoft.IntegrationService(); string senderid = System.Web.Configuration.WebConfigurationManager.AppSettings["PacSoftSenderID"]; string username = System.Web.Configuration.WebConfigurationManager.AppSettings["PacSoftWebUsername"]; string password = System.Web.Configuration.WebConfigurationManager.AppSettings["PacSoftWebPassword"]; service.TransferXml(username, password, CreateXml(delivery, senderid)); } catch (System.Net.Sockets.SocketException ex) { throw new Exception(string.Format(ModuleECommerce.Instance.Strings.GetValue("DeliveryProviderSocketException", FoundationContext.Current.LanguageID, true), delivery.ExternalReferenceID), ex); } catch (Exception ex) { if (ex.Message.IndexOf("NotAuthorizedException", StringComparison.InvariantCultureIgnoreCase) != -1) throw new Exception(string.Format(ModuleECommerce.Instance.Strings.GetValue("DeliveryProviderNotAuthorizedException", FoundationContext.Current.LanguageID, true), delivery.ExternalReferenceID), ex); throw new Exception(string.Format(ModuleECommerce.Instance.Strings.GetValue("DeliveryProviderException", FoundationContext.Current.LanguageID, true), delivery.ExternalReferenceID, ex.Message), ex); } }
/// <summary> /// Executes the reserve operation. /// </summary> /// <param name="paymentInfo">The payment info.</param> public void ExecuteReserve(Litium.Foundation.Modules.ECommerce.Payments.PaymentInfo paymentInfo) { bool isRedirected = false; try { DirectPayPaymentArgs args = new DirectPayPaymentArgs(); args.PaymentMode = ExecutePaymentMode.Reserve; args.UserHostAddress = Request.UserHostAddress; paymentInfo.PaymentProvider.ExecutePayment(args, FoundationContext.Token); } catch (PaymentProviderException) { } if (!isRedirected) { Response.Redirect(UrlConstants.VIEW_PAYMENT + "?" + ParameterConstants.ECOM_SELECTED_NAVBAR_PAGE + "=" + ((int)Litium.Studio.UI.ECommerce.Common.Enums.FilterType.Payments).ToString() + "&" + ParameterConstants.FROM_PAYMENT + "=true&" + ParameterConstants.ECOM_ORDER_ID + "=" + paymentInfo.OrderID + "&" + ParameterConstants.ECOM_PAYMENT_INFO_ID + "=" + paymentInfo.ID + "&" + ParameterConstants.QUERY_STRING_NAVIGATE_FROM + "=2"); } }
private List<Page> GetPagesFromSearchResponse(SearchResponse response, Litium.Foundation.Modules.CMS.Security.PermissionManager permissionManager, SecurityToken token) { List<Page> pages = new List<Page>(); if (response != null && response.Hits != null) { foreach (Hit hit in response.Hits) { Guid pageId = new Guid(hit.Id); // Verify that page exists and user has permission to view page if (Page.ExistsPage(pageId) && permissionManager.UserHasPageReadPermission(token.UserID, pageId, true, true)) { // Fetch page from database Page page = Page.GetFromID(pageId, token); pages.Add(page); } } } return pages; }
/// <summary> /// Gets <see cref="Metadata"/> with complete set of information. /// </summary> /// <param name="request">The request.</param> /// <param name="searchService">The search service.</param> /// <param name="permissionManager">The permission manager.</param> /// <param name="token">The token.</param> /// <returns></returns> public List<Metadata> GetMetadatas(QueryRequest request, Litium.Foundation.Modules.CMS.Security.PermissionManager permissionManager, SecurityToken token) { // Perform search SearchResponse response = Solution.Instance.SearchService.Search(request); if (response == null) { _log.Error("Search returned null instead of zero results."); return new List<Metadata>(); } List<Page> pages = GetPagesFromSearchResponse(response, permissionManager, token); List<Metadata> mds = new List<Metadata>(); foreach (Page page in pages) { mds.Add(new Metadata(page, this, token)); } return mds; }
private ProductModel ConvertFrom(Litium.Domain.Entities.ProductCatalog.Product product) { return new ProductModel(product); }
/// <summary> /// Objects the post form1_ object post edited. /// </summary> /// <param name="post">The post.</param> protected void ObjectPostForm1ObjectPostEdited(Litium.Extensions.ObjectPost.ObjectPost post) { string url = UrlUtilities.RemoveUrlParameter(Page.Request.Url.ToString(), QueryStringParameterConstants.OBJECTPOST_EDITEDOBJECTPOSTID); Response.Redirect(url); }
/// <summary> /// Creates the XML. /// </summary> /// <param name="delivery">The delivery.</param> /// <param name="sender">Sender shortname in pacsoft web-interface</param> /// <returns></returns> private static XmlDocument CreateXml(Litium.Foundation.Modules.ECommerce.Deliveries.Delivery delivery, string sender) { if (!IsPacSoftSupported(delivery.DeliveryMethod.Description, PacSoftMethods)) { throw new NotSupportedException(string.Format("Delivery method {0} not supported by PacSoft.", delivery.DeliveryMethod.Description)); } Order currentOrder = ModuleECommerce.Instance.Orders[delivery.OrderID, FoundationContext.Current.Token]; XmlDocument xDoc = new XmlDocument(); xDoc.PreserveWhitespace = true; //xml header xDoc.AppendChild(xDoc.CreateXmlDeclaration("1.0", "UTF-8", null)); // pacsoftonline root node XmlNode rootNode = xDoc.AppendChild(xDoc.CreateElement("pacsoftonline")); // **** meta node XmlNode metaNode = rootNode.AppendChild(xDoc.CreateElement("meta")); metaNode.AppendChild(CreateValue(xDoc, "printer", "...")); // **** receiver node Litium.Foundation.Modules.ECommerce.Addresses.Address address = delivery.Address; XmlNode receiverNode = rootNode.AppendChild(xDoc.CreateElement("receiver")); receiverNode.Attributes.Append(CreateAttribute(xDoc, "rcvid", "R" + delivery.ExternalReferenceID)); if (string.IsNullOrEmpty(address.OrganizationName)) receiverNode.AppendChild(CreateValue(xDoc, "name", string.Format("{0} {1}", address.FirstName, address.LastName))); else receiverNode.AppendChild(CreateValue(xDoc, "name", address.OrganizationName)); receiverNode.AppendChild(CreateValue(xDoc, "address1", address.Address1)); if (!string.IsNullOrEmpty(address.Address2)) receiverNode.AppendChild(CreateValue(xDoc, "address2", address.Address2)); receiverNode.AppendChild(CreateValue(xDoc, "zipcode", address.Zip)); receiverNode.AppendChild(CreateValue(xDoc, "city", address.City)); receiverNode.AppendChild(CreateValue(xDoc, "country", address.Country)); receiverNode.AppendChild(CreateValue(xDoc, "contact", string.Format("{0} {1}", address.FirstName, address.LastName))); if (!string.IsNullOrEmpty(address.Phone)) receiverNode.AppendChild(CreateValue(xDoc, "phone", address.Phone)); if (!string.IsNullOrEmpty(address.Fax)) receiverNode.AppendChild(CreateValue(xDoc, "fax", address.Fax)); if (!string.IsNullOrEmpty(address.Email)) receiverNode.AppendChild(CreateValue(xDoc, "email", address.Email)); if (!string.IsNullOrEmpty(address.MobilePhone)) receiverNode.AppendChild(CreateValue(xDoc, "sms", address.MobilePhone)); // **** shipment XmlNode shipmentNode = rootNode.AppendChild(xDoc.CreateElement("shipment")); shipmentNode.Attributes.Append(CreateAttribute(xDoc, "orderno", delivery.ExternalReferenceID)); shipmentNode.AppendChild(CreateValue(xDoc, "from", sender)); shipmentNode.AppendChild(CreateValue(xDoc, "to", "R" + delivery.ExternalReferenceID)); shipmentNode.AppendChild(CreateValue(xDoc, "reference", delivery.ExternalReferenceID)); shipmentNode.AppendChild(CreateValue(xDoc, "referencebarcode", delivery.ExternalReferenceID)); // **** **** service XmlElement serviceNode = shipmentNode.AppendChild(xDoc.CreateElement("service")) as XmlElement; serviceNode.IsEmpty = false; //to prevent self-closing tag like <service srvid="P45"/>, pacsoft ignore xmlnode in this case serviceNode.Attributes.Append(CreateAttribute(xDoc, "srvid", delivery.DeliveryMethod.Description)); // **** **** **** addon cod if (IsPacSoftSupported(delivery.DeliveryMethod.Description, PacSoftCODMethods)) { if (IsCodPayment(currentOrder)) { string codAccount = System.Web.Configuration.WebConfigurationManager.AppSettings["PacSoftCodAccount"]; string codCustno = System.Web.Configuration.WebConfigurationManager.AppSettings["PacSoftCodCustno"]; XmlNode addonCodNode = serviceNode.AppendChild(xDoc.CreateElement("addon")); addonCodNode.Attributes.Append(CreateAttribute(xDoc, "adnid", "cod")); addonCodNode.AppendChild(CreateValue(xDoc, "amount", currentOrder.GrandTotal.ToString("0.00"))); addonCodNode.AppendChild(CreateValue(xDoc, "account", codAccount)); addonCodNode.AppendChild(CreateValue(xDoc, "custno", codCustno)); addonCodNode.AppendChild(CreateValue(xDoc, "reference", delivery.ExternalReferenceID)); // <addon adnid="cod"> // <val n="amount">1200.00</val> // <val n="account">488817-8</val> TODO: What need to sent there? // <val n="custno">122343500</val> TODO: What need to sent there? // <val n="reference">Betalreferens</val> // </addon> } } // **** **** **** addon notsms if (IsPacSoftSupported(delivery.DeliveryMethod.Description, PacSoftSmsMethods) && !string.IsNullOrEmpty(address.MobilePhone)) { XmlNode addonSmsNode = serviceNode.AppendChild(xDoc.CreateElement("addon")); addonSmsNode.Attributes.Append(CreateAttribute(xDoc, "adnid", "notsms")); addonSmsNode.AppendChild(CreateValue(xDoc, "misc", address.MobilePhone)); } // **** **** uf online string enotMessage = ModuleECommerce.Instance.Strings.GetValue("PacSoftMessage", FoundationContext.Current.LanguageID, true); if (!string.IsNullOrEmpty(enotMessage) && !string.IsNullOrEmpty(address.Email)) { XmlNode ufoNode = shipmentNode.AppendChild(xDoc.CreateElement("ufonline")); XmlNode optionNode = ufoNode.AppendChild(xDoc.CreateElement("option")); optionNode.Attributes.Append(CreateAttribute(xDoc, "optid", "enot")); optionNode.AppendChild(CreateValue(xDoc, "message", enotMessage.Replace("\n", "
"))); optionNode.AppendChild(CreateValue(xDoc, "to", address.Email)); } // **** **** container XmlNode containerNode = shipmentNode.AppendChild(xDoc.CreateElement("container")); containerNode.Attributes.Append(CreateAttribute(xDoc, "type", "parcel")); containerNode.AppendChild(CreateValue(xDoc, "copies", "1")); return xDoc; }
protected string GetStringContent(Litium.Foundation.Modules.CMS.Pages.Page page, string propertyName) { StringProperty property = page.Content[propertyName] as StringProperty; if(property != null && property.ValueCount > 0) { return property.GetValue(); } return string.Empty; }