public void PostOrderToDataPak(int orderId) { Order orderItem = new OrderManager().GetBatchProcessOrders(orderId); string req = new DataPakTax().GetRequest(orderItem); string res = CommonHelper.HttpPost(config.Attributes["taxTransactionUrl"].Value, req); Dictionary <string, AttributeValue> orderAttributes = new Dictionary <string, AttributeValue>(); orderAttributes.Add("TaxRequest", new CSBusiness.Attributes.AttributeValue(CSCore.Utils.CommonHelper.Encrypt(req))); orderAttributes.Add("TaxResponse", new CSBusiness.Attributes.AttributeValue(res)); XmlDocument doc = new XmlDocument(); doc.LoadXml(res); XmlNode xnResult = doc.SelectSingleNode("/DatapakServices/TaxService/Result/Code"); if (xnResult.InnerText.ToLower().Equals("001")) { //Get the tax XmlNode xnTaxAmount = doc.SelectSingleNode("/DatapakServices/TaxService/Result/CalculatedTax"); if (xnTaxAmount != null && xnResult.InnerText.Length > 0) { decimal taxAmount = 0; if (decimal.TryParse(xnTaxAmount.InnerText, out taxAmount)) { CSResolve.Resolve <IOrderService>().UpdateOrderTax(orderId, taxAmount); } } //} //else //{ // CSResolve.Resolve<IOrderService>().UpdateOrderAttributes(orderId, orderAttributes, null); // //sending email to admins // OrderHelper.SendEmailToAdmins(orderId); //} } CSResolve.Resolve <IOrderService>().UpdateOrderAttributes(orderId, orderAttributes, null); }
public void CalculateTax(int orderId) { Order orderItem = new OrderManager().GetBatchProcessOrders(orderId); //Only if state is taxed if (!IsTaxState(orderItem)) { return; } string req = new DataPakTax().GetRequest(orderItem); string res = CommonHelper.HttpPost(config.Attributes["taxTransactionUrl"].Value, req); Dictionary <string, AttributeValue> orderAttributes = new Dictionary <string, AttributeValue>(); orderAttributes.Add("TaxRequest", new CSBusiness.Attributes.AttributeValue(req)); orderAttributes.Add("TaxResponse", new CSBusiness.Attributes.AttributeValue(res)); XmlDocument doc = new XmlDocument(); doc.LoadXml(res); XmlNode xnResult = doc.SelectSingleNode("/DatapakServices/TaxService/Result/Code"); if (xnResult.InnerText.ToLower().Equals("001")) { //Get the tax XmlNode xnTaxAmount = doc.SelectSingleNode("/DatapakServices/TaxService/Result/CalculatedTax"); if (xnTaxAmount != null && xnResult.InnerText.Length > 0) { decimal taxAmount = 0; if (decimal.TryParse(xnTaxAmount.InnerText, out taxAmount)) { CSResolve.Resolve <IOrderService>().UpdateOrderTax(orderId, taxAmount); } } } CSResolve.Resolve <IOrderService>().UpdateOrderAttributes(orderId, orderAttributes, null); }