Beispiel #1
0
    /****************************************************************
     *
     * AddToCart()
     *
     ***************************************************************/
    protected void AddToCart(string sGUID, int nQty)
    {
        productGUID = new Guid(sGUID);
        try
        {
            product = ProductController.GetProductDeepByGUID(productGUID);
            //make sure we have a product
            TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");

            //set the page variables
            productID        = product.ProductID;
            productSku       = product.Sku;
            product.Quantity = nQty;

            OrderController.AddCallCenterItem(product);

            /********************
             * //* the following if stmt is to track orders from TheLoveDepot.com 2/10
             * string sID = "";
             * sID = HttpContext.Current.Request.Cookies["ID"].Value;
             * if (sID != null)
             * {
             *  Order currentOrder = OrderController.GetCurrentOrder();
             *  OrderController.AddNote(sID, currentOrder);
             * }
             **************/
        }
        catch (Exception ex)
        {
            LovRubLogger.LogException(ex);
            throw ex;
        }
    }
Beispiel #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int nChocQty   = 0;
            int nCherryQty = 0;

            if (txtChocQty.Text.Equals("0") && txtCherryQty.Text.Equals("0"))
            {
                return;
            }

            try
            {
                int.TryParse(txtChocQty.Text, out nChocQty);
                if (nChocQty > 0)
                {
                    Click(nChocQty, sChocolateBDGUID, sChocolateBDGUID);
                }

                int.TryParse(txtCherryQty.Text, out nCherryQty);
                if (nCherryQty > 0)
                {
                    Click(nCherryQty, sCherryBDGUID, sCherryBDGUID);
                }
            }
            catch (Exception ex)
            {
                LovRubLogger.LogException(ex);
                throw ex;
            }
        }
Beispiel #3
0
    public void Click(int nNewQty, string sFullPriceGUID, string sDiscountPriceGUID)
    {
        int nTotalPaidQty    = 0;
        int nMaleFullQty     = 0;
        int nFemaleFullQty   = 0;
        int nRL6FullQty      = 0;
        int nRLFreeQty       = 0;
        int nLipLovFullQty   = 0;
        int nSurvivalFullQty = 0;

        //********************************************************
        //*   Determine # of items in cart and their sku
        //*
        //*   Determine # of new items to be added
        //*
        //*   if cart > 2 items and none are DFDF
        //*      add DFDF
        //*******************************************************
        if (nNewQty <= 0)
        {
            return;
        }

        try
        {
            AddToCart(sFullPriceGUID, nNewQty);
            //AddKeyForOrderMotion();
            Response.Redirect("~/BasketLV3.aspx", false);
        }
        catch (Exception ex)
        {
            LovRubLogger.LogException(ex);
            throw ex;
        }
    }
Beispiel #4
0
        public string POST(string XmlPostData)
        {
            ASCIIEncoding encodedData = new ASCIIEncoding();

            byte[]         byteArray = encodedData.GetBytes(XmlPostData);
            HttpWebRequest wr        = (HttpWebRequest)WebRequest.Create(new Uri(Url));

            wr.Method        = "POST";
            wr.KeepAlive     = false;
            wr.UserAgent     = "dashCommerce";
            wr.ContentType   = "application/x-www-form-urlencoded";
            wr.ContentLength = XmlPostData.Length;
            Stream SendStream = wr.GetRequestStream();

            SendStream.Write(byteArray, 0, byteArray.Length);
            SendStream.Close();
            HttpWebResponse WebResp = (HttpWebResponse)wr.GetResponse();
            string          res     = "";

            try
            {
                using (StreamReader sr = new StreamReader(WebResp.GetResponseStream()))
                {
                    res = sr.ReadToEnd();
                }
                WebResp.Close();
                return(res);
            }
            catch (Exception ex)
            {
                LovRubLogger.LogException(ex); //KPL Added 04/10/08
                throw new Exception("Http Request has failed. Exception: " + ex.ToString());
            }
        }
    protected void btnWomen3_Click(object sender, EventArgs e)
    {
        string sProductGUID = "f6d3b994-d5ca-491f-b55a-f22fa8974b25";

        productGUID = new Guid(sProductGUID);
        try
        {
            product = ProductController.GetProductDeepByGUID(productGUID);
            //make sure we have a product
            TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");

            //set the page variables
            productID        = product.ProductID;
            productSku       = product.Sku;
            product.Quantity = 3;
            OrderController.AddItem(product);
            AddKeyForOrderMotion();
            //This behavior is by design
            //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
            Response.Redirect("additemresult.aspx", false);
            //Response.Redirect("order.aspx", false); KPL
        }
        catch (Exception ex)
        {
            LovRubLogger.LogException(ex); // 04/10/08 KPL added
            throw ex;
            //ExceptionPolicy.HandleException(ex, "Application Exception");
            //Response.Redirect(Page.ResolveUrl("~/ExceptionPage.aspx"), false);
        }
    }
