fix docker build error
This commit is contained in:
@@ -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,
|
||||||
|
@@ -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");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user