MCPcopy Index your code
hub / github.com/simstudioai/sim / createBillingPortalUrl

Function createBillingPortalUrl

apps/sim/lib/billing/webhooks/invoices.ts:176–190  ·  view source on GitHub ↗

* Create a billing portal URL for a Stripe customer

(stripeCustomerId: string)

Source from the content-addressed store, hash-verified

174 * Create a billing portal URL for a Stripe customer
175 */
176async function createBillingPortalUrl(stripeCustomerId: string): Promise<string> {
177 try {
178 const stripe = requireStripeClient()
179 const baseUrl = getBaseUrl()
180 const portal = await stripe.billingPortal.sessions.create({
181 customer: stripeCustomerId,
182 return_url: `${baseUrl}/workspace?billing=updated`,
183 })
184 return portal.url
185 } catch (error) {
186 logger.error('Failed to create billing portal URL', { error, stripeCustomerId })
187 // Fallback to generic billing page
188 return `${getBaseUrl()}/workspace?tab=subscription`
189 }
190}
191
192/**
193 * Get payment method details from Stripe invoice

Callers 1

sendPaymentFailureEmailsFunction · 0.85

Calls 3

requireStripeClientFunction · 0.90
getBaseUrlFunction · 0.90
errorMethod · 0.80

Tested by

no test coverage detected