Repository navigation
feat(give): support account swaps for back campaigns and payment_due notices - #310
Conversation
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
PO acceptance: merge at 8045782 Independent PO flagship money-domain security review (ee890ade-c899-4b4a-ba80-fa2710a5e382): APPROVE (0 P0/P1/P2 findings).
|
Refs #92
Summary
Phase 2 (
DOS/Giveapp surface) following Phase 1 DB migrationDOS/DOS.Me#1873(20261130140000_give_back_campaign_account_swap.sql, merged & deployed to Beta):#55,#92,#264):canAskSwap,approvalBlock,loadEditorAccounts, andrequestAccountSwapto allow finance-approved receiving-account swaps forbackcampaigns inlive,suspended,changes_requested(with recorded transactions; 0-tx still redirects toGIVE_SWAP_USE_RELEASE), andsucceededwhen pledges still have payments due (campaignHasPaymentsDue).#264owner-only money boundary: co-organizers/editors never seeReceivingAccountSectionorAccountSwapBlock, never queryreceiving_accounts/account_swap_requests, and are refused byrequestAccountSwap/cancelAccountSwap.ReceivingAccountSection,AccountSwapBlock,/admin/account-swaps,/adminrecoveryAdvice, andlib/errors.tsVietnamese copy to cover bothgiveandbackcampaigns (removing the obsolete "back campaigns cannot swap" guidance).payment_account_changed) & transactional email (pledge_account_swapped):payment_account_changedrendering inlib/notices.tsand registered it inasksForPaymentsostoppedNoticeCampaigns(#93) hides the payment CTA while payment requests are stopped.pledge_account_swappedtransactional email template inserver/email/templates.ts(no stop/unsubscribe links, live net amount due recomputed net of refunds, deadline,/me/pledges/[code]CTA, HTML/header escaping) andlib/email-outbox.ts(outboxMaxAgeDays = 14, Vietnamese label).maskedAccountLast4,swappedNewAccountLine,swappedOldAccountTarget) across in-app notices and emails so raw multi-digit account numbers can never leak even from malformed payloads.pnpm format:check,pnpm lint,pnpm typecheck,pnpm test(181 files / 2,675 tests), andpnpm buildall pass locally.📌 TL;DR
This PR extends the account swap feature to support "back" (reward-based) campaigns, allowing organizers to request account changes for live, suspended, or succeeded campaigns with pending payments. It updates the admin review interface to validate payment obligations and ensures backers are notified of new payment details upon approval.
🎯 Type of Change
🔍 Changes Walkthrough
apps/web/src/lib/account-swaps.tscanAskSwapnow acceptshasPaymentsDueto allow swaps for succeeded back campaigns. AddedcampaignHasPaymentsDueandcampaignsWithPaymentsDuehelpers to query pending pledges. UpdatedapprovalBlockto validate payment status for back campaigns.apps/web/src/lib/campaign-account.tsloadEditorAccountsto fetch payment status and swap requests for back campaigns. ModifiedcheckSubmitAccountto direct back campaigns with transactions to the swap flow instead of "contact support".apps/web/src/app/me/campaigns/swap-actions.tsrequestAccountSwapnow checks for pending payments on succeeded back campaigns before allowing the request.apps/web/src/app/me/campaigns/[id]/page.tsxReceivingAccountSectionandAccountSwapBlocknow render for back campaigns when eligible. Added specific copy for backers regarding payment updates.apps/web/src/app/admin/account-swaps/page.tsxhasPaymentsDuetoSwapCardto enable/disable approval based on whether the back campaign still has obligations.apps/web/src/app/admin/account-swaps/actions.tsrevalidatePathfor pledge and notice pages to ensure UI updates immediately after approval.apps/web/src/app/me/notices/page.test.tspayment_account_changednotices, verifying distinct CTAs for active vs. stopped campaigns.apps/web/src/app/admin/account-swaps/page.test.tsapps/web/src/app/me/campaigns/[id]/page.test.tsapps/web/src/app/me/campaigns/swap-actions.test.tsapps/web/src/lib/account-swaps.test.tscanAskSwapandapprovalBlockto reflect new back campaign logic.apps/web/src/lib/campaign-account.test.tsloadEditorAccountsandcheckSubmitAccountto verify new data fetching and messaging.apps/web/src/app/admin/page.test.ts📊 Architectural Flow
sequenceDiagram participant Organizer participant Web_App as Web App (Organizer) participant DB as Database participant Admin as Admin (Finance) participant Backer as Backer Note over Organizer, Web_App: Request Swap Organizer->>Web_App: Request Account Swap Web_App->>DB: Check Campaign Status & Pending Payments alt Succeeded Back Campaign with Payments Due Web_App->>DB: Create Swap Request (Pending) else Ineligible Web_App-->>Organizer: Show Error/Contact Support end Note over Admin, Web_App: Review & Approve Admin->>Web_App: Review Swap Request Web_App->>DB: Verify Payments Still Due (if Back Campaign) alt Valid & Payments Due Admin->>Web_App: Approve Swap Web_App->>DB: Execute Swap (Old Binding End, New Binding Start) Web_App->>DB: Create Notice for Backers with Pending Payments Web_App-->>Admin: Success (Backers Notified) else No Payments Due Web_App-->>Admin: Block Approval (No Obligations) end Note over Backer, Web_App: Notification Backer->>Web_App: View Notices Web_App-->>Backer: Show New Payment Details & CTA