Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions apps/minting-service/src/lib/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,17 @@ function readCustomerId(subscription: Stripe.Subscription): string {
}

function periodEnd(subscription: Stripe.Subscription): Date {
// current_period_end is unix seconds; convert to Date.
const epoch = (subscription as unknown as { current_period_end?: number }).current_period_end;
// current_period_end is unix seconds. As of Stripe API 2026-04-22, it moved
// off the subscription object and onto each subscription item. Read item
// first, fall back to the legacy subscription-level field for older API
// versions or replayed historical events.
const subRecord = subscription as unknown as {
current_period_end?: number;
items?: { data?: Array<{ current_period_end?: number }> };
};
const itemEpoch = subRecord.items?.data?.[0]?.current_period_end;
const subEpoch = subRecord.current_period_end;
const epoch = itemEpoch ?? subEpoch;
if (!epoch) {
throw new Error(`subscription ${subscription.id} has no current_period_end`);
}
Expand Down
8 changes: 4 additions & 4 deletions pricing/tiers.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { TierSlug, BillingCycle } from './tiers.config';

type BuyableSlug = Exclude<TierSlug, 'community' | 'enterprise'>;

// Empty stub — run `STRIPE_SECRET_KEY=sk_... pnpm tsx scripts/stripe/sync-products.ts`
// to populate. Until that runs, the checkout API returns a 503 with a helpful
// message.
export const STRIPE_PRICE_IDS: Partial<Record<BuyableSlug, Record<BillingCycle, string>>> = {};
export const STRIPE_PRICE_IDS: Partial<Record<BuyableSlug, Record<BillingCycle, string>>> = {
developer_seat: { monthly: "price_1TapR1GYRsLErhxb83221xMU", annual: "price_1TapR1GYRsLErhxb67dc67h1" },
team: { monthly: "price_1TapR2GYRsLErhxbBbrJMLpk", annual: "price_1TapR2GYRsLErhxbYsWAkYuE" },
};