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

# Update a Payment Intent

> Atualiza um payment intent.

Atualiza um `payment_intent` antes da confirmação. A resposta direta retorna o
objeto completo atualizado; o diff sai apenas no webhook
`payment.intent.updated`.

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

<ParamField body="amount" type="integer">
  Novo valor em centavos. Só pode ser alterado antes do processamento.
</ParamField>

<ParamField body="currency" type="string">
  Nova moeda. Só pode ser alterada antes do processamento.
</ParamField>

<ParamField body="customer" type="string">
  Customer associado (`cus_*`).
</ParamField>

<ParamField body="payment_method" type="string">
  Payment method salvo (`pm_*`).
</ParamField>

<ParamField body="payment_method_types" type="array">
  Métodos permitidos para o intent. Aceita `credit_card` e `pix`.
</ParamField>

<ParamField body="payment_method_options" type="object">
  Opções por método de pagamento.
</ParamField>

<ParamField body="payment_method_options.credit_card.installments.count" type="integer">
  Número de parcelas de cartão antes da confirmação. Quando omitido, usa `1`.
</ParamField>

<ParamField body="payment_method_options.credit_card.installments.has_interest" type="boolean">
  `true` quando o comprador paga o acréscimo do parcelamento; `false` quando o
  lojista absorve o acréscimo (venda sem juros ao comprador). Quando omitido,
  usa a configuração da organização.
</ParamField>

<ParamField body="setup_future_usage" type="string">
  `off_session` ou `on_session`.
</ParamField>

<ParamField body="metadata" type="object">
  Metadata livre.
</ParamField>

<RequestExample>
  ```bash cURL theme={}
  curl -X POST "https://api.chargefy.io/v1/payment-intents/pi_123" \
    -H "Authorization: Bearer {{API_KEY}}" \
    -H "Content-Type: application/json" \
    -d '{
      "metadata": {
        "order_id": "id_456"
      },
      "payment_method": "pm_123",
      "payment_method_options": {
        "credit_card": {
          "installments": {
            "count": 3
          }
        }
      }
    }'
  ```
</RequestExample>

## Resposta

`200 OK` com o objeto `payment_intent` completo — mesmo shape de [GET /v1/payment-intents/:id](/api-reference/payment-intents/get).

<ResponseExample>
  ```json 200 theme={}
  {
    "id": "pi_123",
    "object": "payment_intent",
    "amount": 10528,
    "amount_capturable": 0,
    "amount_details": {
      "installment_interest": 528,
      "subtotal": 10000,
      "total": 10528
    },
    "amount_received": 0,
    "canceled_at": null,
    "cancellation_reason": null,
    "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": {
      "order_id": "id_456"
    },
    "next_action": null,
    "payment_method": "pm_123",
    "payment_method_options": {
      "credit_card": {
        "installments": {
          "amount_subtotal": 10000,
          "amount_total": 10528,
          "count": 3,
          "has_interest": true,
          "interest_amount": 528
        }
      }
    },
    "payment_method_types": [
      "credit_card"
    ],
    "setup_future_usage": null,
    "status": "requires_confirmation",
    "updated_at": "2026-05-16T18:35:00Z"
  }
  ```

  ```json 400 theme={}
  {
    "error": {
      "code": "invalid_request",
      "message": "metadata must be an object.",
      "param": "metadata",
      "type": "invalid_request_error"
    }
  }
  ```

  ```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": "amount cannot be updated after the payment intent has been processed.",
      "param": "amount",
      "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 campo não pode ser alterado no status atual. |
