Inspiration
AI agents are increasingly capable of making decisions and carrying out tasks independently. But when an agent moves from recommending a purchase to actually spending money, an important question arises: Who controls the transaction?
A conventional payment API can process a payment, but it does not automatically establish whether an AI agent is authorized to request it, whether the human has consented to that amount, or whether the request has been tampered with.
I wanted to build the missing trust layer between autonomous agents and financial transactions.
AgentTrust Gateway began with a simple principle: AI agents can initiate commerce, but humans must retain control over the authority to spend.
What it does
AgentTrust Gateway is a merchant-side security and payment orchestration platform for AI agents. It verifies agent identities, enforces human-approved spending restrictions, integrates with PayPal Sandbox, and records transaction decisions for auditing.
Its core capabilities include:
- Cryptographic agent authentication: Each registered agent receives credentials for HMAC-SHA256 request signing. The gateway checks signatures, timestamps, and nonces to reject unauthorized or replayed requests.
- Human consent: Merchants grant specific agents permission to transact within defined currency, spending, and expiration limits. Consent can be revoked.
- Deterministic policy enforcement: Per-transaction limits, daily spending caps, and approval thresholds determine whether a request is allowed, blocked, or requires additional approval.
- PayPal payment orchestration: Approved requests enter a PayPal Orders v2 authorization workflow, followed by buyer approval and a separate merchant-controlled capture process.
- Gemini-powered policy assistance: Google Gemini converts natural-language spending instructions into structured policy proposals, which are validated before a merchant can activate them.
- AI transaction risk assessment: Gemini provides advisory risk explanations alongside the gateway's authoritative deterministic decision.
- Auditability: An operations dashboard tracks agent requests, verification outcomes, policy decisions, payment orders, and security events.
- Interactive Demo Lab: A browser-based demonstration exercises the actual gateway verification and policy logic through three scenarios: unsigned request rejection, over-limit transaction blocking, and an authorized payment request.
The fundamental security boundary is deliberate: the AI model can advise and propose policies, but it cannot independently authorize spending or capture payments.
How we built it
I built AgentTrust Gateway as a full-stack TypeScript application using Next.js, React, Prisma, and PostgreSQL, deployed on Render.
The system is organized around a sequence of trust checks.
First, merchants register AI agents and receive signing credentials. Agent requests use HMAC-SHA256 signatures with timestamps and unique nonces. The gateway validates these credentials before accepting a transaction request.
Next, the gateway evaluates the request against the agent's active human consent and spending policy. The policy engine uses deterministic rules, rather than relying on an LLM to decide whether money can move.
For permitted transactions, the payment layer integrates with PayPal Orders v2 in the Sandbox environment. The workflow separates order creation, buyer approval, authorization, merchant capture approval, and capture. PayPal webhook handling provides a mechanism for verifying and processing payment notifications.
I integrated Google Gemini for natural-language policy generation and advisory transaction risk assessment. Gemini's structured output is validated against application schemas before it can be used in the policy-management workflow. Model-generated recommendations never bypass the gateway's authorization rules.
For the merchant interface, I used AG Grid Community to present sortable and filterable operational records, alongside a dashboard for agents, consent, policies, transactions, and audit history.
I also built an interactive Demo Lab that invokes the real gateway checkout handler. It lets users observe signature rejection, policy enforcement, and the PayPal Sandbox order-creation workflow without writing code or manually generating cryptographic signatures.
The application is hosted on Render with PostgreSQL persistence, and the source code is publicly available on GitHub.
The Demo Lab demonstrates signature rejection, consent enforcement, and successful PayPal Sandbox order creation through the actual gateway verification path. I also successfully tested the complete payment lifecycle, including buyer approval, authorization, and merchant-controlled capture.
Challenges we ran into
One of the largest challenges was designing the boundary between AI-generated recommendations and enforceable financial authorization. A language model can interpret instructions, but its output should not become an unrestricted payment command. I addressed this by separating AI assistance from deterministic policy evaluation and merchant-controlled payment actions.
Another challenge was making agent authentication both secure and demonstrable. Signed requests require precise agreement on request bodies, timestamps, nonces, and HMAC signatures. I built a browser-based Demo Lab that exercises the same production verification path while keeping signing secrets out of the browser.
Payment orchestration also required careful handling of asynchronous states. Creating an order, obtaining buyer approval, recording authorization, and capturing funds are distinct operations, each with its own security and audit requirements.
Deployment presented practical difficulties. I encountered dependency-installation problems, TypeScript compilation failures, Prisma configuration issues, and database migration requirements while moving from a local SQLite-based development setup to hosted PostgreSQL.
I also encountered AI API credit limitations and migrated the AI functionality to Gemini, preserving structured policy validation and the separation between AI advice and payment authority.
Finally, building a useful demonstration required more than exposing API endpoints. I had to make the security decisions visible and understandable through a merchant dashboard, audit records, and interactive test scenarios.
Accomplishments that we're proud of
I am particularly proud of building an integrated system where agent identity, human consent, policy enforcement, AI assistance, and payment orchestration operate as distinct layers.
In live testing, AgentTrust Gateway successfully:
- Rejected an unsigned agent request with HTTP 403 and recorded the rejection in its audit history.
- Verified a correctly signed agent request but blocked a $75 transaction that exceeded a $50 human consent cap.
- Verified a signed $25 request, enforced the configured spending policy, and successfully created a genuine PayPal Sandbox order.
- Completed the end-to-end PayPal Sandbox payment workflow, including buyer approval, payment authorization, and successful merchant-controlled capture.
- Produced structured AI risk analysis while preserving the deterministic gateway's independent decision.
- Exposed these security and payment outcomes through an interactive browser-based demonstration.
I am also proud that the application is deployed as a working full-stack service rather than existing only as a local prototype.
The most important architectural accomplishment is that AI assistance does not weaken payment security. The model helps humans express and understand their policies, while cryptographic verification, explicit consent, deterministic rules, and merchant approval remain authoritative.
Successfully completing the PayPal Sandbox payment lifecycle demonstrates that these security controls can operate alongside real payment APIs, from an authenticated agent request through to merchant-controlled capture.
What we learned
Building AgentTrust Gateway reinforced several important lessons about agentic commerce.
First, an AI agent's ability to request an action is different from its authority to perform that action. Financial applications need explicit, independently verifiable authorization boundaries.
Second, natural-language policy interfaces can make sophisticated controls more accessible, but the generated output must be validated and constrained before activation.
Third, payment systems are stateful. A successful API request is not equivalent to a completed payment, and order creation, buyer approval, authorization, and capture need to be modeled separately.
Fourth, security controls become much more useful when their decisions are observable. Audit trails and clear explanations help merchants understand why an agent request was accepted or rejected.
Finally, I learned how to combine a hosted full-stack application, PostgreSQL persistence, cryptographic request verification, structured AI outputs, and PayPal Sandbox integration into a cohesive developer-facing product.
What's next for AgentTrust Gateway
My next priority is to expand AgentTrust Gateway from a hackathon prototype into reusable trust infrastructure for agentic commerce.
I want to package its authentication, consent, and policy capabilities into a developer SDK and API that can be integrated with different AI-agent frameworks.
I also plan to introduce more granular merchant controls, including merchant allowlists, category restrictions, transaction velocity limits, and configurable risk escalation.
On the payments side, I want to improve reconciliation, webhook monitoring, authorization lifecycle management, and operational visibility.
For AI, I plan to explore risk analysis informed by historical transaction patterns while retaining deterministic enforcement for payment authorization.
The long-term goal is to make it practical for businesses to deploy autonomous purchasing agents without surrendering control over spending authority.
Built With
- ag-grid
- google-gemini
- hmac-sha256
- next.js
- node.js
- paypal
- paypal-rest-apis
- paypal-sandbox
- playwright
- postgresql
- prisma
- react
- render
- tailwind-css
- typescript
- vitest
- zod