Skip to content

Commit

Permalink
fix customer-created
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey committed Dec 21, 2024
1 parent edeb578 commit b128916
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 3 additions & 7 deletions apps/web/app/api/stripe/integration/webhook/customer-created.ts
Original file line number Diff line number Diff line change
@@ -35,8 +35,8 @@ export async function customerCreated(event: Stripe.Event) {
},
});

if (!link) {
return `Link with ID ${linkId} not found, skipping...`;
if (!link || !link.projectId) {
return `Link with ID ${linkId} not found or does not have a project, skipping...`;
}

// Check the customer is not already created
@@ -61,15 +61,11 @@ export async function customerCreated(event: Stripe.Event) {
stripeCustomerId: stripeCustomer.id,
projectConnectId: stripeAccountId,
externalId,
projectId: link.projectId,
linkId,
clickId,
clickedAt: new Date(clickData.timestamp + "Z"),
country: clickData.country,
project: {
connect: {
stripeConnectId: stripeAccountId,
},
},
},
});

7 changes: 5 additions & 2 deletions packages/prisma/schema/customer.prisma
Original file line number Diff line number Diff line change
@@ -4,17 +4,20 @@ model Customer {
email String?
avatar String? @db.LongText
externalId String?
stripeCustomerId String? @unique
linkId String?
clickId String?
clickedAt DateTime?
country String?
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
projectId String
projectConnectId String?
stripeCustomerId String? @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
link Link? @relation(fields: [linkId], references: [id])
sales Sale[]

0 comments on commit b128916

Please sign in to comment.