Exemplo n.º 1
0
        public void when_showing_tax_rates_for_a_location_sst()
        {
            var body = JsonConvert.DeserializeObject <RateResponse>(TaxjarFixture.GetJSON("rates_sst.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/rates/05495-2086")
                .UsingGet()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            var rates = Bootstrap.client.RatesForLocation("05495-2086");

            Assert.AreEqual("05495-2086", rates.Zip);
            Assert.AreEqual("US", rates.Country);
            Assert.AreEqual(0, rates.CountryRate);
            Assert.AreEqual("VT", rates.State);
            Assert.AreEqual(0.06, rates.StateRate);
            Assert.AreEqual("CHITTENDEN", rates.County);
            Assert.AreEqual(0, rates.CountyRate);
            Assert.AreEqual("WILLISTON", rates.City);
            Assert.AreEqual(0, rates.CityRate);
            Assert.AreEqual(0.01, rates.CombinedDistrictRate);
            Assert.AreEqual(0.07, rates.CombinedRate);
            Assert.AreEqual(true, rates.FreightTaxable);
        }
Exemplo n.º 2
0
        public void includes_appropriate_headers()
        {
            var body = JsonConvert.DeserializeObject <CategoriesResponse>(TaxjarFixture.GetJSON("categories.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/categories")
                .UsingGet()
                .WithHeader("Authorization", "*")
                .WithHeader("User-Agent", "*")
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            Bootstrap.client.Categories();

            IEnumerable <LogEntry> logs = Bootstrap.server.FindLogEntries(
                Request.Create()
                .WithPath("/v2/categories")
                .UsingGet()
                .WithHeader("Authorization", "Bearer *")
                .WithHeader("User-Agent", new RegexMatcher("^TaxJar/.NET \\(.+\\) taxjar.net/\\d+\\.\\d+\\.\\d+$"))
                );

            Assert.IsNotEmpty(logs);
        }
Exemplo n.º 3
0
        public void when_calculating_sales_tax_for_an_international_order()
        {
            var body = JsonConvert.DeserializeObject <TaxResponse>(TaxjarFixture.GetJSON("taxes_international.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/taxes")
                .UsingPost()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithBodyAsJson(body)
                );

            var rates = Bootstrap.client.TaxForOrder(new
            {
                from_country = "FI",
                from_zip     = "00150",
                to_country   = "FI",
                to_zip       = "00150",
                amount       = 16.95,
                shipping     = 10,
                line_items   = new[] {
                    new
                    {
                        quantity   = 1,
                        unit_price = 16.95
                    }
                }
            });

            Assert.AreEqual(26.95, rates.OrderTotalAmount);
            Assert.AreEqual(6.47, rates.AmountToCollect);
            Assert.AreEqual(true, rates.HasNexus);
            Assert.AreEqual(true, rates.FreightTaxable);
            Assert.AreEqual("destination", rates.TaxSource);

            // Breakdowns
            Assert.AreEqual(26.95, rates.Breakdown.TaxableAmount);
            Assert.AreEqual(6.47, rates.Breakdown.TaxCollectable);
            Assert.AreEqual(0.24, rates.Breakdown.CombinedTaxRate);
            Assert.AreEqual(26.95, rates.Breakdown.CountryTaxableAmount);
            Assert.AreEqual(0.24, rates.Breakdown.CountryTaxRate);
            Assert.AreEqual(6.47, rates.Breakdown.CountryTaxCollectable);

            Assert.AreEqual(10, rates.Breakdown.Shipping.TaxableAmount);
            Assert.AreEqual(2.4, rates.Breakdown.Shipping.TaxCollectable);
            Assert.AreEqual(0.24, rates.Breakdown.Shipping.CombinedTaxRate);
            Assert.AreEqual(10, rates.Breakdown.Shipping.CountryTaxableAmount);
            Assert.AreEqual(0.24, rates.Breakdown.Shipping.CountryTaxRate);
            Assert.AreEqual(2.4, rates.Breakdown.Shipping.CountryTaxCollectable);

            // Line Items
            Assert.AreEqual(16.95, rates.Breakdown.LineItems[0].TaxableAmount);
            Assert.AreEqual(4.07, rates.Breakdown.LineItems[0].TaxCollectable);
            Assert.AreEqual(0.24, rates.Breakdown.LineItems[0].CombinedTaxRate);
            Assert.AreEqual(16.95, rates.Breakdown.LineItems[0].CountryTaxableAmount);
            Assert.AreEqual(0.24, rates.Breakdown.LineItems[0].CountryTaxRate);
            Assert.AreEqual(4.07, rates.Breakdown.LineItems[0].CountryTaxCollectable);
        }
Exemplo n.º 4
0
        public async Task when_listing_refund_transactions_async()
        {
            var body = JsonConvert.DeserializeObject <RefundsResponse>(TaxjarFixture.GetJSON("refunds/list.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/transactions/refunds")
                .UsingGet()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            var refunds = await Bootstrap.client.ListRefundsAsync(new
            {
                from_transaction_date = "2015/05/01",
                to_transaction_date   = "2015/05/31",
                provider = "api"
            });

            Assert.AreEqual("321", refunds[0]);
            Assert.AreEqual("654", refunds[1]);
        }
Exemplo n.º 5
0
        public void when_updating_an_order_transaction_with_missing_transaction_id()
        {
            var body = JsonConvert.DeserializeObject <OrderResponse>(TaxjarFixture.GetJSON("orders/show.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/transactions/orders/123")
                .UsingPut()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithBodyAsJson(body)
                );

            var systemException = Assert.Throws <ArgumentException>(() => Bootstrap.client.UpdateOrder(new
            {
                amount         = 17.95,
                shipping       = 2,
                exemption_type = "non_exempt",
                line_items     = new[] {
                    new {
                        quantity           = 1,
                        product_identifier = "12-34243-0",
                        description        = "Heavy Widget",
                        product_tax_code   = "20010",
                        unit_price         = 15,
                        discount           = 0,
                        sales_tax          = 0.95
                    }
                }
            }));

            Assert.AreEqual(ErrorMessage.MissingTransactionId, systemException.Message);
        }
Exemplo n.º 6
0
        public void when_updating_an_order_transaction()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Put("/v2/transactions/orders/123"))
            .Return(TaxjarFixture.GetJSON("orders/show.json"))
            .OK();

            var order = client.UpdateOrder(new
            {
                transaction_id = "123",
                amount         = 17.95,
                shipping       = 2,
                line_items     = new[] {
                    new {
                        quantity           = 1,
                        product_identifier = "12-34243-0",
                        description        = "Heavy Widget",
                        unit_price         = 15,
                        discount           = 0,
                        sales_tax          = 0.95
                    }
                }
            });

            this.AssertOrder(order);
        }
Exemplo n.º 7
0
        public async Task when_showing_tax_rates_for_a_location_async()
        {
            var body = JsonConvert.DeserializeObject <RateResponse>(TaxjarFixture.GetJSON("rates.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/rates/90002")
                .UsingGet()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            var rates = await Bootstrap.client.RatesForLocationAsync("90002");

            Assert.AreEqual("90002", rates.Zip);
            Assert.AreEqual("CA", rates.State);
            Assert.AreEqual(0.065, rates.StateRate);
            Assert.AreEqual("LOS ANGELES", rates.County);
            Assert.AreEqual(0.01, rates.CountyRate);
            Assert.AreEqual("WATTS", rates.City);
            Assert.AreEqual(0, rates.CityRate);
            Assert.AreEqual(0.015, rates.CombinedDistrictRate);
            Assert.AreEqual(0.09, rates.CombinedRate);
            Assert.AreEqual(false, rates.FreightTaxable);
        }
Exemplo n.º 8
0
        public void when_updating_a_refund_transaction()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Put("/v2/transactions/refunds/321"))
            .Return(TaxjarFixture.GetJSON("refunds/show.json"))
            .OK();

            var refund = client.UpdateRefund(new
            {
                transaction_id = "321",
                amount         = 17.95,
                shipping       = 2,
                line_items     = new[] {
                    new {
                        quantity           = 1,
                        product_identifier = "12-34243-0",
                        description        = "Heavy Widget",
                        product_tax_code   = "20010",
                        unit_price         = 15,
                        discount           = 0,
                        sales_tax          = 0.95
                    }
                }
            });

            this.AssertRefund(refund);
        }
