Skip to content

fix(core): harden checkout and refund safety - #115

Open
alexasomba wants to merge 3 commits into
emdashCommerce:mainfrom
alexasomba:feat/core-checkout-refund-hardening
Open

alexasomba wants to merge 3 commits into
emdashCommerce:mainfrom
alexasomba:feat/core-checkout-refund-hardening

Conversation

@alexasomba

Copy link
Copy Markdown

Two small, independent core safety fixes from the Flutterwave parity review, combined so the stack has one fewer PR. No reviews yet, so nothing is lost by consolidating.

1. Refuse stripe_tax with a non-Stripe provider

taxMode: "stripe_tax" defers tax calculation to Stripe: core returns zero tax and sends automaticTax: true. A provider that ignores automatic_tax would charge the pre-tax total. checkout/create-session now returns 409 stripe_tax_requires_stripe and asks the merchant to switch to flat/table or to Stripe.

2. Harden refund idempotency

The admin refund route generated a fresh refund:${orderId}:${randomId()} on every click. If the provider accepted the refund but the response was lost, a retry could refund twice.

  • admin/orders/refund accepts a refundRequestId; the UI generates one per attempt and reuses it if the request throws.
  • refundOrder returns the recorded refund for a repeated request id instead of calling the provider again.
  • The refund confirmation says “the payment provider” instead of “Stripe”, and a failed provider refund shows an error rather than “Refund issued”.

Tests

  • 5 new tests: stripe_tax refusal + flat-tax pass-through; same-id refund calls the provider once; a different id is a new refund; an empty id is rejected.
  • 320 core tests pass on upstream/main, 0 failures.
  • Typecheck clean.
  • Changesets: one patch (tax guard), one minor (refund idempotency).

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