fix(minting): read current_period_end from subscription item#534
Open
blove wants to merge 2 commits into
Open
Conversation
Ran scripts/stripe/sync-products.ts against the live Stripe test-mode account after PR #532 landed. The script created 4 recurring prices (monthly + annual × developer_seat + team) and archived the prior one-time-payment prices. Operational follow-ups completed in parallel: - DB migration 0002 applied to the minting Neon DB (stripe_payment_id → stripe_subscription_id) - Webhook endpoint we_1TZcsHGYRsLErhxbdN2JTFTr enabled_events updated: customer.subscription.{created,updated,deleted}, invoice.paid, charge.refunded (dropped checkout.session.completed) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… sub object Stripe API version 2026-04-22 (dahlia) moved `current_period_end` and `current_period_start` from the Subscription object to each SubscriptionItem. The handler was reading the legacy subscription-level field, which is now always null, causing `handleSubscriptionCreated` to throw with `subscription <id> has no current_period_end` for every new subscription. Read the item-level field first, fall back to the legacy subscription-level field for replayed historical events or older API versions. Verified with a live test-mode Team annual subscription (sub_1Tapk3GYRsLErhxb3jnWnxPy): handler now mints + emails the license with expires_at = 2027-05-25 (matches Stripe's item.current_period_end). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stripe API `2026-04-22.dahlia` moved `current_period_end` / `current_period_start` from the `Subscription` object to each `SubscriptionItem`. Our handler still read the legacy subscription-level field, which is now always `null` — so every new `customer.subscription.created` event 500'd with `subscription has no current_period_end`.
This PR reads the item-level field first, falls back to the legacy subscription-level field (replayed historical events, older API versions).
Smoke
Verified live in test mode with a Team annual subscription: handler now mints, upserts, and emails a token with `expires_at` matching Stripe's `item.current_period_end`.
🤖 Generated with Claude Code