private void btnGetSession_Click(object sender, RoutedEventArgs e)
        {
            ACDB.AmeriCommerceDatabaseIO oWS     = new AmeriCommerceApiExamples.ACDB.AmeriCommerceDatabaseIO();
            ACDB.AmeriCommerceHeaderInfo oHeader = new AmeriCommerceApiExamples.ACDB.AmeriCommerceHeaderInfo();
            oWS.Url = Properties.Settings.Default.AmeriCommerceApiExamples_ACDB_AmeriCommerceDatabaseIO;

            oHeader.UserName      = Properties.Settings.Default.ApiUsername;
            oHeader.Password      = Properties.Settings.Default.ApiPassword;
            oHeader.SecurityToken = Properties.Settings.Default.ApiSecurityToken;

            oWS.AmeriCommerceHeaderInfoValue = oHeader;

            this.txtResults.Text = "";


            //Must start a user session and then keep track of this session on your own via a cookie or any accessible means on your codes side
            //this session corresponds to 1 visitor or 1 user session and will have tracking information, cart info, etc. associated with it
            //the session will be logged as a 'session visit' appropriately
            ACDB.SessionTrans oSession;
            if (this.chkNewSession.IsChecked.Value)
            {
                oSession = oWS.Session_StartSession();
            }
            else
            {
                oSession = oWS.Session_GetByKey(1158);
            }

            this.txtResults.Text += "SessionID: " + oSession.ID.Value + "\r\n";
            this.txtResults.Text += "SessionUID: " + oSession.UID + "\r\n";
            this.txtResults.Text += "SourceGroup: " + oSession.SourceGroup + "\r\n";
            this.txtResults.Text += "Source: " + oSession.Source + "\r\n";
            this.txtResults.Text += "UserAgent: " + oSession.userAgent + "\r\n";

            //GET A CART
            this.txtResults.Text += "\r\n";
            //will be 0 on a new session until you call getcart
            this.txtResults.Text += "CartInfoID: " + oSession.ActiveCartInfoID.Value + "\r\n";

            //Does the work of setting up a cart for the session passed in
            var oCartInfo = oWS.Cart_GetBySessionID(oSession.ID.Value);

            this.txtResults.Text += "CartInfoID: " + oCartInfo.CartInfoID.Value + "\r\n";

            //SEE WHATS IN CART - will not have any items in cart usually on a new session
            this.txtResults.Text += "Unique SKUs In Cart: " + oCartInfo.CartColTrans.Count() + "\r\n";

            //Add an item to the sessions cart by the item ID, telling it a quantity as well.
            this.txtResults.Text += "AddToCart Message: " + oWS.Cart_AddToCart_ByItem(oSession.ID.Value, 1, 1) + "\r\n";

            //NOTE: Can also perform these operations on cart
            //oWS.Cart_UpdateCartItem(oSession.ID.Value, 1234, 1); //updates an existing cart item with a new quantity
            //oWS.Cart_RemoveCartItem(oSession.ID.Value, 1234); //removes a specific item from the cart (using it's cartid)
            //oWS.Cart_ClearCart(oSession.ID.Value); //clears the cart entirely

            //NOTE: You also have the ability to add multiple items to the cart with a single call:
            //string[] sResponse =  oWS.Cart_AddToCart_ByItems(oSession.ID.Value, new int[] {1, 2}, new int[] {3, 4} //mass add to cart.
            //The expected parameters are an array of integers that contains each item ID you want to add to the cart,
            //and an additional array of integers that contains the corresponding quantity for the items you want to add
            //this example will add item IDs 1 and 2 to the cart, where item ID 1 has a quantity of 3 and item id 2 has a quantity of 4
            //the indices of the item IDs in the items array should match the indices of the corresponding quantity on the quantities array

            //The response will be an array of strings, each containing the corresponding success or failure message for each item that was added
            //For example, if the first item ID was added to the cart successfully, then element 0 of sResponse should contain "Ok"
            //if the second item ID was NOT added successfully then element 1 of sResponse should contain the error message.

            //If there is an error in the method before the code reaches the point of attempting to add the items to the cart, then sResponse will contain a
            //single element which will be the error message.

            //You MUST specify both an items array and a quantities array, and the number of items in each array must be the same.  If not then the method
            //will fail without attempting to add any items to the cart.

            //TODO: Add Phantom Items
            //TODO: Add Variant Items
            //TODO: Add Multiple Variant Items with single call
            //TODO: Add Personalized Items
            //TODO: Add Group/Kit Items


            //setup some tracking variables
            int     iCartItemID = 0;
            int     iCartItemQuantityForDisplay = 0;
            decimal dCartItemPriceForDisplay    = 0m;


            //Get the updated cart now that it has an item in it, will have values and totals all calculated
            //along with any applicable discounts and rules in place
            oCartInfo = oWS.Cart_GetBySessionID(oSession.ID.Value);
            var aryCartItems = new System.Collections.ArrayList(oCartInfo.CartColTrans);

            foreach (ACDB.CartTrans oItem in aryCartItems)
            {
                if (oItem.itemID.Value == 1) //this is the ID of the product passed in that i'm looking for
                {
                    iCartItemID = oItem.ID.Value;
                    iCartItemQuantityForDisplay = oItem.quantity.Value;
                    dCartItemPriceForDisplay    = oItem.price.Value;
                }
            }
            this.txtResults.Text += "Unique SKUs In Cart: " + oCartInfo.CartColTrans.Count() + "\r\n";
            this.txtResults.Text += "First Item's Quantity: " + iCartItemQuantityForDisplay + "\r\n";
            this.txtResults.Text += "First Item's Price: " + dCartItemPriceForDisplay + "\r\n";
            this.txtResults.Text += "SubTotal Total: " + oCartInfo.SubTotal.Value + "\r\n";
            this.txtResults.Text += "Discount Total: " + oCartInfo.DiscountTotal.Value + "\r\n";
            this.txtResults.Text += "Tax Total: " + oCartInfo.TaxTotal.Value + "\r\n";
            this.txtResults.Text += "Shipping Total: " + oCartInfo.ShippingTotal.Value + "\r\n";
            this.txtResults.Text += "Cart Total: " + oCartInfo.GrandTotal.Value + "\r\n";



            //READ:
            //At this point you can escape out of the API and go directly to the store's AmeriCommerce front end for
            //processing the order, viewing the cart, checking out, etc.
            //OPTIONALLY: You can continue via the API to cart products and process the order

            //ESCAPE POINT #1: UNCOMMENT
            //GO TO THE FRONT END OF SITE AND POPULATE THE SESSION/CART
            //setting z= will set the current session on any americommerce site to the session key passed in
            //System.Diagnostics.Process oProcess = new System.Diagnostics.Process();
            //oProcess.StartInfo.FileName = "http://shop.mybox.com/store/shopcart.aspx?z=" + oSession.UID;
            //oProcess.Start();


            //ESCAPE POINT #2: UNCOMMENT
            //DIRECT TO CHECKOUT
            //setting z= will set the current session on any americommerce site to the session key passed in
            //System.Diagnostics.Process oProcess = new System.Diagnostics.Process();
            //oProcess.StartInfo.FileName = "https://shop.mybox.com/store/OnePageCheckout.aspx?z=" + oSession.UID;
            //oProcess.Start();

            //You have passed on going to the front end so let's finish getting data for the order supplied to the cart and session.



            //Let's go ahead and update the cart, repull it and make sure it's all still there
            //you must use the CartItemID, not the items id...as an item can be in the cart more than once
            aryCartItems = new System.Collections.ArrayList(oCartInfo.CartColTrans);
            foreach (ACDB.CartTrans oItem in aryCartItems)
            {
                if (oItem.itemID.Value == 1) //this is the ID of the product passed in that i'm looking for
                {
                    iCartItemQuantityForDisplay = oItem.quantity.Value;
                    dCartItemPriceForDisplay    = oItem.price.Value;
                }
            }

            //UPDATE THE QUANTITY TO 10
            this.txtResults.Text += "UpdateCartItem Message: " + oWS.Cart_UpdateCartItem(oSession.ID.Value, iCartItemID, 10);
            //CHECK RETURN VALUES
            oCartInfo    = oWS.Cart_GetBySessionID(oSession.ID.Value);
            aryCartItems = new System.Collections.ArrayList(oCartInfo.CartColTrans);
            foreach (ACDB.CartTrans oItem in aryCartItems)
            {
                if (oItem.itemID.Value == 1)
                {
                    iCartItemQuantityForDisplay = oItem.quantity.Value;
                    dCartItemPriceForDisplay    = oItem.price.Value;
                }
            }
            this.txtResults.Text += "Unique SKUs In Cart: " + oCartInfo.CartColTrans.Count() + "\r\n";
            this.txtResults.Text += "First Item's Quantity: " + iCartItemQuantityForDisplay + "\r\n";
            this.txtResults.Text += "First Item's Price: " + dCartItemPriceForDisplay + "\r\n";
            this.txtResults.Text += "SubTotal Total: " + oCartInfo.SubTotal.Value + "\r\n";
            this.txtResults.Text += "Discount Total: " + oCartInfo.DiscountTotal.Value + "\r\n";
            this.txtResults.Text += "Tax Total: " + oCartInfo.TaxTotal.Value + "\r\n";
            this.txtResults.Text += "Shipping Total: " + oCartInfo.ShippingTotal.Value + "\r\n";
            this.txtResults.Text += "Cart Total: " + oCartInfo.GrandTotal.Value + "\r\n";



            //UPDATE THE QUANTITY BACK TO 1
            this.txtResults.Text += "UpdateCartItem 2 Message: " + oWS.Cart_UpdateCartItem(oSession.ID.Value, iCartItemID, 1);
            //CHECK RETURN VALUES
            oCartInfo    = oWS.Cart_GetBySessionID(oSession.ID.Value);
            aryCartItems = new System.Collections.ArrayList(oCartInfo.CartColTrans);
            foreach (ACDB.CartTrans oItem in aryCartItems)
            {
                if (oItem.itemID.Value == 1)
                {
                    iCartItemQuantityForDisplay = oItem.quantity.Value;
                    dCartItemPriceForDisplay    = oItem.price.Value;
                }
            }
            this.txtResults.Text += "Unique SKUs In Cart: " + oCartInfo.CartColTrans.Count() + "\r\n";
            this.txtResults.Text += "First Item's Quantity: " + iCartItemQuantityForDisplay + "\r\n";
            this.txtResults.Text += "First Item's Price: " + dCartItemPriceForDisplay + "\r\n";
            this.txtResults.Text += "SubTotal Total: " + oCartInfo.SubTotal.Value + "\r\n";
            this.txtResults.Text += "Discount Total: " + oCartInfo.DiscountTotal.Value + "\r\n";
            this.txtResults.Text += "Tax Total: " + oCartInfo.TaxTotal.Value + "\r\n";
            this.txtResults.Text += "Shipping Total: " + oCartInfo.ShippingTotal.Value + "\r\n";
            this.txtResults.Text += "Cart Total: " + oCartInfo.GrandTotal.Value + "\r\n";



            //SHIPPING OPTIONS
            //You can directly apply shipping to the cart by saving the CartInfo transport back to the api with the changed value
            //or use the AmeriCommerce Shipping API and rules built into the AmeriCommerce admin console to return rates for choosing and setting on cart

            if (this.chkGetShipping.IsChecked.Value)
            {
                //RETURN SHIPPING QUOTES FOR ADDRESS
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "Get all available shipping rates:\r\n";
                var aryRates = new System.Collections.ArrayList();
                try
                {
                    //Can supply varying amounts of information, standard 2 digit country codes are required.  Can get from Country_GetAll.
                    aryRates              = new System.Collections.ArrayList(oWS.Cart_GetShipping(oSession.ID.Value, "", "", "77707", "US"));
                    this.txtResults.Text += "ShippingRateCount: " + aryRates.Count + "\r\n";
                    foreach (ACDB.Rate oRate in aryRates)
                    {
                        this.txtResults.Text += "Rate: " + oRate.Description + " " + oRate.TotalCharges + "\r\n";
                    }
                }
                catch (System.Exception ex)
                {
                    this.txtResults.Text += ex.GetBaseException().Message + " " + ex.StackTrace;
                }

                //SHIPPING QUOTES COMPLETE, LETS TAKE ONE AND SAVE IT BACK TO CART AS A 'CHOICE'
                //Typically you will give the end customer the shipping options and they will choose one, this will be what you will do when the shipping is chosen to set it on the cart/order permanently
                if (aryRates != null)
                {
                    this.txtResults.Text += "\r\n";
                    this.txtResults.Text += "Set The Selected Shipping Rate:\r\n";
                    string sShippingMethodIdentifier = "";

                    //iterate the rates to show how to do it...just snags the last identifier for use in 'setting' the rate back onto cart from your UI
                    foreach (ACDB.Rate oRate in aryRates)
                    {
                        sShippingMethodIdentifier = oRate.Identifier;
                    }
                    this.txtResults.Text += "Rate Set?" + oWS.Cart_SetShipping(oSession.ID.Value, sShippingMethodIdentifier) + "\r\n";
                }

                //Get the updated cart now for display, just to see the new values
                oCartInfo             = oWS.Cart_GetBySessionID(oSession.ID.Value);
                this.txtResults.Text += "\r\nDISPLAY CART RESULTS\r\n";
                this.txtResults.Text += "**************************\r\n";
                this.txtResults.Text += "Unique SKUs In Cart: " + oCartInfo.CartColTrans.Count() + "\r\n";
                this.txtResults.Text += "SubTotal Total: " + oCartInfo.SubTotal.Value + "\r\n";
                this.txtResults.Text += "Discount Total: " + oCartInfo.DiscountTotal.Value + "\r\n";
                this.txtResults.Text += "Tax Total: " + oCartInfo.TaxTotal.Value + "\r\n";
                this.txtResults.Text += "Shipping Total: " + oCartInfo.ShippingTotal.Value + "\r\n";
                this.txtResults.Text += "Cart Total: " + oCartInfo.GrandTotal.Value + "\r\n";
            }



            if (chkPlaceOrder.IsChecked.Value)
            {
                //CARTING COMPLETED, PLACE ORDER OPERATIONS BEGIN
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "Carting Complete, Ordering Begins\r\n";

                //Get payment methods that are active on the store
                //This can be used to populate your own payment lists
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "List Active Payment Methods.\r\n";
                var aryPaymentMethods = new System.Collections.ArrayList(oWS.Cart_GetPaymentMethods());
                foreach (ACDB.ActivePaymentMethodTrans oPaymentMethod in aryPaymentMethods)
                {
                    this.txtResults.Text += oPaymentMethod.PaymentMethodName + " (" + oPaymentMethod.PaymentType + ") [" + oPaymentMethod.PaymentMethodID + "]\r\n";
                }

                //GATHER FINAL CUSTOMER INFORMATION (can be started at any time on the session, encouraged too for abandoned cart and drip series followup features of AmeriCommerce, gather and post this information as soon as you see fit)
                //We will need all of the pertinent customer information to place the order
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "Gather Remaining Order Information.\r\n";

                //This will be done via your user interface and the fields mapped to their sister values on our API

                var oPlaceOrderInfo = new AmeriCommerceApiExamples.ACDB.PlaceOrderTrans();

                oPlaceOrderInfo.CustomerFirstName = "JohnAPI";
                oPlaceOrderInfo.CustomerLastName  = "DoeAPI";
                oPlaceOrderInfo.CustomerEmail     = "*****@*****.**";
                oPlaceOrderInfo.CustomerPhone1    = "123-123-1234";
                oPlaceOrderInfo.CustomerFax       = "456-456-4567";

                //can leave this blank for guest checkout as long as the customer does not want to track their orders
                oPlaceOrderInfo.CustomerPassword = "******";

                //Address information
                oPlaceOrderInfo.CustomerBillingAddressLine1       = "5390 Washington Blvd.";
                oPlaceOrderInfo.CustomerBillingAddressLine2       = "";
                oPlaceOrderInfo.CustomerBillingAddressCity        = "Beaumont";
                oPlaceOrderInfo.CustomerBillingAddressPostalCode  = "77707";
                oPlaceOrderInfo.CustomerBillingAddressStateCode   = "TX"; //can get from state list
                oPlaceOrderInfo.CustomerBillingAddressCountryCode = "US"; //can get from country list
                oPlaceOrderInfo.CustomerBillingAddressNotes       = "Optional address note: leave at front door";

                //can optionally supply a separate shipping address or just set this flag if ikt is the same as the billing address
                oPlaceOrderInfo.CustomerShippingSameAsBilling = true;

                //payment information is required unless $0 orders are allowed or you have a custom payment method that allows a non-payment order
                oPlaceOrderInfo.PaymentMethodID      = 0;                  //0 = credit card, can get all applicable types from the web service method
                oPlaceOrderInfo.CreditCardNameOnCard = "John Doe Sr.";
                oPlaceOrderInfo.CreditCardNumber     = "4444444444444441"; //with or without dashes
                //oPlaceOrderInfo.CreditCardNumber = "4111111111111111"; //with or without dashes
                oPlaceOrderInfo.CreditCardCVV             = "777";
                oPlaceOrderInfo.CreditCardExpirationMonth = "12";
                oPlaceOrderInfo.CreditCardExpirationYear  = "2010";

                //other info
                oPlaceOrderInfo.GiftMessage          = "Happy Coding!";
                oPlaceOrderInfo.CommentsPrivate      = "Private Comments: Only admins see this by default.";
                oPlaceOrderInfo.CommentsPublic       = "Public: Customers and Admins can see and edit this";
                oPlaceOrderInfo.CommentsInstructions = "Instructions: Viewable but not editable by customer, admins can edit";

                //PLACE THE ORDER
                //  The final step that posts the order into the appropriate status in the AmeriCommerce system
                //  This will capture/authorize payment information and sends email confirmations
                //  Will return status and validation information in the event an error occurs or more entry is needed
                this.txtResults.Text += "Calling Order Placement:\r\n";
                ACDB.PlaceOrderResponseTrans oResponse = oWS.Cart_PlaceOrder(oSession.ID.Value, oPlaceOrderInfo);
                this.txtResults.Text += "OrderID: " + oResponse.OrderID + " Msg: " + oResponse.ResponseMessage + "\r\n";

                ACDB.OrderTrans oOrder = oWS.Order_GetByKey(oResponse.OrderID);
                this.txtResults.Text += "\r\n\r\nCustomerID: " + oOrder.customerID.Value + "\r\n";
                ACDB.CustomerTrans oCustomer = oWS.Customer_GetByKey(oOrder.customerID.Value);
                oCustomer = oWS.Customer_FillCustomerPaymentMethodCollection(oCustomer);
                var aryCustomerPaymentMethods = new System.Collections.ArrayList(oCustomer.CustomerPaymentMethodColTrans);
                foreach (ACDB.CustomerPaymentMethodTrans oPayment in aryCustomerPaymentMethods)
                {
                    this.txtResults.Text += "PaymentMethod: " + oPayment.paymentType + " MaskedValue:" + oPayment.PaymentTypeMasked + "\r\n";
                }
            }
            //Can now grab the order itself from the API if needed by calling Order_Get methods
        }
