Inspiration

Small sellers lose PayPal disputes they should win, and fight ones they should settle.

A dispute arrives with a response deadline. The seller doesn't know which evidence PayPal wants for that reason code. The proof sits in three places: the order system, the carrier's website, and an email from weeks ago. So they miss the deadline, send a weak reply, or spend days fighting a case they were always going to lose, and then pay the dispute fee on top.

It's worst for cross-border sellers. Parcels take days, which invites "item not received" claims, and posting a return back across the world can cost more than the item. My demo seller, Ember & Clay, is a small ceramics studio in Jaipur that sells to buyers in the US. It's exactly the kind of business that can't afford a chargeback specialist.

What it does

Rebuttal is a dispute agent that works for the seller, with the seller's approval.

  • Watches the clock. It receives PayPal's CUSTOMER.DISPUTE.* webhooks (signature-verified) and the Disputes API, and gives every open case a live countdown to seller_response_due_date.
  • Investigates. A tool-using AI agent reads the dispute, the order, every carrier scan, the emails with the buyer, the listing and the shop's policies. The case page shows each step live.
  • Decides with numbers. Code, not the model, rates the evidence (strong, medium or weak) and prices each option PayPal currently allows: fight, a partial refund where the buyer keeps the item, refund after return, refund in full, or "send the tracking and wait" while a parcel is still moving. It tells the seller to refund when the records say they'd lose.
  • Drafts. It writes the statement for PayPal and a short message to the buyer, and builds evidence PDFs from the seller's records. Every PDF footer lists the records it used.
  • Checks before anything is sent. A deterministic gate re-reads PayPal's live copy of the dispute. Sending is blocked unless:
    • the deadline is still open;
    • PayPal allows the action right now (its HATEOAS link is present and the offer type is in allowed_response_options);
    • every evidence type PayPal requested is included;
    • every tracking number matches the shipment;
    • every fact cites a record that exists;
    • the notes fit PayPal's 2,000 characters, and the case is winnable.
  • Acts on one click. It calls provide-evidence (multipart, with the PDFs), make-offer, accept-claim, send-message, or provide-supporting-info when PayPal is already reviewing a claim. An optional autopilot handles small disputes, but only when every check passes and the plan matches the cost comparison.

The demo's four disputes each get a different, correct answer:

Dispute The records show Rebuttal says
Vase "not received", $148 DHL delivered it, signed for by the buyer Fight with evidence
Cups "not as described", $62 The listing discloses that hand-fired glaze colour varies Offer 30% back; posting them back to India costs more than they're worth
Coasters "not received", $35 Tracking stopped 25 days ago Refund: fighting would lose the money and the fee
"Unauthorised", $210 Signed delivery, and the buyer emailed about gift wrap Fight with evidence

How I built it

  • Stack: Python 3.12, FastAPI with server-rendered pages, and SQLite. Evidence PDFs use fpdf2. It runs in a container on Cloud Run.
  • PayPal client: written directly against the REST APIs, with OAuth, Disputes v1, Orders v2, shipment tracking and webhook verification.
  • A fake PayPal for demo mode and tests. It has the same methods and enforces the same rules as the real API: an action needs its HATEOAS link, offer types are checked against allowed_response_options, and each action moves the dispute to the status the real API would. Judges can try everything with no account.
  • The agent loop: any OpenAI-compatible chat API with tool calls. It runs deepseek-ai/DeepSeek-V4-Pro on Nebius Token Factory, at about 25 seconds per case. I compared three models on the same cases and picked this one for speed with fully cited output.
  • A storefront with real PayPal Checkout (JavaScript SDK + Orders v2), so I could create real sandbox payments, upload FedEx trackers to PayPal, and have a buyer file a real dispute.

Verified live on the PayPal sandbox

  • A US sandbox buyer paid through PayPal Checkout. The buyer filed "I didn't receive an item", and PayPal opened dispute PP-R-TLZ-10196141.
  • Rebuttal picked it up, the agent drafted a cited statement, and every check passed. After approval, PayPal's own dispute record lists the statement and proof-of-delivery.pdf under supporting_info with "source": "SUBMITTED_BY_SELLER".
  • PayPal's simulated CUSTOMER.DISPUTE.CREATED event reached the hosted service and passed verify-webhook-signature. An unsigned request is refused with 400.
  • [after 7 Nov] Order EC-2073: paid, shipped on the real clock (FedEx from Jaipur, delivered about four days later), disputed by the buyer, and answered by Rebuttal. This is the case shown in the video.

Challenges I ran into

  • The real dispute didn't look like the docs' happy path. The sandbox sent my buyer's "not received" claim straight into PayPal review. The only seller action allowed was provide-supporting-info, and the sandbox-only require-evidence call was refused for that state. I added that path, and taught the agent that PayPal allows no buyer messages at that stage.
  • Real dispute objects return null for messages, allowed_response_options and the due date, where my fake always filled them in. Several places would have crashed in production.
  • Sandbox country rules. Checkout failed while both sandbox accounts were Indian, because PayPal doesn't allow payments between two Indian accounts. US accounts fixed it.
  • Honest timing. My first demo parcel was "delivered" four minutes after payment, which no reviewer would believe. Carrier scans now follow a planned journey on the real clock, and only the scans that have happened are visible. That also exposed a new case: a buyer who disputes while the parcel is still moving. The right answer there is to send the tracking and wait, not to fight.
  • Concurrency. Filming the demo exposed a race: parallel investigations shared one SQLite connection, and one case briefly lost its shipment record. The gate caught it and blocked the plan, which is what it's for. The bug is fixed, and a test now hammers the connection from eight threads.

Accomplishments that I'm proud of

  • The model can't push a bad case through. A confident draft that cites a record that doesn't exist, or a tracking number that doesn't match, can't be sent.
  • It recommends refunding when that's the cheaper outcome. Most dispute tools only know how to fight.
  • One real round trip through PayPal: Checkout, the tracker, a buyer's dispute, the webhook, the investigation, the checks, approval, and the evidence on PayPal's record.
  • 29 tests covering the decisions, every gate rule, PayPal's rules, the agent loop and webhooks.

What I learned

  • PayPal's HATEOAS links are the real source of truth for what a seller may do right now. Building the gate on them made it robust to dispute states I hadn't anticipated.
  • Splitting the work (code decides the facts and costs, the model writes, a gate checks) gave better results than asking one model to do everything. It's also much easier to trust.

What's next for Rebuttal

  • Connectors for Shopify and WooCommerce orders, and live carrier tracking, in place of the demo shop.
  • Win rates learned from the seller's own closed cases, replacing the fixed estimates per strength level.
  • More reason codes (refund not processed, duplicate, incorrect amount) with their own playbooks.
  • A pilot with small Indian exporters selling through PayPal, where cross-border disputes hurt most.

Built With

Share this project:

Updates

Submission history