Inspiration
AI agents are starting to shop for us, but today you either hand an agent your card details or PayPal login, or approve every purchase yourself. Neither scales. The deeper problem is that a payment can succeed and still violate what the user wanted, and nobody in the chain (merchant, PayPal, the user) can later prove what was actually authorised.
ScopePay gives agents spending power that is limited, scoped and accountable, settled on PayPal.
What it does
1. Link PayPal once. The user approves PayPal a single time (PayPal Vault). ScopePay never sees their PayPal password.
2. Generate a ScopePay code instead of sharing credentials. Each code (e.g. SP-C558-68F3-50AC) carries its own rules:
- Spending cap, tracked across payments
- Expiry: 15 minutes to 7 days
- Merchant lock: only usable at one shop
- Single-use or multi-use until the cap is spent
- Issued to the user or to an AI agent
- Intent in plain English (e.g. "vegetarian groceries, no alcohol") and an approval threshold
Codes are shown once, stored only as a hash, and can be revoked at any time.
3. AI intent check (Claude). After the hard rules pass, Claude checks the basket's line items against the code's intent. It can only pause (the user decides in the wallet) or block a payment, never approve what the rules refuse, and any failure becomes a pause. Basket text is treated as untrusted input, so prompt-injection attempts in item names are held.
4. AI shopping agent. A Claude agent shops at a demo store with a code issued to it: it reads the code's limits, picks products, pays, and explains declines. The code stays inside the tool layer, so the model never sees it or the user's PayPal. The same tools are exposed as an MCP server for Claude Desktop.
5. Fast Pay on PayPal. ScopePay charges the vaulted PayPal with no popup (Orders v2 with vault_id), with the basket's line items on the PayPal order, and pays the merchant's own PayPal account via Payouts. Payments above the threshold wait for the user's approval, bound to a hash of the exact request.
6. Evidence trail. Every action (consent, code issued, every attempt approved or declined, approvals) becomes a SHA-256 hash-chained, Ed25519-signed evidence record, viewable, printable and downloadable as JSON for disputes.
7. Payment monitor (AG Grid). Live AG Grid tables of payment attempts, codes, held payments and the evidence trail, next to the PayPal account's own transactions from the Transaction Search API, matched to evidence records.
8. Optional PYUSD escrow rail. A PayCodeEscrow contract holds a payment for a refund window so disputes can be settled on the evidence (simulated by default, Sepolia-ready).
How we built it
- PayPal sandbox: Vault v3 (setup and payment tokens), Orders v2 with
vault_id, Payouts, Transaction Search and balances, webhook signature verification - AI: Claude (Haiku for the intent check, Sonnet for the agent) through OpenRouter's Anthropic-compatible API; an MCP server for the agent tools
- Backend: Python + FastAPI rules engine, reservations under a lock, idempotent PayPal calls with an "uncertain" state and reconcile, signed evidence ledger
- Frontend: wallet, two fictional demo shops (Greenleaf Grocer, Northside Electronics), evidence pages, AG Grid monitor
- Sponsor tools: AG Grid (monitor), Render (hosting, deploys after CI passes), OpenAPI spec ready for APIMatic SDK generation, a token-protected webhook so Zapier can start agent runs
- Quality: GitHub Actions CI with an offline test suite, including attack scenarios (parallel overspend, double charge, prompt injection, tampered approvals)
Challenges we ran into
- Never overspending or charging twice. ScopePay sets the amount aside before contacting PayPal, so two payments at the same moment can't go over the cap, and a slow reply from PayPal can't lead to a second charge.
Accomplishments that we're proud of
- Agents never handle a PayPal credential: they get a narrow, revocable, expiring code.
- The AI makes payments safer without being trusted: it can only tighten decisions.
- Every decision is explainable and provable after the fact.
What's next
PayPal multiparty onboarding for direct merchant settlement, the PayPal Agent Toolkit, and live product search for the agent.
Try it
Live demo (PayPal sandbox, no real money): https://scopepay-w7w7.onrender.com/preview. Setup instructions are in the GitHub README.
Built With
- ag-grid
- claude
- fastapi
- github-actions
- javascript
- mcp
- openrouter
- paypal
- python
- pyusd
- render
- solidity