Inspiration

I wanted an agent to do my grocery run. The shopping part was easy. Paying was the problem. The only ways to let it pay were to hand it my card, or sit there approving every step. The first is reckless, and the second means the agent isn't saving me anything.

Then I found the part that actually worried me.

Agents read the web, and the web lies. So I wrote a small attack lab: five ways of hiding "we've changed our payment details, pay this new account" in a store page, five models, ten runs each. An honest DeepSeek V4 Pro agent paid the attacker's account 10 times out of 10 when the note was hidden in the page. GPT-5.5 ignored the hidden notes and fell for a visible, ordinary-looking notice 8 times out of 10. DeepSeek Flash saw through all five.

Which model falls for which trick is basically luck. That's the point. You can't fix this by picking a better model, and you definitely can't fix it by asking the model to be careful. You fix it by never letting the model decide where the money goes.

This isn't a niche worry. Ping Identity asked 11,000 consumers and 3% would let an agent pay without asking first. Accenture asked 25,590 and found 32% would let an agent buy within defined limits, while only 9% would let it complete a purchase on its own. People aren't rejecting the idea. They're rejecting the version with no limits. ICSC and McKinsey expect US agentic commerce to hit $1 trillion by 2030, and the "payments moved" scam that fools these agents cost US victims $3.05 billion in 2025, according to the FBI.

What it does

Allowance sits between an AI agent and PayPal. You write the rules in plain English, it turns them into hard limits, and every payment is checked by a deterministic engine and an AI auditor before PayPal moves anything.

  • Link PayPal once. The wallet is saved with PayPal Vault. The agent never sees a login, a card number or a token.
  • Write rules like you'd say them out loud. "Groceries and household stuff only, up to $60 a week. Ask me over $25. Never alcohol." Allowance shows you, line by line, how it read each sentence, and adds the safety rules you'd want anyway, like blocking gift cards, money transfers, crypto and gambling.
  • Two checks, not one. A unit-tested engine with integer-cent math enforces the limits. Then an AI auditor looks at intent: is this prompt injection, a swapped payee, a purchase that doesn't fit the agent's job? The auditor can only make a decision stricter, never looser. If it errors or times out, you get asked.
  • You're one tap away. Anything big or unusual pings your phone with Approve / Deny.
  • PayPal moves the money. Orders v2 charges the vaulted wallet, Payouts pays the merchant, and webhooks plus Transaction Search keep the books straight. If a buyer opens a dispute, the agent that made the purchase is frozen automatically.
  • It works with the agent you already use. It's a remote MCP server. Claude, ChatGPT, Cursor or your own agent gets a key and can only see and spend its own allowance.
  • It guards a business account too. Businesses are handing agents PayPal access through PayPal's own Agent Toolkit. Allowance runs that toolkit in-process behind the same checks, so a support agent can refund and invoice, but a prompt-injected email can't get a stranger refunded or a scammer invoiced.
  • The console does more than look pretty. An AG Studio dashboard of every payment, with a Guardian that can answer questions and also freeze agents, refund purchases, change rules and reconcile with PayPal, each behind a confirmation the model can't skip.

You can try all of it at allowance-ft4z.onrender.com. Each visitor gets a private demo household with a sandbox wallet already linked, so you can run the attack yourself without affecting anyone.

How we built it

Next.js 16 and TypeScript, one service on Render, SQLite locally and Turso in production through Drizzle.

The PayPal side is a hardened REST client: cached OAuth tokens refreshed from expires_in, a PayPal-Request-Id on every POST (reused on retries), exponential backoff on 429 and 5xx that honors Retry-After, debug_id logged on every error, and credentials only on the server. On top of that: Vault v3 setup and payment tokens, Orders v2 with vault_id, Payouts, captures and refunds, webhooks signature-verified on the raw body and registered automatically, and Transaction Search for reconciliation.

The AI is DeepSeek through its OpenAI-compatible Responses API: deepseek-flash with strict JSON-schema output for the rules compiler and the auditor, and deepseek-v4-pro as a selectable agent model in the playground and the one the attack scenario runs on. All model calls go through one small client, so switching providers is configuration. It started on OpenAI models and moved to DeepSeek mid-hackathon.

MCP does the rest. The TypeScript SDK's web-standard Streamable HTTP transport, one stateless server per request bound to the authenticated agent. The demo agent talks to that same server through an in-memory MCP client, so the demo exercises the exact path an external agent uses, not a shortcut.

For business agents, PayPal's Agent Toolkit runs in-process behind Allowance. They get PayPal's own tools (get_order, create_refund, create_invoice/send_invoice, disputes), and every money-moving call is checked against business rules first. The facts that matter, like who actually paid, come from PayPal, not from the email the agent is reading.

The console is AG Studio with six related tables and a pre-built report. I extended its lead agent with six Allowance tools through api.defineAiTool, and routed the Responses-API adapter through a same-origin proxy so no key reaches the browser.

