Skip to content

Notify partners via email when a stablecoin payout fails or is returned - #4264

Open
devkiran wants to merge 2 commits into
mainfrom
stablecoin-payout-failed-email
Open

Notify partners via email when a stablecoin payout fails or is returned#4264
devkiran wants to merge 2 commits into
mainfrom
stablecoin-payout-failed-email

Conversation

@devkiran

@devkiran devkiran commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added email notifications for partners when stablecoin payouts fail or are returned.
    • Notifications include payout details, program information, wallet details, and failure reasons when available.
    • Added links to reconnect payout wallets and retry failed payouts.

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dub Ready Ready Preview Aug 4, 2026 10:11am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Stablecoin payout notifications

Layer / File(s) Summary
Failure notification email template
packages/email/src/templates/partner-stablecoin-payout-failed.tsx
Adds the partner email template with payout details, wallet data, failure reasons, retry instructions, and footer content.
Payout failure notification workflow
apps/web/app/(ee)/api/stripe/connect/v2/webhook/utils/notify-partner-stablecoin-payout-failed.ts
Finds failed payouts, aggregates payout and program data, masks wallet addresses, validates partner email data, and sends the notification.
Webhook notification wiring
apps/web/app/(ee)/api/stripe/connect/v2/webhook/outbound-payment-failed.ts, apps/web/app/(ee)/api/stripe/connect/v2/webhook/outbound-payment-returned.ts
Invokes the notification workflow after failed payout records are updated for failed and returned outbound payments.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OutboundPaymentWebhook
  participant notifyPartnerStablecoinPayoutFailed
  participant PartnerStablecoinPayoutFailed
  OutboundPaymentWebhook->>notifyPartnerStablecoinPayoutFailed: invoke after failed payout update
  notifyPartnerStablecoinPayoutFailed->>PartnerStablecoinPayoutFailed: provide aggregated payout and partner data
  PartnerStablecoinPayoutFailed-->>notifyPartnerStablecoinPayoutFailed: render notification email
Loading

Possibly related PRs

Suggested reviewers: pepeladeira, steven-tey

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: notifying partners by email when stablecoin payouts fail or are returned.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stablecoin-payout-failed-email

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/web/app/`(ee)/api/stripe/connect/v2/webhook/utils/notify-partner-stablecoin-payout-failed.ts:
- Around line 84-87: Update the logging in the stablecoin payout failure
notification flow to remove partner.email and the full emailResponse from
console.log. Use the available non-PII payout identifier and log only a minimal
delivery status, preserving the existing notification behavior and avoiding
provider metadata.
- Around line 65-82: Update notifyPartnerStablecoinPayoutFailed to atomically
claim or create a unique durable notification/outbox record keyed by
outboundPaymentId before calling sendEmail. Return without sending when the
claim already exists, mark the claim delivered only after successful email
delivery, and preserve retryability by leaving failed sends uncompleted so
webhook replays can retry without duplicating successful emails.
- Around line 43-59: Prevent cross-partner aggregation in the notification flow
around payouts.findMany and notifyPartnerStablecoinPayoutFailed: either enforce
a durable uniqueness constraint on the stripePayoutId/partner combination, or
scope the query and aggregation to a single partner before using
payouts[0].partner, totalAmount, and programs. Ensure one partner’s payout data
can never be included in another partner’s email.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b8045399-4735-4a95-aebb-90566c8f6fce

📥 Commits

Reviewing files that changed from the base of the PR and between bac6b33 and 97ee02d.

📒 Files selected for processing (4)
  • apps/web/app/(ee)/api/stripe/connect/v2/webhook/outbound-payment-failed.ts
  • apps/web/app/(ee)/api/stripe/connect/v2/webhook/outbound-payment-returned.ts
  • apps/web/app/(ee)/api/stripe/connect/v2/webhook/utils/notify-partner-stablecoin-payout-failed.ts
  • packages/email/src/templates/partner-stablecoin-payout-failed.tsx

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