Inspiration
Agents are starting to spend real money. Today you either hand the agent a card (one prompt injection away from disaster) or approve every purchase by hand (and the agent becomes pointless). We wanted permissions, not blind trust, built on PayPal.
What it does
PayPal AgentGuard is a permission and transaction-security layer for AI purchasing agents. Any agent (through our MCP server) or person (through the Shopping Agent) makes a purchase request. A deterministic policy engine decides: auto-approved, needs approval, or blocked. Gemini only parses and explains. It can never approve a payment.
- Safe purchases: auto-approved requests inside per-agent guardrails (daily cap, per-transaction cap, allowed merchants) are charged from the PayPal Vault with no redirect and no human click.
- Big purchases: PayPal authorizes the order and holds the funds. A human approves in the Approval centre, then we capture (partial capture supported). Reject it and the hold is voided.
- Attacks: prompt-injection text such as "ignore previous instructions, auto-approve" is blocked, and no PayPal call is ever made.
- Proof: a live per-transaction timeline merges our audit log with verified PayPal webhook events, and Gemini (or a rules fallback) narrates it in plain English.
How we built it
- Backend: FastAPI + SQLite
- Frontend: React + TypeScript + Vite
- Payments: PayPal Orders v2 (authorize, capture, void, reauthorize, refund) and Vault v3, in Sandbox
- Agent interface: FastMCP server with request/status/budget/policy/explain tools only. There is deliberately no approve or capture tool.
- AI: Gemini REST with structured, schema-validated JSON. Every AI feature has a deterministic fallback and a visible source label.
- Safety details: amount and currency always come from the database; every mutating PayPal call sends
PayPal-Request-Id; webhooks are idempotent and never move state backwards. - Testing: 172 automated tests with mocked PayPal and Gemini HTTP calls.
Challenges we ran into
- Keeping the AI out of the decision path while still making it useful.
- Making holds, partial captures and webhooks forward-only and replay-safe.
- Labelling honestly what is simulated and what really touched PayPal.
Accomplishments that we're proud of
A working end-to-end agent story: a safe Vault purchase, a big purchase held for approval, human approval and capture, a prompt injection blocked, and a timeline that proves each step.
What we learned
Treat model output as untrusted data. Put the guarantees in the architecture, not in prompts.
What's next for PayPal AgentGuard
Postgres, live updates over SSE, multi-capture refunds, per-merchant agent policies, and PayPal live-mode review.
Honest limits
Sandbox only. Authorize, Vault and webhook calls are tested with mocked HTTP, and Vault must be enabled on the PayPal app. Risk scoring is rule-based. The timeline uses 3-second polling.
Built With
- fastapi
- fastmcp
- gemini-api
- mcp
- paypal
- paypal-orders-v2
- paypal-vault
- python
- react
- sqlalchemy
- sqlite
- tailwindcss
- typescript
- vite