-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix queueStripePayouts #3138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix queueStripePayouts #3138
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughUpdates the Prisma query used by the Stripe payout cron to require that partners have a non-null Changes
Estimated code review effortπ― 1 (Trivial) | β±οΈ ~3 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touchesβ Failed checks (1 warning)
β Passed checks (2 passed)
β¨ Finishing touches
π§ͺ Generate unit tests (beta)
π Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro π Files selected for processing (1)
π§ Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
π§Ή Nitpick comments (1)
apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts (1)
48-55: Consider adding observability logging for filtered partners.Similar to the existing logging for missing
chargeId(lines 32-40), consider logging when partners are filtered out due to missingstripeConnectIdorpayoutsEnabledAt. This would help with debugging if someone expects a payout to be queued but it isn't.You could add logging after the query like this:
const partnersInCurrentInvoice = await prisma.payout.groupBy({ by: ["partnerId"], where: { invoiceId, status: "processing", mode: "internal", partner: { stripeConnectId: { not: null, }, payoutsEnabledAt: { not: null, }, }, }, }); + + // Log if no partners were found to help with debugging + if (partnersInCurrentInvoice.length === 0) { + await log({ + message: `No eligible partners found for Stripe payouts in invoice ${invoiceId} (partners must have stripeConnectId and payoutsEnabledAt set)`, + type: "info", + }); + }
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (1)
apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts(1 hunks)
π§° Additional context used
π§ Learnings (3)
π Common learnings
Learnt from: devkiran
Repo: dubinc/dub PR: 2635
File: packages/prisma/schema/payout.prisma:24-25
Timestamp: 2025-07-11T16:28:55.693Z
Learning: In the Dub codebase, multiple payout records can now share the same stripeTransferId because payouts are grouped by partner and processed as single Stripe transfers. This is why the unique constraint was removed from the stripeTransferId field in the Payout model - a single transfer can include multiple payouts for the same partner.
π Learning: 2025-07-11T16:28:55.693Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2635
File: packages/prisma/schema/payout.prisma:24-25
Timestamp: 2025-07-11T16:28:55.693Z
Learning: In the Dub codebase, multiple payout records can now share the same stripeTransferId because payouts are grouped by partner and processed as single Stripe transfers. This is why the unique constraint was removed from the stripeTransferId field in the Payout model - a single transfer can include multiple payouts for the same partner.
Applied to files:
apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts
π Learning: 2025-08-25T21:41:06.073Z
Learnt from: steven-tey
Repo: dubinc/dub PR: 2758
File: apps/web/app/(ee)/api/cron/payouts/balance-available/route.ts:43-45
Timestamp: 2025-08-25T21:41:06.073Z
Learning: For Stripe API calls on connected accounts, the stripeAccount parameter should be passed in the first parameter object (e.g., stripe.balance.retrieve({ stripeAccount })), not as request options in the second parameter.
Applied to files:
apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
π Additional comments (1)
apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts (1)
48-55: Filter correctly prevents invalid Stripe payouts and follows established patterns.The partner validation filters are defensive and necessary. Upstream validation in
getPayoutEligibilityFilteralready requirespayoutsEnabledAtto be non-null for internal mode payouts at creation time, but webhooks can later disable payouts for partners, making the query-time checks essential. The pattern mirrors the already-deployed PayPal processing logic, which similarly filters for non-nullpayoutsEnabledAt. ThestripeConnectIdcheck is critical since Stripe transfers require a valid Connect account. If no partners match the filter criteria, the query gracefully returns an empty array with no side effects.
Summary by CodeRabbit
βοΈ Tip: You can customize this high-level summary in your review settings.