Skip to content

About

πŸ€–πŸ’΅ Agentic Payment Service for Open Agent Skills Ecosystem.

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

122 Commits

Folders and files

Repository files navigation

πŸ€–πŸ’΅ Agentic Payment Service for Open Agent Skills Ecosystem.

A tri-protocol (x402 + AP2 + MPP) agentic payment service for Open Agent Skills Ecosystem (including OpenClaw, Claude Code, Codex, Junie, OpenCode, GitHub Copilot, Gemini CLI, etc.), with web3 & web2 gateway support, EIP-3009 signed stablecoin authorizations (Viem), AWS KMS key management, policy engine compliance, audit trail, and human-in-the-loop confirmation.

TypeScript OpenClaw Skill License: Apache 2.0


Table of Contents


Overview

agentic-payments-bot is a payment serivce/gateway/bot/agent/assistant with support for and providing of X402, AP2, and MPP server and client, and providing an Open Agent Skills Ecosystem compliant skill, that enables AI agents to autonomously initiate, validate, and execute payments across both blockchain (web3) and traditional (web2) payment rails.

Key Capabilities

Capability Details
Triple protocol support x402 (HTTP 402 + onchain settlement), AP2 (Google's mandate-based agent payments), and MPP (Machine Payments Protocol β€” rail-agnostic quote β†’ invoice β†’ settle β†’ receipt lifecycle with content-addressed invoices and signed receipts)
Dual role: server + client Acts as a payment gateway (accepts payments from external agents via x402/AP2/MPP server endpoints) and as a payment client (makes payments to external services via all backends)
Web3 transactions Ethereum, Base, Polygon via Viem β€” native ETH and ERC-20 (USDC, etc.)
EIP-3009 signing Full x402 client payment flow: EIP-712 TransferWithAuthorization signed via Viem with a private key decrypted through the configured KMS backend β€” the key never leaves the KMS trust boundary
Web2 gateways Stripe, PayPal, Visa Direct, Mastercard Send, Google Pay, Apple Pay
Protocol gateways x402 remote resource payment, AP2 remote mandate submission, MPP remote invoice payment β€” paying any service that supports these protocols
Key management Pluggable KMS providers: AWS KMS, OS Keyring (KDE Wallet / GNOME Keyring / macOS Keychain / Windows Credential Manager), D-Bus Secret Service, GnuPG, Local AES-256-GCM
Policy engine Per-tx limits, daily/weekly/monthly aggregates, time-of-day, blacklist/whitelist, currency restrictions
Human-in-the-loop Automatic escalation on policy violations via CLI prompt, chat prompt, or web API
Audit trail Every action logged to SQLite audit_log table + Winston (stdout/stderr/file)
Three interfaces OpenClaw (or other agent) chat, CLI (agentic-payments-bot), REST web API
Fully configurable Single YAML file controls all behavior

Architecture

System Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           Agent Payments Skill                                    β”‚
β”‚                                                                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ SERVER SIDE (Accept Payments) ───────────────────────────┐  β”‚
β”‚  β”‚                                                                             β”‚  β”‚
β”‚  β”‚  External Agents ──► x402 Paywall Middleware (HTTP 402 flow)                β”‚  β”‚
β”‚  β”‚                      AP2 Mandate Endpoints (mandate lifecycle)              β”‚  β”‚
β”‚  β”‚                      MPP Endpoints (quote β†’ invoice β†’ settle β†’   ──► Paymentβ”‚  β”‚
β”‚  β”‚                      receipt)                                     Execution β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                 β”‚
β”‚  β”‚  Chat UI  β”‚   β”‚   CLI (term)  β”‚   β”‚ Web API  β”‚                                 β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜                                 β”‚
β”‚        β”‚                 β”‚                β”‚                                       β”‚
β”‚        β–Ό                 β–Ό                β–Ό                                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                           β”‚
β”‚  β”‚              Protocol Router                       β”‚                           β”‚
β”‚  β”‚  (AI output parser β†’ PaymentIntent β†’ routing)      β”‚                           β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜                           β”‚
β”‚       β”‚          β”‚         β”‚          β”‚          β”‚                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β” β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”                           β”‚
β”‚  β”‚ web3   β”‚ β”‚ web2   β”‚ β”‚ x402   β”‚ β”‚ ap2    β”‚ β”‚ mpp    β”‚                           β”‚
β”‚  β”‚(Viem)  β”‚ β”‚(Stripe β”‚ β”‚(remote β”‚ β”‚(remote β”‚ β”‚(remote β”‚                           β”‚
β”‚  β”‚        β”‚ β”‚PayPal  β”‚ β”‚resourceβ”‚ β”‚mandate β”‚ β”‚invoice β”‚                           β”‚
β”‚  β”‚        β”‚ β”‚Visa MC β”‚ β”‚client) β”‚ β”‚client) β”‚ β”‚client) β”‚                           β”‚
β”‚  β”‚        β”‚ β”‚GPay    β”‚ β”‚        β”‚ β”‚        β”‚ β”‚        β”‚                           β”‚
β”‚  β”‚        β”‚ β”‚APay)   β”‚ β”‚        β”‚ β”‚        β”‚ β”‚        β”‚                           β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜ β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜                           β”‚
β”‚       β”‚         β”‚          β”‚          β”‚          β”‚                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”                           β”‚
β”‚  β”‚            Policy Engine                           β”‚                           β”‚
β”‚  β”‚  (compliance checks before execution)              β”‚                           β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚                           β”‚
β”‚  β”‚  β”‚ β€’ Single tx limit    β€’ Blacklist      β”‚         β”‚                           β”‚
β”‚  β”‚  β”‚ β€’ Daily/Weekly/Mo    β€’ Whitelist      β”‚         β”‚                           β”‚
β”‚  β”‚  β”‚ β€’ Time-of-day        β€’ Currency       β”‚         β”‚                           β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚                           β”‚
β”‚  β”‚       β”‚ (violation?) ──► Human Confirm             β”‚                           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β”‚
β”‚          β”‚                                                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
β”‚  β”‚          Payment Execution                  β”‚  β”‚  KMS Provider β”‚               β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”  β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚               β”‚
β”‚  β”‚  β”‚ Viem   β”‚ β”‚ Stripe β”‚ β”‚ Visa   β”‚ β”‚ x402 β”‚  β”‚  β”‚ β”‚ AWS KMS   β”‚ β”‚               β”‚
β”‚  β”‚  β”‚(ETH/   β”‚ β”‚ PayPal β”‚ β”‚ MC     β”‚ β”‚ AP2  β”‚  β”‚  β”‚ β”‚ OS Keyringβ”‚ β”‚               β”‚
β”‚  β”‚  β”‚ ERC20/ β”‚ β”‚ GPay   β”‚ β”‚        β”‚ β”‚ MPP  β”‚  β”‚  β”‚ β”‚ D-Bus SS  β”‚ β”‚               β”‚
β”‚  β”‚  β”‚ EIP-   β”‚ β”‚ APay   β”‚ β”‚        β”‚ β”‚      β”‚  │◄─│ β”‚ GnuPG     β”‚ β”‚               β”‚
β”‚  β”‚  β”‚ 3009)  β”‚ β”‚        β”‚ β”‚        β”‚ β”‚      β”‚  β”‚  β”‚ β”‚ Local AES β”‚ β”‚               β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚               β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚                 β”‚                                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                  β”‚
β”‚  β”‚                  SQLite                     β”‚                                  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚                                  β”‚
β”‚  β”‚  β”‚encrypted_keysβ”‚ β”‚transac-  β”‚ β”‚audit_log β”‚ β”‚                                  β”‚
β”‚  β”‚  β”‚              β”‚ β”‚tions     β”‚ β”‚          β”‚ β”‚                                  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚                                  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Directory Structure

agentic-payments-bot/
β”œβ”€β”€ SKILL.md                          # Open Agent Skills Ecosystem compliant skill definition (YAML frontmatter + markdown)
β”œβ”€β”€ package.json                      # npm package manifest
β”œβ”€β”€ tsconfig.json                     # TypeScript compiler config
β”œβ”€β”€ .env.example                      # Environment variable template
β”œβ”€β”€ .gitignore
β”œβ”€β”€ config/
β”‚   └── default.yaml                  # Master YAML configuration
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts                      # Main entry point / orchestrator
β”‚   β”œβ”€β”€ cli.ts                        # CLI interface (Commander.js)
β”‚   β”œβ”€β”€ web-api.ts                    # REST API (Express) β€” includes x402/AP2 server endpoints
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── loader.ts                 # YAML config loader + Zod validation
β”‚   β”œβ”€β”€ protocols/
β”‚   β”‚   β”œβ”€β”€ router.ts                 # Protocol router + AI output parser
β”‚   β”‚   β”œβ”€β”€ x402/
β”‚   β”‚   β”‚   β”œβ”€β”€ client.ts             # x402 HTTP 402 client (paying for resources)
β”‚   β”‚   β”‚   β”œβ”€β”€ eip3009.ts            # EIP-3009 TransferWithAuthorization signer (EIP-712 via Viem)
β”‚   β”‚   β”‚   └── server.ts             # x402 paywall middleware & settlement (accepting payments)
β”‚   β”‚   β”œβ”€β”€ ap2/
β”‚   β”‚   β”‚   β”œβ”€β”€ client.ts             # AP2 mandate-based client (submitting mandates)
β”‚   β”‚   β”‚   └── server.ts             # AP2 mandate lifecycle server (processing mandates)
β”‚   β”‚   └── mpp/
β”‚   β”‚       β”œβ”€β”€ types.ts              # MPP shared types (Quote, Invoice, SettleRequest, Receipt)
β”‚   β”‚       β”œβ”€β”€ client.ts             # MPP client (quote β†’ invoice β†’ settle β†’ receipt)
β”‚   β”‚       └── server.ts             # MPP server (content-addressed invoices, signed receipts, rail dispatch)
β”‚   β”œβ”€β”€ payments/
β”‚   β”‚   β”œβ”€β”€ web3/
β”‚   β”‚   β”‚   └── ethereum.ts           # Viem-based ETH/ERC-20 tx producer
β”‚   β”‚   └── web2/
β”‚   β”‚       └── gateways.ts           # Stripe, PayPal, Visa, MasterCard, Google Pay, Apple Pay
β”‚   β”œβ”€β”€ kms/
β”‚   β”‚   β”œβ”€β”€ provider.ts               # KmsProvider interface (shared contract)
β”‚   β”‚   β”œβ”€β”€ factory.ts                # Provider factory (selects backend from config)
β”‚   β”‚   β”œβ”€β”€ aws-kms.ts                # Public API: encryptAndStore / retrieveAndDecrypt
β”‚   β”‚   β”œβ”€β”€ aws-kms-provider.ts       # AWS KMS provider implementation
β”‚   β”‚   β”œβ”€β”€ os-keyring-provider.ts    # OS Keyring via @aspect-build/keytar
β”‚   β”‚   β”œβ”€β”€ dbus-secret-service-provider.ts  # Linux D-Bus Secret Service (dbus-next)
β”‚   β”‚   β”œβ”€β”€ gpg-provider.ts           # GnuPG encryption for headless Linux
β”‚   β”‚   └── local-aes-provider.ts     # Local AES-256-GCM (fallback / dry-run)
β”‚   β”œβ”€β”€ dry-run/
β”‚   β”‚   β”œβ”€β”€ crypto.ts                 # Local AES-256-GCM encryption (no KMS)
β”‚   β”‚   β”œβ”€β”€ stubs.ts                  # Gateway stub responses (success/failure/random)
β”‚   β”‚   └── wallet.ts                 # Viem key generation + local encrypt/store
β”‚   β”œβ”€β”€ db/
β”‚   β”‚   β”œβ”€β”€ sqlite.ts                 # SQLite init + migrations
β”‚   β”‚   β”œβ”€β”€ key-store.ts              # Encrypted key CRUD
β”‚   β”‚   β”œβ”€β”€ transactions.ts           # Transaction records + aggregates
β”‚   β”‚   └── audit.ts                  # Audit trail read/write
β”‚   β”œβ”€β”€ policy/
β”‚   β”‚   β”œβ”€β”€ engine.ts                 # Policy rule evaluator
β”‚   β”‚   └── feedback.ts               # Human confirmation (CLI/chat/API)
β”‚   └── logging/
β”‚       └── logger.ts                 # Winston multi-transport logger
β”œβ”€β”€ data/                             # (created at runtime)
β”‚   └── payments.db                   # SQLite database
└── logs/                             # (created at runtime)
    └── payment-skill.log             # File log output

Data Flow

Client Side β€” Making Payments (Agent β†’ External Services)

User/Agent input
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Parse AI Output  │────►│ Validate JSON Schema β”‚
β”‚ (regex + JSON)   β”‚     β”‚ (Zod PaymentIntent)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Protocol Router    β”‚
                         β”‚ (detect gateway:     β”‚
                         β”‚  web3/web2/x402/     β”‚
                         β”‚  ap2/mpp)            β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Create Transaction   β”‚
                         β”‚ Record (SQLite)      β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Policy Engine       │◄── rules from YAML
                         β”‚ β€’ limits check        │◄── aggregates from SQLite
                         β”‚ β€’ blacklist/whitelist β”‚
                         β”‚ β€’ time restrictions   β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                            β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                            β”‚  violations?   β”‚
                            β””β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”˜
                           yes  β”‚        β”‚ no
                                β–Ό        β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
                    β”‚ Human Confirm β”‚    β”‚
                    β”‚ (CLI/Chat/API)β”‚    β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
                     reject β”‚ confirm    β”‚
                       β–Ό    β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”˜
                    REJECT  β”‚    β”‚
                            β–Ό    β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Decrypt Keys (KMS)  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚               β”‚                β”‚
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
     β”‚ web3 (Viem)   β”‚ β”‚ web2        β”‚ β”‚ Protocol      β”‚
     β”‚ ETH / ERC-20  β”‚ β”‚ Stripe      β”‚ β”‚ Clients       β”‚
     β”‚               β”‚ β”‚ PayPal      β”‚ β”‚               β”‚
     β”‚ Direct chain  β”‚ β”‚ Visa / MC   β”‚ β”‚ x402: discoverβ”‚
     β”‚ transactions  β”‚ β”‚ GPay / APay β”‚ β”‚ β†’ sign EIP-   β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚ 3009 (KMS key)β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚ β†’ pay         β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚ β†’ get resourceβ”‚
     β”‚               β”‚ β”‚             β”‚ β”‚               β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚ AP2: mandate  β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚ β†’ sign β†’ cred β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚ β†’ submit      β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚               β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚ MPP: quote    β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚ β†’ invoice     β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚ β†’ settle(rail)β”‚
     β”‚               β”‚ β”‚             β”‚ β”‚ β†’ receipt     β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚               β”‚                β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Update Transaction β”‚
                    β”‚  + Audit Log        β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Server Side β€” Accepting Payments (External Agents β†’ This Service)

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚       External Agent Request         β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚          β”‚          β”‚
              x402 path    β”‚          β”‚ AP2 path β”‚  MPP path
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚          └───────────────────┐
         β”‚                            β”‚                              β”‚
         β–Ό                            β–Ό                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ GET /x402/premium/data β”‚ β”‚ POST /ap2/mandates       β”‚ β”‚ POST /mpp/quote          β”‚
β”‚ (any paywall route)    β”‚ β”‚ (accept mandate)         β”‚ β”‚ (issue quote)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                           β”‚                            β”‚
     β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”                    β–Ό                            β–Ό
     β”‚ X-PAYMENT   β”‚      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚ header?     β”‚      β”‚ POST /ap2/sign-mandate   β”‚ β”‚ POST /mpp/invoice        β”‚
     β””β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”˜      β”‚ (credential provider)    β”‚ β”‚ (content-addressed,      β”‚
     no β”‚      β”‚ yes      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚  signed invoice)         β”‚
        β–Ό      β”‚                       β”‚               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚                       β–Ό                            β”‚
 β”‚ HTTP 402   β”‚β”‚      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β–Ό
 β”‚ + payment  β”‚β”‚      β”‚ POST /ap2/payment-credentialsβ”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚ requirem.  β”‚β”‚      β”‚ (issue scoped tokens)        β”‚ β”‚ POST /mpp/settle         β”‚
 β”‚ in X-PAY-  β”‚β”‚      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ (rail: x402 / stripe /   β”‚
 β”‚ MENT hdr   β”‚β”‚                   β”‚                   β”‚  paypal / card / crypto) β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚                   β–Ό                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β–Ό            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ POST /ap2/process-payment  β”‚          β–Ό
    β”‚ Validate payload:   β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ β€’ auth fields       β”‚              β”‚                 β”‚ GET /mpp/receipt/:id   β”‚
    β”‚ β€’ EIP-3009 signed   β”‚              β”‚                 β”‚ (signed receipt)       β”‚
    β”‚   authorization     β”‚              β”‚                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚ β€’ amount β‰₯ required β”‚              β”‚                              β”‚
    β”‚ β€’ time bounds       β”‚              β”‚                              β”‚
    β”‚ β€’ payTo matches     β”‚              β”‚                              β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚                              β”‚
               β”‚                         β”‚                              β”‚
               β–Ό                         β–Ό                              β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Submit to on-chain  β”‚ β”‚ Route to internal backend:   β”‚ β”‚ Settle on chosen rail:   β”‚
    β”‚ facilitator for     β”‚ β”‚ β€’ stripe  β€’ paypal  β€’ card   β”‚ β”‚ β€’ x402 β†’ facilitator     β”‚
    β”‚ settlement          β”‚ β”‚ β€’ crypto (Viem ETH/ERC-20)   β”‚ β”‚ β€’ stripe/paypal/card     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β€’ crypto (tx reference)  β”‚
               β”‚                           β”‚                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β–Ό                           β–Ό                                β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
    β”‚ HTTP 200            β”‚ β”‚ Return AP2PaymentResult:     β”‚               β–Ό
    β”‚ + resource data     β”‚ β”‚ { mandate_id, status,        β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ + X-PAYMENT-RESPONSEβ”‚ β”‚   transaction_id, receipt }  β”‚ β”‚ Return MPPReceipt:       β”‚
    β”‚   (settlement proof)β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ { receipt_id, status,    β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚                 β”‚   rail_reference, sig }  β”‚
               β”‚                           β”‚                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚  Audit Log (SQLite  β”‚
                   β”‚  + Winston)         β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Quick Start

A quick start guide with Docker and Docker Compose.

Usage

Quick start (dry-run, no credentials needed):

# Build and start both services
DRY_RUN=true docker compose up --build -d

# Start everything (first run auto-configures OpenClaw + installs skill)
docker compose up -d

# Or explicitly run skill installation first
docker compose --profile setup run --rm install-skill
docker compose up -d

# Check the payment API health
curl http://localhost:3402/api/v1/health

# Run the demo via the CLI helper
DRY_RUN=true docker compose run --rm cli demo

# Run CLI commands
docker compose run --rm --profile cli cli demo --stub-mode success

# Quick dry-run test
DRY_RUN=true docker compose up -d

# Check logs
docker compose logs -f agentic-payments-bot

# View audit log
DRY_RUN=true docker compose run --rm cli audit --limit 30

# Store a key via CLI
DRY_RUN=true docker compose run --rm cli keys list

Production (with real credentials):

# Create a .env file with your secrets
cat > .env <<EOF
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=...
AWS_KMS_KEY_ID=arn:aws:kms:us-east-1:123456789012:key/...
LLM_PROVIDER=anthropic
LLM_API_KEY=sk-ant-...
OPENCLAW_GATEWAY_TOKEN=your-gateway-token
EOF

# Start
docker compose up --build -d

# Tail logs
docker compose logs -f agentic-payments-bot

# Stop
docker compose down

Pair OpenClaw with a messaging channel (e.g. Telegram):

# Run the OpenClaw CLI inside the running container
docker compose exec agentic-payments-bot openclaw pairing approve telegram

What this gives you

Container Service Port Description
agentic-payments-bot Payment Bot Web API (npm run web) 3402 REST API for payments, parsing, confirmations, audit
agentic-payments-bot OpenClaw Gateway (openclaw gateway) 18789 Agent gateway (Telegram, Slack, WhatsApp, etc.)
agentic-payments-bot OpenClaw Bridge (openclaw) 18790 Internal bridge for multi-channel routing
agentic-payments-bot CLI (on-demand) (npm run cli) β€” Runs agentic-payments-bot CLI commands against the shared SQLite DB

Both services share the same SQLite database and encrypted key store through Docker volumes [1]. The payment skill is auto-registered as an OpenClaw skill via the symlink into ~/.openclaw/skills/ [2], so the agent discovers it at startup through the standard skill loading mechanism.


Documentation

See the REFERENCE_README file for the full exhaustive comprehensive thorough documentation and details.


License

This project is licensed under the Apache 2.0 License. See the LICENSE-APACHE file for the details.


Built with πŸ€–πŸ’΅ for the Open Agent Skills Ecosystem and for the OpenClaw ecosystem.

Protocols: x402 Β· AP2 Β· MPP

About

πŸ€–πŸ’΅ Agentic Payment Service for Open Agent Skills Ecosystem.

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages