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

# Cancel Payment

A payment with a **PENDING** status due to an **AUTHORIZE** transaction status can be canceled before it is completed if the payment is no longer required. Sending a cancel request will update the payment status to **CANCELLED**.

<Warning>
  **3DS Payments**

  Payments in a **PENDING** status due to 3DS authentication cannot be canceled. These payments are in a temporary state awaiting user authentication. The payment status will automatically update to either **FRAUD VERIFIED** or **CANCELLED** based on the outcome of the authentication process.
</Warning>

<Note>
  **Alternative Payment Methods**

  Alternative payment methods such as PIX also support payment cancellation with a PENDING status. Reach out to your technical account manager for more information.
</Note>

If you need a receipt for the canceled transaction, you can retrieve it after it has been created. To do this, use the [Retrieve Payment by ID](/reference/retrieve-payment-by-id) endpoint and check the `receipt_url` field in the `payment.transaction` object. See [The Payment Object](/reference/the-payment-object) for `receipt`, `receipt_url`, and `receipt_language`.

To use this endpoint, you have to provide an `X-Idempotency-Key` in your request. Check the [Authentication](/reference/authentication#idempotency) page for more information.


## OpenAPI

````yaml openapi/payments/cancel-payment.json POST /payments/{payment_id}/transactions/{transaction_id}/cancel
openapi: 3.1.0
info:
  title: payment-api-refundcancel-payment
  version: 1.0.2
servers:
  - url: https://api-sandbox.y.uno/v1
security:
  - sec0: []
    sec1: []
    sec2: []
paths:
  /payments/{payment_id}/transactions/{transaction_id}/cancel:
    post:
      summary: Cancel Payment
      operationId: cancel-payment
      parameters:
        - name: payment_id
          in: path
          description: The unique identifier of the payment (UUID, 36 chars).
          schema:
            type: string
          required: true
        - name: transaction_id
          in: path
          description: The unique identifier of the transaction (UUID, 36 chars).
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - merchant_reference
              properties:
                description:
                  type: string
                  description: Description of the cancellation.(MAX 255; MIN 3)
                reason:
                  type: string
                  description: >-
                    Reason for the cancellation. Values can be `DUPLICATE`,
                    `FRAUDULENT`, and `REQUESTED_BY_CUSTOMER`.
                  enum:
                    - DUPLICATE
                    - FRAUDULENT
                    - REQUESTED_BY_CUSTOMER
                merchant_reference:
                  type: string
                  description: >-
                    Identification of the payment transaction defined by the
                    merchant (MAX 255; MIN 3).
                response_additional_data:
                  type: object
                  description: >-
                    Specifies additional data for required the transaction
                    response
                  properties:
                    receipt:
                      type: boolean
                      description: >-
                        Indicates if a receipt is necessary for the transaction
                        response
                    receipt_language:
                      type: string
                      description: Indicates the language of the receipt to be generated
                      enum:
                        - ES
                        - EN
                        - PT
                    transactions_history:
                      type: boolean
                      description: >-
                        When true, includes the transactions history in the
                        response
                    raw_response:
                      type: boolean
                      description: >-
                        When true, includes the provider raw response in the
                        output
            examples:
              Request Example:
                value:
                  description: Duplicate
                  reason: REQUESTED_BY_CUSTOMER
                  merchant_reference: AAB01-432245
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Result:
                  value:
                    id: 438bea6c-9061-4416-b824-469c3c05868d
                    type: CANCEL
                    status: SUCCEEDED
                    category: CARD
                    amount:
                      captured: 0
                      currency: USD
                      currency_conversion: null
                      refunded: 0
                      value: 30000
                    merchant_reference: ''
                    created_at: '2024-06-06T14:03:08.384014Z'
                    updated_at: '2024-06-06T14:03:08.453617Z'
                    provider_data:
                      id: YUNO_TEST_PAYMENT_GW
                      transaction_id: ''
                      account_id: ''
                      status: SUCCEEDED
                      sub_status: ''
                      status_detail: SUCCEEDED
                      response_message: null
                      response_code: SUCCEEDED
                      raw_response:
                        message: provider response
                      third_party_transaction_id: null
                      third_party_account_id: null
                      iso8583_response_code: '00'
                      iso8583_response_message: Approved or completed successfully
                    response_code: SUCCEEDED
                    response_message: Transaction successful
                    payment:
                      id: 2d6f75c1-c4bc-4d2d-80ec-0af4d12c85da
                      account_id: ''
                      description: Test
                      country: US
                      status: CANCELED
                      sub_status: CANCELED
                      merchant_order_id: '0000023'
                      created_at: '2024-06-06T14:01:34.286228Z'
                      updated_at: '2024-06-06T14:03:08.484781Z'
                      amount:
                        captured: 0
                        currency: USD
                        currency_conversion: null
                        refunded: 0
                        value: 30000
                      split_marketplace: []
                    customer_payer: null
                    simplified_mode: false
                    receipt: false
                    receipt_url: null
                    receipt_language: null
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: 438bea6c-9061-4416-b824-469c3c05868d
                  type:
                    type: string
                    example: CANCEL
                  status:
                    type: string
                    example: SUCCEEDED
                  category:
                    type: string
                    example: CARD
                  amount:
                    type: object
                    properties:
                      captured:
                        type: integer
                        example: 0
                        default: 0
                      currency:
                        type: string
                        example: USD
                      currency_conversion: {}
                      refunded:
                        type: integer
                        example: 0
                        default: 0
                      value:
                        type: integer
                        example: 30000
                        default: 0
                  merchant_reference:
                    type: string
                    example: ''
                  created_at:
                    type: string
                    example: '2024-06-06T14:03:08.384014Z'
                  updated_at:
                    type: string
                    example: '2024-06-06T14:03:08.453617Z'
                  provider_data:
                    type: object
                    properties:
                      id:
                        type: string
                        example: YUNO_TEST_PAYMENT_GW
                      transaction_id:
                        type: string
                        example: ''
                      account_id:
                        type: string
                        example: ''
                      status:
                        type: string
                        example: SUCCEEDED
                      sub_status:
                        type: string
                        example: ''
                      status_detail:
                        type: string
                        example: SUCCEEDED
                      response_message: {}
                      response_code:
                        type: string
                        example: SUCCEEDED
                      raw_response:
                        type: object
                        properties:
                          message:
                            type: string
                            example: provider response
                      third_party_transaction_id: {}
                      third_party_account_id: {}
                      iso8583_response_code:
                        type: string
                        example: '00'
                      iso8583_response_message:
                        type: string
                        example: Approved or completed successfully
                  response_code:
                    type: string
                    example: SUCCEEDED
                  response_message:
                    type: string
                    example: Transaction successful
                  payment:
                    type: object
                    properties:
                      id:
                        type: string
                        example: 2d6f75c1-c4bc-4d2d-80ec-0af4d12c85da
                      account_id:
                        type: string
                        example: ''
                      description:
                        type: string
                        example: Test
                      country:
                        type: string
                        example: US
                      status:
                        type: string
                        example: CANCELED
                      sub_status:
                        type: string
                        example: CANCELED
                      merchant_order_id:
                        type: string
                        example: '0000023'
                      created_at:
                        type: string
                        example: '2024-06-06T14:01:34.286228Z'
                      updated_at:
                        type: string
                        example: '2024-06-06T14:03:08.484781Z'
                      amount:
                        type: object
                        properties:
                          captured:
                            type: integer
                            example: 0
                            default: 0
                          currency:
                            type: string
                            example: USD
                          currency_conversion: {}
                          refunded:
                            type: integer
                            example: 0
                            default: 0
                          value:
                            type: integer
                            example: 30000
                            default: 0
                      split_marketplace:
                        type: array
                  customer_payer: {}
                  simplified_mode:
                    type: boolean
                    example: false
                    default: true
                  receipt:
                    type: boolean
                    example: false
                    default: true
                  receipt_url: {}
                  receipt_language: {}
        '400':
          description: '400'
          content:
            application/json:
              examples:
                Result:
                  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
      x-default: <Your public-api-key>
      name: public-api-key
    sec1:
      type: apiKey
      in: header
      x-default: <Your private-secret-key>
      name: private-secret-key
    sec2:
      type: apiKey
      in: header
      x-default: <Your X-Idempotency-Key>
      name: X-Idempotency-Key

````