# Payments for existing customers

Learn how to charge an existing payment method while a customer is on-session.

# Stripe-hosted page


A Checkout Session allows customers to enter their payment details. If this is an existing customer, you can configure the Checkout Session to prefill the details with one of their [saved cards](https://docs.stripe.com/payments/save-and-reuse.md?platform=web&ui=stripe-hosted). The Checkout Session displays up to 50 saved cards that a customer can choose to pay with.
![Checkout with one saved card](https://b.stripecdn.com/docs-statics-srv/assets/saved-card.59d38df89f7892ff0a3669779ec30f0b.png)

## Create a Checkout Session [Client-side] [Server-side]

Add a checkout button to your website that calls a server-side endpoint to create a Checkout Session.

```html
<html>
  <head>
    <title>Checkout</title>
  </head>
  <body>
    <form action="/create-checkout-session" method="POST">
      <button type="submit">Checkout</button>
    </form>
  </body>
</html>
```

Checkout supports reusing existing customer-configured `Account` objects with the [customer_account](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer_account) parameter or `Customer` objects with the [customer](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer) parameter. When reusing existing customers, all objects created by Checkout, such as `PaymentIntents` and `Subscriptions`, are associated with the object that represents that customer.

> #### Use the Accounts v2 API to represent customers
> 
> The Accounts v2 API is generally available for Connect users, and in public preview for other Stripe users. If you’re part of the Accounts v2 preview, you need to specify a [preview version](https://docs.stripe.com/api-v2-overview.md#sdk-and-api-versioning) in your code.
> 
> To join the Accounts v2 preview, go to [Account previews and features](https://dashboard.stripe.com/settings/previews) in your Dashboard and enable **Reusable payment methods for Global Payouts**.
> 
> For most use cases, we recommend [modeling your customers as customer-configured Account objects](https://docs.stripe.com/accounts-v2/use-accounts-as-customers.md) instead of using [Customer](https://docs.stripe.com/api/customers.md) objects.

Append the `{CHECKOUT_SESSION_ID}` template variable to the `success_url` to get access to the Session ID after your customer successfully completes a Checkout Session. After creating the Checkout Session, redirect your customer to the [URL](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-url) returned in the response.

#### Accounts v2

```curl
curl https://api.stripe.com/v1/checkout/sessions \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d mode=payment \
  -d "line_items[0][price]={{PRICE_ID}}" \
  -d "line_items[0][quantity]=1" \
  -d "customer_account={{CUSTOMERACCOUNT_ID}}" \
  --data-urlencode "success_url=https://example.com/success?session_id={CHECKOUT_SESSION_ID}"
```

#### Customers v1

```curl
curl https://api.stripe.com/v1/checkout/sessions \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d mode=payment \
  -d "line_items[0][price]={{PRICE_ID}}" \
  -d "line_items[0][quantity]=1" \
  -d "customer={{CUSTOMER_ID}}" \
  --data-urlencode "success_url=https://example.com/success?session_id={CHECKOUT_SESSION_ID}"
```

## Optional: Display additional saved payment methods [Server-side]

> #### Compliance
> 
> You’re responsible for your compliance with all applicable laws, regulations, and network rules when saving a customer’s payment details. When rendering past payment methods to a customer for future purchases, make sure you’ve collected consent to save the payment method details for this specific future use.

By default, we only show payment methods set to [always allow redisplay](https://docs.stripe.com/api/payment_methods/object.md#payment_method_object-allow_redisplay).

You can’t reuse Apple Pay and Google Pay during a Checkout Session, so these payment methods don’t appear in the list of saved options. You must display the Google Pay and Apple Pay UI, and the payment request button UI, each time the Checkout Session is active.

You can display other previously saved payment methods by including other redisplay values in the Checkout Session, or by updating a payment method’s `allow_redisplay` setting to `always`.

- Use the `allow_redisplay_filters` [parameter](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-saved_payment_method_options-allow_redisplay_filters) to specify which saved payment methods to show in Checkout. You can set any of the valid values: `limited`, `unspecified` and `always`.

  If you specify redisplay filtering in your Checkout Session, it overrides the default behavior, so you must include the `always` value to see those saved payment methods.

  #### Accounts v2

  ```curl
  curl https://api.stripe.com/v1/checkout/sessions \
    -u "<<YOUR_SECRET_KEY>>:" \
    -d mode=payment \
    -d "line_items[0][price]={{PRICE_ID}}" \
    -d "line_items[0][quantity]=1" \
    -d "customer_account={{CUSTOMERACCOUNT_ID}}" \
    --data-urlencode "success_url=https://example.com/success?session_id={CHECKOUT_SESSION_ID}" \
    -d "saved_payment_method_options[allow_redisplay_filters][0]=always" \
    -d "saved_payment_method_options[allow_redisplay_filters][1]=limited" \
    -d "saved_payment_method_options[allow_redisplay_filters][2]=unspecified"
  ```

  #### Customers v1

  ```curl
  curl https://api.stripe.com/v1/checkout/sessions \
    -u "<<YOUR_SECRET_KEY>>:" \
    -d mode=payment \
    -d "line_items[0][price]={{PRICE_ID}}" \
    -d "line_items[0][quantity]=1" \
    -d "customer={{CUSTOMER_ID}}" \
    --data-urlencode "success_url=https://example.com/success?session_id={CHECKOUT_SESSION_ID}" \
    -d "saved_payment_method_options[allow_redisplay_filters][0]=always" \
    -d "saved_payment_method_options[allow_redisplay_filters][1]=limited" \
    -d "saved_payment_method_options[allow_redisplay_filters][2]=unspecified"
  ```

- [Update the Payment Method](https://docs.stripe.com/api/payment_methods/update.md) to set the `allow_redisplay` value on individual payment methods.
  ```curl
  curl https://api.stripe.com/v1/payment_methods/{{PAYMENTMETHOD_ID}} \
    -u "<<YOUR_SECRET_KEY>>:" \
    -d allow_redisplay=always
  ```

## Prefill fields on payment page

If all the following conditions are true, Checkout prefills the **email**, **name**, **card**, and **billing address** fields on the payment page using details from the customer’s saved card:

- Checkout is in `payment` or `subscription` mode; `setup` mode doesn’t support prefilling fields.
- The customer has a saved card. Checkout only supports prefilling card payment methods.
- The saved card has `allow_redisplay` set to `always` or you adjusted the [default display setting](https://docs.stripe.com/payments/existing-customers.md#display-additional-saved-payment-methods).
- The payment method includes [billing_details](https://docs.stripe.com/api/payment_methods/object.md#payment_method_object-billing_details) required by the Checkout Session’s [billing_address_collection](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-billing_address_collection) value:
  - `auto` requires values for `email`, `name`, and `address[country]`. US, CA, and GB billing addresses also require `address[postal_code]`.
  - `required` requires values for `email`, `name`, and all `address` fields.

If your customer has multiple saved cards, Checkout prefills details from the card matching the following prioritization:

- In `payment` mode, Stripe prefills the fields using the customer’s newest saved card.
- In `subscription` mode, Stripe prefills the customer’s default payment method if it’s a card. Otherwise, Stripe prefills the newest saved card.

When Checkout is [collecting a shipping address](https://docs.stripe.com/payments/collect-addresses.md), it prefills shipping address fields if the customer’s shipping address is in one of the Checkout Session’s [supported countries](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-shipping_address_collection-allowed_countries).

To let your customers remove saved cards during a Checkout Session, set [save_payment_method_options[payment_method_remove]](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-saved_payment_method_options-payment_method_remove) to `enabled`.

> #### Prefill timeout
> 
> The prefilled payment method displays for 30 minutes following Checkout Session creation. After it expires, loading the same Checkout Session doesn’t prefill the payment method anymore for security reasons.

## Handle post-payment events [Server-side]

Stripe sends a [checkout.session.completed](https://docs.stripe.com/api/events/types.md#event_types-checkout.session.completed) event when a customer completes a Checkout Session payment. Use the [Dashboard webhook tool](https://dashboard.stripe.com/webhooks) or follow the [webhook guide](https://docs.stripe.com/webhooks/quickstart.md) to receive and handle these events, which might trigger you to:

- Send an order confirmation email to your customer.
- Log the sale in a database.
- Start a shipping workflow.

Listen to events rather than waiting for your customer to be redirected back to your website. Triggering fulfillment only from your Checkout success page is unreliable.

Learn more in our [fulfillment guide for Checkout](https://docs.stripe.com/checkout/fulfillment.md).

