Fix wrong domainName for redirect url (#9586)
Closes https://github.com/twentyhq/twenty/issues/9097 Fixes the redirect url of stripe `checkout` and `billingPortal` sessions ## Before https://github.com/user-attachments/assets/4ccab325-41e1-494e-854a-9d9a72e534f1 ## After https://github.com/user-attachments/assets/740b07f4-84b0-4670-a5b6-2684fde640c8
This commit is contained in:
@ -45,7 +45,7 @@ export class BillingResolver {
|
|||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
url: await this.billingPortalWorkspaceService.computeBillingPortalSessionURLOrThrow(
|
url: await this.billingPortalWorkspaceService.computeBillingPortalSessionURLOrThrow(
|
||||||
workspace.id,
|
workspace,
|
||||||
returnUrlPath,
|
returnUrlPath,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|||||||
@ -36,7 +36,9 @@ export class BillingPortalWorkspaceService {
|
|||||||
plan?: BillingPlanKey,
|
plan?: BillingPlanKey,
|
||||||
requirePaymentMethod?: boolean,
|
requirePaymentMethod?: boolean,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const frontBaseUrl = this.domainManagerService.getBaseUrl();
|
const frontBaseUrl = this.domainManagerService.buildWorkspaceURL({
|
||||||
|
subdomain: workspace.subdomain,
|
||||||
|
});
|
||||||
const cancelUrl = frontBaseUrl.toString();
|
const cancelUrl = frontBaseUrl.toString();
|
||||||
|
|
||||||
if (successUrlPath) {
|
if (successUrlPath) {
|
||||||
@ -72,13 +74,13 @@ export class BillingPortalWorkspaceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async computeBillingPortalSessionURLOrThrow(
|
async computeBillingPortalSessionURLOrThrow(
|
||||||
workspaceId: string,
|
workspace: Workspace,
|
||||||
returnUrlPath?: string,
|
returnUrlPath?: string,
|
||||||
) {
|
) {
|
||||||
const currentSubscription =
|
const currentSubscription =
|
||||||
await this.billingSubscriptionService.getCurrentBillingSubscriptionOrThrow(
|
await this.billingSubscriptionService.getCurrentBillingSubscriptionOrThrow(
|
||||||
{
|
{
|
||||||
workspaceId,
|
workspaceId: workspace.id,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -92,7 +94,9 @@ export class BillingPortalWorkspaceService {
|
|||||||
throw new Error('Error: missing stripeCustomerId');
|
throw new Error('Error: missing stripeCustomerId');
|
||||||
}
|
}
|
||||||
|
|
||||||
const frontBaseUrl = this.domainManagerService.getBaseUrl();
|
const frontBaseUrl = this.domainManagerService.buildWorkspaceURL({
|
||||||
|
subdomain: workspace.subdomain,
|
||||||
|
});
|
||||||
|
|
||||||
if (returnUrlPath) {
|
if (returnUrlPath) {
|
||||||
frontBaseUrl.pathname = returnUrlPath;
|
frontBaseUrl.pathname = returnUrlPath;
|
||||||
|
|||||||
Reference in New Issue
Block a user