Inspiration

Autonomous AI agents are now capable of writing code, deploying infrastructure, and running data workflows. However, granting agents payment capability has      
remained a critical bottleneck. A single runaway loop or prompt injection attack could drain bank accounts within minutes. We built **PayAgent** to bridge this  
trust gap by inserting a deterministic policy and budgeting guardrail between the autonomous LLM decision loop and the PayPal Orders v2 API.

## What it does
PayAgent is an autonomous agentic commerce protocol that:
1. **Understands Commercial Intent:** Parses user requests or multi-step agent tasks to find necessary digital goods (compute GPUs, vector storage, LLM token    
packs, domains).
2. **Enforces Deterministic Guardrails:** Evaluates single-order caps ($35), rolling 24-hour spend ceilings ($150), category whitelists, and vendor reputation   
scoring before touching financial rails.
3. **Automates PayPal Orders v2:** Seamlessly creates and captures sandbox orders using PayPal's `/v2/checkout/orders` REST API.
4. **Human-in-the-Loop Escalation:** Automatically stages orders above autonomous thresholds ($25) and generates a one-click PayPal checkout approval URL for    
human operator authorization.
5. **Real-Time Audit Ledger:** Logs an immutable compliance record with PayPal Order IDs, risk scores, and capture IDs.

## How we built it
- **Runtime & Language:** Built with Bun and native TypeScript for sub-millisecond execution latency.
- **Payment Gateway:** Direct REST integration with PayPal Orders v2 (`/v2/checkout/orders` and `/v2/checkout/orders/{id}/capture`) with dual-mode sandbox       
simulation.
- **Guardrail Engine:** Policy evaluator managing rolling daily spend rollover, category filtering, and risk scoring.
- **Telemetry UI & WebSockets:** Glassmorphism FinTech dashboard with real-time SSE/WebSocket telemetry streaming every decision phase.

## Challenges we ran into
Balancing autonomous speed with strict safety. We designed a staged order authorization pattern where low-risk micro-purchases settle autonomously in       
milliseconds, while higher-value or policy-borderline orders pause into a staged PayPal approval flow without crashing agent execution. 

## Accomplishments that we're proud of
- 100% test coverage across boundary conditions and PayPal integration flows. 
- Zero external runtime bundle dependencies. 
- A functional proof-of-concept for the future of safe Agent-to-Business (A2B) commerce.

## What we learned
How PayPal's developer platform can serve as the universal identity, authentication, and settlement layer for the emerging autonomous software agent economy. 

## What's next for PayAgent
- Multi-currency support with dynamic FX conversion. 
- Agent-to-Agent (A2A) micro-negotiation protocols.
- Webhook listener for asynchronous PayPal capture callbacks.

Built With

  • agentic-ai
  • bun
  • fintech
  • llm
  • paypal-orders-v2
  • rest-api
  • typescript
  • websocket
Share this project:

Updates

posted an update —

Project Update: Announcing PayAgent -- Autonomous Agentic Commerce Protocol with PayPal Guardrails

We just published the first full release of PayAgent for the PayPal AI Hackathon: Build what's next with PayPal and AI!

### The Big Idea

Autonomous AI agents are increasingly capable of coding, provisioning infrastructure, and orchestrating cloud services. But granting them payment access has been
an unsolved risk: a single runaway loop or prompt injection exploit could drain financial accounts in minutes.

PayAgent solves this by establishing a hardened programmatic guardrail layer between LLMs and payment gateways.

### What's New & Included:

- **PayPal Orders v2 REST Integration**: Direct OAuth2 token exchange with https://api-m.sandbox.paypal.com to create digital goods orders with strict item
breakdown validation and automated capture.                                                                                                                   
- **Deterministic Budget Guardrails**: Real-time evaluation of single-transaction caps ($35 default), rolling 24h spend ceilings ($150), and merchant whitelist
categories.                                                                                                                                                     
- **AdversarialShield & Shadow Simulation Box**: Intercepts prompt injections (SYSTEM OVERRIDE), delimiter density attacks, and unverified wallet redirects with
a pre-flight dry run before financial execution.                                                                                                                 
- **Human-in-the-Loop Escalation**: Flagged purchases above authorization thresholds pause and stage live PayPal checkout approval links for operator sign-off.
- **Cryptographic SHA-256 Merkle Audit Chain**: Tamper-evident hash-chained transaction ledger with replay attack prevention.
- **Stock shadcn/ui Zinc Dashboard**: Real-time WebSocket telemetry stream and interactive scenario tester.

### Quality & Open Source

- 18 / 18 unit & integration tests passing (bun test).
- Zero external runtime bloat built on Bun + TypeScript.
- Released under the permissive MIT Open Source License. 

Explore the code on GitHub: https://github.com/Codenuclei/payagent

Submission history