Ucp checkout session
Skill fxp/agentic-commerce-skills/skills/03-checkout/ucp-checkout-session
Drive a UCP checkout session over its real REST endpoints — create, get, update (PUT, full-replace), complete, and cancel a /checkout-sessions resource. Covers cart management (line_items), buyer, totals, messages, and the order returned on completion. Use when a commerce agent turns discovered products into a placed order on a UCP merchant. This is the dev.ucp.shopping.checkout capability.From its SKILL.md
npx -y skills add fxp/agentic-commerce-skills --skill ucp-checkout-sessionAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
6.9 KB, ~1.9k tokens by cl100k_base, as published. Nobody here has run it
UCP Checkout Session
中文摘要:用 UCP 真实 REST 端点驱动结算会话——create / get / update(PUT,整体替换)/ complete / cancel。购物车就是 session 里的
line_items(UCP 没有独立 cart 能力)。包含 buyer、totals、messages,以及完成时返回的 order。对应能力dev.ucp.shopping.checkout。
When to use / 何时使用
- You have
item.ids from discovery and need to build + complete a purchase. - The user is iterating on quantities/items — that's editing
line_itemson the session. - You need authoritative totals (tax, fulfillment, discount) and to place the order.
Cart = the session. Core UCP has no separate cart object; the cart is the
line_itemsarray of a checkout session. 购物车即 session 的line_items。
UCP mapping / UCP 映射
Capability dev.ucp.shopping.checkout. Base URL = ucp.services["dev.ucp.shopping"].endpoint
from the merchant's /.well-known/ucp. Five real endpoints:
| Operation | Method | Path |
|---|---|---|
| Create | POST | /checkout-sessions |
| Get | GET | /checkout-sessions/{id} |
| Update | PUT | /checkout-sessions/{id} |
| Complete | POST | /checkout-sessions/{id}/complete |
| Cancel | POST | /checkout-sessions/{id}/cancel |
PUT replaces the entire session. You must resend every field you want to keep — it is not a partial PATCH. PUT 是整体替换,需带上所有要保留的字段。
Required headers / 必需头部
UCP-Agent: profile="https://platform.example/.well-known/ucp"
Idempotency-Key: <uuid> # on POST/PUT state changes — prevents double orders
Request-Id: <uuid>
Content-Type: application/json
Accept: application/json
# auth (one of): Authorization: Bearer {token} | X-API-Key: {key}
# | HTTP Message Signatures (RFC 9421): Signature, Signature-Input, Content-Digest
Request & response fields / 请求与响应字段 (verbatim)
Create/Update request body:
{
"line_items": [ { "id": "li_1", "item": { "id": "sku_8821" }, "quantity": 2 } ],
"buyer": { "first_name": "Ada", "last_name": "L", "email": "[email protected]", "phone_number": "+49…" },
"fulfillment": { "methods": [ /* see ucp-fulfillment skill */ ] },
"payment": { "instruments": [ /* see ap2-payment-mandate skill */ ] },
"signals": { /* provided on complete */ }
}
Response (checkout session):
{
"ucp": { "version": "2026-04-08", "capabilities": { }, "payment_handlers": { }, "status": "success" },
"id": "cs_01H…",
"status": "ready_for_complete", // incomplete | ready_for_complete | completed | canceled | requires_escalation
"currency": "EUR",
"messages": [
{ "type": "error", "code": "buyer.email.missing", "path": "$.buyer.email",
"content": "Email required", "severity": "recoverable" } // severity: recoverable | unrecoverable
],
"line_items": [
{ "id": "li_1", "item": { "id": "sku_8821", "title": "Trail Runner GTX", "price": 11900 },
"quantity": 2, "totals": [ { "type": "subtotal", "amount": 23800 } ] }
],
"totals": [ // type: subtotal | tax | fulfillment | fee | discount | total
{ "type": "subtotal", "display_text": "Subtotal", "amount": 23800 },
{ "type": "fulfillment", "display_text": "Shipping", "amount": 0 },
{ "type": "tax", "display_text": "Tax", "amount": 4522 },
{ "type": "total", "display_text": "Total", "amount": 28322 }
],
"fulfillment": { "methods": [ ] },
"payment": { "instruments": [ ] },
"links": [ ],
"continue_url": "https://merchant.example/checkout/cs_01H…",
"order": { "id": "ord_77Q…", "label": "#1042", "permalink_url": "https://merchant.example/orders/ord_77Q…" }
}
All money amount/price are integers in the currency's minor units. 金额均为最小货币单位整数。
Workflow / 工作流
POST /checkout-sessionswithline_items→ captureid. Server may re-validate inventory and returnmessages(severity: recoverable|unrecoverable).PUT /checkout-sessions/{id}to setbuyer,fulfillment(address + selected option), apply discounts → server returns authoritativetotals. Resend all fields (full replace).- Drive
statustowardready_for_complete; resolve everyrecoverablemessage. Ifrequires_escalation, hand back to the user/UI — it can't be resolved via API. - Show the
total(lasttotals[type=total].amount) and get explicit confirmation. POST /checkout-sessions/{id}/completewithpayment+signalsand anIdempotency-Key. Build the AP2 payment proof first — seeap2-payment-mandate.- On success,
status: completed+order { id, label, permalink_url }→ hand toucp-order-management. POST /checkout-sessions/{id}/cancelto abandon.
Edge cases & failure modes / 边界与失败
- PUT drops fields → forgetting to resend a field deletes it; always send the full object.
- Total changed before complete → re-confirm; an AP2 mandate is bound to a specific amount.
requires_escalation→ needs buyer input outside the API; escalate, don't loop.- Duplicate complete → same
Idempotency-Keyreturns the same order, never double-charges. unrecoverablemessage → stop; the session can't reachready_for_complete.- Inventory lost at complete → server rejects; surface the line, re-cart.
Worked example / 示例
2 × sku_8821, ship-to DE, Acme account linked.
POST /checkout-sessions {line_items:[{item:{id:"sku_8821"},quantity:2}]}→cs_01H…,status:incomplete.PUT /checkout-sessions/cs_01H…with full body incl.buyer, selected fulfillment option,Authorization: Bearer …→totals: subtotal 23800 + fulfillment 0 + tax 4522 = total 28322 EUR,status:ready_for_complete.- Show €283.22 → user confirms → build PaymentMandate bound to 28322.
POST /checkout-sessions/cs_01H…/complete(+Idempotency-Key) →status:completed,order.id=ord_77Q….
References / 参考
- UCP HTTP/REST binding: https://ucp.dev/specification/checkout-rest/
- Native checkout guide: https://developers.google.com/merchant/ucp/guides/checkout/native
- Schemas: https://ucp.dev/schemas/ · Payment proof:
ap2-payment-mandate
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.