Giter Club home page Giter Club logo

taxjar-ruby's Introduction

TaxJar Sales Tax API for Ruby RubyGems Build Status

TaxJar

A Ruby interface to the TaxJar Sales Tax API. TaxJar makes sales tax filing easier for online sellers and merchants. See local jurisdictional tax reports, get payment reminders, and more. You can use our API to access TaxJar API endpoints, which can get information on sales tax rates, categories or upload transactions.

  • This wrapper supports 100% of the TaxJar API
  • Data returned from API calls are mapped to Ruby objects

Supported Ruby Versions
Gem Dependencies
Installation
Authentication
Usage
Custom Options
Sandbox Environment
Error Handling
Tests
More Information
License
Support
Contributing


Supported Ruby Versions

Ruby 2.3 or greater

Gem Dependencies

Installing this gem also bundles the following dependencies:

  • http - Fast Ruby HTTP client with a chainable API and full streaming support.
  • addressable - Replacement for the URI implementation that is part of Ruby's standard library. It more closely conforms to the relevant RFCs and adds support for IRIs and URI templates.
  • memoizable - Memoize method return values.
  • model_attribute - Type casted attributes for non-ActiveRecord models.

Installation

Add this line to your application's Gemfile:

gem 'taxjar-ruby', require: 'taxjar'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install taxjar-ruby

Authentication

Generate an API token from TaxJar. Copy and paste your API token when instantiating a new client:

require 'taxjar'
client = Taxjar::Client.new(api_key: 'YOUR_API_TOKEN')

You're now ready to use TaxJar! Check out our quickstart guide to get up and running quickly.

Usage

categories - List all tax categories
tax_for_order - Calculate sales tax for an order
list_orders - List order transactions
show_order - Show order transaction
create_order - Create order transaction
update_order - Update order transaction
delete_order - Delete order transaction
list_refunds - List refund transactions
show_refund - Show refund transaction
create_refund - Create refund transaction
update_refund - Update refund transaction
delete_refund - Delete refund transaction
list_customers - List customers
show_customer - Show customer
create_customer - Create customer
update_customer - Update customer
delete_customer - Delete customer
rates_for_location - List tax rates for a location (by zip/postal code)
nexus_regions - List nexus regions
validate_address - Validate an address
validate - Validate a VAT number
summary_rates - Summarize tax rates for all regions


List all tax categories (API docs)

The TaxJar API provides product-level tax rules for a subset of product categories. These categories are to be used for products that are either exempt from sales tax in some jurisdictions or are taxed at reduced rates. You need not pass in a product tax code for sales tax calculations on product that is fully taxable. Simply leave that parameter out.

Definition

client.categories

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.categories

Example Response

[
  #<Taxjar::Category:0x00000a @attrs={
    :name => 'Digital Goods',
    :product_tax_code => 31000,
    :description => 'Digital products transferred electronically.'
  }>,
  #<Taxjar::Category:0x00000a @attrs={
    :name => 'Clothing',
    :product_tax_code => 20010,
    :description => 'All human wearing apparel suitable for general use'
  }>,
  #<Taxjar::Category:0x00000a @attrs={
    :name => 'Non-Prescription',
    :product_tax_code => 51010,
    :description => 'Drugs for human use without a prescription'
  }>
]

Calculate sales tax for an order (API docs)

Shows the sales tax that should be collected for a given order.

Definition

client.tax_for_order

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.tax_for_order({
    :from_country => 'US',
    :from_zip => '94025',
    :from_state => 'CA',
    :from_city => 'Menlo Park',
    :from_street => '2825 Sand Hill Rd',
    :to_country => 'US',
    :to_zip => '94303',
    :to_state => 'CA',
    :to_city => 'Palo Alto',
    :to_street => '5230 Newell Road',
    :amount => 267.9,
    :shipping => 0,
    :nexus_addresses => [{:country => 'US',
                          :state => 'CA'}],
    :line_items => [{:id => '1',
                     :quantity => 1,
                     :product_tax_code => '19005',
                     :unit_price => 535.8,
                     :discount => 267.9}]
})

Example Response

#<Taxjar::Tax:0x00000a @attrs={
  :taxable_amount => 0,
  :tax_source => 'destination',
  :shipping => 0,
  :rate => 0,
  :order_total_amount => 267.9
  :jurisdictions => #<Taxjar::Jurisdictions:0x00000a @attrs={
    :state => 'CA',
    :county => 'SAN MATEO',
    :country => 'US',
    :city => 'EAST PALO ALTO'
  }>,
  :has_nexus => true,
  :freight_taxable => false,
  :breakdown => #<Taxjar::Breakdown:0x00000a @attrs={
    :taxable_amount => 0,
    :tax_collectable => 0,
    :state_taxable_amount => 0,
    :state_tax_rate => 0,
    :state_tax_collectable => 0,
    :special_tax_rate => 0,
    :special_district_taxable_amount => 0,
    :special_district_tax_collectable => 0,
    :line_items => [
      #<Taxjar::BreakdownLineItem:0x00000a @attrs={
        :taxable_amount => 0,
        :tax_collectable => 0,
        :state_taxable_amount => 0,
        :state_sales_tax_rate => 0,
        :state_amount => 0,
        :special_tax_rate => 0,
        :special_district_taxable_amount => 0,
        :special_district_amount => 0,
        :id => '1',
        :county_taxable_amount => 0,
        :county_tax_rate => 0,
        :county_amount => 0,
        :combined_tax_rate => 0,
        :city_taxable_amount => 0,
        :city_tax_rate => 0,
        :city_amount => 0,
      }>
    ],
    :county_taxable_amount => 0,
    :county_tax_rate => 0,
    :county_tax_collectable => 0,
    :combined_tax_rate => 0,
    :city_taxable_amount => 0,
    :city_tax_rate => 0,
    :city_tax_collectable => 0
  }>
  :amount_to_collect => 0
}>

List order transactions (API docs)

Lists existing order transactions created through the API.

Definition

client.list_orders

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.list_orders({:from_transaction_date => '2015/05/01',
                    :to_transaction_date => '2015/05/31'})

Example Response

['20', '21', '22']

Show order transaction (API docs)

Shows an existing order transaction created through the API.

Definition

client.show_order

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.show_order('123')

Example Response

