Skip to content

fix(billing): make billable-GMV event types explicit + extensible - #70

Open
keithfawcett wants to merge 1 commit into
mainfrom
fix/metering-billable-types
Open

fix(billing): make billable-GMV event types explicit + extensible#70
keithfawcett wants to merge 1 commit into
mainfrom
fix/metering-billable-types

Conversation

@keithfawcett

Copy link
Copy Markdown
Contributor

Problem (audit #3 — HIGH)

Metering counted only invoice_paid + subscription_created toward attributed GMV. A merchant reporting revenue under a custom event type (e.g. order_paid) accrued partner commissions but escaped the platform % (revshare 3% / flex 1.5%).

Fix (the safe option, chosen with the owner)

Make the billable set an explicit, documented semantic: default to the two Stripe-native types; extend via OPENPARTNER_BILLABLE_EVENT_TYPES_EXTRA (comma-separated) for operator-known custom revenue types. aggregateAttributedGmv now takes the event-type set (default = configured).

Why this over the alternatives

No GMV definition is fully dodge-proof on merchant self-reported data:

  • percent-commission base just moves the dodge to fixed commissions, and changes existing invoices in both directions;
  • count all attributed value>0 over-bills when a merchant attaches an arbitrary value to a non-revenue event.

The allowlist changes no existing invoice, makes the semantic explicit (what the review asked for), and lets the operator add a tenant's custom revenue type the moment it's noticed. Per-tenant granularity + auto-detection are follow-ups.

Tests

A custom order_paid conversion is excluded by default (reproduces the leak) and counted once it's in the billable set. Typecheck clean.

🤖 Generated with Claude Code

Metering counted only invoice_paid + subscription_created toward attributed
GMV, so a merchant reporting revenue under a CUSTOM event type accrued partner
commissions but escaped the platform % (revshare 3% / flex 1.5%). Make the
billable set an explicit, documented semantic: default to the two Stripe-
native types, extend via OPENPARTNER_BILLABLE_EVENT_TYPES_EXTRA (comma-
separated) for operator-known custom revenue types. aggregateAttributedGmv
now takes the event-type set (default = configured) so it's explicit at the
call site and testable.

Chosen (with the user) as the safe option: it changes NO existing invoice and
locks in no possibly-wrong auto-semantic — no GMV definition is fully
dodge-proof on self-reported data (percent-base just moves the dodge to fixed
commissions; count-all over-bills mislabeled values). Per-tenant granularity
+ auto-detection are follow-ups.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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