Inspiration
When a payment request times out, the merchant doesn't know what happened. Did PayPal capture the money or not? The obvious reaction is to retry, and that is how customers get charged twice. Support teams then spend hours piecing together logs, webhooks and dashboards to find out what really happened.
We wanted an investigator that answers three questions: what happened, how do we know, and what is the safest next step. It should also refuse to guess.
What it does
PayPal PaymentOps AI investigates payment failures using evidence, and it never takes a risky action on its own.
- Real PayPal Sandbox payments. Create an order, approve it as a buyer, and capture it with explicit human approval.
- Timeline reconstruction. Events from PayPal API responses, verified webhooks and merchant logs are merged into one timeline. Each entry is labelled confirmed or inferred.
- Agentic investigation. Before diagnosing a real order, the backend makes a read-only call to PayPal for the order's current state. A timeout with no known outcome becomes either "timeout after success" or "safe to retry with approval".
- AI log reader. Paste a raw merchant log and the AI extracts events from it. Code then checks every event: the quote must exist in the log, and the event needs a valid type and timestamp. Pasted logs can never override PayPal's confirmed state.
- Deterministic safety engine. Rules, not the AI, block dangerous actions such as capturing again, retrying blindly or marking an order failed. A retry is only allowed after PayPal has confirmed the order was not captured, and it still needs human approval.
- Duplicate webhook handling. PayPal can deliver the same event more than once. Events are deduplicated, and captures are idempotent.
- Exportable report for each incident, with the evidence, the actions to avoid and the recommended step.
How we built it
- Backend: Python, FastAPI and SQLAlchemy on Neon Postgres.
- PayPal: Orders v2 and the Webhooks verify-signature API in the sandbox.
PayPal-Request-Idprovides idempotency. - AI: OpenRouter models, with strict JSON output. A validator then checks the output: it must follow the schema, cite real evidence IDs, and recommend nothing that is prohibited. If the AI fails, a rules-only diagnosis takes over.
- Confidence is based on the quality of the evidence. It is not the model's self-reported number.
- Frontend: Vite, React and TypeScript, deployed on Vercel. The backend runs on Render.
- Privacy: emails, tokens and card-like numbers are redacted before anything is sent to the AI or stored.
Challenges
- Keeping the AI from inventing facts. We solved it by making the LLM propose and the code decide. It has no way to change payment state.
- Telling "merchant says completed" apart from "PayPal confirms completed". Only an API response or a signature-verified webhook counts as authoritative.
- Making a real timeout happen on demand. The demo capture uses a very short read timeout, so the incident is genuine.
- PayPal sandbox setup. We needed US Business and US Personal accounts, because other regions gave currency errors.
What we learned
The most important thing a payment AI can do is say "I don't know yet, here is how to check". The best design was a safety layer that works without the AI, with the AI as an assistant on top.
What's next
- Support for refunds and disputes.
- Merchant-side SDKs that send logs automatically.
- Alerts when an incident is opened.
The four demo scenarios are labelled "Synthetic fixture" in the app. Incidents labelled "PayPal Sandbox" come from real sandbox calls.
Built With
- fastapi
- gsap
- httpx
- llm
- neon
- openrouter
- paypal
- paypal-orders-api
- paypal-sandbox
- paypal-webhooks
- postgresql
- pydantic
- python
- react
- recharts
- render
- sqlalchemy
- typescript
- vercel
- vite