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

# Payment Method Sessions

> Learn how to create and manage Payment Method Sessions to collect and save a payment method.

export const APIBadge = () => {
  return <div style={{
    display: 'inline-block',
    backgroundColor: 'rgb(var(--primary-light))',
    color: '#ffffff',
    padding: '1px 4px',
    borderRadius: '.375rem',
    borderColor: 'rgb(var(--gray-200))',
    borderWidth: '1px',
    position: 'relative',
    top: '-2px',
    marginLeft: '4px',
    fontSize: '11px',
    fontWeight: 700,
    letterSpacing: '0.05em',
    lineHeight: '11px'
  }}>
      API
    </div>;
};

Payment Method Sessions allow you to securely collect and save payment methods from your customers. Unlike Payment Sessions which collect a one-time payment, Payment Method Sessions save the payment method for future use with subscriptions, invoices, and transactions.

## Create a customer

Before creating a Payment Method Session, you need a customer to attach the payment method to. You can either use an existing customer or create a new one using the [Customers API<APIBadge />](https://docs.yorlet.com/api/core/customers/create).

```bash Create a customer theme={"theme":"dracula"}
curl https://api.yorlet.com/v1/customers \
  -H "Authorization: Bearer {{API_KEY}}" \
  -H "Yorlet-Version: 2025-08-21.preview" \
  -H "Content-Type: application/json" \
  -d '{
        "email": "jane@example.com"
      }'
```

If the request completed successfully, the response contains the customer object.

```json Customer object theme={"theme":"dracula"}
{
  "id": "cus_lrhplff1u4ZhIPSU",
  "object": "customer",
  "email": "jane@example.com"
  // ... other fields on the Customer object
}
```

## Create a Payment Method Session

To [create a Payment Method Session<APIBadge />](https://docs.yorlet.com/api/payments/payment-method-sessions/create), you need to specify the `customer` and `payment_method_types`. You can optionally include a `return_url` to redirect customers after the payment method is collected.

```bash Create a Payment Method Session theme={"theme":"dracula"}
curl https://api.yorlet.com/v1/payment_method_sessions \
  -H "Authorization: Bearer {{API_KEY}}" \
  -H "Yorlet-Version: 2025-08-21.preview" \
  -H "Content-Type: application/json" \
  -d '{
        "customer": "{{CUSTOMER_ID}}",
        "payment_method_types": ["card", "bacs_debit"],
        "return_url": "https://example.com/success"
      }'
```

If the request completed successfully, the Payment Method Session object contains the `url` parameter.

```json Payment Method Session object theme={"theme":"dracula"}
{
  "id": "pmsess_kfls092pPQalaj2",
  "object": "payment_method_session",
  "customer": "cus_lrhplff1u4ZhIPSU",
  "payment_method": null,
  "payment_method_types": ["card", "bacs_debit"],
  "return_url": "https://example.com/success",
  "url": "https://pay.yorlet.com/payment-methods/pmsess_kfls092pPQalaj2-eyJhbGciOiJIUzI1NiJ9"
  // ... other fields on the Payment Method Session object
}
```

### Supported payment method types

You can collect the following payment method types:

| Type                  | Description                |
| --------------------- | -------------------------- |
| `card`                | Credit or debit card       |
| `bacs_debit`          | Bacs Direct Debit (UK)     |
| `sepa_debit`          | SEPA Direct Debit (EU)     |
| `autogiro`            | Autogiro (Sweden)          |
| `bank_transfer`       | Bank transfer              |
| `direct_transfer`     | Direct transfer            |
| `gbp_credit_transfer` | GBP credit transfer        |
| `pay_by_bank`         | Pay by Bank (Open Banking) |
| `card_present`        | In-person card payment     |

### Share the Payment Method Session URL

After creating a Payment Method Session, share the `url` with your customer. They will be guided through a secure flow to enter their payment details. Once complete, they will be redirected to your `return_url`.

<Note>
  By default, Yorlet automatically emails the `url` to the customer, so you don't need to share it yourself. Set `send_email` to `false` if you'd rather share the URL through your own application.
</Note>

```bash Skip the automatic email theme={"theme":"dracula"}
curl https://api.yorlet.com/v1/payment_method_sessions \
  -H "Authorization: Bearer {{API_KEY}}" \
  -H "Yorlet-Version: 2025-08-21.preview" \
  -H "Content-Type: application/json" \
  -d '{
        "customer": "{{CUSTOMER_ID}}",
        "payment_method_types": ["card"],
        "send_email": false
      }'
```

## Collect payment method for a subscription

You can associate a Payment Method Session with a subscription. Once the customer completes the session, the payment method will automatically be attached to the subscription.

```bash Create a Payment Method Session for a subscription theme={"theme":"dracula"}
curl https://api.yorlet.com/v1/payment_method_sessions \
  -H "Authorization: Bearer {{API_KEY}}" \
  -H "Yorlet-Version: 2025-08-21.preview" \
  -H "Content-Type: application/json" \
  -d '{
        "customer": "{{CUSTOMER_ID}}",
        "payment_method_types": ["bacs_debit"],
        "subscription": "{{SUBSCRIPTION_ID}}",
        "return_url": "https://example.com/success"
      }'
```

## Retrieve a Payment Method Session

You can [retrieve a Payment Method Session<APIBadge />](https://docs.yorlet.com/api/payments/payment-method-sessions/retrieve) to check its status and see which payment method was created.

```bash Retrieve a Payment Method Session theme={"theme":"dracula"}
curl https://api.yorlet.com/v1/payment_method_sessions/{{PAYMENT_METHOD_SESSION_ID}} \
  -H "Authorization: Bearer {{API_KEY}}" \
  -H "Yorlet-Version: 2025-08-21.preview"
```

Once the customer completes the session, the `payment_method` field will contain the ID of the created payment method.

```json Completed Payment Method Session theme={"theme":"dracula"}
{
  "id": "pmsess_kfls092pPQalaj2",
  "object": "payment_method_session",
  "customer": "cus_lrhplff1u4ZhIPSU",
  "payment_method": "pm_l34dl7phkOVU7wcI",
  "payment_method_types": ["card"],
  "status": "complete"
  // ... other fields on the Payment Method Session object
}
```
