All Projects → taxjar → Taxjar Node

taxjar / Taxjar Node

Licence: mit
Sales Tax API Client for Node

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Taxjar Node

Syliusmercanetbnpparibasplugin
BnpParibas Mercanet payment gateway for Sylius based applications.
Stars: ✭ 12 (-72.09%)
Mutual labels:  ecommerce
React Native Ultimate Modal Picker
NPM Link: https://www.npmjs.com/package/react-native-ultimate-modal-picker
Stars: ✭ 30 (-30.23%)
Mutual labels:  npm-package
Connect Java Sdk
Java client library for the Square Connect v2 API
Stars: ✭ 36 (-16.28%)
Mutual labels:  ecommerce
Woocommerce
An open source eCommerce plugin for WordPress.
Stars: ✭ 7,473 (+17279.07%)
Mutual labels:  ecommerce
Ecommerce
A powerful and lightweight eCommerce platform using ReactJs, Graphql, PHP, and Mysql.
Stars: ✭ 28 (-34.88%)
Mutual labels:  ecommerce
Byte Size
Isomorphic function to convert a bytes value (e.g. 3456) to a human-readable string ('3.5 kB')
Stars: ✭ 33 (-23.26%)
Mutual labels:  npm-package
Django Ecommerce
An e-commerce website built with Django
Stars: ✭ 861 (+1902.33%)
Mutual labels:  ecommerce
Noop Stream
Create a readable Node.js stream that produces no data (or optionally blank data) or a writable stream that discards data
Stars: ✭ 40 (-6.98%)
Mutual labels:  npm-package
Oc Shop Plugin
An ecommerce platform for October CMS.
Stars: ✭ 29 (-32.56%)
Mutual labels:  ecommerce
Voicecommerce
JavaScript library for easily connecting ecommerce to Alexa and Google Assistant
Stars: ✭ 36 (-16.28%)
Mutual labels:  ecommerce
Pro
ECStore Pro - Laravel 微信网店微服务框架
Stars: ✭ 14 (-67.44%)
Mutual labels:  ecommerce
Catchart
Pipe something from command line to a chart in the browser
Stars: ✭ 27 (-37.21%)
Mutual labels:  npm-package
Ecommerce
We're going to take you step-by-step to build a modern, fully open-source, eCommerce web application using Python, Django, Bootstrap, Javascript, and more.
Stars: ✭ 980 (+2179.07%)
Mutual labels:  ecommerce
Yarpm
CLI tool to run npm scripts with either npm or yarn, depending on how it was started
Stars: ✭ 13 (-69.77%)
Mutual labels:  npm-package
Ever
Ever® - Open-Source Commerce Platform for On-Demand Economy and Digital Marketplaces
Stars: ✭ 980 (+2179.07%)
Mutual labels:  ecommerce
Bmp085
A node.js module for reading a BMP085 barometer sensor.
Stars: ✭ 11 (-74.42%)
Mutual labels:  npm-package
Express React Boilerplate
🚀🚀🚀 This is a tool that helps programmers create Express & React projects easily base on react-cool-starter.
Stars: ✭ 32 (-25.58%)
Mutual labels:  npm-package
Is
Type check values
Stars: ✭ 1,011 (+2251.16%)
Mutual labels:  npm-package
Configs
Public, free to use, repository with diggers configs for scraping / extracting data from various e-commerce websites and online stores
Stars: ✭ 37 (-13.95%)
Mutual labels:  ecommerce
Actions Package Update
keeps npm dependencies up-to-date by making pull requests from GitHub Actions or CI.
Stars: ✭ 36 (-16.28%)
Mutual labels:  npm-package

TaxJar Sales Tax API for Node NPM Module Build Status Known Vulnerabilities

TaxJar

Official Node client for Sales Tax API v2. For the API documentation, please visit https://developers.taxjar.com/api/reference/.


Requirements
Installation
Authentication
Usage
Sandbox Environment
Error Handling
Testing


Requirements

  • Node.js v4.0 and later.

Installation

npm install taxjar

Authentication

// CommonJS Import
const Taxjar = require('taxjar');

// ES6 Import
// Using TypeScript? Pass `esModuleInterop` in tsconfig.json
// https://www.typescriptlang.org/docs/handbook/compiler-options.html
import Taxjar from 'taxjar';

