x402 付費 API 的回執:只確認已付款卻沒有金額,不算回執
A receipt that says paid but names no amount is not a receipt
一名 x402 資源伺服器營運者發現,28 項付費 AI 任務中只有 1 項出現在發現目錄,因為只有一次結算經由會寫入目錄的 facilitator 完成。成功訊號若沒有金額、端點和決策版本,索引器便無法判斷它對應哪項請求。28 筆款項均已到帳,失效的是證據鏈。
I run a small x402 resource server with 28 paid AI tasks. Last week I looked at the discovery catalog that lists paid endpoints and found exactly one of my 28 tasks there.
The first explanation I reached for was metadata. All 28 endpoints validate against the facilitator's schema; all 28 carry the discovery extension in the right place. So the metadata was not the difference. The difference was who reported success.
What actually happened
Twenty-eight tasks were paid. Only one settle went through the facilitator that writes discovery rows. The rest delivered the money through a different path. From the caller's point of view every one of those requests ended the same way: Success true, resource served.
But a success event that carries no amount, no endpoint, and no decision version is not a receipt. It is a confirmation that something happened. The downstream indexer could not tell which request it belonged to, so it wrote nothing.
This is the same shape as the indeterminate-write problem in payment retries: attempt 0 is accepted but the response is lost; the caller retries with the same signed authorization; the facilitator answers "already settled" without enough context to show that this is a different request at a different price. The caller reads it as confirmation of the new request too.
What changed in the way I think about it
Bind the idempotency key to the intent, not just the authorization. An authorization key proves same intent to pay; it does not prove same amount, same resource, same quote version. Include the request hash. If the hash differs on retry, that is a re-quote, not a replay.
Persist the outcome before returning. A lost response then becomes an idempotent read later, not another write against a busy channel.
Make the receipt carry the observation: amount, endpoint, decision version, transaction identity. A conclusion that does not carry what it rests on can only be trusted; a conclusion that does can be checked.
The part that surprised me
The money arrived in all 28 cases. Nothing was stolen, nothing double-charged. The only thing that failed was the evidence chain, and that was enough to make the work invisible to every consumer that discovers endpoints rather than knowing them in advance.
If you build paid APIs, the catalog is not a marketing afterthought. It is a consumer that trusts your success signal more than it trusts your documentation. Make that signal self-describing.
I'm Redzad Bakalovic (Workflow Alpha). I build x402 micro-services and n8n automations, and I write about the failure modes that only show up once real money moves.
來源:DEV Community · dev.to