Update subscription pricing and improve subscription handling

- Changed subscription cancellation message from "Ends on" to "Cancels on" for clarity.
- Updated subscription data structure to require `cancelAtPeriodEnd` field.
- Adjusted Stripe pricing for various plans, increasing monthly and annual prices.
- Modified pricing display logic in the PricingSection component to reflect new prices.
- Increased default event limit for users without an active subscription from 10,000 to 100,000.
- Enhanced subscription retrieval to include `cancelAtPeriodEnd` status.
This commit is contained in:
Bill Yang 2025-05-03 22:17:41 -07:00
parent 696c6b6145
commit e1adb3a2a3
7 changed files with 20 additions and 18 deletions

View file

@ -101,7 +101,7 @@ export function ProPlan() {
const formattedDate = formatDate(activeSubscription.currentPeriodEnd);
if (activeSubscription.cancelAtPeriodEnd) {
return `Ends on ${formattedDate}`;
return `Cancels on ${formattedDate}`;
}
if (activeSubscription.status === "active") {
return isAnnualPlan

View file

@ -9,7 +9,7 @@ interface SubscriptionData {
monthlyEventCount: number;
eventLimit: number;
interval: string;
cancelAtPeriodEnd?: boolean;
cancelAtPeriodEnd: boolean;
isTrial?: boolean;
trialDaysRemaining?: number;
message?: string; // For expired trial message

View file

@ -91,8 +91,8 @@ export const STRIPE_PRICES = [
},
{
name: "pro5m",
priceId: "price_1R2kybDFVprnAny21Mo1Wjuz",
price: 129,
priceId: "price_1RKuYJDFVprnAny2apEXvkde",
price: 149,
interval: "month",
limits: {
events: 5_000_000,
@ -100,8 +100,8 @@ export const STRIPE_PRICES = [
},
{
name: "pro5m-annual",
priceId: "price_1RE1ebDFVprnAny2BbHtnuko",
price: 1290,
priceId: "price_1RKuYaDFVprnAny2xEoejLRR",
price: 1490,
interval: "year",
limits: {
events: 5_000_000,
@ -109,8 +109,8 @@ export const STRIPE_PRICES = [
},
{
name: "pro10m",
priceId: "price_1R2kzxDFVprnAny2wdMx2Npp",
price: 169,
priceId: "price_1RKuX5DFVprnAny20UMfh10N",
price: 249,
interval: "month",
limits: {
events: 10_000_000,
@ -118,8 +118,8 @@ export const STRIPE_PRICES = [
},
{
name: "pro10m-annual",
priceId: "price_1RE1fHDFVprnAny2SKY4gFCA",
price: 1690,
priceId: "price_1RKuXODFVprnAny2JUjrCSyY",
price: 2490,
interval: "year",
limits: {
events: 10_000_000,

View file

@ -29,8 +29,8 @@ function getFormattedPrice(eventLimit, isAnnual) {
else if (eventLimit <= 500_000) monthlyPrice = 49;
else if (eventLimit <= 1_000_000) monthlyPrice = 69;
else if (eventLimit <= 2_000_000) monthlyPrice = 99;
else if (eventLimit <= 5_000_000) monthlyPrice = 129;
else monthlyPrice = 169; // 10M events
else if (eventLimit <= 5_000_000) monthlyPrice = 149;
else monthlyPrice = 249; // 10M events
// Annual prices are 10x monthly (2 months free)
const annualPrice = monthlyPrice * 10;

View file

@ -7,7 +7,7 @@ import { getSubscriptionInner } from "../stripe/getSubscription.js";
import { IS_CLOUD } from "../../lib/const.js";
// Default event limit for users without an active subscription
const DEFAULT_EVENT_LIMIT = 10_000;
const DEFAULT_EVENT_LIMIT = 100_000;
export async function getSites(req: FastifyRequest, reply: FastifyReply) {
try {

View file

@ -67,6 +67,7 @@ export async function getSubscriptionInner(userId: string) {
planName: "Unknown Plan", // Indicate missing details
status: sub.status,
currentPeriodEnd: new Date(sub.current_period_end * 1000),
cancelAtPeriodEnd: sub.cancel_at_period_end,
eventLimit: 0, // Unknown limit
monthlyEventCount: user.monthlyEventCount,
interval: sub.items.data[0]?.price.recurring?.interval ?? "unknown",
@ -78,7 +79,8 @@ export async function getSubscriptionInner(userId: string) {
id: sub.id,
planName: planDetails.name,
status: sub.status,
currentPeriodEnd: new Date(sub.current_period_end * 1000), // Convert Unix timestamp to Date
currentPeriodEnd: new Date(sub.current_period_end * 1000),
cancelAtPeriodEnd: sub.cancel_at_period_end,
eventLimit: planDetails.limits.events,
monthlyEventCount: user.monthlyEventCount,
interval: sub.items.data[0]?.price.recurring?.interval ?? "unknown",

View file

@ -103,7 +103,7 @@ export const STRIPE_PRICES: StripePlan[] = [
},
{
name: "pro5m",
priceId: "price_1R2kybDFVprnAny21Mo1Wjuz",
priceId: "price_1RKuYJDFVprnAny2apEXvkde",
interval: "month",
limits: {
events: 5_000_000,
@ -111,7 +111,7 @@ export const STRIPE_PRICES: StripePlan[] = [
},
{
name: "pro5m-annual",
priceId: "price_1RE1ebDFVprnAny2BbHtnuko",
priceId: "price_1RKuYaDFVprnAny2xEoejLRR",
interval: "year",
limits: {
events: 5_000_000,
@ -119,7 +119,7 @@ export const STRIPE_PRICES: StripePlan[] = [
},
{
name: "pro10m",
priceId: "price_1R2kzxDFVprnAny2wdMx2Npp",
priceId: "price_1RKuX5DFVprnAny20UMfh10N",
interval: "month",
limits: {
events: 10_000_000,
@ -127,7 +127,7 @@ export const STRIPE_PRICES: StripePlan[] = [
},
{
name: "pro10m-annual",
priceId: "price_1RE1fHDFVprnAny2SKY4gFCA",
priceId: "price_1RKuXODFVprnAny2JUjrCSyY",
interval: "year",
limits: {
events: 10_000_000,