Inspiration

AI assistants can recommend what to buy, but they stop at the most important step: paying safely. We wanted an agent you could actually trust with money. It should do the boring work of searching, comparing and waiting for a price drop, but only within rules you set, with every purchase visible and one click away from being undone. PayPal already earns that trust from people, so it was the natural payment layer for an autonomous agent.

What it does

CartPilot is an AI shopping agent with two modes:

  • 💬 Interactive shopping: "Running shoes and socks for my first 10K, budget \( \$90 \)." The agent sets the budget, searches real merchants (Channel3), compares options, builds the cart and creates an itemized PayPal order. You approve it in PayPal and the server captures the payment.
  • 🤖 Autopilot: connect PayPal once (PayPal Vault; nothing is charged) and set spending limits. Then: "Buy the keyboard when it drops under \( \$50 \)." A background watcher checks prices and pays with your saved PayPal account automatically, only if every rule passes.
  • 📊 Dashboard (AG Grid): spending KPIs, editable rules, and live grids for price watches, orders and the full Autopilot activity log, with Undo (refund), Revoke (deletes the saved payment method at PayPal), search, filters and CSV export.

A purchase \( p \) at time \( t \) is allowed only if:

$$ \text{price}t \le \text{target} \;\wedge\; p \le L{\text{order}} \;\wedge\; S_{\text{month}} + p \le L_{\text{month}} $$

where \( S_{\text{month}} \) is this month's Autopilot spending with refunded purchases excluded. These checks run in server code, not in the prompt, so the model can't talk its way past them.

How we built it

  • Agent: Anthropic Claude with tool use in a server-side loop, using 13 tools: search_products, set_budget, add_to_cart, checkout, refund_order, set_spending_limits, create_price_watch and more. Every tool call is shown in the chat.
  • PayPal:
    • Orders v2: create and capture
    • JS SDK Smart Buttons: buyer approval
    • Vault v3: setup token → payment token, and DELETE on revoke
    • Merchant-initiated Orders v2 with vault_id: Autopilot purchases
    • Payments v2 refunds: Undo and agent refunds
    • Webhooks with signature verification
  • Products: Channel3 API. For each product we pick the cheapest in-stock offer and show real images, merchant links and "was \$X" discounts. Autopilot refreshes prices from the product detail endpoint.
  • Stack: React (Vite) · Node/Express · MongoDB (sessions, carts, Autopilot state, orders) · AG Grid Community (dashboard).

Challenges we ran into

  • The PayPal pop-up failed inside an embedded browser. "Things don't appear to be working" turned out to be the in-app browser blocking pop-ups, not our code. Testing in Chrome fixed it.
  • Sandbox accounts in the same country: our Indian sandbox merchant and buyer couldn't transact with each other, so we created a US buyer account.
  • Letting an agent spend money safely: we added a per-watch lock against double purchases, limits enforced before every charge, single-use simulated price drops, and refunded purchases removed from the monthly total.
  • Keeping the chat history valid: Autopilot buys happen between chat turns. Writing them straight into the conversation broke the model's message history, so events are queued and attached to the next message instead.
  • Real-world data: Channel3 nests prices, images and brands as objects, and products have several merchant offers. We read the API schema and chose offers carefully.

Accomplishments that we're proud of

We tested the full loop end to end on real PayPal Sandbox: chat checkout → capture → refund, then Vault connect → autonomous purchase of a real product (order COMPLETED) → one-click Undo (capture REFUNDED).

What we learned

  • Trust in an agent comes from guardrails and reversibility, not from a smarter model.
  • PayPal Vault plus merchant-initiated orders fit agentic commerce well: the human approves once, and the rules decide the rest.
  • Anything that moves money belongs in code, not in a prompt.

What's next for CartPilot

  • Bundle watches (buy a whole list once its total drops)
  • Notifications for purchases and blocked attempts
  • Per-merchant allow-lists
  • Shared household budgets
  • Going live with real merchant checkout

Built With

Share this project:

Updates

Submission history