10 lines
446 B
TypeScript
10 lines
446 B
TypeScript
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;
|
||
|
|
}
|