Example #2
0
        private void btnGetSession_Click(object sender, RoutedEventArgs e)
        {
            ACDB.AmeriCommerceDatabaseIO oWS = new AmeriCommerceApiExamples.ACDB.AmeriCommerceDatabaseIO();
            ACDB.AmeriCommerceHeaderInfo oHeader = new AmeriCommerceApiExamples.ACDB.AmeriCommerceHeaderInfo();
            oWS.Url = Properties.Settings.Default.AmeriCommerceApiExamples_ACDB_AmeriCommerceDatabaseIO;

            oHeader.UserName = Properties.Settings.Default.ApiUsername;
            oHeader.Password = Properties.Settings.Default.ApiPassword;
            oHeader.SecurityToken = Properties.Settings.Default.ApiSecurityToken;

            oWS.AmeriCommerceHeaderInfoValue = oHeader;

            this.txtResults.Text = "";

            //Must start a user session and then keep track of this session on your own via a cookie or any accessible means on your codes side
            //this session corresponds to 1 visitor or 1 user session and will have tracking information, cart info, etc. associated with it
            //the session will be logged as a 'session visit' appropriately
            ACDB.SessionTrans oSession;
            if (this.chkNewSession.IsChecked.Value)
                oSession = oWS.Session_StartSession();
            else
                oSession = oWS.Session_GetByKey(1158);

            this.txtResults.Text += "SessionID: " + oSession.ID.Value + "\r\n";
            this.txtResults.Text += "SessionUID: " + oSession.UID + "\r\n";
            this.txtResults.Text += "SourceGroup: " + oSession.SourceGroup + "\r\n";
            this.txtResults.Text += "Source: " + oSession.Source + "\r\n";
            this.txtResults.Text += "UserAgent: " + oSession.userAgent + "\r\n";

            //GET A CART
            this.txtResults.Text += "\r\n";
            //will be 0 on a new session until you call getcart
            this.txtResults.Text += "CartInfoID: " + oSession.ActiveCartInfoID.Value + "\r\n";

            //Does the work of setting up a cart for the session passed in
            var oCartInfo = oWS.Cart_GetBySessionID(oSession.ID.Value);
            this.txtResults.Text += "CartInfoID: " + oCartInfo.CartInfoID.Value + "\r\n";

            //SEE WHATS IN CART - will not have any items in cart usually on a new session
            this.txtResults.Text += "Unique SKUs In Cart: " + oCartInfo.CartColTrans.Count() + "\r\n";

            //Add an item to the sessions cart by the item ID, telling it a quantity as well.
            this.txtResults.Text += "AddToCart Message: " + oWS.Cart_AddToCart_ByItem(oSession.ID.Value, 1, 1) + "\r\n";

            //NOTE: Can also perform these operations on cart
            //oWS.Cart_UpdateCartItem(oSession.ID.Value, 1234, 1); //updates an existing cart item with a new quantity
            //oWS.Cart_RemoveCartItem(oSession.ID.Value, 1234); //removes a specific item from the cart (using it's cartid)
            //oWS.Cart_ClearCart(oSession.ID.Value); //clears the cart entirely

            //NOTE: You also have the ability to add multiple items to the cart with a single call:
            //string[] sResponse =  oWS.Cart_AddToCart_ByItems(oSession.ID.Value, new int[] {1, 2}, new int[] {3, 4} //mass add to cart.
            //The expected parameters are an array of integers that contains each item ID you want to add to the cart,
            //and an additional array of integers that contains the corresponding quantity for the items you want to add
            //this example will add item IDs 1 and 2 to the cart, where item ID 1 has a quantity of 3 and item id 2 has a quantity of 4
            //the indices of the item IDs in the items array should match the indices of the corresponding quantity on the quantities array

            //The response will be an array of strings, each containing the corresponding success or failure message for each item that was added
            //For example, if the first item ID was added to the cart successfully, then element 0 of sResponse should contain "Ok"
            //if the second item ID was NOT added successfully then element 1 of sResponse should contain the error message.

            //If there is an error in the method before the code reaches the point of attempting to add the items to the cart, then sResponse will contain a
            //single element which will be the error message.

            //You MUST specify both an items array and a quantities array, and the number of items in each array must be the same.  If not then the method
            //will fail without attempting to add any items to the cart.

            //TODO: Add Phantom Items
            //TODO: Add Variant Items
            //TODO: Add Multiple Variant Items with single call
            //TODO: Add Personalized Items
            //TODO: Add Group/Kit Items

            //setup some tracking variables
            int iCartItemID = 0;
            int iCartItemQuantityForDisplay = 0;
            decimal dCartItemPriceForDisplay = 0m;

            //Get the updated cart now that it has an item in it, will have values and totals all calculated
            //along with any applicable discounts and rules in place
            oCartInfo = oWS.Cart_GetBySessionID(oSession.ID.Value);
            var aryCartItems = new System.Collections.ArrayList(oCartInfo.CartColTrans);
            foreach (ACDB.CartTrans oItem in aryCartItems)
            {
                if (oItem.itemID.Value == 1) //this is the ID of the product passed in that i'm looking for
                {
                    iCartItemID = oItem.ID.Value;
                    iCartItemQuantityForDisplay = oItem.quantity.Value;
                    dCartItemPriceForDisplay = oItem.price.Value;
                }
            }
            this.txtResults.Text += "Unique SKUs In Cart: " + oCartInfo.CartColTrans.Count() + "\r\n";
            this.txtResults.Text += "First Item's Quantity: " + iCartItemQuantityForDisplay + "\r\n";
            this.txtResults.Text += "First Item's Price: " + dCartItemPriceForDisplay + "\r\n";
            this.txtResults.Text += "SubTotal Total: " + oCartInfo.SubTotal.Value + "\r\n";
            this.txtResults.Text += "Discount Total: " + oCartInfo.DiscountTotal.Value + "\r\n";
            this.txtResults.Text += "Tax Total: " + oCartInfo.TaxTotal.Value + "\r\n";
            this.txtResults.Text += "Shipping Total: " + oCartInfo.ShippingTotal.Value + "\r\n";
            this.txtResults.Text += "Cart Total: " + oCartInfo.GrandTotal.Value + "\r\n";

            //READ:
            //At this point you can escape out of the API and go directly to the store's AmeriCommerce front end for
            //processing the order, viewing the cart, checking out, etc.
            //OPTIONALLY: You can continue via the API to cart products and process the order

            //ESCAPE POINT #1: UNCOMMENT
            //GO TO THE FRONT END OF SITE AND POPULATE THE SESSION/CART
            //setting z= will set the current session on any americommerce site to the session key passed in
            //System.Diagnostics.Process oProcess = new System.Diagnostics.Process();
            //oProcess.StartInfo.FileName = "http://shop.mybox.com/store/shopcart.aspx?z=" + oSession.UID;
            //oProcess.Start();

            //ESCAPE POINT #2: UNCOMMENT
            //DIRECT TO CHECKOUT
            //setting z= will set the current session on any americommerce site to the session key passed in
            //System.Diagnostics.Process oProcess = new System.Diagnostics.Process();
            //oProcess.StartInfo.FileName = "https://shop.mybox.com/store/OnePageCheckout.aspx?z=" + oSession.UID;
            //oProcess.Start();

            //You have passed on going to the front end so let's finish getting data for the order supplied to the cart and session.

            //Let's go ahead and update the cart, repull it and make sure it's all still there
            //you must use the CartItemID, not the items id...as an item can be in the cart more than once
            aryCartItems = new System.Collections.ArrayList(oCartInfo.CartColTrans);
            foreach (ACDB.CartTrans oItem in aryCartItems)
            {
                if (oItem.itemID.Value == 1) //this is the ID of the product passed in that i'm looking for
                {
                    iCartItemQuantityForDisplay = oItem.quantity.Value;
                    dCartItemPriceForDisplay = oItem.price.Value;
                }
            }

            //UPDATE THE QUANTITY TO 10
            this.txtResults.Text += "UpdateCartItem Message: " + oWS.Cart_UpdateCartItem(oSession.ID.Value, iCartItemID, 10);
            //CHECK RETURN VALUES
            oCartInfo = oWS.Cart_GetBySessionID(oSession.ID.Value);
            aryCartItems = new System.Collections.ArrayList(oCartInfo.CartColTrans);
            foreach (ACDB.CartTrans oItem in aryCartItems)
            {
                if (oItem.itemID.Value == 1)
                {
                    iCartItemQuantityForDisplay = oItem.quantity.Value;
                    dCartItemPriceForDisplay = oItem.price.Value;
                }
            }
            this.txtResults.Text += "Unique SKUs In Cart: " + oCartInfo.CartColTrans.Count() + "\r\n";
            this.txtResults.Text += "First Item's Quantity: " + iCartItemQuantityForDisplay + "\r\n";
            this.txtResults.Text += "First Item's Price: " + dCartItemPriceForDisplay + "\r\n";
            this.txtResults.Text += "SubTotal Total: " + oCartInfo.SubTotal.Value + "\r\n";
            this.txtResults.Text += "Discount Total: " + oCartInfo.DiscountTotal.Value + "\r\n";
            this.txtResults.Text += "Tax Total: " + oCartInfo.TaxTotal.Value + "\r\n";
            this.txtResults.Text += "Shipping Total: " + oCartInfo.ShippingTotal.Value + "\r\n";
            this.txtResults.Text += "Cart Total: " + oCartInfo.GrandTotal.Value + "\r\n";

            //UPDATE THE QUANTITY BACK TO 1
            this.txtResults.Text += "UpdateCartItem 2 Message: " + oWS.Cart_UpdateCartItem(oSession.ID.Value, iCartItemID, 1);
            //CHECK RETURN VALUES
            oCartInfo = oWS.Cart_GetBySessionID(oSession.ID.Value);
            aryCartItems = new System.Collections.ArrayList(oCartInfo.CartColTrans);
            foreach (ACDB.CartTrans oItem in aryCartItems)
            {
                if (oItem.itemID.Value == 1)
                {
                    iCartItemQuantityForDisplay = oItem.quantity.Value;
                    dCartItemPriceForDisplay = oItem.price.Value;
                }
            }
            this.txtResults.Text += "Unique SKUs In Cart: " + oCartInfo.CartColTrans.Count() + "\r\n";
            this.txtResults.Text += "First Item's Quantity: " + iCartItemQuantityForDisplay + "\r\n";
            this.txtResults.Text += "First Item's Price: " + dCartItemPriceForDisplay + "\r\n";
            this.txtResults.Text += "SubTotal Total: " + oCartInfo.SubTotal.Value + "\r\n";
            this.txtResults.Text += "Discount Total: " + oCartInfo.DiscountTotal.Value + "\r\n";
            this.txtResults.Text += "Tax Total: " + oCartInfo.TaxTotal.Value + "\r\n";
            this.txtResults.Text += "Shipping Total: " + oCartInfo.ShippingTotal.Value + "\r\n";
            this.txtResults.Text += "Cart Total: " + oCartInfo.GrandTotal.Value + "\r\n";

            //SHIPPING OPTIONS
            //You can directly apply shipping to the cart by saving the CartInfo transport back to the api with the changed value
            //or use the AmeriCommerce Shipping API and rules built into the AmeriCommerce admin console to return rates for choosing and setting on cart

            if(this.chkGetShipping.IsChecked.Value)
            {
                //RETURN SHIPPING QUOTES FOR ADDRESS
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "Get all available shipping rates:\r\n";
                var aryRates = new System.Collections.ArrayList();
                try
                {
                    //Can supply varying amounts of information, standard 2 digit country codes are required.  Can get from Country_GetAll.
                    aryRates = new System.Collections.ArrayList(oWS.Cart_GetShipping(oSession.ID.Value, "", "", "77707", "US"));
                    this.txtResults.Text += "ShippingRateCount: " + aryRates.Count + "\r\n";
                    foreach(ACDB.Rate oRate in aryRates)
                        this.txtResults.Text += "Rate: " + oRate.Description + " " + oRate.TotalCharges + "\r\n";
                }
                catch(System.Exception ex)
                {
                    this.txtResults.Text += ex.GetBaseException().Message + " " + ex.StackTrace;
                }

                //SHIPPING QUOTES COMPLETE, LETS TAKE ONE AND SAVE IT BACK TO CART AS A 'CHOICE'
                //Typically you will give the end customer the shipping options and they will choose one, this will be what you will do when the shipping is chosen to set it on the cart/order permanently
                if(aryRates != null)
                {
                    this.txtResults.Text += "\r\n";
                    this.txtResults.Text += "Set The Selected Shipping Rate:\r\n";
                    string sShippingMethodIdentifier = "";

                    //iterate the rates to show how to do it...just snags the last identifier for use in 'setting' the rate back onto cart from your UI
                    foreach(ACDB.Rate oRate in aryRates)
                        sShippingMethodIdentifier = oRate.Identifier;
                    this.txtResults.Text += "Rate Set?" + oWS.Cart_SetShipping(oSession.ID.Value, sShippingMethodIdentifier) + "\r\n";
                }

                //Get the updated cart now for display, just to see the new values
                oCartInfo = oWS.Cart_GetBySessionID(oSession.ID.Value);
                this.txtResults.Text += "\r\nDISPLAY CART RESULTS\r\n";
                this.txtResults.Text += "**************************\r\n";
                this.txtResults.Text += "Unique SKUs In Cart: " + oCartInfo.CartColTrans.Count() + "\r\n";
                this.txtResults.Text += "SubTotal Total: " + oCartInfo.SubTotal.Value + "\r\n";
                this.txtResults.Text += "Discount Total: " + oCartInfo.DiscountTotal.Value + "\r\n";
                this.txtResults.Text += "Tax Total: " + oCartInfo.TaxTotal.Value + "\r\n";
                this.txtResults.Text += "Shipping Total: " + oCartInfo.ShippingTotal.Value + "\r\n";
                this.txtResults.Text += "Cart Total: " + oCartInfo.GrandTotal.Value + "\r\n";
            }

            if (chkPlaceOrder.IsChecked.Value)
            {

                //CARTING COMPLETED, PLACE ORDER OPERATIONS BEGIN
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "Carting Complete, Ordering Begins\r\n";

                //Get payment methods that are active on the store
                //This can be used to populate your own payment lists
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "List Active Payment Methods.\r\n";
                var aryPaymentMethods = new System.Collections.ArrayList(oWS.Cart_GetPaymentMethods());
                foreach (ACDB.ActivePaymentMethodTrans oPaymentMethod in aryPaymentMethods)
                {
                    this.txtResults.Text += oPaymentMethod.PaymentMethodName + " (" + oPaymentMethod.PaymentType + ") [" + oPaymentMethod.PaymentMethodID + "]\r\n";
                }

                //GATHER FINAL CUSTOMER INFORMATION (can be started at any time on the session, encouraged too for abandoned cart and drip series followup features of AmeriCommerce, gather and post this information as soon as you see fit)
                //We will need all of the pertinent customer information to place the order
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "\r\n";
                this.txtResults.Text += "Gather Remaining Order Information.\r\n";

                //This will be done via your user interface and the fields mapped to their sister values on our API

                var oPlaceOrderInfo = new AmeriCommerceApiExamples.ACDB.PlaceOrderTrans();

                oPlaceOrderInfo.CustomerFirstName = "JohnAPI";
                oPlaceOrderInfo.CustomerLastName = "DoeAPI";
                oPlaceOrderInfo.CustomerEmail = "*****@*****.**";
                oPlaceOrderInfo.CustomerPhone1 = "123-123-1234";
                oPlaceOrderInfo.CustomerFax = "456-456-4567";

                //can leave this blank for guest checkout as long as the customer does not want to track their orders
                oPlaceOrderInfo.CustomerPassword = "******";

                //Address information
                oPlaceOrderInfo.CustomerBillingAddressLine1 = "5390 Washington Blvd.";
                oPlaceOrderInfo.CustomerBillingAddressLine2 = "";
                oPlaceOrderInfo.CustomerBillingAddressCity = "Beaumont";
                oPlaceOrderInfo.CustomerBillingAddressPostalCode = "77707";
                oPlaceOrderInfo.CustomerBillingAddressStateCode = "TX"; //can get from state list
                oPlaceOrderInfo.CustomerBillingAddressCountryCode = "US"; //can get from country list
                oPlaceOrderInfo.CustomerBillingAddressNotes = "Optional address note: leave at front door";

                //can optionally supply a separate shipping address or just set this flag if ikt is the same as the billing address
                oPlaceOrderInfo.CustomerShippingSameAsBilling = true;

                //payment information is required unless $0 orders are allowed or you have a custom payment method that allows a non-payment order
                oPlaceOrderInfo.PaymentMethodID = 0; //0 = credit card, can get all applicable types from the web service method
                oPlaceOrderInfo.CreditCardNameOnCard = "John Doe Sr.";
                oPlaceOrderInfo.CreditCardNumber = "4444444444444441"; //with or without dashes
                //oPlaceOrderInfo.CreditCardNumber = "4111111111111111"; //with or without dashes
                oPlaceOrderInfo.CreditCardCVV = "777";
                oPlaceOrderInfo.CreditCardExpirationMonth = "12";
                oPlaceOrderInfo.CreditCardExpirationYear = "2010";

                //other info
                oPlaceOrderInfo.GiftMessage = "Happy Coding!";
                oPlaceOrderInfo.CommentsPrivate = "Private Comments: Only admins see this by default.";
                oPlaceOrderInfo.CommentsPublic = "Public: Customers and Admins can see and edit this";
                oPlaceOrderInfo.CommentsInstructions = "Instructions: Viewable but not editable by customer, admins can edit";

                //PLACE THE ORDER
                //  The final step that posts the order into the appropriate status in the AmeriCommerce system
                //  This will capture/authorize payment information and sends email confirmations
                //  Will return status and validation information in the event an error occurs or more entry is needed
                this.txtResults.Text += "Calling Order Placement:\r\n";
                ACDB.PlaceOrderResponseTrans oResponse = oWS.Cart_PlaceOrder(oSession.ID.Value, oPlaceOrderInfo);
                this.txtResults.Text += "OrderID: " + oResponse.OrderID + " Msg: " + oResponse.ResponseMessage + "\r\n";

                ACDB.OrderTrans oOrder = oWS.Order_GetByKey(oResponse.OrderID);
                this.txtResults.Text += "\r\n\r\nCustomerID: " + oOrder.customerID.Value + "\r\n";
                ACDB.CustomerTrans oCustomer = oWS.Customer_GetByKey(oOrder.customerID.Value);
                oCustomer = oWS.Customer_FillCustomerPaymentMethodCollection(oCustomer);
                var aryCustomerPaymentMethods = new System.Collections.ArrayList(oCustomer.CustomerPaymentMethodColTrans);
                foreach(ACDB.CustomerPaymentMethodTrans oPayment in aryCustomerPaymentMethods)
                    this.txtResults.Text += "PaymentMethod: " + oPayment.paymentType + " MaskedValue:" + oPayment.PaymentTypeMasked + "\r\n";

            }
            //Can now grab the order itself from the API if needed by calling Order_Get methods
        }