Beispiel #1
0
        public static bool AuthorizeOrder(int orderID)
        {
            Request _request = new Request();

            Order orderData = CSResolve.Resolve <IOrderService>().GetOrderDetails(orderID, true);

            _request.CardNumber             = orderData.CreditInfo.CreditCardNumber;
            _request.CardType               = GetCCType(orderData.CreditInfo.CreditCardName);
            _request.CardCvv                = orderData.CreditInfo.CreditCardCSC;
            _request.CurrencyCode           = "$";
            _request.ExpireDate             = orderData.CreditInfo.CreditCardExpired;
            _request.Amount                 = (double)orderData.Total;
            _request.FirstName              = orderData.CustomerInfo.BillingAddress.FirstName;
            _request.LastName               = orderData.CustomerInfo.BillingAddress.LastName;
            _request.Address1               = orderData.CustomerInfo.BillingAddress.Address1;
            _request.Address2               = orderData.CustomerInfo.BillingAddress.Address2;
            _request.City                   = orderData.CustomerInfo.BillingAddress.City;
            _request.State                  = StateManager.GetStateName(orderData.CustomerInfo.BillingAddress.StateProvinceId);
            _request.Country                = CountryManager.CountryCode(orderData.CustomerInfo.BillingAddress.CountryId);
            _request.ZipCode                = orderData.CustomerInfo.BillingAddress.ZipPostalCode;
            _request.TransactionDescription = orderData.CustomerInfo.BillingAddress.FirstName + " " + orderData.CustomerInfo.BillingAddress.LastName;
            _request.CustomerID             = orderData.CustomerId.ToString();
            _request.InvoiceNumber          = orderData.OrderId.ToString();
            _request.IPAddress              = orderData.IpAddress;
            _request.Email                  = orderData.Email;

            //Make transaction request
            Response _response = TokenexProcessor.GetInstance().PerformAuthRequest(_request);

            //Save gateway transaction
            Dictionary <string, AttributeValue> orderAttributes = new Dictionary <string, AttributeValue>();

            orderAttributes.Add("AuthRequest", new CSBusiness.Attributes.AttributeValue(CSCore.Utils.CommonHelper.Encrypt(_response.GatewayRequestRaw)));
            orderAttributes.Add("AuthResponse", new CSBusiness.Attributes.AttributeValue(_response.GatewayResponseRaw));
            CSResolve.Resolve <IOrderService>().UpdateOrderAttributes(orderData.OrderId, orderAttributes, null);

            bool _returnValue = false;

            //Save results
            if (_response != null && _response.ResponseType != TransactionResponseType.Approved)
            {
                CSResolve.Resolve <IOrderService>().SaveOrder(orderData.OrderId,
                                                              (_response.TransactionID == null) ? string.Empty : _response.TransactionID,
                                                              (_response.AuthCode == null) ? string.Empty : _response.AuthCode, 7);

                _returnValue = false;
            }
            else if (_response != null && _response.ResponseType == TransactionResponseType.Approved)
            {
                CSResolve.Resolve <IOrderService>().SaveOrder(orderData.OrderId,
                                                              (_response.TransactionID == null) ? string.Empty : _response.TransactionID,
                                                              (_response.AuthCode == null) ? string.Empty : _response.AuthCode, 4);
                _returnValue = true;
            }
            UserSessions.InsertSessionEntry(null, _returnValue, (decimal)(_request.Amount), orderData.CustomerId, orderID);

            return(_returnValue);
        }
        public static bool AuthorizeOrder(int orderID)
        {
            Request _request = new Request();

            Order orderData = CSResolve.Resolve <IOrderService>().GetOrderDetails(orderID, true);

            _request.CardNumber             = orderData.CreditInfo.CreditCardNumber;
            _request.CardCvv                = orderData.CreditInfo.CreditCardCSC;
            _request.CurrencyCode           = "$";
            _request.ExpireDate             = orderData.CreditInfo.CreditCardExpired;
            _request.Amount                 = (double)orderData.Total;
            _request.FirstName              = orderData.CustomerInfo.BillingAddress.FirstName;
            _request.LastName               = orderData.CustomerInfo.BillingAddress.LastName;
            _request.Address1               = orderData.CustomerInfo.BillingAddress.Address1;
            _request.City                   = orderData.CustomerInfo.BillingAddress.City;
            _request.State                  = StateManager.GetStateName(orderData.CustomerInfo.BillingAddress.StateProvinceId);
            _request.Country                = CountryManager.CountryCode(orderData.CustomerInfo.BillingAddress.CountryId);
            _request.ZipCode                = orderData.CustomerInfo.BillingAddress.ZipPostalCode;
            _request.TransactionDescription = orderData.CustomerInfo.BillingAddress.FirstName + " " + orderData.CustomerInfo.BillingAddress.LastName;
            _request.CustomerID             = orderData.CustomerId.ToString();
            _request.InvoiceNumber          = orderData.OrderId.ToString();

            //Read information from web.config
            //Response _response =   GatewayProvider.Instance("PaymentProvider").PerformRequest(_request);

            //Read information from client DB setting
            Response _response = PaymentProviderRepository.Instance.Get().PerformRequest(_request);


            if (_response != null && _response.ResponseType != TransactionResponseType.Approved)
            {
                CSResolve.Resolve <IOrderService>().SaveOrder(orderData.OrderId, _response.TransactionID, _response.AuthCode, 7);

                return(false);
            }
            else if (_response != null && _response.ResponseType == TransactionResponseType.Approved)
            {
                CSResolve.Resolve <IOrderService>().SaveOrder(orderData.OrderId, _response.TransactionID, _response.AuthCode, 4);
                return(true);
            }

            return(true);
        }
