Skip to main content
A customer (cus_…) belongs to one merchant and one mode. The customer a payment lands on holds that payment’s saved card, subscription, and history. Checkout buyers pay as guests unless a customer is needed. A guest payment has no customer; the buyer’s details stay on the checkout session. Your integration creates customers for buyers it knows, and checkout creates one when a subscription needs it or when you ask it to.

Customers and guests

Checkout treats the email a buyer types as contact details, not as proof of identity. It never attaches a payment to an existing customer because the buyer typed that customer’s email.

How checkout decides

Subscription sessions always require an email, so every subscription signup has a customer. With customer_creation: always, a payment where the buyer enters no email also completes as a guest. When the buyer is signed in to your site, pass their customer ID as customer when you create the session. The payment, any saved card, and any subscription attach to that customer. Checkout shows the customer’s email, and the buyer can’t change it.
  • The customer must belong to the same merchant and mode as the session and must be active. A deleted customer, or one from another merchant or mode, returns 404 with code CUSTOMER_NOT_FOUND.
  • To show an email for a buyer without a customer record, pass customer_email instead. Checkout shows it, the buyer can’t change it, and the payment uses it. Pass either customer or customer_email; a session with both returns 400.
  • Create the customer with POST /v1/customers the first time a buyer signs up, store its ID on your user record, and pass that ID on every session for the same buyer.

Read a guest’s details

A completed guest session has customer set to null. The buyer’s email, name, phone, and billing address are in customer_details, and a shipping address, when the session collects one, is in shipping_details. Read them from the checkout.session.completed event, whose data.object is the session, or retrieve the session after the buyer returns to your success_url.
TypeScript
Each submission replaces the last, so the details reflect what the buyer entered on the attempt that paid.

Create a customer for every buyer

Set customer_creation to always when you want a customer for each buyer who enters an email. Set it on a payment link to apply it to every checkout from that link. In the dashboard, select Create a customer for every buyer under Payment options when you create or edit a one-time payment link.
  • The completed session’s customer holds the customer checkout created, and customer.created fires with data.object.creation_source set to checkout.
  • A session creates at most one customer. When the buyer submits the same session again, for example after a declined card, the session keeps that customer and updates it with the details from the new submission, and customer.updated fires when anything changed. A customer you pass as customer is never changed.
  • customer_creation applies to payment sessions and one-time payment links. Subscription sessions always create a customer, and setting the field on them returns 400.

Save cards

A saved card belongs to a customer. When you set payment_intent_data.setup_future_usage, checkout offers the buyer the option to save their card only when the session has a customer or customer_creation: always. A guest’s card is not saved. On a one-time payment link in the dashboard, selecting Save card for future payments also selects Create a customer for every buyer, so each saved card has a customer to belong to.

Keep your records in sync

  • Store customers by id. One email can belong to several customers at the same merchant: one you created and one for each session that created a customer for that buyer.
  • Find every customer for an email with the list endpoint. search matches part of a customer’s email, name, or ID, so keep the results whose email equals the address, ignoring case. Results are paginated: iterate with for await in the SDK, or pass next_cursor as starting_after until has_more is false.
  • Reuse the customer behind a 409. When POST /v1/customers returns CUSTOMER_EMAIL_ALREADY_EXISTS, search for the email and use the customer you created earlier. Only customers you create count toward the 409.

Guests in the dashboard

The Guests tab on the Customers page groups guest payments by email, with each guest’s payment count, spend, and first and last payment. Open a guest to see their payments. Guest payments in the payments list show the buyer’s email.

Returning-customer counts

The dashboard counts paying buyers by email within the selected date range, guests included. A buyer counts once, even if they pay through several checkouts. They count as new if their first payment falls within that range, or as returning if their first payment was before it.

Connected accounts

On a Connect platform, each connected account has its own customers and guests, and every rule on this page applies per account. A checkout session you create for a connected account creates any customer under that account. Store the merchant ID next to each customer ID, and pass a customer that belongs to the same connected account.

What’s next

Manage customers

Create, update, and list customers, and attach payment methods.

Hosted checkout

Create a session and send the buyer to the hosted page.