[PR #5847] fix(stripe): prevent duplicate customer creation on signup #14521

Closed
opened 2026-04-13 09:31:07 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5847

State: closed
Merged: Yes


Closes https://github.com/better-auth/better-auth/issues/3670


Summary by cubic

Prevents duplicate Stripe customer creation on signup by checking for an existing customer and linking it instead of creating a new one. Adds clear logging and safer error handling around customer creation.

  • Bug Fixes
    • Skip creation if user already has stripeCustomerId.
    • Look up existing Stripe customer by email (limit 1); if found, link to the user and call onCustomerCreate.
    • Create a customer only when none exists; then persist stripeCustomerId.
    • Add info/error logs for link/create paths and failures.
    • Add tests covering: user with existing ID, email present in Stripe, and clean create path.

Written for commit 5a0e3a5db5. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5847 **State:** closed **Merged:** Yes --- Closes https://github.com/better-auth/better-auth/issues/3670 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prevents duplicate Stripe customer creation on signup by checking for an existing customer and linking it instead of creating a new one. Adds clear logging and safer error handling around customer creation. - **Bug Fixes** - Skip creation if user already has stripeCustomerId. - Look up existing Stripe customer by email (limit 1); if found, link to the user and call onCustomerCreate. - Create a customer only when none exists; then persist stripeCustomerId. - Add info/error logs for link/create paths and failures. - Add tests covering: user with existing ID, email present in Stripe, and clean create path. <sup>Written for commit 5a0e3a5db5d9fb5dca55dd20ef93d825ba4b9226. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:31:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14521