Inspiration
A small seller facing a payment dispute has a decision to make before writing a response. Does the evidence support fighting it, or is it better to accept the claim or offer a settlement? Counterclaim helps the seller make that call with the records in front of them.
What it does
Counterclaim pulls disputes from the PayPal sandbox and combines them with available seller records. It produces a case file with clickable citations, missing proof, conditional financial outcomes, and a recommended response. In the weak-delivery replay, the recommendation is “Don’t fight this one.” The tracking stalled and the address did not match.
Before sending, the seller reviews the exact note and evidence PDF. The app excludes internal costs, confidence, strategy, and policy records from the outbound packet. Approval binds the reviewed version and PDF bytes. A separate Send action rechecks the current PayPal stage and available actions. When the submission outcome is uncertain, the app locks the attempt to prevent an accidental duplicate.
How we built it
Next.js, React, TypeScript, and SQLite power the app. AG Grid Community runs the dispute queue, with sorting, search, and currency-separated totals. Through OpenRouter, the AI reads disputes, orders, and seller records using four read-only tools. Zod and deterministic checks verify structure, citations, money, and privacy before approval. A separate PayPal sandbox REST adapter handles approved writes, and pdf-lib builds the evidence PDF.
Challenges we ran into
In our November 5–6 UTC sandbox test, PayPal rejected signature evidence at inquiry and accepted fulfillment evidence with tracking. Reviewing the buyer’s view exposed internal costs in our first note, so we added an allowlisted outbound packet and made the exclusions visible at approval. When the case escalated to chargeback, Counterclaim blocked the old approval and required a new investigation and review.
Accomplishments that we’re proud of
We exercised a $10 item-not-received dispute in PayPal’s sandbox from import through AI investigation, seller approval, accepted evidence at two stages, and synced closure. We selected the final seller-favor outcome using a sandbox control. It provides no evidence about real-world win rates.
The read-only demo includes four recorded AI runs on synthetic seller records: fight, refund, settlement offer, and a case with a hostile instruction embedded in a record. A separate replay reconstructs the prior sandbox timeline. Each case is labeled with its source.
What we learned
The seller’s internal case file and the buyer-facing response have different jobs. The first needs costs, gaps, and reasoning. The second needs only the reviewed evidence and response. Sandbox stages and evidence rules can change while someone works, so we verify the current PayPal state again at send time.
What’s next
We plan to verify live webhook delivery, expand live-model evaluation, and test handling time and decision quality with consenting sellers.
Built With
- ag
- grid
- next.js
- openrouter
- paypal
- react
- sqlite
- typescript