Skip to content

Fix LOB-BANK-DIAGNOSTIC: Owner-only endpoint to fetch Lob's view of a bank account#202

Open
bmoss2015 wants to merge 1 commit into
mainfrom
fix/lob-bank-diagnostic
Open

Fix LOB-BANK-DIAGNOSTIC: Owner-only endpoint to fetch Lob's view of a bank account#202
bmoss2015 wants to merge 1 commit into
mainfrom
fix/lob-bank-diagnostic

Conversation

@bmoss2015

Copy link
Copy Markdown
Owner

Why

The bank Bree added Friday 6/19 has gone through two rounds of $0.01 deposit + immediate reversal with no second micro-deposit, and the same pattern happened in May. Our DB only shows what we wrote into it (status=unverified, 0 attempts). It does not tell us what Lob has recorded about the verification attempts, ACH return codes, or whether Lob thinks the account is failed vs pending.

This adds a one-shot diagnostic so we can see Lob's authoritative view.

What

  • lobGetBankAccount(bnkId) helper in lib/mail/lob.ts — calls GET /v1/bank_accounts/{id} and returns the raw Lob response object
  • /api/admin/lob-bank-debug — owner-only Next.js route handler that joins the portal row with the live Lob lookup

Usage

Sign in to app.nextsurplus.com as owner, then visit either:

  • https://app.nextsurplus.com/api/admin/lob-bank-debug?id=edfbe660-8ee8-4b85-b3d6-53682f2ee134 (the unverified Mercury account)
  • https://app.nextsurplus.com/api/admin/lob-bank-debug?lob_id=bank_5b6b93b4d5730ab (direct Lob ID)

Returns bare JSON: { ok, portal_row, lob_bank_id, lob_response: { ok, raw: { ... } } }.

Test plan

  • npx tsc --noEmit passes
  • Preview deploys clean
  • Hitting the URL as owner returns Lob's bank_account object
  • Hitting the URL as non-owner returns 403

🤖 Generated with Claude Code

… bank account

After two rounds of the $0.01-and-immediate-reversal pattern with no
second micro-deposit landing, we need to see what Lob actually thinks
about bank_5b6b93b4d5730ab. Our DB only shows what we wrote, not what
Lob has recorded (verification_status, attempts, reversal codes,
signatory mismatch, etc).

Adds:
- lobGetBankAccount helper in lib/mail/lob.ts that calls GET /v1/
  bank_accounts/{id} and returns the raw Lob response untouched
- /api/admin/lob-bank-debug owner-only endpoint that joins the portal
  row with the live Lob lookup. Returns bare JSON, no UI.

Usage:
  GET /api/admin/lob-bank-debug?id=<mail_bank_accounts.id>
  GET /api/admin/lob-bank-debug?lob_id=bank_xxxxxxxxxxxxxxx

One-shot diagnostic. Kept around for future bank-verification debugging.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
moss-equity-portal Ready Ready Preview, Comment Jun 24, 2026 8:03pm

Request Review

@supabase

supabase Bot commented Jun 24, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project rsdmyydyhqgkkvwlklif because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

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