Inspiration## Inspiration
I hang out in import/export communities. The same story shows up every week: someone finds a supplier on Alibaba, gets a great price, wires a 30% deposit, and the "factory" turns out to be someone in an apartment borrowing a real manufacturer's licence. By the time you know, the money's gone.
The deposit is the moment everything turns. Before you send it, you have leverage. After, you don't. PayPal gives purchase protection — but only if you catch the problem before you approve the payment. I wanted to build the thing that catches it.
What It Does
You paste a supplier's invoice, listing, or just a company name + registration number. ProofBeforePay runs a full investigation:
- Reads the message — extracts every checkable claim (company name, licence, address, certificates, payment details).
- Checks each claim — lookups against corporate registries, customs databases, certificate directories, satellite maps, and the web. Each finding can trigger a follow-up on a new source.
- Argues with itself — a second model tries to prove the verdict wrong.
- Decides — Proceed, Verify First, or Stop.
- Gates PayPal — the verdict isn't advice. It controls what PayPal does with the money:
- Proceed →
Orders v2,intent: CAPTURE— paid directly, with Purchase Protection. - Verify first →
intent: AUTHORIZE— money held, released only after the supplier proves the open questions. - Stop → no PayPal order is ever created. Blocked in code.
- Proceed →
How I Built It
Backend — Python / FastAPI. The investigation pipeline loops: each Tavily web lookup can surface a new inconsistency, which triggers another lookup on a different source, until nothing new comes up. Three NVIDIA Nemotron model tiers keep costs honest — Nano handles the 9+ page-reading calls per run, Super runs the adversarial challenge, Ultra reads everything once and makes the final call.
Frontend — Next.js 16, React 19, TypeScript, Tailwind CSS 4. The report has a Proof Trail: click any source and the full path from evidence to verdict lights up. GSAP handles scroll animations, Three.js renders a particle field in the hero.
PayPal — Orders v2 API (sandbox). The hold flow is the interesting part: AUTHORIZE reserves the buyer's funds, then the supplier's proof is reviewed against the report's open questions before a CAPTURE or VOID. A code-level rule blocks releasing funds if the supplier asks for Friends & Family, crypto, or a different account holder — regardless of what the AI concludes.
Infrastructure — Supabase for auth and persistence, Render for hosting, Docker for the backend container.
Challenges
The hold flow timing. PayPal's AUTHORIZE has a 3-day honor period (extendable to 29 days). Getting the capture/void logic right with webhook confirmations and edge cases (what if the authorization expires before the supplier responds?) took real debugging.
Citation integrity. Saying "the licence belongs to another company" is only useful if you can point at the exact page that proves it. Building the chain where each finding cites a specific source URL — and rendering that chain visually in the report — was the hardest UI problem.
Cost control. Running everything through Nemotron Ultra would cost ~$0.40/check. Routing the frequent, simple jobs (read a registry page, extract a licence number) to Nano and reserving Ultra for the single final judgment brought it to ~$0.06 average. Figuring out which tasks actually need the big model took iteration.
False positives. A missing customs record doesn't prove fraud — the company might be new or trade domestically. Distinguishing "no evidence found" from "evidence contradicts the claim" was a design problem as much as a coding one.
What I Learned
- PayPal's Orders v2 is well-designed for conditional payment flows. AUTHORIZE/CAPTURE maps cleanly onto "hold until proven."
- Multi-model routing isn't just about cost — Nano is genuinely better at structured extraction because it doesn't overthink simple tasks.
- The adversarial step (Super arguing against Ultra's verdict) catches real errors. In testing it downgraded ~15% of Stop verdicts to Verify First with legitimate reasoning.
- Building something that touches real money, even in sandbox, forces a level of care that a pure demo doesn't.