#<Taxjar::Order:0x00000a @attrs={
  :transaction_id => '123',
  :user_id => 11836,
  :transaction_date => '2015-05-14T00:00:00Z',
  :transaction_reference_id => nil,
  :from_country => 'US',
  :from_zip => '93107',
  :from_state => 'CA',
  :from_city => 'SANTA BARBARA',
  :from_street => '1281 State St',
  :to_country => 'US',
  :to_zip => '90002',
  :to_state => 'CA',
  :to_city => 'LOS ANGELES',
  :to_street => '123 Palm Grove Ln',
  :amount => 17,
  :shipping => 2,
  :sales_tax => 0.95,
  :line_items => [
    {
      :id => '1',
      :quantity => 1,
      :product_identifier => '12-34243-0',
      :product_tax_code => nil,
      :description => 'Heavy Widget',
      :unit_price => 15,
      :discount => 0,
      :sales_tax => 0.95
    }
  ]
}>

Create order transaction (API docs)

Creates a new order transaction.

Definition

client.create_order

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

order = client.create_order({
    :transaction_id => '123',
    :transaction_date => '2015/05/15',
    :from_country => 'US',
    :from_zip => '94025',
    :from_state => 'CA',
    :from_city => 'Menlo Park',
    :from_street => '2825 Sand Hill Rd',
    :to_country => 'US',
    :to_zip => '94303',
    :to_state => 'CA',
    :to_city => 'Palo Alto',
    :to_street => '5230 Newell Road',
    :amount => 267.9,
    :shipping => 0,
    :sales_tax => 0,
    :line_items => [{:id => '1',
                     :quantity => 1,
                     :description => 'Legal Services',
                     :product_tax_code => '19005',
                     :unit_price => 535.8,
                     :discount => 267.9,
                     :sales_tax => 0}]
})

Example Response

#<Taxjar::Order:0x00000a @attrs={
  :transaction_id => '123',
  :user_id => 11836,
  :provider => 'api',
  :transaction_date => '2015-05-15T00:00:00Z',
  :transaction_reference_id => nil,
  :customer_id => nil,
  :exemption_type => nil,
  :from_country => 'US',
  :from_zip => '94025',
  :from_state => 'CA',
  :from_city => 'MENLO PARK',
  :from_street => '2825 Sand Hill Rd',
  :to_country => 'US',
  :to_zip => '94303',
  :to_state => 'CA',
  :to_city => 'PALO ALTO',
  :to_street => '5230 Newell Rd',
  :amount => 267.9,
  :shipping => 0,
  :sales_tax => 0,
  :line_items => [
    {
      :id => '1',
      :quantity => 1,
      :product_identifier => nil,
      :product_tax_code => '19005',
      :description => 'Legal Services',
      :unit_price => 535.8,
      :discount => 267.9,
      :sales_tax => 0
    }
  ]
}>

Update order transaction (API docs)

Updates an existing order transaction created through the API.

Definition

client.update_order

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

order = client.update_order({
    :transaction_id => '123',
    :amount => 283.6,
    :shipping => 5,
    :sales_tax => 1.04,
    :line_items => [
      {
        :id => '1',
        :quantity => 1,
        :description => 'Legal Services',
        :product_tax_code => '19005',
        :unit_price => 535.8,
        :discount => 267.9,
        :sales_tax => 0
      },
      {
        :id => '2',
        :quantity => 2,
        :description => 'Hoberman Switch Pitch',
        :unit_price => 10.7,
        :discount => 10.7,
        :sales_tax => 1.04
      }
    ]
})

Example Response

#<Taxjar::Order:0x00000a @attrs={
  :transaction_id => '123',
  :user_id => 11836,
  :provider => 'api',
  :transaction_date => '2015-05-15T00:00:00Z',
  :transaction_reference_id => nil,
  :customer_id => nil,
  :exemption_type => nil,
  :from_country => 'US',
  :from_zip => '94025',
  :from_state => 'CA',
  :from_city => 'MENLO PARK',
  :from_street => '2825 Sand Hill Rd',
  :to_country => 'US',
  :to_zip => '94303',
  :to_state => 'CA',
  :to_city => 'PALO ALTO',
  :to_street => '5230 Newell Road',
  :amount => 283.6,
  :shipping => 5,
  :sales_tax => 1.04,
  :line_items => [
    {
      :id => '1',
      :quantity => 1,
      :product_identifier => nil,
      :product_tax_code => '19005',
      :description => 'Legal Services',
      :unit_price => 535.8,
      :discount => 267.9,
      :sales_tax => 0
    },
    {
      :id => '2',
      :quantity => 2,
      :product_identifier => nil,
      :product_tax_code => nil,
      :description => 'Hoberman Switch Pitch',
      :unit_price => 10.7,
      :discount => 10.7,
      :sales_tax => 1.04
    }
  ]
}>

Delete order transaction (API docs)

Deletes an existing order transaction created through the API.

Definition

client.delete_order

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.delete_order('123')

Example Response

#<Taxjar::Order:0x00000a @attrs={
  :transaction_id => '123',
  :user_id => 11836,
  :provider => 'api',
  :transaction_date => nil,
  :transaction_reference_id => nil,
  :customer_id => nil,
  :exemption_type => nil,
  :from_country => nil,
  :from_zip => nil,
  :from_state => nil,
  :from_city => nil,
  :from_street => nil,
  :to_country => nil,
  :to_zip => nil,
  :to_state => nil,
  :to_city => nil,
  :to_street => nil,
  :amount => nil,
  :shipping => nil,
  :sales_tax => nil,
  :line_items => []
}>

List refund transactions (API docs)

Lists existing refund transactions created through the API.

Definition

client.list_refunds

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.list_refunds({:from_transaction_date => '2015/05/01',
                     :to_transaction_date => '2015/05/31'})

Example Response

['20-refund', '21-refund', '22-refund']

Show refund transaction (API docs)

Shows an existing refund transaction created through the API.

Definition

client.show_refund

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.show_refund('20-refund')

Example Response