Exemplo n.º 9
0
        public void when_updating_an_order_transaction()
        {
            var body = JsonConvert.DeserializeObject <OrderResponse>(TaxjarFixture.GetJSON("orders/show.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/transactions/orders/123")
                .UsingPut()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            var order = Bootstrap.client.UpdateOrder(new
            {
                transaction_id = "123",
                amount         = 17.95,
                shipping       = 2,
                line_items     = new[] {
                    new {
                        quantity           = 1,
                        product_identifier = "12-34243-0",
                        description        = "Heavy Widget",
                        product_tax_code   = "20010",
                        unit_price         = 15,
                        discount           = 0,
                        sales_tax          = 0.95
                    }
                }
            });

            AssertOrder(order);
        }
Exemplo n.º 10
0
        public void when_updating_a_customer_with_missing_customer_id()
        {
            var body = JsonConvert.DeserializeObject <CustomerResponse>(TaxjarFixture.GetJSON("customers/show.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/customers/123")
                .UsingPut()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithBodyAsJson(body)
                );

            var systemException = Assert.Throws <Exception>(() => Bootstrap.client.UpdateCustomer(new
            {
                exemption_type = "wholesale",
                name           = "Sterling Cooper",
                exempt_regions = new[] {
                    new {
                        country = "US",
                        state   = "NY"
                    }
                },
                country = "US",
                state   = "NY",
                zip     = "10010",
                city    = "New York",
                street  = "405 Madison Ave"
            }));

            Assert.AreEqual("Missing customer ID for `UpdateCustomer`", systemException.Message);
        }
Exemplo n.º 11
0
        public async Task when_validating_an_address_async()
        {
            var body = JsonConvert.DeserializeObject <AddressValidationResponse>(TaxjarFixture.GetJSON("addresses.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/addresses/validate")
                .UsingPost()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            var addresses = await Bootstrap.client.ValidateAddressAsync(new
            {
                country = "US",
                state   = "AZ",
                zip     = "85297",
                city    = "Gilbert",
                street  = "3301 South Greenfield Rd"
            });

            Assert.AreEqual("85297-2176", addresses[0].Zip);
            Assert.AreEqual("3301 S Greenfield Rd", addresses[0].Street);
            Assert.AreEqual("AZ", addresses[0].State);
            Assert.AreEqual("US", addresses[0].Country);
            Assert.AreEqual("Gilbert", addresses[0].City);
        }
Exemplo n.º 12
0
        public async Task when_summarizing_tax_rates_for_all_regions_async()
        {
            var body = JsonConvert.DeserializeObject <SummaryRatesResponse>(TaxjarFixture.GetJSON("summary_rates.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/summary_rates")
                .UsingGet()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            var summaryRates = await Bootstrap.client.SummaryRatesAsync();

            Assert.AreEqual(3, summaryRates.Count);
            Assert.AreEqual("US", summaryRates[0].CountryCode);
            Assert.AreEqual("United States", summaryRates[0].Country);
            Assert.AreEqual("CA", summaryRates[0].RegionCode);
            Assert.AreEqual("California", summaryRates[0].Region);
            Assert.AreEqual("State Tax", summaryRates[0].MinimumRate.Label);
            Assert.AreEqual(0.065, summaryRates[0].MinimumRate.Rate);
            Assert.AreEqual("Tax", summaryRates[0].AverageRate.Label);
            Assert.AreEqual(0.0827, summaryRates[0].AverageRate.Rate);
        }
Exemplo n.º 13
0
        public void when_validating_an_address_with_multiple_matches()
        {
            var body = JsonConvert.DeserializeObject <AddressValidationResponse>(TaxjarFixture.GetJSON("addresses_multiple.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/addresses/validate")
                .UsingPost()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            var addresses = Bootstrap.client.ValidateAddress(new
            {
                state  = "AZ",
                city   = "Phoenix",
                street = "1109 9th"
            });

            Assert.AreEqual("85007-3646", addresses[0].Zip);
            Assert.AreEqual("1109 S 9th Ave", addresses[0].Street);
            Assert.AreEqual("AZ", addresses[0].State);
            Assert.AreEqual("US", addresses[0].Country);
            Assert.AreEqual("Phoenix", addresses[0].City);

            Assert.AreEqual("85006-2734", addresses[1].Zip);
            Assert.AreEqual("1109 N 9th St", addresses[1].Street);
            Assert.AreEqual("AZ", addresses[1].State);
            Assert.AreEqual("US", addresses[1].Country);
            Assert.AreEqual("Phoenix", addresses[1].City);
        }
Exemplo n.º 14
0
        public void when_updating_a_refund_transaction_with_missing_transaction_id()
        {
            var body = JsonConvert.DeserializeObject <RefundResponse>(TaxjarFixture.GetJSON("refunds/show.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/transactions/refunds/321")
                .UsingPut()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.Created)
                .WithBodyAsJson(body)
                );

            var systemException = Assert.Throws <Exception>(() => Bootstrap.client.UpdateRefund(new
            {
                amount     = 17.95,
                shipping   = 2,
                line_items = new[] {
                    new {
                        quantity           = 1,
                        product_identifier = "12-34243-0",
                        description        = "Heavy Widget",
                        product_tax_code   = "20010",
                        unit_price         = 15,
                        discount           = 0,
                        sales_tax          = 0.95
                    }
                }
            }));

            Assert.AreEqual("Missing transaction ID for `UpdateRefund`", systemException.Message);
        }
Exemplo n.º 15
0
        public async Task when_validating_a_vat_number_async()
        {
            var body = JsonConvert.DeserializeObject <ValidationResponse>(TaxjarFixture.GetJSON("validation.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/validation")
                .UsingGet()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            var validation = await Bootstrap.client.ValidateVatAsync(new
            {
                vat = "FR40303265045"
            });

            Assert.AreEqual(true, validation.Valid);
            Assert.AreEqual(true, validation.Exists);
            Assert.AreEqual(true, validation.ViesAvailable);
            Assert.AreEqual("FR", validation.ViesResponse.CountryCode);
            Assert.AreEqual("40303265045", validation.ViesResponse.VatNumber);
            Assert.AreEqual("2016-02-10", validation.ViesResponse.RequestDate);
            Assert.AreEqual(true, validation.ViesResponse.Valid);
            Assert.AreEqual("SA SODIMAS", validation.ViesResponse.Name);
            Assert.AreEqual("11 RUE AMPEREn26600 PONT DE L ISERE", validation.ViesResponse.Address);
        }
Exemplo n.º 16
0
        public async Task when_updating_a_refund_transaction_async()
        {
            var body = JsonConvert.DeserializeObject <RefundResponse>(TaxjarFixture.GetJSON("refunds/show.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/transactions/refunds/321")
                .UsingPut()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.Created)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            var refund = await Bootstrap.client.UpdateRefundAsync(new
            {
                transaction_id = "321",
                amount         = 17.95,
                shipping       = 2,
                line_items     = new[] {
                    new {
                        quantity           = 1,
                        product_identifier = "12-34243-0",
                        description        = "Heavy Widget",
                        product_tax_code   = "20010",
                        unit_price         = 15,
                        discount           = 0,
                        sales_tax          = 0.95
                    }
                }
            });

            AssertRefund(refund);
        }
Exemplo n.º 17
0
        public void when_updating_a_customer()
        {
            var body = JsonConvert.DeserializeObject <CustomerResponse>(TaxjarFixture.GetJSON("customers/show.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/customers/123")
                .UsingPut()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithBodyAsJson(body)
                );

            var customer = Bootstrap.client.UpdateCustomer(new
            {
                customer_id    = "123",
                exemption_type = "wholesale",
                name           = "Sterling Cooper",
                exempt_regions = new[] {
                    new {
                        country = "US",
                        state   = "NY"
                    }
                },
                country = "US",
                state   = "NY",
                zip     = "10010",
                city    = "New York",
                street  = "405 Madison Ave"
            });

            AssertCustomer(customer);
        }
Exemplo n.º 18
0
        public void when_creating_a_refund_transaction()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Post("/v2/transactions/refunds"))
            .Return(TaxjarFixture.GetJSON("refunds/show.json"))
            .WithStatus(HttpStatusCode.Created);

            var refund = client.CreateRefund(new
            {
                transaction_id           = "321",
                transaction_date         = "2015/05/04",
                transaction_reference_id = "123",
                to_country = "US",
                to_zip     = "90002",
                to_city    = "Los Angeles",
                to_street  = "123 Palm Grove Ln",
                amount     = 17.95,
                shipping   = 2,
                sales_tax  = 0.95,
                line_items = new[] {
                    new {
                        quantity           = 1,
                        product_identifier = "12-34243-0",
                        description        = "Heavy Widget",
                        product_tax_code   = "20010",
                        unit_price         = 15,
                        sales_tax          = 0.95
                    }
                }
            });

            this.AssertRefund(refund);
        }
Exemplo n.º 19
0
        public void when_showing_tax_rates_for_a_location_eu()
        {
            var body = JsonConvert.DeserializeObject <RateResponse>(TaxjarFixture.GetJSON("rates_eu.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/rates/00150")
                .UsingGet()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithHeader("Content-Type", "application/json")
                .WithBodyAsJson(body)
                );

            var rates = Bootstrap.client.RatesForLocation("00150");

            Assert.AreEqual("FI", rates.Country);
            Assert.AreEqual("Finland", rates.Name);
            Assert.AreEqual(0.24, rates.StandardRate);
            Assert.AreEqual(0, rates.ReducedRate);
            Assert.AreEqual(0, rates.SuperReducedRate);
            Assert.AreEqual(0, rates.ParkingRate);
            Assert.AreEqual(0, rates.DistanceSaleThreshold);
            Assert.AreEqual(true, rates.FreightTaxable);
        }
Exemplo n.º 20
0
        public void when_calculating_sales_tax_for_an_international_order()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Post("/v2/taxes"))
            .Return(TaxjarFixture.GetJSON("taxes_international.json"))
            .OK();

            var rates = client.TaxForOrder(new
            {
                from_country = "FI",
                from_zip     = "00150",
                to_country   = "FI",
                to_zip       = "00150",
                amount       = 16.95,
                shipping     = 10,
                line_items   = new[] {
                    new
                    {
                        quantity   = 1,
                        unit_price = 16.95
                    }
                }
            });

            Assert.AreEqual(26.95, rates.OrderTotalAmount);
            Assert.AreEqual(6.47, rates.AmountToCollect);
            Assert.AreEqual(true, rates.HasNexus);
            Assert.AreEqual(true, rates.FreightTaxable);
            Assert.AreEqual("destination", rates.TaxSource);

            // Breakdowns
            Assert.AreEqual(26.95, rates.Breakdown.TaxableAmount);
            Assert.AreEqual(6.47, rates.Breakdown.TaxCollectable);
            Assert.AreEqual(0.24, rates.Breakdown.CombinedTaxRate);
            Assert.AreEqual(26.95, rates.Breakdown.CountryTaxableAmount);
            Assert.AreEqual(0.24, rates.Breakdown.CountryTaxRate);
            Assert.AreEqual(6.47, rates.Breakdown.CountryTaxCollectable);

            Assert.AreEqual(10, rates.Breakdown.Shipping.TaxableAmount);
            Assert.AreEqual(2.4, rates.Breakdown.Shipping.TaxCollectable);
            Assert.AreEqual(0.24, rates.Breakdown.Shipping.CombinedTaxRate);
            Assert.AreEqual(10, rates.Breakdown.Shipping.CountryTaxableAmount);
            Assert.AreEqual(0.24, rates.Breakdown.Shipping.CountryTaxRate);
            Assert.AreEqual(2.4, rates.Breakdown.Shipping.CountryTaxCollectable);

            // Line Items
            Assert.AreEqual(16.95, rates.Breakdown.LineItems[0].TaxableAmount);
            Assert.AreEqual(4.07, rates.Breakdown.LineItems[0].TaxCollectable);
            Assert.AreEqual(0.24, rates.Breakdown.LineItems[0].CombinedTaxRate);
            Assert.AreEqual(16.95, rates.Breakdown.LineItems[0].CountryTaxableAmount);
            Assert.AreEqual(0.24, rates.Breakdown.LineItems[0].CountryTaxRate);
            Assert.AreEqual(4.07, rates.Breakdown.LineItems[0].CountryTaxCollectable);
        }
