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

# 取消付款

取消付款以阻止资金被转出。可用于停止因错误创建或需要更正的交易。

> **注意**
>
> 您只能取消状态为 **Locked** 或 **On Hold** 的付款。有关状态转换的详细信息，请参阅[付款概述](https://docs.localpayment.com/zh/reference/create-a-payout.md)文档。

此接口可确保资金不会发送给错误的收款人或以错误的金额发送，从而保护您的交易。


## OpenAPI

````yaml openapi/zh/localpayment.json PATCH /api/payout/cancel
openapi: 3.1.0
info:
  version: '1.0'
  title: Localpayment
  contact:
    name: Support
    url: mailto:support@localpayment.com
servers:
  - url: https://api.stage.localpayment.com
    description: Stage
security:
  - token: []
paths:
  /api/payout/cancel:
    patch:
      summary: 取消付款（Payout）
      operationId: void-a-payout
      parameters:
        - name: Authorization
          in: header
          description: >-
            用于身份验证的 Bearer
            访问令牌。该令牌可从[获取访问令牌](/zh/reference/get-token)或[刷新访问令牌](/zh/reference/refresh-token)endpoint
            获取。
          required: true
          schema:
            type: string
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              type: object
              properties:
                externalId:
                  type: string
                  description: 要作废的交易 ID。
              required:
                - externalId
              x-examples:
                Example 1:
                  externalId: '1736488554'
            examples:
              Void a payout:
                value:
                  externalId: '1736488554'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  externalId:
                    type: string
                    description: 系统生成的唯一标识符，用于跟踪交易（包含字母、数字和连字符）。我们建议使用 UUID4 以确保唯一性。
                  internalId:
                    type: string
                    description: Localpayment交易标识符。
                  status:
                    type: object
                    title: 状态
                    description: 操作状态。
                    properties:
                      code:
                        type: string
                        description: '[状态码](/zh/reference/transaction-status-error-codes)。'
                      description:
                        type: string
                        description: '[状态描述](/zh/reference/transaction-status-error-codes)。'
                      detail:
                        type: string
                        description: 更多状态信息。
                required:
                  - externalId
                  - internalId
                  - status
                x-examples:
                  Example 1:
                    externalId: '1736488510'
                    internalId: 3d36811d-1c02-41ea-a576-68df62c4603a
                    status:
                      code: '900'
                      description: Cancelled
                      detail: The payout was cancelled
              examples:
                900 - Cancelled:
                  value:
                    externalId: '1736488510'
                    internalId: 3d36811d-1c02-41ea-a576-68df62c4603a
                    status:
                      code: '900'
                      description: Cancelled
                      detail: The payout was cancelled
        '401':
          description: 未经授权。
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: 回复的补充信息。
                  code:
                    type: string
                    description: 状态码。
                  messages:
                    type: array
                    description: 消息列表。
                    items:
                      type: object
                      properties:
                        token_class:
                          type: string
                          description: Token 类。
                        token_type:
                          type: string
                          description: 令牌类型。
                        message:
                          type: string
                          description: 包含补充信息的消息。
                x-examples:
                  Example 1:
                    detail: Given token not valid for any token type
                    code: token_not_valid
                    messages:
                      - token_class: AccessToken
                        token_type: access
                        message: Token is invalid or expired
              examples:
                401 - Token is invalid or expired:
                  value:
                    detail: Given token not valid for any token type
                    code: token_not_valid
                    messages:
                      - token_class: AccessToken
                        token_type: access
                        message: Token is invalid or expired
        '404':
          description: 未找到
          content:
            application/json:
              schema:
                type: object
                properties:
                  Status:
                    type: integer
                    description: 状态码。
                  Message:
                    type: string
                    description: 包含补充信息的消息。
                  TraceId:
                    type: string
                    description: 跟踪标识符。
                required:
                  - Status
                  - Message
                  - TraceId
                x-examples:
                  Example 1:
                    Status: 404
                    Message: This transacion does not exists.
                    TraceId: d11cea70-7f14-4f11-b66e-13f5f56c2e56
              examples:
                404 - Transaction does not exists:
                  value:
                    Status: 404
                    Message: This transacion does not exists.
                    TraceId: dae2d1cb-7e9e-48a5-8530-980f38b31712
      security:
        - token: []
      servers:
        - url: https://api.stage.localpayment.com
          description: Stage
components:
  securitySchemes:
    token:
      type: http
      scheme: bearer

````

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