Inspiration

AI agents read the web but never see ads, so publishers earn nothing from them, and many now block AI bots entirely. The fair fix is letting agents pay a few cents per article over HTTP 402 Payment Required. But nobody wants to hand an AI their wallet: nothing stops an agent from overspending or buying junk. I built the missing piece: a spending guard that lets an agent pay on its own for small, useful things, and stops everything else for a human.

What it does

  • Agent owners connect PayPal once (PayPal Vault, no purchase), set a per-item limit and a daily budget, and send their agent on a task.
  • Websites answer AI agents with a 402 and a price. People pass a Cloudflare Turnstile check and read free.
  • The guard decides, in this order:
    1. Already owned? If the agent bought this article in the last 24 hours, it reuses that payment and nothing is charged.
    2. Rules: approved site, per-item limit, daily budget. Anything blocked waits for the owner to approve or deny.
    3. AI advisor (Gemini): can only veto purchases that don't help the task, never approve. If Gemini is unavailable, the purchase waits for the owner.
  • Payment: the owner's saved PayPal is charged with no popup, the publisher is paid through PayPal Payouts, and the paywall verifies the capture with PayPal before unlocking the article.
  • Creators can list a site and set a price for agents (saved for review; going live is next).
  • Every decision is logged with its reason.

An autonomous purchase happens only if

$$\text{price} \le \text{limit}{\text{item}} \;\wedge\; \text{spent}{\text{today}} + \text{price} \le \text{budget}_{\text{day}} \;\wedge\; \text{AI} \ne \text{veto}$$

How I built it

  • Node.js + Express, as two services on Render: the guard and the paywall, plus a separate agent process that never receives PayPal credentials. It gets a one-time token that only lets it request payments for the user who started it.
  • PayPal Vault v3: setup tokens, then payment tokens, so every visitor connects their own PayPal.
  • PayPal Orders v2 with vault_id for merchant-initiated charges.
  • PayPal Captures so the paywall verifies each payment proof: completed, right amount, right currency.
  • PayPal Payouts to send the money to the publisher's own account.
  • Gemini as a veto-only advisor, returning JSON.
  • Cloudflare Turnstile for the human check.
  • Signed HttpOnly cookie sessions, per-user storage on a persistent disk, and money math in cents.

Challenges

  • Cached PayPal tokens: features I enabled on my app later didn't apply, because PayPal reuses access tokens for hours. A fresh app fixed it.
  • Paying the publisher directly failed with BILLING_AGREEMENT_NOT_FOUND: a saved payment method can only be charged by the merchant it was saved with. I switched to "platform verifies, merchant receives": the platform captures the payment, then pays the site through Payouts.
  • The live agent kept failing with a 502. A wake-then-run experiment proved the free-tier paywall was falling asleep. Moving it to an always-on instance fixed it.
  • Paying twice for the same article: replay protection rejected reused proofs, so a second visit meant a second payment. I turned proofs into 24-hour receipts tied to one article: still rejected on any other site, and expired after a day.

What I learned

When money moves, AI should advise, never decide. Hard limits in code come first, the AI can only say no, and a human decides anything risky. And on the website side, never trust the buyer's word: verify every payment with PayPal.

What's next

  • Creator marketplace: ownership checks and direct payouts to each creator
  • AI-suggested prices that publishers approve
  • Batched payouts to cut fees

Built With

Share this project:

Updates

Submission history