Inspiration
We are witnessing an explosion of autonomous AI agents capable of planning trips, generating code, and diagnosing systems. Yet, when it comes to real-world commerce, autonomous agents hit a dangerous roadblock: financial trust and security.
Allowing an LLM unrestricted access to a credit card or payment credential introduces catastrophic vulnerabilities:
- Prompt Injection & Financial Leakage: Adversarial inputs could coerce an agent into overpaying or diverting funds.
- Hallucination of Transactions: Probabilistic models can invent phantom providers, hallucinate deliveries, or negotiate invalid contract terms.
- Manual Haggling Fatigue: Conversely, traditional human e-commerce forces buyers to manually scroll through dozens of vendor listings, compare opaque pricing, and haggling over delivery milestones.
We asked ourselves: What if autonomous AI agents could negotiate, discover, and strategize transactions on our behalf, but all money movement was strictly governed by deterministic, tamper-proof guardrails and mandatory human sign-off before PayPal capture?
This vision led to PayMesh — an autonomous multi-agent commerce network where intelligence is decentralized, negotiation is competitive, and financial execution is unconditionally secured by PayPal Sandbox Orders v2.
What it does
PayMesh delegates service discovery, multi-attribute evaluation, and multi-vendor price negotiation to coordinated AI agents, while enforcing deterministic risk assertions and explicit human authorization before payment settlement:
- Natural Language Intent Extraction: A buyer provides an unstructured requirement ("Find a professional logo designer under $100 within 3 days rated above 4.5"). The Personal Intent Agent extracts typed economic parameters and hard boundaries.
- Marketplace Discovery: The Discovery Agent queries verified provider registries with zero hallucination risk, filtering strictly by capability, availability, and rating thresholds.
- Multi-Factor Algorithmic Scoring: The Evaluation Agent scores candidates using a 5-dimensional weighted utility model: $$S_{\text{composite}} = 0.30 \cdot R_{\text{rel}} + 0.25 \cdot R_{\text{rating}} + 0.20 \cdot B_{\text{eff}} + 0.15 \cdot D_{\text{speed}} + 0.10 \cdot V_{\text{verif}}$$
- Competitive Multi-Provider Bidding: Rather than haggling with a single vendor, the Buyer Negotiation Agent opens concurrent, multi-round bargaining sessions with the top competing Merchant Agents. Each vendor defends reservation floor prices while competing for the contract.
- Automated Arbitration Matrix: The Arbitration Agent evaluates final counter-proposals based on composite utility: $$U_{\text{bid}} = 12 \cdot R_{\text{rating}} + 1.5 \cdot \text{Savings}\% + 0.8 \cdot \Delta_{\text{budget}} - 2.5 \cdot D_{\text{days}}$$ The optimal value bid is crowned with a Designated Winning Proposal badge, with instant human override controls.
- Live SSE Streaming Feed: Every thought trace, bid, counter-offer, and policy assertion streams in real time via Server-Sent Events (SSE).
- Deterministic Policy & Risk Engine: Zero AI trust for financial authorization. A pure mathematical rule engine validates:
- Budget ceiling: (\text{Price} \le \text{Max Budget})
- Account limits: (\text{Price} \le \text{User Cap})
- Currency match: (\text{Currency}{\text{Offer}} == \text{Currency}{\text{Task}})
- Provider verification & standing
- Unexpired cryptographic proposal timestamps
- Anti-replay idempotency guards
- Human Approval Gate & PayPal Capture: Only upon explicit operator sign-off is a PayPal Sandbox Order created (
intent: CAPTURE). The client authorizes the transaction via PayPal Smart Buttons, and the server verifies capture statusCOMPLETED. - Verifiable Official PayPal Receipt: Generates an official, print-ready vector PDF receipt modeled after PayPal's digital settlement receipts, including transaction breakdowns, policy compliance proofs, and a SHA-256 cryptographic verification digest.
How we built it
PayMesh is architected as an end-to-end, full-stack multi-agent platform:
- Backend Architecture (FastAPI & Python 3.13):
- Asynchronous FastAPI server structured around decoupled services: Agent Orchestrator, Negotiation Engine, Policy Gate, and PayPal REST Service.
- Streaming responses powered by async generators over Server-Sent Events (SSE) (
text/event-stream). - Relational persistence using SQLAlchemy 2.0 with dual database support (SQLite for zero-setup local execution, PostgreSQL / Supabase for production).
- Payment Core (PayPal Sandbox Orders v2):
- Direct server-to-server integration with PayPal REST APIs using OAuth 2.0 client credentials.
- Backend order creation (
POST /v2/checkout/orders) and secure server-side capture verification (POST /v2/checkout/orders/{id}/capture). - Comprehensive webhook listener with cryptographic transmission signature verification and replay prevention.
- Frontend Web Application (React 18, Vite 6, Tailwind CSS):
- High-performance reactive interface featuring real-time streaming agent monitors, 3-way comparative bidding matrix, and audit ledger.
- Integrated PayPal JavaScript SDK smart checkout flows.
- Vector PDF engine built with
jsPDFimplementing authentic PayPal receipt typography, alignments, and cryptographic badges.
Challenges we ran into
- Preventing Agent Hallucinations in Pricing & Policy: Early prompt-based agents could hallucinate agreed prices below vendor operational floors. We solved this by designing a Simulated Merchant Agent enforcing immutable mathematical reservation floors ((P_{\text{floor}})), and moving security enforcement entirely into a non-AI Deterministic Policy Engine.
- Real-Time Multi-Agent Streaming: Streaming multiple asynchronous agent deliberations, concurrent negotiations, and state updates over HTTP without UI freezing required building custom SSE generators and clean client-side event demultiplexing.
- Cross-Platform PDF Font Encoding: Standard PDF engines corrupted unicode characters (e.g., rendering rating stars or checkmarks as raw punctuation or disrupting font kerning). We rebuilt the document layout from the ground up, utilizing precise point-grid geometry and authentic PayPal brand typography.
- Idempotency in Agent Transactions: Ensuring that an agent or user could never double-authorize a capture required database-level state machine locking across Task, Offer, Approval, and Payment entities.
Accomplishments that we're proud of
- True Agent-to-Agent Coordination: PayMesh is not a generic chatbot with a checkout link. It features genuine autonomous agent interaction: Buyer Agent and Merchant Agent negotiating terms dynamically across multiple rounds.
- 100% Pass Rate Across Automated Test Suites: 9 comprehensive integration and unit test suites verifying agent constraints, policy assertions, PayPal order lifecycles, and tenant isolation.
- Zero-Setup Offline Resilience: PayMesh seamlessly toggles between real live PayPal Sandbox REST credentials and an offline simulation mode with
SANDBOX-identifiers, allowing instant evaluator testing without configuration barriers. - Enterprise-Grade Security Baseline: Strict tenant isolation, backend-only secret management, and human-in-the-loop authorization ensure that funds are never moved without deterministic cryptographic verification.
What we learned
- Deterministic Gates are Non-Negotiable: Generative AI is phenomenal for synthesis, strategy, and semantic extraction, but financial authorization must remain deterministic, audited, and strictly rule-bound.
- Parallel Bidding Maximizes Value: Simulating parallel negotiation across multiple providers consistently achieved 10% to 18% cost reductions below catalog rates while respecting merchant margins.
- PayPal Orders v2 Extensibility: Working with PayPal's Orders v2 capture lifecycle highlighted how well PayPal's server-side verification and webhook architecture integrates with autonomous software agents.
What's next for PayMesh — Autonomous Multi-Agent Commerce Network
- Milestone Escrow & AI Deliverable Inspection: Integrating automated escrow disbursements where an AI Inspection Agent verifies submitted project deliverables (code, design files, copy) against original specifications before triggering PayPal capture release.
- PayPal Subscriptions & Recurring Retainers: Extending agent commerce to handle recurring freelance retainers, automated domain/API subscription management, and periodic maintenance contracts.
- Decentralized Multi-Currency FX Settlement: Real-time multi-currency conversions across USD, EUR, GBP, and INR with automated currency conversion optimization before PayPal checkout dispatch.
- Production Cloud Deployment: Containerized deployment across Render, Vercel, and Supabase PostgreSQL with GitHub Actions CI/CD pipelines.
Built With
- artificial-intelligence
- css3
- fastapi
- html5
- json
- jspdf
- jwt
- multi-agent-systems
- paypal
- postgresql
- pydantic
- python
- react
- rest-api
- server-sent-events
- sqlalchemy
- sqlite
- sse
- tailwindcss
- typescript
- vite
- webhooks
Log in or sign up for Devpost to join the conversation.