- Split the donate page into step components and reorder the flow: intent, rank or amount, recipient, gift, upgrade target, then confirm - Let a gift go to a player on the other edition, and allow anonymous gifts (donor is left blank in metadata) - Look up the recipient's current rank for upgrades and disable ranks they already hold - Validate custom amounts on the server as integers between CUSTOM_MIN and CUSTOM_MAX - Show friendly messages for checkout errors and send users back to the step that needs fixing - Build the Stripe appearance from the page's glow accent colour, and tint the glow to match a custom amount's unlocked tier
37 lines
1.9 KiB
TypeScript
37 lines
1.9 KiB
TypeScript
export type TierId = "iron" | "gold" | "diamond" | "patron" | "custom";
|
|
export const TIERS = {
|
|
iron: { id: "iron" as const, label: "Iron", price: 300, group: "iron", weight: 10, perks: ["Iron prefix & grey name", "/hat cosmetics", "Supporter role"], popular: false },
|
|
gold: { id: "gold" as const, label: "Gold", price: 500, group: "gold", weight: 20, perks: ["All Iron perks", "Gold prefix & particles", "/nick + join effects"], popular: true },
|
|
diamond: { id: "diamond" as const, label: "Diamond", price: 700, group: "diamond", weight: 30, perks: ["All Gold perks", "Diamond prefix & aqua glow", "All pets, hats & morphs"], popular: false },
|
|
patron: { id: "patron" as const, label: "Patron", price: 500, group: "patron", weight: 40, subscription: true, perks: ["All Diamond perks", "Patron badge & extras", "Ongoing support"], popular: false },
|
|
} as const;
|
|
|
|
export const TIER_ORDER: TierId[] = ["iron", "gold", "diamond"];
|
|
|
|
export function upgradePrice(from: TierId, to: TierId): number | null {
|
|
const f = (TIERS as any)[from]?.price;
|
|
const t = (TIERS as any)[to]?.price;
|
|
if (f == null || t == null) return null;
|
|
const diff = t - f;
|
|
return diff > 0 ? diff : null;
|
|
}
|
|
|
|
// One-time custom: highest tier affordable in that payment.
|
|
// Recurring custom: >=£5/mo acts as Patron, <£5 cumulative unlocks tiers.
|
|
export function tierForAmount(pence: number): TierId | null {
|
|
if (pence >= TIERS.diamond.price) return "diamond";
|
|
if (pence >= TIERS.gold.price) return "gold";
|
|
if (pence >= TIERS.iron.price) return "iron";
|
|
return null;
|
|
}
|
|
export function tierForCumulative(pence: number): TierId | null {
|
|
return tierForAmount(pence);
|
|
}
|
|
export function tierForCustom(pence: number, recurring?: boolean): TierId | null {
|
|
if (recurring && pence >= TIERS.patron.price) return "patron";
|
|
return tierForAmount(pence);
|
|
}
|
|
|
|
// Custom donation limits, in pence. The checkout route enforces the same bounds.
|
|
export const CUSTOM_MIN = 100;
|
|
export const CUSTOM_MAX = 100_000;
|