Beispiel #3
0
        public string GetShipRateRequest(ClientCartContext cart)
        {
            String strXml = String.Empty;

            using (StringWriter str = new StringWriter())
            {
                using (XmlTextWriter xml = new XmlTextWriter(str))
                {
                    //root node

                    List <StateProvince> states = StateManager.GetAllStates(0);
                    xml.WriteStartDocument();
                    xml.WriteWhitespace("\n");
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    xml.WriteStartElement("RateRequest");
                    xml.WriteWhitespace("\n");

                    xml.WriteElementString("Username", "*****@*****.**");
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Password", "5922d4678819620d");
                    xml.WriteWhitespace("\n");
                    //xml.WriteElementString("Server", "Test");
                    //xml.WriteWhitespace("\n");
                    //xml.WriteElementString("Referer", "Test");
                    //xml.WriteWhitespace("\n");
                    xml.WriteStartElement("Order");
                    xml.WriteAttributeString("id", "TESTTSE" + cart.CustomerInfo.CustomerId);
                    xml.WriteWhitespace("\n");

                    xml.WriteElementString("Warehouse", "0");
                    xml.WriteWhitespace("\n");
                    xml.WriteStartElement("AddressInfo");
                    xml.WriteAttributeString("type", "ship");
                    xml.WriteWhitespace("\n");

                    xml.WriteElementString("Address1", cart.CustomerInfo.ShippingAddress.Address1);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Address2", cart.CustomerInfo.ShippingAddress.Address2);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("City", cart.CustomerInfo.ShippingAddress.City);
                    xml.WriteWhitespace("\n");
                    StateProvince itemShippingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(cart.CustomerInfo.ShippingAddress.StateProvinceId));
                    if (itemShippingStateProvince != null)
                    {
                        xml.WriteElementString("State", itemShippingStateProvince.Abbreviation.Trim());
                        xml.WriteWhitespace("\n");
                    }
                    else
                    {
                        xml.WriteElementString("State", string.Empty);
                        xml.WriteWhitespace("\n");
                    }

                    string country1 = CountryManager.CountryCode(cart.CustomerInfo.ShippingAddress.CountryId);

                    xml.WriteElementString("Country", country1.Trim());
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("ZIP", cart.CustomerInfo.ShippingAddress.ZipPostalCode);
                    xml.WriteWhitespace("\n");


                    xml.WriteEndElement();


                    xml.WriteStartElement("Item");
                    xml.WriteAttributeString("num", "0");
                    xml.WriteWhitespace("\n");

                    xml.WriteElementString("Code", "1000001");
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Quantity", "1");
                    xml.WriteWhitespace("\n");

                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");

                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");

                    xml.WriteEndElement();



                    strXml = str.ToString();
                }
            }
            return(strXml);
        }
        public static bool ValidationCheck(int orderID)
        {
            Request _request = new Request();

            Order orderData             = CSResolve.Resolve <IOrderService>().GetOrderDetails(orderID, true);
            List <StateProvince> states = StateManager.GetAllStates(0);

            _request.CardNumber   = orderData.CreditInfo.CreditCardNumber;
            _request.CardCvv      = orderData.CreditInfo.CreditCardCSC;
            _request.CurrencyCode = "$";
            _request.ExpireDate   = orderData.CreditInfo.CreditCardExpired;
            _request.Amount       = (double)orderData.Total;
            _request.FirstName    = orderData.CustomerInfo.BillingAddress.FirstName;
            _request.LastName     = orderData.CustomerInfo.BillingAddress.LastName;
            _request.Address1     = orderData.CustomerInfo.BillingAddress.Address1;
            _request.City         = orderData.CustomerInfo.BillingAddress.City;
            StateProvince itemStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderData.CustomerInfo.BillingAddress.StateProvinceId));

            if (itemStateProvince != null)
            {
                _request.State = itemStateProvince.Abbreviation.Trim();
            }

            _request.Country = CountryManager.CountryCode(orderData.CustomerInfo.BillingAddress.CountryId).Trim();
            _request.ZipCode = orderData.CustomerInfo.BillingAddress.ZipPostalCode;
            _request.TransactionDescription = orderData.CustomerInfo.BillingAddress.FirstName + " " + orderData.CustomerInfo.BillingAddress.LastName;
            _request.CustomerID             = orderData.CustomerId.ToString();
            _request.InvoiceNumber          = orderData.OrderId.ToString();

            _request.ShipToFirstName = orderData.CustomerInfo.ShippingAddress.FirstName;
            _request.ShipToLastName  = orderData.CustomerInfo.ShippingAddress.LastName;
            _request.ShipToAddress   = orderData.CustomerInfo.ShippingAddress.Address1;
            StateProvince itemStateProvince1 = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderData.CustomerInfo.ShippingAddress.StateProvinceId));

            if (itemStateProvince != null)
            {
                _request.ShipToState = itemStateProvince1.Abbreviation.Trim();
            }
            //_request.ShipToState = StateManager.GetStateName(orderData.CustomerInfo.ShippingAddress.StateProvinceId);
            _request.ShipToZipCode = orderData.CustomerInfo.ShippingAddress.ZipPostalCode;
            _request.ShipToCity    = orderData.CustomerInfo.ShippingAddress.City;
            _request.IPAddress     = orderData.IpAddress;
            _request.Phone         = orderData.CustomerInfo.BillingAddress.PhoneNumber;


            _request.ShipToCountry = CountryManager.CountryCode(orderData.CustomerInfo.ShippingAddress.CountryId).Trim();

            _request.Email = orderData.Email;


            Response _response = PaymentProviderRepository.Instance.Get().PerformValidationRequest(_request);


            if (_response != null && _response.ResponseType != TransactionResponseType.Approved)
            {
                CSResolve.Resolve <IOrderService>().SaveOrder(orderData.OrderId, _response.TransactionID, _response.AuthCode, 7);

                return(false);
            }
            else if (_response != null && _response.ResponseType == TransactionResponseType.Approved)
            {
                CSResolve.Resolve <IOrderService>().SaveOrder(orderData.OrderId, _response.TransactionID, _response.AuthCode, 4);
                return(true);
            }

            return(true);
        }
        public void SetGtmParameters()
        {
            try
            {
                if (CartContext != null)
                {
                    try
                    {
                        ltOrderId.Text   = CartContext.OrderId.ToString();
                        ltEmail.Text     = CartContext.CustomerInfo.Email;
                        ltFirstName.Text = CartContext.CustomerInfo.BillingAddress.FirstName;
                        ltLastName.Text  = CartContext.CustomerInfo.BillingAddress.LastName;
                    }
                    catch { }

                    ltSubTotal.Text = CartContext.CartInfo.SubTotal.ToString("n2");
                    ltShipping.Text = CartContext.CartInfo.ShippingCost.ToString("n2");
                    ltTotal.Text    = (CartContext.CartInfo.SubTotalFullPrice + CartContext.CartInfo.TaxFullPrice + CartContext.CartInfo.ShippingCost).ToString("n2");
                    if (Session["RegenerateUrl"] != null && Session["RegenerateUrl"] != "")
                    {
                        ltReturnUrl.Text = Session["RegenerateUrl"].ToString();
                    }
                    Session["wppoTotal"]   = (CartContext.CartInfo.SubTotalFullPrice + CartContext.CartInfo.TaxFullPrice + CartContext.CartInfo.ShippingCost).ToString("n2");
                    ltTax.Text             = CartContext.CartInfo.TaxCost.ToString("n2");
                    lttransactionDate.Text = DateTime.Now.ToShortDateString();
                    StringBuilder sbListrakPixel     = new StringBuilder();
                    StringBuilder sbListrakPixelCart = new StringBuilder();
                    StringBuilder sbFriendBuy        = new StringBuilder();
                    StringBuilder sbGTM = new StringBuilder();
                    StringBuilder sbGTMtransactionProducts = new StringBuilder();
                    StringBuilder sbGTO = new StringBuilder();
                    try
                    {
                        ///////////////////////////////////////////////////////////////////////////////////

                        sbGTO.AppendLine("<div id=\"gts-order\" style=\"display:none;\" translate=\"no\">");
                        sbGTO.AppendLine("<span id=\"gts-o-id\">" + CartContext.OrderId.ToString() + "</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-domain\">www.legtendzxl.com</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-email\">" + CartContext.CustomerInfo.Email + "</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-country\">" + CountryManager.CountryCode(CartContext.CustomerInfo.ShippingAddress.CountryId).Trim() + "</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-currency\">USD</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-total\">" + (CartContext.CartInfo.SubTotalFullPrice + CartContext.CartInfo.TaxFullPrice + CartContext.CartInfo.ShippingCost).ToString("n2") + "</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-discounts\">0</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-shipping-total\">" + CartContext.CartInfo.ShippingCost.ToString("n2") + "</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-tax-total\">" + CartContext.CartInfo.TaxFullPrice.ToString("n2") + "</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-est-ship-date\">" + DateTime.Today.AddDays(3).ToString("yyyy-MM-dd") + "</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-est-delivery-date\">" + DateTime.Today.AddDays(18).ToString("yyyy-MM-dd") + "</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-has-preorder\">N</span>");
                        sbGTO.AppendLine("<span id=\"gts-o-has-digital\">N</span>");
                        ///////////////////////////////////////////////////////////////////////////////////
                    }
                    catch { }
                    try
                    {
                        sbGTM.AppendLine("'products': [");
                        int productCount = 0;
                        foreach (Sku sku in CartContext.CartInfo.CartItems)
                        {
                            ///////////////////////////////////////////////////////////////////////////////////
                            sbGTO.AppendLine("<span class=\"gts-item\">");
                            sbGTO.AppendLine("<span class=\"gts-i-name\">" + sku.Title.Replace("'", "") + "</span>");
                            sbGTO.AppendLine("<span class=\"gts-i-price\">" + sku.FullPrice.ToString("n2") + "</span>");
                            sbGTO.AppendLine("<span class=\"gts-i-quantity\">" + sku.Quantity + "</span>");
                            sbGTO.AppendLine("<span class=\"gts-i-prodsearch-id\">101739885</span>");
                            sbGTO.AppendLine("<span class=\"gts-i-prodsearch-store-id\">112</span>");
                            sbGTO.AppendLine("<span class=\"gts-i-prodsearch-country\">US</span>");
                            sbGTO.AppendLine("<span class=\"gts-i-prodsearch-language\">en</span>");
                            sbGTO.AppendLine("</span>");
                            ///////////////////////////////////////////////////////////////////////////////////
                            sbGTM.AppendLine("{");
                            sbGTM.AppendLine("'name': '" + sku.Title.Replace("'", "") + "',");
                            sbGTM.AppendLine("'id': '" + sku.SkuCode + "',");
                            sbGTM.AppendLine("'price': '" + sku.FullPrice + "',");
                            sbGTM.AppendLine("'quantity': '" + sku.Quantity + "',");
                            productCount += 1;
                            if (productCount == CartContext.CartInfo.CartItems.Count)
                            {
                                sbGTM.AppendLine("}");
                            }
                            else
                            {
                                sbGTM.AppendLine("},");
                            }
                            sbListrakPixel.AppendLine("_ltk.Order.AddItem('" + sku.SkuCode + "', " + sku.Quantity + ", '" + Math.Round(sku.InitialPrice, 2) + "');");
                            sbListrakPixelCart.AppendLine("_ltk.SCA.AddItemWithLinks('" + sku.SkuCode + "', " + sku.Quantity + ", '" + Math.Round(sku.InitialPrice, 2) + "', '" + sku.Title + "', '" + sku.ImagePath + "', 'index.aspx');"); // one line per item
                            sbFriendBuy.AppendLine("{sku: '" + sku.SkuCode + "',price: '" + sku.FullPrice.ToString("n2") + "',quantity: '" + sku.Quantity + "'}");
                            // sbGTMtransactionProducts.AppendLine("{\"sku\": " + productCount + ",\"name\": \" " + sku.SkuCode + " \",\"price\": \"" + sku.FullPrice.ToString("n2") + "\",\"currency\": \"USD\",\"quantity\": " + sku.Quantity + "},");
                            sku.LoadAttributeValues();
                            var image_url = "";
                            if (sku.ContainsAttribute("bigproductimage1"))
                            {
                                if (sku.AttributeValues["bigproductimage1"] != null)
                                {
                                    image_url = sku.GetAttributeValue <string>("bigproductimage1", "");
                                }
                            }
                            else if (sku.ContainsAttribute("productimage"))
                            {
                                image_url = sku.GetAttributeValue <string>("productimage", "");
                            }
                            else
                            {
                                image_url = sku.ImagePath;
                            }
                            var skuRoutingName = "";
                            if (sku.ContainsAttribute("skuroutingname"))
                            {
                                if (sku.AttributeValues["skuroutingname"] != null)
                                {
                                    skuRoutingName = sku.GetAttributeValue <string>("skuroutingname", "");
                                }
                                else
                                {
                                    skuRoutingName = sku.ImagePath;
                                }
                            }
                            var product_url = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "/" + OrderHelper.GetVersionName() + "/" + skuRoutingName);

                            sbGTMtransactionProducts.AppendLine("{\"sku\": " + sku.SkuId + ",\"name\": \" " + sku.Title + " \",\"price\": \"" + sku.FullPrice.ToString("n2") + "\",\"currency\": \"USD\",\"quantity\": " + sku.Quantity + ",\"qty_price\": \" " + sku.Quantity * sku.FullPrice + "\",\"image_url\": \" " + image_url + "\",\"product_url\": \" " + product_url + "\"},");
                        }
                    }
                    catch { }
                    sbGTO.AppendLine("</div>");
                    sbGTM.AppendLine("]");
                    ltGTMSkuItem.Text             = sbGTM.ToString();
                    ltSkuItem.Text                = sbListrakPixel.ToString();
                    ltCartSkuItem.Text            = sbFriendBuy.ToString();
                    ltCustomOrderItem.Text        = sbGTO.ToString();
                    ltGTMtransactionProducts.Text = sbGTMtransactionProducts.ToString();
                }
            }
            catch { }

            try
            {
                if (Request.RawUrl.ToLower().Contains("receipt") || Request.RawUrl.ToLower().Contains("postsale"))
                {
                    pnlReceiptPage.Visible = true;
                    if (Session["FirstTime"] == null)
                    {
                        Session["FirstTime"]      = "true";
                        ltFirstTime.Text          = "true";
                        ltCustomOrderItem.Visible = true;
                    }
                    else
                    {
                        Session["FirstTime"]      = "false";
                        ltFirstTime.Text          = "false";
                        ltCustomOrderItem.Visible = false;
                    }
                }
                else
                {
                    Session["FirstTime"] = null;
                }
            }
            catch
            {
            }
        }
