Download the PHP package ejosterberg/opensalestax-stripe-php without Composer

On this page you can find all versions of the php package ejosterberg/opensalestax-stripe-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package opensalestax-stripe-php

opensalestax-stripe-php

Replace Stripe Tax with self-hosted OpenSalesTax. Server-side US sales tax calculation library for PHP SaaS using Stripe.

Status: v0.1 alpha. Tested against stripe/stripe-php v20 + OpenSalesTax engine v0.24.

What this saves you

Stripe Tax charges 0.5% per transaction (or $0.50, whichever is greater). At scale, that's real money:

Annual revenue Stripe Tax annual cost This connector + self-hosted engine
$50K MRR / $600K ARR ~$3,000/yr $0 software cost
$100K MRR / $1.2M ARR ~$6,000/yr $0
$250K MRR / $3M ARR ~$15,000/yr $0
$500K MRR / $6M ARR ~$30,000/yr $0

You still pay infrastructure: a small VM running the OpenSalesTax engine (~$20–50/mo) plus a few hours/year to deploy engine updates. Below ~$1M ARR, Stripe Tax is reasonable. Above that, the math flips fast.

How it works

This connector reads a Stripe Invoice or Checkout\Session, calls your OpenSalesTax engine for the right ZIP-based tax, and returns a structured breakdown you apply back to the invoice via Stripe\TaxRate. Three-line core path:

That's the entire integration shape. Full code below.

Install

This pulls in:

You'll also need:

Production deployment guide

For an existing PHP SaaS already using Stripe for billing. ~30 minutes if your codebase is tidy.

Step 1 — Spin up an OpenSalesTax engine

Production: deploy the same compose file to your own VM, point a hostname at it, lock down with a firewall or reverse proxy.

Step 2 — Collect billing addresses on checkout

If your Stripe Checkout sessions don't already require a billing address, add one line to Session::create():

Stripe persists the address on the Customer object; subsequent recurring invoices have it automatically — no further work needed.

Step 3 — Add an invoice.created webhook handler

In your existing Stripe webhook router, add the case:

Step 4 — Implement applyOpenSalesTax

Step 5 — Set OPENSALESTAX_BASE_URL on production

That's it. The next subscription invoice fired will be auto-taxed.

Quickstart (just the calculator, no webhook integration)

If you just want to compute tax on demand:

For Checkout Sessions (instead of invoices):

Stripe Tax Code mapping

Each Stripe line item can carry a tax_code on its Price (e.g. txcd_10103001 for SaaS Business). The connector translates Stripe's catalog into OpenSalesTax's 6 categories. Default mapping:

Stripe code OST category
txcd_99999999 General Tangible Goods general
txcd_20030000 General Services general
txcd_10103001 SaaS Business / txcd_10103000 SaaS Personal digital_goods
txcd_10101000 IaaS / txcd_10102000 PaaS / txcd_10105002 AIaaS digital_goods
txcd_10302000 Digital Books / txcd_10402100 Digital Video / txcd_10401100 Digital Audio / txcd_10701100 Website Hosting digital_goods
txcd_00000000 Nontaxable line is excluded from the OST calc; tax = 0
anything else falls through to general (a warning callback can capture these)

Override the mapping for your own catalog:

The default table covers SaaS / digital products. For physical-goods merchants, expect to add specific Stripe codes for clothing / groceries / etc. depending on your catalog.

How this compares

Cost Self-hosted Per-jurisdiction breakdown Stripe-native flow
Stripe Tax 0.5%/txn ❌ ✅ ✅
TaxJar API from ~$0.50/txn ❌ ✅ partial
Avalara AvaTax enterprise pricing ❌ ✅ partial
OpenSalesTax + this connector $0 software ✅ ✅ via TaxRate.create

OpenSalesTax + this connector trades operational responsibility (run a small engine VM) for transactional cost (zero). For SaaS founders comfortable with Docker, that's an easy win above ~$50K MRR.

What's NOT in v0.1

Quality bar

Engine compatibility

Tested against OpenSalesTax v0.24. Engine v0.22+ recommended for production (a state-bleed data bug was fixed in v0.22). Pin both:

Disclaimer

Tax calculations are provided as-is for convenience. The merchant is solely responsible for tax-collection accuracy and remittance to the appropriate jurisdictions. Verify against your state Department of Revenue before remitting.

Contributing

DCO sign-off (git commit -s) required on every commit. See CONTRIBUTING.md. Dual-licensed Apache-2.0 OR GPL-2.0-or-later + SPDX header on every source file.

License

Dual-licensed under your choice of LICENSE.


All versions of opensalestax-stripe-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ejosterberg/opensalestax Version ^0.3.0
stripe/stripe-php Version ^20.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ejosterberg/opensalestax-stripe-php contains the following files

Loading the files please wait ...