[GH-ISSUE #3670] STRIPE. Duplicate customers are created when using createCustomerOnSignUp: true and and a customer with same email exists in stripe #27003

Closed
opened 2026-04-17 17:46:49 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @pauksztello on GitHub (Jul 28, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3670

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Add stripe plugin with createCustomerOnSignUp true
  2. Pass existing stripeCustomerId on signUp

Current vs. Expected behavior

Im using stripe plugin and with createCustomerOnSignUp: true. I have a case where i want to pass existing stripeCustomerId on signup. When i due it , the plugin overwrites it and creates a new customer.

What version of Better Auth are you using?

1.3.4

Provide environment information

-

Which area(s) are affected? (Select all that apply)

Backend, Package

Auth config (if applicable)

stripe({
      createCustomerOnSignUp: true,

Additional context

No response

Originally created by @pauksztello on GitHub (Jul 28, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3670 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Add stripe plugin with createCustomerOnSignUp true 2. Pass existing stripeCustomerId on signUp ### Current vs. Expected behavior Im using stripe plugin and with createCustomerOnSignUp: true. I have a case where i want to pass existing stripeCustomerId on signup. When i due it , the plugin overwrites it and creates a new customer. ### What version of Better Auth are you using? 1.3.4 ### Provide environment information ```bash - ``` ### Which area(s) are affected? (Select all that apply) Backend, Package ### Auth config (if applicable) ```typescript stripe({ createCustomerOnSignUp: true, ``` ### Additional context _No response_
GiteaMirror added the lockedstale labels 2026-04-17 17:46:49 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 28, 2025):

Hi @paukstelom! I'm Dosu and I’m helping the better-auth team.

The current Stripe plugin logic in Better Auth v1.3.4 always creates a new Stripe customer and overwrites any provided stripeCustomerId when createCustomerOnSignUp is true—there’s no check for an existing ID, so your supplied value gets ignored and replaced with a new customer ID from Stripe. This is confirmed by the code in the plugin’s sign-up flow, which unconditionally calls stripe.customers.create and updates the user record with the new ID, regardless of what you pass in. There’s no documented workaround for preserving a provided stripeCustomerId in this scenario, and the preventDuplicateCustomers option only checks for existing customers by email, not by a supplied ID (sourcePR 2566PR 3459).

If you need to preserve an existing stripeCustomerId, you’ll need to disable createCustomerOnSignUp and handle customer assignment manually, or consider requesting a feature to add a guard for this use case.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3126221620 --> @dosubot[bot] commented on GitHub (Jul 28, 2025): <!-- Greeting --> Hi @paukstelom! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> The current Stripe plugin logic in Better Auth v1.3.4 always creates a new Stripe customer and overwrites any provided stripeCustomerId when createCustomerOnSignUp is true—there’s no check for an existing ID, so your supplied value gets ignored and replaced with a new customer ID from Stripe. This is confirmed by the code in the plugin’s sign-up flow, which unconditionally calls stripe.customers.create and updates the user record with the new ID, regardless of what you pass in. There’s no documented workaround for preserving a provided stripeCustomerId in this scenario, and the preventDuplicateCustomers option only checks for existing customers by email, not by a supplied ID ([source](https://github.com/better-auth/better-auth/blob/259184641e24a7df6efdd7200c16654307c81b4b/packages/stripe/src/index.ts), [PR 2566](https://github.com/better-auth/better-auth/pull/2566), [PR 3459](https://github.com/better-auth/better-auth/pull/3459)). If you need to preserve an existing stripeCustomerId, you’ll need to disable createCustomerOnSignUp and handle customer assignment manually, or consider requesting a feature to add a guard for this use case. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/edc68998-dfd5-4adb-9cb5-06c90d073e8f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/edc68998-dfd5-4adb-9cb5-06c90d073e8f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/edc68998-dfd5-4adb-9cb5-06c90d073e8f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/edc68998-dfd5-4adb-9cb5-06c90d073e8f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/edc68998-dfd5-4adb-9cb5-06c90d073e8f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/edc68998-dfd5-4adb-9cb5-06c90d073e8f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/edc68998-dfd5-4adb-9cb5-06c90d073e8f?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3670)
Author
Owner

@pauksztello commented on GitHub (Jul 28, 2025):

I understand, the preventDuplicateCustomers should handle my case, however for some reason during signUpEmail, a new customer is still being created instead of linking to an existing customer with same email,

<!-- gh-comment-id:3126271451 --> @pauksztello commented on GitHub (Jul 28, 2025): I understand, the preventDuplicateCustomers should handle my case, however for some reason during signUpEmail, a new customer is still being created instead of linking to an existing customer with same email,
Author
Owner

@dagmawibabi commented on GitHub (Aug 2, 2025):

@paukstelom okay so what you'd expect is to reject the new signups?

<!-- gh-comment-id:3146116217 --> @dagmawibabi commented on GitHub (Aug 2, 2025): @paukstelom okay so what you'd expect is to reject the new signups?
Author
Owner

@pauksztello commented on GitHub (Aug 6, 2025):

Sorry for the late response. To be more specific, I would expect to create new stripe customer only when stripeCustomerId is not provided, but I believe that would let anyone set any id they want. In this case, I believe my confusion was caused due to stripeCustomerId field being exposed in the signUp and updateUser apis.

Image
<!-- gh-comment-id:3161170898 --> @pauksztello commented on GitHub (Aug 6, 2025): Sorry for the late response. To be more specific, I would expect to create new stripe customer only when stripeCustomerId is not provided, but I believe that would let anyone set any id they want. In this case, I believe my confusion was caused due to stripeCustomerId field being exposed in the signUp and updateUser apis. <img width="515" height="203" alt="Image" src="https://github.com/user-attachments/assets/dee57ff8-2649-4141-b828-93b64d884e39" />
Author
Owner

@pauksztello commented on GitHub (Aug 6, 2025):

After investigating further. Ive noticed that logic of preventing duplicate customers is missing in after create db hooks.

Image

Its only handled when updating subscription:

Image
<!-- gh-comment-id:3161453723 --> @pauksztello commented on GitHub (Aug 6, 2025): After investigating further. Ive noticed that logic of preventing duplicate customers is missing in after create db hooks. <img width="741" height="540" alt="Image" src="https://github.com/user-attachments/assets/e8ab403c-ce91-45f5-9cd1-accacfca5fed" /> Its only handled when updating subscription: <img width="662" height="490" alt="Image" src="https://github.com/user-attachments/assets/730588e6-7154-4daa-a685-27ac5974ffb5" />
Author
Owner

@dosubot[bot] commented on GitHub (Nov 5, 2025):

Hi, @pauksztello. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported that in Better Auth v1.3.4, the Stripe plugin creates duplicate customers when createCustomerOnSignUp is true and an existing stripeCustomerId is passed during signup.
  • The plugin currently always creates a new Stripe customer on signup, ignoring any provided customer ID.
  • There is no workaround except disabling createCustomerOnSignUp and manually handling customer assignment.
  • You noted that the logic to prevent duplicate customers is missing in the after-create database hooks and only applied during subscription updates, which may cause preventDuplicateCustomers to not work as expected during signup.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of better-auth by commenting here to keep the discussion open.
  • Otherwise, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3492141807 --> @dosubot[bot] commented on GitHub (Nov 5, 2025): Hi, @pauksztello. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported that in Better Auth v1.3.4, the Stripe plugin creates duplicate customers when `createCustomerOnSignUp` is true and an existing `stripeCustomerId` is passed during signup. - The plugin currently always creates a new Stripe customer on signup, ignoring any provided customer ID. - There is no workaround except disabling `createCustomerOnSignUp` and manually handling customer assignment. - You noted that the logic to prevent duplicate customers is missing in the after-create database hooks and only applied during subscription updates, which may cause `preventDuplicateCustomers` to not work as expected during signup. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of better-auth by commenting here to keep the discussion open. - Otherwise, this issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27003