[PR #2129] [MERGED] fix(stripe): Throw err if passed referenceId when no subscription authorizeReference` is defined #29769

Closed
opened 2026-04-17 21:02:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2129
Author: @ping-maxwell
Created: 4/4/2025
Status: Merged
Merged: 4/10/2025
Merged by: @Bekacru

Base: mainHead: fix/stripe/reference-id-with-no-authorizeReference


📝 Commits (2)

  • ae6dcd8 fix(stripe): Throw err if passed referenceId when no subscription.authorizeReference is defined
  • 98b39e4 fix: typo

📊 Changes

1 file changed (+7 additions, -0 deletions)

View changed files

📝 packages/stripe/src/index.ts (+7 -0)

📄 Description

If a user uses something like subscription.upgrade and pass a referenceId, but they never defined a options.subscription.authorizeReference then it will throw an error saying unauthorized. (since no function defined, means it will just return false in it's checks)
While this error is valid, it isn't very clear up-front to the developer that it was due to them passing referenceId. To them, they're logged in, so it makes no sense why they would get an unauthorized error.
This PR adds a check if they're missing that function, yet passed referenceId to throw a bad request, and provide more info in the server logs.


🔄 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/2129 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 4/4/2025 **Status:** ✅ Merged **Merged:** 4/10/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `fix/stripe/reference-id-with-no-authorizeReference` --- ### 📝 Commits (2) - [`ae6dcd8`](https://github.com/better-auth/better-auth/commit/ae6dcd8360b6368afeba597b78905de018e164ae) fix(stripe): Throw err if passed `referenceId` when no `subscription.authorizeReference` is defined - [`98b39e4`](https://github.com/better-auth/better-auth/commit/98b39e4eb4eebca7cb4cbcf62e1fa1880d2b5511) fix: typo ### 📊 Changes **1 file changed** (+7 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/index.ts` (+7 -0) </details> ### 📄 Description If a user uses something like `subscription.upgrade` and pass a `referenceId`, but they never defined a `options.subscription.authorizeReference` then it will throw an error saying unauthorized. (since no function defined, means it will just return `false` in it's checks) While this error is valid, it isn't very clear up-front to the developer that it was due to them passing `referenceId`. To them, they're logged in, so it makes no sense why they would get an unauthorized error. This PR adds a check if they're missing that function, yet passed `referenceId` to throw a bad request, and provide more info in the server logs. --- <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 21:02:38 -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#29769