Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
901f50cb01
commit
86b08b8072
@@ -176,15 +176,10 @@ export const cancelPaymentRequest = createServerFn({ method: "POST" })
|
||||
export const getPublicPaymentRequest = createServerFn({ method: "GET" })
|
||||
.inputValidator((data: { id: string }) => data)
|
||||
.handler(async ({ data }) => {
|
||||
// Use anon-key client; RLS policy "pr_select_public_by_id" allows public reads
|
||||
const { createClient } = await import("@supabase/supabase-js");
|
||||
const url = process.env.SUPABASE_URL;
|
||||
const anonKey = process.env.SUPABASE_PUBLISHABLE_KEY;
|
||||
if (!url || !anonKey) throw new Error("Supabase env not configured");
|
||||
const sb = createClient(url, anonKey, {
|
||||
auth: { persistSession: false, autoRefreshToken: false },
|
||||
});
|
||||
const { data: row } = await sb
|
||||
// Use service-role client to bypass RLS; return only a strict whitelist
|
||||
// of non-sensitive fields for the public pay page.
|
||||
const { supabaseAdmin } = await import("@/integrations/supabase/client.server");
|
||||
const { data: row } = await supabaseAdmin
|
||||
.from("payment_requests")
|
||||
.select(
|
||||
"id, recipient_name, description, base_amount_cents, fee_amount_cents, total_amount_cents, currency, status, stripe_checkout_url, paid_at",
|
||||
|
||||
Reference in New Issue
Block a user