Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update charge-failed.ts

Kiran K9b8313b4366a
diff --git a/apps/web/app/(ee)/api/stripe/webhook/charge-failed.ts b/apps/web/app/(ee)/api/stripe/webhook/charge-failed.ts
index dce73529fa..2251d03de8 100644
--- a/apps/web/app/(ee)/api/stripe/webhook/charge-failed.ts
+++ b/apps/web/app/(ee)/api/stripe/webhook/charge-failed.ts
@@ -53,6 +53,18 @@ export async function chargeFailed(event: Stripe.Event) {
},
});
+ // Reduce the payoutsUsage by the invoice amount since the charge failed
+ await prisma.project.update({
+ where: {
+ id: invoice.workspaceId,
+ },
+ data: {
+ payoutsUsage: {
+ decrement: invoice.amount,
+ },
+ },
+ });
+
const workspace = await prisma.project.findUniqueOrThrow({
where: {
id: invoice.workspaceId,