The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Use updateCustomerWithStripeCustomerId in invoice.paid
Rafi0ce4fe22fc00
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.tsindex 1d15caa51c..6a1136e27e 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@@ -21,6 +21,7 @@ import { WebhookHandlerInput, WebhookHandlerResponse } from "./types";import { attributeViaPromotionCodeId } from "./utils/attribute-via-promotion-code-id";import { getConnectedCustomer } from "./utils/get-connected-customer";import { getDubCustomerExternalIdFromMetadata } from "./utils/get-dub-customer-external-id-from-metadata";+import { updateCustomerWithStripeCustomerId } from "./utils/update-customer-with-stripe-customer-id";// Handle event "invoice.paid"export async function invoicePaid({@@ -65,22 +66,11 @@ export async function invoicePaid({);if (dubCustomerExternalId) {- try {- // Update customer with stripeCustomerId if exists – for future events- customer = await prisma.customer.update({- where: {- projectConnectId_externalId: {- projectConnectId: stripeAccountId,- externalId: dubCustomerExternalId,- },- },- data: {- stripeCustomerId,- },- });- } catch (error) {- console.log(error);- }+ customer = await updateCustomerWithStripeCustomerId({+ workspaceId: workspace.id,+ dubCustomerExternalId,+ stripeCustomerId,+ });}}