void Page_InitComplete(object sender, EventArgs e) { WebTrace.Write("InitComplete, Ensuring Child Controls for ScriptletPart"); // MAKE SURE ALL CONTROLS ARE CREATED AFTER PERSONALIZATION IS APPLIED // BUT BEFORE THE PAGE LOAD EVENT OCCURS this.EnsureChildControls(); }
private LSDecimal Calculate_PointOfDelivery(Basket basket, Dictionary <string, string> existingTransactions) { WebTrace.Write("CertiTAX: Begin Calculate POD"); LSDecimal totalTax = 0; foreach (BasketShipment shipment in basket.Shipments) { CertiTAX.Order taxOrder = new CertiTAX.Order(); //SET THE TAXORDER ADDRESS BuildTaxOrderAddress(taxOrder, shipment.Address); //BUILD THE TAXORDER OBJECT BuildTaxOrder(taxOrder, basket, shipment.BasketShipmentId, existingTransactions); taxOrder.Nexus = "POD"; //EXECUTE THE TRANSACTION CertiTAX.TaxTransaction taxTransaction = null; try { taxTransaction = (new CertiTAX.CertiCalc()).Calculate(taxOrder); } catch (Exception ex) { WebTrace.Write("CertiTax could not calculate tax. The error was: " + ex.Message); if (!this.IgnoreFailedConfirm) { throw; } } //PARSE THE RESULTS totalTax += ParseTaxTransaction(taxTransaction, basket, shipment.BasketShipmentId); } WebTrace.Write("CertiTAX: End Calculate POD"); //RETURN THE TOTAL TAX return(totalTax); }
private LSDecimal Calculate_PointOfSale(Basket basket, Dictionary <string, string> existingTransactions) { WebTrace.Write("CertiTAX: Begin Calculate POS"); CertiTAX.Order taxOrder = new CertiTAX.Order(); //SET THE TAXORDER ADDRESS BuildTaxOrderAddress(taxOrder, StoreDataSource.Load().DefaultWarehouse); //BUILD THE TAXORDER OBJECT BuildTaxOrder(taxOrder, basket, 0, existingTransactions); taxOrder.Nexus = "POS"; //EXECUTE THE TRANSACTION CertiTAX.TaxTransaction taxTransaction = null; try { taxTransaction = (new CertiTAX.CertiCalc()).Calculate(taxOrder); } catch (Exception ex) { WebTrace.Write("CertiTax could not calculate tax. The error was: " + ex.Message); if (!this.IgnoreFailedConfirm) { throw; } } //PARSE THE RESULTS LSDecimal totalTax = ParseTaxTransaction(taxTransaction, basket, 0); WebTrace.Write("CertiTAX: End Calculate POS"); return(totalTax); }
private void CombineItems() { WebTrace.Write("Begin Combine"); WishlistItem item; for (int i = this.Count - 1; i > 0; i--) { item = this[i]; if (item.Desired > 0) { WebTrace.Write("i: " + i.ToString() + ", WishlistItemId: " + item.WishlistItemId.ToString() + ", ProductId: " + item.ProductId); WishlistItem match = this.Find(new System.Predicate <WishlistItem>(item.CanCombine)); WebTrace.Write("(match!=null): " + (match != null)); if ((match != null) && (item.WishlistItemId != match.WishlistItemId)) { WebTrace.Write("match.WishlistItemId: " + match.WishlistItemId.ToString()); match.Desired += item.Desired; this.DeleteAt(i); } } else { this.DeleteAt(i); } } }
/// <summary> /// Validates a credit card number using the standard Luhn/mod10 /// validation algorithm. /// </summary> /// <param name="routingNumber">Card number, without punctuation or spaces.</param> /// <returns>True if card number appears valid, false if not /// </returns> public bool ValidateRoutingNumber(string routingNumber) { try { if (String.IsNullOrEmpty(routingNumber)) { return(false); } if (routingNumber.Length != 9) { return(false); } int digit, sum = 0; for (int i = 0; i < routingNumber.Length; i += 3) { digit = AlwaysConvert.ToInt(routingNumber.Substring(i, 1)); sum += digit * 3; digit = AlwaysConvert.ToInt(routingNumber.Substring(i + 1, 1)); sum += digit * 7; digit = AlwaysConvert.ToInt(routingNumber.Substring(i + 2, 1)); sum += digit; } WebTrace.Write("sum: " + sum); return((sum > 0) && (sum % 10 == 0)); } catch { return(false); } }
public void TriggerCacheSync([FromBody] AgilityPublishRequest publishRequest) { ValidateRequest(publishRequest.WebsiteName, publishRequest.SecurityKey); WebTrace.WriteVerboseLine(string.Format("Cache sync triggered: Domain:{0}, Website:{1}, Key:{2}", publishRequest.WebsiteDomain, publishRequest.WebsiteName, publishRequest.SecurityKey)); SyncThread.QueueSyncThread(publishRequest, false); }
private void RunLogProcessingThread() { try { //TODO: check impersonation? //WindowsImpersonationContext wi = Sync.SyncThread.ApplicationIdentity.Impersonate(); //only do this processing if we need to... if (!Configuration.Current.Settings.Trace.EmailErrors) { return; } //wait a minute before we get started Thread.Sleep(TimeSpan.FromMinutes(1)); Agility.Web.Tracing.WebTrace.WriteVerboseLine("Starting offline processing thread."); Int64 minutes = 1; Int64 ERROR_CHECK_MINUTES = 15; Int64 CLEANUP_CHECK_MINUTES = 60; while (true) { try { if (minutes == 1 || minutes % ERROR_CHECK_MINUTES == 0) { Agility.Web.Tracing.WebTrace.WriteVerboseLine("Checking for errors in error log."); //do the error log check WebTrace.SendErrorSummary(); } } catch (Exception ex) { Agility.Web.Tracing.WebTrace.WriteException(ex); } Thread.Sleep(TimeSpan.FromMinutes(1)); minutes++; } } catch (ThreadAbortException) { //this will be called when the app is shutdown or the thread is killed } catch (Exception ex) { Agility.Web.Tracing.WebTrace.WriteException(ex); } finally { IsOfflineThreadRunning = false; } }
public void ClearAllCache([FromBody] AgilityPublishRequest publishRequest) { WebTrace.WriteInfoLine("Triggering Cache Clear: " + publishRequest.WebsiteName + " - " + publishRequest.SecurityKey); ValidateRequest(publishRequest.WebsiteName, publishRequest.SecurityKey); //trigger a sync that will sync ALL items Sync.SyncThread.QueueSyncThread(publishRequest, true); }
protected override bool EvaluateIsValid() { if (IsValidCardType(_cardNumber.Text)) { WebTrace.Write("Valid Card Type Detected. Accepted Card Type: " + AcceptedCardType.ToString()); return(ValidateCardNumber(_cardNumber.Text)); } return(false); }
/// <summary> /// Combines any shipments in the collection that have equivalent data. /// </summary> /// <param name="save">Flag indicating whether or not to persist changes.</param> /// <remarks>When shipments are combined any items they contain are merged into a single shipment.</remarks> public void Combine(bool save) { WebTrace.Write("Combine Basket Shipments"); for (int i = this.Count - 1; i >= 0; i--) { BasketShipment shipment = this[i]; List <BasketItem> shipmentItems = shipment.Items.FindAll(delegate(BasketItem item) { return(item.BasketShipmentId == shipment.BasketShipmentId); }); if (shipmentItems.Count > 0) { WebTrace.Write("i: " + i.ToString() + ", BasketShipmentId: " + shipment.BasketShipmentId.ToString()); BasketShipment match = this.Find(new System.Predicate <BasketShipment>(shipment.CanCombine)); if ((match != null) && (match.BasketShipmentId != shipment.BasketShipmentId)) { WebTrace.Write("match.BasketShipmentId: " + match.BasketShipmentId.ToString()); //NEED TO MOVE ITEMS FROM THIS SHIPMENT TO THE MATCHED SHIPMENT foreach (BasketItem item in shipmentItems) { item.BasketShipmentId = match.BasketShipmentId; if (save) { item.Save(); } } if (save) { this.DeleteAt(i); } else { removedItems.Add(this[i]); this.RemoveAt(i); } } } else { if (save) { this.DeleteAt(i); } else { removedItems.Add(this[i]); this.RemoveAt(i); } } } this.Save(); }
private void CreateTaxLineItem(Basket basket, int shipmentId, string authorityName, string certiTaxTransactionId, LSDecimal amount) { BasketItem taxLineItem = new BasketItem(); taxLineItem.BasketId = basket.BasketId; taxLineItem.OrderItemType = OrderItemType.Tax; taxLineItem.BasketShipmentId = shipmentId; taxLineItem.Name = authorityName; taxLineItem.Sku = string.Format("CT:" + certiTaxTransactionId); taxLineItem.Price = amount; taxLineItem.Quantity = 1; taxLineItem.Save(); basket.Items.Add(taxLineItem); WebTrace.Write("Tax Line Item Added"); }
public override void Cancel(CommerceBuilder.Orders.Basket basket) { WebTrace.Write("Cancel Existing Taxes"); List <string> uniqueTransactionIds = new List <string>(); Dictionary <string, string> existingTransactions = ClearExistingTaxes(basket); CertiTAX.CertiCalc comm = new CertiTAX.CertiCalc(); foreach (string transactionId in existingTransactions.Values) { if (uniqueTransactionIds.IndexOf(transactionId) < 0) { uniqueTransactionIds.Add(transactionId); comm.Cancel(transactionId, CT_SERIAL_NUMBER, this.ReferredID); } } }
private void BuildTaxOrderItems(CertiTAX.Order taxOrder, Basket basket, int shipmentId) { if (this.UseLineItems) { WebTrace.Write("Process Tax Items -- Line Items Mode"); LSDecimal productTotal = 0; List <CertiTAX.OrderLineItem> taxLineItems = new List <CertiTAX.OrderLineItem>(); foreach (BasketItem item in basket.Items) { if (item.OrderItemType == OrderItemType.Product) { CertiTAX.OrderLineItem taxLineItem = new CertiTAX.OrderLineItem(); taxLineItem.ItemId = item.ProductId.ToString(); taxLineItem.StockingUnit = item.Sku; taxLineItem.Quantity = item.Quantity; taxLineItem.ExtendedPrice = (Decimal)item.ExtendedPrice; productTotal += item.ExtendedPrice; taxLineItems.Add(taxLineItem); } } taxOrder.LineItems = taxLineItems.ToArray(); taxOrder.Total = (Decimal)productTotal; } else { WebTrace.Write("Process Tax Items -- Order Total Mode"); OrderItemType[] productTypes = { OrderItemType.Product, OrderItemType.Coupon, OrderItemType.Discount }; if (shipmentId == 0) { //SET TOTAL FOR THE BASKET taxOrder.Total = (Decimal)basket.Items.TotalPrice(productTypes); } else { //SET TOTAL FOR THE SHIPMENT BasketShipment shipment = this.GetShipment(basket, shipmentId); if (shipment != null) { taxOrder.Total = (Decimal)shipment.GetItems().TotalPrice(productTypes); } else { taxOrder.Total = 0; } } } }
private static Dictionary <string, string> ClearExistingTaxes(Basket basket) { WebTrace.Write("Clear Existing Taxes"); Dictionary <string, string> existingTransactions = new Dictionary <string, string>(); for (int i = basket.Items.Count - 1; i >= 0; i--) { BasketItem item = basket.Items[i]; if (item.OrderItemType == OrderItemType.Tax) { if (!existingTransactions.ContainsKey(item.BasketShipmentId.ToString()) && item.Sku.StartsWith("CT:")) { existingTransactions[item.BasketShipmentId.ToString()] = item.Sku.Substring(3); } basket.Items.DeleteAt(i); } } return(existingTransactions); }
protected override void CreateControlHierarchy() { if (HttpContext.Current != null) { WebTrace.Write(this.GetType().ToString(), "CreateControlHierarchy, CategoryId " + this.CategoryId); WebTrace.Write(this.GetType().ToString(), "CurrentNodeId: " + CurrentNodeId); WebTrace.Write(this.GetType().ToString(), "CurrentNodeType: " + CurrentNodeType); SiteMapNodeItemType itemType; List <CmsPathNode> cmsPath = CmsPath.GetCmsPath(CategoryId, CurrentNodeId, CurrentNodeType); int pathIndex = 0; int nodeIndex = 1; foreach (CmsPathNode node in cmsPath) { if (nodeIndex == cmsPath.Count) { WebTrace.Write(node.Title + ": Current"); itemType = SiteMapNodeItemType.Current; } else if (nodeIndex == 1) { WebTrace.Write(node.Title + ": Root"); itemType = SiteMapNodeItemType.Root; } else { WebTrace.Write(node.Title + ": Parent"); itemType = SiteMapNodeItemType.Parent; } if (nodeIndex > 1) { this.CreateItemFromCmsPathNode(pathIndex, SiteMapNodeItemType.PathSeparator, null); pathIndex++; } CreateItemFromCmsPathNode(pathIndex, itemType, node); pathIndex++; nodeIndex++; } } else { base.CreateControlHierarchy(); } }
public override void Commit(CommerceBuilder.Orders.Order order) { WebTrace.Write("Commit Existing Taxes"); List <string> uniqueTransactionIds = new List <string>(); CertiTAX.CertiCalc comm = new CertiTAX.CertiCalc(); foreach (OrderItem item in order.Items) { if ((item.OrderItemType == OrderItemType.Tax) && (item.Sku.StartsWith("CT:") && (!item.LineMessage.Equals("Committed")))) { string transactionId = item.Sku.Substring(3); if (uniqueTransactionIds.IndexOf(transactionId) < 0) { CommerceBuilder.Taxes.Providers.CCH.CertiTAX.TaxTransaction tx = new CommerceBuilder.Taxes.Providers.CCH.CertiTAX.TaxTransaction(); uniqueTransactionIds.Add(transactionId); comm.Commit(transactionId, CT_SERIAL_NUMBER, this.ReferredID); item.LineMessage = "Committed"; } } } }
private void InitText(string uniqueId) { HttpContext context = HttpContext.Current; if (context != null) { if (string.IsNullOrEmpty(uniqueId)) { uniqueId = this.UniqueID; } WebTrace.Write("Init text, using uniqueid: " + this.UniqueID); if (string.IsNullOrEmpty(context.Request.Form[uniqueId])) { this.Text = "0"; } else { this.Text = context.Request.Form[uniqueId]; } WebTrace.Write("text: " + this.Text); } }
private void BuildTaxOrder(CertiTAX.Order taxOrder, Basket basket, int shipmentId, Dictionary <string, string> existingTransactions) { if (existingTransactions.ContainsKey(shipmentId.ToString())) { taxOrder.CertiTAXTransactionId = existingTransactions[shipmentId.ToString()]; } LSDecimal shippingCharge = 0; LSDecimal handlingCharge = 0; GetShipCharges(basket, shipmentId, out shippingCharge, out handlingCharge); taxOrder.SerialNumber = CT_SERIAL_NUMBER; taxOrder.ReferredId = ReferredID; taxOrder.CalculateTax = true; taxOrder.ConfirmAddress = this.ConfirmAddresses; taxOrder.DefaultProductCode = 0; taxOrder.HandlingCharge = (Decimal)handlingCharge; taxOrder.ShippingCharge = (Decimal)shippingCharge; taxOrder.Location = Location; taxOrder.MerchantTransactionId = basket.BasketId.ToString(); WebTrace.Write("Processing Items"); BuildTaxOrderItems(taxOrder, basket, shipmentId); }
/// <summary> /// Initializes the provider. /// </summary> /// <param name="name">The friendly name of the provider.</param> /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param> public override void Initialize(string name, NameValueCollection config) { WebTrace.Write("Initializing AbleCommerceMembershipProvider"); if (config == null) { throw new ArgumentNullException("config"); } if (string.IsNullOrEmpty(name)) { name = "AbleCommerceMembershipProvider"; } config.Remove("name"); if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "A membership provider for the AbleCommerce application."); } base.Initialize(name, config); //SET THE PASSWORD FORMAT _PasswordPolicy = new MerchantPasswordPolicy(); }
protected override bool ControlPropertiesValid() { // Should have a text box control to check Control ctrl = FindControl(ControlToValidate); WebTrace.Write("Found control to validate: " + (null != ctrl)); if (null != ctrl) { if (ctrl is System.Web.UI.WebControls.TextBox) // ensure its a text box { _cardNumber = (System.Web.UI.WebControls.TextBox)ctrl; // set the member variable WebTrace.Write("Control to validate is textbox: " + (null != _cardNumber)); return(null != _cardNumber); // check that it's been set ok } else { return(false); } } else { return(false); } }
public static HttpException CreateFromLastError(string message) { WebTrace.WriteLine("CreateFromLastError"); return(new HttpException(message, 0)); }
public override SiteMapNode FindSiteMapNode(string rawUrl) { //FIRST CHECK WHETHER THIS PAGE IS SPECIFICALLY KEYED IN THE CONFIG FILE SiteMapNode baseNode = base.FindSiteMapNode(rawUrl); if (baseNode != null) { if (_EnableHiding) { return(FindVisibleNode(baseNode)); } return(baseNode); } //PAGE NOT FOUND, CHECK WHETHER THIS URL MATCHES KNOWN CMS PAGES int categoryId = -1; WebTrace.Write(this.GetType().ToString(), "FindSiteMapNode: " + rawUrl + ", Check For CategoryId"); Match urlMatch = Regex.Match(rawUrl, "(?<baseUrl>.*)\\?(?:.*&)?CategoryId=(?<categoryId>[^&]*)", (RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase)); if (urlMatch.Success) { //CATEGORYID PROVIDED IN URL categoryId = AlwaysConvert.ToInt(urlMatch.Groups[2].Value); } else { WebTrace.Write(this.GetType().ToString(), "FindSiteMapNode: " + rawUrl + ", Check For Catalog Object Id"); urlMatch = Regex.Match(rawUrl, "(?<baseUrl>.*)\\?(?:.*&)?(?<nodeType>ProductId|WebpageId|LinkId)=(?<catalogId>[^&]*)", (RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase)); if (urlMatch.Success) { string objectType = urlMatch.Groups[2].Value; switch (objectType) { case "ProductId": categoryId = CatalogDataSource.GetCategoryId(AlwaysConvert.ToInt(urlMatch.Groups[3].Value), CatalogNodeType.Product); break; case "WebpageId": categoryId = CatalogDataSource.GetCategoryId(AlwaysConvert.ToInt(urlMatch.Groups[3].Value), CatalogNodeType.Webpage); break; default: categoryId = CatalogDataSource.GetCategoryId(AlwaysConvert.ToInt(urlMatch.Groups[3].Value), CatalogNodeType.Link); break; } WebTrace.Write("Found catalogobjectid, type: " + objectType + ", id: " + categoryId.ToString()); } } if (categoryId > -1) { //FIND BASE NODE WebTrace.Write(this.GetType().ToString(), "CategoryId Detected, Find Base Node"); baseNode = base.FindSiteMapNode(urlMatch.Groups[1].Value); if (baseNode != null) { WebTrace.Write(this.GetType().ToString(), "Base Node Found, Inject Catalog Path"); List <SiteMapNode> pathNodes = this.GetSiteMapPathNodes(baseNode); WebTrace.Write("default pathnodes count: " + pathNodes.Count.ToString()); int catalogNodeIndex = this.GetCatalogNodeIndex(pathNodes); //IF CATALOG NODE IS NOT FOUND, RETURN THE BASE NODE FOUND BY PROVIDER if (catalogNodeIndex < 0) { return(baseNode); } WebTrace.Write(this.GetType().ToString(), "Catalog Node Obtained, Building Dynamic Path"); //APPEND CMS PATH TO THE List <SiteMapNode> dynamicNodes = new List <SiteMapNode>(); List <CmsPathNode> activeCatalogPath = CmsPath.GetCmsPath(0, categoryId, CatalogNodeType.Category); //IF THERE ARE IS NO PATH INFORMATION BEYOND THE ROOT NODE, RETURN THE BASE NODE FOUND BY PROVIDER if ((activeCatalogPath == null) || (activeCatalogPath.Count < 1)) { return(baseNode); } WebTrace.Write("ActivePathCount: " + activeCatalogPath.Count.ToString()); for (int i = 0; i < activeCatalogPath.Count; i++) { SiteMapNode newDynamicNode = new SiteMapNode(baseNode.Provider, activeCatalogPath[i].NodeId.ToString(), activeCatalogPath[i].Url, activeCatalogPath[i].Title, activeCatalogPath[i].Description); if (dynamicNodes.Count > 0) { newDynamicNode.ParentNode = dynamicNodes[dynamicNodes.Count - 1]; } dynamicNodes.Add(newDynamicNode); } dynamicNodes[0].ParentNode = pathNodes[catalogNodeIndex]; if (catalogNodeIndex == pathNodes.Count - 1) { //THERE ARE NO PATH NODES FOLLOWING CATALOG, RETURN LAST DYNAMIC NODE WebTrace.Write("return last dynamic node"); return(dynamicNodes[dynamicNodes.Count - 1]); } else { //THERE WERE PATH NODES FOLLOWING CATALOG, UPDATE PARENT TO LAST DYNAMIC NODE WebTrace.Write("append nodes following catalog"); //GET NODE THAT SHOULD BE LINKED FROM LAST DYNAMIC PATH NODE //CLONE THE NODE TO PREVENT CACHING, THEN SET PARENT TO DYNAMIC NODE SiteMapNode dynamicNextPathNode = pathNodes[catalogNodeIndex + 1].Clone(false); pathNodes[catalogNodeIndex + 1] = dynamicNextPathNode; dynamicNextPathNode.ReadOnly = false; dynamicNextPathNode.ParentNode = dynamicNodes[dynamicNodes.Count - 1]; //LOOP THROUGH REMAINING PATH NODES, CLONE THEM AND SET PARENT TO PREVIOUS DYNAMIC NODE for (int i = catalogNodeIndex + 2; i < pathNodes.Count; i++) { dynamicNextPathNode = pathNodes[i].Clone(false); pathNodes[i] = dynamicNextPathNode; dynamicNextPathNode.ReadOnly = false; dynamicNextPathNode.ParentNode = pathNodes[i - 1]; } //NOW RETURN LAST PATH NODE return(pathNodes[pathNodes.Count - 1]); } } } //THIS PATH TO THIS PAGE CANNOT BE DETERMINED return(null); }
private Dictionary <string, ProviderShipRateQuote> GetAllProviderShipRateQuotes(Warehouse origin, Address destination, BasketItemCollection contents) { //CHECK CACHE FOR QUOTES FOR THIS SHIPMEN string cacheKey = StringHelper.CalculateMD5Hash(Utility.Misc.GetClassId(this.GetType()) + "_" + origin.WarehouseId.ToString() + "_" + destination.AddressId.ToString() + "_" + contents.GenerateContentHash()); HttpContext context = HttpContext.Current; if (context != null) { WebTrace.Write("Checking Cache for " + cacheKey); if (context.Items.Contains(cacheKey)) { return((Dictionary <string, ProviderShipRateQuote>)context.Items[cacheKey]); } } //VERIFY WE HAVE A DESTINATION COUNTRY if (string.IsNullOrEmpty(destination.CountryCode)) { return(null); } //BUILD A LIST OF USPS PACKAGES FROM THE SHIPMENT ITEMS PackageList plist = PreparePackages(origin, contents); if (plist == null || plist.Count == 0) { return(null); } Package[] shipmentPackages = plist.ToArray(); //BUILD THE REQUEST FOR THIS SHIPMENT XmlDocument providerRequest; bool domestic = (destination.CountryCode == "US"); if (domestic) { if (string.IsNullOrEmpty(origin.PostalCode) || (origin.PostalCode.Length < 5)) { throw new ArgumentException("origin.PostalCode is empty or invalid length"); } if (string.IsNullOrEmpty(destination.PostalCode) || (destination.PostalCode.Length < 5)) { throw new ArgumentException("destination.PostalCode is empty or invalid length"); } providerRequest = BuildProviderRequest(shipmentPackages, origin.PostalCode.Substring(0, 5), destination.PostalCode.Substring(0, 5)); } else { string countryName = destination.Country.Name; if (destination.CountryCode.Equals("GB")) { countryName = "Great Britain"; } providerRequest = BuildProviderRequestIntl(shipmentPackages, countryName); } //SEND THIS REQUEST TO THE PROVIDER XmlDocument providerResponse = SendRequestToProvider(providerRequest, domestic ? "RateV3" : "IntlRate"); //PARSE THE THE RATE QUOTES FROM THE RESPONSE Dictionary <string, ProviderShipRateQuote> allServiceQuotes; if (domestic) { allServiceQuotes = ParseProviderRateReponse(providerResponse, shipmentPackages); } else { allServiceQuotes = ParseProviderRateReponseIntl(providerResponse, shipmentPackages); } //CACHE THE RATE QUOTES INTO REQUEST if (context != null) { context.Items[cacheKey] = allServiceQuotes; } return(allServiceQuotes); }
public override ShippingResult GetShippingResult(string ShipMethodName, Order ThisOrder, AnonymousAddress Address) { TraceContext trace = WebTrace.GetTraceContext(); ShippingResult RetVal = new ShippingResult(); RetVal.Shippable = false; CommerceBuilder.Orders.Basket basket = ThisOrder.AcBasket; if (basket == null) { basket = AcHelper.GetAcBasket(ThisOrder.ShoppingCart, true); if (basket != null) { basket.Package(false); } ThisOrder.AcBasket = basket; } if (basket == null || basket.Shipments.Count == 0) { return(RetVal); } ShipMethodCollection shipMethods = ThisOrder.AcShipMethods; if (shipMethods == null) { shipMethods = ShipMethodDataSource.LoadForStore(); ThisOrder.AcShipMethods = shipMethods; } if (shipMethods == null || shipMethods.Count == 0) { return(RetVal); } ShipMethod shipMethod; string methodName = ""; int shipMethodId = AcHelper.ExtractShipMethodId(ShipMethodName, out methodName); if (shipMethodId != 0) { shipMethod = AcHelper.FindShipMethod(shipMethods, shipMethodId); } else { shipMethod = AcHelper.FindShipMethod(shipMethods, methodName); } if (shipMethod == null) { return(RetVal); } CommerceBuilder.Users.Address acAddress = AcHelper.GetAnonAcAddress(basket.User, Address); if (!shipMethod.IsApplicableTo(acAddress)) { return(RetVal); } ShipRateQuote rateQuote; //TODO : should assign a default ship rate RetVal.ShippingRate = 0; bool isValid = true; foreach (Orders.BasketShipment bshipment in basket.Shipments) { bshipment.SetAddress(acAddress); if (!bshipment.IsShipMethodApplicable(shipMethod)) { isValid = false; break; } rateQuote = shipMethod.GetShipRateQuote(bshipment); if (rateQuote != null && rateQuote.TotalRate > 0) { RetVal.ShippingRate += rateQuote.TotalRate; } else if (rateQuote == null) { //this ship method is not applicable isValid = false; break; } } if (isValid) { RetVal.Shippable = true; } return(RetVal); }
public Dictionary <string, string> CheckDomainStatus() { Dictionary <string, string> result = new Dictionary <string, string>(); #region agilityWebVersion //**** agilityWebVersion try { result["agilityWebVersion"] = this.GetType().Assembly.GetName().Version.ToString(); } catch (Exception ex) { result["agilityWebVersion"] = "Error"; Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString()); } #endregion #region canWriteContentFiles //**** canWriteContentFiles try { if (!Directory.Exists(Current.Settings.ContentCacheFilePath)) { Directory.CreateDirectory(Current.Settings.ContentCacheFilePath); } string filepath = Path.Combine(Current.Settings.ContentCacheFilePath, "TestWebsiteConfiguration.tmp"); System.IO.File.WriteAllText(filepath, DateTime.Now.ToString()); result["canWriteContentFiles"] = true.ToString(); } catch (Exception ex) { result["canWriteContentFiles"] = false.ToString(); Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString()); } #endregion #region canDeleteContentFiles //**** canDeleteContentFiles try { string filepath = Path.Combine(Current.Settings.ContentCacheFilePath, "TestWebsiteConfiguration.tmp"); System.IO.File.WriteAllText(filepath, DateTime.Now.ToString()); System.IO.File.Delete(filepath); result["canDeleteContentFiles"] = true.ToString(); } catch (Exception ex) { result["canDeleteContentFiles"] = false.ToString(); Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString()); } #endregion #region dotNetVersion //**** dotNetVersion try { result["dotNetVersion"] = System.Environment.Version.ToString(); } catch (Exception ex) { result["dotNetVersion"] = "Error"; Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString()); } #endregion //**** contentServerURL result["contentServerUrl"] = Current.Settings.ContentServerUrl; #region canContactContentServer //**** canContactContentServer try { AgilityWebsiteAuthorization auth = BaseCache.GetAgilityWebsiteAuthorization(); try { if (AgilityContext.Domain != null) { auth.WebsiteDomain = AgilityContext.Domain.DomainName; } } catch { } using (AgilityContentServerClient client = BaseCache.GetAgilityServerClient()) { string url = client.TestConnectionAsync(auth).Result.TestConnectionResult; } result["canContactContentServer"] = true.ToString(); } catch (Exception ex) { result["canContactContentServer"] = false.ToString(); Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString()); } #endregion //**** smtpServer result["smtpServer"] = Current.Settings.SmtpServer; #region canWriteToLog //**** canWriteToLog try { if (AgilityContext.ContentAccessor != null) { result["canWriteToLog"] = true.ToString(); } else { string logFile = WebTrace.GetLogFilePath(); FileInfo fo = new FileInfo(logFile); if (string.IsNullOrEmpty(logFile) || (fo.Exists && fo.IsReadOnly)) { result["canWriteToLog"] = false.ToString(); } else { if (!Directory.Exists(Path.GetDirectoryName(logFile))) { Directory.CreateDirectory(Path.GetDirectoryName(logFile)); if (!Directory.Exists(Path.GetDirectoryName(logFile))) { throw new ApplicationException("The log directory does not exist."); } } string filepath = Path.Combine(Path.GetDirectoryName(logFile), "TestWebsiteConfiguration.tmp"); System.IO.File.WriteAllText(filepath, DateTime.Now.ToString()); result["canWriteToLog"] = true.ToString(); } } } catch (Exception ex) { result["canWriteToLog"] = false.ToString(); Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString()); } #endregion //**** logFilePath if (AgilityContext.ContentAccessor != null) { result["logFilePath"] = "Blob Storage"; } else { result["logFilePath"] = Current.Settings.Trace.LogFilePath; } //**** traceLevel result["traceLevel"] = string.Format("{0}", Current.Settings.Trace.TraceLevel); //**** siteUsername result["siteUsername"] = string.Format("{0}", Environment.UserName); // System.Threading.Thread..CurrentPrincipal.Identity.Name); //**** isDevelopmentMode result["isDevelopmentMode"] = string.Format("{0}", Current.Settings.DevelopmentMode); //**** osVersion result["osVersion"] = string.Format("{0}", Environment.OSVersion); return(result); }
protected virtual AgilitySiteMapNode GenerateAgilitySitemap() { // Since the SiteMap class is static, make sure that it is // not modified while the site map is built. AgilitySiteMapNode rootNode = null; WebTrace.WriteInfoLine( $"Building Sitemap: {AgilityContext.CurrentMode}, {AgilityContext.LanguageCode}, {AgilityContext.WebsiteName}, {AgilityContext.CurrentChannel.ReferenceName}"); // Start with a clean slate _tmpAddedNodes.Clear(); if (menuXml != null) { //THE ROOT NODE rootNode = new AgilitySiteMapNode(string.Empty, string.Empty, string.Empty) { ParentNode = null }; } else { return(null); } if (menuXml.DocumentElement == null) { return(null); } //get the xml element that represents this channel var channelElem = (menuXml.DocumentElement.SelectSingleNode( $"//ChannelNode[@channelID='{AgilityContext.CurrentChannel.ID}']") ?? menuXml.DocumentElement.SelectSingleNode("ChannelNode")) ?? menuXml.DocumentElement; var childNodes = channelElem.SelectNodes("SiteNode"); if (childNodes == null) { return(rootNode); } foreach (XmlElement elem in childNodes) { var childNode = ConvertXmlElementToSiteMapNode(elem, null); if (childNode == null) { continue; } //if the child node wasn't excluded via timed release var agilitySiteMapNodes = AddNode(childNode, rootNode); foreach (var agilitySiteMapNode in agilitySiteMapNodes) { //add it's children AddChildNodes(agilitySiteMapNode, elem); } } return(rootNode); }
internal static string GetStatusPanelScript() { //Add the Style Sheets for the StatusBar and Edit In Place: StringBuilder sb = new StringBuilder(); //HACK bool isPublished = false; bool containsUnpublishedModules = false; string pageTemplatePath = string.Empty; int pageTemplateID = -1; int pageID = -1; if (AgilityContext.Page != null) { AgilityPage page = AgilityContext.Page; pageID = page.ID; if (page.IsPublished) { isPublished = true; } if (!string.IsNullOrEmpty(page.TemplatePath) && page.TemplateID > 0) { pageTemplatePath = page.TemplatePath; if (pageTemplatePath.StartsWith("~/")) { pageTemplatePath = pageTemplatePath.Substring(1); string appPath = "/"; if (appPath != "/") { pageTemplatePath = string.Format("{0}{1}{2}", appPath, "/TemplatePreview", pageTemplatePath); } else { pageTemplatePath = string.Format("{0}{1}", "/TemplatePreview", pageTemplatePath); } } pageTemplateID = page.TemplateID; } bool switchMode = false; if (AgilityContext.CurrentMode == Agility.Web.Enum.Mode.Live) { //if the site is in live mode, switch to staging to check if any modules are required publishing. switchMode = true; AgilityContext.CurrentMode = Agility.Web.Enum.Mode.Staging; } //check if there are any modules that have not yet been publish foreach (ContentSection sect in AgilityContext.Page.ContentSections) { if (sect.ModuleID > 0) { AgilityContentServer.AgilityModule module = BaseCache.GetModule(sect.ModuleID, AgilityContext.WebsiteName); if (module != null && !module.IsPublished && module.IsPublishedSpecified) { containsUnpublishedModules = true; } } } if (switchMode) { AgilityContext.CurrentMode = Agility.Web.Enum.Mode.Live; } } //generate the preview key string securityKey = Current.Settings.SecurityKey; byte[] data = UnicodeEncoding.Unicode.GetBytes(string.Format("{0}_{1}_Preview", -1, securityKey)); SHA512 shaM = new SHA512Managed(); byte[] result = shaM.ComputeHash(data); string previewKey = Convert.ToBase64String(result); string appendQuery = string.Format("agilitypreviewkey={0}&agilityts={1}&lang={2}", HttpUtility.UrlEncode(previewKey), DateTime.Now.ToString("yyyyMMddhhmmss"), HttpUtility.UrlEncode(AgilityContext.LanguageCode)); string pageUrl = AgilityContext.UrlForPreviewBar; if (string.IsNullOrEmpty(pageUrl)) { pageUrl = AgilityContext.HttpContext.Request.GetEncodedUrl(); } string innerUrl = Agility.Web.Util.Url.ModifyQueryString( HttpUtility.UrlPathEncode(pageUrl), appendQuery, "ispreview"); string subject = string.Format("Agility {0} Preview", AgilityContext.WebsiteName); string body = string.Format("Click the link below to preview the {0} site:\n{1}\n____________________\nSent from Agility\nhttp://www.agilitycms.com", AgilityContext.WebsiteName, innerUrl); string previewURL = string.Format("mailto:?subject={0}&body={1}", HttpUtility.UrlEncode(subject).Replace("+", "%20"), HttpUtility.UrlEncode(body).Replace("+", "%20")); //channel listing string[] channels = (from c in BaseCache.GetDigitalChannels(AgilityContext.WebsiteName).Channels select string.Format("{{Name:\"{0}\",ID:'{1}'}}", c.DisplayName.Replace("\"", "\\\""), c.ReferenceName)).ToArray(); string uniqueID = Guid.NewGuid().ToString(); string previewDateStr = AgilityContext.PreviewDateTime.ToString("yyyy-M-d h:mm tt", CultureInfo.InvariantCulture); if (AgilityContext.PreviewDateTime == DateTime.MinValue) { previewDateStr = string.Empty; } //output the script for the onload sb.Append("<script type='text/javascript'>"); //output the context object sb.AppendFormat(@"var agilityContextObj = {{ currentMode:""{0}"", isPreview:{1}, isTemplatePreview:{2}, languageCode:""{3}"", websiteName:""{4}"", isDevelopmentMode:{5}, controlUniqueID:""{6}"", previewDateTime:""{7}"", isPublished:{8}, containsUnpublishedModules:{9}, pageTemplatePath:""{10}"", pageTemplateID:{11}, previewURL:""{12}"", cookieDomain:""{13}"", pageID:""{14}"", errorLink:{15}, channel:'{16}', channels:[{17}] }}; " , new object[] { AgilityContext.CurrentMode, //0 AgilityContext.IsPreview.ToString().ToLowerInvariant(), //1 AgilityContext.IsTemplatePreview.ToString().ToLowerInvariant(), //2 AgilityContext.LanguageCode, //3 AgilityContext.WebsiteName.Replace("\"", "\\\"").Replace(" ", ""), //4 Current.Settings.DevelopmentMode.ToString().ToLowerInvariant(), //5 uniqueID, //6 previewDateStr, //7 isPublished.ToString().ToLowerInvariant(), //8 containsUnpublishedModules.ToString().ToLowerInvariant(), //9 pageTemplatePath.Replace("\"", "\\\""), //10 pageTemplateID, //11 previewURL.Replace("\"", "\\\""), //12 Current.Settings.CookieDomain, //13 pageID, Current.Settings.DevelopmentMode && WebTrace.HasErrorOccurred ? string.Format("'{0}?enc={1}'", Agility.Web.HttpModules.AgilityHttpModule.ECMS_ERRORS_KEY, HttpUtility.UrlEncode(WebTrace.GetEncryptionQueryStringForLogFile(DateTime.Now))) : "null", AgilityContext.CurrentChannel.ReferenceName, string.Join(",", channels) }); sb.Append(Environment.NewLine); sb.Append("var agilityLanguages = ["); foreach (Language lang in AgilityContext.Domain.Languages) { sb.AppendFormat("['{0}', '{1}'],", lang.LanguageName, lang.LanguageCode); } sb = sb.Remove(sb.Length - 1, 1); sb.Append("];"); sb.Append(Environment.NewLine); sb.Append("</script>"); sb.Append("<script type='text/javascript' src='https://media.agilitycms.com/preview-bar/2018-11/agility-preview-bar.es5.min.js'></script>"); return(sb.ToString()); }
/// <summary> /// Retrieves a site map node based on a search criterion. /// </summary> /// <param name="rawUrl">A URL that identifies the page for which to retrieve a SiteMapNode</param> /// <returns>A site map node based on a search criterion</returns> public override System.Web.SiteMapNode FindSiteMapNode(string rawUrl) { //FIRST CHECK WHETHER THIS PAGE IS SPECIFICALLY KEYED IN THE CONFIG FILE SiteMapNode baseNode = base.FindSiteMapNode(rawUrl); if (baseNode != null) { return(baseNode); } //PAGE NOT FOUND, CHECK WHETHER THIS URL MATCHES KNOWN CMS PAGES WebTrace.Write(this.GetType().ToString(), "FindSiteMapNode: " + rawUrl + ", Check For CategoryId"); Match urlMatch = Regex.Match(rawUrl, "(?<baseUrl>.*)\\?.*CategoryId=(?<categoryId>[^&]*)", (RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase)); if (urlMatch.Success) { //FIND BASE NODE WebTrace.Write(this.GetType().ToString(), "CategoryId Detected, Find Base Node"); baseNode = base.FindSiteMapNode(urlMatch.Groups[1].Value); if (baseNode != null) { WebTrace.Write(this.GetType().ToString(), "Base Node Found, Inject Catalog Path"); List <SiteMapNode> pathNodes = this.GetSiteMapPathNodes(baseNode); int catalogNodeIndex = this.GetCatalogNodeIndex(pathNodes); //IF CATALOG NODE IS NOT FOUND, RETURN THE BASE NODE FOUND BY PROVIDER if (catalogNodeIndex < 0) { return(baseNode); } WebTrace.Write(this.GetType().ToString(), "Catalog Node Obtained, Building Dynamic Path"); //APPEND CMS PATH TO THE List <SiteMapNode> dynamicNodes = new List <SiteMapNode>(); List <CmsPathNode> activeCatalogPath = CmsPath.GetCmsPath(0, AlwaysConvert.ToInt(urlMatch.Groups[2].Value), CatalogNodeType.Category); //IF THERE ARE IS NO PATH INFORMATION BEYOND THE ROOT NODE, RETURN THE BASE NODE FOUND BY PROVIDER if (activeCatalogPath.Count < 2) { return(baseNode); } for (int i = 1; i < activeCatalogPath.Count; i++) { SiteMapNode newDynamicNode = new SiteMapNode(baseNode.Provider, activeCatalogPath[i].NodeId.ToString(), activeCatalogPath[i].Url, activeCatalogPath[i].Title, activeCatalogPath[i].Description); if (dynamicNodes.Count > 0) { newDynamicNode.ParentNode = dynamicNodes[dynamicNodes.Count - 1]; } dynamicNodes.Add(newDynamicNode); } dynamicNodes[0].ParentNode = pathNodes[catalogNodeIndex]; if (catalogNodeIndex == pathNodes.Count - 1) { //THERE ARE NO PATH NODES FOLLOWING CATALOG, RETURN LAST DYNAMIC NODE return(dynamicNodes[dynamicNodes.Count - 1]); } else { //THERE WERE PATH NODES FOLLOWING CATALOG, UPDATE PARENT TO LAST DYNAMIC NODE SiteMapNode nextPathNode = pathNodes[catalogNodeIndex + 1]; nextPathNode.ReadOnly = false; nextPathNode.ParentNode = dynamicNodes[dynamicNodes.Count - 1]; //THEN RETURN LAST PATH NODE return(pathNodes[pathNodes.Count - 1]); } } } //THIS PATH TO THIS PAGE CANNOT BE DETERMINED return(null); }
public void Process() { TraceContext trace = WebTrace.GetTraceContext(); string traceKey = "GoogleCheckout.AC.NewOrderHandler"; trace.Write(traceKey, "Begin NewOrderHandler.Process, Google order number " + N1.googleordernumber); Order order = OrderDataSource.LoadForGoogleOrderNumber(N1.googleordernumber); if (order == null) // ordernumber not already entered { trace.Write(traceKey, "Google order not present in database, get basket"); Basket basket = AcHelper.GetAcBasket(N1.shoppingcart, true); if (basket == null) { trace.Write(traceKey, "Basket could not be obtained (End NewOrderHandler.Process)"); return; } //basket is ready. check if there are any order adjustments to be made trace.Write(traceKey, "Check for order adjustments"); OrderAdjustment orderAdj = N1.orderadjustment; if (orderAdj != null) { trace.Write(traceKey, "Order adjustments present, add to basket"); OrderAdjustmentHelper.DoOrderAdjustments(orderAdj, basket); } trace.Write(traceKey, "set billing address"); Users.Address primaryAddress = basket.User.PrimaryAddress; AcHelper.PopulateAcAddress(primaryAddress, N1.buyerbillingaddress); trace.Write(traceKey, "set shipping address"); Users.Address shipAddr = AcHelper.GetAcAddress(basket.User, N1.buyershippingaddress); basket.User.Addresses.Add(shipAddr); basket.User.Save(); trace.Write(traceKey, "package the basket"); basket.Package(false); if (basket.Shipments.Count > 0) { //there are shippable items / shipments //set shipment address and shipment method trace.Write(traceKey, "shippable items present, get shipping method"); ShipMethod shipMethod = AcHelper.GetShipMethod(basket); trace.Write(traceKey, "ship method is " + shipMethod.Name + " (ID" + shipMethod.ShipMethodId.ToString() + ")"); foreach (BasketShipment shipment in basket.Shipments) { shipment.AddressId = shipAddr.AddressId; shipment.ShipMethodId = shipMethod.ShipMethodId; shipment.Save(); } //have to link the shipping charges with some shipment. //we can't know which shipment. Just link to the first. trace.Write(traceKey, "assign shipping charges to first shipment"); BasketShipment basketShipment = basket.Shipments[0]; foreach (BasketItem item in basket.Items) { if (item.OrderItemType == OrderItemType.Shipping) { item.BasketShipmentId = basketShipment.BasketShipmentId; //update the sku and shipping method name so that scrubbed name is not used item.Name = shipMethod.Name; item.Sku = string.Empty; } } } trace.Write(traceKey, "save basket"); basket.Save(); //now checkout the order with null payment. //this will alow payment to be processed later trace.Write(traceKey, "submit basket checkout"); CheckoutRequest acCheckout = new CheckoutRequest(null); CheckoutResponse acResp = basket.Checkout(acCheckout); if (acResp.Success) { trace.Write(traceKey, "checkout was successful, update the google order number for AC order number " + acResp.OrderNumber.ToString()); order = OrderDataSource.Load(acResp.OrderId, false); if (order != null) { //update email address associated with order order.BillToEmail = N1.buyerbillingaddress.email; order.GoogleOrderNumber = N1.googleordernumber; bool isPaidByGc = false; //IF THERE IS ONE PAYMENT AND IT IS A GIFT CERTIFICATE //AND IT COVERS THE BALANCE OF THE ORDER THEN THIS IS THE GOOGLE PAYMENT if (order.Payments.Count == 1) { int gcPayMethodId = PaymentEngine.GetGiftCertificatePaymentMethod().PaymentMethodId; Payment payment = order.Payments[0]; if (payment.PaymentMethodId == gcPayMethodId) { if (payment.Amount == order.TotalCharges) { isPaidByGc = true; } } } if (!isPaidByGc) { //We need to create a new payment with status of authorization pending Payment payment = new Payment(); payment.PaymentMethodId = AcHelper.GetGCPaymentMethodId(this.GatewayInstance); payment.Amount = order.GetBalance(false); payment.OrderId = order.OrderId; payment.PaymentMethodName = "GoogleCheckout"; Transaction trans = new Transaction(); trans.TransactionType = TransactionType.Authorize; trans.TransactionStatus = TransactionStatus.Pending; trans.Amount = payment.Amount; trans.PaymentGatewayId = this.GatewayInstance.PaymentGatewayId; trans.ProviderTransactionId = N1.googleordernumber; trans.TransactionDate = N1.timestamp; payment.Transactions.Add(trans); payment.PaymentStatus = PaymentStatus.AuthorizationPending; order.Payments.Add(payment); } order.Save(); } else { OrderDataSource.UpdateGoogleOrderNumber(acResp.OrderId, N1.googleordernumber); } } else { trace.Write(traceKey, "checkout failed for google order"); CommerceBuilder.Utility.Logger.Warn("GoogleCheckout : New Order Checkout Failed."); } trace.Write(traceKey, "Send AC order number back to Google"); AcNotifier.AddMerchantOrderNumber(GatewayInstance, N1.googleordernumber, acResp.OrderNumber.ToString()); } else { //order number already entered. Just send notification trace.Write(traceKey, "Google order in database, send AC order number back to Google"); AcNotifier.AddMerchantOrderNumber(GatewayInstance, N1.googleordernumber, order.OrderNumber.ToString()); } trace.Write(traceKey, "End NewOrderHandler.Process"); }
public static void DoOrderAdjustments(OrderAdjustment orderAdj, Basket basket) { TraceContext trace = WebTrace.GetTraceContext(); string traceKey = "OrderAdjustmentHelper.DoOrderAdjustments"; if (orderAdj == null) { throw new ArgumentNullException("orderAdj", "OrderAdjustment can't be null"); } OrderAdjustmentMerchantcodes oamcs = orderAdj.merchantcodes; if (oamcs != null && oamcs.Items != null) { trace.Write(traceKey, "check merchant codes"); Object[] merchantCodes = oamcs.Items; CouponAdjustment coupAdj; GiftCertificateAdjustment giftCertAdj; //coupon and giftcertificate adjustment foreach (Object obj in merchantCodes) { if (obj == null) { continue; } if (obj is CouponAdjustment) { coupAdj = (CouponAdjustment)obj; trace.Write(traceKey, "Apply coupon: " + coupAdj.code + ", " + coupAdj.appliedamount); OrderAdjustmentHelper.AdjustCoupon(basket, coupAdj); } else if (obj is GiftCertificateAdjustment) { giftCertAdj = (GiftCertificateAdjustment)obj; trace.Write(traceKey, "Apply gift cert: " + giftCertAdj.code + " for " + giftCertAdj.appliedamount.Value); OrderAdjustmentHelper.AdjustGiftCertificate(basket, giftCertAdj); } } } OrderAdjustmentShipping oas = orderAdj.shipping; if (oas != null && oas.Item != null) { trace.Write(traceKey, "check shipping adjustments"); Object shipAdj = oas.Item; if (shipAdj is MerchantCalculatedShippingAdjustment) { MerchantCalculatedShippingAdjustment mcsa = (MerchantCalculatedShippingAdjustment)shipAdj; OrderAdjustmentHelper.AdjustMerchantCalculatedShipping(basket, mcsa); } else if (shipAdj is FlatRateShippingAdjustment) { FlatRateShippingAdjustment frsa = (FlatRateShippingAdjustment)shipAdj; OrderAdjustmentHelper.AdjustFlatRateShipping(basket, frsa); } else if (shipAdj is PickupShippingAdjustment) { PickupShippingAdjustment pusa = (PickupShippingAdjustment)shipAdj; OrderAdjustmentHelper.AdjustPickupShipping(basket, pusa); } } //tax adjustments if (orderAdj.totaltax != null && orderAdj.totaltax.Value > 0) { trace.Write(traceKey, "process tax adjustments"); OrderAdjustmentHelper.AdjustTax(basket, orderAdj.totaltax.Value); } }