Beispiel #6
0
    protected void btnMen3_Click(object sender, EventArgs e)
    {
        string sProductGUID = "a3ba18d1-b7d0-488c-9687-706873e0ee53";

        productGUID = new Guid(sProductGUID);
        try
        {
            product = ProductController.GetProductDeepByGUID(productGUID);
            //make sure we have a product
            TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");

            //set the page variables
            productID        = product.ProductID;
            productSku       = product.Sku;
            product.Quantity = 3;
            OrderController.AddItem(product);
            AddKeyForOrderMotion();
            //This behavior is by design
            //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
            Response.Redirect("additemresult.aspx", false);
            //Response.Redirect("order.aspx", false); KPL
        }
        catch (Exception ex)
        {
            LovRubLogger.LogException(ex); // 04/10/08 KPL added
            throw ex;
        }
    }
Beispiel #7
0
    void SetExpressOrder()
    {
        //use the API to get the SetCheckout response.
        //Then, redirect to PayPal
        int currencyDecimals = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits;
        //get the wrapper
        APIWrapper wrapper = GetPPWrapper();

        string sEmail = "";

        if (Profile.LastShippingAddress != null)
        {
            if (Profile.LastShippingAddress.Email != string.Empty)
            {
                sEmail = Profile.LastShippingAddress.Email;
            }
            else
            {
                sEmail = "*****@*****.**";
            }
        }

        //send them back here for all occassions
        string successURL = Utility.GetSiteRoot() + "/checkout.aspx";
        string failURL    = Utility.GetSiteRoot() + "/default.aspx";


        if (currentOrder.Items.Count > 0)
        {
            string ppToken = wrapper.SetExpressCheckout(sEmail, currentOrder.CalculateSubTotal(),
                                                        successURL, failURL, true, addShipping.SelectedAddress);
            if (ppToken.ToLower().Contains("error"))
            {
                //lblPPErr.Text="PayPal has returned an error message: "+ppToken;
            }
            else
            {
                string sUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppToken;

                if (!SiteConfig.PayPalAPIIsLive)
                {
                    sUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppToken;
                }

                try {
                    Response.Redirect(sUrl, false);
                }
                catch (Exception x)
                {
                    LovRubLogger.LogException(x); // 04/10/08 KPL added
                    ResultMessage1.ShowFail(x.Message);
                }
            }
        }
        else
        {
            Response.Redirect("CCBasket.aspx", false);
        }
    }
Beispiel #8
0
    protected void btnWomen2_Click(object sender, EventArgs e)
    {
        int nTotalQty          = 0;
        int nMaleFullQty       = 0;
        int nMaleDiscountQty   = 0;
        int nFemaleFullQty     = 0;
        int nFemaleDiscountQty = 0;

        /********************************************************
         *   Determine # of items in cart and their sku
         *
         *   if cart is empty
         *       add 1st item as full price
         *       add rest as discount
         *   if cart has a full price item already
         *       add rest of items as discount
         *******************************************************/
        try
        {
            // Calculate total, male, female qty
            DetermineBasketContents(out nMaleFullQty, out nMaleDiscountQty, out nFemaleFullQty, out nFemaleDiscountQty);

            nTotalQty = nMaleFullQty + nMaleDiscountQty + nFemaleFullQty + nFemaleDiscountQty;

            // If cart is empty, add 1st item as full price, rest as discounted.
            // in this case, user selected 2 male, so add 1st as full, 2nd as discount
            if (0 == nTotalQty)
            {
                //put first Male in using current ID (LRM1)
                AddToCart(sFemaleProductGUID, 1);

                //add next Male items to cart at Discounted Price (LRMCC1, LRWCC1)
                AddToCart(sFemaleDiscountGUID, 1);
            }

            // if cart has a full price item already, add rest of items as discount
            // in this case, user selected 2 male, so add both as discount
            if ((1 == nMaleFullQty) || (1 == nFemaleFullQty))
            {
                AddToCart(sFemaleDiscountGUID, 2);
            }

            AddKeyForOrderMotion();

            //Response.Redirect("CCBasket.aspx", false);
            Response.Redirect("BasketNew.aspx", false);
            //Response.Redirect("Basket.aspx", false);

            //Response.Redirect("additemresult.aspx", false);
        }
        catch (Exception ex)
        {
            LovRubLogger.LogException(ex);
            throw ex;
        }
    }
Beispiel #9
0
    string RunCharge()
    {
        string sOut = "";

        try {
            Transaction trans = OrderController.TransactOrder(currentOrder, TransactionType.CreditCardPayment);
            //the orderID is set during the TransactOrder process
            sOut = currentOrder.OrderGUID;
        }
        catch (Exception x)
        {
            LovRubLogger.LogException(x); // 04/10/08 KPL added
            ResultMessage1.ShowFail(x.Message);
        }

        return(sOut);
    }
