The Taxjar Ruby Gem
A Ruby interface to the Taxjar 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 Version 2
- Data returned from API calls are mapped into Ruby objects
Gem Dependencies
Installing this gem also installs the following gems:
- http http.rb: a fast Ruby HTTP client with a chainable API and full streaming support
- addressable Addressable is a 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
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
Quick Start Guide
First, [get an api key from Taxar][https://app.taxjar.com/api_sign_up/plus/].
Then copy and paste in your API keys:
client = Taxjar::Client.new(api_key: "YOUR KEY")
You are ready to use Taxjar.
Usage
List all tax categories
categories = client.categories
List tax rates for a location (by zip/postal code)
rates = client.rates_for_location('10001')
Calculate Sales tax for an order
order = client.tax_for_order({
:to_country => 'US',
:to_zip => '90002',
:to_city => 'Los Angeles',
:from_country => 'US',
:from_zip => '92093',
:from_city => 'San Diego',
:amount => 16.50,
:shipping => 1.5,
:line_items => [{:quantity => 1,
:product_identifier => '12-34243-9',
:unit_price => 15.0,
:product_tax_code => 31000}]
})
Create order transaction
order = client.create_order({
:transaction_id => '123',
:transaction_date => '2015/05/14',
:to_country => 'US',
:to_zip => '90002',
:to_city => 'Los Angeles',
:to_street => '123 Palm Grove Ln',
:amount => 17.45,
:shipping => 1.5,
:sales_tax => 0.95,
:line_items => [{:quantity => 1,
:product_identifier => '12-34243-9',
:descriptiion => 'Fuzzy Widget',
:unit_price => 15.0,
:sales_tax => 0.95}]
})
Update order transaction
order = client.update_order({
:transaction_id => '123',
:amount => 17.95,
:shipping => 2.0,
:line_items => [{:quantity => 1,
:product_identifier => '12-34243-0',
:descriptiion => 'Heavy Widget',
:unit_price => 15.0,
:discount => 0.0,
:sales_tax => 0.95}]
})
Create refund transaction
refund = client.create_refund({
:transaction_id => '321',
:transaction_date => '2015/05/14',
:transaction_reference_id => '123',
:to_country => 'US',
:to_zip => '90002',
:to_state => 'CA',
:to_city => 'Los Angeles',
:to_street => '123 Palm Grove Ln',
:amount => 17.45,
:shipping => 1.5,
:sales_tax => 0.95,
:line_items => [{:quantity => 1,
:product_identifier => '12-34243-9',
:descriptiion => 'Fuzzy Widget',
:unit_price => 15.0,
:sales_tax => 0.95}]
})
Update refund transaction
refund = client.update_refund{
:transaction_id => '321',
:amount => 17.95,
:shipping => 2.0,
:sales_tax => 0.95,
:line_items => [{:quantity => 1,
:product_identifier => '12-34243-9',
:descriptiion => 'Heavy Widget',
:unit_price => 15.0,
:sales_tax => 0.95}]
})
Tests
An Rspec test suite is available to ensure API functionality:
- $ git clone git://github.com/taxjar/taxjar-ruby.git
- $ bundle install (installs rspec and other supporting gems, see GEMFILE for complete listing)
- $ rspec
More Information
More information can be found on the Taxjar developer site.
License
Taxjar is released under the MIT License.
Support
Bug reports and feature requests should be filed on the github issue tracking page.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
