Set optional checkout.session.url (#4569)

* Set optional checkout.session.url

* Lint

* Edit .env.example

* Vale CI

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
martmull
2024-03-20 07:04:07 +01:00
committed by GitHub
parent c90e379fc4
commit 35d41e38c8
7 changed files with 22 additions and 16 deletions

View File

@ -131,10 +131,13 @@ export class BillingService {
workspaceId: string,
returnUrlPath?: string,
) {
const billingSubscription =
await this.billingSubscriptionRepository.findOneOrFail({
where: { workspaceId },
});
const billingSubscription = await this.getCurrentBillingSubscription({
workspaceId,
});
if (!billingSubscription) {
return;
}
const frontBaseUrl = this.environmentService.get('FRONT_BASE_URL');
const returnUrl = returnUrlPath
@ -190,10 +193,9 @@ export class BillingService {
}
async deleteSubscription(workspaceId: string) {
const subscriptionToCancel =
await this.billingSubscriptionRepository.findOneBy({
workspaceId,
});
const subscriptionToCancel = await this.getCurrentBillingSubscription({
workspaceId,
});
if (subscriptionToCancel) {
await this.stripeService.cancelSubscription(

View File

@ -2,6 +2,6 @@ import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType()
export class SessionEntity {
@Field(() => String)
@Field(() => String, { nullable: true })
url: string;
}