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

# 取消付款授权

此 endpoint 用于取消先前已授权的收款交易的授权，从而阻止资金被请款。如果您需要在结算前撤销授权，这会非常有用。


## OpenAPI

````yaml openapi/zh/localpayment.json PATCH /api/payin/capture/{externalId}/status
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/payin/capture/{externalId}/status:
    patch:
      summary: 取消收款授权
      operationId: cancel-authorization
      parameters:
        - name: Authorization
          in: header
          description: >-
            用于身份验证的 Bearer
            访问令牌。该令牌可从[获取访问令牌](/zh/reference/get-token)或[刷新访问令牌](/zh/reference/refresh-token)endpoint
            获取。
          required: true
          schema:
            type: string
        - name: externalId
          in: path
          description: 您这边会生成一个用于交易追溯的ID。该ID必须是唯一的，并且只接受字母数字字符和连字符（例如UUID4）。
          required: true
          schema:
            type: string
            pattern: '[a-zA-Z0-9\- ]+'
            examples:
              - 53025bf4-4c87-4b4f-8fea-b47004440f37
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  const: CANCELLED
                  description: 更改状态为`CANCELLED`。
              required:
                - status
            examples:
              200 - Cancelled:
                value:
                  status: CANCELLED
      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: 更多状态信息。
                x-examples:
                  Example 1:
                    externalId: '1648840917'
                    internalId: 39eb0371-3f21-488f-a779-913799e51406
                    status:
                      code: '905'
                      description: CANCELLED
                      detail: The authorization was cancelled
              examples:
                905 - The authorization was cancelled:
                  value:
                    externalId: '1648840917'
                    internalId: 39eb0371-3f21-488f-a779-913799e51406
                    status:
                      code: '905'
                      description: CANCELLED
                      detail: The authorization was cancelled
                400 - Invalid operation.:
                  value:
                    status:
                      code: '400'
                      description: ERROR
                      detail: Invalid operation
        '400':
          description: 错误的请求。
          content:
            application/json:
              schema:
                type: object
                properties:
                  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: 更多状态信息。
                x-examples:
                  Example 1:
                    status:
                      code: '400'
                      description: ERROR
                      detail: Status should be present and be a valid value
              examples:
                400 - Status should be present and be a valid value.:
                  value:
                    status:
                      code: '400'
                      description: ERROR
                      detail: Status should be present and be a valid value
        '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: 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: 更多状态信息。
                x-examples:
                  Example 1:
                    status:
                      code: '404'
                      description: ERROR
                      detail: Payin not found
              examples:
                404 - Payin not found.:
                  value:
                    status:
                      code: '404'
                      description: ERROR
                      detail: Payin not found
      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.