[GH-ISSUE #2938] [Stripe] Create a new subscription when the subscriptionId is the one from the database #9404

Closed
opened 2026-04-13 04:50:56 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @TheYoxy on GitHub (Jun 7, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2938

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Try to upgrade a subscription while using the subscriptionId from the database.

...
const result = await authClient.subscription.upgrade({
  plan: plan.name,
  seats,
  subscriptionId: subscription.id,
});
...

When using this method, a new subscription is created in stripe instead of upgrading the current subscription.

Current vs. Expected behavior

When using the stripeSubscriptionId, it upgrade the selected subscription instead of recreating a new one.

...
const result = await authClient.subscription.upgrade({
  plan: plan.name,
  seats,
  subscriptionId: subscription.stripeSubscriptionId,
});
...

What version of Better Auth are you using?

1.2.9-beta.9

Provide environment information

- OS: Arch
- Browser: all

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
  plugins: [
  stripe({
    stripeClient,
    stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET,
    subscription: {
      authorizeReference() {
        return true;
      },
      enabled: true,
      organization: {
        enabled: true,
      },
      plans,
    },
  })]
});

Additional context

The subscription to update is fetched here:

335e6be0bf/packages/stripe/src/index.ts (L200-L216)

But when trying to upgrade the selected subscription, it uses the subscriptionId from the request and not the one from the subscription fetched.

335e6be0bf/packages/stripe/src/index.ts (L263-L275)

Originally created by @TheYoxy on GitHub (Jun 7, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2938 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Try to upgrade a subscription while using the subscriptionId from the database. ```ts ... const result = await authClient.subscription.upgrade({ plan: plan.name, seats, subscriptionId: subscription.id, }); ... ``` When using this method, a new subscription is created in stripe instead of upgrading the current subscription. ### Current vs. Expected behavior When using the stripeSubscriptionId, it upgrade the selected subscription instead of recreating a new one. ```ts ... const result = await authClient.subscription.upgrade({ plan: plan.name, seats, subscriptionId: subscription.stripeSubscriptionId, }); ... ``` ### What version of Better Auth are you using? 1.2.9-beta.9 ### Provide environment information ```bash - OS: Arch - Browser: all ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, plugins: [ stripe({ stripeClient, stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET, subscription: { authorizeReference() { return true; }, enabled: true, organization: { enabled: true, }, plans, }, })] }); ``` ### Additional context The subscription to update is fetched here: https://github.com/better-auth/better-auth/blob/335e6be0bf9557a06dd01c9f8b59423f40f39a24/packages/stripe/src/index.ts#L200-L216 But when trying to upgrade the selected subscription, it uses the subscriptionId from the request and not the one from the subscription fetched. https://github.com/better-auth/better-auth/blob/335e6be0bf9557a06dd01c9f8b59423f40f39a24/packages/stripe/src/index.ts#L263-L275
GiteaMirror added the locked label 2026-04-13 04:50: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#9404