Beispiel #10
0
    /****************************************************************
     *
     * AddToCart()
     *
     * *************************************************************/
    void AddToCart(string sGUID, int nQty)
    {
        //string sFemaleProductGUID = "f6d3b994-d5ca-491f-b55a-f22fa8974b25";
        productGUID = new Guid(sGUID);
        try
        {
            product = ProductController.GetProductDeepByGUID(productGUID);
            //make sure we have a product
            TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");

            //set the page variables
            productID        = product.ProductID;
            productSku       = product.Sku;
            product.Quantity = nQty;
            OrderController.AddCallCenterItem(product);

            //**********************************************************************************
            // Add keycode for OrderMotion
            // but only add one note, so check to see if the keycode note has already been added.
            //**********************************************************************************
            bool bIsCallCtrOrder = false;
            currentOrder = OrderController.GetCurrentOrder();
            OrderNoteCollection noteCollection = currentOrder.Notes;
            int nCount = noteCollection.Count;
            for (int nIndex = 0; nCount > nIndex; nIndex++)
            {
                OrderNote note = noteCollection[nIndex];
                //if (note.Equals("CALLCENTER"))
                if (true == note.Note.Equals("CALLCENTER"))
                {
                    bIsCallCtrOrder = true;
                    break;
                }
            }
            if (false == bIsCallCtrOrder)
            {
                OrderController.AddNote("CALLCENTER", currentOrder);
            }
        }
        catch (Exception ex)
        {
            LovRubLogger.LogException(ex);
            throw ex;
        }
    }
Beispiel #11
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int nNewQty = 0;

            if (txtQty.Text.Equals(""))
            {
                return;
            }
            try
            {
                int.TryParse(txtQty.Text, out nNewQty);

                Click(nNewQty, sFemaleProductGUID, sFemaleDiscountGUID);
            }
            catch (Exception ex)
            {
                LovRubLogger.LogException(ex);
                throw ex;
            }
        }
Beispiel #12
0
        public static bool SendEmail(Email mailer)
        {
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            using (System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage()) {
                bool bOut = false;
                if (!String.IsNullOrEmpty(mailer.ToList))
                {
                    string[] toList = mailer.ToList.Split(';');
                    foreach (string to in toList)
                    {
                        message.To.Add(new MailAddress(to));
                    }
                }
                if (!String.IsNullOrEmpty(mailer.CcList))
                {
                    string[] ccList = mailer.CcList.Split(';');
                    foreach (string cc in ccList)
                    {
                        message.CC.Add(new MailAddress(cc));
                    }
                }

                message.Subject    = mailer.Subject;
                message.IsBodyHtml = mailer.IsHTML;
                message.Body       = mailer.MessageBody;
                try {
                    client.Send(message);
                    //TODO: CMC - log this
                    bOut = true;
                }
                catch (System.Net.Mail.SmtpException x)
                {
                    LovRubLogger.LogException(x); // KPL added 04/10/08
                    throw x;
                    //TODO: CMC - Log Exception, Do we really want to throw this back up the stack?
                    //throw new Exception("Email not sent: " + x.Message + "; message details: " + message.ToString());
                    //log this
                }
                return(bOut);
            }
        }
Beispiel #13
0
    /****************************************************************
     *
     * AddToCart()
     *
     * *************************************************************/
    void AddToCart(string sGUID, int nQty)
    {
        productGUID = new Guid(sGUID);
        try
        {
            product = ProductController.GetProductDeepByGUID(productGUID);
            //make sure we have a product
            TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");

            //set the page variables
            productID        = product.ProductID;
            productSku       = product.Sku;
            product.Quantity = nQty;
            OrderController.AddCallCenterItem(product);
        }
        catch (Exception ex)
        {
            LovRubLogger.LogException(ex);
            throw ex;
        }
    }
Beispiel #14
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            /******
            * determine if hh, mm, or ff
            * determine qty
            * add them all to cart
            ******/
            int nHisHers, nGay, nLesbo = 0;

            try
            {
                nHisHers = ddlHisHer.SelectedIndex;
                nGay     = ddlGay.SelectedIndex;
                nLesbo   = ddlLesbo.SelectedIndex;

                if (nHisHers > 0)
                {
                    AddToCart(sHisHersValentineGUID, nHisHers);
                }

                if (nGay > 0)
                {
                    AddToCart(sGayValentineGUID, nGay);
                }

                if (nLesbo > 0)
                {
                    AddToCart(sLesboValentineGUID, nLesbo);
                }

                //AddKeyForOrderMotion();
                Response.Redirect("~/BasketLV3.aspx", false);
            }
            catch (Exception ex)
            {
                LovRubLogger.LogException(ex);
                throw ex;
            }
        }
