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 invoice-paid.ts

Kiran K725718bb70c1
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
index 717f5d9b38..d5f2f8b5c9 100644
--- a/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
@@ -223,65 +223,65 @@ export async function invoicePaid({
});
const [_sale, linkUpdated, , customerUpdated] = await Promise.all([
- recordSale(saleData),
+ recordSale(saleData),
- // update link stats
- prisma.link.update({
- where: {
- id: linkId,
- },
- data: {
- ...(firstConversionFlag && {
- conversions: {
- increment: 1,
- },
- lastConversionAt: new Date(),
- }),
- sales: {
+ // update link stats
+ prisma.link.update({
+ where: {
+ id: linkId,
+ },
+ data: {
+ ...(firstConversionFlag && {
+ conversions: {
increment: 1,
},
- saleAmount: {
- increment: invoiceSaleAmount,
- },
+ lastConversionAt: new Date(),
+ }),
+ sales: {
+ increment: 1,
},
- include: includeTags,
- }),
-
- // update workspace sales usage
- prisma.project.update({
- where: {
- id: customer.projectId,
+ saleAmount: {
+ increment: invoiceSaleAmount,
},
- data: {
- usage: {
- increment: 1,
- },
+ },
+ include: includeTags,
+ }),
+
+ // update workspace sales usage
+ prisma.project.update({
+ where: {
+ id: customer.projectId,
+ },
+ data: {
+ usage: {
+ increment: 1,
},
- }),
+ },
+ }),
- // update customer sales count
- prisma.customer.update({
- where: {
- id: customer.id,
+ // update customer sales count
+ prisma.customer.update({
+ where: {
+ id: customer.id,
+ },
+ data: {
+ ...(link?.programId && {
+ programId: link.programId,
+ }),
+ ...(link?.partnerId && {
+ partnerId: link.partnerId,
+ }),
+ sales: {
+ increment: 1,
},
- data: {
- ...(link?.programId && {
- programId: link.programId,
- }),
- ...(link?.partnerId && {
- partnerId: link.partnerId,
- }),
- sales: {
- increment: 1,
- },
- saleAmount: {
- increment: invoiceSaleAmount,
- },
- firstSaleAt: customer.firstSaleAt ? undefined : new Date(),
- subscriptionCanceledAt: null,
+ saleAmount: {
+ increment: invoiceSaleAmount,
},
- }),
- ]);
+ firstSaleAt: customer.firstSaleAt ? undefined : new Date(),
+ subscriptionCanceledAt: null,
+ },
+ }),
+ ]);
// for program links
let result: