fix: billing webhook secret (#17005)

* fix: billing webhook secret

* Update __handler.test.ts
This commit is contained in:
Omar López
2024-10-08 21:26:39 +00:00
committed by GitHub
parent 343e2ac9d7
commit 2bdf65ce8c
3 changed files with 6 additions and 5 deletions
@@ -19,11 +19,11 @@ vi.mock("@calcom/app-store/stripepayment/lib/server", () => ({
},
}));
const STRIPE_WEBHOOK_SECRET = "whsec_test_secret";
const STRIPE_WEBHOOK_SECRET_BILLING = "whsec_test_secret";
describe("stripeWebhookHandler", () => {
beforeEach(() => {
vi.stubEnv("STRIPE_WEBHOOK_SECRET", STRIPE_WEBHOOK_SECRET);
vi.stubEnv("STRIPE_WEBHOOK_SECRET_BILLING", STRIPE_WEBHOOK_SECRET_BILLING);
});
const mockRequest = (headers: Record<string, string>, body: string): NextApiRequest =>
@@ -41,8 +41,8 @@ describe("stripeWebhookHandler", () => {
await expect(handler(req)).rejects.toThrow(new HttpCode(400, "Missing stripe-signature"));
});
it("should throw an error if STRIPE_WEBHOOK_SECRET is missing", async () => {
vi.stubEnv("STRIPE_WEBHOOK_SECRET", "");
it("should throw an error if STRIPE_WEBHOOK_SECRET_BILLING is missing", async () => {
vi.stubEnv("STRIPE_WEBHOOK_SECRET_BILLING", "");
const { req } = createMocks<CustomNextApiRequest, CustomNextApiResponse>({
method: "POST",
headers: {
@@ -42,7 +42,7 @@ export class HttpCode extends HttpError {
* ```
*/
export const stripeWebhookHandler = (handlers: SWHandlers) => async (req: NextApiRequest) => {
const STRIPE_WEBHOOK_SECRET = process.env.STRIPE_WEBHOOK_SECRET;
const STRIPE_WEBHOOK_SECRET = process.env.STRIPE_WEBHOOK_SECRET_BILLING;
const sig = req.headers["stripe-signature"];
if (!sig) throw new HttpCode(400, "Missing stripe-signature");
if (!STRIPE_WEBHOOK_SECRET) throw new HttpCode(500, "Missing STRIPE_WEBHOOK_SECRET");
+1
View File
@@ -407,6 +407,7 @@
"STRIPE_PRODUCT_ID_STARTER",
"STRIPE_WEBHOOK_SECRET",
"STRIPE_WEBHOOK_SECRET_APPS",
"STRIPE_WEBHOOK_SECRET_BILLING",
"TANDEM_BASE_URL",
"TANDEM_CLIENT_ID",
"TANDEM_CLIENT_SECRET",