Sandbox
v6.12.0 · 46th Domain Module

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.

2 MCP Tools
3 Artisan Commands
52 Tests Passing
Demo & Process Drivers

How It Works

Three steps from request to settled payment — fully automated for AI agents, fully auditable for compliance.

1

Agent Requests Payment

An AI agent invokes visacli.payment via MCP, or a developer calls POST /billing/invoices/{id}/pay.

2

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.

3

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

SSRF Prevention

Payment URLs validated against blocked internal addresses (localhost, 169.254.x, 10.x, 192.168.x). Only http/https allowed.

Atomic Spending

Check-and-reserve under lockForUpdate(). Concurrent requests cannot exceed budget even under race conditions.

Webhook HMAC + Replay Protection

SHA-256 signature verification with 5-minute timestamp window. Unsigned webhooks rejected in production.

Log Redaction

GitHub tokens and credentials automatically stripped from process error output before logging.

Quick Start

Three commands from zero to payment.

1

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)
2

Verify the integration

$ php artisan visa:status

Visa CLI Status
+---------------+-----------+
| Property      | Value     |
+---------------+-----------+
| Initialized   | Yes       |
| Driver        | demo      |
| Enrolled Cards| 0         |
+---------------+-----------+
3

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 methodCard (via third-party CLI)USDC on-chain
SettlementCard network (1-2 days)Instant on-chain
Best forTraditional APIs, SaaSCrypto-native APIs
Auth modelGitHub + enrolled cardWallet signature
Agent spending limits
MCP toolvisacli.paymentx402.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