Inspiration
We have all found the perfect deal online, only to hesitate because we have never heard of the seller. Pay and hope, or walk away? Millions of people face this every day, and it often goes wrong: Mastercard projects 286 million chargebacks worldwide in 2026, and merchants lose an estimated $4.61 for every $1 of fraud.
Payment platforms like PayPal are caught in the middle, paying for disputes, card processing fees and money lost to fraud. I wanted to build something where every payment gets better for everyone at once: the shopper, the merchant and PayPal.
That became Milo: your money stays in hand till your order's in hand.
What it does
Milo is an AI checkout agent that lives inside your PayPal wallet.
- You ask: "Find noise cancelling headphones under $150."
- Milo searches and compares sellers on price and trust.
- Milo scores the risk (0 to 100) from the seller's age, dispute rate, rating, cross-border shipping and order value.
- Milo picks how to pay:
- PYUSD when you have the balance: instant, almost free for PayPal, and you get part of the saving as cashback.
- PayPal checkout otherwise.
- Risky orders are protected: PYUSD is locked in a smart-contract escrow, and card payments get a PayPal authorization hold instead of an immediate charge.
- A second AI agent verifies delivery from carrier events, buyer claims and photos, then releases the money to the seller, refunds you in seconds, or sends the case to human review.
- Idle balance nudge: Milo spots money sitting unused and offers to move it into PYUSD to earn rewards.
Nothing moves until you press Confirm.
How I built it
- PayPal (sandbox):
- Orders API v2: intent
CAPTUREfor low-risk orders,AUTHORIZEfor protected ones. - Payments API v2: capture, void and refund once the verifier decides.
- PayPal JS SDK: buttons loaded under two namespaces so capture and authorize flows work side by side.
- Orders API v2: intent
- DeFi: a Solidity
PYUSDEscrowcontract with lock, release, refund, dispute, and auto-release after an undisputed deadline so merchants are protected too. It runs on a local EVM out of the box, or on Sepolia with testnet PYUSD, using ethers.js. - AI: a tool-calling agent with six tools (
search_products,prepare_checkout,get_wallet,list_orders,report_problem,get_insights), plus a verification agent that returns structured JSON. Both work with any OpenAI-compatible model; I used Groq. - Backend: Node.js and Express. Frontend: plain HTML, CSS and JavaScript with no build step.
The economics, per order
For an order of amount $A$ from a cross-border seller, the estimated card funding cost is
$$C_{card} = 0.022A + 0.10 + 0.015A$$
Paying in PYUSD costs about $C_{pyusd} \approx \$0.01$, so Milo creates a saving of
$$S = C_{card} - C_{pyusd}$$
The shopper receives $0.4S$ as cashback and PayPal keeps $0.6S$. For the $139 headphones in my demo, $S = \$5.23$, the shopper gets $2.09 and PayPal keeps $3.14, before counting the dispute cost avoided by the escrow. All assumptions are configurable.
Challenges I ran into
- Keeping the AI honest. An LLM that invents a fee or a risk score in a payments product is unacceptable. I split the system: the AI decides and explains, but every number comes from deterministic code.
- One protection model, two payment rails. Making an on-chain escrow and PayPal's authorize-then-capture flow behave identically for the user took careful design.
- Fairness to both sides. Protecting buyers cannot mean locking up honest sellers' money, so the contract auto-releases funds when nobody disputes before the deadline.
- AI provider churn. Model names were retired mid-build, so Milo now checks which models a key can access and switches automatically, with clear startup checks and a labelled fallback mode.
- Mixing PayPal intents. The JS SDK is tied to one intent per script load, so I load it twice under separate namespaces.
What I learned
- How to build a tool-calling AI agent that is useful but safely constrained.
- How PayPal's Orders and Payments APIs handle authorizations, captures and voids.
- How stablecoins like PYUSD can make payments cheaper and enable programmable protection like escrow.
- That the best fintech ideas create value for every party in the transaction, not just one.
What's next
- Real merchant risk signals from PayPal's data.
- Live carrier tracking webhooks instead of demo buttons.
- Escrow on PYUSD's Solana deployment for lower fees.
- A merchant dashboard and an API so other AI shopping agents can pay safely through Milo.
Built With
- css3
- defi
- escrow
- ethereum
- ethers.js
- express.js
- groq
- hardhat
- html5
- javascript
- node.js
- paypal
- paypal-js-sdk
- paypal-orders-api
- paypal-payments-api
- pyusd
- smart-contracts
- solidity
- stablecoin