import type { Me, PayMethod, PublicConfig } from "./types"; /** * How this user can buy packages. Until purchases open (and with a Stripe * test key) only admins can; everyone else sees "soon". */ 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_admins_only && !me.user.roles.includes("admin")) return null; return config.payments_test ? "stripe_test" : "stripe"; }