Inspiration

Most PayPal sellers who lose a dispute don't lose it because they were wrong. They lose it because they ran out of time, or because they answered with the wrong thing.

When a buyer opens a dispute, PayPal gives the seller a respond-by date. Miss it, and the case closes in the buyer's favour. Answer it, and you still have to collect the proof yourself: the order, the shipping address, the item, the tracking number, the delivery date. That information is spread across PayPal, your store and your carrier. Then you have to pick the evidence type PayPal expects and write a clear, factual statement, usually at the end of a long day of running the shop.

A large company has a team for this. A one-person store selling handmade throws has an inbox and a deadline.

We wanted to build the colleague that small seller doesn't have. It reads every new dispute the moment it arrives, puts the facts together, says honestly whether the case is worth fighting, and writes the answer. The final click stays with the seller.

What it does

DisputeShield connects to a merchant's PayPal account and turns each new dispute into a ready answer in four steps:

  1. A dispute arrives. A verified PayPal webhook brings it into the queue straight away, and a check every minute catches anything a webhook misses. The queue is ordered by deadline.
  2. The case is built from PayPal's own records. DisputeShield reads the disputed payment, the order behind it (buyer, ship-to address, items, tracking) and, for other payments, PayPal's transaction history. Nobody types the facts in.
  3. Gemini analyses it when it arrives. It returns a structured verdict:
    • fight, refund, or "more information needed";
    • a strength score from 0 to 100;
    • the evidence type PayPal expects;
    • the statement to send to PayPal and a polite message for the buyer;
    • the strengths, the risks and the evidence that is still missing;
    • every fact it relied on, shown as a chip the seller can check.
  4. The seller decides. They can:
    • edit the draft and submit it to PayPal with an evidence PDF that DisputeShield generates;
    • message the buyer first;
    • accept the claim and refund. A second click confirms the amount, so nobody refunds by accident.

Nothing reaches PayPal until the seller clicks.

Around that core:

  • Overview. Money at risk, cases due in the next 48 hours, Gemini's strength score for each open case, dispute reasons, a 14-day trend and a full activity log.
  • Dispute queue. A searchable, sortable table with CSV export.
  • Payments page. It creates real PayPal sandbox orders, so anyone can test the whole loop from checkout to dispute to resolution.
  • Live landing page. Its numbers (disputes handled, win rate, money kept, the latest cases and the next deadline) come from the database.

How we built it

PayPal integration (Node.js, no dependencies). The server uses only Node's built-in http module and fetch, with zero npm packages. One PayPal client covers:

  • OAuth, with a cached token and retries;
  • Orders v2, Payments v2 and Transaction Search;
  • the Disputes API: list, details, provide evidence, provide supporting info, send a message, accept a claim, escalate;
  • webhook registration and signature verification.

We wrote the multipart uploader and the PDF generator for the evidence file ourselves.

PayPal decides which buttons exist. Each dispute from PayPal comes with links to the actions allowed right now. The interface only shows a button when the matching link is there, so the app never offers something PayPal would reject.

Gemini with structured output. We call Gemini's generateContent REST API with a JSON schema, so every analysis has the same shape and the app can render and check it. The prompt has a few hard rules:

  • use only facts present in the input;
  • never invent tracking numbers, dates, addresses or conversations;
  • check dates against each other and against today. Shipping before payment, or a delivery date in the future, gets listed as a risk instead of quoted to PayPal.

Gemini models are sometimes busy, so a fallback chain keeps analysis running: a busy model rests for 60 seconds, and the model that worked last time is tried first.

Data in Supabase. Supabase (Postgres) stores cases, PayPal facts, analyses, submissions, activity and payments, with a local JSON backup. The public stats endpoint sends cases without buyer names or email addresses.

Frontend. Plain JavaScript and CSS, with no framework and no build step, plus AG Grid for the queue and a Content-Security-Policy on every response.

Hosting. The app runs on Render's free plan. Free apps sleep after 15 idle minutes, so a keep-awake ping keeps it ready for judges.

