> ## 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.

# 取消支付（两张卡）

> 使用某张卡的交易 id，取消双卡支付中该卡的授权。

此请求取消通过[创建支付（两张卡）](https://docs.y.uno/zh-hans/reference/payments/create-payment-v2.md)创建的支付中一张已授权的卡。取消按卡进行：请发送来自 `payment_method.payment_methods[].transactions` 的该卡 `AUTHORIZE` 交易的 `id`。如需在一个请求中取消整笔支付，请使用[取消或退款支付（两张卡）](https://docs.y.uno/zh-hans/reference/payments/cancel-or-refund-a-payment-v2.md)。

响应为 `201`，支付采用 v2 结构。

> [!WARNING]
>
> 当支付处于 `REFUND_RETRY_IN_PROCESS` 或 `CANCEL_RETRY_IN_PROCESS` 状态时，取消会被拒绝。请参阅[使用两张卡支付](https://docs.y.uno/zh-hans/docs/payment-features/pay-with-two-cards.md#operations)。

此请求需要 `X-Idempotency-Key`。详情请参阅[身份验证](https://docs.y.uno/zh-hans/reference/getting-started/authentication.md#idempotency)。


## OpenAPI

````yaml openapi/zh-hans/payments/cancel-payment-v2.json POST /payments/{payment_id}/transactions/{transaction_id}/cancel
openapi: 3.1.0
info:
  title: payments-v2
  version: 2.0.0
servers:
  - url: https://api-sandbox.y.uno/v2
    description: Sandbox
  - url: https://api.y.uno/v2
    description: Production (US)
security:
  - sec0: []
    sec1: []
paths:
  /payments/{payment_id}/transactions/{transaction_id}/cancel:
    post:
      summary: 取消支付（两张卡）
      description: 使用该卡的 `AUTHORIZE` 交易 id，取消一张卡的授权。
      operationId: cancel-payment-v2
      parameters:
        - name: X-Idempotency-Key
          in: header
          required: true
          description: >-
            此请求的唯一键。每个 v2 支付请求都必须提供。结果不明确时，请使用相同的键重试。缺少该键时，请求会被拒绝并返回 `400
            INVALID_PARAMETERS`："The header 'x-idempotency-key' is required."
          schema:
            type: string
            format: uuid
        - name: payment_id
          in: path
          required: true
          description: '`POST /v2/payments` 返回的支付 `id`。'
          schema:
            type: string
            format: uuid
        - name: transaction_id
          in: path
          required: true
          description: 要操作的卡交易的 `id`，来自 `payment_method.payment_methods[].transactions[]`。
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - merchant_reference
              properties:
                description:
                  type: string
                  description: 取消的描述（MAX 255；MIN 3）
                reason:
                  type: string
                  description: >-
                    操作原因。可能的值为 `DUPLICATE`、`FRAUDULENT` 和
                    `REQUESTED_BY_CUSTOMER`。
                  enum:
                    - DUPLICATE
                    - FRAUDULENT
                    - REQUESTED_BY_CUSTOMER
                merchant_reference:
                  type: string
                  description: 由商户定义的支付交易标识（MAX 255；MIN 3）。
      responses:
        '201':
          description: 操作后的支付，采用 v2 结构
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentV2'
              examples:
                Card canceled:
                  value:
                    id: 7c1b6e2a-5f3d-4a8e-9b21-3e4f5a6b7c8d
                    account_id: 493e9374-510a-4201-9e09-de669d75f256
                    description: Order paid with two cards
                    country: BR
                    status: CANCELED
                    sub_status: CANCELED
                    merchant_order_id: order-10045
                    created_at: '2026-10-27T14:02:11.120Z'
                    updated_at: '2026-10-27T14:02:12.300Z'
                    split_payment_methods: true
                    payment_methods_count: 2
                    sdk_action_required: false
                    amount:
                      currency: BRL
                      value: 300
                    checkout:
                      session: null
                    payment_method:
                      capture: false
                      account_updater: false
                      payment_methods:
                        - sequence: 1
                          type: CARD
                          amount:
                            currency: BRL
                            value: 200
                          transactions:
                            - id: d2a4f6b8-1c3e-4a5b-8d7f-9e0a1b2c3d4e
                              type: AUTHORIZE
                              status: SUCCEEDED
                              category: CARD
                              amount: 200
                              provider_id: YUNO_TEST_PAYMENT_GATEWAY
                              response_code: SUCCEEDED
                              response_message: Transaction successful
                              reason: null
                              description: null
                              merchant_reference: null
                              three_d_secure_action_required: false
                              created_at: '2026-10-27T14:02:11.402Z'
                              updated_at: '2026-10-27T14:02:12.118Z'
                            - id: c7f9e1a3-6b8d-4f0a-9c2e-4d5e6f7a8b9c
                              type: CANCEL
                              status: SUCCEEDED
                              category: CARD
                              amount: 200
                              provider_id: YUNO_TEST_PAYMENT_GATEWAY
                              response_code: SUCCEEDED
                              response_message: Transaction successful
                              reason: null
                              description: null
                              merchant_reference: null
                              three_d_secure_action_required: false
                              created_at: '2026-10-27T14:02:11.402Z'
                              updated_at: '2026-10-27T14:02:12.118Z'
                        - sequence: 2
                          type: CARD
                          amount:
                            currency: BRL
                            value: 100
                          transactions:
                            - id: e3b5a7c9-2d4f-4b6c-9e8a-0f1b2c3d4e5f
                              type: AUTHORIZE
                              status: SUCCEEDED
                              category: CARD
                              amount: 100
                              provider_id: YUNO_TEST_PAYMENT_GATEWAY
                              response_code: SUCCEEDED
                              response_message: Transaction successful
                              reason: null
                              description: null
                              merchant_reference: null
                              three_d_secure_action_required: false
                              created_at: '2026-10-27T14:02:11.402Z'
                              updated_at: '2026-10-27T14:02:12.118Z'
                    customer_payer:
                      id: cfae0941-7234-427a-a739-ef4fce966c79
                      first_name: Ana
                      last_name: Souza
                      email: ana.souza@example.com
                    workflow: DIRECT
                    callback_url: https://merchant.example.com/checkout/return
                    metadata: []
        '400':
          description: >-
            无效请求。缺少幂等键或金额超过可操作的上限时返回 `INVALID_PARAMETERS`；卡无法执行该操作时返回
            `INVALID_STATUS`，例如卡有未结拒付时退款，或支付处于 `REFUND_RETRY_IN_PROCESS` 或
            `CANCEL_RETRY_IN_PROCESS` 时捕获或取消。
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  messages:
                    type: array
                    items:
                      type: string
              examples:
                Missing idempotency key:
                  value:
                    code: INVALID_PARAMETERS
                    messages:
                      - The header 'x-idempotency-key' is required.
        '401':
          description: 凭证无效
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  messages:
                    type: array
                    items:
                      type: string
              example:
                code: INVALID_CREDENTIALS
                messages:
                  - Invalid credentials
components:
  schemas:
    PaymentV2:
      type: object
      description: 由两张卡共同支付的支付。
      properties:
        id:
          type: string
          format: uuid
        account_id:
          type: string
          format: uuid
        description:
          type: string
        country:
          type: string
        status:
          type: string
          description: >-
            支付的汇总状态。参见[使用两张卡支付](/zh-hans/docs/payment-features/pay-with-two-cards#statuses)。
        sub_status:
          type: string
          description: >-
            汇总子状态，例如
            `APPROVED`、`AUTHORIZED`、`PARTIALLY_CAPTURED`、`PARTIALLY_REFUNDED`、`REFUND_RETRY_IN_PROCESS`
            或 `CANCEL_RETRY_IN_PROCESS`。
        merchant_order_id:
          type: string
        merchant_reference:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        split_payment_methods:
          type: boolean
          description: 由两张卡共同支付的支付为 `true`。
        payment_methods_count:
          type: integer
          description: 为该支付出资的卡数量：`2`。
        sdk_action_required:
          type: boolean
          description: 当 SDK 必须继续该支付时为 `true`，例如运行 3DS 验证。
        amount:
          type: object
          description: 支付总额。
          required:
            - currency
            - value
          properties:
            currency:
              type: string
              description: ISO 4217 货币代码（3 个字符）。
              example: BRL
            value:
              type: number
              description: 以主单位表示的金额（0.0001 的倍数）。
              example: 300
        checkout:
          type: object
          properties:
            session:
              type:
                - string
                - 'null'
        payment_method:
          type: object
          properties:
            capture:
              type: boolean
              description: 两张卡共用的捕获设置。
            account_updater:
              type:
                - boolean
                - 'null'
            payment_methods:
              type: array
              description: 每张卡一条记录。不提供单卡状态：请从各卡的 `transactions` 中读取其结果。
              minItems: 2
              maxItems: 2
              items:
                type: object
                properties:
                  sequence:
                    type: integer
                    description: 卡的位置：`1` 或 `2`。
                  type:
                    type: string
                    enum:
                      - CARD
                  amount:
                    type: object
                    description: 该卡支付的总额部分。
                    required:
                      - currency
                      - value
                    properties:
                      currency:
                        type: string
                        description: ISO 4217 货币代码（3 个字符）。
                        example: BRL
                      value:
                        type: number
                        description: 以主单位表示的金额（0.0001 的倍数）。
                        example: 300
                  payment_method_detail:
                    type: object
                    description: 卡详细信息，与 v1 支付对象一致。
                  payment_method_owner:
                    type: object
                    description: 持卡人，在请求中发送时返回。
                  transactions:
                    type: array
                    description: >-
                      该卡的交易。经过 3DS 的卡会显示 `THREE_D_SECURE`，随后是 `PURCHASE` 或
                      `AUTHORIZE`。
                    items:
                      type: object
                      description: 该卡的一笔交易。请从其交易中读取该卡的结果。
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: 交易 id。用于按交易执行的操作。
                        type:
                          type: string
                          description: >-
                            交易类型，例如
                            `THREE_D_SECURE`、`PURCHASE`、`AUTHORIZE`、`CAPTURE`、`CANCEL`
                            或 `REFUND`。
                        status:
                          type: string
                          description: >-
                            该交易的状态，例如 `SUCCEEDED`、`DECLINED`、`PENDING` 或
                            `ERROR`。
                        category:
                          type: string
                          example: CARD
                        amount:
                          type: number
                          description: 该交易的金额。
                        provider_id:
                          type: string
                          description: 处理该交易的服务提供商。
                        response_code:
                          type: string
                          description: 该交易的 Yuno 响应代码。
                        response_message:
                          type: string
                        reason:
                          type:
                            - string
                            - 'null'
                        description:
                          type:
                            - string
                            - 'null'
                        merchant_reference:
                          type:
                            - string
                            - 'null'
                        three_d_secure_action_required:
                          type:
                            - boolean
                            - 'null'
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type:
                            - string
                            - 'null'
                          format: date-time
        customer_payer:
          type: object
          description: 付款方，与请求中发送的一致。
        additional_data:
          type:
            - object
            - 'null'
        callback_url:
          type: string
        workflow:
          type: string
          enum:
            - DIRECT
            - REDIRECT
            - SDK_CHECKOUT
        metadata:
          type: array
          items:
            type: object
  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.