Exemplo n.º 21
0
        public void when_deleting_a_refund_transaction()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Delete("/v2/transactions/refunds/321"))
            .Return(TaxjarFixture.GetJSON("refunds/delete.json"))
            .OK();

            var refund = client.DeleteRefund("321");

            this.AssertDeletedRefund(refund);
        }
Exemplo n.º 22
0
        public void when_deleting_an_order_transaction()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Delete("/v2/transactions/orders/123"))
            .Return(TaxjarFixture.GetJSON("orders/delete.json"))
            .OK();

            var order = client.DeleteOrder("123");

            this.AssertDeletedOrder(order);
        }
Exemplo n.º 23
0
        public void when_listing_tax_categories()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Get("/v2/categories"))
            .Return(TaxjarFixture.GetJSON("categories.json"))
            .OK();

            var categories = client.Categories();

            Assert.AreEqual(7, categories.Count);
            Assert.AreEqual("Digital Goods", categories[0].Name);
            Assert.AreEqual("31000", categories[0].ProductTaxCode);
            Assert.AreEqual("Digital products transferred electronically, meaning obtained by the purchaser by means other than tangible storage media.", categories[0].Description);
        }
Exemplo n.º 24
0
        public void when_showing_tax_rates_for_a_location_au()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Get("/v2/rates/2060"))
            .Return(TaxjarFixture.GetJSON("rates_au.json"))
            .OK();

            var rates = client.RatesForLocation("2060");

            Assert.AreEqual("2060", rates.Zip);
            Assert.AreEqual("AU", rates.Country);
            Assert.AreEqual(0.1, rates.CountryRate);
            Assert.AreEqual(0.1, rates.CombinedRate);
            Assert.AreEqual(true, rates.FreightTaxable);
        }
