Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion apps/web/app/(ee)/api/stripe/webhook/charge-succeeded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,29 @@ export async function chargeSucceeded(event: Stripe.Event) {
const { transfer_group: invoiceId } = charge;

if (!invoiceId) {
console.log("No transfer group found, skipping...");
// check if the customer's workspace has paymentFailedAt, if so, reset it to null
const stripeId = charge.customer as string;
if (stripeId) {
const workspace = await prisma.project.findUnique({
where: {
stripeId,
},
});
if (workspace?.paymentFailedAt) {
console.log("Workspace has paymentFailedAt, resetting it to null...");
await prisma.project.update({
where: {
id: workspace.id,
},
data: {
paymentFailedAt: null,
},
});
}
}
console.log(
"No transfer_group (invoiceId) found, skipping invoice update flow...",
);
return;
}

Expand Down