#<Taxjar::Refund:0x00000a @attrs={
  :transaction_id => '20-refund',
  :user_id => 11836,
  :provider => 'api',
  :transaction_date => '2015-05-15T00:00:00Z',
  :transaction_reference_id => '20',
  :customer_id => nil,
  :exemption_type => nil,
  :from_country => 'US',
  :from_zip => '93107',
  :from_state => 'CA',
  :from_city => 'SANTA BARBARA',
  :from_street => '1218 State St',
  :to_country => 'US',
  :to_zip => '90002',
  :to_state => 'CA',
  :to_city => 'LOS ANGELES',
  :to_street => '123 Palm Grove Ln',
  :amount => -17,
  :shipping => -2,
  :sales_tax => -0.95,
  :line_items => [
    {
      :id => '1',
      :quantity => 1,
      :product_identifier => '12-34243-0',
      :product_tax_code => nil,
      :description => 'Heavy Widget',
      :unit_price => -15,
      :discount => 0,
      :sales_tax => -0.95
    }
  ]
}>

Create refund transaction (API docs)

Creates a new refund transaction.

Definition

client.create_refund

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

refund = client.create_refund({
    :transaction_id => '123-refund',
    :transaction_reference_id => '123',
    :transaction_date => '2015/05/15',
    :from_country => 'US',
    :from_zip => '94025',
    :from_state => 'CA',
    :from_city => 'Menlo Park',
    :from_street => '2825 Sand Hill Rd',
    :to_country => 'US',
    :to_zip => '94303',
    :to_state => 'CA',
    :to_city => 'Palo Alto',
    :to_street => '5230 Newell Road',
    :amount => -5.35,
    :shipping => -0,
    :sales_tax => -0.52,
    :line_items => [
      {
        :id => '1',
        :quantity => 1,
        :description => 'Legal Services',
        :product_tax_code => '19005',
        :unit_price => -0,
        :discount => -0,
        :sales_tax => -0
      },
      {
        :id => '2',
        :quantity => 1,
        :description => 'Hoberman Switch Pitch',
        :unit_price => -0,
        :discount => -5.35,
        :sales_tax => -0.52
      }
    ]
})

Example Response

#<Taxjar::Refund:0x00000a @attrs={
  :transaction_id => '123-refund',
  :user_id => 11836,
  :provider => 'api',
  :transaction_date => '2015-05-15T00:00:00Z',
  :transaction_reference_id => '123',
  :customer_id => nil,
  :exemption_type => nil,
  :from_country => 'US',
  :from_zip => '94025',
  :from_state => 'CA',
  :from_city => 'MENLO PARK',
  :from_street => '2825 Sand Hill Rd',
  :to_country => 'US',
  :to_zip => '94303',
  :to_state => 'CA',
  :to_city => 'PALO ALTO',
  :to_street => '5230 Newell Road',
  :amount => -5.35,
  :shipping => -0,
  :sales_tax => -0.52,
  :line_items => [
    {
      :id => '1',
      :quantity => 1,
      :product_identifier => nil,
      :product_tax_code => '19005',
      :description => 'Legal Services',
      :unit_price => 0,
      :discount => 0,
      :sales_tax => 0
    },
    {
      :id => '2',
      :quantity => 1,
      :product_identifier => nil,
      :product_tax_code => nil,
      :description => 'Hoberman Switch Pitch',
      :unit_price => 0,
      :discount => -5.35,
      :sales_tax => -0.52
    }
  ]
}>

Update refund transaction (API docs)

Updates an existing refund transaction created through the API.

Definition

client.update_refund

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

refund = client.update_refund({
  :transaction_id => '123-refund',
  :transaction_reference_id => '123',
  :amount => -10.35,
  :shipping => -5
})

Example Response

#<Taxjar::Refund:0x00000a @attrs={
  :transaction_id => '123-refund',
  :user_id => 11836,
  :provider => 'api',
  :transaction_date => '2015-05-15T00:00:00Z',
  :transaction_reference_id => '123',
  :customer_id => nil,
  :exemption_type => nil,
  :from_country => 'US',
  :from_zip => '94025',
  :from_state => 'CA',
  :from_city => 'MENLO PARK',
  :from_street => '2825 Sand Hill Rd',
  :to_country => 'US',
  :to_zip => '94303',
  :to_state => 'CA',
  :to_city => 'PALO ALTO',
  :to_street => '5230 Newell Road',
  :amount => -10.35,
  :shipping => -5,
  :sales_tax => 0,
  :line_items => [
    {
      :id => '1',
      :quantity => 1,
      :product_identifier => nil,
      :product_tax_code => '19005',
      :description => 'Legal Services',
      :unit_price => 0,
      :discount => 0,
      :sales_tax => 0
    },
    {
      :id => '2',
      :quantity => 1,
      :product_identifier => nil,
      :product_tax_code => nil,
      :description => 'Hoberman Switch Pitch',
      :unit_price => 0,
      :discount => -5.35,
      :sales_tax => -0.52
    }
  ]
}>

Delete refund transaction (API docs)

Deletes an existing refund transaction created through the API.

Definition

client.delete_refund

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.delete_refund('123-refund')

Example Response

#<Taxjar::Refund:0x00000a @attrs={
  :transaction_id => '123-refund',
  :user_id => 11836,
  :provider => 'api',
  :transaction_date => nil,
  :transaction_reference_id => nil,
  :customer_id => nil,
  :exemption_type => nil,
  :from_country => nil,
  :from_zip => nil,
  :from_state => nil,
  :from_city => nil,
  :from_street => nil,
  :to_country => nil,
  :to_zip => nil,
  :to_state => nil,
  :to_city => nil,
  :to_street => nil,
  :amount => nil,
  :shipping => nil,
  :sales_tax => nil,
  :line_items => []
}>

List customers (API docs)

Lists existing customers created through the API.

Definition

client.list_customers

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.list_customers

Example Response

['123', '124', '125']

Show customer (API docs)

Shows an existing customer created through the API.

Definition

client.show_customer

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.show_customer('123')

Example Response

#<Taxjar::Customer @attrs={
  :customer_id => "123",
  :exemption_type => "wholesale",
  :exempt_regions => [
    [0] {
      :country => "US",
      :state => "FL"
    },
    [1] {
      :country => "US",
      :state => "PA"
    }
  ],
  :name => "Dunder Mifflin Paper Company",
  :country => "US",
  :state => "PA",
  :zip => "18504",
  :city => "Scranton",
  :street => "1725 Slough Avenue"
}>

Create customer (API docs)

Creates a new customer.

Definition

client.create_customer

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

customer = client.create_customer({
  :customer_id => '123',
  :exemption_type => 'wholesale',
  :name => 'Dunder Mifflin Paper Company',
  :exempt_regions => [
    {
      :country => 'US',
      :state => 'FL'
    },
    {
      :country => 'US',
      :state => 'PA'
    }
  ],
  :country => 'US',
  :state => 'PA',
  :zip => '18504',
  :city => 'Scranton',
  :street => '1725 Slough Avenue'
})

Example Response

#<Taxjar::Customer @attrs={
  :customer_id => "123",
  :exemption_type => "wholesale",
  :exempt_regions => [
    [0] {
      :country => "US",
      :state => "FL"
    },
    [1] {
      :country => "US",
      :state => "PA"
    }
  ],
  :name => "Dunder Mifflin Paper Company",
  :country => "US",
  :state => "PA",
  :zip => "18504",
  :city => "Scranton",
  :street => "1725 Slough Avenue"
}>

Update customer (API docs)

Updates an existing customer created through the API.

Definition

client.update_customer

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

customer = client.update_customer({
  :customer_id => '123',
  :exemption_type => 'wholesale',
  :name => 'Sterling Cooper',
  :exempt_regions => [
    {
      :country => 'US',
      :state => 'NY'
    }
  ],
  :country => 'US',
  :state => 'NY',
  :zip => '10010',
  :city => 'New York',
  :street => '405 Madison Ave'
})

Example Response

#<Taxjar::Customer @attrs={
  :customer_id => "123",
  :exemption_type => "wholesale",
  :exempt_regions => [
    [0] {
      :country => "US",
      :state => "NY"
    }
  ],
  :name => "Sterling Cooper",
  :country => "US",
  :state => "NY",
  :zip => "10010",
  :city => "New York",
  :street => "405 Madison Ave"
}>

Delete customer (API docs)

Deletes an existing customer created through the API.

Definition

client.delete_customer

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

client.delete_customer('123')

Example Response

#<Taxjar::Customer @attrs={
  :customer_id => "123",
  :exemption_type => "wholesale",
  :exempt_regions => [],
  :name => "Dunder Mifflin Paper Company",
  :country => "US",
  :state => "PA",
  :zip => "18504",
  :city => "Scranton",
  :street => "1725 Slough Avenue"
}>

List tax rates for a location (by zip/postal code) (API docs)

Shows the sales tax rates for a given location.

Please note this method only returns the full combined rate for a given location. It does not support nexus determination, sourcing based on a ship from and ship to address, shipping taxability, product exemptions, customer exemptions, or sales tax holidays. We recommend using tax_for_order to accurately calculate sales tax for an order.

Definition

client.rates_for_location

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')

# United States (ZIP+4)
rates = client.rates_for_location('90404-3370')

# United States (ZIP w/ Optional Params)
rates = client.rates_for_location('90404', {
  :city => 'SANTA MONICA',
  :country => 'US'
})

# International Examples (Requires City and Country)
rates = client.rates_for_location('V5K0A1', {
  :city => 'VANCOUVER',
  :country => 'CA'
})

rates = client.rates_for_location('00150', {
  :city => 'HELSINKI',
  :country => 'FI'
})

Example Response

#<Taxjar::Rate:0x00000a @attrs={
  :zip => '90002',
  :state => 'CA',
  :state_rate => 0.065,
  :county => 'LOS ANGELES',
  :county_rate => 0.01,
  :city => 'WATTS',
  :city_rate => 0,
  :combined_district_rate => 0.015,
  :combined_rate => 0.09,
  :freight_taxable => false
}>

#<Taxjar::Rate:0x00000a @attrs={
  :zip => 'V5K0A1',
  :city => 'Vancouver',
  :state => 'BC',
  :country => 'CA',
  :combined_rate => 0.12,
  :freight_taxable => true
}>

#<Taxjar::Rate:0x00000a @attrs={
  :country => 'FI',
  :name => 'Finland',
  :standard_rate => 0.24,
  :reduced_rate => nil,
  :super_reduced_rate => nil,
  :parking_rate => nil,
  :distance_sale_threshold => nil,
  :freight_taxable => true
}>

List nexus regions (API docs)

Lists existing nexus locations for a TaxJar account.

Definition

client.nexus_regions

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '9e0cd62a22f451701f29c3bde214')

nexus_regions = client.nexus_regions

Example Response

[
  #<Taxjar::NexusRegion:0x00000a @attrs={
    :country_code => 'US',
    :country => 'United States',
    :region_code => 'CA',
    :region => 'California'
  }>,
  #<Taxjar::NexusRegion:0x00000a @attrs={
    :country_code => 'US',
    :country => 'United States',
    :region_code => 'NY',
    :region => 'New York'
  }>,
  #<Taxjar::NexusRegion:0x00000a @attrs={
    :country_code => 'US',
    :country => 'United States',
    :region_code => 'WA',
    :region => 'Washington'
  }>
]

Validate an address (API docs)

Validates a customer address and returns back a collection of address matches. Address validation requires a TaxJar Professional subscription.

Definition

client.validate_address

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '9e0cd62a22f451701f29c3bde214')

addresses = client.validate_address({
  :country => 'US',
  :state => 'AZ',
  :zip => '85297',
  :city => 'Gilbert',
  :street => '3301 Greenfield Rd'
})

Example Response

[
  #<Taxjar::Address:0x00000a @attrs={
    :zip => '85297-2176',
    :street => '3301 S Greenfield Rd',
    :state => 'AZ',
    :country => 'US',
    :city => 'Gilbert'
  }>
]

Validate a VAT number (API docs)

Validates an existing VAT identification number against VIES.

Definition

client.validate

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '9e0cd62a22f451701f29c3bde214')

validation = client.validate({
  :vat => 'FR40303265045'
})

Example Response

#<Taxjar::Validation:0x00000a @attrs={
  :valid => true,
  :exists => true,
  :vies_available => true,
  :vies_response => {
    :country_code => 'FR',
    :vat_number => '40303265045',
    :request_date => '2016-02-10',
    :valid => true,
    :name => 'SA SODIMAS',
    :address => "11 RUE AMPERE\n26600 PONT DE L ISERE"
  }
}>

Summarize tax rates for all regions (API docs)

Retrieve minimum and average sales tax rates by region as a backup.

