Inspiration
Small shops that sell with PayPal lose disputes they should win. The owner is busy running the shop, the response deadline slips by, or the proof that would win (a tracking number, a delivery scan) never reaches PayPal. Then there is the hard call: refund or fight? Without a clear read of the evidence it's a guess either way. I wanted a clerk that does the tedious part, never misses a deadline, and leaves the decision with the owner.
What it does
Verdict is an AI dispute clerk for small PayPal merchants, running against the PayPal sandbox.
- War Room. Every open dispute with a live deadline clock, money at stake, evidence strength and Verdict's recommendation. New disputes arrive by PayPal webhook. The dashboard is built with AG Studio and AG Grid: custom widgets (deadline clocks, an evidence gauge), charts that cross-filter the page, and an assistant (Claude running inside AG Studio's Agent Framework) that answers questions and adds charts.
- Case File. Verdict's agent, Claude with read-only tools, reads the PayPal dispute, the order, the tracking, the customer's history and the shop's Playbook, then recommends: refund in full, offer a partial refund, contest with evidence, or hand it to the owner. Every piece of evidence cites a real store record, and every answer passes guardrails before the owner sees it. The owner approves, edits or overrides, and only then does Verdict re-check the dispute with PayPal and send the response through the PayPal Disputes API.
- Arena. A wind tunnel for the dispute strategy. A Claude buyer agent (honest, mistaken, opportunistic or aggressive) disputes a fictional order, Verdict responds, and a SIMULATED rule-based arbiter, a stand-in for PayPal's reviewers, rules on it. It reports right calls by dispute type, weak spots and money kept, and a policy slider shows what auto-refunding small disputes would cost.
How we built it
- PayPal: Orders v2 (vaulted sandbox buyer), Shipment Tracking, the Disputes API (list, get, accept claim, make offer, provide evidence, provide supporting info, plus the sandbox-only adjudicate and require-evidence), and verified webhooks (
CUSTOMER.DISPUTE.CREATED/UPDATED/RESOLVED) with a polling fallback. Before every action, Verdict re-fetches the dispute and only uses actions PayPal offers and the documented stage rules allow. - Claude (Anthropic SDK): the defender agent uses tool use with Zod-validated structured output. It has seven read-only tools, and the server, not the model, builds every evidence item from database records. Guardrails check the allowed action, the evidence citations, the Playbook's thresholds and confidence, and a prompt-injection screen on buyer text. Every decision goes to an audit log. Claude also plays the Arena's buyer agent and powers a custom adapter for the AG Studio Agent Framework.
- App: Next.js (App Router) and TypeScript, SQLite (better-sqlite3) seeded on boot, Tailwind, Zod everywhere. Vitest (132 tests on recorded sandbox fixtures), Playwright end-to-end with axe accessibility checks, and an evaluation harness.
- Hosting: Render. The public demo runs in a clearly labelled REPLAY mode built from recorded sandbox disputes, so it never depends on sandbox uptime, with rate and cost limits on anything that calls Claude.
Challenges we ran into
- The sandbox dispute lifecycle. Disputes publish about 3 minutes after filing. Inquiries and claims allow different actions, some actions appear only 10–20 minutes later, and some documented evidence types are rejected in practice. We recorded what the sandbox actually does in
docs/api-notes.mdand gated every action on it. - Untrusted buyer text. Buyer messages go to the model, so we fence them as data, screen them for instructions aimed at the AI, and flag those cases for the owner instead of acting.
- Honest evaluation. PayPal's real decisions aren't available in the sandbox, so we wrote a rule-based arbiter from PayPal's published seller-protection rules and labelled it SIMULATED everywhere it appears.
Accomplishments that we're proud of
- A full real loop in the PayPal sandbox: a buyer files, the webhook arrives, Claude builds the case, the owner approves, and PayPal receives the response.
- On 20 labelled scenarios (SIMULATED,
npm run eval): 95% right action, 100% routed to a human when required, 100% valid evidence citations, 100% prompt-injection resistance, about 9 seconds and $0.03 per dispute. - An Arena that finds real weak spots in the strategy, such as late-delivery claims where the parcel arrived after the claim was filed.
What we learned
Sandbox behaviour beats the docs: record real responses and test against them. Keep the model's job narrow (read and recommend) and let code own the money-moving actions. And being explicit about what's real and what's simulated makes a demo more convincing, not less.
What's next for Verdict
Calibrating against real PayPal outcomes, multiple merchants and stores, Venmo and card chargebacks, appeals, and a store-platform integration so the order and shipping records come straight from the shop.
Built With
- ag-grid
- ag-studio
- anthropic
- claude
- next.js
- paypal
- paypal-disputes-api
- paypal-rest-api
- playwright
- react
- render
- sqlite
- tailwindcss
- typescript
- vitest
- webhooks
- zod