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

Closed
opened 2026-03-13 12:53:05 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5847
Author: @bytaesu
Created: 11/8/2025
Status: Merged
Merged: 11/8/2025
Merged by: @himself65

Base: canaryHead: 2025-11-08/fix/stripe-duplicate-customer


📝 Commits (3)

  • 12bbe28 fix(stripe): prevent duplicate customer creation on signup
  • 8e5a1e4 test: add test cases for duplicate customer prevention on signup
  • 5a0e3a5 test: drop invalid case

📊 Changes

2 files changed (+188 additions, -3 deletions)

View changed files

📝 packages/stripe/src/index.ts (+49 -3)
📝 packages/stripe/src/stripe.test.ts (+139 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5847 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 11/8/2025 **Status:** ✅ Merged **Merged:** 11/8/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2025-11-08/fix/stripe-duplicate-customer` --- ### 📝 Commits (3) - [`12bbe28`](https://github.com/better-auth/better-auth/commit/12bbe282d47e8c35b97e1f0407311607732cad7f) fix(stripe): prevent duplicate customer creation on signup - [`8e5a1e4`](https://github.com/better-auth/better-auth/commit/8e5a1e4f80ad35f101b48972e03de35a81975b04) test: add test cases for duplicate customer prevention on signup - [`5a0e3a5`](https://github.com/better-auth/better-auth/commit/5a0e3a5db5d9fb5dca55dd20ef93d825ba4b9226) test: drop invalid case ### 📊 Changes **2 files changed** (+188 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/index.ts` (+49 -3) 📝 `packages/stripe/src/stripe.test.ts` (+139 -0) </details> ### 📄 Description 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. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:53:05 -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#6274