43 add billing portal link (#4318)
* Add create billing portal session endpoint * Rename checkout to checkoutSession * Add billig portal query in twenty-front * Add billing menu item * WIP: add menu page * Code review returns * Rename request files * Unwip: add menu page * Add billing cover image * Fix icon imports * Rename parameter * Add feature flag soon pill
This commit is contained in:
@ -111,9 +111,14 @@ export class BillingService {
|
||||
where: { workspaceId },
|
||||
});
|
||||
|
||||
const frontBaseUrl = this.environmentService.getFrontBaseUrl();
|
||||
const returnUrl = returnUrlPath
|
||||
? frontBaseUrl + returnUrlPath
|
||||
: frontBaseUrl;
|
||||
|
||||
const session = await this.stripeService.createBillingPortalSession(
|
||||
billingSubscription.stripeCustomerId,
|
||||
returnUrlPath,
|
||||
returnUrl,
|
||||
);
|
||||
|
||||
assert(session.url, 'Error: missing billingPortal.session.url');
|
||||
|
||||
@ -44,11 +44,11 @@ export class StripeService {
|
||||
|
||||
async createBillingPortalSession(
|
||||
stripeCustomerId: string,
|
||||
returnUrlPath?: string,
|
||||
returnUrl?: string,
|
||||
): Promise<Stripe.BillingPortal.Session> {
|
||||
return await this.stripe.billingPortal.sessions.create({
|
||||
customer: stripeCustomerId,
|
||||
return_url: returnUrlPath ?? this.environmentService.getFrontBaseUrl(),
|
||||
return_url: returnUrl ?? this.environmentService.getFrontBaseUrl(),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user