Inspiration

Shopping is moving into AI assistants. When a shopper asks an agent for "good espresso beans under $25", there is no search results page and no banner: the agent just answers. Small merchants are invisible in that answer, and there's no ad product built for it.

We noticed that PayPal is the one company that holds both halves of the problem: the transaction graph (who buys what, and when) and the checkout (proof that a sale really happened). That combination makes a new kind of ad possible: one that runs inside AI agents and is paid for only when a real purchase settles. We built ADGENT to be that ad product: PayPal Ads for the AI-shopping era.

What it does

ADGENT connects four parties: Merchant → ADGENT → AI agent → Shopper → PayPal → ADGENT settles.

  • Merchant Copilot builds audiences from the PayPal transaction graph (due for a refill, lapsed, VIP, and lookalikes from cross-merchant affinity). AI proposes campaigns, but forecast numbers are computed from the data, not by the model, and any proposal that cites an audience or product that doesn't exist is dropped. One click launches a campaign.
  • AI shopping agent + MCP server. Shoppers ask in plain language. Offers are always labelled Sponsored and ranked relevance first (relevance × (1 + bid) × merchant trust), so a high bid can't buy an irrelevant slot. External AI agents can connect through our MCP server (find_sponsored_offers, start_paypal_checkout, confirm_purchase).
  • PayPal checkout with a human in the loop. The agent creates a real PayPal order, but the shopper approves every payment on PayPal. The agent can only check out an offer it actually showed the shopper.
  • Pay only for sales. On capture, ADGENT books the ad fee. After a refund hold, one PayPal Payouts batch pays the merchant its net and the publisher its share. A refund at any point reverses the fee.
  • Publisher widget. Any site can show shoppable sponsored offers with one script tag, and earns a share of the ad fee via PayPal Payouts.
  • Mission Control (AG Grid). A live, streamed attribution ledger (click → PayPal order → capture → fee → payout), an Orders grid showing where every cent went (with Refund), inline-editable campaigns, "ask your ads" in plain English, and a budget guardian that pauses campaigns below 1× incremental ROAS, measured against a stable 10% holdout.
  • Merchant onboarding and product publishing APIs so merchants can register and publish products for agents to discover.

Why it matters to PayPal: every ad dollar brings four revenue lines: the ad fee, branded-checkout volume, Pay Later, and Payouts.

How we built it

  • Next.js 16 (App Router) + TypeScript for the app and API routes, Turso/libSQL + Drizzle for the database, deployed on Render.
  • PayPal REST APIs through a typed client: Orders v2 (create/capture, with attribution in custom_id and a discount breakdown), Payments refunds, Payouts (merchant + publisher in one batch after a refund hold), Webhooks with signature verification and de-duplication, and the PayPal JS SDK Smart Buttons with Pay Later messaging. Invoicing powers an alternative fee mode where merchants are paid directly and billed per sale.
  • Claude (Anthropic): Opus 5.5 for campaign strategy and the shopping agent, Haiku 5.5 for offer ranking and "ask your ads". Advertiser text is passed to models only inside an <untrusted_offer_data> wrapper.
  • Model Context Protocol server so any MCP-capable assistant (e.g. Claude Desktop) can shop through ADGENT.
  • AG Grid for Mission Control's ledger, orders and campaign grids; Server-Sent Events stream the ledger live.
  • Claude Code for planning, building, testing and debugging.
  • A built-in PayPal simulator and an offline agent let the whole app run end to end with no keys (clearly labelled on every page); adding sandbox keys switches the same code to the real PayPal sandbox.
  • 69 automated tests (Vitest) cover the full money path, webhook replays, ten prompt-injection attacks and web-security guards.

Verified on the real PayPal sandbox: a $17.09 sandbox purchase through the AI agent (order 1535574240356792E, capture 8T597932UT259682W), followed by a processed Payouts batch paying the merchant $15.38 and the publisher $0.51, with the ad fee kept by ADGENT.

Challenges we ran into

  • Passing tests ≠ working payments. Everything passed against our simulator, but with real sandbox keys the PayPal button failed with "Could not load the PayPal SDK". Our strict Content-Security-Policy was blocking PayPal's script, frames and API calls. We traced it and allowed only PayPal's domains, and the real payment went through.
  • Choosing a money flow a standard PayPal app can support. Splitting fees at capture (platform_fees) needs a Multiparty partner app. We wrote a spike script that probes the sandbox app's capabilities, and designed ADGENT as the payee with Payouts settlement, keeping platform_fees and Invoicing as alternate modes.
  • Money-path correctness. Racing captures, duplicate webhooks and refunds after payout all had to be safe. We made capture, settlement and refunds idempotent (PayPal-Request-Id plus conditional database updates) and record clawbacks when a refund lands after payout.
  • Trust in AI-placed ads. Advertisers could try to steer the agent with their copy. We sanitize advertiser text, isolate it from instructions, rank relevance first, and require the shopper to approve every payment.
  • Hosting on a deadline. The app needs a long-running server for its live ledger stream and settlement worker, which ruled out a purely serverless deploy.

Accomplishments that we're proud of

  • A real end-to-end PayPal sandbox transaction initiated by an AI agent, with a real Payouts settlement to the merchant and publisher.
  • An ad model that is honest by design: pay only for sales, Sponsored labels, relevance-first ranking, and incremental lift measured against a holdout, not just attributed revenue.
  • Agent safety that holds structurally, not just by prompting: the agent can't pay on its own and can't sell an offer it never showed.
  • A demo that runs anywhere: zero keys gives a labelled simulator; real keys give the real sandbox with the same code.
  • 69 passing tests, CI, and a security write-up.

What we learned

  • How the PayPal pieces fit together in practice: Orders v2, capture, refunds, Payouts, webhooks with verification, and the JS SDK, plus which capabilities a standard sandbox app has and which need partner onboarding.
  • That a simulator is great for speed but only real sandbox runs catch issues like CSP blocking the SDK.
  • How to use LLMs responsibly in a money flow: models propose, data decides, humans approve payments.
  • How to plan, debug and ship as a team with AI coding tools (Claude Code) under a hard deadline.

What's next for ADGENT

  • Agent Toolkit integration and PayPal's agentic commerce services, so ADGENT offers show up across more AI shopping surfaces.
  • Multiparty / platform_fees once partner-enabled, so PayPal splits the ad fee at capture.
  • Real merchant onboarding with PayPal-connected accounts, a richer self-serve product catalog, and more LLM providers behind the same agent API.
  • Smarter bidding and budget pacing driven by measured incremental lift.
  • A pilot with small merchants to validate pay-per-sale advertising inside AI agents.

Built With

  • ag-grid
  • anthropic-claude
  • claude-code
  • drizzle-orm
  • libsql
  • model-context-protocol
  • nextjs
  • node.js
  • paypal-invoicing-api
  • paypal-js-sdk
  • paypal-orders-api
  • paypal-payouts-api
  • paypal-webhooks
  • react
  • sqlite
  • tailwindcss
  • turso
  • typescript
  • vitest
  • zod
Share this project:

Updates

Submission history