Exemplo n.º 25
0
        public void when_listing_nexus_regions()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Get("/v2/nexus/regions"))
            .Return(TaxjarFixture.GetJSON("nexus_regions.json"))
            .OK();

            var nexusRegions = client.NexusRegions();

            Assert.AreEqual(3, nexusRegions.Count);
            Assert.AreEqual("US", nexusRegions[0].CountryCode);
            Assert.AreEqual("United States", nexusRegions[0].Country);
            Assert.AreEqual("CA", nexusRegions[0].RegionCode);
            Assert.AreEqual("California", nexusRegions[0].Region);
        }
Exemplo n.º 26
0
        public void when_listing_order_transactions()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Get("/v2/transactions/orders"))
            .Return(TaxjarFixture.GetJSON("orders/list.json"))
            .OK();

            var orders = client.ListOrders(new {
                from_transaction_date = "2015/05/01",
                to_transaction_date   = "2015/05/31"
            });

            Assert.AreEqual("123", orders[0]);
            Assert.AreEqual("456", orders[1]);
        }
Exemplo n.º 27
0
        public void when_showing_tax_rates_for_a_location_ca()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Get("/v2/rates/V5K0A1"))
            .Return(TaxjarFixture.GetJSON("rates_ca.json"))
            .OK();

            var rates = client.RatesForLocation("V5K0A1");

            Assert.AreEqual("V5K0A1", rates.Zip);
            Assert.AreEqual("Vancouver", rates.City);
            Assert.AreEqual("BC", rates.State);
            Assert.AreEqual("CA", rates.Country);
            Assert.AreEqual(0.12, rates.CombinedRate);
            Assert.AreEqual(true, rates.FreightTaxable);
        }
