Files
courier/lib/pricing.ts
T
2026-11-23 10:55:47 +00:00

75 lines
1.8 KiB
TypeScript

export type SesPlan = {
id: string;
name: string;
base: number;
tiers: { upTo: number | null; rate: number }[];
note: string;
};
export const SES_PLANS: SesPlan[] = [
{
id: "a-la-carte",
name: "À la carte",
base: 0,
tiers: [{ upTo: null, rate: 0.1 }],
note: "Pay-as-you-go, keine Grundgebühr.",
},
{
id: "essentials",
name: "Essentials",
base: 0,
tiers: [
{ upTo: 10_000_000, rate: 0.16 },
{ upTo: 100_000_000, rate: 0.14 },
{ upTo: null, rate: 0.11 },
],
note: "Standard für neue SES-Konten, ohne Grundgebühr.",
},
{
id: "pro",
name: "Pro",
base: 105,
tiers: [
{ upTo: 10_000_000, rate: 0.22 },
{ upTo: 100_000_000, rate: 0.17 },
{ upTo: null, rate: 0.12 },
],
note: "Mit Dedicated IPs und erweiterten Deliverability-Funktionen.",
},
{
id: "enterprise",
name: "Enterprise",
base: 500,
tiers: [
{ upTo: 10_000_000, rate: 0.23 },
{ upTo: 100_000_000, rate: 0.18 },
{ upTo: null, rate: 0.13 },
],
note: "Mehrere Domains, viele Dedicated IPs und Seedlist-Tests.",
},
];
export function estimateMonthly(plan: SesPlan, volume: number): number {
let remaining = Math.max(0, Math.floor(volume));
let last = 0;
let cost = plan.base;
for (const tier of plan.tiers) {
const limit = tier.upTo === null ? remaining : Math.min(remaining, tier.upTo - last);
if (limit <= 0) break;
cost += (limit / 1000) * tier.rate;
remaining -= limit;
last = tier.upTo ?? last;
if (remaining <= 0) break;
}
return cost;
}
export function usd(value: number): string {
return new Intl.NumberFormat("de-DE", {
style: "currency",
currency: "USD",
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(value);
}