fix(stripe): improve subscription cancellation handling and add callback endpoint

This commit is contained in:
Bereket Engida
2025-03-02 11:39:57 +03:00
parent 1d700f38f1
commit 1c91294e23
10 changed files with 254 additions and 83 deletions

View File

@@ -20,7 +20,6 @@ import { nextCookies } from "better-auth/next-js";
import { passkey } from "better-auth/plugins/passkey";
import { stripe } from "@better-auth/stripe";
import { Stripe } from "stripe";
import Database from "better-sqlite3";
const from = process.env.BETTER_AUTH_EMAIL || "delivered@resend.dev";
const to = process.env.TEST_EMAIL || "";
@@ -51,7 +50,10 @@ const STARTER_PRICE_ID = {
export const auth = betterAuth({
appName: "Better Auth Demo",
database: new Database("./stripe.db"),
database: {
dialect,
type: process.env.USE_MYSQL ? "mysql" : "sqlite",
},
emailVerification: {
async sendVerificationEmail({ user, url }) {
const res = await resend.emails.send({
@@ -163,7 +165,6 @@ export const auth = betterAuth({
stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
subscription: {
enabled: true,
requireEmailVerification: true,
plans: [
{
name: "Starter",