[PR #4435] [MERGED] fix: shouldn't update personal sub when upgrading with org ref id #5382

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

📋 Pull Request Information

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

Base: canaryHead: fix/stripe-org


📝 Commits (2)

  • 2f7c73e fix: shouldn't update personal sub when upgrading with org ref id
  • 0cbfac2 chore: lint

📊 Changes

2 files changed (+117 additions, -2 deletions)

View changed files

📝 packages/stripe/src/index.ts (+9 -2)
📝 packages/stripe/src/stripe.test.ts (+108 -0)

📄 Description

Summary by cubic

Fixes upgrades with an organization referenceId so they no longer modify a user’s personal subscription. The upgrade correctly targets the org scope and creates a checkout session for the org.

  • Bug Fixes
    • When referenceId is provided (and no subscriptionId), fetch the subscription by referenceId instead of falling back to the personal one.
    • Do not default-match an active subscription when no explicit id is provided, preventing accidental updates to personal subs.
    • For org upgrades, skip the billing portal and return a checkout URL.
    • Added tests to verify the personal sub stays active and a new org sub is created/incomplete during org upgrades.

🔄 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/4435 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 9/4/2025 **Status:** ✅ Merged **Merged:** 9/4/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/stripe-org` --- ### 📝 Commits (2) - [`2f7c73e`](https://github.com/better-auth/better-auth/commit/2f7c73e5aefd4ed2f54f1b451428b751ff1e35ae) fix: shouldn't update personal sub when upgrading with org ref id - [`0cbfac2`](https://github.com/better-auth/better-auth/commit/0cbfac29187a3827e68e04d20e5bfb5f67496792) chore: lint ### 📊 Changes **2 files changed** (+117 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/index.ts` (+9 -2) 📝 `packages/stripe/src/stripe.test.ts` (+108 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fixes upgrades with an organization referenceId so they no longer modify a user’s personal subscription. The upgrade correctly targets the org scope and creates a checkout session for the org. - **Bug Fixes** - When referenceId is provided (and no subscriptionId), fetch the subscription by referenceId instead of falling back to the personal one. - Do not default-match an active subscription when no explicit id is provided, preventing accidental updates to personal subs. - For org upgrades, skip the billing portal and return a checkout URL. - Added tests to verify the personal sub stays active and a new org sub is created/incomplete during org upgrades. <!-- 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:20:57 -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#5382