Beispiel #15
0
    string RunExpressCheckout()
    {
        //InitOrder();

        //this is the PayPal response holder
        string orderID = "";

        string sToken = Utility.GetParameter("token");

        //run the Final Express Checkout
        try {
            Transaction trans = OrderController.TransactOrder(currentOrder, TransactionType.PayPalPayment);
            orderID = currentOrder.OrderGUID;
        }
        catch (Exception x)
        {
            LovRubLogger.LogException(x); // 04/10/08 KPL added
            ResultMessage1.ShowFail(x.Message);
        }

        return(orderID);
    }
Beispiel #16
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int nHisQty     = 0;
            int nHersQty    = 0;
            int nHisHersQty = 0;

            if (txtHisQty.Text.Equals("0") && txtHersQty.Text.Equals("0") && txtHisHersQty.Text.Equals("0"))
            {
                return;
            }

            try
            {
                int.TryParse(txtHisQty.Text, out nHisQty);
                if (nHisQty > 0)
                {
                    Click(nHisQty, sHisChocDelightGUID, sHisChocDelightGUID);
                }

                int.TryParse(txtHersQty.Text, out nHersQty);
                if (nHersQty > 0)
                {
                    Click(nHersQty, sHersChocDelightGUID, sHersChocDelightGUID);
                }

                int.TryParse(txtHisHersQty.Text, out nHisHersQty);
                if (nHisHersQty > 0)
                {
                    Click(nHisHersQty, sHisHersChocDelightGUID, sHisHersChocDelightGUID);
                }
            }
            catch (Exception ex)
            {
                LovRubLogger.LogException(ex);
                throw ex;
            }
        }
Beispiel #17
0
    protected void AddFreeItemToCart()
    {
        int nCartItems = OrderController.GetCartItemCount();

        bool bAddFreeItem = false;

        int nTotalQty          = 0;
        int nMaleFullQty       = 0;
        int nMaleDiscountQty   = 0;
        int nFemaleFullQty     = 0;
        int nFemaleDiscountQty = 0;
        int nRL6FullQty        = 0;
        int nRLG6DiscountQty   = 0;
        int nRLFreeQty         = 0;
        int nSeasonalQty       = 0;
        int nSurvivalFullQty   = 0;
        int nChocBDFullQty     = 0;
        int nCherBDFullQty     = 0;

        int nLipLovFullQty     = 0;
        int nLipLovDiscountQty = 0;
        int nFullQty           = 0;
        int nFreeItemsToAdd    = 0;


        if (true == OrderController.IsFreeItemInCart())
        {
            return;
        }

        // Calculate total, male, female, RubLov qty

        /****** commented out 11/24/09 removed discounts
         * OrderController.DetermineBasketContents(
         *                                      out nTotalQty,
         *                                      out nMaleFullQty,
         *                                      out nMaleDiscountQty,
         *                                      out nFemaleFullQty,
         *                                      out nFemaleDiscountQty,
         *                                      out nRL6FullQty,
         *                                      out nRLG6DiscountQty,
         *                                      out nRLFreeQty,
         *                                      out nSeasonalQty,
         *                                      out nLipLovFullQty,
         *                                      out nLipLovDiscountQty,
         *                                      out nSurvivalFullQty);
         ****** commented out 11/24/09 removed discounts ************/

        OrderController.DetermineBasketContents(
            out nTotalQty,
            out nMaleFullQty,
            out nFemaleFullQty,
            out nRL6FullQty,
            out nRLFreeQty,
            out nLipLovFullQty,
            out nSurvivalFullQty,
            out nChocBDFullQty,
            out nCherBDFullQty);
        // should be 1 freebie per order.
        if ((nTotalQty > 0) && (0 == nRLFreeQty))
        {
            nFreeItemsToAdd = 1;
        }

        if (nFreeItemsToAdd > 0)
        {
            try
            {
                string sFreeMassageGelGUID      = "f7ada596-0385-4314-8b13-bd949d3856f0";
                Guid   productGUID              = new Guid(sFreeMassageGelGUID);
                Commerce.Common.Product product = ProductController.GetProductDeepByGUID(productGUID);
                product.Quantity = nFreeItemsToAdd;
                OrderController.AddCallCenterItem(product);
            }
            catch (Exception ex)
            {
                LovRubLogger.LogException(ex);
                throw ex;
            }
        }
    }
