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

# Manage Payment Intent

The Modem Pay SDK provides straightforward methods to manage Payment Intents beyond creating them, allowing you to cancel, retrieve, and list Payment Intents easily.

***

#### Cancel a Payment Intent

If a payment session is no longer needed, you can cancel a Payment Intent. Once canceled, the Payment Intent can’t be completed, which is useful for handling expired or abandoned payments.

**Parameters:**

* `id` *(string)*: The unique identifier of the Payment Intent you wish to cancel.

<CodeGroup>
  ```javascript nodejs theme={null}
  const paymentIntent = await modempay.paymentIntents.cancel(
      "49ac6595-beba-480f-bc3d-33e5d4162c4c"
  );
  ```

  ```python python theme={null}
  payment_intent = modem_pay.payment_intents.cancel(
      "49ac6595-beba-480f-bc3d-33e5d4162c4c"
  )
  ```

  ```php php theme={null}
  $payment_intent = $modemPay->paymentIntents()->cancel(
      "49ac6595-beba-480f-bc3d-33e5d4162c4c"
  );
  ```

  ```bash cURL theme={null}
  cURL -X PATCH "https://api.modempay.com/v1/payments/<payment_intent_id>" \
    -H "Authorization: Bearer <your_api_key>"
  ```
</CodeGroup>

**Response:**
Returns the canceled Payment Intent object, updating its status to `"cancelled"`.

```json theme={null}
{
  ...
  "status": "cancelled"
}
```

***

#### Retrieve a Payment Intent

To check the current status or details of an existing Payment Intent, you can retrieve it by the secret. This is especially useful for confirming the progress or outcome of a payment attempt.

**Parameters:**

* `intent_secret` *(string)*: The unique secret of the Payment Intent you’re retrieving.

<CodeGroup>
  ```javascript nodejs theme={null}
  const paymentIntent = await modempay.paymentIntents.retrieve(
      "bfa7eb3ea516ee15f80915a922c00242a77629eb5b1efe34048b83a61925bbf5"
  );
  ```

  ```python python theme={null}
  payment_intent = modem_pay.payment_intents.retrieve(
      "bfa7eb3ea516ee15f80915a922c00242a77629eb5b1efe34048b83a61925bbf5"
  )
  ```

  ```php php theme={null}
  $payment_intent = $modemPay->paymentIntents()->retrieve(
      "49ac6595-beba-480f-bc3d-33e5d4162c4c"
  );
  ```

  ```bash cURL theme={null}
  cURL -X GET "https://api.modempay.com/v1/payments/verify?intent_secret=<intent_secret>" \
    -H "Authorization: Bearer <your_api_key>"
  ```
</CodeGroup>

**Response:**
Returns the Payment Intent object, including attributes such as:

* **status**: Shows if the intent is `"initialized"`, `"processing"`, `"successful"`, etc.
* **amount, currency, description**: Reflects the payment details initially set.
* **link**: The unique payment link for the intent.
* **customer**: Linked customer details, if available.

***

#### List Payment Intents

To view a collection of recent Payment Intents, use the `list` method. This is ideal for tracking activity, viewing recent payment attempts, or obtaining an overview of intents by status.

**Parameters:**

* `limit` *(number, optional)*: The number of Payment Intents to retrieve (default is typically 10).

<CodeGroup>
  ```javascript nodejs theme={null}
  const paymentIntents = await modempay.paymentIntents.list({ limit: 10 });
  ```

  ```python python theme={null}
  payment_intents = modem_pay.payment_intents.list(options={"limit": 10})
  ```

  ```php php theme={null}
  $payment_intents = $modemPay->paymentIntents()->list(['limit' => 10]);
  ```

  ```bash cURL theme={null}
  cURL -X GET "https://api.modempay.com/v1/payments?offset=0&limit=10" \
    -H "Authorization: Bearer <your_api_key>"
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "data": [],
  "meta": {
    "total": 31
  }
}

```
