This endpoint requires a valid Bearer token and an existing Stripe customer account. Users on the free plan who have never subscribed will receive a 400 error.
Creates a Stripe Customer Portal session and returns a redirect URL. The portal is a Stripe-hosted page where users can:
Update or replace their payment method
View past invoices and download receipts
Cancel or reactivate a scheduled cancellation
Review billing history
After the user is done, Stripe redirects them back to the /settings page in the Hayon frontend.
The authenticated user must have a stripeCustomerId on file. This is set automatically when the user first completes a checkout session. Calling this endpoint without a prior subscription returns:
{ "message": "No billing account found. Please subscribe first."}
Changes made in the portal (e.g., toggling a cancellation) are communicated back to the server via Stripe webhooks. The customer.subscription.updated event keeps the database in sync.
The portal session return URL is configured to send the user back to /settings after they exit.
The returned url is single-use. If the user’s session expires, call this endpoint again to generate a fresh URL.