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

# Payment methods

> Add a payment method, choose a default and select how a customer pays.

A payment method identifies how your customer pays, such as a card or direct debit. Lago uses the payment provider’s reference to request payment.

## Add a payment method

A checkout URL sends the customer to the provider's checkout page to register a payment method. The customer must already be [connected to a provider](https://getlago.com/docs/v2/guide/payments/payment-providers.md).

> [tab] Dashboard
>
> 1. Open the customer.
> 2. In **Payment methods**, click **Add a payment method**.
> 3. Click **Generate link**.
> 4. Copy the URL.
> 5. Share it with your customer.

> [tab] API
>
> | Field | Meaning |
> | - | - |
> | `lago_id` | Lago identifier, used in the endpoints below. |
> | `external_customer_id` | The customer that owns the method. |
> | `provider_method_id` | Identifier of the instrument in the provider. |
> | `payment_provider_code`, `payment_provider_name`, `payment_provider_type` | The provider connection. |
> | `is_default` | Whether it is the customer's default method. |
> | `deleted_at` | Set once the method is deleted. |
>
> No request body is required.
>
> ```bash Create a checkout URL theme={"dark"}
> LAGO_URL="https://api.getlago.com"
> API_KEY="__YOUR_API_KEY__"
>
> curl --location --request POST "$LAGO_URL/api/v2/customers/customer_example/checkout_url" \
>   --header "Authorization: Bearer $API_KEY"
> ```
>
> Use `checkout_url.checkout_url` from the response to open the provider’s setup page. This registers a payment method; to collect an invoice, [create a payment URL](https://getlago.com/docs/v2/guide/payments/payment-retries.md#create-a-payment-url).

## List a customer's payment methods

```bash List payment methods theme={"dark"}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request GET "$LAGO_URL/api/v2/customers/customer_example/payment_methods" \
  --header "Authorization: Bearer $API_KEY"
```

The list is cursor-paginated and accepts `created_at_from` and `created_at_to`.

## Set the default payment method

The default method is used when a payment request or a retry does not select one. No request body is required.

```bash Set the default payment method theme={"dark"}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
PAYMENT_METHOD_ID="__YOUR_PAYMENT_METHOD_ID__"

curl --location --request PUT "$LAGO_URL/api/v2/customers/customer_example/payment_methods/$PAYMENT_METHOD_ID/set_as_default" \
  --header "Authorization: Bearer $API_KEY"
```

## Choose a method for a payment

[Payment requests](https://getlago.com/docs/v2/guide/payments/payment-requests.md) and [payment retries](https://getlago.com/docs/v2/guide/payments/payment-retries.md) accept an optional `payment_method` object. Omit it to use the configured default.

| Field | Values |
| - | - |
| `payment_method_type` | How the payment is collected: `provider` or `manual`. |
| `payment_method_id` | `lago_id` of a payment method that belongs to the customer. |

```json theme={"dark"}
{
  "payment_method": {
    "payment_method_type": "provider",
    "payment_method_id": "__YOUR_PAYMENT_METHOD_ID__"
  }
}
```

## Delete a payment method

> [!WARNING]
>
> Before deleting a payment method, select another method for payments that relied on it.

```bash Delete a payment method theme={"dark"}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
PAYMENT_METHOD_ID="__YOUR_PAYMENT_METHOD_ID__"

curl --location --request DELETE "$LAGO_URL/api/v2/customers/customer_example/payment_methods/$PAYMENT_METHOD_ID" \
  --header "Authorization: Bearer $API_KEY"
```

The response returns the payment method with `deleted_at` set.

## Next steps

> [card] [Payment retries](https://getlago.com/docs/v2/guide/payments/payment-retries.md)
>
> Retry an invoice payment with a chosen method.

> [card] [Payment requests](https://getlago.com/docs/v2/guide/payments/payment-requests.md)
>
> Collect several overdue invoices at once.

> [card] [List payment methods (API)](https://getlago.com/docs/v2/api-reference/customers/list-payment-methods.md)
>
> Response schema.

> [card] [Create a checkout URL (API)](https://getlago.com/docs/v2/api-reference/customers/checkout-url.md)
>
> Response schema.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.