Inspiration
Most commercial deals start with friction. Freelancers and small businesses trade emails, argue over scope in PDFs, hand-write quotes, and then chase invoices for weeks. We asked: what if an agent could turn a plain-English conversation into a structured deal and settle it on the spot? PayPal already handles trust and payments for millions of people, so pairing it with a conversational agent felt like a natural fit for agentic commerce.
What it does
PayAgent is a dual-pane commerce app. The buyer chats on the left, and a live agreement canvas updates on the right.
- Describe the deal. For example: "I need an enterprise AI audit with a 15% discount and a 40% milestone deposit ($950)."
- The agent structures it. It extracts the budget and constraints, builds itemized deliverables, applies discounts, and proposes an upfront deposit plus a milestone schedule. An Agent Thought Process accordion shows each step of the reasoning.
- Pay with PayPal. The backend creates a PayPal order (Orders API v2, intent
CAPTURE) and the PayPal Smart Button completes checkout in the sandbox. PayAgent can also generate PayPal invoices via the Invoicing API v2. - Verified Ledger. After a successful capture, the app celebrates with confetti and records the capture ID, payer details, and timestamp.
The pricing logic is simple and transparent. For a base price ( P ), discount rate ( d ), and deposit rate ( r ):
$$ \text{Total} = P\,(1 - d), \qquad \text{Deposit} = r \cdot P\,(1 - d) $$
For example, with ( P = 950 ), ( d = 0.15 ), and ( r = 0.40 ), the total is \$807.50 and the upfront deposit is \$323.00, leaving \$484.50 to be released across milestones.
How we built it
- Frontend: Next.js 16 (App Router, Turbopack), React 19, and TypeScript in strict mode, styled with Tailwind CSS v4 in a dark, glassmorphic fintech look inspired by Linear and Stripe.
- Payments:
@paypal/react-paypal-jsfor the client-side Smart Buttons, with server-side calls to the PayPal REST API v2 for order creation, capture, and invoicing. OAuth2 client-credentials tokens are cached in memory with a TTL. - Agent engine: a multi-step reasoning pipeline that extracts financial entities, parses scope, builds the milestone schedule, and triggers PayPal tools. It works out of the box with no external key, and Gemini or OpenAI keys can be added as optional extras.
- Evaluation dataset: no public dataset fits this use case, so we generated a synthetic benchmark of 300 messy deal requests (typos, "5k", "fifteen percent off", mid-sentence corrections). It has 258 valid, 16 ambiguous, and 26 invalid deals, with ground-truth totals computed in code from the formula above. We use it to score extraction accuracy, math correctness, and guardrail behavior.
- Polish:
lucide-reacticons andcanvas-confettifor the payment celebration.
Challenges we ran into
- Keeping two panes in sync. Conversation changes, line items, and PayPal order IDs all had to stay consistent, or a buyer could end up paying for a stale purchase unit. We designed the state so the order is always created from the latest agreed terms.
- Token overhead. Requesting a new PayPal OAuth2 token on every call added needless latency, so we added an in-memory TTL cache.
- Building trust into the UI. Financial actions need to feel safe, so we made the agent's reasoning visible and kept the buyer in control of the final payment click.
- Messy input and no training data. Buyers write "5k", "twenty percent off", or "actually make it 20%", and sometimes ask for impossible terms like a discount over 100%. No public dataset covers this, so we built our own benchmark to test how the agent handles ambiguous and invalid requests.
Accomplishments that we're proud of
- A working end-to-end flow from chat to sandbox order creation to capture to ledger entry.
- A polished, transparent agent UI that shows its reasoning instead of acting as a black box.
- A practical use case for freelancers, agencies, and online merchants.
- A 300-deal benchmark that tests the agent on valid, ambiguous, and invalid requests, so reliability is measured instead of assumed.
What we learned
- How PayPal REST API v2 purchase units, captures, and invoices map onto an agentic workflow.
- How to design agent interfaces that give users confidence and control when money is involved.
- When an agent handles money, testing matters as much as features. A benchmark with ground truth computed in code shows where the agent is wrong, which a good demo alone can hide.
What's next for PayAgent
- Conditional escrow release triggered by deliverable events such as GitHub PR merges and webhooks.
- PayPal Subscriptions for recurring agent-managed retainers.
- Multi-currency support with real-time conversion for cross-border contracts.
Built With
- antigravity
- claude
- css
- next.js-16-(app-router
- openai
- paypal
- react
- turbopack)
- typescript