Beispiel #18
0
    void SetExpressOrder()
    {
        //use the API to get the SetCheckout response.
        //Then, redirect to PayPal
        //get the wrapper
        APIWrapper wrapper = GetPPWrapper();

        string sEmail = "";

        if (Profile.LastShippingAddress != null)
        {
            if (Profile.LastShippingAddress.Email != string.Empty)
            {
                sEmail = Profile.LastShippingAddress.Email;
            }
            else
            {
                MembershipUserCollection membershipUserCollection = Membership.FindUsersByName(Request.Cookies["shopperID"].Value);
                if (membershipUserCollection.Count > 0)
                {
                    sEmail = membershipUserCollection[Request.Cookies["shopperID"].Value].Email;
                }
            }
        }

        //send them back here for all occassions
        string successURL = Utility.GetSiteRoot() + "/checkout.aspx";
        string failURL    = Utility.GetSiteRoot() + "/default.aspx";

        currentOrder = GetCurrentOrder();
        if (currentOrder.Items.Count > 0)
        {
            string ppToken = wrapper.SetExpressCheckout(sEmail, currentOrder.CalculateSubTotal(),
                                                        successURL, failURL, false, null);
            if (ppToken.ToLower().Contains("error"))
            {
                lblPPErr.Text = "PayPal has returned an error message: " + ppToken;
            }
            else
            {
                string sUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppToken;
                if (!SiteConfig.PayPalAPIIsLive)
                {
                    sUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppToken;
                }

                try {
                    Response.Redirect(sUrl, false);
                }
                catch (Exception x)
                {
                    LovRubLogger.LogException(x); // 04/10/08 KPL added
                    ResultMessage1.ShowFail(x.Message);
                }
            }
        }
        else
        {
            Response.Redirect("CCBasket.aspx", false);
        }
    }
