Skip to content

Commit

Permalink
reply to webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
spolu committed Nov 4, 2023
1 parent 754232a commit a6d0e3b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions front/pages/api/stripe/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async function handler(
},
`[Stripe Webhook] Received checkout.session.completed with status "${session.status}". Ignoring event.`
);
return;
return res.status(200).json({ success: true });
}
if (session.status !== "complete") {
logger.error(
Expand All @@ -113,7 +113,7 @@ async function handler(
},
`[Stripe Webhook] Received checkout.session.completed with unkown status "${session.status}". Ignoring event.`
);
return;
return res.status(200).json({ success: true });
}

try {
Expand Down Expand Up @@ -142,7 +142,7 @@ async function handler(
);
}

return await front_sequelize.transaction(async (t) => {
await front_sequelize.transaction(async (t) => {
const now = new Date();
const activeSubscription = await Subscription.findOne({
where: { workspaceId: workspace.id, status: "active" },
Expand Down Expand Up @@ -188,6 +188,8 @@ async function handler(
{ transaction: t }
);
});

return res.status(200).json({ success: true });
} catch (error) {
logger.error(
{
Expand All @@ -199,6 +201,7 @@ async function handler(
},
"Error creating subscription."
);

return apiError(req, res, {
status_code: 500,
api_error: {
Expand Down Expand Up @@ -267,7 +270,7 @@ async function handler(
// Unhandled event type
}

return;
return res.status(200).json({ success: true });

default:
return apiError(req, res, {
Expand Down

0 comments on commit a6d0e3b

Please sign in to comment.