Skip to content

fix(stripe): read current_period_end from subscription item, not subscription - #4

Merged
gkhngyk merged 1 commit into
mainfrom
fix/stripe-current-period-end-on-item
May 8, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/stripe-current-period-end-on-item

Conversation

@gkhngyk

@gkhngyk gkhngyk commented May 8, 2026

Copy link
Copy Markdown
Contributor

Stripe API 2025-03-31 (and the matching SDK 22.x) removed
current_period_end from the Subscription object and moved it onto each
SubscriptionItem so subscriptions with multi-billing-cycle items make
sense. Our code still read sub.current_period_end, which is undefined
under the new shape — new Date(undefined * 1000).toISOString() then
threw RangeError: Invalid time value, surfacing as a 500 on
GET /api/stripe/subscription and breaking the Settings → Billing page.

Adds a getCurrentPeriodEndIso() helper that reads item-level first and
falls back to the subscription-level field for older API versions.
Returns null when neither is present so the response stays valid JSON
instead of crashing the request. The webhook handler for
customer.subscription.updated gets the same treatment.

…cription

Stripe API 2025-03-31 (and the matching SDK 22.x) removed
current_period_end from the Subscription object and moved it onto each
SubscriptionItem so subscriptions with multi-billing-cycle items make
sense. Our code still read sub.current_period_end, which is undefined
under the new shape — `new Date(undefined * 1000).toISOString()` then
threw RangeError: Invalid time value, surfacing as a 500 on
GET /api/stripe/subscription and breaking the Settings → Billing page.

Adds a getCurrentPeriodEndIso() helper that reads item-level first and
falls back to the subscription-level field for older API versions.
Returns null when neither is present so the response stays valid JSON
instead of crashing the request. The webhook handler for
customer.subscription.updated gets the same treatment.
@vercel

vercel Bot commented May 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ansvisor Ready Ready Preview, Comment May 8, 2026 1:14pm

Request Review

This branch was successfully deployed

1 active deployment
Preview — dd58b370 Deployed May 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant