Skip to content

feat: add account/close, billing/plan, payout-methods default, and wallet/pending endpoints#1088

Merged
davedumto merged 1 commit into
davedumto:mainfrom
HasToBeJames:feat/close-1047-1046-1034-1027
Jun 25, 2026
Merged

feat: add account/close, billing/plan, payout-methods default, and wallet/pending endpoints#1088
davedumto merged 1 commit into
davedumto:mainfrom
HasToBeJames:feat/close-1047-1046-1034-1027

Conversation

@HasToBeJames

Copy link
Copy Markdown
Contributor

Description

Implements four missing routes-d endpoints: closing a user account with a reason, fetching subscription plan info, setting a payout method as default, and listing pending wallet balances.

Closes #1047
Closes #1046
Closes #1034
Closes #1027

Changes proposed

What were you told to do?

Implement the four routes-d endpoints listed above with auth, validation, structured errors, and unit tests.

What did I do?

POST /api/routes-d/account/close (#1047)

  • Auth and ownership check via verifyAuthToken + prisma.user
  • Returns 409 if account already closed
  • Validates reason: optional string, max 500 chars, returns 422 on violation
  • Updates user.status to 'closed', returns closedAt timestamp
  • Tests: 401 (no token), 401 (invalid token), 401 (user not found), 409 (already closed), 200 (with reason), 200 (no reason), 422 (reason too long)

GET /api/routes-d/billing/plan (#1046)

  • Auth check, loads user with subscription relation
  • Falls back to 'free' plan when no subscription exists
  • Returns plan key, displayName, monthlyPriceCents, features array, renewsAt, status
  • Plan details table: free/starter/pro/enterprise
  • Tests: 401 (no token), 401 (invalid), 401 (no user), 200 (free fallback), 200 (pro), 200 (enterprise -1 price)

PATCH /api/routes-d/payout-methods/[id]/default (#1034)

  • Auth + ownership check (method must belong to authenticated user)
  • Returns 404 if method not found for user
  • Returns 409 if method already default
  • Uses to atomically unset old default and set new one
  • Tests: 401, 401 (user not found), 404, 409 (already default), 200 (sets new default)

GET /api/routes-d/wallet/pending (#1027)

  • Auth check, returns all pending transactions for user
  • Aggregates totals grouped by currency
  • Returns: pending[], totals{currency: amount}, count
  • Tests: 401 (no token), 401 (invalid), 401 (no user), 200 (empty), 200 (multi-currency totals)

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • This PR does not contain plagiarized content.
  • The title and description of the PR is clear and explains the approach.
  • I am making a pull request against the main branch (left side).
  • My commit messages styles matches our requested structure.
  • The implementation was reviewed and confirmed to work as intended.
  • I am only making changes to files I was requested to.

Screenshots / Validation Evidence

8 files added: 4 route handlers and 4 test files. Auth pattern, error envelopes, and Prisma mock structure match existing routes-d conventions.

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

@HasToBeJames is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@davedumto davedumto merged commit a2c4430 into davedumto:main Jun 25, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants