PURCHASES_OPEN (default false) keeps Stripe purchases to admins, also with a live key, so nobody types a real card before the opening. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
13 lines
540 B
TypeScript
13 lines
540 B
TypeScript
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";
|
|
}
|