Skip to content
albertsalguedaPublic

About

Let your AI agent pay. Fund with your card. Set limits. Done. πŸ’³πŸ€–

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

πŸ’³ LetPay

The open-source payment layer for AI agents.

Give your agent a virtual card. Fund it with your card. Set spending rules. Done.

Build License: MIT


Why LetPay?

AI agents are spending money β€” APIs, subscriptions, domains, services. But giving them payment access today is painful:

Solution Problem
Crypto wallets (Skyfire, x402) Requires stablecoins β€” not mass-market
US-only cards (Privacy.com, Slash) Doesn't work in Europe
Enterprise APIs (Visa, PayPal) Not built for individual developers
Sharing your card No controls, no limits, no visibility

LetPay fills the gap: real money, real cards, real controls. Open source. Works in EU + US.

How It Works

User                          LetPay                         Card Provider
  β”‚                              β”‚                               β”‚
  β”œβ”€β”€ Sign up ──────────────────►│                               β”‚
  β”œβ”€β”€ Create wallet β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”œβ”€β”€ Issue virtual card ────────►│
  β”œβ”€β”€ Fund wallet (Stripe) β”€β”€β”€β”€β”€β–Ίβ”œβ”€β”€ Credit balance              β”‚
  β”‚                              β”‚                               β”‚
Agent                            β”‚                               β”‚
  β”œβ”€β”€ letpay_pay(€15, OpenAI) β”€β”€β–Ίβ”œβ”€β”€ Check rules                 β”‚
  β”‚                              β”œβ”€β”€ βœ… Auto-approve (< threshold)β”‚
  │◄── Card details (PAN/CVV) ───                               β”‚
  β”œβ”€β”€ Uses card at checkout ─────┼──────────────────────────────►│
  β”‚                              │◄── Webhook: charge confirmed  β”‚
  β”‚                              β”œβ”€β”€ Record transaction          β”‚
  β”‚                              β”œβ”€β”€ Notify user (Telegram)      β”‚

Features

  • πŸ’³ Virtual Visa cards β€” one per agent, isolated spending
  • πŸ”’ Spending rules β€” monthly limits, per-transaction caps, merchant category controls
  • πŸ€– MCP server β€” works with any MCP-compatible agent (Claude, OpenClaw, etc.)
  • πŸ‘€ Human-in-the-loop β€” approve big purchases via Telegram
  • πŸ“Š Dashboard β€” real-time transactions, wallet management, API keys
  • ⚑ Instant alerts β€” Telegram notifications on every spend
  • πŸ›‘ Kill switch β€” freeze any wallet instantly
  • 🌍 EU + US β€” multi-provider architecture (Stripe, Wallester, more coming)
  • πŸ”Œ Provider-agnostic β€” swap card issuers without changing your agent code

Quick Start

1. Clone & Install

git clone https://github.com/albertsalgueda/letpay.git
cd letpay
pnpm install

2. Set Up Environment

cp .env.example .env
# Edit .env with your credentials (or use USE_MOCKS=true for local dev)

3. Run with Mocks (no API keys needed)

# Start the database
docker compose up -d postgres

# Push the schema
cd packages/db && DATABASE_URL=postgresql://letpay:letpay@localhost:5432/letpay npx drizzle-kit push && cd ../..

# Start the API
pnpm --filter @letpay/api dev

# Start the dashboard (separate terminal)
pnpm --filter @letpay/web dev

API runs on http://localhost:3001, dashboard on http://localhost:3000.

4. Connect Your Agent (MCP)

{
  "mcpServers": {
    "letpay": {
      "command": "npx",
      "args": ["@letpay/mcp-server"],
      "env": {
        "LETPAY_API_KEY": "your-api-key",
        "LETPAY_API_URL": "http://localhost:3001"
      }
    }
  }
}

Your agent now has 4 tools: letpay_balance, letpay_pay, letpay_history, letpay_request_topup.

Architecture

letpay/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/              # REST API (Hono + Node.js)
β”‚   β”œβ”€β”€ web/              # Dashboard (Next.js 15)
β”‚   └── telegram-bot/     # Notifications + approval bot (grammy)
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ core/             # Business logic, rules engine, provider interfaces
β”‚   β”œβ”€β”€ db/               # Database schema + migrations (Drizzle + Postgres)
β”‚   └── mcp-server/       # MCP server for agent integration

Provider Architecture

LetPay uses a provider interface pattern β€” card issuers and payment processors are pluggable:

// packages/core/src/cards/interface.ts
interface CardIssuingService {
  createVirtualCard(params): Promise<CardInfo>;
  getCardDetails(cardId): Promise<CardDetails>;
  freezeCard(cardId): Promise<void>;
  approveAuthorization(authId): Promise<void>;
  declineAuthorization(authId, reason): Promise<void>;
  // ...
}