This method is useful for periodically pulling down rates to use if the TaxJar API is unavailable. However, it does not support nexus determination, sourcing based on a ship from and ship to address, shipping taxability, product exemptions, customer exemptions, or sales tax holidays. We recommend using tax_for_order to accurately calculate sales tax for an order.

Definition

client.summary_rates

Example Request

require 'taxjar'
client = Taxjar::Client.new(api_key: '9e0cd62a22f451701f29c3bde214')

summarized_rates = client.summary_rates

Example Response

[
  #<Taxjar::SummaryRate:0x00000a @attrs={
    :country_code => 'US',
    :country => 'United States',
    :region_code => 'CA',
    :region => 'California',
    :minimum_rate => {
      :label => 'State Tax',
      :rate => 0.065
    },
    :average_rate => {
      :label => 'Tax',
      :rate => 0.0827
    }
  }>,
  #<Taxjar::SummaryRate:0x00000a @attrs={
    :country_code => 'CA',
    :country => 'Canada',
    :region_code => 'BC',
    :region => 'British Columbia',
    :minimum_rate => {
      :label => 'GST',
      :rate => 0.05
    },
    :average_rate => {
      :label => 'PST',
      :rate => 0.12
    }
  }>,
  #<Taxjar::SummaryRate:0x00000a @attrs={
    :country_code => 'UK',
    :country => 'United Kingdom',
    :region_code => nil,
    :region => nil,
    :minimum_rate => {
      :label => 'VAT',
      :rate => 0.2
    },
    :average_rate => {
      :label => 'VAT',
      :rate => 0.2
    }
  }>
]

Custom Options

Pass a hash to any API method above for the following options:

Timeouts

Set request timeout in seconds:

client.tax_for_order({ timeout: 30 })

Sandbox Environment

You can easily configure the client to use the TaxJar Sandbox:

require 'taxjar'
client = Taxjar::Client.new(api_key: 'YOUR_SANDBOX_API_TOKEN', api_url: 'https://api.sandbox.taxjar.com')

For testing specific error response codes, pass the custom X-TJ-Expected-Response header:

client.set_api_config('headers', {
  'X-TJ-Expected-Response' => 422
})

Error Handling

When invalid data is sent to TaxJar or we encounter an error, weโ€™ll throw a Taxjar::Error with the HTTP status code and error message. To catch these exceptions, refer to the example below. Click here for a list of common error response classes.

require 'taxjar'
client = Taxjar::Client.new(api_key: '9e0cd62a22f451701f29c3bde214')

begin
  order = client.create_order({
    :transaction_date => '2015/05/14',
    :to_country => 'US',
    :to_state => 'CA',
    :to_zip => '90002',
    :amount => 17.45,
    :shipping => 1.5,
    :sales_tax => 0.95
  })
rescue Taxjar::Error => e
  # <Taxjar::Error::NotAcceptable: transaction_id is missing>
  puts e.class.name
  puts e.message
end

Tests

An RSpec test suite is available to ensure API functionality:

$ git clone git://github.com/taxjar/taxjar-ruby.git
$ bundle install
$ rspec

More Information

More information can be found on TaxJar Developers.

License

TaxJar is released under the MIT License.

Support

Bug reports and feature requests should be filed on the GitHub issue tracking page.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new pull request

taxjar-ruby's People

Contributors

deremer avatar fastdivision avatar flapjackfritz avatar florianroesler avatar francescoaiello01 avatar kjrocker avatar leonyip avatar mfichman avatar milboj avatar poops avatar prsimp avatar scottrudiger avatar tonkapark avatar viraptor avatar yjukaku avatar zanker-stripe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

taxjar-ruby's Issues

Dependancy on http 1.0.4

Hi,

We are using the component and we are wondering what caused the revert in the HTTP gem versions.

Namely 2e784c8 and then bcfc4ad after a failed CI build.

The problem is that we will have to downgrade because of this dependency.

Issue accessing line_items in breakdown

resp = @taxjar.tax_for_order(@order_req)
resp.breakdown.line_items

Results in: RuntimeError: can't modify frozen Taxjar::Breakdown from line 13 of breakdown.rb

CHANGELOG?

Hi - as users of your public API, we would really love to see a Changelog that lists what is new when the gem version is bumped. This makes it very helpful to know if we need to change our own code, update our tests/fixtures, etc.

Do you think this can be added? Thanks!

Timeout option for requests

It would be beneficial to have a options[:timeout] option in requests so that we can prevent long timeout requests if there's an issue. I have put out an attempt to add this feature in #20

Doesn't provide access to all jurisdiction information

I'm sure this is a problem with the API, but I use the Ruby client, so I'm reporting it here. I've been working on generating tax reports for the company that I work for and have had to manually calculate the tax rates for places that have more complicated local/use tax requirements. I noticed that the Ruby client recently added support for accessing the jurisdictions. However, it assumes that there is only one jurisdiction part per county/city. In my experience, a given address may have multiple parts which make up its jurisdiction which don't map 1-1 to a county/city (e.g. transit taxes, ambulance district taxes, etc) , which result in different tax rates and reporting requirements.

Missouri example:

Jurisdiction Name Jurisdiction Code Sales Tax Rate Use Tax Rate
LEE'S SUMMIT
JACKSON COUNTY
KANSAS CITY ZOOLOGICAL DISTRICT
PINE TREE CID
41330-095-018 8.8500% 4.2250%

Texas example:

Jurisdiction Name Jurisdiction Code Type Tax Rate
THE WOODLANDS TNSP EDZ 5170629 SPD 0.0100000
THE WOODLANDS TOWNSHIP 5170503 SPD 0.0100000
STATE SALES TAX ย  STATE 0.0625000

There may be other states like this.

These states have unique reporting requirements which require access to all of this different information. It would be nice if the Taxjar API could provide this information. I currently have to scrape data from multiple sources in order to properly generate reports for these states since Taxjar does not provide this information.

default User-Agent can cause 500 errors

The default User-Agent set by this library can sometimes include characters that are not valid characters for an HTTP header. When it does this, any requests made by the client result in a 500 response.

HTTP headers (of which User-Agent is one) must be encoded using the ISO-8859-1 character set. Computer hostnames (at least on MacOS) permit characters that aren't part of the ISO-8859-1 character set, e.g. the curly apostrophe in "Jonathan Hinkleโ€™s MacBook Pro". Since this library puts the computer's hostname into the User-Agent string (via uname -a), that means that the User-Agent can end up containing characters that are not legal in ISO-8859-1. This scenario ends up causing some kind of conversion error on the server, resulting in a 500 for the client.

