feat(billing): Stripe Customer Portal route + email + /thanks link#537
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Lets buyers self-serve subscription management (cancel, switch monthly↔annual, update card, view invoices) via Stripe's hosted Customer Portal. apps/website/src/app/api/portal/session/route.ts (NEW) - POST + GET handlers - Resolves a customer id from either: - session_id (Checkout Session) → fetches the session and reads .customer - customer_id (cus_…) directly — used by email links - Creates a Stripe billingPortal session and 303-redirects to its URL apps/website/src/app/thanks/page.tsx - When ?session_id=cs_… is present in the success URL, render a "Manage subscription" button alongside "Installation & licensing" - Page is now async so we can read the searchParams apps/minting-service/src/lib/email.ts - LicenseEmailVars gains required stripeCustomerId - Both text and HTML bodies of the license email now include a "Manage subscription" link to /api/portal/session?customer_id=… - portalUrl() reads PORTAL_BASE_URL when set (preview deploys), defaults to https://threadplane.ai apps/minting-service/src/lib/handlers.ts - Pass stripeCustomerId in the email vars at mint time Tests - email.spec fixtures gain stripeCustomerId on every renderLicenseEmail call - handlers.spec uses expect.objectContaining for vars so the new field doesn't tighten existing assertions Out of band: enable the Customer Portal in the Stripe dashboard (Settings → Billing → Customer portal) so the API call actually returns a URL. Test mode and live mode have separate portal configs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4b4cb10 to
128b118
Compare
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
Buyers can self-serve subscription management (cancel, switch billing cycle, update card, view invoices) via Stripe's hosted Customer Portal.
Operational follow-up
Enable Customer Portal in the Stripe dashboard (Settings → Billing → Customer portal) for both test and live modes. Configuration includes:
Test plan
🤖 Generated with Claude Code