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

# Cancel a Payment Intent

> Cancela um payment intent.

Cancela um `payment_intent` que ainda não está concluído.

<ParamField path="id" type="string" required>
  ID do payment intent (`pi_*`).
</ParamField>

<ParamField body="cancellation_reason" type="string">
  `duplicate`, `fraudulent`, `requested_by_customer` ou `abandoned`.
</ParamField>

<RequestExample>
  ```bash cURL theme={}
  curl -X POST "https://api.chargefy.io/v1/payment-intents/pi_123/cancel" \
    -H "Authorization: Bearer {{API_KEY}}"
  ```
</RequestExample>

## Resposta

`200 OK` com o objeto `payment_intent` completo — mesmo shape de [GET /v1/payment-intents/:id](/api-reference/payment-intents/get) — agora com `status: "canceled"`, `canceled_at` preenchido e `cancellation_reason` ecoando o motivo enviado.

<ResponseExample>
  ```json 200 theme={}
  {
    "id": "pi_123",
    "object": "payment_intent",
    "amount": 9990,
    "amount_capturable": 0,
    "amount_details": {
      "installment_interest": 0,
      "subtotal": 9990,
      "total": 9990
    },
    "amount_received": 0,
    "canceled_at": "2026-05-16T19:00:00Z",
    "cancellation_reason": "requested_by_customer",
    "capture_method": "automatic",
    "client_secret": "pi_123_secret_abc",
    "confirmation_method": "automatic",
    "created_at": "2026-05-16T18:34:58Z",
    "currency": "brl",
    "customer": "cus_123",
    "invoice": null,
    "last_payment_error": null,
    "latest_charge": null,
    "livemode": true,
    "metadata": {},
    "next_action": null,
    "payment_method": "pm_123",
    "payment_method_options": {
      "credit_card": {
        "installments": {
          "amount_subtotal": 9990,
          "amount_total": 9990,
          "count": 1,
          "has_interest": true,
          "interest_amount": 0
        }
      }
    },
    "payment_method_types": [
      "credit_card"
    ],
    "setup_future_usage": null,
    "status": "canceled",
    "updated_at": "2026-05-16T19:00:00Z"
  }
  ```

  ```json 401 theme={}
  {
    "error": {
      "code": "authentication_failed",
      "message": "Invalid API key provided.",
      "type": "authentication_error"
    }
  }
  ```

  ```json 404 theme={}
  {
    "error": {
      "code": "resource_missing",
      "message": "Payment intent not found.",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 409 theme={}
  {
    "error": {
      "code": "resource_state_conflict",
      "message": "Payment intent already in terminal status succeeded.",
      "type": "invalid_request_error"
    }
  }
  ```
</ResponseExample>

## Erros comuns

| Status | `code`                    | Quando ocorre                                    |
| ------ | ------------------------- | ------------------------------------------------ |
| `404`  | `resource_missing`        | O payment intent não existe nesta organização.   |
| `409`  | `resource_state_conflict` | O payment intent já está concluído ou cancelado. |
