From ef5bf529c8eb0d64539d688fc4c25f882aca9fdc Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 18:16:58 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/lib/payments.functions.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lib/payments.functions.ts b/src/lib/payments.functions.ts index e21727d..12eeec1 100644 --- a/src/lib/payments.functions.ts +++ b/src/lib/payments.functions.ts @@ -124,8 +124,9 @@ export const createPaymentRequest = createServerFn({ method: "POST" }) export const refreshPaymentStatus = createServerFn({ method: "POST" }) .middleware([attachSupabaseAuth, requireSupabaseAuth]) .inputValidator((data: { id: string }) => data) - .handler(async ({ data }) => { - const { data: row } = await supabaseAdmin + .handler(async ({ data, context }) => { + const { supabase } = context; + const { data: row } = await supabase .from("payment_requests") .select("*") .eq("id", data.id) @@ -135,7 +136,7 @@ export const refreshPaymentStatus = createServerFn({ method: "POST" }) const stripe = getStripe(); const session = await stripe.checkout.sessions.retrieve(row.stripe_session_id); if (session.payment_status === "paid") { - await supabaseAdmin + await supabase .from("payment_requests") .update({ status: "paid", @@ -152,8 +153,8 @@ export const refreshPaymentStatus = createServerFn({ method: "POST" }) export const markPaymentEmailSent = createServerFn({ method: "POST" }) .middleware([attachSupabaseAuth, requireSupabaseAuth]) .inputValidator((data: { id: string }) => data) - .handler(async ({ data }) => { - await supabaseAdmin + .handler(async ({ data, context }) => { + await context.supabase .from("payment_requests") .update({ email_sent_at: new Date().toISOString() }) .eq("id", data.id); @@ -163,8 +164,8 @@ export const markPaymentEmailSent = createServerFn({ method: "POST" }) export const cancelPaymentRequest = createServerFn({ method: "POST" }) .middleware([attachSupabaseAuth, requireSupabaseAuth]) .inputValidator((data: { id: string }) => data) - .handler(async ({ data }) => { - await supabaseAdmin + .handler(async ({ data, context }) => { + await context.supabase .from("payment_requests") .update({ status: "canceled" }) .eq("id", data.id);