From 4f917322812f866db8e523a2471ed7459d684322 Mon Sep 17 00:00:00 2001 From: "Yeyang (Justin) Sun" Date: Sun, 18 Feb 2024 22:22:21 +1030 Subject: [PATCH] fix(server): member `undefined` when verify payment (#66) --- src/server/verify-membership-payment.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/verify-membership-payment.ts b/src/server/verify-membership-payment.ts index 352e555f..38295e3c 100644 --- a/src/server/verify-membership-payment.ts +++ b/src/server/verify-membership-payment.ts @@ -7,7 +7,7 @@ import { updateMemberExpiryDate } from './update-member-expiry-date'; export const verifyMembershipPayment = async (clerkId: string) => { // Get user's membership expiry date from the database - const [{ membershipExpiresAt }] = await db + const [member] = await db .select({ id: memberTable.id, membershipExpiresAt: memberTable.membershipExpiresAt, @@ -15,8 +15,8 @@ export const verifyMembershipPayment = async (clerkId: string) => { .from(memberTable) .where(eq(memberTable.clerkId, clerkId)); // If membership expiry date exists, return the existing date - if (membershipExpiresAt) { - return { paid: true as const, membershipExpiresAt }; + if (member && member.membershipExpiresAt) { + return { paid: true as const, membershipExpiresAt: member.membershipExpiresAt }; } const paymentId = await redisClient.hGet(`payment:membership:${clerkId}`, 'paymentId');