Repository navigation
feat(billing): record affiliate commission in billing history - #4278
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
Warning Review limit reached
This review includes 35 billable files and costs up to $8.75.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 16 minutes for your next included review. View limit details
|
1d50ba2 to
7f67a5b
Compare
d3b6cd9 to
78d73c9
Compare
|
@claude review |
There was a problem hiding this comment.
An organization admin can view or raise the monthly spending cap at claude.ai/admin-settings/usage, on the Claude Code Review row under Services. The cap resets at the start of the next billing period.
Once the cap resets or is raised, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
78d73c9 to
bd1213b
Compare
80eb401 to
1d9a57c
Compare
bd1213b to
9e54cd2
Compare
1d9a57c to
b020646
Compare
4de533a to
a283986
Compare
b020646 to
10cb1a6
Compare
a283986 to
7e24410
Compare
7e24410 to
3d06a3a
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4278 +/- ##
==========================================
+ Coverage 94.89% 95.10% +0.20%
==========================================
Files 2145 2077 -68
Lines 62324 60619 -1705
Branches 15578 15256 -322
==========================================
- Hits 59143 57649 -1494
+ Misses 2861 2665 -196
+ Partials 320 305 -15
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
3d06a3a to
92f853c
Compare
Referred sign-ups now get the env-configured referral trial deployment allowance instead of the standard trial amount, exposed via GET /v1/referral and shown on the onboarding page.
Kills two surviving mutants from the stryker run: a zero-cents edge case on the recorded referral trial amount, and a sign check on the trial activation latency passed to instrumentation.
recordTrialGranted ran after the wallet was marked activatedAt, so a failure there left the trial credits unrecorded while the retry short-circuited on the already-activated wallet and reported success. Granting on-chain, then recording the referral trial, then activating means a failure anywhere leaves the wallet unactivated and the retry replays the whole sequence.
A referred user briefly saw the default trial amount before the referral query resolved and swapped in the referral amount.
Adds the `affiliate_commission` stripe_transactions type and a source_transaction_id column so a future commission job can link a grant back to the payment it was earned on, and plumbs the new type through the API schema, http-sdk, billing history UI and the credits-added Slack alert. - add enum value + source_transaction_id (partial unique index) via migration 0075_affiliate_commission - add StripeTransactionRepository.createAffiliateCommission, findAffiliateCommissionBySource(AndLock) - regenerate the OpenAPI spec and console-api-types
… of blocking it source_transaction_id defaulted to ON DELETE NO ACTION, so deleting a referred user (which cascades to their payment row) would fail with an FK violation once the affiliate's commission row referenced that payment. The commission is the affiliate's ledger entry and must survive account deletion with its source link severed, so the FK is ON DELETE SET NULL instead. 0075_affiliate_commission is unreleased, so the migration and its snapshot are updated in place rather than adding a new one.
"Refunded" on a commission row read as money returned to the affiliate, when the commission was in fact taken back.
92f853c to
d50dd71
Compare
Why
Part of CON-1191. Affiliate commission is paid as Console credit, and it has to show up in the affiliate's billing history like any other credit. This PR adds the transaction type and the storage; the next one grants the commission.
Merges after #4277. It targets main so CI runs; until #4277 merges, the diff also shows the PRs below it.
What
stripe_transactionsgets theaffiliate_commissiontype and asource_transaction_idcolumn pointing at the referred user's payment (migration 0128). A partial unique index allows at most one commission per payment. If the referred user's account is deleted, the commission row stays on the affiliate's ledger and its source becomes null.payment_intentrows count as a purchase, so a commission can never trigger the first-purchase bonus.Testing
Repository integration specs (create, find, lock, unique violation, deleting the referred user), plus BillingView and Slack message specs. Mutation score on changed lines: API 100%, deploy-web 100%.
Screenshots
Billing history with test data: a commission credit, a commission fully taken back after a refund, a card payment and a coupon.