Files
sorsfonalak/services/frontend/src/lib/payments.ts
T

10 lines
446 B
TypeScript
Raw Normal View History

2026-11-20 06:41:21 +00:00
import type { Me, PayMethod, PublicConfig } from "./types";
/** How this user can buy packages (with a Stripe test key: admins only). */
export function payMethod(config: PublicConfig | null | undefined, me: Me): PayMethod | null {
if (config?.payments === "mock") return "mock";
if (config?.payments !== "stripe") return null;
if (!config.payments_test) return "stripe";
return me.user.roles.includes("admin") ? "stripe_test" : null;
}