diff --git a/src/app/(account)/settings/page.tsx b/src/app/(account)/settings/page.tsx index 1eecb0eb..f1bb3067 100644 --- a/src/app/(account)/settings/page.tsx +++ b/src/app/(account)/settings/page.tsx @@ -15,6 +15,7 @@ const verifyMembershipPayment = async (clerkId: string) => { // Get user's membership expiry date from the database const [{ membershipExpiresAt }] = await db .select({ + id: memberTable.id, membershipExpiresAt: memberTable.membershipExpiresAt, }) .from(memberTable) @@ -43,7 +44,7 @@ const verifyMembershipPayment = async (clerkId: string) => { await db .update(memberTable) .set({ membershipExpiresAt: expiryDate }) - .where(eq(memberTable.id, clerkId)); + .where(eq(memberTable.clerkId, clerkId)); // Delete key from Redis since it is no longer needed await redisClient.del(`payment:membership:${clerkId}`); diff --git a/src/app/api/payment/route.ts b/src/app/api/payment/route.ts index 1570a1bc..f5b504d9 100644 --- a/src/app/api/payment/route.ts +++ b/src/app/api/payment/route.ts @@ -9,7 +9,6 @@ import { env } from '@/env.mjs'; import { redisClient } from '@/lib/redis'; import { squareClient } from '@/lib/square'; import { currentUser } from '@clerk/nextjs'; -import type { NextRequest } from 'next/server'; import type { CreatePaymentLinkRequest } from 'square'; import { ApiError } from 'square'; import { z } from 'zod'; @@ -85,24 +84,3 @@ export async function POST(request: Request) { return new Response(null, { status: 500 }); } } - -// Get a Square payment -// See: https://developer.squareup.com/reference/square/payments-api/get-payment -export async function GET(request: NextRequest) { - const params = request.nextUrl.searchParams; - const paymentId = params.get('paymentId'); - - if (!paymentId) { - return new Response('Square payment ID must be provided', { status: 400 }); - } - - try { - const resp = await squareClient.paymentsApi.getPayment(paymentId); - return Response.json(resp.result.payment); - } catch (e) { - if (e instanceof ApiError) { - return new Response(JSON.stringify(e.errors), { status: e.statusCode }); - } - return new Response(null, { status: 500 }); - } -}