Skip to content

feat(revenue): Stripe refunds and net revenue tiles - #37

Merged
mlava merged 1 commit into
mainfrom
feat/stripe-refunds
Aug 3, 2026
Merged

feat(revenue): Stripe refunds and net revenue tiles#37
mlava merged 1 commit into
mainfrom
feat/stripe-refunds

Conversation

@mlava

@mlava mlava commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

The one-off product row on the Revenue page now reports refunds — prompted by a live test order that was refunded and still showed as $9 revenue.

  • New client methods: listRefunds(created[gte]) and getOneOffPurchaseByPaymentIntent; sessions now carry their payment_intent.
  • Refunds (succeeded only) are attributed to the one-off product through the PaymentIntent → Checkout Session join, with a capped (20) per-refund session lookup for refunds whose purchase predates the 60-day sessions window.
  • UI: the one-off row grows to four tiles — Purchases, Gross revenue, Refunds (lower is better), Net revenue — all last-30 vs prior-30. Refund windows use the refund's created date (a July refund of a June purchase is a July refund).
  • Graceful degradation: a STRIPE_SECRET_KEY without the Refunds → Read grant gets the old gross-only tiles plus a hint, not an error. Docs updated (.env.example, setup card, spec 0014).
  • get_stripe_revenue MCP output includes refunds/net (or notes the missing grant).

Testing

  • 15 unit tests pass (new: refund windowing; PI-based attribution incl. lookup fallback and cross-product rejection); tsc, oxlint, Prettier clean.

🤖 Generated with Claude Code

…ucts

Refunds live on PaymentIntents, not Checkout Sessions, so refunds from
/v1/refunds are attributed to the one-off product via the session's
payment_intent — with a capped per-refund session lookup for refunds
whose purchase predates the 60-day sessions window. The one-off row
gains Refunds and Net revenue tiles; a key without the Refunds read
grant degrades to the old gross-only tiles with a hint instead of
failing the panel.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mlava
mlava merged commit 12197d6 into main Aug 3, 2026
@mlava
mlava deleted the feat/stripe-refunds branch August 3, 2026 10:07
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