Current implementations:

  • MockCardIssuingService β€” for local development
  • Stripe Issuing β€” coming soon
  • Wallester β€” coming soon
  • Your provider β€” implement the interface, submit a PR

Rules Engine

Every transaction is evaluated against configurable rules:

1. Sufficient balance?          β†’ Decline if not
2. Per-transaction limit?       β†’ Decline if exceeded
3. Monthly limit?               β†’ Decline if exceeded
4. Merchant category blocked?   β†’ Decline if MCC in blocklist
5. Merchant category allowed?   β†’ Decline if MCC not in allowlist
6. Above approval threshold?    β†’ Route to human approval
7. All clear                    β†’ Auto-approve βœ…

Tech Stack

Layer Technology
API Node.js, TypeScript, Hono
Database PostgreSQL + Drizzle ORM
Dashboard Next.js 15, Tailwind CSS
Auth Supabase Auth
Agent Integration MCP (Model Context Protocol)
Notifications Telegram Bot (grammy)
Payments Stripe (funding)
Card Issuing Provider-agnostic interface
Monorepo pnpm workspaces + Turborepo
CI GitHub Actions

API Reference

Agent Endpoints

POST /v1/agent/pay          # Request a payment
GET  /v1/agent/balance      # Check wallet balances
GET  /v1/agent/history      # Recent transactions

Wallet Management

POST   /v1/wallets              # Create wallet
GET    /v1/wallets              # List wallets
GET    /v1/wallets/:id          # Get wallet
PATCH  /v1/wallets/:id          # Update wallet
POST   /v1/wallets/:id/freeze   # Freeze wallet
POST   /v1/wallets/:id/unfreeze # Unfreeze wallet
POST   /v1/wallets/:id/topup    # Fund wallet
GET    /v1/wallets/:id/balance  # Get balance
GET    /v1/wallets/:id/rules    # Get spending rules
PUT    /v1/wallets/:id/rules    # Update spending rules

Approvals

GET  /v1/approvals                # List pending approvals
POST /v1/approvals/:id/approve    # Approve
POST /v1/approvals/:id/deny       # Deny

MCP Tools

Tool Description
letpay_balance Check wallet balance and monthly spending
letpay_pay Request a payment (returns card details if approved)
letpay_history View recent transactions
letpay_request_topup Ask the user to add funds

Self-Hosting

Docker Compose (recommended)

docker compose up

This starts PostgreSQL, the API, the web dashboard, and the Telegram bot.

Environment Variables

Variable Required Description
DATABASE_URL Yes PostgreSQL connection string
SUPABASE_URL For auth Supabase project URL
SUPABASE_ANON_KEY For auth Supabase publishable key
SUPABASE_SERVICE_ROLE_KEY For auth Supabase secret key
STRIPE_SECRET_KEY For payments Stripe secret key
STRIPE_WEBHOOK_SECRET For payments Stripe webhook signing secret
TELEGRAM_BOT_TOKEN For notifications Telegram bot token from @BotFather
USE_MOCKS No Set to true for local dev without real APIs

Deployment

Vercel (Dashboard)

cd apps/web
vercel deploy

Railway / Fly.io (API + Bot)

The API and Telegram bot need long-running processes. Deploy to Railway, Fly.io, or any container platform.

# API
docker build -f apps/api/Dockerfile -t letpay-api .
# Bot
docker build -f apps/telegram-bot/Dockerfile -t letpay-bot .

Contributing

We're building in the open. Contributions welcome!

Adding a Card Provider

  1. Implement CardIssuingService interface in packages/core/src/cards/
  2. Add tests in packages/core/__tests__/cards/
  3. Register in apps/api/src/deps.ts
  4. Submit a PR

Development

pnpm install
pnpm build        # Build all packages
pnpm test         # Run all tests
pnpm dev          # Start API + web in dev mode

Roadmap

  • Core rules engine
  • MCP server (4 tools)
  • REST API with auth
  • Web dashboard
  • Telegram bot (notifications + approvals)
  • Stripe payment integration
  • Mock mode for local dev
  • Stripe Issuing provider
  • Wallester provider
  • Slash API provider (US)
  • Multi-agent wallets
  • Receipt/invoice capture
  • Team accounts
  • OpenClaw skill (ClawHub)
  • AP2 protocol support
  • x402 support

License

MIT β€” use it however you want.


Built by Albert Salgueda

Every AI agent will need a wallet. This is the open-source one.

About

Let your AI agent pay. Fund with your card. Set limits. Done. πŸ’³πŸ€–

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages