Stripe Plugin bug

authClient.subscription.upgrade() does not work with prisma, it says a column is missing even though the prisma studio shows it exists, the neon dashboard says it exists, and I can access the field using the prisma adapter in my code no problem.

# SERVER_ERROR:  [Error [PrismaClientValidationError]:
Invalid `db[getModelName(model)].create()` invocation in
/home/dd0k/prog/site/.next/server/chunks/node_modules_better-auth_dist_27182c5e._.js:2804:62

  2801 if (!db[getModelName(model)]) {
  2802     throw new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$better$2d$auth$2f$dist$2f$shared$2f$better$2d$auth$2e$DdzSJf$2d$n$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["B"](`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
  2803 }
→ 2804 const result = await db[getModelName(model)].create({
         data: {
           id: "El1Rxk2gbJK2QEPIr7dsBzcukjN2rBc3",
           plan: "basic",
           referenceId: "oFzjRP9pngfBpN7lYf54aSdzU34NrWds",
           stripeCustomerId: "cus_Rs3OupAOBNGKM7",
           status: "incomplete",
           seats: 1,
       +   stripeSubscriptionId: String
         },
         select: undefined
       })

Argument `stripeSubscriptionId` is missing.] {
  clientVersion: '6.4.1'
}
 POST /api/auth/subscription/upgrade 500 in 3275ms
Solution
Probably because you made stripeSubscriptionId required in your schema.

Just go to your schema.prisma and remove the ? on stripeSubscriptionId: String?

It has to be optional because this val comes from stripe, and is put in the db down the line by the webhook handler built into better-auth
Was this page helpful?