Beispiel #19
0
        //************************************************************
        //
        // OrderMotion
        //
        //************************************************************
        public void OrderMotion(Commerce.Common.Order order, String strAuthCode, int nTransID)
        {
            int    nTotalQty = 0, nIndex = 0, nFreeBottles = 0, nFreeMale = 0, nFreeFemale = 0;
            int    nMaleQty = 0, nFemaleQty = 0;
            String strKeycode = "";

            // get OrderMotion keycode
            GetKeyCode(order, out strKeycode);

            /********************************************
            *  determine total quantity ordered. dont count the free bottles, if this is CCtr order.
            *  determine how many male
            *  determine how many female
            *  GetTotalBottlesOrdered( out nTotalQty, out nMaleQty, out nFemaleQty )
            *
            *  determine how many free bottles to send
            *  determine how many male or female bottles to send
            *  (if CCtr order, the free bottles are already in 'order' object. so set variables accordingly)
            *
            *  GetFreeBottleQty( int nTotalQty, out int nFreeBottles, out int nFreeMale, out int nFreeFemale )
            ********************************************/
            GetTotalBottlesOrdered(order, out nTotalQty, out nMaleQty, out nFemaleQty);

            GetFreeBottleQty(order,
                             nTotalQty,
                             nMaleQty,
                             nFemaleQty,
                             out nFreeBottles,
                             out nFreeMale,
                             out nFreeFemale);


            //*********************************
            // generate OrderDetails line items
            //*********************************
            // determine total # of line items
            int nLineItems = 0;

            if (nMaleQty > 0)
            {
                nLineItems++;
            }
            if (nFemaleQty > 0)
            {
                nLineItems++;
            }
            if (nFreeFemale > 0)
            {
                nLineItems++;
            }
            if (nFreeMale > 0)
            {
                nLineItems++;
            }
            // END determine total # of line items

            // Populate XML file
            String strPost = "";

            strPost = "<?xml version=\"1.0\"?>" +

                      "<UDOARequest version=\"2.00\">" +
                      "<UDIParameter>" +
                      "<Parameter key=\"HTTPBizID\">" +
                      "jRfJIJtOgVGWQpJNyPVJhqvwNndjkjkTNuVXUhlScTEueBSeLvaFgjVVgSjQuuBQuPHhgKBYcQTnmEMhfFhwkaJAmExnCdhrvrVolebsqlQqtxmMhPfiDXMFieRpojHVYOgjNHUwgPUpeltQwAUdGQZwdgwLqNkFbxuhneNuiVuhIggLFpEybMjqfLRfoKQQiiAyENJDdbXiaKeOHPJXFNADyQnBVcfOYgMOjvAfXYNKYqjhKrDhRVIrmQnCLil" +
                      "</Parameter>" +
                      "<Parameter key=\"Keycode\">" + strKeycode + "</Parameter>" +
                      "<Parameter key=\"VerifyFlag\">False</Parameter>" +
                      "<Parameter key=\"QueueFlag\">True</Parameter>" +
                      "</UDIParameter>" +
                      "<Header>" +
                      // OrderDate should be in form "CCYY-MM-DD hh:mm"
                      // It isn't necessary so to start I'll leave it out.
                      //"<OrderDate>2003-04-01 22:15:10</OrderDate>" +
                      "<OriginType>3</OriginType>" +
                      "<OrderID>" + order.OrderNumber + "</OrderID>" +
                      "<StoreCode/>" +
                      "</Header>" +

                      "<Customer>" +
                      "<Address type=\"BillTo\">" +
                      "<TitleCode>0</TitleCode>" +
                      "<Company/>" +
                      "<Firstname>" + order.BillingAddress.FirstName + "</Firstname>" +
                      "<Lastname>" + order.BillingAddress.LastName + "</Lastname>" +
                      "<Address1>" + order.BillingAddress.Address1 + "</Address1>" +
                      "<Address2>" + order.BillingAddress.Address2 + "</Address2>" +
                      "<City>" + order.BillingAddress.City + "</City>" +
                      "<State>" + order.BillingAddress.StateOrRegion + "</State>" +
                      "<ZIP>" + order.BillingAddress.Zip + "</ZIP>" +
                      "<TLD>" + order.BillingAddress.Country + "</TLD>" +
                      "<PhoneNumber/>" +
                      "<Email>" + order.BillingAddress.Email + "</Email>" +
                      "</Address>" +
                      "<FlagData>" +
                      "<Flag name=\"DoNotMail\">True</Flag>" +
                      "<Flag name=\"DoNotCall\">True</Flag>" +
                      "<Flag name=\"DoNotEmail\">True</Flag>" +
                      "</FlagData>" +
                      "</Customer>" +

                      "<ShippingInformation>" +
                      "<Address type=\"ShipTo\">" +
                      "<TitleCode>0</TitleCode>" +
                      "<Firstname>" + order.ShippingAddress.FirstName + "</Firstname>" +
                      "<Lastname>" + order.ShippingAddress.LastName + "</Lastname>" +
                      "<Address1>" + order.ShippingAddress.Address1 + "</Address1>" +
                      "<Address2>" + order.ShippingAddress.Address2 + "</Address2>" +
                      "<City>" + order.ShippingAddress.City + "</City>" +
                      "<State>" + order.ShippingAddress.StateOrRegion + "</State>" +
                      "<ZIP>" + order.ShippingAddress.Zip + "</ZIP>" +
                      "<TLD>" + order.ShippingAddress.Country + "</TLD>" +
                      "</Address>" +
                      //"<MethodName> + "1st Class US Mail" + "</MethodName>" +
                      "<MethodCode>2</MethodCode>" +
                      "<ShippingAmount>" + order.ShippingAmount + "</ShippingAmount>" +
                      "<HandlingAmount>0.0</HandlingAmount>" +
                      "<SpecialInstructions>" + order.SpecialInstructions + "</SpecialInstructions>" +
                      "</ShippingInformation>" +

                      "<Payment type=\"1\">" +
                      "<CardNumber>" + order.CreditCardNumber + "</CardNumber>" +
                      "<CardVerification>" + order.CreditCardSecurityNumber + "</CardVerification>" +
                      "<CardExpDateMonth>" + order.CreditCardExpireMonth + "</CardExpDateMonth>" +
                      "<CardExpDateYear>" + order.CreditCardExpireYear + "</CardExpDateYear>" +
                      // CardStatus 11 means 'already authorized'.
                      "<CardStatus>11</CardStatus>" +
                      "<CardAuthCode>" + strAuthCode + "</CardAuthCode>" +
                      //"<CardTransactionID>" + strTransID + "</CardTransactionID>" +
                      "</Payment>";

            //**********************
            // Orderdetail goes here
            //**********************
            String strOrderDetail = "<OrderDetail>";

            nIndex = 1;
            if (nMaleQty > 0)
            {
                strOrderDetail += "<LineItem lineNumber=\"" + nIndex + "\">" +
                                  "<ItemCode>" + strMaleItemCode + "</ItemCode>" +
                                  "<Quantity>" + nMaleQty + "</Quantity>" +
                                  "<UnitPrice>" + dMaleUnitPrice + "</UnitPrice>" +
                                  "</LineItem>";
                nIndex++;
            }

            // Generate free Male line items
            if (nFreeMale > 0)
            {
                strOrderDetail += "<LineItem lineNumber=\"" + nIndex + "\">" +
                                  "<ItemCode>" + strMaleItemCode + "</ItemCode>" +
                                  "<Quantity>" + nFreeMale + "</Quantity>" +
                                  "<UnitPrice>0.0</UnitPrice>" +
                                  "</LineItem>";

                nIndex++;
            }

            // generate Female line items
            if (nFemaleQty > 0)
            {
                strOrderDetail += "<LineItem lineNumber=\"" + nIndex + "\">" +
                                  "<ItemCode>" + strFemaleItemCode + "</ItemCode>" +
                                  "<Quantity>" + nFemaleQty + "</Quantity>" +
                                  "<UnitPrice>" + dFemaleUnitPrice + "</UnitPrice>" +
                                  "</LineItem>";

                nIndex++;
            }

            // generate free Female line items
            if (nFreeFemale > 0)
            {
                strOrderDetail += "<LineItem lineNumber=\"" + nIndex + "\">" +
                                  "<ItemCode>" + strFemaleItemCode + "</ItemCode>" +
                                  "<Quantity>" + nFreeFemale + "</Quantity>" +
                                  "<UnitPrice>0.0</UnitPrice>" +
                                  "</LineItem>";
            }

            strOrderDetail += "</OrderDetail>";

            strOrderDetail += "<Check><TotalAmount>" + order.OrderTotal + "</TotalAmount></Check>";

            strPost += strOrderDetail + "</UDOARequest>";

            //********************************************
            // Post to OrderMotion
            //********************************************
            StreamWriter   myWriter       = null;
            String         strOMServerURL = "https://members.ordermotion.com/hdde/xml/udi.asp";
            HttpWebRequest objRequest     = (HttpWebRequest)WebRequest.Create(strOMServerURL);

            objRequest.Method        = "POST";
            objRequest.ContentLength = strPost.Length;
            objRequest.ContentType   = "text/xml";

            try
            {
                myWriter = new StreamWriter(objRequest.GetRequestStream());
                myWriter.Write(strPost);
            }
            catch (Exception e)
            {
                LovRubLogger.LogException(e);             // KPL 04/05/08
                throw e;
            }
            finally
            {
                myWriter.Close();
            }

            Commerce.Common.Transaction trans       = new Commerce.Common.Transaction();
            HttpWebResponse             objResponse = (HttpWebResponse)objRequest.GetResponse();

            try
            {
                XmlReader reader = XmlReader.Create((Stream)objResponse.GetResponseStream());
                reader.MoveToContent();
                while (reader.Read())
                {
                    if (XmlNodeType.Element == reader.NodeType)
                    {
                        if (reader.Name.Equals("Success"))
                        {
                            reader.Read();
                            if (false == reader.Value.Equals("1"))
                            {               // failure;
                                throw new Exception("OM Failure:<Success>= " + reader.Value);
                            }
                        }
                        if (reader.Name.Equals("ErrorData"))
                        {
                            reader.Read();
                            if (false == reader.Value.Equals("\n"))
                            {               // failure;
                                throw new Exception("OM Failure:<ErrorData>= " + reader.Value);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LovRubLogger.LogException(e);             // KPL 04/05/08
                throw e;
            }
        }
Beispiel #20
0
        public override Commerce.Common.Transaction Charge(Commerce.Common.Order order)
        {
            //string sOut = "";

            decimal dTotal  = order.OrderTotal;
            int     roundTo = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits;

            dTotal = Math.Round(dTotal, roundTo);

            //make sure that the ExpMonth has a leading 0
            string sExpMonth = order.CreditCardExpireMonth.ToString();

            if (order.CreditCardExpireMonth < 10)
            {
                sExpMonth = "0" + sExpMonth;
            }

            bool useTestServer = serverURL.IndexOf("test") >= 0;

            String strPost = "x_login="******"&x_tran_key=" + transactionKey +
                             "&x_method=CC" +
                                                   //"&x_type=AUTH_CAPTURE" +  KPL commented out 12/30/07
                             "&x_type=AUTH_ONLY" + // KPL Added 12/30/07
                             "&x_amount=" + dTotal.ToString() +
                             "&x_delim_data=TRUE" +
                             "&x_delim_char=|" +
                             "&x_relay_response=FALSE" +
                             "&x_card_num=" + order.CreditCardNumber +
                             "&x_exp_date=" + sExpMonth + order.CreditCardExpireYear.ToString() +
                             "&x_version=3.1" +
                             //the following is optional however it's good to have for records
                             "&x_first_name=" + order.BillingAddress.FirstName +
                             "&x_last_name=" + order.BillingAddress.LastName +
                             "&x_address=" + order.BillingAddress.Address1 +
                             "&x_city=" + order.BillingAddress.City +
                             "&x_state=" + order.BillingAddress.StateOrRegion +
                             "&x_zip=" + order.BillingAddress.Zip +
                             "&x_currency_code=" + currencyCode +
                             "&x_country=" + order.BillingAddress.Country +
                             "&x_card_code=" + order.CreditCardSecurityNumber;

            //you can set this up to send you an email if you like
            //by adding this:
            //&[email protected]

            //you can also have them send you customer an email
            //&[email protected]&x_email_customer=TRUE

            if (useTestServer)
            {
                strPost += "&x_test_request=TRUE";
            }

            //*******************************************************
            // Post to AUTHORIZE.NET and get response.
            //*******************************************************
            Commerce.Common.Transaction trans = new Commerce.Common.Transaction();
            WebClient wc = new WebClient();

            try
            {
                byte[]   response = wc.UploadData(serverURL, System.Text.ASCIIEncoding.UTF8.GetBytes(strPost));
                String   result   = System.Text.ASCIIEncoding.UTF8.GetString(response);
                string[] lines    = result.Split('|');

                //the response flag is the first item
                //1=success, 2=declined, 3=error
                string sFlag = lines[0];

                if (sFlag == "1")
                {
                    trans.GatewayResponse   = lines[37];
                    trans.AuthorizationCode = lines[4];

                    //return the transactionID
                    trans.GatewayResponse = result;
                }
                else if (sFlag == "2")
                {
                    trans.GatewayResponse = lines[3];
                    throw new Exception("Declined: " + lines[3]);
                }
                else
                {
                    trans.GatewayResponse = lines[3];
                    throw new Exception("Error: " + lines[3]);
                }
            }
            catch (Exception e)
            {
                LovRubLogger.LogException(e, strPost);   // KPL 04/05/08
                throw e;
            }

            // Call OrderMotion to submit order to them.
            string strKeycode = "";

            GetKeyCode(order, out strKeycode);

/*************** Commented out for new price change KPL 09/20/08
 *          if (strKeycode.Equals("CALLCENTER") ) // Added for new CallCenter KPL 06/06/08
 *              CallCenterOrderMotion(order, trans.AuthorizationCode, trans.TransactionID);
 *          else
 *              OrderMotion(order, trans.AuthorizationCode, trans.TransactionID);
 ****************/
            CallCenterOrderMotion(order, trans.AuthorizationCode, trans.TransactionID);
            return(trans);
        }
Beispiel #21
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int nNewQty = 0;

            if (txtQty.Text.Equals(""))
            {
                return;
            }
            try
            {
                int.TryParse(txtQty.Text, out nNewQty);

                if (0 == nNewQty)
                {
                    return;
                }

                AddToCart(sSurvivalGUID, nNewQty);

                //AddKeyForOrderMotion();

                Response.Redirect("~/BasketLV3.aspx", false);
            }
            catch (Exception ex)
            {
                LovRubLogger.LogException(ex);
                throw ex;
            }

/*************************************************************************
 *
 *          int nTotalQty = 0;
 *          int nMaleFullQty = 0;
 *          int nMaleDiscountQty = 0;
 *          int nFemaleFullQty = 0;
 *          int nFemaleDiscountQty = 0;
 *          int nRL6FullQty = 0;
 *          int nRLG6DiscountQty = 0;
 *          int nRLFreeQty = 0;
 *          int nSeasonalQty = 0;
 *
 *          int nLipLovFullQty = 0;
 *          int nLipLovDiscountQty = 0;
 *
 *          int nNewQty = 0;
 ************/

            /********************************************************
             *   Determine # of items in cart and their sku
             *
             *   Determine # of new items to be added
             *
             *   if cart is empty
             *      if 1 == nNewQty
             *         add 1st item as full price
             *      if nNewQty > 1
             *          add 1st item as full price
             *          add rest as discount
             *
             *   if cart has a full price item already
             *       add rest of items as discount
             *   if cart > 2 items and none are DFDF
             *      add DFDF
             *******************************************************/

/*************************************************
 *          if (txtQty.Text.Equals(""))
 *              return;
 *          try
 *          {
 *              int.TryParse(txtQty.Text, out nNewQty);
 *
 *              // Calculate total, male, female, RubLov qty
 *              OrderController.DetermineBasketContents(out nMaleFullQty,
 *                                                      out nMaleDiscountQty,
 *                                                      out nFemaleFullQty,
 *                                                      out nFemaleDiscountQty,
 *                                                      out nRL6FullQty,
 *                                                      out nRLG6DiscountQty,
 *                                                      out nRLFreeQty,
 *                                                      out nSeasonalQty,
 *                                                      out nLipLovFullQty,
 *                                                      out nLipLovDiscountQty);
 *
 *              nTotalQty = nMaleFullQty +
 *                          nMaleDiscountQty +
 *                          nFemaleFullQty +
 *                          nFemaleDiscountQty +
 *                          nRL6FullQty +
 *                          nRLG6DiscountQty +
 *                          nRLFreeQty +
 *                          nSeasonalQty +
 *                          nLipLovFullQty +
 *                          nLipLovDiscountQty;
 *
 *              // If cart is empty, add 1st item as full price, rest as discounted.
 *              if (0 == nTotalQty)
 *              {
 *                  if (1 == nNewQty)
 *                      //put first Male in using current ID (LRM1)
 *                      AddToCart(sMaleProductGUID, 1);
 *
 *                  // add 1st item as full price, rest as discounted.
 *                  if (nNewQty > 1)
 *                  {
 *                      AddToCart(sMaleProductGUID, 1);
 *
 *                      // add rest as discount
 *                      int nDiscountedMaleItems = nNewQty - 1;
 *                      if (nDiscountedMaleItems > 0)
 *                          AddToCart(sMaleDiscountGUID, nDiscountedMaleItems);
 *                  }
 *              }
 *
 *              // if cart has a full price item already, add rest of items as discount
 *              if ((0 != nMaleFullQty) || (0 != nFemaleFullQty) || (0 != nRL6FullQty) || (0 != nLipLovFullQty))
 *              {
 *                  AddToCart(sMaleDiscountGUID, nNewQty);
 *              }
 *
 *              AddKeyForOrderMotion();
 *
 *              Response.Redirect("~/BasketLV3.aspx", false);
 *          }
 *          catch (Exception ex)
 *          {
 *              LovRubLogger.LogException(ex);
 *              throw ex;
 *          }
 *********************************************/
        }