← 返回
未分类

Ucp Checkout Rest

Implement UCP Checkout over the REST binding — create, get, update, complete, and cancel checkout sessions with proper headers, idempotency, status transitio...
实现 UCP Checkout REST 绑定:创建、获取、更新、完成、取消结算会话,使用正确的请求头、幂等性及状态转换。
ichiorca ichiorca 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 239
下载
💾 0
安装
1
版本
#latest

概述

UCP Checkout — REST Binding

Before writing code

Fetch live spec: Web-search site:ucp.dev specification checkout-rest and fetch the page for the exact current endpoint shapes, required headers, request/response schemas, and status codes.

Also fetch https://ucp.dev/specification/reference/ for all data type definitions (Buyer, LineItem, Total, Message, etc.).

Conceptual Architecture

Five REST Operations

OperationHTTPPathIdempotent?
------------------------------------
Create CheckoutPOST/checkout-sessionsYes (via Idempotency-Key)
Get CheckoutGET/checkout-sessions/{id}Naturally
Update CheckoutPUT/checkout-sessions/{id}Yes (full replace)
Complete CheckoutPOST/checkout-sessions/{id}/completeYes (via Idempotency-Key)
Cancel CheckoutPOST/checkout-sessions/{id}/cancelYes (via Idempotency-Key)

Required Headers (every request)

  • UCP-Agent: Platform's profile URI in RFC 8941 structured field format — profile="https://..."
  • Idempotency-Key: UUID for mutating operations; Business caches 24+ hours
  • Request-Id: UUID for distributed tracing
  • Request-Signature: Cryptographic signature for request integrity verification
  • Content-Type: application/json

Status State Machine

incomplete → requires_escalation → ready_for_complete → complete_in_progress → completed
     |               |                    |                      |
     +---------------+--------------------+----------------------+--------→ canceled

The canceled state is reachable from any non-terminal state (incomplete, requires_escalation, ready_for_complete, complete_in_progress).

The agent's job is to drive the session from incomplete to ready_for_complete by resolving messages, then call complete.

Negotiation in Every Response

Every response includes a ucp object with the negotiated version and capabilities. The Business computes the intersection of its own capabilities with the Platform's profile, prunes orphaned extensions, and returns only what both sides support.

Error Handling Pattern

Responses include a messages array. Each message has:

  • type: error / warning / info
  • code: Machine-readable error code
  • content: Human-readable description
  • severity: recoverable / requires_buyer_input / requires_buyer_review (these are the 3 formal enum values; note: escalation appears in some spec sections but is NOT part of the formal severity enum — this is a spec inconsistency)
  • path: JSONPath pointing to the problematic field

Agent behavior by severity:

  • recoverable → Agent fixes automatically (e.g., update with missing address)
  • requires_buyer_input → Ask the human user
  • requires_buyer_review → Show totals/terms for human confirmation
  • escalation → Redirect to continue_url

Implementation Checklist

Business (merchant server):

  1. Parse UCP-Agent header and fetch platform profile for negotiation
  2. Validate Idempotency-Key — return cached response if duplicate
  3. Create checkout session with line items, compute totals
  4. Return negotiated ucp object + full session state + messages
  5. Handle Update by recalculating totals, re-validating, updating messages
  6. Handle Complete by processing payment credential, creating order
  7. Handle Cancel by cleaning up session
  8. Return proper HTTP status codes (201 Created, 200 OK, 400/409/429, etc.)

Platform (agent client):

  1. Discover Business profile at /.well-known/ucp
  2. Send UCP-Agent header with own profile URI
  3. Create checkout, inspect status and messages
  4. Loop: resolve messages → update checkout → re-check status
  5. When ready_for_complete: acquire payment credential, call complete
  6. Handle requires_escalation by surfacing continue_url to user

Monetary Values

All amounts are integers in minor currency units (e.g., $29.99 = 2999). Never use floating point.

TLS Requirement

All UCP REST endpoints MUST be served over HTTPS with minimum TLS 1.3.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-21 14:58 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Ucp Checkout A2a

ichiorca
在 A2A(代理转代理)绑定上实现 UCP 结账,使用代理卡片和结构化消息部件实现自主代理间商务。
★ 0 📥 309
dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 196 📥 67,884
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 75 📥 182,309