Testing. 24 automated tests (Node's built-in test runner), plus scripted headless-Chrome user flows at phone, tablet and desktop sizes.

The dashboard numbers are deliberately simple and honest. Only decided cases count toward the win rate, and cancelled cases count toward neither number:

$$\text{win rate} = \frac{\text{won}}{\text{won} + \text{refunded}} \qquad\qquad \text{money at risk} = \sum_{d \,\in\, \text{open}} \text{amount}(d)$$

Challenges we ran into

PayPal's sandbox taught us a lot, and each lesson cost real hours.

  • Card payments are off in a default sandbox account (PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING), so test buyers have to pay with sandbox PayPal accounts. Our first buyer account was created in India, and checkout refused it with "this seller doesn't accept payments in your currency". A US buyer account fixed it.
  • A seller's app can't create disputes. PayPal's create-dispute API needs buyer-side permissions. So we opened disputes the way a real customer would, from the sandbox buyer's account.
  • The sandbox runs on its own clock. Right after we asked PayPal to require evidence, the "provide evidence" link wasn't there yet, so our first submission went in as supporting information instead. Now DisputeShield waits for PayPal's link before it submits. The sandbox ruling step is also only available about 30 minutes after a dispute is created, and a request sent while a case is changing state can fail, so we retry once.
  • Allowed evidence types depend on the case state. At one point PayPal refused PROOF_OF_FULFILLMENT (EVIDENCE_TYPE_IS_NOT_ALLOWED). Instead of failing, the app falls back to OTHER with the PDF attached.
  • Accepting a claim takes a different request format from the one we expected. We send JSON first and fall back to the multipart format PayPal documents.
  • AI models change under you. During testing, one Gemini model returned "not found" for our key and others were overloaded. That is why the fallback chain exists.
  • Keeping the AI honest. An answer that only sounds right isn't good enough when it goes to PayPal in the seller's name. The JSON schema, the facts-only rules, the date check and the visible fact chips make every claim checkable.
  • Real data only. We decided early that the product never shows invented data. Without PayPal credentials the API returns an error instead of sample data. That made the demo harder, because every number had to come from real sandbox payments and disputes. It also means everything in our video actually happened.
  • Two servers, one database. A local server and the hosted one, both pointed at the same Supabase project, overwrote each other's records. Now exactly one server writes.

Accomplishments that we're proud of

It works end to end on real PayPal sandbox data. We took real sandbox payments, opened real disputes as a buyer, and resolved both through DisputeShield:

  • PP-R-KZL-10200251, item not received, $89.
    • Gemini recommended fighting (strength 70/100).
    • We sent the evidence and the generated PDF through the Disputes API.
    • The case closed in the seller's favour, so the $89 was kept.
    • In the sandbox no PayPal agent reviews cases. The ruling is triggered with PayPal's sandbox adjudication endpoint once the evidence is on file, and we chose the seller-wins outcome there.
  • PP-R-XWS-10200290, not as described, $129.
    • Gemini said it needed more information (45/100).
    • We sent the buyer a message through PayPal first.
    • We then accepted the claim and refunded, to show the other path. PayPal refunded the buyer and closed the case.

We're also proud of:

  • No mock data anywhere. Every number on the landing page and dashboard comes from PayPal and our database.
  • Humans stay in control. Gemini drafts and people decide. Refunds need two clicks.
  • A small, auditable codebase. Under 5,000 lines with zero runtime dependencies, our own PDF writer and multipart encoder, and secrets only in environment variables.
  • A product, not a script. It works from 360px phones up to large desktops, with deadlines, charts, CSV export and a live landing page.

What we learned

  • PayPal's API tells you what's allowed, so listen to it. Driving the interface from the action links PayPal returns removed a whole class of "why did PayPal reject this?" errors.
  • Structured output is what makes an AI model usable in a workflow. A schema, a short list of hard rules and visible sources did more than a longer prompt ever did.
  • "Should we fight?" matters as much as "how do we fight?" Sometimes the right answer is a quick refund. A tool that always says "fight" wastes the seller's time and money.
  • A sandbox is not production. Timing, permissions and allowed states differ, so solid code waits, checks and retries instead of assuming.
  • Trust is a design feature. Sellers get comfortable letting AI near their money when they can see where every fact came from and nothing is sent without their click.

What's next for DisputeShield

  • One-click onboarding through PayPal's partner onboarding, so a seller connects with "Log in with PayPal" instead of creating API credentials.
  • Carrier tracking. Delivery scans and signatures pulled in automatically for stronger proof of delivery.
  • Deadline reminders by email or Slack before a respond-by date gets close.
  • Learning from outcomes. Compare Gemini's verdict with PayPal's final ruling to calibrate the strength score.
  • Card chargebacks once card processing is enabled, plus buyer messages in the buyer's language.
  • Teams and multiple stores, with roles and an audit log.
Share this project:

Updates

Submission history