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