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

# Automatically set default payment methods in Stripe for subscriptions

> How to set up a webhook in Stripe so that, when a payment method is first added to a customer's subscription, it is automatically set as the default payment method.

<Note>
  This guide is only relevant for **Subscription** checkout mode.

  For **Payment** mode, all you need to do is set "Setup Future Usage" to "Off Session" in the Stripe component options.

  For **Setup** mode, you don't need to do anything - payment methods are automatically set as default in this mode.
</Note>

When a customer enters their credit card or other payment method for a subscription in Stripe, that payment method is not automatically set as the <strong>default</strong> payment method.

Without this, the next payment in the customer's subscription may fail, unless you manually set the payment method as the default in your Stripe Dashboard.

This guide explains how to set up a Webhook to ensure that when a new payment method is added to a Stripe customer, it is automatically set as the default payment method.

<Frame caption="Example: The top customer has a default payment method set; the bottom customer does not, which can cause payment issues.">
  ![Example: Top customer has a default payment method set; bottom customer does
  not, which can cause payment
  issues.](https://assets.embeddables.com/Screenshot2025-07-21at9_19167427955247518.33.08am.png)
</Frame>

## Adding a webhook to automatically set the default payment method in Stripe

<Tabs>
  <Tab title="You have Workbench enabled">
    {" "}

    <Note>
      Note: This requires a Stripe component that is set up to create{" "}
      <strong>subscriptions</strong>
    </Note>

    <Steps>
      <Step title="Create a new webhook in Stripe">
        * Log in to your Stripe Dashboard.

        * Open the Workbench.

        * Navigate to the Webhooks tab.

        * Click <strong>+ Add destination</strong>.
      </Step>

      <Step title="Configure your webhook settings">
        * Make sure "Events" is set to as "Your account".

        * Make sure "API version" is set to "Your current version".

        * Under "Events", find the `payment_method.attached` event and select it.

        * Click <strong>Continue</strong>.

        * Make sure "Webhook endpoint" is selected and click <strong>Continue</strong>.
      </Step>

      <Step title="Add your endpoint and create the webhook">
        * Grab your Project ID from the URL in the Embeddables Web App - it's the ID after `/project/` that starts with `pr_`.

        * In the "Endpoint URL" field in Stripe, paste the following URL, replacing `<YOUR_PROJECT_ID>` with your Project ID:

        ```
        https://webhooks.embeddables.com/webhooks/stripe/payment_method.attached?project_id=<YOUR_PROJECT_ID>
        ```

        <Tip>
          If you're setting up a webhook for Stripe's test environment, add `&test=true` to the end of the endpoint URL.
        </Tip>

        * Click <strong>Create destination</strong>.
      </Step>
    </Steps>
  </Tab>

  <Tab title="You don't have Workbench enabled">
    {" "}

    <Note>
      Note: This requires a Stripe component that is set up to create{" "}
      <strong>subscriptions</strong>
    </Note>

    <Steps>
      <Step title="Create a new webhook in Stripe">
        * Log in to your Stripe Dashboard.

        * Go to the Developers section (bottom-left in your sidebar).

        * Navigate to the Webhooks tab.

        * Click <strong>+ Add endpoint</strong>.
      </Step>

      <Step title="Add your endpoint">
        * Grab your Project ID from the URL in the Embeddables Web App - it's the ID after `/project/` that starts with `pr_`.

        * In the "Endpoint URL" field in Stripe, paste the following URL, replacing `<YOUR_PROJECT_ID>` with your Project ID:

        ```
        https://webhooks.embeddables.com/webhooks/stripe/payment_method.attached?project_id=<YOUR_PROJECT_ID>
        ```

        <Tip>
          If you're setting up a webhook for Stripe's test environment, add `&test=true` to the end of the endpoint URL.
        </Tip>

        * Add a description of what the endpoint is for.
      </Step>

      <Step title="Configure your webhook settings">
        * Make sure "Listen to" is set to as "Events on your account".

        * Make sure "Version" is set to "Your current version".

        * Click "Select events", find the `payment_method.attached` event and select it.

        * Click <strong>Add endpoint</strong>
      </Step>
    </Steps>
  </Tab>
</Tabs>

***

## Migrating from the old webhook URL to the new format

<Tabs>
  <Tab title="You have Workbench enabled">
    #### Migrating to the new webhook URL with Workbench enabled

    <Steps>
      <Step title="Update your webhook endpoint URL">
        * Go to your Stripe Dashboard and open the Workbench.

        * Navigate to the Webhooks tab and find your existing webhook for `payment_method.attached`.

        * Edit the endpoint URL to use the new format:

        ```
        https://webhooks.embeddables.com/webhooks/stripe/payment_method.attached?project_id=<YOUR_PROJECT_ID>
        ```

        <Tip>
          If you're setting up a webhook for Stripe's test environment, add `&test=true` to the end of the endpoint URL.
        </Tip>

        * You can get your project ID from the URL in the Embeddables Web App - it's the ID after `/project/` that starts with `pr_`.
        * Save your changes.
      </Step>
    </Steps>
  </Tab>

  <Tab title="You don't have Workbench enabled">
    #### Migrating to the new webhook URL with Workbench disabled

    <Steps>
      <Step title="Update your webhook endpoint URL">
        * Go to your Stripe Dashboard and open the Developers > Webhooks section.

        * Find your existing webhook for `payment_method.attached`.

        * Edit the endpoint URL to use the new format:

        ```
        https://webhooks.embeddables.com/webhooks/stripe/payment_method.attached?project_id=<YOUR_PROJECT_ID>
        ```

        <Tip>
          If you're setting up a webhook for Stripe's test environment, add `&test=true` to the end of the endpoint URL.
        </Tip>

        * You can get your project ID from the URL in the Embeddables Web App - it's the ID after `/project/` that starts with `pr_`.
        * Save your changes.
      </Step>
    </Steps>
  </Tab>
</Tabs>