const client = new Taxjar({
  apiKey: process.env.TAXJAR_API_KEY
});

Warning: Never expose your API token in client-side JavaScript. This is insecure and could put your TaxJar account at risk.

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

Usage

categories - List all tax categories
taxForOrder - Calculate sales tax for an order
listOrders - List order transactions
showOrder - Show order transaction
createOrder - Create order transaction
updateOrder - Update order transaction
deleteOrder - Delete order transaction
listRefunds - List refund transactions
showRefund - Show refund transaction
createRefund - Create refund transaction
updateRefund - Update refund transaction
deleteRefund - Delete refund transaction
listCustomers - List customers
showCustomer - Show customer
createCustomer - Create customer
updateCustomer - Update customer
deleteCustomer - Delete customer
ratesForLocation - List tax rates for a location (by zip/postal code)
nexusRegions - List nexus regions
validateAddress - Validate an address
validate - Validate a VAT number
summaryRates - 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.

client.categories().then(res => {
  res.categories; // Array of categories
});

Calculate sales tax for an order (API docs)

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

client.taxForOrder({
  from_country: 'US',
  from_zip: '07001',
  from_state: 'NJ',
  from_city: 'Avenel',
  from_street: '305 W Village Dr',
  to_country: 'US',
  to_zip: '07446',
  to_state: 'NJ',
  to_city: 'Ramsey',
  to_street: '63 W Main St',
  amount: 16.50,
  shipping: 1.5,
  line_items: [
    {
      id: '1',
      quantity: 1,
      product_tax_code: '31000',
      unit_price: 15.0,
      discount: 0
    }
  ]
}).then(res => {
  res.tax; // Tax object
  res.tax.amount_to_collect; // Amount to collect
});

List order transactions (API docs)

Lists existing order transactions created through the API.

client.listOrders({
  from_transaction_date: '2015/05/01',
  to_transaction_date: '2015/05/31'
}).then(res => {
  res.orders; // Orders object
});

Show order transaction (API docs)

Shows an existing order transaction created through the API.

client.showOrder('123').then(res => {
  res.order; // Order object
});

Create order transaction (API docs)

Creates a new order transaction.

client.createOrder({
  transaction_id: '123',
  transaction_date: '2015/05/14',
  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: '123 Palm Grove Ln',
  amount: 17.45,
  shipping: 1.5,
  sales_tax: 0.95,
  line_items: [
    {
      id: '1',
      quantity: 1,
      product_identifier: '12-34243-9',
      description: 'Fuzzy Widget',
      unit_price: 15.0,
      discount: 0,
      sales_tax: 0.95
    }
  ]
}).then(res => {
  res.order; // Order object
});

Update order transaction (API docs)

Updates an existing order transaction created through the API.

client.updateOrder({
  transaction_id: '123',
  amount: 17.45,
  shipping: 1.5,
  line_items: [
    {
      quantity: 1,
      product_identifier: '12-34243-0',
      description: 'Heavy Widget',
      unit_price: 15.0,
      discount: 0.0,
      sales_tax: 0.95
    }
  ]
}).then(res => {
  res.order; // Order object
});

Delete order transaction (API docs)

Deletes an existing order transaction created through the API.

client.deleteOrder('123').then(res => {
  res.order; // Order object
});

List refund transactions (API docs)

Lists existing refund transactions created through the API.

client.listRefunds({
  from_transaction_date: '2015/05/01',
  to_transaction_date: '2015/05/31'
}).then(res => {
  res.refunds; // Refunds object
});

Show refund transaction (API docs)

Shows an existing refund transaction created through the API.

client.showRefund('123-refund').then(res => {
  res.refund; // Refund object
});

Create refund transaction (API docs)

Creates a new refund transaction.

client.createRefund({
  transaction_id: '123-refund',
  transaction_reference_id: '123',
  transaction_date: '2015/05/14',
  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: '123 Palm Grove Ln',
  amount: -17.45,
  shipping: -1.5,
  sales_tax: -0.95,
  line_items: [
    {
      id: '1',
      quantity: 1,
      product_identifier: '12-34243-9',
      description: 'Fuzzy Widget',
      unit_price: -15.0,
      discount: -0,
      sales_tax: -0.95
    }
  ]
}).then(res => {
  res.refund; // Refund object
});

Update refund transaction (API docs)

Updates an existing refund transaction created through the API.

client.updateRefund({
  transaction_id: '123-refund',
  transaction_reference_id: '123',
  amount: -17.95,
  shipping: -2.0,
  line_items: [
    {
      id: '1',
      quantity: 1,
      product_identifier: '12-34243-0',
      description: 'Heavy Widget',
      unit_price: -15.0,
      discount: -0,
      sales_tax: -0.95
    }
  ]
}).then(res => {
  res.refund; // Refund object
});

Delete refund transaction (API docs)

Deletes an existing refund transaction created through the API.

client.deleteRefund('123-refund').then(res => {
  res.refund; // Refund object
});

List customers (API docs)

Lists existing customers created through the API.

client.listCustomers().then(res => {
  res.customers; // Customers object
});

Show customer (API docs)

Shows an existing customer created through the API.

client.showCustomer('123').then(res => {
  res.customer; // Customer object
});

Create customer (API docs)

Creates a new customer.

client.createCustomer({
  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'
}).then(res => {
  res.customer; // Customer object
});

Update customer (API docs)

Updates an existing customer created through the API.

client.updateCustomer({
  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'
}).then(res => {
  res.customer; // Customer object
});

Delete customer (API docs)

Deletes an existing customer created through the API.

client.deleteCustomer('123').then(res => {
  res.customer; // Customer object
});

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 taxForOrder to accurately calculate sales tax for an order.

client.ratesForLocation('90002').then(res => {
  res.rate; // Rate object
});

List nexus regions (API docs)

Lists existing nexus locations for a TaxJar account.

client.nexusRegions().then(res => {
  res.regions; // Array of nexus regions
});

Validate an address (API docs)

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

client.validateAddress({
  country: 'US',
  state: 'AZ',
  zip: '85297',
  city: 'Gilbert',
  street: '3301 South Greenfield Rd'
}).then(res => {
  res.addresses; // Array of address matches
});

Validate a VAT number (API docs)

Validates an existing VAT identification number against VIES.

client.validate({
  vat: 'FR40303265045'
}).then(res => {
  res.validation; // Validation object
});

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 taxForOrder to accurately calculate sales tax for an order.

client.summaryRates().then(res => {
  res.summary_rates; // Array of summarized rates
});

Sandbox Environment

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

// CommonJS Import
const Taxjar = require('taxjar');

// ES6 Import
import Taxjar from 'taxjar';

const client = new Taxjar({
  apiKey: process.env.TAXJAR_SANDBOX_API_KEY,
  apiUrl: Taxjar.SANDBOX_API_URL
});

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

client.setApiConfig('headers', {
  'X-TJ-Expected-Response': '422'
});

Error Handling

client.taxForOrder({
  from_country: 'US',
  from_zip: '07001',
  from_state: 'NJ',
  from_city: 'Avenel',
  from_street: '305 W Village Dr',
  to_country: 'US',
  to_zip: '07446',
  to_state: 'NJ',
  to_city: 'Ramsey',
  to_street: '63 W Main St',
  amount: 16.50,
  shipping: 1.5,
  line_items: [
    {
      id: '1',
      quantity: 1,
      product_tax_code: '31000',
      unit_price: 15.0,
      discount: 0,
      sales_tax: 0.95
    }
  ]
}).then(res => {
  res.tax; // Tax object
  res.tax.amount_to_collect; // Amount to collect
}).catch(err => {
  err.detail; // Error detail
  err.status; // Error status code
});

In TypeScript, you may want to first check the error's type before handling:

client.taxForOrder(/* ... */)
  .catch(err => {
    if (err instanceof Taxjar.Error) {
      err.detail; // Error detail
      err.status; // Error status code
    } else {
      // handle non-taxjar error
    }
  });

Testing

npm test

To validate API methods in the TaxJar sandbox environment, pass the following environment variables:

TAXJAR_API_URL="https://api.sandbox.taxjar.com" \
TAXJAR_API_KEY="9e0cd62a22f451701f29c3bde214" \
npm test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].