Inspiration
Small merchants rarely have a finance team. Payment problems such as a duplicate capture, a failed payment, or a fee that doesn't add up usually surface late, if at all. I wanted a tool that watches a PayPal account, flags possible leaks, and shows its evidence, while keeping AI away from decisions and money.
What it does
- Runs a real PayPal Sandbox checkout (Orders v2): create, buyer approval, server-side verification, capture.
- Receives signed PayPal webhooks (capture completed, denied, refunded), verifies each signature through PayPal, and records every event once, even when PayPal retries.
- Logs every payment attempt with typed PayPal error codes and computes a decline rate from real attempts only.
- Runs deterministic Go detectors (duplicate capture, fee mismatch) and shows a Revenue Leakage Score: lost, recoverable, recovered.
- Explains spend with Groq (gpt-oss-20b). The model sees only real captures, answers in a strict JSON schema, and every claim must cite a real order and capture ID, or the answer is rejected.
- Lets a human approve a finding, with an audit trail. Approval records a decision only. No refund is sent and no money moves.
How I built it
Go (standard library plus lib/pq) on PostgreSQL, hosted on Render, with PayPal Orders v2 and Webhooks, Groq for the AI, and AG Grid and Tailwind on the frontend. Money is stored as integer minor units. Captures use a deterministic PayPal-Request-Id and a per-order PostgreSQL advisory lock. CI runs gofmt, vet, race tests, and PostgreSQL integration tests for concurrency, webhook deduplication and retry, and the audit guard.
How it was updated during the submission period
The project began as a small dashboard of sandbox captures with AI commentary (first commit: [DATE]). During the submission period I extended it with integer-money handling, concurrency-safe capture, typed PayPal errors, an attempts history, signed webhook processing, deterministic detectors, audited actions, citation-validated AI insights, a webhook activity panel, and integration-tested CI.
Challenges
- Making capture safe under concurrent requests, and treating PayPal's already-captured response as a reconcile.
- Making webhook handling retry-safe, so a failed event can be delivered again but never processed twice.
- Keeping the AI honest: citations are checked against the evidence, and with no data it says so.
- Sandbox limits: reason codes come from PayPal negative testing, and one mocked insufficient-funds response returned a 403 with an empty body, so unclassified failures are handled safely instead of guessed.
Honest limitations
Sandbox only. The demo finding is simulated and labeled. The fee check is a heuristic, not PayPal's full fee schedule. Approval does not refund. Findings and action writes use one shared admin token. The free-tier host sleeps when idle, so the first load can take about 50 seconds.
What's next
Multi-merchant onboarding, the PayPal Disputes and Refunds APIs with human-approved execution, per-merchant fee schedules, and more detectors.
Try it
- Open https://paypal-ai-auditor.onrender.com (wait up to a minute if it was asleep).
- Click Continue with PayPal and approve the $25.00 test payment with this Sandbox buyer: [[email protected]] / [SANDBOX BUYER PASSWORD:Q&a7D}_h].
- Watch the Webhook activity panel update.
- Click Seed Demo Leak, then Run Audit, then approve a finding with this demo token: [hpZ38yNljSH4cH9vweBzZrQETvsG2h1gPOLf7V8UB0]. The button is labeled "Approve Refund" but only records a decision. Local setup instructions are in the README.
Built With
- ag-grid
- github-actions
- go
- groq
- html
- javascript
- paypal-orders-api
- paypal-webhooks
- postgresql
- render
- tailwind-css