Inspiration
AI agents are starting to shop and pay on their own, and PayPal, Visa, Mastercard and Stripe all now offer some form of agent checkout. But the payment rail was never the hard part. Knowing an agent can pay is different from knowing it should, and from being able to explain afterwards why it did.
Forrester draws this line clearly: most of what ships today is "payments simply triggered by an AI assistant", not true agentic payments, which they define as "programmable, policy-governed payment flows in which AI agents act on behalf of businesses to initiate, authorize, execute, and reconcile transactions" (source).
People won't hand an AI agent their wallet until they trust it. I wanted to build that missing trust layer for PayPal.
What it does
PayPal Agent Guardrails sits between an AI agent and PayPal. Instead of calling PayPal directly, the agent proposes a purchase to the guardrail API, and one of two things happens:
- Below your threshold: the purchase is approved instantly and a real PayPal order is created.
- Above your threshold (any amount, no ceiling) or in a flagged category: the purchase pauses and waits for you. You see the agent's reasoning and an AI risk score, then click Approve (the PayPal order is created) or Reject.
The system never rejects a purchase on its own. A transaction is only blocked when a human clicks Reject, so no legitimate large purchase is ever lost to a rigid rule.
Every decision is logged in a live audit dashboard: amount, category, status, risk score, the agent's reasoning, the rule check result and the PayPal order ID.
How I built it
- PayPal Developer Platform (Sandbox Orders v2 API): creates and captures the real order once a purchase is approved.
- Google Gemini API (
gemini-3.5-flash-lite): writes the agent's first-person justification for a purchase, and produces a 0–100 risk score with a one-sentence rationale, using the rule check result and the last five transactions as context. - AG Grid (
ag-grid-react): the audit log, with sortable and resizable columns, status badges, and click-to-expand detail rows. - Node.js + Express + SQLite: the API, the rule check and the transaction log.
- React + Vite: the dashboard.
- Render: hosts both services from a single
render.yamlBlueprint.
The flow is: agent request → rule check → Gemini (reasoning + risk) → PayPal Sandbox → SQLite → AG Grid dashboard.
The rule check is deliberately deterministic and separate from the AI calls. How much an agent may spend without asking should not depend on a model call succeeding.
Challenges I ran into
- Gemini free-tier quota: the first model I used allowed only 20 requests a day and ran out during testing. I moved to
gemini-3.5-flash-lite(500 a day) and added retries plus a fallback risk score, so a model outage never breaks a purchase decision. - AG Grid detail rows: the built-in master/detail feature is Enterprise-only and would have put a watermark on the public demo, so I built the expandable rows with Community full-width rows instead.
- Silent deploy regressions: a delayed auto-deploy webhook on Render overwrote a newer manual deploy with an older commit. I turned auto-deploy off and now verify every deploy by its exact commit hash.
- Getting the product model right: my first version hard-blocked purchases over a limit. I realised that an automatic "no" loses real transactions, which is the opposite of what PayPal or its users want, so I rebuilt it around "approve, or ask a human".
Accomplishments that I'm proud of
- It works end to end on a live URL: real PayPal sandbox orders, real Gemini calls, no mocks.
- The risk scoring reads intent, not just the amount. In testing, a purchase with suspicious-sounding reasoning scored 75 while a similarly priced normal one scored 15.
- A \$50,000 test purchase correctly paused for confirmation instead of being rejected.
- Write endpoints are protected, inputs are validated, and buttons can't double-submit.
What I learned
- In agentic commerce the blocker is trust, not technology. The most useful control is not "stop the agent" but "let me see why, and ask me when it matters".
- Keep hard guarantees deterministic and use the model for judgment, with a fallback for when it is unavailable.
- Verify a deploy by commit hash, not by a green "Live" label.
What's next for PayPal Agent Guardrails
- Per-agent and per-user rule sets with sign-in.
- Persistent storage (the free-tier demo database resets when the backend restarts).
- Approval requests by push notification or email, so the human doesn't need the dashboard open.
- Connecting a real shopping agent in place of the built-in purchase simulator.
Try it: Live demo (the backend is on a free tier, so the first load can take 30–60 seconds to wake up).
Independent hackathon project for the PayPal AI Hackathon — not an official PayPal product.
Built With
- ag-grid
- express.js
- gemini
- javascript
- node.js
- paypal
- react
- render
- sqlite
- vite