fix docker build error

This commit is contained in:
KMKoushik
2025-03-23 12:59:32 +11:00
parent 3eef910544
commit eb1f8e4fe6
2 changed files with 4 additions and 7 deletions

View File

@@ -2,12 +2,7 @@ import { headers } from "next/headers";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import Stripe from "stripe"; import Stripe from "stripe";
import { env } from "~/env"; import { env } from "~/env";
import { syncStripeData } from "~/server/billing/payments"; import { getStripe, syncStripeData } from "~/server/billing/payments";
import { db } from "~/server/db";
const stripe = new Stripe(env.STRIPE_SECRET_KEY!, {
apiVersion: "2025-01-27.acacia",
});
const allowedEvents: Stripe.Event.Type[] = [ const allowedEvents: Stripe.Event.Type[] = [
"checkout.session.completed", "checkout.session.completed",
@@ -44,6 +39,8 @@ export async function POST(req: Request) {
return new NextResponse("No webhook secret", { status: 400 }); return new NextResponse("No webhook secret", { status: 400 });
} }
const stripe = getStripe();
try { try {
const event = stripe.webhooks.constructEvent( const event = stripe.webhooks.constructEvent(
body, body,

View File

@@ -2,7 +2,7 @@ import Stripe from "stripe";
import { env } from "~/env"; import { env } from "~/env";
import { db } from "../db"; import { db } from "../db";
function getStripe() { export function getStripe() {
if (!env.STRIPE_SECRET_KEY) { if (!env.STRIPE_SECRET_KEY) {
throw new Error("STRIPE_SECRET_KEY is not set"); throw new Error("STRIPE_SECRET_KEY is not set");
} }