Exemplo n.º 28
0
        public void when_listing_refund_transactions()
        {
            var stubHttp = HttpMockRepository.At("http://localhost:9191");

            stubHttp.Stub(x => x.Get("/v2/transactions/refunds"))
            .Return(TaxjarFixture.GetJSON("refunds/list.json"))
            .OK();

            var refunds = client.ListRefunds(new
            {
                from_transaction_date = "2015/05/01",
                to_transaction_date   = "2015/05/31"
            });

            Assert.AreEqual("321", refunds[0]);
            Assert.AreEqual("654", refunds[1]);
        }
Exemplo n.º 29
0
        public void when_showing_a_refund_transaction()
        {
            var body = JsonConvert.DeserializeObject <RefundResponse>(TaxjarFixture.GetJSON("refunds/show.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/transactions/refunds/321")
                .UsingGet()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithBodyAsJson(body)
                );

            var refund = Bootstrap.client.ShowRefund("321");

            AssertRefund(refund);
        }
Exemplo n.º 30
0
        public void when_showing_an_order_transaction()
        {
            var body = JsonConvert.DeserializeObject <CustomerResponse>(TaxjarFixture.GetJSON("customers/show.json"));

            Bootstrap.server.Given(
                Request.Create()
                .WithPath("/v2/customers/123")
                .UsingGet()
                ).RespondWith(
                Response.Create()
                .WithStatusCode(200)
                .WithBodyAsJson(body)
                );

            var customer = Bootstrap.client.ShowCustomer("123");

            AssertCustomer(customer);
        }