Skip to content

Commit

Permalink
Fixes error when user cancels stripe integration (calcom#813)
Browse files Browse the repository at this point in the history
* Fixes customer portal return ur

* Attempt to fix portal CSRF issue

* Fixes CSRF issue with Stripe redirect

* Fixes error when user cancels stripe integration
  • Loading branch information
zomars authored Sep 28, 2021
1 parent f8a4f81 commit 7a8ad83
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ee/pages/api/integrations/stripepayment/callback.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Prisma } from "@prisma/client";
import type { NextApiRequest, NextApiResponse } from "next";
import { stringify } from "querystring";

import stripe, { StripeData } from "@ee/lib/stripe/server";

import { getSession } from "@lib/auth";
import prisma from "@lib/prisma";

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { code } = req.query;
const { code, error, error_description } = req.query;
// Check that user is authenticated
const session = await getSession({ req: req });

Expand All @@ -16,6 +17,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
return;
}

if (error) {
const query = stringify({ error, error_description });
res.redirect("/integrations?" + query);
return;
}

const response = await stripe.oauth.token({
grant_type: "authorization_code",
code: code.toString(),
Expand Down

0 comments on commit 7a8ad83

Please sign in to comment.