This episode explores the payment ecosystem for agents: the x402 extension with the HTTP 402 status code, the mandate and approval concepts, interop with UCP and AP2, and trust rails like Visa TAP and Mastercard Agent Pay.

Episode 18 took you to the performance level: tasks in the thousands per second with pooling, caching, load balancing, and gRPC. Now the question changes — no longer "how do we serve faster", but "should this agent be served at all". In the real world, services cost money, and agents that do work deserve to be paid.
Episode 19 introduces the commerce layer of the A2A ecosystem. We'll discuss the x402 extension that lets agents request payment via the HTTP 402 status code, the mandate and approval concepts that keep transaction authorization in check, then interop with UCP and AP2 as the big map of agentic commerce — including the trust rails from Visa and Mastercard that underpin trust behind the scenes.
Most HTTP codes are familiar: 200 success, 404 not found, 500 server error. There's one code that has sat idle since 1998: 402 Payment Required. It never had a standard meaning — until the x402 ecosystem gave it one: "this work can be done, but you have to pay first."
When an agent client sends a task to a paid remote agent, the remote agent doesn't simply refuse. It replies with status 402 and includes a payment request — a price description, denomination, receiver, and instructions on how to pay:
curl -s -o /dev/null -w "%{http_code}" -X POST \
https://agent-premium.example.com/ \
-d '{"jsonrpc":"2.0","id":1,"method":"tasks/send","params":{...}}'{
"payments": [
{
"id": "pay_abc123",
"description": "Analisis kredit 10 dokumen",
"amount": "250",
"currency": "usd",
"receiver": "https://wallet.agent-premium.example.com",
"network": "ethereum"
}
]
}The client reads this response, then decides: pay now, or decline. This shifts the agent interaction pattern from "everything is free" to valuable services with transparent pricing. The key point: x402 isn't a new currency — it's a layer of payment instructions on top of existing networks, so agents don't need to understand blockchain details to request payment.
The x402 extension runs on top of the A2A HTTP binding. The flow is like a sequential negotiation:
tasks/send to the remote agent.402 Payment Required and a payment request (as above).import httpx
async def send_paid_task(url: str, task: dict) -> dict:
async with httpx.AsyncClient() as client:
resp = await client.post(url, json={"task": task})
if resp.status_code != 402:
return resp.json()
payment_request = resp.json()["payments"][0]
proof = await settle_payment(payment_request)
final = await client.post(
url,
json={"task": task, "payment_proof": proof},
)
return final.json()Note two important things in this example. First, the task remains a single unit — only the payment proof is added, not a different task structure. Second, settle_payment can be anything: calling an agent wallet, requesting user approval, or executing a contract on a payment network. This flexibility is what makes x402 cross-domain.
If every transaction has to request full approval from the user, agents will stall. The solution has two keywords: mandate and approval.
class PaymentPolicy:
def __init__(self):
self.mandates = {
"agent-analisis": {"limit_daily": 50.0, "spent": 0.0},
}
async def authorize(self, payer: str, amount: float, receiver: str) -> str:
mandate = self.mandates.get(payer)
if mandate and mandate["spent"] + amount <= mandate["limit_daily"]:
mandate["spent"] += amount
return "approved-by-mandate"
return await self.request_approval(payer, amount, receiver)This pattern balances speed and control: routine transactions run without friction, while suspicious or large transactions still go through a human path. In real deployments, mandates live on the wallet or policy service side, not in the agent code — so financial decisions can be audited separately from agent logic.
x402 is a direct payment protocol between agents. On top of it, two initiatives shape agentic commerce more fully:
Both are complementary to A2A: A2A handles "how agents ask for work to be done", UCP handles "what the transaction value is", and AP2 handles "how that value moves from agent A's wallet to agent B's wallet". You can think of this stack like layers in an OSI network — each deals with its own problem and doesn't care about the layers beneath.
All the protocols above only mean something if there are trust rails — trusted pathways that guarantee money actually moves. This is where traditional payment institutions enter the agent world. Visa TAP (Tokenized Agent Payments) and Mastercard Agent Pay are two initiatives connecting agents to card payment networks:
agent:
name: "payment-processor-agent"
description: "Menerima task berbayar dengan x402"
capabilities:
- streaming
- push
payment:
methods:
- x402
- visa-tap
- mastercard-agent-pay
default_currency: usd
max_amount_per_task: 1000In a real ecosystem, the remote agent doesn't have to choose one — it can publish an agent card with a list of payment methods and let the client pick the most convenient path. This is the power of card-based design: capabilities are published, decisions are left to the counterparty.
Episode 19 places A2A in the context of the agent economy: HTTP 402 becomes the signal for "pay first, work later", the x402 extension wraps the payment proof into the task flow you already know, mandate and approval keep spending under control, and UCP plus AP2 provide the big map of agentic commerce — while the trust rails from Visa and Mastercard ensure value really moves in the real world.
Here's the core takeaway:
In episode 20 we turn from money matters to operational matters: policy-as-code and automation — deploying agents with CI/CD, testing multi-agent systems in the pipeline, contract testing for agent cards, and governance of versions and SLAs. See you there!