Exemplo n.º 1
0
        public void DefaultTaxTable_AddStateTaxRule_VerifyTaxRateSetsIsSpecified()
        {
            //create a pickup shipping method
            var request = new CheckoutShoppingCartRequest(MERCHANT_ID, MERCHANT_KEY, EnvironmentType.Sandbox, "GBP", 120);

            request.AddStateTaxRule("OH", .05, true);

            CheckoutShoppingCart roundTrip = EncodeHelper.Deserialize(EncodeHelper.Utf8BytesToString(request.GetXml()),
                                                                      typeof(CheckoutShoppingCart)) as CheckoutShoppingCart;

            var actualTaxTable = roundTrip.checkoutflowsupport.Item.taxtables.defaulttaxtable.taxrules[0];

            Assert.AreEqual(.05, actualTaxTable.rate);
            Assert.IsTrue(actualTaxTable.rateSpecified);
            Assert.IsTrue(actualTaxTable.shippingtaxed);
            Assert.AreEqual(typeof(USStateArea), actualTaxTable.taxarea.Item.GetType());
        }
Exemplo n.º 2
0
        public void VerifyTaxRateSetsIsSpecified()
        {
            //create a pickup shipping method
            var request = new CheckoutShoppingCartRequest(MERCHANT_ID, MERCHANT_KEY, EnvironmentType.Sandbox, "GBP", 120);

            request.AddPickupShippingMethod("Name", 4.95m);
            request.AddCountryTaxRule(GCheckout.AutoGen.USAreas.ALL, .05, true);
            request.AddWorldAreaTaxRule(.02, true);
            //Tax GB at 5%
            request.AddPostalAreaTaxRule("GB", .05, true);

            CheckoutShoppingCart roundTrip = EncodeHelper.Deserialize(EncodeHelper.Utf8BytesToString(request.GetXml()),
                                                                      typeof(CheckoutShoppingCart)) as CheckoutShoppingCart;

            Assert.IsTrue(roundTrip.checkoutflowsupport.Item.taxtables.defaulttaxtable.taxrules[0].rateSpecified);
            Assert.IsTrue(roundTrip.checkoutflowsupport.Item.taxtables.defaulttaxtable.taxrules[0].shippingtaxed);
            Assert.IsTrue(roundTrip.checkoutflowsupport.Item.taxtables.defaulttaxtable.taxrules[0].shippingtaxedSpecified);
        }
Exemplo n.º 3
0
    public string GetGoogleCartCode()
    {
        StringBuilder cartXML = new StringBuilder();

        Cart cart = ((BasePage)this.Page).Cart;
        CheckoutShoppingCart googleCart = new CheckoutShoppingCart();

        googleCart.shoppingcart       = new ShoppingCart();
        googleCart.shoppingcart.items = new Item[cart.CartItems.Count];

        for (int i = 0; i < googleCart.shoppingcart.items.Length; i++)
        {
            googleCart.shoppingcart.items[i] = new Item();
            googleCart.shoppingcart.items[i].merchantitemid = cart.CartItems.ElementAt(i).CatalogNumber;
            googleCart.shoppingcart.items[i].quantity       = cart.CartItems.ElementAt(i).Quantity;
            googleCart.shoppingcart.items[i].unitprice      = new Money()
            {
                Value = cart.CartItems.ElementAt(i).PricePerUnit, currency = "USD"
            };
            googleCart.shoppingcart.items[i].itemname = cart.CartItems.ElementAt(i).ProductName;
            foreach (ProductOption option in cart.CartItems.ElementAt(i).ProductOptions)
            {
                googleCart.shoppingcart.items[i].itemname        += " " + option.ProductOptionName;
                googleCart.shoppingcart.items[i].unitprice.Value += option.PriceChange;
            }
            foreach (CustomField field in cart.CartItems.ElementAt(i).CustomFields)
            {
                googleCart.shoppingcart.items[i].itemname += " " + field.CustomFieldName + ": " + field.CustomFieldValue;
            }
            googleCart.shoppingcart.items[i].itemdescription = cart.CartItems.ElementAt(i).ProductName;
        }
        googleCart.checkoutflowsupport      = new CheckoutShoppingCartCheckoutflowsupport();
        googleCart.checkoutflowsupport.Item = new MerchantCheckoutFlowSupport();
        googleCart.checkoutflowsupport.Item.shippingmethods = GetGoogleShippingMethods();

        XmlWriter     writer     = XmlWriter.Create(cartXML);
        XmlSerializer serializer = new XmlSerializer(typeof(CheckoutShoppingCart));

        serializer.Serialize(writer, googleCart);
        writer.Close();

        return(cartXML.ToString());
    }
        public void TestAlternateTaxTable_NoRules_VerifyNodeIsCreated()
        {
            //create a pickup shipping method
            var request = new CheckoutShoppingCartRequest(MERCHANT_ID, MERCHANT_KEY, EnvironmentType.Sandbox, "GBP", 120);

            var taxTable = new AlternateTaxTable("canada");

            request.AlternateTaxTables.Add(taxTable);

            CheckoutShoppingCart roundTrip = EncodeHelper.Deserialize(EncodeHelper.Utf8BytesToString(request.GetXml()),
                                                                      typeof(CheckoutShoppingCart)) as CheckoutShoppingCart;

            //Debug.WriteLine(EncodeHelper.Utf8BytesToString(request.GetXml()));

            var actualTaxTable = roundTrip.checkoutflowsupport.Item.taxtables.alternatetaxtables[0];

            Assert.IsNotNull(actualTaxTable.alternatetaxrules);
            Assert.IsTrue(actualTaxTable.alternatetaxrules.Length == 0);
        }
        public void TestAlternateTaxTable_AddWorldAreaTaxRule_VerifyTaxRateSetsIsSpecified()
        {
            //create a pickup shipping method
            var request = new CheckoutShoppingCartRequest(MERCHANT_ID, MERCHANT_KEY, EnvironmentType.Sandbox, "GBP", 120);

            var taxTable = new AlternateTaxTable("canada");

            request.AlternateTaxTables.Add(taxTable);
            taxTable.AddWorldAreaTaxRule(.05);

            CheckoutShoppingCart roundTrip = EncodeHelper.Deserialize(EncodeHelper.Utf8BytesToString(request.GetXml()),
                                                                      typeof(CheckoutShoppingCart)) as CheckoutShoppingCart;

            var actualTaxTable = roundTrip.checkoutflowsupport.Item.taxtables.alternatetaxtables[0].alternatetaxrules[0];

            Assert.AreEqual(.05, actualTaxTable.rate);
            Assert.IsTrue(actualTaxTable.rateSpecified);
            Assert.AreEqual(typeof(WorldArea), actualTaxTable.taxarea.Item.GetType());
        }