Ejemplo n.º 1
0
        public void GetTaxCalculationGoodRequestTest()
        {
            string apikey = "5da2f821eee4035db4771edab942a4cc";

            TaxJarCalculationRequest jarCalculationRequest = new TaxJarCalculationRequest
            {
                from_country    = "US",
                from_zip        = "92093",
                from_state      = "CA",
                from_city       = "La Jolla",
                from_street     = "9500 Gilman Drive",
                to_country      = "US",
                to_zip          = "90002",
                to_state        = "CA",
                to_city         = "Los Angeles",
                to_street       = "1335 E 103rd St",
                amount          = 15,
                shipping        = 1.5F,
                nexus_addresses = new List <TaxJarAddress> {
                    new TaxJarAddress {
                        id      = "Main Location",
                        country = "US",
                        zip     = "92093",
                        state   = "CA",
                        city    = "La Jolla",
                        street  = "9500 Gilman Drive",
                    }
                },
                line_items = new List <TaxJarLineItem> {
                    new TaxJarLineItem {
                        id               = "1",
                        quantity         = 1,
                        product_tax_code = "20010",
                        unit_price       = 15,
                        discount         = 0
                    }
                }
            };

            Calculators.TaxJar taxJar = new Calculators.TaxJar(apikey, "https://api.taxjar.com/v2/taxes", "");
            using (var service = Factory.GetTaxService(taxJar))
            {
                try
                {
                    TaxJarCalculationResponse result2 = service.GetTaxCalculationForOrder(jarCalculationRequest);
                    Assert.IsNotNull(result2);
                }
                catch (Exception ex)
                {
                    Assert.Fail(ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public void GetTaxCalculationNullCalculatorTest()
        {
            TaxJarCalculationRequest jarCalculationRequest = new TaxJarCalculationRequest
            {
                from_country    = "US",
                from_zip        = "92093",
                from_state      = "CA",
                from_city       = "La Jolla",
                from_street     = "9500 Gilman Drive",
                to_country      = "US",
                to_zip          = "90002",
                to_state        = "CA",
                to_city         = "Los Angeles",
                to_street       = "1335 E 103rd St",
                amount          = 15,
                shipping        = 1.5F,
                nexus_addresses = new List <TaxJarAddress> {
                    new TaxJarAddress {
                        id      = "Main Location",
                        country = "US",
                        zip     = "92093",
                        state   = "CA",
                        city    = "La Jolla",
                        street  = "9500 Gilman Drive",
                    }
                },
                line_items = new List <TaxJarLineItem> {
                    new TaxJarLineItem {
                        id               = "1",
                        quantity         = 1,
                        product_tax_code = "20010",
                        unit_price       = 15,
                        discount         = 0
                    }
                }
            };

            Calculators.TaxJar taxJar = null;
            using (var service = Factory.GetTaxService(taxJar))
            {
                try
                {
                    TaxJarCalculationResponse result2 = service.GetTaxCalculationForOrder(jarCalculationRequest);
                    Assert.Fail("Should throw exception");
                }
                catch (Exception ex)
                {
                    Assert.IsNotNull(ex);
                }
            }
        }
Ejemplo n.º 3
0
        public void GetTaxCalculationBadCalculatorNoAPIKeyTest()
        {
            TaxJarCalculationRequest jarCalculationRequest = new TaxJarCalculationRequest
            {
                from_country    = "US",
                from_zip        = "92093",
                from_state      = "CA",
                from_city       = "La Jolla",
                from_street     = "9500 Gilman Drive",
                to_country      = "US",
                to_zip          = "90002",
                to_state        = "CA",
                to_city         = "Los Angeles",
                to_street       = "1335 E 103rd St",
                amount          = 15,
                shipping        = 1.5F,
                nexus_addresses = new List <TaxJarAddress> {
                    new TaxJarAddress {
                        id      = "Main Location",
                        country = "US",
                        zip     = "92093",
                        state   = "CA",
                        city    = "La Jolla",
                        street  = "9500 Gilman Drive",
                    }
                },
                line_items = new List <TaxJarLineItem> {
                    new TaxJarLineItem {
                        id               = "1",
                        quantity         = 1,
                        product_tax_code = "20010",
                        unit_price       = 15,
                        discount         = 0
                    }
                }
            };

            Calculators.TaxJar taxJar = new Calculators.TaxJar("", "https://api.taxjar.com/v2/taxes", "");
            try
            {
                TaxJarCalculationResponse result2 = taxJar.CalculateTaxForOrder(jarCalculationRequest);
                Assert.Fail("Should throw exception");
            }
            catch (Exception ex)
            {
                Assert.IsNotNull(ex);
            }
        }
Ejemplo n.º 4
0
        private static void RunTaxJarSample()
        {
            string            taxRateApiendpoint = "https://api.taxjar.com/v2/rates";
            string            apikey             = "5da2f821eee4035db4771edab942a4cc";
            TaxJarRateRequest taxRateRequest     = new TaxJarRateRequest
            {
                Street  = "312 Hurricane Lane",
                City    = "Williston",
                State   = "VT",
                Country = "US",
                Zip     = "05495-2086"
            };

            TaxJarCalculationRequest jarCalculationRequest = new TaxJarCalculationRequest
            {
                from_country    = "US",
                from_zip        = "92093",
                from_state      = "CA",
                from_city       = "La Jolla",
                from_street     = "9500 Gilman Drive",
                to_country      = "US",
                to_zip          = "90002",
                to_state        = "CA",
                to_city         = "Los Angeles",
                to_street       = "1335 E 103rd St",
                amount          = 15,
                shipping        = 1.5F,
                nexus_addresses = new System.Collections.Generic.List <TaxJarAddress> {
                    new TaxJarAddress {
                        id      = "Main Location",
                        country = "US",
                        zip     = "92093",
                        state   = "CA",
                        city    = "La Jolla",
                        street  = "9500 Gilman Drive",
                    }
                },
                line_items = new System.Collections.Generic.List <TaxJarLineItem> {
                    new TaxJarLineItem {
                        id               = "1",
                        quantity         = 1,
                        product_tax_code = "20010",
                        unit_price       = 15,
                        discount         = 0
                    }
                }
            };

            TaxCalculationLibrary.Calculators.TaxJar taxJar = new TaxCalculationLibrary.Calculators.TaxJar(apikey, "https://api.taxjar.com/v2/taxes", taxRateApiendpoint);
            using (var service = TaxCalculationLibrary.Service.Factory.GetTaxService(taxJar))
            {
                try
                {
                    Console.WriteLine(service.GetTaxRate(taxRateRequest).Jsonify());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                try
                {
                    Console.WriteLine(service.GetTaxCalculationForOrder(jarCalculationRequest).Jsonify());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }