@xdabuss/vendure-plugin-ninja-tax
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

NinjaAPI US Tax Plugin

This plugin provides a simple way to add in US sales tax to Vendure orders. The plugin adds TaxLines to an order based on the customer's zipcode. Tax data is retrieved from https://api-ninjas.com/api/salestax. State, city, county, and misc. tax rates for a given zip code are retrieved from this endpoint and added as separate TaxLines.

Usage

  1. yarn add @xdabuss/vendure-plugin-ninja-tax
  2. Add plugin to vendure config:
export const config: VendureConfig = {
  // .. the rest of your vendure config
  plugins: [
    NinjaTaxPlugin.init({fallbackTaxRate: 15}),
    )},
};

fallbackTaxRate is an optional value that will be used for a US customer if the call to NinjaAPI fails. If unset, its default is 15%, since that should cover even the highest US sales tax locations. My thinking is you'd rather let the order continue (and possible refund the extra tax later) with a default rate than have the order fail if NinjaAPI is unresponsive.

  1. Create Ninja API account, create API key, add NINJA_KEY=<example_key> to root level .env file

Relevant Docs

Notes

  • If the shiping address is not from the US (order.shippingAddress.countryCode !== "US"), the tax lines will be calculated using Vendure's DefaultTaxLineCalculationStrategy

Possible improvements

  • Use caching for the tax rates so that NinjaAPI doesn't need to be called if customer's zipcode is already in cache

Development

Run yarn dev to start Vendure on http://localhost:3050/admin

License

MIT

Dependents (0)

Package Sidebar

Install

npm i @xdabuss/vendure-plugin-ninja-tax

Weekly Downloads

46

Version

1.0.8

License

MIT

Unpacked Size

12.6 kB

Total Files

12

Last publish

Collaborators

  • xdabuss