Reproduction steps:

  1. set your computer's hostname to something that includes any character that isn't a part of ISO-8859-1 (e.g. curly apostrophe: โ€™)
  2. attempt to make a request using this library
  3. response status code will be 500

Potential fix:

Update Taxjar::Client#user_agent to run its current return value through something like .encode("ISO-8859-1", invalid: :replace, undef: :replace). This would result in a User-Agent string where the invalid bytes are replaced by "?", e.g. "Jonathan Hinkle???s MacBook Pro" for the hostname part.

It would be a good idea to confirm the behavior of characters that are not part of ASCII but are part of ISO-8859-1 (e.g. รฅ) to confirm that they work without error.

Cannot create customer with the API

I am trying to use the API to create a customer but i am unable to do so. i get a Taxjar::Error::NotFound: No such route 'POST /v2/customers' error

[18] pry(#<Taxjar::Api>)> taxjar_client
=> #<Taxjar::Client:0x00007fe48788b490 @api_key="792ee5ec85cd1a8eaea3d8e0527a49a0", @api_url="https://api.sandbox.taxjar.com">
[19] pry(#<Taxjar::Api>)> params
=> {:customer_id=>"123",
 :exemption_type=>"wholesale",
 :name=>"Dunder Mifflin Paper Company",
 :exempt_regions=>[{:country=>"US", :state=>"FL"}, {:country=>"US", :state=>"PA"}],
 :country=>"US",
 :state=>"PA",
 :zip=>"18504",
 :city=>"Scranton",
 :street=>"1725 Slough Avenue"}
[20] pry(#<Taxjar::Api>)> taxjar_client.create_customer(params)
Taxjar::Error::NotFound: No such route 'POST /v2/customers'
from /home/adnan/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/taxjar-ruby-3.0.0/lib/taxjar/api/request.rb:77:in `fail_or_return_response_body'
[21] pry(#<Taxjar::Api>)>

How does the the dependency on model_attributes work?

Hi! I'm trying to use the Taxjar ruby gem, and have a question about its dependencies. The gemspec indicates that it uses model_attributes, '~> 3.2' here: https://github.com/taxjar/taxjar-ruby/blob/master/taxjar-ruby.gemspec#L26
But the README (https://github.com/taxjar/taxjar-ruby#gem-dependencies) says it depends on a forked version. And the forked version also has a different name: https://github.com/taxjar/model_attribute/blob/master/taxjar-model_attribute.gemspec#L7

It seems to me like Taxjar doesn't depend on the forked version, right?

Thanks!

HTTP::Error: Unknown MIME type: text/html in rare cases

Hello! ๐Ÿ‘‹ It seems that calling the Taxjar API sometimes returns an HTML (not JSON) response. In that case, this library fails with HTTP::Error: Unknown MIME type: text/html, due to the call to Http::Request#parse.

  1. Do you have any idea when/why the Taxjar API would return HTML?
  2. Can we raise a more helpful error in these cases?

Thanks!

Here's a sample backtrace:

HTTP::Error: Unknown MIME type: text/html 
File /app/vendor/bundle/ruby/2.6.0/gems/http-4.1.1/lib/http/mime_type.rb line 38 in []
File /app/vendor/bundle/ruby/2.6.0/gems/http-4.1.1/lib/http/response.rb line 158 in parse
File /app/vendor/bundle/ruby/2.6.0/gems/taxjar-ruby-2.6.0/lib/taxjar/api/request.rb line 31 in perform
File /app/vendor/bundle/ruby/2.6.0/gems/taxjar-ruby-2.6.0/lib/taxjar/api/utils.rb line 7 in perform_request
File /app/vendor/bundle/ruby/2.6.0/gems/taxjar-ruby-2.6.0/lib/taxjar/api/utils.rb line 39 in perform_request_with_object
File /app/vendor/bundle/ruby/2.6.0/gems/taxjar-ruby-2.6.0/lib/taxjar/api/utils.rb line 11 in perform_get_with_object
File /app/vendor/bundle/ruby/2.6.0/gems/taxjar-ruby-2.6.0/lib/taxjar/api/api.rb line 12 in rates_for_location

Undefined method `combined_tax_rate` for Taxjar::BreakdownLineItem

Version: 1.4.0

When calculating sales tax for an order per https://developers.taxjar.com/api/reference/?ruby#post-calculate-sales-tax-for-an-order, it says the response should include combined_tax_rate and taxable_amount properties for each provided line item. However, both methods appear to be undefined.

Using the deprecated line_item[:combined_tax_rate] or line_item[:taxable_amount] both return nil (though without error). However, converting the line item to a hash first will return the correct values for these attributes like so: line_item.to_h[:combined_tax_rate].

This value can be manually calculated from other values, but the behavior is inconsistent with the API reference.

Different states tax calculation

Hello there. I am trying to calculate tax for order where sender and a recipient are in different states. For some reason it returns zero. If sender and recipient are in the same state it works as expected. Can you explain this?

Params
{:amount=>5000, :shipping=>1006, :line_items=>[{:retail_price=>5000, :discounted_price=>nil, :variant_id=>"3", :quantity=>1, :product_tax_code=>"20010", :unit_price=>5000, :retailer_id=>2, :weight=>1.0, :discount=>0}], :from_zip=>"94025", :from_state=>"CA", :from_city=>"Menlo Park", :from_street=>"2825 Sand Hill Rd", :from_country=>"US", :retailer_id=>2, :to_zip=>85297, :to_state=>"AZ", :to_city=>"Gilbert", :to_street=>"3301 Greenfield Rd", :to_country=>"US"}

Response
<Taxjar::Tax order_total_amount: 6006.0, shipping: 1006.0, taxable_amount: 0.0, amount_to_collect: 0.0, rate: 0.0, has_nexus: false, freight_taxable: false, tax_source: nil, exemption_type: nil>

Breakdown line_items frozen

Accessing line items through the breakdown object creates this error:

RuntimeError: can't modify frozen Taxjar::Breakdown

Unable to parse invalid JSON when service unavailable

We recently had an error report that occurred when the TaxJar service was unavailable (or the request timed out). Here is the error and stacktrace:

JSON::ParserError: 822: unexpected token at '{"error":"Service Unavailable", detail: "Request Timed Out", status: "504"}'

Screen Shot 2019-03-22 at 10 51 25 AM

So it looks like the API (or maybe the gem) is returning invalid JSON (half JSON, half Ruby hash). The JSON should look like this:

{"error":"Service Unavailable", "detail": "Request Timed Out", "status": "504"}

We're using taxjar-ruby version 2.2.0. I checked the changelog and didn't see anything addressing this, so I assume that it's still an issue.

Passing a zip code string that starts with an 0 returns an error

Hey guys, we've hit an issue where passing a zip code as a string that begins with a 0 is causing a Taxjar::Error::NotFound: Resource can not be found error.

For example: @taxjar.rates_for_location('00150')

In the last hour, we've also had issues with "01915", "06108", "06902", "02125", "07601", and some others, all starting with 0.

Unless I'm missing something this actually doesn't seem to be an issue with the Ruby client because this is failing with a curl request too. I didn't see a spot in the docs to send a message, so figured I'd try through here first.

Best way to get effective tax rate on line item?

I need the overall effective percentage rate per line item for my order management system. I was going to add it in a fork. Any thoughts why I shouldn't do this? I'm thinking it wasn't included for some tax reason?

To add more notes:
I see in the response object I have an aggregated rate. My question is let's say one of the line item is for a prescription drug and the tax rate is different than the line item for syringes. This aggregated amount won't be quite rate. Technically I have different tax rates per line item. I'm looking to find out that aggregated rate per line item. Is this even possible? Thoughts?

Taxjar::Base has confusing mixed data states

Taxjar::Base and all the data models that currently inherit from it use a confusing mix of data states, stored both directly into an @attrs instance variable, and also managed by ModelAttributes (which stores each attribute in its own instance variable).

While these states are initially in-sync when the object is constructed, using any of the attribute writers causes these states to go out of sync, and data read from the attributes to no longer match the data to be sent in an API request.

Expected Behaviour

order = Taxjar::Order.new(to_city: 'Toronto')
assert_equal order.to_city, 'Toronto' # Passes
assert_equal order.to_hash['to_city'], 'Toronto' # Passes

order.to_city = 'New York'
assert_equal order.to_city, 'New York' # Passes
assert_equal order.to_hash['to_city'], 'New York' # Passes

assert_equal order.to_json, '{"to_city":"New York"}' # Passes

Actual Behaviour

order = Taxjar::Order.new(to_city: 'Toronto')
assert_equal order.to_city, 'Toronto' # Passes
assert_equal order.to_hash['to_city'], 'Toronto' # Passes

order.to_city = 'New York'
assert_equal order.to_city, 'New York' # Passes
assert_equal order.to_hash['to_city'], 'New York' # Fails! `@attrs['to_city']` is still equal to 'Toronto'!

assert_equal order.to_json, '{"to_city":"New York"}' # Fails! `#to_json` still returns `{"to_city":"Toronto"}`!

This is caused because Taxjar::Base stores two separate data states:

  • @attrs, which is only assigned in the constructor, and delegates #to_hash
  • ModelAttributes, which is initialized in the constructor, and whenever attribute writers are used, but never updates @attrs state

Another Example

order = Taxjar::Order.new

order.to_country = 'CA'
order.to_state = 'ON'
order.to_city = 'Toronto'

order.to_json # => "{}" - Empty JSON object!

This happens because Taxjar::Base#to_h and Taxjar::Base#to_hash delegate to @attrs, which is not updated by attribute writers.

Suggested Fix

All usage of @attrs should be removed, instead using the #attributes method provided by ModelAttributes.

Occasional InternalServerError on address validation

Hi,

We use the validate_address to verify state information for zipcodes. 99% of the time it works perfectly. Every once in a while, we get a Taxjar::Error::InternalServerError: Something unexpected went wrong error response.

The most recent one happened with a zipcode of "94010" which is a valid CA zipcode and returned correctly when ran again.

ruby 2.4.6
taxjar-ruby 2.4.1

Do you have any recommendations besides trying the request multiple times when the error happens?

Thanks!

Support for API versions; gem should upgrade before it is forced

According to https://developers.taxjar.com/api/reference/?ruby#api-version , there are various versions of the API. By email we were told that the version will be force-upgraded for everyone on August 31, but there's no obvious way to test the latest version with this gem.

It seems to me that the gem should provide access to the version and also default to the latest version of the API starting now, so that anyone can test it out as part of their normal gem upgrade process.

Stripe Subscription Integration Questions

I am looking at Stripe-Taxjar documentation, but it seems like it is deprecated.

I have a rails app that charges Stripe subscriptions, what would be the best way to implement this?

I linked the Stripe in the Taxjar dashboard, but it didn't import any of the transactions. It indicates it only works with Relay orders.

Is SmartCalcs API transaction going to create transactions in Taxjar dashboard?

Client doesn't throw Taxjar exceptions during outage

Howdy!

This is happening during a major outage (1/11/21, 13:30-14:30 EST). Here's a log of the issue:

irb(main):014:0> Taxjar::Version.to_s
=> "2.6.1"
irb(main):015:0> c = ::Taxjar::Client.new(api_key: ENV['TAXJAR_API_KEY'])
irb(main):016:0> c.categories
=> []
irb(main):017:0> c.rates_for_location zipcode: 95060, city: 'Santa Cruz', state: 'CA', country: 'US'
Traceback (most recent call last):
        1: from (irb):17
NoMethodError (undefined method `each' for nil:NilClass)
irb(main):018:0>

I've traced it back to model_attributes, in this case it's a set_attributes call from trying to build a Taxjar::Rate, when I tried tax_for_order it was a Taxjar::Tax, so I don't think it's specific to the model.

(It would be swell if there was an option to get verbose http output for situations like these too.)

Thanks much!

ArgumentError: invalid value for Integer() when accessing ID

If I set a line item's ID to an arbitrary string when calling tax_for_order, then accessing the returned tax.breakdown.line_items array throws an ArgumentError.

Here's an example that reproduces the problem:

tax = client.tax_for_order(
  :to_city=>"San Jose", 
  :to_country=>"US", 
  :to_state=>"CA", :to_zip=>"95131", 
  :from_city=>"San Jose", 
  :from_country=>"US", :from_state=>"CA", 
  :from_zip=>"95131", 
  :shipping=>"7.25", 
  :line_items=>[{
    :id=>"product_line_item_0", 
    :quantity=>1, 
    :discount=>"0.00", 
    :unit_price=>"99.99"
  }]
)

# Throws "ArgumentError: invalid value for Integer() when accessing ID"
puts tax.breakdown.line_items

This is problematic, b/c the id field of a line_item is a string (not necessarily an integer), per the API documentation here.

EDIT: I'm using taxjar-ruby v1.5.0.

Can't access line item breakdown, can't modify frozen error

I've submitted individual line items to the tax_for_order method. I get the results I'm expecting but I can't access the breakdown line items.

result = Taxjar::Client.new(api_key: my_api_key).tax_for_order(
      to_country: order.shipping_address.country.code,
      to_zip: order.shipping_address.zip_code,
      to_city: order.shipping_address.city,
      to_state: order.shipping_address.state.code,
      from_country: order.location.country.code,
      from_zip: order.location.zip_code,
      from_city: order.location.city,
      shipping: order.shipping_cost,
      amount: order.subtotal,
      line_items: order_line_items
    )

This is what order_line_items looks like:

  def order_line_items
    order_line_items = []

    order.order_line_items.each do |oli|
      next if oli.line_type == 'Shipping'

      order_line_item = {
        id: oli.id,
        quantity: oli.quantity,
        unit_price: oli.price,
        discount: oli.discount,
        product_identifier: (oli.variant.sku unless oli.variant.blank?),
        description: (oli.variant.name unless oli.variant.blank?),
        product_tax_code: ('99999' if oli.tax_exempt?)
      }

      order_line_items << order_line_item
    end

    order_line_items
  end

result.breakdown

{
                :state_taxable_amount => 44.99,
               :state_tax_collectable => 2.02,
               :county_taxable_amount => 44.99,
              :county_tax_collectable => 0.41,
                 :city_taxable_amount => 44.99,
                :city_tax_collectable => 1.8,
     :special_district_taxable_amount => 0,
    :special_district_tax_collectable => 0,
                          :line_items => [
        [0] {
                                         :id => "169",
                            :tax_collectable => 0.0,
                       :state_taxable_amount => 0.0,
                       :state_sales_tax_rate => 0.045,
                               :state_amount => 0.0,
                      :county_taxable_amount => 0.0,
                            :county_tax_rate => 0.00917,
                              :county_amount => 0.0,
                        :city_taxable_amount => 0.0,
                              :city_tax_rate => 0.04,
                                :city_amount => 0.0,
            :special_district_taxable_amount => 0.0,
                           :special_tax_rate => 0.0,
                    :special_district_amount => 0.0
        },
        [1] {
                                         :id => "168",
                            :tax_collectable => 0.0,
                       :state_taxable_amount => 0.0,
                       :state_sales_tax_rate => 0.045,
                               :state_amount => 0.0,
                      :county_taxable_amount => 0.0,
                            :county_tax_rate => 0.00917,
                              :county_amount => 0.0,
                        :city_taxable_amount => 0.0,
                              :city_tax_rate => 0.04,
                                :city_amount => 0.0,
            :special_district_taxable_amount => 0.0,
                           :special_tax_rate => 0.0,
                    :special_district_amount => 0.0
        },
...
2.2.4 :009 > result.breakdown.line_items
RuntimeError: can't modify frozen Taxjar::Breakdown
    from /usr/local/rvm/gems/ruby-2.2.4@uber-app/gems/taxjar-ruby-1.1.0/lib/taxjar/breakdown.rb:13:in `line_items'

I'm updating tax on individual line items so I need this data but I can't seem to access it programatically. What am I missing?

Bump http gem dependency to support v5

I need to upgrade my http gem dependency to v5 but the taxjar-ruby gemspec specifies < 5. Please relax or upgrade the dependency on http < 5. Thanks!

Better way to configure the BASE_URL

Currently, changing the BASE_URL for a test endpoint yields

Taxjar::API::Request::BASE_URL = 'https://test.com'

warning: already initialized constant Taxjar::API::Request::BASE_URL
warning: previous definition of BASE_URL was here

I'd prefer this didn't show up in my logs for every test (this is set in the spec_helper.rb).

Calculate Sales Tax for a Saas based product without shipping

We are providing software as services using monthly/yearly subscription. Payment is done using stripe. We have monthly/yearly payments and few one time charge payments using stripe charge API. As per taxjar blog, we need to calculate it by taxjar api.
https://developers.taxjar.com/blog/handling-sales-tax-with-stripe/

We decided to calculate sales tax using rate api. But it doesn't support product_tax_code so i can mention my product_type as saas(product_tax_code). So it even calculate tax for California which is non-taxable state for Saas

https://blog.taxjar.com/saas-sales-tax/

**SAAS Category **

`{
  "name": "Software as a Service",
  "product_tax_code": "30070",
  "description": "Pre-written software, delivered electronically, but access remotely."
}`

Rate API Code

client = Taxjar::Client.new(api_key: api_key)
 tax = client.rates_for_location(address.zip, { city: address.city, state: address.state, country: address.country_code })

Then i tried to use tax_for_order function, but as it is a subscription, there is no shipping and without shipping it give sales tax 0.0 results to every state.

 client.tax_for_order({
    :to_country => 'US',
    :to_zip => '99217',
    :to_city => 'Spokane',
    :to_state => 'WA',
    :from_country => 'US',
    :from_zip => '97005',
    :from_city => 'Beaverton',
    :from_state => 'OR',
    :amount => 15,
    :shipping => 0,
    :nexus_addresses => [{:address_id => 1,
                          :country => 'US',
                          :zip => '93101',
                          :state => 'OR',
                          :city => 'Beaverton''}],
    :line_items => [{:quantity => 1,
                     :unit_price => 15,
                     :product_tax_code => 30070}]
}) 

So goal is to calculate sales tax for a saas based product without shipping. Please if you can guide me in right direction.

Support for Ruby 1.9.3

I noticed in issue #27 you talked about continuing support for Ruby 1.9.3. Did you decide to continue to support Ruby 1.9.3? I'm assuming not but thought I would check. Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.