diff --git a/src/lib/payments.functions.ts b/src/lib/payments.functions.ts index 4a759c7..e21727d 100644 --- a/src/lib/payments.functions.ts +++ b/src/lib/payments.functions.ts @@ -51,13 +51,13 @@ export const createPaymentRequest = createServerFn({ method: "POST" }) }, ) .handler(async ({ data, context }) => { - const { userId } = context; + const { userId, supabase } = context; const stripe = getStripe(); const { totalCents, feeCents } = calcSurcharge(data.base_amount_cents); const origin = getOrigin(); - // Insert pending row first - const { data: row, error: insErr } = await supabaseAdmin + // Insert pending row first (uses authenticated client; RLS allows insert by auth users) + const { data: row, error: insErr } = await supabase .from("payment_requests") .insert({ recipient_name: data.recipient_name, @@ -110,7 +110,7 @@ export const createPaymentRequest = createServerFn({ method: "POST" }) metadata: { payment_request_id: row.id }, }); - await supabaseAdmin + await supabase .from("payment_requests") .update({ stripe_session_id: session.id,