Inspiration

AI agents can now find a product, compare prices and decide to buy. The last step is the hard one: paying. Giving an agent a credit card means no limits, no questions and no way back. Giving it nothing means a human clicks pay every time. I wanted the middle path: a wallet where the agent can ask, and the owner's rules decide.

What it does

AgentPurse is a PayPal wallet for AI agents. Each agent gets its own wallet with a daily cap, an auto approve limit, a shop allow list and a freeze switch. The owner writes rules in plain words, like "ask me before any buy over 300 dollars". Every spend request ends in one of three ways:

  • Paid (small and safe): the merchant is paid at once with PayPal Payouts.
  • Pending (risky): it waits on an approval card with an AI risk review and the failed checks. One tap approves and pays.
  • Blocked (rule breaking): refused with every reason. Fast repeat buys can freeze the wallet.

Every decision lands in a ledger with the reason and the PayPal payout id. If a payout is returned or fails, a PayPal webhook puts the money back in the purse on its own. Owners log in with PayPal and get a private purse and private agent keys.

Agents connect with an MCP server (5 tools) or a plain REST API. They can search products with Channel3 and see, for every offer, whether the rules will pay it at once, hold it or block it.

How I built it

  • PayPal: Orders v2 to fund the purse, Payouts v1 to pay merchants (idempotent by request id), payout item cancel and Payments refunds for money back, signed Webhooks for failed payouts, Log in with PayPal (OpenID Connect) for private purses, and the PayPal Agent Toolkit for a treasurer chat that reads real PayPal data.
  • Rule engine: one pure function that runs before any PayPal call. Order of effect: freeze, then block, then ask, then auto pay. It runs every check so the agent and owner see all reasons. 12 unit tests.
  • Channel3: product search and price compare inside the agent loop, with a rules preview per offer.
  • AG Grid and AG Studio: the ledger, plus Studio reports with an AI chart assistant.
  • Bryntum Scheduler: a timeline with one row per agent and one bar per request.
  • Render: web service from a Blueprint, plus a Render Workflow that builds a weekly digest with parallel tasks and retries.
  • OpenAI: turns plain words into rules, writes risk notes, the weekly recap and the treasurer answers.
  • APIMatic: an OpenAPI 3 spec of the agent API, ready for SDK generation.
  • Next.js 15, React 19, TypeScript. Each owner's purse is scoped with AsyncLocalStorage, so code inside a request can only touch that owner's data.

Challenges

  • Making money safe: the balance is reserved before the PayPal call and restored on failure, and the payout id is the request id, so a retry can never pay twice.
  • One shared demo purse could not work for real logins, so I rebuilt storage into private purses and routed webhooks by payout item id.
  • Proving the webhook path end to end with real sandbox events, not only mock ones.
  • Keeping an agent from working around a block. The tool replies tell the model not to retry with another shop or split the amount, and the velocity rule freezes fast repeat buys.

What I learned

Good agent payments are about the owner's control, not the agent's power. Plain word rules, a human yes on big buys and a clear ledger made the whole thing feel safe.

What's next

Postgres with per owner row level security, hashed agent keys, rate limits, spend analytics by category, and approvals from Slack or email.

Everything runs on the PayPal sandbox. With no keys the app runs in mock mode, so anyone can click through it. Code, architecture diagrams and the full technical README are in the GitHub repo.

Built With

  • ag-grid
  • ag-studio
  • bryntum
  • channel3
  • log-in-with-paypal
  • mcp
  • nextjs
  • openai
  • openapi
  • paypal
  • paypal-agent-toolkit
  • paypal-orders
  • paypal-payouts
  • paypal-webhooks
  • react
  • render
  • render-workflows
  • typescript
Share this project:

Updates

Submission history