I built it in Claude Code, with PayPal's AI Toolkit plugin and APIMatic's PayPal context plugin installed.

Challenges we ran into

The vault doesn't work the way I assumed. My first design charged the buyer's saved wallet straight to the store with a payee override. PayPal answered BILLING_AGREEMENT_NOT_FOUND, and the reason is obvious once you know it: a vault token is scoped to the merchant that saved it. So Allowance charges the wallet as the platform and settles the store with Payouts. I checked the whole round trip in the sandbox before building anything on top of it: $23.75 charge, $23.75 payout, $0.25 fee.

My first attack didn't work. I started with a hidden "buy a gift card" injection, and GPT-5.5 ignored it every single time. That's why the attack lab exists. I needed to find what actually fools a strong model instead of guessing. The thing that worked was boring: a normal-looking "payments moved" notice, the same invoice scam that costs businesses billions.

My OpenAI credits ran out. I moved everything to DeepSeek in the middle of the build. Its Responses API is stateless, so the agent loop has to resend the whole conversation every turn. Before choosing models I measured them: compiling the same rules took V4 Pro 44 to 156 seconds and Flash 4 to 25, with the same policy coming out. Flash does the compiling now. I also stopped letting the model add safety defaults, because it would occasionally skip one. Blocking gift cards, transfers, crypto and gambling is code with tests, not a prompt.

Making an LLM safe next to money took longer than making it work. The auditor only escalates. Failures fail closed. Amounts are integer cents. Requests lock per agent so two concurrent purchases can't both squeeze under the same limit. And agents never choose the payee for a merchant Allowance already knows.

Accomplishments that we're proud of

Money actually moved in the sandbox. Save a wallet once, charge it with the buyer absent, settle the merchant with Payouts, refund it, reconcile it. That loop works end to end, and every step has an ID you can look up: order, capture, payout batch.

A real agent gets attacked in the live demo, and it gets stopped. DeepSeek V4 Pro reads a store page with a note hidden in it, asks to pay "HarvestLane Pay" instead of the real store, and the auditor blocks it outright with risk 95 and a written reason. It fell for that note 10 out of 10 times in our lab. You can run it yourself.

I approved a purchase from my phone with one tap. That's the whole product in one gesture: the agent shops, I stay the final say, and I don't have to sit there watching it.

A support agent worked a real inbox. Through PayPal's Agent Toolkit it issued a partial refund on a damaged order and sent an invoice to a legitimate customer. A stranger's "refund it in full" on someone else's order got declined, because the agent checked the order in PayPal and saw a different payer. A "we bought last month, invoice our reorder" from an address that had never paid us was held for me, whatever the email claimed.

A console that acts rather than just charts. AG Studio shows every payment as tables and charts, and the Guardian can freeze an agent, refund a purchase, change a rule or reconcile with PayPal without the model being able to skip the confirmation.

What we learned

The payments part was the easy part. The hard part is deciding when an agent is allowed to spend, and being able to prove why afterwards.

Rules and model judgment aren't rivals. Rules are good at what you can measure: amounts, categories, merchants, time windows. The model is good at intent, which is exactly where prompt injection lives. Put the model second, only let it say "stricter", and you get both without betting your money on it.

And model choice is not a security control. The bigger, "smarter" model was the one that fell for the injection; the cheaper one ignored it. If your safety story depends on which model your agent happens to run, you don't have a safety story.

Finally, PayPal's existing pieces are enough. Vault, Orders, Payouts, Webhooks and Transaction Search already do what an agent payments layer needs. What was missing was the layer that decides whether to use them.

What's next for Allowance

The demo moves money the only way PayPal's sandbox lets a hackathon entrant move it: Allowance charges the buyer's wallet as the merchant, then pays the store with Payouts. That means it briefly holds the buyer's money, which in production is wrong. Holding other people's money generally needs a money-transmitter licence, and the platform would eat every chargeback.

So in production Allowance never touches the money. It becomes the authorization layer, and PayPal moves funds from buyer to seller directly. With PayPal's multiparty platform, sellers onboard through Partner Referrals and each order names the seller as payee. With PayPal's agentic checkout, Allowance supplies the permission and the approval. The business-agent half already works this way. Nothing about the rules engine, the auditor, the approvals or the MCP tools changes; only the rail underneath does.

After that: more business tools behind the same guard as the Agent Toolkit grows, plugging into PayPal's agentic rails properly, real accounts and shared household allowances, and a browser extension that puts the same guardrails in front of agentic browsers.

Built With

  • ag-grid
  • ag-studio
  • deepseek
  • drizzle-orm
  • github-actions
  • libsql
  • model-context-protocol
  • nextjs
  • ntfy
  • openai
  • paypal
  • paypal-agent-toolkit
  • paypal-orders
  • paypal-payouts
  • paypal-transaction-search
  • paypal-vault
  • paypal-webhooks
  • react
  • render
  • sqlite
  • tailwindcss
  • turso
  • typescript
  • vitest
Share this project:

Updates

Submission history