refactor(dokploy): remove stripe from global scope

This commit is contained in:
Mauricio Siu
2024-10-24 01:10:17 -06:00
parent bcc7afa3e4
commit fa053b4d1f
2 changed files with 5 additions and 11 deletions

View File

@@ -6,11 +6,6 @@ import { asc, eq } from "drizzle-orm";
import type { NextApiRequest, NextApiResponse } from "next";
import Stripe from "stripe";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
apiVersion: "2024-09-30.acacia",
maxNetworkRetries: 3,
});
const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET || "";
export const config = {
@@ -26,6 +21,11 @@ export default async function handler(
if (!endpointSecret) {
return res.status(400).send("Webhook Error: Missing Stripe Secret Key");
}
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
apiVersion: "2024-09-30.acacia",
maxNetworkRetries: 3,
});
const buf = await buffer(req);
const sig = req.headers["stripe-signature"] as string;