[PR #4988] [MERGED] fix(stripe): update with an existing subscription #31296

Closed
opened 2026-04-17 22:10:56 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4988
Author: @himself65
Created: 9/30/2025
Status: Merged
Merged: 9/30/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/09/30/stripe


📝 Commits (5)

  • f012ef6 chore: fix adapter tests (#4844)
  • 0f068c0 fix(stripe): update with an existing subscription
  • 783f746 Merge branch 'canary' into himself65/2025/09/30/stripe
  • 50cf8ab Merge branch 'canary' into himself65/2025/09/30/stripe
  • 46fb642 chore: lint fix

📊 Changes

2 files changed (+220 additions, -20 deletions)

View changed files

📝 packages/stripe/src/index.ts (+84 -20)
📝 packages/stripe/src/stripe.test.ts (+136 -0)

📄 Description

Fixes: https://github.com/better-auth/better-auth/issues/1880
Closes: https://linear.app/better-auth/issue/ENG-77/fix-update-existing-stripe-subscription-instead-of-creating-new-one

Summary by cubic

Updates the Stripe upgrade flow to modify an existing active or trialing subscription instead of creating a new one. This prevents duplicate subscriptions and sends users to the billing portal with the correct price and seat count.

  • Bug Fixes
    • Reuse the customer’s existing subscription by matching ID or current reference, avoiding mix-ups between personal and org subscriptions.
    • If a Stripe subscription exists without a DB record, relink by updating the existing DB subscription.
    • Resolve price IDs via lookup keys when needed; throw a clear error if none found.
    • Switch to Billing Portal subscription_update_confirm to change price/quantity; skip creating Checkout sessions.

🔄 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/4988 **Author:** [@himself65](https://github.com/himself65) **Created:** 9/30/2025 **Status:** ✅ Merged **Merged:** 9/30/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/09/30/stripe` --- ### 📝 Commits (5) - [`f012ef6`](https://github.com/better-auth/better-auth/commit/f012ef625b356387e35e9aa80f9428e6fabaf425) chore: fix adapter tests (#4844) - [`0f068c0`](https://github.com/better-auth/better-auth/commit/0f068c08f8550867c007c67577af92b3e9cecb4b) fix(stripe): update with an existing subscription - [`783f746`](https://github.com/better-auth/better-auth/commit/783f746c8239037823176d6cf7b2b07929fbff6b) Merge branch 'canary' into himself65/2025/09/30/stripe - [`50cf8ab`](https://github.com/better-auth/better-auth/commit/50cf8aba0eef34a2b75ba6686377a212add22f68) Merge branch 'canary' into himself65/2025/09/30/stripe - [`46fb642`](https://github.com/better-auth/better-auth/commit/46fb6420fdeddde2b51330e8152d6c8aeae10caf) chore: lint fix ### 📊 Changes **2 files changed** (+220 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/index.ts` (+84 -20) 📝 `packages/stripe/src/stripe.test.ts` (+136 -0) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/issues/1880 Closes: https://linear.app/better-auth/issue/ENG-77/fix-update-existing-stripe-subscription-instead-of-creating-new-one <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Updates the Stripe upgrade flow to modify an existing active or trialing subscription instead of creating a new one. This prevents duplicate subscriptions and sends users to the billing portal with the correct price and seat count. - **Bug Fixes** - Reuse the customer’s existing subscription by matching ID or current reference, avoiding mix-ups between personal and org subscriptions. - If a Stripe subscription exists without a DB record, relink by updating the existing DB subscription. - Resolve price IDs via lookup keys when needed; throw a clear error if none found. - Switch to Billing Portal subscription_update_confirm to change price/quantity; skip creating Checkout sessions. <!-- 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-04-17 22:10:56 -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#31296