mirror of
https://github.com/lingble/twenty.git
synced 2025-11-03 22:27:57 +00:00
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:
@@ -552,7 +552,7 @@ export type Sentry = {
|
|||||||
|
|
||||||
export type SessionEntity = {
|
export type SessionEntity = {
|
||||||
__typename?: 'SessionEntity';
|
__typename?: 'SessionEntity';
|
||||||
url: Scalars['String'];
|
url?: Maybe<Scalars['String']>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Sort Directions */
|
/** Sort Directions */
|
||||||
@@ -1015,7 +1015,7 @@ export type BillingPortalSessionQueryVariables = Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type BillingPortalSessionQuery = { __typename?: 'Query', billingPortalSession: { __typename?: 'SessionEntity', url: string } };
|
export type BillingPortalSessionQuery = { __typename?: 'Query', billingPortalSession: { __typename?: 'SessionEntity', url?: string | null } };
|
||||||
|
|
||||||
export type CheckoutSessionMutationVariables = Exact<{
|
export type CheckoutSessionMutationVariables = Exact<{
|
||||||
recurringInterval: Scalars['String'];
|
recurringInterval: Scalars['String'];
|
||||||
@@ -1023,7 +1023,7 @@ export type CheckoutSessionMutationVariables = Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type CheckoutSessionMutation = { __typename?: 'Mutation', checkoutSession: { __typename?: 'SessionEntity', url: string } };
|
export type CheckoutSessionMutation = { __typename?: 'Mutation', checkoutSession: { __typename?: 'SessionEntity', url?: string | null } };
|
||||||
|
|
||||||
export type GetProductPricesQueryVariables = Exact<{
|
export type GetProductPricesQueryVariables = Exact<{
|
||||||
product: Scalars['String'];
|
product: Scalars['String'];
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ export const SettingsBilling = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const billingPortalButtonDisabled =
|
||||||
|
loading || !isDefined(data) || !isDefined(data.billingPortalSession.url);
|
||||||
|
|
||||||
const displayPaymentFailInfo =
|
const displayPaymentFailInfo =
|
||||||
onboardingStatus === OnboardingStatus.PastDue ||
|
onboardingStatus === OnboardingStatus.PastDue ||
|
||||||
onboardingStatus === OnboardingStatus.Unpaid;
|
onboardingStatus === OnboardingStatus.Unpaid;
|
||||||
@@ -46,7 +49,7 @@ export const SettingsBilling = () => {
|
|||||||
onboardingStatus === OnboardingStatus.CompletedWithoutSubscription;
|
onboardingStatus === OnboardingStatus.CompletedWithoutSubscription;
|
||||||
|
|
||||||
const openBillingPortal = () => {
|
const openBillingPortal = () => {
|
||||||
if (isDefined(data)) {
|
if (isDefined(data) && isDefined(data.billingPortalSession.url)) {
|
||||||
window.location.replace(data.billingPortalSession.url);
|
window.location.replace(data.billingPortalSession.url);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -95,7 +98,7 @@ export const SettingsBilling = () => {
|
|||||||
title="View billing details"
|
title="View billing details"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
onClick={openBillingPortal}
|
onClick={openBillingPortal}
|
||||||
disabled={loading}
|
disabled={billingPortalButtonDisabled}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ FRONT_BASE_URL=http://localhost:3001
|
|||||||
ACCESS_TOKEN_SECRET=replace_me_with_a_random_string_access
|
ACCESS_TOKEN_SECRET=replace_me_with_a_random_string_access
|
||||||
LOGIN_TOKEN_SECRET=replace_me_with_a_random_string_login
|
LOGIN_TOKEN_SECRET=replace_me_with_a_random_string_login
|
||||||
REFRESH_TOKEN_SECRET=replace_me_with_a_random_string_refresh
|
REFRESH_TOKEN_SECRET=replace_me_with_a_random_string_refresh
|
||||||
|
FILE_TOKEN_SECRET=replace_me_with_a_random_string_refresh
|
||||||
SIGN_IN_PREFILLED=true
|
SIGN_IN_PREFILLED=true
|
||||||
|
|
||||||
# ———————— Optional ————————
|
# ———————— Optional ————————
|
||||||
|
|||||||
@@ -131,10 +131,13 @@ export class BillingService {
|
|||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
returnUrlPath?: string,
|
returnUrlPath?: string,
|
||||||
) {
|
) {
|
||||||
const billingSubscription =
|
const billingSubscription = await this.getCurrentBillingSubscription({
|
||||||
await this.billingSubscriptionRepository.findOneOrFail({
|
workspaceId,
|
||||||
where: { workspaceId },
|
});
|
||||||
});
|
|
||||||
|
if (!billingSubscription) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const frontBaseUrl = this.environmentService.get('FRONT_BASE_URL');
|
const frontBaseUrl = this.environmentService.get('FRONT_BASE_URL');
|
||||||
const returnUrl = returnUrlPath
|
const returnUrl = returnUrlPath
|
||||||
@@ -190,10 +193,9 @@ export class BillingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async deleteSubscription(workspaceId: string) {
|
async deleteSubscription(workspaceId: string) {
|
||||||
const subscriptionToCancel =
|
const subscriptionToCancel = await this.getCurrentBillingSubscription({
|
||||||
await this.billingSubscriptionRepository.findOneBy({
|
workspaceId,
|
||||||
workspaceId,
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (subscriptionToCancel) {
|
if (subscriptionToCancel) {
|
||||||
await this.stripeService.cancelSubscription(
|
await this.stripeService.cancelSubscription(
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ import { Field, ObjectType } from '@nestjs/graphql';
|
|||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class SessionEntity {
|
export class SessionEntity {
|
||||||
@Field(() => String)
|
@Field(() => String, { nullable: true })
|
||||||
url: string;
|
url: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ Date: Feb 3rd 2024
|
|||||||
|
|
||||||
# Rating field
|
# Rating field
|
||||||
|
|
||||||
The new Rating field represents a numeric value from 0 to 5, it can be useful for various use-cases such as scoring leads.
|
The new Rating field represents a numeric value from zero to five, it can be useful for various use-cases such as scoring leads.
|
||||||
|
|
||||||

|

|
||||||
Reference in New Issue
Block a user