Skip to content

Commit

Permalink
fix: use Clerk ID for Redis key
Browse files Browse the repository at this point in the history
  • Loading branch information
rayokamoto committed Feb 17, 2024
1 parent 360da54 commit 632daab
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/app/api/payment/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down

0 comments on commit 632daab

Please sign in to comment.