# @xdabuss/vendure-plugin-ninja-tax

> Vendure plugin for sales tax in US using NinjaAPI

Latest version **1.0.8** (published 2024-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @xdabuss/vendure-plugin-ninja-tax
pnpm add @xdabuss/vendure-plugin-ninja-tax
yarn add @xdabuss/vendure-plugin-ninja-tax
bun add @xdabuss/vendure-plugin-ninja-tax
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2024-01-03 |
| First published | 2024-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | Alex Bussan amity.solutions23@gmail.com |
| Maintainers | xdabuss |
| Keywords | vendure, us, tax, sales |

## Links

- npm: https://www.npmjs.com/package/@xdabuss/vendure-plugin-ninja-tax
- Repository: https://github.com/xdabuss/vendure-plugin-ninja-tax
- Homepage: https://github.com/xdabuss/vendure-plugin-ninja-tax#readme
- Issues: https://github.com/xdabuss/vendure-plugin-ninja-tax/issues
- npm.io page: https://npm.io/package/@xdabuss/vendure-plugin-ninja-tax

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.6.3

## Alternatives

- [adhdev](https://npm.io/package/adhdev.md) — 11.1K weekly downloads
- [react-slide-button](https://npm.io/package/react-slide-button.md) — 310 weekly downloads
- [better](https://npm.io/package/better.md) — 42 weekly downloads
- [react-native-swipe-image](https://npm.io/package/react-native-swipe-image.md) — 22 weekly downloads
- [nl.fokkezb.pulltorefresh](https://npm.io/package/nl.fokkezb.pulltorefresh.md) — 11 weekly downloads

## Recent versions

- 1.0.8 (latest) — 2024-01-03
- 1.0.7 — 2024-01-02
- 1.0.6 — 2024-01-02
- 1.0.5 — 2024-01-02
- 1.0.4 — 2024-01-02
- 1.0.3 — 2024-01-02
- 1.0.2 — 2024-01-02
- 1.0.1 — 2024-01-02
- 1.0.0 — 2024-01-02

## README

# 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:

```ts
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.

3. Create Ninja API [account](https://api-ninjas.com/api), create API key, add `NINJA_KEY=<example_key>` to root level `.env` file

## Relevant Docs

-   https://api-ninjas.com/api/salestax
-   https://docs.vendure.io/guides/core-concepts/taxes/
-   https://docs.vendure.io/reference/typescript-api/tax/tax-line-calculation-strategy
-   https://docs.vendure.io/reference/typescript-api/orders/order-item-price-calculation-strategy/

## 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

---
_Source: https://npm.io/package/@xdabuss/vendure-plugin-ninja-tax · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
