From 07071dfc08742feab3250928c1606b7c0c7c0c95 Mon Sep 17 00:00:00 2001 From: Amir Fakhrullah Date: Mon, 17 Apr 2023 01:16:11 +0800 Subject: [PATCH] add unique --- prisma/schema.prisma | 3 +-- src/pages/api/webhooks/stripe.ts | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 72916a9..0ec31df 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -62,10 +62,9 @@ model Order { orderItems OrderItem[] createdAt DateTime @default(now()) updatedAt DateTime? - stripePaymentIntentId String? + stripePaymentIntentId String? @unique stripePaymentClientSecret String? - @@unique([stripePaymentIntentId, stripePaymentClientSecret]) @@index([userId]) } diff --git a/src/pages/api/webhooks/stripe.ts b/src/pages/api/webhooks/stripe.ts index 2b4fab8..69148ba 100644 --- a/src/pages/api/webhooks/stripe.ts +++ b/src/pages/api/webhooks/stripe.ts @@ -37,7 +37,6 @@ export default async function handler( const eventObj = event.data.object as Stripe.PaymentIntent; const stripePaymentIntentId = eventObj.id; - const stripePaymentIntentClientSecret = eventObj.client_secret; let status: Status | undefined; @@ -57,11 +56,10 @@ export default async function handler( break; } - if (stripePaymentIntentId && stripePaymentIntentClientSecret && status) { + if (stripePaymentIntentId && status) { await db.order.update({ where: { stripePaymentIntentId, - stripePaymentClientSecret: stripePaymentIntentClientSecret, }, data: { status,