CREATE OR REPLACE FUNCTION public.get_association_payment_gateways(p_association_id uuid) RETURNS jsonb LANGUAGE sql STABLE SECURITY DEFINER SET search_path TO 'public' AS $function$ SELECT jsonb_build_object( 'stripe', ( SELECT jsonb_build_object( 'id', id, 'association_id', association_id, 'stripe_account_id', stripe_account_id, 'stripe_public_key', stripe_public_key, 'is_active', is_active, 'label', label, 'pass_processing_fee', pass_processing_fee, 'processing_fee_percent', processing_fee_percent, 'processing_fee_fixed_cents', processing_fee_fixed_cents ) FROM public.stripe_account_mappings WHERE association_id = p_association_id AND is_active = true LIMIT 1 ) ); $function$;