Earmark: AI-Powered Autonomous Commerce
Your money. Your rules. AI does the work.
Inspiration
AI has become remarkably good at answering questions, researching products, and making recommendations. Yet a massive gap remains between an AI recommending a product and actually buying it for you.
Today, online shopping still requires jumping across multiple tabs, comparing pricing tiers, vetting unfamiliar merchants, and manually filling out checkout forms. Even when an assistant handles the initial research, the user is left doing all the transactional heavy lifting.
We wanted to change that workflow. What if you could tell an AI what you need, hand it a strict budget, and trust it to execute the purchase safely within your exact boundaries?
That question led us to build Earmark. Our goal is to make autonomous commerce practical without sacrificing the security, transparency, and strict financial control that real-world spending requires.
What it does
Earmark is an AI purchasing agent that turns natural-language requests into verified, policy-controlled transactions.
Instead of digging through storefronts and checkout flows, you can give Earmark a direct instruction:
"Find me a weather API subscription for under $10 per month, compare the top options, and recommend the best fit."
Earmark brings conversational reasoning, live web discovery, merchant verification, and payment execution into a single pipeline:
- Natural-Language Purchasing: Describe what you need, set your ceiling price, and specify vendor preferences in plain English.
- Live Market Research: Uses Google Gemini and Tavily to surface real-time product listings, subscription tiers, and vendor details.
- Evidence-Based Comparison: Weighs pricing, merchant credibility, and verified checkout terms before putting forward a proposal.
- Granular Spending Mandates: Lets you lock in exact spending caps and pre-approved merchant rules before any funds move.
- Deterministic Policy Enforcement: Runs every AI proposal through an independent, non-AI authorization engine prior to touching payment APIs.
- PayPal Checkout Integration: Executes order creation, buyer approval, and payment capture through the PayPal Sandbox.
- End-to-End Auditability: Tracks active mandates, reserved balances, settled captures, and remaining budgets in real time.
We built Earmark around one core principle: AI decides what to propose, but the deterministic policy engine decides what is allowed.
How we built it
We engineered Earmark as a full-stack application that decouples conversational reasoning from financial execution.
1. AI Reasoning & Live Merchant Discovery
We paired Google Gemini with Tavily so Earmark can evaluate live market offerings rather than relying on static training data. Gemini interprets user intent, calls structured discovery tools, and formats structured purchase proposals. Importantly, our discovery pipeline treats web results as raw claims rather than guaranteed facts, explicitly verifying pricing and payment compatibility before advancing an offer.
2. Financial Security & Deterministic Authorization
Giving an LLM direct access to a wallet or payment API is a recipe for costly mistakes. To make autonomous commerce safe, we isolated Gemini from our payment execution layer.
When Gemini proposes a purchase, our deterministic backend authorization engine intercepts the request and checks:
- Active mandate status and expiration
- Remaining budget and active fund reservations
- Merchant whitelist eligibility
- Per-transaction spending caps
Alongside policy validation, we built strict idempotency keys, state-machine guards, and ledger reconciliation into PostgreSQL (Neon) to prevent double charges or race conditions.
3. PayPal Payment Infrastructure
Once a proposal clears the policy gate, Earmark hands execution over to the PayPal REST APIs. Our backend manages OAuth2 token lifecycles, order creation, buyer approval redirects, payment capture, and ledger settlement. We also implemented PayPal Wallet vaulting via the Payment Method Tokens API (covering setup tokens, buyer consent, and payment token exchange) to lay the groundwork for recurring and zero-click autonomous checkouts.
Technology Stack
- Frontend: Next.js, React, TypeScript, Tailwind CSS
- AI & Reasoning: Google Gemini
- Live Web Discovery: Tavily Search API
- Payments: PayPal REST APIs & PayPal Sandbox (Orders v2 & Payment Method Tokens)
- Database: PostgreSQL (hosted on Neon)
- Testing: Vitest (automated security, policy, and integration suites)
- Deployment & Tooling: Vercel, GitHub, Node.js
Challenges we ran into
1. Making AI decisions financially safe Language models are probabilistic, which means prompt injection or hallucinated prices can never be trusted near a payment gateway. We solved this by treating the AI strictly as an untrusted proposer and enforcing all financial rules inside a deterministic TypeScript/PostgreSQL policy engine.
2. Navigating PayPal Sandbox edge cases and state transitions
Real payment processing goes far beyond firing a single POST request. We had to coordinate OAuth token caching, asynchronous buyer approvals, idempotent captures, and multi-stage ledger reservations. Early on, we hit regional merchant eligibility blocks in our initial Sandbox setup; provisioning matched US Sandbox business and personal accounts allowed us to validate the full end-to-end capture cycle cleanly.
3. Enforcing strict identity checks on saved-wallet tokens To enable future purchases without repeated buyer pop-ups, we built out PayPal's setup-token and vaulting workflow. While testing token exchange, our validation layer flagged a customer-identifier mismatch across Sandbox contexts. Rather than loosening our security checks to force a demo through, we engineered the pipeline to halt safely whenever payer identity binding cannot be verified with 100% certainty.
4. Separating marketing copy from checkout reality A webpage advertising a "$9/mo plan" does not guarantee that the plan is currently in stock or accepts automated checkout. We structured our discovery parser to separate unverified merchant claims from confirmed checkout capabilities, ensuring the agent never commits funds on guesswork.
Accomplishments that we're proud of
Our proudest achievement is proving that autonomous AI commerce can be built with bank-grade guardrails:
- True Separation of Powers: Built an architecture where Gemini can research and propose deals, but cannot bypass deterministic spending mandates.
- Verified End-to-End PayPal Settlement: Executed a real $6.00 PayPal Sandbox transaction from natural-language prompt to buyer approval, payment capture, and automated ledger reconciliation.
- PayPal Wallet Vaulting Flow: Exercised setup-token generation, buyer consent, and payment-token exchange using the PayPal Payment Method Tokens API.
- Live Web Grounding: Integrated Tavily so the agent evaluates real, up-to-date product offerings instead of hallucinating vendors.
- Fail-Safe Accounting: Implemented idempotency protections, fund reservations, and audit logs backed by automated Vitest security and integration tests.
What we learned
Building Earmark showed us that the hardest problem in agentic commerce isn't intelligence. It's trust.
- Model confidence is not financial permission: An AI agent should never hold the keys to execute a charge without an independent policy check.
- Consent operates in layers: Setting a $50 budget inside an app is distinct from granting a payment processor cryptographic authority to debit a vaulted wallet.
- Financial state requires strict discipline: Idempotency, atomic reservations, and clear audit trails are mandatory the moment real payment APIs enter the loop.
- Failing safely is a core feature: When merchant data is ambiguous or identity tokens do not align, stopping the transaction and alerting the user is the right outcome.
What's next for Earmark
We are evolving Earmark from a policy-guarded purchasing assistant into a complete autonomous commerce platform:
- Unattended Vaulted Checkouts: Complete end-to-end payer identity binding for vaulted PayPal payment tokens so pre-approved mandates can settle recurring or low-cost purchases without manual checkout clicks.
- Direct Merchant API Connectors: Expand beyond web scraping and discovery into direct programmatic checkout integrations with SaaS, cloud, and digital goods providers.
- Smarter Deal Evaluation: Incorporate historical price tracking, vendor reputation scoring, and cancellation-term analysis into Gemini's comparison rubric.
- Scheduled & Conditional Buying: Let users set trigger-based mandates (for example, automatically renewing an API quota or purchasing compute credits when prices dip below a target threshold).
- Team & Business Spend Controls: Introduce multi-user budgets, role-based approval thresholds, and exportable audit ledgers for startups and engineering teams.
Our Vision
We believe the future of commerce is conversational, intelligent, and autonomous, while keeping financial control firmly in the hands of the user. Earmark is our blueprint for that future.
Tell Earmark what you need. Set your limits. Let AI handle the rest.
Built With
- next
- react
- typescript