Unified · Split
| @@ -6,11 +6,6 @@ import { asc, eq } from "drizzle-orm"; · 5 unmodified lines | |||
| 6 | import type { NextApiRequest, NextApiResponse } from "next"; | 6 | import type { NextApiRequest, NextApiResponse } from "next"; |
| 7 | import Stripe from "stripe"; | 7 | import Stripe from "stripe"; |
| 8 | 8 | ||
| 9 | const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", { | ||
| 10 | apiVersion: "2024-09-30.acacia", | ||
| 11 | maxNetworkRetries: 3, | ||
| 12 | }); | ||
| 13 | |||
| 14 | const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET || ""; | 9 | const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET || ""; |
| 15 | 10 | ||
| 16 | export const config = { | 11 | export const config = { |
| @@ -26,6 +21,11 @@ export default async function handler( · 9 unmodified lines | |||
| 26 | if (!endpointSecret) { | 21 | if (!endpointSecret) { |
| 27 | return res.status(400).send("Webhook Error: Missing Stripe Secret Key"); | 22 | return res.status(400).send("Webhook Error: Missing Stripe Secret Key"); |
| 28 | } | 23 | } |
| 24 | const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", { | ||
| 25 | apiVersion: "2024-09-30.acacia", | ||
| 26 | maxNetworkRetries: 3, | ||
| 27 | }); | ||
| 28 | |||
| 29 | const buf = await buffer(req); | 29 | const buf = await buffer(req); |
| 30 | const sig = req.headers["stripe-signature"] as string; | 30 | const sig = req.headers["stripe-signature"] as string; |
| 31 | 31 | ||
| @@ -1,14 +1,8 @@ | |||
| 1 | import Stripe from "stripe"; | ||
| 2 | |||
| 3 | export const WEBSITE_URL = | 1 | export const WEBSITE_URL = |
| 4 | process.env.NODE_ENV === "development" | 2 | process.env.NODE_ENV === "development" |
| 5 | ? "http://localhost:3000" | 3 | ? "http://localhost:3000" |
| 6 | : "https://app.dokploy.com"; | 4 | : "https://app.dokploy.com"; |
| 7 | 5 | ||
| 8 | export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", { | ||
| 9 | apiVersion: "2024-09-30.acacia", | ||
| 10 | }); | ||
| 11 | |||
| 12 | const BASE_PRICE_MONTHLY_ID = process.env.BASE_PRICE_MONTHLY_ID || ""; // $4.00 | 6 | const BASE_PRICE_MONTHLY_ID = process.env.BASE_PRICE_MONTHLY_ID || ""; // $4.00 |
| 13 | 7 | ||
| 14 | const BASE_ANNUAL_MONTHLY_ID = process.env.BASE_ANNUAL_MONTHLY_ID || ""; // $7.99 | 8 | const BASE_ANNUAL_MONTHLY_ID = process.env.BASE_ANNUAL_MONTHLY_ID || ""; // $7.99 |