[GH-ISSUE #2258] [BUG] Incorrect API call when restoring a cancelled stripe subscription #9117

Closed
opened 2026-04-13 04:28:17 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @Konixy on GitHub (Apr 13, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2258

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Restore a cancelled subscription by calling authClient.subscription.restore() (propably specific to sveltekit using better-auth/svelte's createAuthClient() method)

Current vs. Expected behavior

When calling the subscription.restore method from the auth client, it returns a 404 error from a GET request:

Image

Figured out when looking a the plugin code that the auth client should be douing a POST request instead of a GET request.

Here is my auth-client.ts:

import { stripeClient } from '@better-auth/stripe/client';
import { emailOTPClient } from 'better-auth/client/plugins';
import { createAuthClient } from 'better-auth/svelte';

export const authClient = createAuthClient({
	plugins: [
		emailOTPClient(),
		stripeClient({
			subscription: true
		})
	]
});

What version of Better Auth are you using?

1.2.6

Provide environment information

- OS: MacOS Sequoia 15.4
- Browser: Arc (chromium)

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

Package

Auth config (if applicable)

import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import prisma from './prisma';
import { emailOTP } from 'better-auth/plugins';
import { sendOTP, sendTrialEmail } from './resend';
import { stripe } from '@better-auth/stripe';
import Stripe from 'stripe';
import {
	STRIPE_SECRET_KEY,
	STRIPE_WEBHOOK_SECRET,
	STRIPE_PRICE_ID,
	STRIPE_YEARLY_PRICE_ID
} from '$env/static/private';
import { Locale } from '@prisma/client';

const stripeClient = new Stripe(STRIPE_SECRET_KEY);

export const auth = betterAuth({
	plugins: [
		emailOTP({
			async sendVerificationOTP(data) {
				console.log('sendVerificationOTP', data);
				await sendOTP(data);
			}
		}),
		stripe({
			stripeClient,
			stripeWebhookSecret: STRIPE_WEBHOOK_SECRET,
			createCustomerOnSignUp: true,
			subscription: {
				enabled: true,
				plans: [
					{
						name: 'pro',
						priceId: STRIPE_PRICE_ID,
						annualDiscountPriceId: STRIPE_YEARLY_PRICE_ID,
						freeTrial: {
							days: 30
						}
					}
				],
				requireEmailVerification: true,
				getCheckoutSessionParams() {
					return {
						params: {
							payment_method_collection: 'if_required'
						}
					};
				}
			}
		})
	],
	database: prismaAdapter(prisma, {
		provider: 'mongodb'
	}),
	emailAndPassword: {
		enabled: true
	},
	user: {
		additionalFields: {
			currency: {
				type: 'string',
				required: false,
				default: 'DEFAULT'
			},
			locale: {
				type: 'string',
				required: true,
				default: 'en'
			}
		}
	},
	databaseHooks: {
		user: {
			create: {
				async before(user, context) {
					let locale = 'en';

					if (
						context?.body.locale &&
						typeof context.body.locale === 'string' &&
						Object.values(Locale).includes(context.body.locale)
					) {
						locale = context.body.locale;
					}

					return { data: { ...user, locale } };
				}
			}
		}
	}
});

Additional context

I'm using sveltekit 2.20.5. Tried uninstalling and reinstalling dependencies multiple times and even deleting the .svelte-kit folder and rebuilding again but didn't worked.

Originally created by @Konixy on GitHub (Apr 13, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2258 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Restore a cancelled subscription by calling `authClient.subscription.restore()` (propably specific to sveltekit using `better-auth/svelte`'s `createAuthClient()` method) ### Current vs. Expected behavior When calling the `subscription.restore` method from the auth client, it returns a 404 error from a `GET` request: ![Image](https://github.com/user-attachments/assets/1fe441e0-463b-466b-8b39-6500b0f74767) Figured out when looking a [the plugin code](https://github.com/better-auth/better-auth/commit/8263382b#diff-ccb5282d4490ceec8e8c99f978be2383dd1915db21316f3baba6066420070b08R621) that the auth client should be douing a `POST` request instead of a `GET` request. Here is my `auth-client.ts`: ```ts import { stripeClient } from '@better-auth/stripe/client'; import { emailOTPClient } from 'better-auth/client/plugins'; import { createAuthClient } from 'better-auth/svelte'; export const authClient = createAuthClient({ plugins: [ emailOTPClient(), stripeClient({ subscription: true }) ] }); ``` ### What version of Better Auth are you using? 1.2.6 ### Provide environment information ```bash - OS: MacOS Sequoia 15.4 - Browser: Arc (chromium) ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { betterAuth } from 'better-auth'; import { prismaAdapter } from 'better-auth/adapters/prisma'; import prisma from './prisma'; import { emailOTP } from 'better-auth/plugins'; import { sendOTP, sendTrialEmail } from './resend'; import { stripe } from '@better-auth/stripe'; import Stripe from 'stripe'; import { STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, STRIPE_PRICE_ID, STRIPE_YEARLY_PRICE_ID } from '$env/static/private'; import { Locale } from '@prisma/client'; const stripeClient = new Stripe(STRIPE_SECRET_KEY); export const auth = betterAuth({ plugins: [ emailOTP({ async sendVerificationOTP(data) { console.log('sendVerificationOTP', data); await sendOTP(data); } }), stripe({ stripeClient, stripeWebhookSecret: STRIPE_WEBHOOK_SECRET, createCustomerOnSignUp: true, subscription: { enabled: true, plans: [ { name: 'pro', priceId: STRIPE_PRICE_ID, annualDiscountPriceId: STRIPE_YEARLY_PRICE_ID, freeTrial: { days: 30 } } ], requireEmailVerification: true, getCheckoutSessionParams() { return { params: { payment_method_collection: 'if_required' } }; } } }) ], database: prismaAdapter(prisma, { provider: 'mongodb' }), emailAndPassword: { enabled: true }, user: { additionalFields: { currency: { type: 'string', required: false, default: 'DEFAULT' }, locale: { type: 'string', required: true, default: 'en' } } }, databaseHooks: { user: { create: { async before(user, context) { let locale = 'en'; if ( context?.body.locale && typeof context.body.locale === 'string' && Object.values(Locale).includes(context.body.locale) ) { locale = context.body.locale; } return { data: { ...user, locale } }; } } } } }); ``` ### Additional context I'm using sveltekit 2.20.5. Tried uninstalling and reinstalling dependencies multiple times and even deleting the `.svelte-kit` folder and rebuilding again but didn't worked.
GiteaMirror added the locked label 2026-04-13 04:28:17 -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#9117