Inspiration

AI agents are starting to buy things for people. The scary part is not the payment, it is an agent spending money you never agreed to.

What it does

You type a request like "Buy $15 of cloud credits, max $20". Gemini turns it into structured JSON (item, amount, currency, your limit). A policy on the server then decides:

  • BLOCK: over the budget cap or over the limit you wrote. No PayPal order is created.
  • REVIEW: unknown item or over the auto-approve line. A human clicks Approve or Reject. Approval cannot override a hard limit.
  • ALLOW: within budget and an approved item.

Allowed requests become a PayPal Orders v2 order in the sandbox. The buyer approves on PayPal, the server captures it, and the capture id goes into an audit log on the page.

How we built it

Python standard library only, so it runs with no installs. PayPal OAuth2 client credentials, Orders v2 create and capture, and the sandbox buyer approval flow. Gemini through the REST API in JSON mode, with a fallback across Flash models when one is overloaded.

Challenges we ran into

Keeping the money decision out of the AI. The model only reads the request; the server makes the decision with fixed rules, so a prompt cannot talk the agent past the budget.

AI tools used

Google Gemini Flash parses each purchase request into JSON inside the app. Claude Code helped write the code.

What's next

Per-seller limits, daily totals, and the PayPal webhook for capture events.

Run it

python app.py with PayPal sandbox credentials. Full steps are in the README.

Built With

Share this project:

Updates

Submission history