Inspiration

Small merchants lose money to rings of accounts that share devices and addresses and buy or dispute in coordinated bursts. PayPal shows each payment on its own, so the pattern is easy to miss. Acting on a hunch also punishes honest customers, such as families and flat-shares. I wanted a system that stops the ring before money moves and can show its working.

What it does

  • Authorize first. Checkout reserves the buyer's money without charging it (PayPal Orders v2, authorize intent).
  • Screen before capture. The buyer is linked to existing accounts in a graph. A buyer who shares a device with a flagged ring is held for the merchant. Everyone else is charged. Address or IP links alone never hold anyone, so families and offices are left alone.
  • A hold costs nothing. No money has moved, so voiding a held order just releases the reservation.
  • An AI analyst writes the case: evidence, caveats and recommended actions (hold accounts, refund payments). The merchant approves each action. Nothing moves without approval.
  • Every decision can be explained and replayed. The hold decision is one deterministic function with a versioned policy. For each order I keep the evidence snapshot with a hash, show where every signal came from and how far to trust it, show what would have changed the decision, and replay it.
  • Payment truth. A Verify button asks PayPal what it says about an order and compares it field by field with my record. If a capture gets no answer, the order becomes "outcome unknown" and the merchant reconciles from PayPal's answer instead of guessing. Refunds are all-or-nothing and safe to retry. An append-only, hash-chained audit ledger records every step.
  • Disputes. Verified PayPal dispute webhooks are linked to buyers and rings, and the merchant can draft and send evidence. The draft only uses the merchant's records and never claims shipping without real tracking.
  • I attack my own detector. A self-test with a naive baseline and confidence intervals, and an AI red team where a separate model invents evasion strategies that I replay against the live rule.

How I built it

Python and FastAPI, SQLAlchemy on Postgres (SQLite locally), networkx for the account graph, and PayPal's REST APIs: Orders v2 (create, get, authorize, capture), Payments v2 (capture authorization, void, refund), signature-verified webhooks, and Disputes. The dashboard is a single page with AG Grid tables and an SVG graph. It is deployed on Render with a managed Postgres database. 57 automated tests cover the checkout, the guardrails, the replay and the ledger, and I tested the full lifecycle against real PayPal sandbox money (authorize, capture, void, refund, webhooks, disputes).

The role of AI (and what AI does not decide)

The hold decision is deterministic. The AI explains and recommends, and it is fenced in code: model output is validated against a schema, actions must come from an allow-list, account IDs must belong to the case, hold and refund are limited to accounts with strong evidence, and standard caveats ("heuristic, not proof of fraud") are always added. If the model fails, the app falls back to a deterministic analyst and never blocks the merchant. The analyst can look up live PayPal orders and disputes through the PayPal Agent Toolkit (read-only), restricted to accounts in the case.

Challenges I ran into

  • Telling "PayPal said no" apart from "PayPal did not answer", because the money may or may not have moved.
  • Not punishing innocent households: a naive "hold anyone who shares anything" rule holds 80% of my innocent test groups.
  • My own evaluation was circular. I fixed a bug in one scenario, ran on draws not used during development, added a baseline and intervals, and added an AI red team so I am not the only one writing attacks.
  • A ring that slows down evaded the timing signal. The evaluation exposed it, and I added a rule for one device used across many addresses.

Accomplishments that I'm proud of

  • On fresh draws (100 trials per scenario), across the four scenarios the rule is designed for, it blocks 82% of follow-up ring buyers and disrupts 0% of innocent groups. A fifth, labelled blind spot (rotating devices, nothing else shared) is 0%. The naive rule blocks 100% but disrupts 80% of innocent groups. A hold threshold of 0.3 wrongly holds some innocent buyers; from 0.4 up none are held in these scenarios, and I use 0.5.
  • The red team found real gaps. In my offline sample, 3 of 6 invented strategies evade the detector. I show that instead of hiding it.
  • Real sandbox money flows end to end, with a one-click check against PayPal's own record.

What I learned

Separating "decides" from "explains" is what makes AI safe near money. A system that shows its evidence, its limits and a replay is more convincing than one that just says "fraud".

What's next

Real device fingerprinting (today the device ID is a browser value that an attacker can change), a ring registry shared across merchants, and validation with real merchant data.

Prior work disclosure

This is a new project, built during the submission period, including app/detection_core.py. See HACKATHON_CHANGES.md in the repo.

Limitations

Detection is heuristic, not proof of fraud. The device ID is client-supplied. PayPal gives merchants no card fingerprint, so live linking uses device, address, IP and timing. My evaluation uses my own synthetic scenarios. The first buyer in a ring is always charged. The public demo runs on a free tier and sleeps when idle, so the first load can take about a minute.

Sponsor tools

  • Render: the app runs as a Render web service with a managed Render Postgres database, defined in a Blueprint (render.yaml) with a health check and environment-based configuration.
  • AG Grid: the merchant dashboard uses AG Grid Community for its case and dispute tables.

Built With

  • ag-grid
  • fastapi
  • gpt-oss-120b
  • groq
  • networkx
  • paypal-agent-toolkit
  • paypal-disputes-api
  • paypal-orders-api
  • paypal-payments-api
  • paypal-webhooks
  • postgresql
  • pytest
  • python
  • render
  • sqlalchemy
Share this project:

Updates

Submission history