Inspiration
AI agents can now shop for us, but there are only two options: hand them your whole payment method, or approve every purchase yourself. Neither works. We already solve this with people: we give them an allowance with clear limits. I wanted the same thing for AI agents on PayPal.
PayPal has backed Google's Agent Payments Protocol (AP2), which is built around one question: does this agent have real permission from a real customer? Allowance is a working answer to that question on PayPal today, using AP2's Intent Mandate and Cart Mandate model.
What it does
Allowance is a permission layer between an AI shopping agent and PayPal.
- Set the rules in plain English, for example: "Office supplies and computer accessories only, max $200 a month, ask me above $50, never gift cards." Gemini turns this into a strict policy, which is validated and signed, so it cannot be changed silently.
- The agent shops. It searches real stores through Channel3, picks a product and asks Allowance for permission to pay.
- Allowance decides using two independent gates:
- Hard rules (deterministic code): signature, category, merchant, monthly budget, auto-approve limit.
- AI intent check: Gemini compares the cart with what the user actually asked for.
- Three outcomes:
- ✅ Approved: within policy and small, paid instantly with a vaulted PayPal payment method, no checkout click.
- ⏸️ Held: within policy but above the limit, waits for the user's approval. Budget is re-checked before PayPal is charged.
- ⛔ Blocked: PayPal is never called.
The attack demo: a fake product page hides instructions for AI agents and swaps a keyboard for a $45 gift card that claims to be a computer accessory. A plain spending limit would see an allowed category and a small amount. Allowance also checks intent: a gift card is not a keyboard, so it is blocked. Every decision and its reason is logged in an audit trail.
How I built it
- PayPal: Orders v2 with Vault v3 payment tokens. The buyer approves PayPal once, after which approved carts are paid without a redirect.
PayPal-Request-Ididempotency and a pending-first write make sure nothing is charged twice. - Google Gemini: drafts policies from plain English, plans and picks products for the agent, and verifies intent. Carts are treated as untrusted input and fenced in the prompt. If Gemini is unavailable, the system fails closed and blocks.
- Channel3: the agent's eyes. Every product it considers comes from a live Channel3 search across real stores, filtered to in-stock USD offers, and the store's own category is treated only as a hint because listings can lie.
- Backend: Node 22, Express 5, Zod, Prisma, TiDB Cloud. Money is handled in integer cents. 98 automated tests.
- Frontend: React 19, Vite, Tailwind CSS, AG Grid for the activity and audit tables.
- Hosting: Render.
Challenges I ran into
Making AI trustworthy enough to sit in a payment path: retries and model fallback for Gemini, failing closed instead of open, and treating every cart as untrusted so a prompt injection cannot talk the verifier into approving it. Also making sure a held purchase re-checks the budget and can never be paid twice.
Accomplishments that I'm proud of
A real end-to-end flow on live services: real products from Channel3, real decisions from Gemini, and real sandbox payments through PayPal with no buyer click. Plus a concrete attack that the system actually stops.
What I learned
Spending limits alone are not enough for agents. A hijacked agent can make a cart look valid. Checking intent, not just limits, is what closes the gap.
What's next
- User-held keys and verifiable credentials for mandates (full AP2)
- Multiple users with sign-in
- An SDK so any agent framework can ask Allowance before it pays
Live demo: https://allowance-web-auua.onrender.com Code: https://github.com/salman-ctrl/allowance/