Inspiration
AI agents can now buy things for us, but the control model hasn't caught up. Today you either approve every purchase yourself, which defeats the point of an agent, or you hand the agent a payment method and hope one manipulated product listing doesn't drain it. I wanted the option in between: small, safe purchases happen on their own, bigger ones ask first, and anything unsafe is stopped, with a record of why.
What it does
Velora puts a team of seven specialist agents between a request and a PayPal payment:
| Agent | Job |
|---|---|
| Intake | Turns a sentence into items, quantities and a budget (Gemini) |
| Scout | Searches real listings from Channel3 and drops look-alikes |
| Risk Sentinel | Quarantines prompt injection, off-platform payment requests, fake discounts and restricted goods |
| Deal Analyst | Picks the best basket within budget |
| Policy Guardian | Decides: auto-approve, ask the owner, or block. Plain code, no AI |
| Auditor | Explains the decision in plain language |
| Treasurer | The only agent that can call PayPal, and only with a signed mandate |
A purchase pays by itself only when every rule holds:
$$ \text{autopay} \iff \text{total} \le L_{\text{agent}} \;\wedge\; \text{spent}_{\text{month}} + \text{total} \le B \;\wedge\; \text{all 10 checks pass} \;\wedge\; \text{autopay is on} $$
Velora is also an MCP server, so Claude, ChatGPT or any MCP client can shop through it with a personal agent key. Agents get three tools, get_spending_rules, request_purchase and check_purchase, and deliberately no tool to approve, refund or change a limit. In the demo, Claude really buys a $5.90 toothbrush through Velora, and the mission is labelled "Asked by Claude via MCP".
Around that core: a cart that pays in one PayPal order, one-click refunds that restore the budget, a live dashboard of spending and guardrail catches, and private data for every visitor on the hosted site.
How I built it
- Next.js 16, React 19, TypeScript and Tailwind, with streaming so each agent's step appears as it happens.
- PayPal sandbox: Orders v2 for checkout, Vault v3 so the owner approves once and agents can then pay with the saved account, Payments v2 refunds, signature-verified webhooks, and
PayPal-Request-Idon every money-moving call so a retry can never charge twice. - Google Gemini (free tier) for understanding requests, judging whether a listing is really the product asked for, and explaining decisions. Every agent falls back to rules if the model is busy.
- Channel3 for live product search with price, gender, age, condition and colour data. Its categories and compare-at prices feed the safety rules directly.
- Signed mandates: approval produces an HMAC bound to the exact basket and amount, and it expires after 15 minutes:
$$ \sigma = \mathrm{HMAC}k\big(\text{mission},\ \text{amount},\ H(\text{basket}),\ t{\text{expiry}}\big) $$
The Treasurer checks $\sigma$ again before creating the order and again before capture, so a changed basket or amount is refused.
- Tamper-evident audit trail: each event stores the previous event's hash, $h_i = \mathrm{SHA256}(e_i \,|\, h_{i-1})$, so one edit breaks the chain from that point on.
- MCP SDK with a stateless HTTP transport, and Render for hosting, with every push to GitHub redeploying the live site.
- 104 automated tests with Vitest, including simulated PayPal failures. I also reviewed the code against PayPal's AI Toolkit Doctor checklist, which ended with 0 critical issues open.
Challenges I ran into
- The AI quietly stopped working. Simple requests like "chocolate cookies" returned random products. Gemini was rejecting my 8-second timeout, so every model call failed, and the Scout's relevance filter was skipped without anyone noticing. I raised the timeout to 12 seconds, added fallback to a second model, and added an always-on rule-based filter so look-alikes such as decorative bottles or toy food can't slip through even without the AI.
- Saying "no match" honestly. Channel3 has no groceries, so instead of returning the closest wrong item, Velora now says the catalog had no real match.
- Revoked autopay. When I removed Velora's access in my PayPal sandbox account, charges failed with a 403. Velora now turns autopay off, charges nothing and shows the owner a notice instead of failing silently.
- Hosting changed the data model. Once the app was public, every visitor would have seen everyone else's missions. I moved to per-visitor private state keyed by a random cookie, and webhooks are routed to whichever visitor owns the payment.
- Making MCP safe. The hardest design question was what an outside agent should not be able to do. The answer was least privilege: ask and check only, a key separate from the browser session, and shared rate limits.
What I learned
- An AI agent should never hold the permission to spend. The model can improve the choice, but plain code has to own the decision.
- Payment correctness lives in the details: idempotency keys, re-checking amounts right before capture, and webhooks for changes that happen outside your app.
- A silent fallback can hide a broken dependency for days, so every step in Velora records whether it ran on AI, rules or a live API.
What's next
Real accounts and a database, routing each payment to the actual store through PayPal's partner payments, OAuth for MCP clients instead of copied keys, PayPal dispute updates in the audit trail, and shared budgets for households and teams.
Built With
- channel3
- claude
- github
- google-gemini
- model-context-protocol
- next.js
- node.js
- paypal
- paypal-orders-api
- paypal-sandbox
- paypal-webhooks
- react
- render
- tailwindcss
- typescript
- vitest