Inspiration

AI agents can now spend money for people with PayPal. But agents read untrusted text, and one poisoned product listing can tell an agent to ignore its budget or pay someone else. Most projects show a defence. I wanted to show proof.

What it does

Mandate is an AI shopping agent with a payment guard. You set a mandate (budget, per-order cap, allowed categories, trusted merchants) and give a goal such as "Buy me the cheapest laptop stand." The AI agent searches a catalog and proposes a purchase. A guard written in plain code checks every proposal against the mandate, the merchant and the listing text. Approved proposals become a PayPal order that the buyer approves in the PayPal sandbox, and every decision is recorded with its reasons in an AG Grid ledger.

The Attack Lab fires nine attack scenarios at the guard: prompt injection, forged pre-approval, payee redirection, price tampering, a lookalike merchant, bulk-order abuse, category drift and more. Result: 8 blocked, 1 escalated to a human, and over $2,000 of attempted loss prevented. No AI is involved in that check, so it is repeatable.

How PayPal and AI are used

PayPal: the PayPal Orders v2 REST API in the sandbox (OAuth token, create order, buyer approval, capture). The capture endpoint only accepts orders the guard created.

AI: an LLM with tool calling drives the agent (search_catalog and propose_purchase). It has no payment tool. The AI proposes and the guard decides. If the AI provider is unavailable, a deterministic fallback agent runs through the same guard and the same PayPal sandbox, and says so.

How I built it

Python and FastAPI backend, SQLite ledger, AG Grid Community for the ledger and Attack Lab grids, a plain HTML and JavaScript front end, deployed on Render. The guard has unit tests.

Challenges

  • PayPal requires buyer approval before capture, so payments are agent-prepared and human-approved by design.
  • The free LLM quota ran out during testing, so I added retry with backoff and the fallback agent.
  • Prompt-injection detection is heuristic, so the design relies on hard limits (amount, merchant, cap, category) that hold no matter what the text says.

Accomplishments

A live, deployed app where every claim can be checked: an Attack Lab with repeatable results, not just a happy-path demo.

What I learned

Don't trust the model with money. Put the decision in code the model can't be talked out of.

What's next

A tamper-evident audit chain, live merchant intelligence (RDAP and DNS lookups), pre-approved payments with PayPal saved methods, and PayPal Agent Toolkit integration.

Built With

Share this project:

Updates

Submission history