Card-Payment CLI Adapter
Let AI agents pay for APIs and services through visa-cli, a third-party card-payment CLI (third-party tool; not affiliated with or endorsed by Visa) — with per-agent budgets, atomic spending limits, and a full audit trail. Integration adapters for third-party APIs; no partnership or endorsement implied.
How It Works
Three steps from request to settled payment — fully automated for AI agents, fully auditable for compliance.
Agent Requests Payment
An AI agent invokes visacli.payment via MCP, or a developer calls POST /billing/invoices/{id}/pay.
Budget Reserved Atomically
The spending limit is checked and reserved under a database row lock. Two concurrent requests from the same agent can never exceed the daily budget.
Payment Settles
The payment executes via the card enrolled in the third-party CLI. An immutable ShouldBeStored event captures every state transition for audit.
What Agents Pay For
The adapter targets AI agents that need to purchase services autonomously.
API-Metered Services
Image generation, LLM inference, speech synthesis, translation — any pay-per-call API where the agent decides when and what to buy.
Datasets & Research
Purchase market data feeds, satellite imagery, academic papers, or proprietary datasets on behalf of research pipelines.
Developer Invoice Collection
Collect BaaS partner billing invoices ($99–$1,999/mo tiers) through the existing billing system with a single API call.
Core Capabilities
Six integrated services spanning agent payments, card enrollment, invoice collection, and operational tooling.
MCP Tools for AI Agents
visacli.payment executes payments; visacli.cards lists enrolled cards. Both registered in the MCP tool registry alongside x402 and Agent Protocol tools.
Atomic Spending Limits
Per-agent daily budgets and per-transaction caps enforced with lockForUpdate(). Concurrent requests from the same agent cannot exceed the budget.
Invoice Payment Gateway
Partner billing invoices collected via POST /billing/invoices/{'{id}'}/pay. Calls PartnerInvoice::markAsPaid() on success — fills the missing payment rail in BaaS.
Card Enrollment Bridge
Enrolled cards sync to the CardIssuance domain via VisaCliCardEnrolled events. DDD boundary maintained — unified card view, separate bounded contexts.
Event-Sourced Audit Trail
Five domain events (PaymentInitiated, Completed, Failed, CardEnrolled, CardRemoved) stored immutably via Spatie Event Sourcing.
Artisan CLI Commands
visa:status for diagnostics, visa:enroll for card enrollment, visa:pay for manual payments — with formatted output and confirmation prompts.
Domain Architecture
Separate bounded context with demo and production drivers. No coupling to CardIssuance or x402.
Domain Structure
app/Domain/VisaCli/ Contracts/ VisaCliClientInterface VisaCliPaymentGatewayInterface Services/ DemoVisaCliClient (cache-based mock) VisaCliProcessClient (real binary) VisaCliPaymentService VisaCliSpendingLimitService VisaCliCardEnrollmentService VisaCliPaymentGatewayService Models/ VisaCliPayment VisaCliEnrolledCard VisaCliSpendingLimit Events/ PaymentInitiated, Completed, Failed CardEnrolled, CardRemoved
Security Hardening
Payment URLs validated against blocked internal addresses (localhost, 169.254.x, 10.x, 192.168.x). Only http/https allowed.
Check-and-reserve under lockForUpdate(). Concurrent requests cannot exceed budget even under race conditions.
SHA-256 signature verification with 5-minute timestamp window. Unsigned webhooks rejected in production.
GitHub tokens and credentials automatically stripped from process error output before logging.
Quick Start
Three commands from zero to payment.
Enable in .env
VISACLI_ENABLED=true
VISACLI_DRIVER=demo # or "process" for real visa-cli binary
VISACLI_DAILY_LIMIT=10000 # $100.00 daily limit (cents)
VISACLI_PER_TX_LIMIT=1000 # $10.00 per transaction (cents)
Verify the integration
$ php artisan visa:status
Visa CLI Status
+---------------+-----------+
| Property | Value |
+---------------+-----------+
| Initialized | Yes |
| Driver | demo |
| Enrolled Cards| 0 |
+---------------+-----------+
Execute a payment
$ php artisan visa:pay https://api.example.com/generate --amount=500 --agent=image-bot
Processing payment...
URL: https://api.example.com/generate
Amount: $5.00
Agent: image-bot
Payment completed!
+------------+------------------------------+
| Reference | visa_pay_demo_a1b2c3d4e5f6 |
| Status | completed |
| Amount | $5.00 |
+------------+------------------------------+
Card-payment CLI vs x402 Protocol
Two payment rails, different strengths. Use both in the same platform.
| Card-payment CLI | x402 Protocol | |
|---|---|---|
| Payment method | Card (via third-party CLI) | USDC on-chain |
| Settlement | Card network (1-2 days) | Instant on-chain |
| Best for | Traditional APIs, SaaS | Crypto-native APIs |
| Auth model | GitHub + enrolled card | Wallet signature |
| Agent spending limits | ||
| MCP tool | visacli.payment | x402.payment |
Start building with the card-payment CLI adapter
Enable the demo driver and run visa:status in under a minute.
Related: Zelta CLI · Machine Payments