Inspiration
AI agents can now shop and pay for us, and PayPal's agent toolkit gives a connected agent dozens of tools, including refunds and subscriptions. But the limits a person actually means ("headphones, under $150, from Best Buy") live only in the chat with the agent. PayPal never sees them, so nothing enforces them. Worse, agents read untrusted web pages, and a product listing can quietly tell them to pay a different account or add a "required" subscription.
PayPal's protections answer "is this caller legitimate?". I wanted something that answers "is this what the person asked for?". Spendward protects the buyer from their own agent.
What it does
Spendward is a safety layer between an AI shopping agent and PayPal.
- You write your limits in plain English. An AI drafts them into a mandate (amount per payment, monthly budget, allowed shops, no subscriptions) and lists every assumption it made. You check it and sign it with your own key.
- The agent shops and pays as usual. Spendward speaks the same tool names as PayPal's agent toolkit, so the agent needs no changes.
- Every payment is checked before PayPal is called, by 14 fixed rules with no AI involved:
- 🟢 Allowed: paid at once from your saved PayPal wallet.
- 🟡 Held for you: a little over the limit, or a shop you did not list. You see exactly which PayPal account would be paid, and approve once.
- 🔴 Blocked: outside your limits. PayPal is never called.
Spendward also writes the PayPal payee itself, from your mandate, so a "send the money to this settlement account" trick goes nowhere. Every order must match a real listing, so a hidden subscription line is refused. Every decision goes into a tamper-evident log, next to PayPal's own verified confirmations. The Insights page, built with AG Studio, shows where the money went and what was stopped, and Ask Spendward answers questions about it.
Try it live: https://spendward.onrender.com (no login or keys needed; open Try it).
How I built it
- PayPal Orders v2: every allowed purchase is a real sandbox order, and Spendward sets
payee.merchant_iditself. - PayPal Vault (v3 payment tokens): a saved wallet, so the agent can pay with no checkout page. That is exactly why the mandate matters.
- PayPal Webhooks with signature verification: confirmations are verified and shown beside Spendward's decisions, and approved checkouts are captured automatically.
- Model Context Protocol: an MCP server that mirrors PayPal's agent tool names.
- DeepSeek V4.1 Flash on Microsoft Azure: the shopping agent, the mandate drafter and Ask Spendward. It never decides whether money moves.
- Channel3: live products from real retailers (Best Buy, Macy's). Its listings are the source of truth every order must match.
- AG Studio from AG Grid: the Insights report and its Agent Framework, behind a server proxy that keeps the model key on the server and rate-limits use.
- Ed25519 signed mandates, an HMAC-chained audit log, the wallet encrypted at rest, written in TypeScript (Node, Hono), and deployed on Render with a persistent disk.
Challenges I ran into
- Agents fall for facts, not commands. The textbook "ignore your limits" injection failed every time. What worked was a plain-looking fact, like a "settlement account" or a "required" monthly plan. That pushed me to enforce rules instead of trying to detect attacks.
- Making the agent actually pay. PayPal Vault was refused on my first sandbox app until I created a new one with saved payment methods enabled.
- Keeping two copies safe: my local copy and the live site share one PayPal app, so the local tunnel gets its own webhook and can never take the live site's.
- Two AG Grid builds on one page: AG Studio's styles restyled my Activity table, so the report now runs in its own frame.
Accomplishments that I'm proud of
- In testing, an agent left to run on its own fell for the hidden-subscription listing 8 times out of 8. Spendward blocked all 8. Across five models and 45 runs, every one of the 28 requests that reached Spendward was held to the mandate.
- It is a real, working product, not a mockup: real PayPal sandbox orders, a saved wallet, verified webhooks, live retail products, and a dashboard anyone can try in two minutes.
- One command to run it yourself (
npm run web), and 45 automated tests.
What I learned
- Enforce, don't detect. Spotting prompt injection is unreliable by nature. A payment outside the mandate should be refused whatever caused it.
- The safest place to stop an agent is the money path itself. If the agent never chooses who gets paid, a whole class of attacks disappears.
- A careful model is not enough: with a person to ask, the agent often stopped; running unattended, it was fooled every time.
What's next for Spendward
- Running in front of PayPal's own agent toolkit as a drop-in proxy for any PayPal-connected agent.
- Mandates per agent, and shared business policies for teams.
- Approvals on your phone.
- Aligning the mandate format with Google's Agent Payments Protocol (AP2), which it is already shaped like.
Built With
- ag-grid
- ag-studio
- azure
- channel3
- deepseek
- hono
- model-context-protocol
- node.js
- paypal
- paypal-orders-api
- paypal-vault
- paypal-webhooks
- render
- typescript