[PR #7547] [MERGED] fix(stripe): find active subscription correctly when upgrading #7392

Closed
opened 2026-03-13 13:34:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7547
Author: @bytaesu
Created: 1/22/2026
Status: Merged
Merged: 1/22/2026
Merged by: @himself65

Base: canaryHead: 2026-01-22/fix/stripe-find-active-subscription


📝 Commits (1)

  • 6b7b426 fix(stripe): find active subscription correctly when upgrading

📊 Changes

2 files changed (+106 additions, -17 deletions)

View changed files

📝 packages/stripe/src/routes.ts (+10 -17)
📝 packages/stripe/test/stripe.test.ts (+96 -0)

📄 Description

Summary by cubic

Fix subscription upgrade to correctly use the active subscription when a canceled subscription exists for the same referenceId. This prevents creating new checkout sessions and routes users to the billing portal as expected.

  • Bug Fixes
    • Only look up a subscription by subscriptionId when it’s provided; don’t preselect by referenceId.
    • Throw SUBSCRIPTION_NOT_FOUND when the provided subscriptionId is missing or has a different referenceId.
    • Added a test to ensure upgrades use the active subscription and billing portal, not checkout, when a canceled subscription also exists.

Written for commit 6b7b426e68. Summary will update 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/7547 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 1/22/2026 **Status:** ✅ Merged **Merged:** 1/22/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-01-22/fix/stripe-find-active-subscription` --- ### 📝 Commits (1) - [`6b7b426`](https://github.com/better-auth/better-auth/commit/6b7b426e68c71ec811afa6b3e8098db0e754c83a) fix(stripe): find active subscription correctly when upgrading ### 📊 Changes **2 files changed** (+106 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/routes.ts` (+10 -17) 📝 `packages/stripe/test/stripe.test.ts` (+96 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fix subscription upgrade to correctly use the active subscription when a canceled subscription exists for the same referenceId. This prevents creating new checkout sessions and routes users to the billing portal as expected. - **Bug Fixes** - Only look up a subscription by subscriptionId when it’s provided; don’t preselect by referenceId. - Throw SUBSCRIPTION_NOT_FOUND when the provided subscriptionId is missing or has a different referenceId. - Added a test to ensure upgrades use the active subscription and billing portal, not checkout, when a canceled subscription also exists. <sup>Written for commit 6b7b426e68c71ec811afa6b3e8098db0e754c83a. Summary will update 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 13:34:35 -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#7392