Packages paid through Stripe Checkout
The catalog stays in packages.rs: every checkout session carries the package's name and gross price, nothing has to be kept in Stripe. The package is granted once, when Stripe confirms the payment: by the signed webhook, or by the return page asking Stripe when the webhook is late. With a test key only admins can buy, so Stripe's test cards give nobody free packages. Without the keys nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
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;
|
||||
}
|
||||
@@ -92,6 +92,10 @@ export interface PublicConfig {
|
||||
password_login: boolean;
|
||||
password_min_length: number;
|
||||
mock_payments: boolean;
|
||||
/** How packages are paid: Stripe Checkout, the stand-in, or not at all. */
|
||||
payments: "stripe" | "mock" | null;
|
||||
/** Stripe has a test key: only admins can buy. */
|
||||
payments_test: boolean;
|
||||
/** "invite": new accounts need an invitation. */
|
||||
signup_mode: "invite" | "open";
|
||||
/** Users may invite others (off until the launch; admins always may). */
|
||||
@@ -573,3 +577,6 @@ export interface PersonInviteLanding {
|
||||
status: "pending" | "accepted" | "expired";
|
||||
expires_at: string;
|
||||
}
|
||||
|
||||
/** How this user can buy a package; `null`: purchases are off. */
|
||||
export type PayMethod = "stripe" | "stripe_test" | "mock";
|
||||
|
||||
Reference in New Issue
Block a user