[GH-ISSUE #2495] Feature Request: option to prevent duplicate Stripe customers #17857

Closed
opened 2026-04-15 16:12:16 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @zpg6 on GitHub (Apr 30, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2495

Is this suited for github?

  • Yes, this is suited for github

Currently you can create multiple customers with the same email address, as it seems Stripe does not enforce uniqueness. This can be a huge hassle, so it should be an option of the stripe plugin.

Describe the solution you'd like

When creating the customer does something like:

const existingCustomer = await stripe.customers.list({
    email: user.email,
    limit: 1,
});
if (existingCustomer.data.length > 0) {
    // they already exist as a customer in our stripe account
}

Describe alternatives you've considered

I've implemented something like this myself, disabling the createCustomerOnSignUp and doing my own customer creating in databaseHook for user.create.after.

Additional context

No response

Originally created by @zpg6 on GitHub (Apr 30, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2495 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Currently you can create multiple customers with the same email address, as it seems Stripe does not enforce uniqueness. This can be a huge hassle, so it should be an option of the stripe plugin. ### Describe the solution you'd like When creating the customer does something like: ```typescript const existingCustomer = await stripe.customers.list({ email: user.email, limit: 1, }); if (existingCustomer.data.length > 0) { // they already exist as a customer in our stripe account } ``` ### Describe alternatives you've considered I've implemented something like this myself, disabling the `createCustomerOnSignUp` and doing my own customer creating in `databaseHook` for `user.create.after`. ### Additional context _No response_
GiteaMirror added the locked label 2026-04-15 16:12:16 -05:00
Author
Owner

@zpg6 commented on GitHub (May 4, 2025):

Update

I looked a bit more closely, if we did add this option for preventDuplicateCustomers it would apply:

  1. When user signs up if createCustomerOnSignUp is true: we would need to ensure they aren't already a customer (e.g. for another one of our products - maybe they pay on our mobile app that uses a different auth system).
  2. When the user updates their subscription if the customerId is not available: it currently will create new one for you. But even if there was an issue in our database, if there was a customer with this email in our stripe account we would want to re-link it not create a new customer.
<!-- gh-comment-id:2849255201 --> @zpg6 commented on GitHub (May 4, 2025): ## Update I looked a bit more closely, if we did add this option for `preventDuplicateCustomers` it would apply: 1. **When user signs up if `createCustomerOnSignUp` is `true`**: we would need to ensure they aren't already a customer (e.g. for another one of our products - maybe they pay on our mobile app that uses a different auth system). 2. **When the user updates their subscription if the `customerId` is not available**: it currently will create new one for you. But even if there was an issue in our database, if there was a customer with this email in our stripe account we would want to re-link it not create a new customer.
Author
Owner

@dagmawibabi commented on GitHub (Jul 10, 2025):

Great job on the PR, reviewing it.

<!-- gh-comment-id:3058254548 --> @dagmawibabi commented on GitHub (Jul 10, 2025): Great job on the PR, reviewing it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#17857