Пример #1
0
        public decimal GetShippingRate(ClientCartContext cart)
        {
            Decimal result = 0;
            string  req    = new ShipWire().GetShipRateRequest(cart); // Posting order to OMX
            string  res    = CommonHelper.HttpPost(config.Attributes["transactionUrl"].Value, req);
            Dictionary <string, AttributeValue> orderAttributes = new Dictionary <string, AttributeValue>();

            orderAttributes.Add("Request", new CSBusiness.Attributes.AttributeValue(req));
            orderAttributes.Add("Response", new CSBusiness.Attributes.AttributeValue(res));

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(res);
            XmlNode xnResult = doc.SelectSingleNode("/RateResponse/Status");

            if (xnResult.InnerText.ToLower().Equals("ok"))
            {
                XmlNode xnTrans = doc.SelectSingleNode("/RateResponse/Order/Quotes/Quote/Cost");
                result = Convert.ToDecimal(xnTrans.InnerText.ToLower());
                //orderAttributes.Add("ShipWireTransactionId", new CSBusiness.Attributes.AttributeValue(xnTrans.InnerText.ToLower()));
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Пример #2
0
        public bool PostOrder(int orderId)
        {
            bool   result = false;
            string req    = new ShipWire().GetRequest(orderId, false, false); // Posting order to OMX
            string res    = CommonHelper.HttpPost(config.Attributes["transactionUrl"].Value, req);
            Dictionary <string, AttributeValue> orderAttributes = new Dictionary <string, AttributeValue>();

            orderAttributes.Add("Request", new CSBusiness.Attributes.AttributeValue(req));
            orderAttributes.Add("Response", new CSBusiness.Attributes.AttributeValue(res));

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(res);
            XmlNode xnResult = doc.SelectSingleNode("/SubmitOrderResponse/Status");

            if (xnResult.InnerText.ToLower().Equals("0"))
            {
                result = true;
                XmlNode xnTrans = doc.SelectSingleNode("/SubmitOrderResponse/TransactionId");
                orderAttributes.Add("ShipWireTransactionId", new CSBusiness.Attributes.AttributeValue(xnTrans.InnerText.ToLower()));

                CSResolve.Resolve <IOrderService>().UpdateOrderAttributes(orderId, orderAttributes, 2);
            }
            else
            {
                CSResolve.Resolve <IOrderService>().UpdateOrderAttributes(orderId, orderAttributes, 8);
                //sending email to admins
                OrderHelper.SendEmailToAdmins(orderId);
            }
            return(result);
        }