Skip to content

fix(core): refuse stripe_tax with a non-Stripe provider - #111

Closed
alexasomba wants to merge 1 commit into
emdashCommerce:mainfrom
alexasomba:feat/provider-tax-guard
Closed

alexasomba wants to merge 1 commit into
emdashCommerce:mainfrom
alexasomba:feat/provider-tax-guard

Conversation

@alexasomba

Copy link
Copy Markdown

Part of the Flutterwave follow-up in #97. Independent of the split work.

Why

taxMode: "stripe_tax" defers tax calculation to Stripe: core returns zero tax in recalculate() and sends automaticTax: true on checkout. A provider that does not implement Stripe's automatic_tax (Flutterwave, Paystack, the mock) ignores that field, so the customer is charged the pre-tax total with no error.

This is the one silent money bug in the Stripe parity gap. Flat and table tax are unaffected because core computes those and includes them in the amount.

What

  • checkout/create-session returns 409 with code: "stripe_tax_requires_stripe" when taxMode is stripe_tax and the selected provider is not Stripe.
  • The message tells the merchant to switch to flat/table tax in Settings → Tax or to use Stripe.
  • The check runs before the draft, stock lock or provider call, so a refused checkout leaves no state behind.

Tests

  • 2 new tests: stripe_tax with the mock provider returns 409 and the code; flat tax still starts checkout.
  • 317 core tests pass on upstream/main, 0 failures.
  • Typecheck clean.
  • Changeset: patch.

Notes

  • Deliberately not a fallback to flat/table: silently changing the tax mode would be another surprise. A 409 is explicit and actionable.
  • checkout/create-intent is already Stripe-only and returns 409 for a non-Stripe provider before this point.

@alexasomba

Copy link
Copy Markdown
Author

Superseded by #115. No review had started, so the two small safety fixes were combined to reduce the stack.

@alexasomba alexasomba closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant