mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-27 09:32:20 -05:00
fix(stripe): Throw err if passed referenceId when no subscription authorizeReference` is defined (#2129)
* fix(stripe): Throw err if passed `referenceId` when no `subscription.authorizeReference` is defined * fix: typo
This commit is contained in:
@@ -66,6 +66,13 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
||||
}
|
||||
const referenceId =
|
||||
ctx.body?.referenceId || ctx.query?.referenceId || session.user.id;
|
||||
|
||||
if (ctx.body?.referenceId && !options.subscription?.authorizeReference) {
|
||||
logger.error(`Passing referenceId into a subscription action isn't allowed if subscription.authorizeReference isn't defined in your stripe plugin config.`)
|
||||
throw new APIError("BAD_REQUEST", {
|
||||
message: "Reference id is not allowed. Read server logs for more details.",
|
||||
});
|
||||
}
|
||||
const isAuthorized = ctx.body?.referenceId
|
||||
? await options.subscription?.authorizeReference?.({
|
||||
user: session.user,
|
||||
|
||||
Reference in New Issue
Block a user