From 632daab0ab6b8f6220d9c027dd12f4742c6c1b32 Mon Sep 17 00:00:00 2001 From: Ray <22254748+rayokamoto@users.noreply.github.com> Date: Sat, 17 Feb 2024 15:35:30 +1030 Subject: [PATCH] fix: use Clerk ID for Redis key --- src/app/api/payment/route.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/app/api/payment/route.ts b/src/app/api/payment/route.ts index f94c8e4e..1226ab6d 100644 --- a/src/app/api/payment/route.ts +++ b/src/app/api/payment/route.ts @@ -70,16 +70,10 @@ export async function POST(request: Request) { const resp = await squareClient.checkoutApi.createPaymentLink(body); if (reqBody.data.product === 'membership') { - // Add user ID and payment ID to Redis cache - const [{ id: userId }] = await db - .select({ - id: memberTable.id, - }) - .from(memberTable) - .where(eq(memberTable.clerkId, user.id)); + // Add Clerk ID and payment ID to Redis cache const paymentId = resp.result.paymentLink?.id ?? ''; const createdAt = resp.result.paymentLink?.createdAt ?? ''; - await redisClient.hSet(`payment:membership:${userId}`, { + await redisClient.hSet(`payment:membership:${user.id}`, { paymentId: paymentId, createdAt: createdAt, });