Inspiration
AI agents can already compare suppliers and read invoices, but businesses still cannot trust an unconstrained LLM with a live company wallet. Early 2026 agentic checkout rollouts proved that even a 1% agent error rate at scale fractures the legal liability chain and triggers unmanageable chargebacks. We built AegisPay to give AI agents secure "hands" on PayPal—combining machine-speed B2B procurement with deterministic budget rules, escrow holds, and automated dispute defense.
What it does
AegisPay is an autonomous B2B procurement, escrow, and dispute-defense control plane built on PayPal and AI:
Scoped Discovery: A read-only agent searches 100M+ products via Channel3 and audits supplier PDF contracts indexed in Elastic.
Deterministic Mandate Gate & PayPal Escrow: Before staging any payment, a deterministic policy engine verifies our core procurement invariant:
Total Cost <= Budget Cap ^ Unit Price <= Ceiling ^ ETA <= SLA
Verified orders are staged via the PayPal MCP Server using Orders v2 (intent: "AUTHORIZE") or Invoicing v2 (PAY_BY_BANK with quoted contract clauses) and require human approval via the PayPal JavaScript SDK v6.
Live Reconciliation & Auto-Dispute Defense: Teams track holds and delivery SLAs in AG Grid and Bryntum. On-time delivery via PayPal Shipment Tracking triggers capture (pay_order); SLA breaches or buyer claims trigger APIMatic-typed PayPal Disputes v1 calls (/v1/customer/disputes/{id}/provide-evidence) with attached carrier logs, Channel3 price snapshots, and Elastic contract citations
How we built it
PayPal & AI Stack (AI Tools Statement): Integrated PayPal MCP Server (@paypal/mcp v1.8.1) over Streamable HTTP and PayPal Agent Toolkit (@paypal/agent-toolkit) (create_order, get_order, pay_order, create_refund, create_invoice, create_subscription, list_disputes, list_transactions), orchestrated by Claude / Gemini (Vercel AI SDK) and audited with PayPal AI Toolkit (/paypal:doctor). Least-Privilege Security: Enforced PayPal MCP Restricted Tool Visibility so sourcing agents cannot access payment capture or refund tools, backed by an auto-refreshing OAuth2 token vault. Partner Stack: AG Grid (live reconciliation ledger), Bryntum (SLA & auth countdown timeline), Channel3 (product sourcing), Elastic (contract RAG), APIMatic (typed Disputes/Webhooks SDKs), Postman (API collections), and Render (cloud hosting for Node.js, TypeScript, PostgreSQL, and Redis).
Challenges we ran into
Webhook Verification: PayPal’s /v1/notifications/verify-webhook-signature rejects simulator mock events (WEBHOOK_ID), and JSON parsing breaks raw CRC32 hashing. We built a dual-mode verifier running offline RSA-SHA256 + unsigned 32-bit CRC32 checks on raw byte buffers alongside live postback verification.
Dispute State Routing: PayPal’s /provide-evidence requires WAITING_FOR_SELLER_RESPONSE status and strict reason-to-evidence_type mapping (PROOF_OF_FULFILLMENT vs. OTHER), which we enforced via HATEOAS link checks and APIMatic schemas.
Sandbox Token Expiry: Because Sandbox OAuth2 tokens expire every 3–8 hours, we built background pre-expiry token refresh to keep our Render deployment live across the judging window.
Accomplishments that we're proud of
Passing all PayPal /paypal:doctor static and live sandbox probes (Auth, Order, Subscription, and Webhook verification).
Guaranteeing zero unapproved AI spend every PayPal hold and capture is locked to a verified Channel3 SKU, an Elastic contract citation, and human sign-off.
Real-time bidirectional reactivity between PayPal Sandbox Webhooks, AG Grid, and Bryntum.
What we learned
Financial AI works best when LLMs handle unstructured tasks (catalog comparison, contract reading, evidence drafting) while deterministic code governs budget math, OAuth scopes, and payment execution.
PayPal’s MCP Server and Restricted Tool Visibility provide production-ready least-privilege security for multi-agent commerce.
What's next for AegisPay
Supporting PayPal Agent Ready flows integrating Agentic Commerce Protocol (ACP) delegated payment tokens and Universal Commerce Protocol (UCP) encrypted checkout credentials across ChatGPT and Google AI Mode.
Adding WebAuthn passkey co-signing for high-value treasury approvals and automated cross-border supplier payouts.
Built With
- ag-grid
- apimatic
- bryntum
- channel3
- elasticsearch
- mcp
- node.js
- paypal
- postgresql
- postman
- react
- redis
- render
- tailwindcss
- typescript