> ## Documentation Index
> Fetch the complete documentation index at: https://docs.y.uno/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 更新结账会话

> 更新现有结账会话的字段，仅修改您发送的值

使用此 endpoint 更新现有的结账会话。只有您发送的字段会被更新。

> [!NOTE]
>
> 更新结账会话不会延长其有效期。会话仍会在创建后 2.5 小时过期（在 sandbox 中为 3.5 小时）。如果会话已经过期，此 endpoint 会返回 `CHECKOUT_SESSION_EXPIRED_TIME`，您必须创建新的结账会话。


## OpenAPI

````yaml openapi/zh-hans/checkout-sessions/update-checkout-session.json PATCH /checkout/sessions/{checkout_session}
openapi: 3.1.0
info:
  title: checkout-api
  version: 1.0.2
servers:
  - url: https://api-sandbox.y.uno/v1
    description: Sandbox
  - url: https://api.y.uno/v1
    description: Production (US)
security:
  - sec0: []
    sec1: []
paths:
  /checkout/sessions/{checkout_session}:
    patch:
      summary: 更新结账会话
      operationId: update-checkout-session
      parameters:
        - in: path
          name: checkout_session
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - merchant_order_id
                - payment_description
                - country
                - account_id
              properties:
                customer_id:
                  type: string
                  description: >-
                    客户的唯一标识符，通过 [Create
                    Customer](https://docs.y.uno/zh-hans/reference/customers/create-customer)
                    endpoint 创建（UUID，36 个字符）。
                merchant_order_id:
                  type: string
                  description: 客户订单的唯一标识符（MAX 255；MIN 3）。
                payment_description:
                  type: string
                  description: 支付的描述（MAX 255；MIN 3）。
                callback_url:
                  type: string
                  description: 客户完成购买后我们将其重定向到的 URL。对于有重定向的替代支付方式必填。（MAX 526; MIN 3）
                country:
                  type: string
                  description: >-
                    必须处理该交易的国家（MAX 2；MIN 2；[ISO
                    3166-1](/zh-hans/reference/country-reference)）。
                account_id:
                  type: string
                  description: >-
                    账户的唯一标识符。您可以在 [Yuno Dashboard](https://dashboard.y.uno/)
                    上找到此信息（UUID，36 个字符）。
                  default: '{{account_id}}'
                amount:
                  type: object
                  description: 指定支付金额对象，包含金额值和币种。
                  required:
                    - currency
                    - value
                  properties:
                    currency:
                      type: string
                      description: >-
                        用于支付的币种。有关币种代码的完整列表，请参阅[国家参考](/zh-hans/reference/country-reference)（MAX
                        3；MIN 3；ISO 4217）。
                    value:
                      type: number
                      description: 支付金额（0.0001 的倍数）。
                      format: float
                alternative_amount:
                  type: object
                  description: 交易金额的替代货币表示。
                  required:
                    - currency
                    - value
                  properties:
                    currency:
                      type: string
                      description: >-
                        替代货币代码。有关货币代码的完整列表，请参阅 [Country
                        reference](/zh-hans/reference/country-reference)（MAX 3;
                        MIN 3; ISO 4217）。
                      nullable: true
                    value:
                      type: number
                      description: 备选金额值（0.0001 的倍数）。
                      format: float
                metadata:
                  type: array
                  description: 指定元数据对象列表。您最多可添加 120 个元数据对象。
                  items:
                    properties:
                      key:
                        type: string
                        description: 元数据键（MAX 48）
                      value:
                        type: string
                        description: 元数据键值（MAX 512）
                    required:
                      - key
                      - value
                    type: object
                workflow:
                  type: string
                  description: 结账工作流类型。
                  enum:
                    - SDK_CHECKOUT
                    - CHECKOUT
                    - SDK_SEAMLESS
                installments:
                  type: object
                  description: >-
                    用于发送在 Yuno
                    中创建的分期付款计划的对象，以便向您的客户展示并供其选择。此可选字段用于会话中需要使用特定分期付款计划的情况。如果未发送，我们将针对每种场景显示为该账户创建的分期付款计划（如有）。
                  properties:
                    plan_id:
                      type: string
                      description: 在 Yuno 中创建的分期付款计划的计划 ID
                    plan:
                      type: array
                      description: >-
                        在 checkout_session
                        中向客户展示的分期付款。此可选结构用于会话中需要使用特定分期付款计划、但尚未为其创建分期付款计划的情况。如果未发送，我们将针对每种场景显示为该账户创建的分期付款计划（如有）。
                      items:
                        properties:
                          installment:
                            type: integer
                            description: 购物者可选择的按月分期付款期数
                            format: int32
                          rate:
                            type: number
                            description: >-
                              使用分期付款后，支付服务提供商对交易最终金额应用的费率。该值应以乘数形式输入，而不是百分比。例如，要应用
                              20% 的费率，请输入 `1.20` 而不是 `20`。
                            format: float
                        required:
                          - installment
                          - rate
                        type: object
            examples:
              Update checkout session:
                value:
                  country: BR
                  amount:
                    currency: ARS
                  alternative_amount:
                    currency: ARS
                  merchant_order_id: '007'
                  payment_description: Payment Test
                  account_id: '{{account_id}}'
                summary: Update checkout session
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Success:
                  value:
                    merchant_order_id: '007'
                    checkout_session: c67ce158-6053-4661-a1de-aed5c945b935
                    country: BR
                    payment_description: Payment Test
                    callback_url: null
                    amount:
                      currency: ARS
                      value: 100
                    created_at: '2025-11-14T00:43:22.719648Z'
                    metadata: null
                    workflow: SDK_CHECKOUT
                    installments:
                      plan_id: null
                      plan: null
                    used: false
                    customer_id: 5e7baf7d-88d5-47c4-8baf-93354d5e195e
                    recurring_payment:
                      description: Monthly subscription
                      management_url: https://example.com/manage
                      billing_agreement: BA-123
                      regular_billing:
                        label: Monthly
                        amount: 9.99
                        interval_unit: month
                        interval_count: 1
                      trial_billing:
                        label: Free trial
                        amount: 0
                        interval_unit: month
                        interval_count: 1
                    checkout_id: fd9b15a0-92a4-4e2c-8e4c-27764a1aa43e
                  summary: Success
              schema:
                type: object
                properties:
                  merchant_order_id:
                    type: string
                    example: '007'
                  checkout_session:
                    type: string
                    example: c67ce158-6053-4661-a1de-aed5c945b935
                  country:
                    type: string
                    example: BR
                  payment_description:
                    type: string
                    example: Payment Test
                  callback_url: {}
                  amount:
                    type: object
                    properties:
                      currency:
                        type: string
                        example: ARS
                      value:
                        type: integer
                        example: 100
                        default: 0
                  created_at:
                    type: string
                    example: '2025-11-14T00:43:22.719648Z'
                  metadata: {}
                  workflow:
                    type: string
                    example: SDK_CHECKOUT
                  installments:
                    type: object
                    properties:
                      plan_id: {}
                      plan: {}
                  used:
                    type: boolean
                    example: false
                    default: true
                  customer_id:
                    type: string
                    example: 5e7baf7d-88d5-47c4-8baf-93354d5e195e
                    description: 客户 ID。
                  recurring_payment:
                    type: object
                    properties:
                      description:
                        type: string
                        example: Monthly subscription
                      management_url:
                        type: string
                        example: https://example.com/manage
                      billing_agreement:
                        type: string
                        example: BA-123
                      regular_billing:
                        type: object
                        properties:
                          label:
                            type: string
                            example: Monthly
                          amount:
                            type: number
                            example: 9.99
                          interval_unit:
                            type: string
                            example: month
                          interval_count:
                            type: integer
                            example: 1
                      trial_billing:
                        type: object
                        properties:
                          label:
                            type: string
                            example: Free trial
                          amount:
                            type: number
                            example: 0
                          interval_unit:
                            type: string
                            example: month
                          interval_count:
                            type: integer
                            example: 1
                    description: 定期支付。
                  checkout_id:
                    type: string
                    example: fd9b15a0-92a4-4e2c-8e4c-27764a1aa43e
                    description: Checkout ID。
        '400':
          description: '400'
          content:
            application/json:
              examples:
                Bad Request:
                  value:
                    code: INVALID_REQUEST
                    messages:
                      - Invalid request
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: INVALID_REQUEST
                  messages:
                    type: array
                    items:
                      type: string
                      example: Invalid request
        '401':
          description: '401'
          content:
            application/json:
              examples:
                Unauthorized:
                  value:
                    code: INVALID_CREDENTIALS
                    messages:
                      - Invalid credentials
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: INVALID_CREDENTIALS
                  messages:
                    type: array
                    items:
                      type: string
                      example: Invalid credentials
        '403':
          description: '403'
          content:
            application/json:
              examples:
                Forbidden:
                  value:
                    code: AUTHORIZATION_REQUIRED
                    messages:
                      - The merchant has no authorization to use this API.
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: AUTHORIZATION_REQUIRED
                  messages:
                    type: array
                    items:
                      type: string
                      example: The merchant has no authorization to use this API.
      deprecated: false
components:
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: public-api-key
      x-default: <Your public-api-key>
    sec1:
      type: apiKey
      in: header
      name: private-secret-key
      x-default: <Your private-secret-key>

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.