Beispiel #6
0
        public PostOrderBatchRequest GetRequest(Order orderItem)
        {
            String strXml = String.Empty;

            orderItem.LoadAttributeValues();

            string ShippingStateProvinceAbbreviation = "";
            string BillingStateProvinceAbbreviation  = "";
            List <StateProvince> states = StateManager.GetAllStates(0);
            StateProvince        itemShippingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.ShippingAddress.StateProvinceId));

            if (itemShippingStateProvince != null)
            {
                ShippingStateProvinceAbbreviation = itemShippingStateProvince.Abbreviation.Trim();
            }
            StateProvince itemBillingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.BillingAddress.StateProvinceId));

            if (itemBillingStateProvince != null)
            {
                BillingStateProvinceAbbreviation = itemBillingStateProvince.Abbreviation.Trim();
            }

            Sku ShippingSku = GetShippingSku(orderItem);
            //string ShipCodeService = GetShippingSku(orderItem).SkuCode;

            PostOrderBatchRequest PostOrderBatchRequest1 = new PostOrderBatchRequest();

            InnotracWS.WSAuthorization WSAuthorization1 = new InnotracWS.WSAuthorization();
            WSAuthorization1.Username = config.Attributes["Username"].Value;
            WSAuthorization1.Password = config.Attributes["Password"].Value;
            PostOrderBatchRequest1.WSAuthorization = WSAuthorization1;

            int TransmissionBatchID = 0; // GetTransmissionBatchID();

            PostOrderBatchRequestOrderBatch OrderBatch1 = new PostOrderBatchRequestOrderBatch();

            OrderBatch1.TransmissionBatchID = Convert.ToDouble(TransmissionBatchID);
            OrderBatch1.TransmissionSource  = config.Attributes["TransmissionSource"].Value;
            OrderBatch1.TransmissionDate    = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd H:mm:ss"));
            OrderBatch1.Telemarketer        = config.Attributes["Telemarketer"].Value;
            OrderBatch1.RerunCount          = Convert.ToInt32(config.Attributes["RerunCount"].Value);
            OrderBatch1.NumberOfOrders      = Convert.ToInt32(config.Attributes["NumberOfOrders"].Value);
            OrderBatch1.CustomerInfoOnly    = config.Attributes["CustomerInfoOnly"].Value;

            PostOrderBatchRequestOrderBatchCustomer Customer = new PostOrderBatchRequestOrderBatchCustomer();

            Customer.SerialID                = config.Attributes["SerialID"].Value;
            Customer.Project                 = Convert.ToInt32(config.Attributes["Project"].Value);
            Customer.CustomerNo              = Convert.ToInt32(config.Attributes["CustomerNo"].Value);
            Customer.CustomerNoSpecified     = true;
            Customer.ClientCustomer          = Convert.ToInt32(config.Attributes["ClientCustomer"].Value);
            Customer.ClientCustomerSpecified = true;
            Customer.FirstName               = orderItem.CustomerInfo.BillingAddress.FirstName;
            Customer.LastName                = orderItem.CustomerInfo.BillingAddress.LastName;
            Customer.Address1                = orderItem.CustomerInfo.BillingAddress.Address1;
            Customer.Address2                = orderItem.CustomerInfo.BillingAddress.Address2;
            Customer.City = orderItem.CustomerInfo.BillingAddress.City;

            Customer.State = BillingStateProvinceAbbreviation; //  orderItem.CustomerInfo.BillingAddress.StateProvinceName;
            Customer.Zip   = orderItem.CustomerInfo.BillingAddress.ZipPostalCode;
            if (orderItem.CustomerInfo.BillingAddress.CountryId == 46)
            {
                Customer.Country = "CN";
            }
            else
            {
                Customer.Country = CountryManager.CountryCode(orderItem.CustomerInfo.BillingAddress.CountryId).Trim();
            }
            Customer.DayPhoneSpecified = true;
            Customer.DayPhone          = Convert.ToDouble(OrderHelper.GetCleanPhoneNumber(orderItem.CustomerInfo.BillingAddress.PhoneNumber));

            PostOrderBatchRequestOrderBatchCustomerEmail CustomerEmail = new PostOrderBatchRequestOrderBatchCustomerEmail();

            CustomerEmail.EmailAddress = orderItem.Email;
            CustomerEmail.EmailFlag    = config.Attributes["EmailFlag"].Value;
            Customer.Email             = new PostOrderBatchRequestOrderBatchCustomerEmail[1];
            Customer.Email[0]          = CustomerEmail;

            Customer.CustomerMailFlag = config.Attributes["CustomerMailFlag"].Value;
            Customer.RentNameFlag     = config.Attributes["RentNameFlag"].Value;
            Customer.OrderEmailsFlag  = config.Attributes["OrderEmailsFlag"].Value;
            string MarketingEmailsFlag = "N";

            //if (orderItem.AttributeValues.ContainsAttribute("sendoffers") && orderItem.AttributeValues["sendoffers"].Value != null)
            //{
            //    if (orderItem.AttributeValues["sendoffers"].Value.Equals("1"))
            //    {
            //        MarketingEmailsFlag = "Y";
            //    }
            //    else
            //    {
            //        MarketingEmailsFlag = "N";
            //    }
            //}
            Customer.MarketingEmailsFlag = MarketingEmailsFlag.ToUpper();
            Customer.Language            = config.Attributes["Language"].Value;

            PostOrderBatchRequestOrderBatchCustomerOrder CustomerOrder = new PostOrderBatchRequestOrderBatchCustomerOrder();

            CustomerOrder.ServiceBeforeShip = config.Attributes["ServiceBeforeShip"].Value;
            CustomerOrder.OrderNo           = Convert.ToInt32(config.Attributes["OrderNo"].Value);
            CustomerOrder.OrderNoSpecified  = true;
            CustomerOrder.PurchaseOrder     = config.Attributes["OrderIdPrefix"].Value + orderItem.OrderId.ToString();
            CustomerOrder.Promotion         = config.Attributes["Promotion"].Value;


            string Media = config.Attributes["MediaCode"].Value;

            //if (orderItem.AttributeValues.ContainsAttribute("mediacode") && orderItem.AttributeValues["mediacode"].Value != null && !orderItem.AttributeValues["mediacode"].Value.Equals(""))
            //{
            //    Media = orderItem.AttributeValues["mediacode"].Value;
            //}
            CustomerOrder.Media = Media;
            //CustomerOrder.BackEndCode = config.Attributes["BackEndCode"].Value;
            CustomerOrder.BaseContinuityOrderFlag = GetContinuityFlag(orderItem);                               // config.Attributes["BaseContinuityOrderFlag"].Value;
            CustomerOrder.OrderCategory           = config.Attributes["OrderCategory"].Value;
            CustomerOrder.OrderDate = Convert.ToDateTime(orderItem.CreatedDate.ToString("yyyy-MM-dd H:mm:ss")); // .ToString("MM/dd/yy hh:mm:ss"));
            // These should instead have a T separating date from time, like this: <inoc:OrderDate>2014-05-13T19:24:02</inoc:OrderDate>
            CustomerOrder.OrderReferenceNo1         = config.Attributes["OrderIdPrefix"].Value + orderItem.OrderId.ToString();
            CustomerOrder.UserId                    = config.Attributes["UserId"].Value;
            CustomerOrder.ShipFeeService            = ShippingSku.SkuCode; // ShipFeeService; //  GetShipFeeService(orderItem);
            CustomerOrder.ShipCodeService           = ShippingSku.SkuCode; // ShipCodeService; // GetShipCodeService(orderItem);
            CustomerOrder.ResidentialCommercialFlag = config.Attributes["ResidentialCommercialFlag"].Value;
            CustomerOrder.PricingCalculationMethod  = config.Attributes["PricingCalculationMethod"].Value;
            CustomerOrder.ShippingCalculationMethod = config.Attributes["ShippingCalculationMethod"].Value;
            CustomerOrder.PaymentPlan               = GetPaymentPlan(orderItem);
            CustomerOrder.Language                  = config.Attributes["Language"].Value;

            PostOrderBatchRequestOrderBatchCustomerOrderOrderShipTo OrderOrderShipTo = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipTo();

            OrderOrderShipTo.ShipToFirstName = orderItem.CustomerInfo.ShippingAddress.FirstName;
            OrderOrderShipTo.ShipToLastName  = orderItem.CustomerInfo.ShippingAddress.LastName;
            OrderOrderShipTo.ShipToAddress1  = orderItem.CustomerInfo.ShippingAddress.Address1;
            OrderOrderShipTo.ShipToAddress2  = orderItem.CustomerInfo.ShippingAddress.Address2;
            OrderOrderShipTo.ShipToCity      = orderItem.CustomerInfo.ShippingAddress.City;
            OrderOrderShipTo.ShipToState     = ShippingStateProvinceAbbreviation; // orderItem.CustomerInfo.ShippingAddress.StateProvinceName;
            OrderOrderShipTo.ShipToZip       = orderItem.CustomerInfo.ShippingAddress.ZipPostalCode;
            if (orderItem.CustomerInfo.ShippingAddress.CountryId == 46)
            {
                OrderOrderShipTo.ShipToCountry = "CN";
            }
            else
            {
                OrderOrderShipTo.ShipToCountry = CountryManager.CountryCode(orderItem.CustomerInfo.ShippingAddress.CountryId).Trim();
            }
            OrderOrderShipTo.ShipFeeService  = ShippingSku.SkuCode; // GetShipFeeService(orderItem);
            OrderOrderShipTo.ShipCodeService = ShippingSku.SkuCode; // GetShipCodeService(orderItem);

            OrderOrderShipTo.OrderItems = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipToOrderItems[orderItem.SkuItems.Count];
            PostOrderBatchRequestOrderBatchCustomerOrderOrderShipToOrderItems OrderShipToOrderItems;
            int        LineNo       = 1;
            int        arrayCounter = 0;
            decimal    ItemPrice    = 0;
            SkuManager skuManager   = new SkuManager();
            List <Sku> SkuItems1    = new List <Sku>();

            foreach (Sku Item in orderItem.SkuItems)
            {
                // Add BASE SKU for Sending to Innotrac
                //if (skuManager.GetSkuByID(Item.SkuId).CategoryId == 1)
                //{
                SkuItems1.Add(Item);
                //}
            }
            // Add FREEGIFT at LAST for SEnding to Innotrac
            //foreach (Sku Item in orderItem.SkuItems)
            //{
            //    // FREEGIFT CategoryId 16
            //    if (skuManager.GetSkuByID(Item.SkuId).CategoryId == 16)
            //    {
            //        SkuItems1.Add(Item);
            //    }
            //}
            foreach (Sku Item in SkuItems1)
            {
                //if (skuManager.GetSkuByID(Item.SkuId).CategoryId == 1)
                //{
                //ItemPricing ItemPricing1 = ItemPricingBySkuID[Item.SkuId];
                OrderShipToOrderItems     = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipToOrderItems();
                OrderShipToOrderItems.SKU = Item.SkuCode;
                //if (orderItem.CustomerInfo.ShippingAddress.CountryId == 46)
                //{
                //    Item.LoadAttributeValues();
                //    if (Item.GetAttributeValue<string>("skucode_canada", string.Empty) != string.Empty)
                //    {
                //        OrderShipToOrderItems.SKU = Item.GetAttributeValue<string>("skucode_canada", string.Empty);
                //    }
                //}
                OrderShipToOrderItems.Quantity            = Item.Quantity;
                OrderShipToOrderItems.LineNumber          = LineNo;
                OrderShipToOrderItems.LineNumberSpecified = true;

                PostOrderBatchRequestOrderBatchCustomerOrderOrderShipToOrderItemsItemPricing OrderItemsItemPricing = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipToOrderItemsItemPricing();
                ItemPrice = 0;
                ItemPrice = Item.FullPrice * Item.Quantity;
                //Pass P for PricingCalculationMethod (M). you need to remove the ItemPricing section, since we will be calculating each of the prices for you, at the line level.
                //OrderItemsItemPricing.ExtendedPrice = Convert.ToDecimal(ItemPrice.ToString("N2"));
                //OrderItemsItemPricing.ExtendedPriceSpecified = true;
                //OrderItemsItemPricing.ExtendedShipFee =(decimal)0;//ItemPricing1.SKU_Shipping_Price.ToString("N2"));
                //OrderItemsItemPricing.ExtendedShipFeeSpecified = true;
                //OrderItemsItemPricing.ExtendedTax = GetSkuTaxCost(orderItem.CustomerInfo.ShippingAddress, Item);// ItemPricing1.SKU_Total_Tax.ToString("N2"));
                //OrderItemsItemPricing.ExtendedTaxSpecified = true;
                OrderShipToOrderItems.ItemPricing         = OrderItemsItemPricing;
                OrderOrderShipTo.OrderItems[arrayCounter] = OrderShipToOrderItems;
                LineNo++;
                arrayCounter++;
                // }
            }

            // IF order contains more than one unique SKU -AND- is trying to do an install payment, flag as 'Y'
            //string InstallPaymentPlanCode = config.Attributes["InstallPaymentPlanCode"].Value.ToUpper();
            //if (LineNo > 2 && CustomerOrder.PaymentPlan.ToUpper().Equals(InstallPaymentPlanCode))
            //{
            //    CustomerOrder.ServiceBeforeShip = "Y";
            //}
            //else
            //{
            CustomerOrder.ServiceBeforeShip = config.Attributes["ServiceBeforeShip"].Value;
            //}

            CustomerOrder.OrderShipTo    = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipTo[1];
            CustomerOrder.OrderShipTo[0] = OrderOrderShipTo;

            PostOrderBatchRequestOrderBatchCustomerOrderPayment           OrderPayment      = new PostOrderBatchRequestOrderBatchCustomerOrderPayment();
            PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCard PaymentCreditCard = new PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCard();

            PaymentCreditCard.SequenceNo       = Convert.ToInt32(config.Attributes["SequenceNo"].Value);
            PaymentCreditCard.CreditCardNumber = orderItem.CreditInfo.CreditCardNumber;
            PaymentCreditCard.ExpirationDate   = orderItem.CreditInfo.CreditCardExpired.ToString("MMyy");
            if ((orderItem.CustomerInfo.BillingAddress.Address1.Equals(orderItem.CustomerInfo.ShippingAddress.Address1)) && (orderItem.CustomerInfo.BillingAddress.City.Equals(orderItem.CustomerInfo.ShippingAddress.City)) &&
                (orderItem.CustomerInfo.BillingAddress.ZipPostalCode.Equals(orderItem.CustomerInfo.ShippingAddress.ZipPostalCode)))
            {
                PaymentCreditCard.CardHolderFlag = CardHolderFlag.S; // If Bill To Address = Ship To Address, then S - Otherwise M
            }
            else
            {
                PaymentCreditCard.CardHolderFlag = CardHolderFlag.M; // If Bill To Address = Ship To Address, then S - Otherwise M
            }
            PaymentCreditCard.CVV2Code = "";

            PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCardBillingAddress CreditCardBillingAddress = new PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCardBillingAddress();

            CreditCardBillingAddress.BillingFirstName = orderItem.CustomerInfo.BillingAddress.FirstName;
            CreditCardBillingAddress.BillingLastName  = orderItem.CustomerInfo.BillingAddress.LastName;
            CreditCardBillingAddress.BillingAddress1  = orderItem.CustomerInfo.BillingAddress.Address1;
            CreditCardBillingAddress.BillingAddress2  = orderItem.CustomerInfo.BillingAddress.Address2;
            CreditCardBillingAddress.BillingCity      = orderItem.CustomerInfo.BillingAddress.City;
            CreditCardBillingAddress.BillingState     = BillingStateProvinceAbbreviation; // orderItem.CustomerInfo.BillingAddress.StateProvinceName;
            CreditCardBillingAddress.BillingZip       = orderItem.CustomerInfo.BillingAddress.ZipPostalCode;
            if (orderItem.CustomerInfo.BillingAddress.CountryId == 46)
            {
                CreditCardBillingAddress.BillingCountry = "CN";
            }
            else
            {
                CreditCardBillingAddress.BillingCountry = orderItem.CustomerInfo.BillingAddress.CountryCode.Trim();
            }
            PaymentCreditCard.BillingAddress = CreditCardBillingAddress;
            OrderPayment.CreditCard          = new PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCard[1];
            OrderPayment.CreditCard[0]       = PaymentCreditCard;
            OrderPayment.CurrencyCode        = config.Attributes["CurrencyCode"].Value;
            CustomerOrder.Payment            = OrderPayment;

            PostOrderBatchRequestOrderBatchCustomerOrderOrderSourceTotals OrderOrderSourceTotals = new PostOrderBatchRequestOrderBatchCustomerOrderOrderSourceTotals();
            decimal SubTotalFullPrice_ContinuityProducts = 0;                                                                                                      // GetFullPriceSubTotal_ContinuitySKU(orderItem);

            OrderOrderSourceTotals.ProductTotal = Convert.ToDecimal(String.Format("{0:.00}", orderItem.FullPriceSubTotal - SubTotalFullPrice_ContinuityProducts)); // SubTotal)); // FullPriceSubTotal));
            if (orderItem.CustomerInfo.ShippingAddress.CountryId == 46)
            {
                // setup the tax as a flat 10% for Canadian orders
                // it would be best if you sent the 10 percent charge as S&H as that is the way we display it in our CRM and the customer pack slip.
                OrderOrderSourceTotals.TaxTotal     = Convert.ToDecimal(String.Format("{0:.00}", "0.00"));
                OrderOrderSourceTotals.ShipFeeTotal = orderItem.ShippingCost + orderItem.AdditionalShippingCharge + orderItem.FullPriceTax;
            }
            else
            {
                OrderOrderSourceTotals.TaxTotal     = Convert.ToDecimal(String.Format("{0:.00}", orderItem.FullPriceTax));
                OrderOrderSourceTotals.ShipFeeTotal = orderItem.ShippingCost + orderItem.AdditionalShippingCharge;  // ShippingSku.FullPrice + orderItem.AdditionalShippingCharge;// Convert.ToDecimal(String.Format("{0:.00}", orderItem.ShippingCost));
            }
            OrderOrderSourceTotals.GiftCertificateTotalSpecified = true;
            OrderOrderSourceTotals.GiftCertificateTotal          = 0;
            CustomerOrder.OrderSourceTotals = OrderOrderSourceTotals;
            CustomerOrder.ShipCompleteFlag  = "";
            Customer.Order                    = new PostOrderBatchRequestOrderBatchCustomerOrder[1];
            Customer.Order[0]                 = CustomerOrder;
            OrderBatch1.Customer              = new PostOrderBatchRequestOrderBatchCustomer[1];
            OrderBatch1.Customer[0]           = Customer;
            PostOrderBatchRequest1.OrderBatch = OrderBatch1;
            return(PostOrderBatchRequest1); // strXml;
        }