mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Mm 52577 Tie use of Stripe (or its mock) to use of CWS (or its mock) (#23277)
* set config CWSMock value according to model.MockCWS
This commit is contained in:
parent
9f1796f98b
commit
9ee3526ca1
@ -93,6 +93,7 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
|
|||||||
props["EnableEmailInvitations"] = strconv.FormatBool(*c.ServiceSettings.EnableEmailInvitations)
|
props["EnableEmailInvitations"] = strconv.FormatBool(*c.ServiceSettings.EnableEmailInvitations)
|
||||||
|
|
||||||
props["CWSURL"] = *c.CloudSettings.CWSURL
|
props["CWSURL"] = *c.CloudSettings.CWSURL
|
||||||
|
props["CWSMock"] = model.MockCWS
|
||||||
|
|
||||||
props["DisableRefetchingOnBrowserFocus"] = strconv.FormatBool(*c.ExperimentalSettings.DisableRefetchingOnBrowserFocus)
|
props["DisableRefetchingOnBrowserFocus"] = strconv.FormatBool(*c.ExperimentalSettings.DisableRefetchingOnBrowserFocus)
|
||||||
|
|
||||||
|
@ -2780,6 +2780,7 @@ func (s *JobSettings) SetDefaults() {
|
|||||||
type CloudSettings struct {
|
type CloudSettings struct {
|
||||||
CWSURL *string `access:"write_restrictable"`
|
CWSURL *string `access:"write_restrictable"`
|
||||||
CWSAPIURL *string `access:"write_restrictable"`
|
CWSAPIURL *string `access:"write_restrictable"`
|
||||||
|
CWSMock *bool `access:"write_restrictable"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CloudSettings) SetDefaults() {
|
func (s *CloudSettings) SetDefaults() {
|
||||||
@ -2795,6 +2796,10 @@ func (s *CloudSettings) SetDefaults() {
|
|||||||
s.CWSAPIURL = NewString(CloudSettingsDefaultCwsAPIURLTest)
|
s.CWSAPIURL = NewString(CloudSettingsDefaultCwsAPIURLTest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if s.CWSMock == nil {
|
||||||
|
isMockCws := MockCWS == "true"
|
||||||
|
s.CWSMock = &isMockCws
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProductSettings struct {
|
type ProductSettings struct {
|
||||||
|
@ -22,7 +22,7 @@ import {Address, Feedback, WorkspaceDeletionRequest} from '@mattermost/types/clo
|
|||||||
export function completeStripeAddPaymentMethod(
|
export function completeStripeAddPaymentMethod(
|
||||||
stripe: Stripe,
|
stripe: Stripe,
|
||||||
billingDetails: BillingDetails,
|
billingDetails: BillingDetails,
|
||||||
isDevMode: boolean,
|
cwsMockMode: boolean,
|
||||||
) {
|
) {
|
||||||
return async () => {
|
return async () => {
|
||||||
let paymentSetupIntent: StripeSetupIntent;
|
let paymentSetupIntent: StripeSetupIntent;
|
||||||
@ -31,7 +31,7 @@ export function completeStripeAddPaymentMethod(
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
const cardSetupFunction = getConfirmCardSetup(isDevMode);
|
const cardSetupFunction = getConfirmCardSetup(cwsMockMode);
|
||||||
const confirmCardSetup = cardSetupFunction(stripe.confirmCardSetup);
|
const confirmCardSetup = cardSetupFunction(stripe.confirmCardSetup);
|
||||||
|
|
||||||
const result = await confirmCardSetup(
|
const result = await confirmCardSetup(
|
||||||
|
@ -35,13 +35,13 @@ const STRIPE_ALREADY_SUCCEEDED = 'You cannot update this SetupIntent because it
|
|||||||
export function confirmSelfHostedSignup(
|
export function confirmSelfHostedSignup(
|
||||||
stripe: Stripe,
|
stripe: Stripe,
|
||||||
stripeSetupIntent: StripeSetupIntent,
|
stripeSetupIntent: StripeSetupIntent,
|
||||||
isDevMode: boolean,
|
cwsMockMode: boolean,
|
||||||
billingDetails: BillingDetails,
|
billingDetails: BillingDetails,
|
||||||
initialProgress: ValueOf<typeof SelfHostedSignupProgress>,
|
initialProgress: ValueOf<typeof SelfHostedSignupProgress>,
|
||||||
subscriptionRequest: CreateSubscriptionRequest,
|
subscriptionRequest: CreateSubscriptionRequest,
|
||||||
): ActionFunc {
|
): ActionFunc {
|
||||||
return async (dispatch: DispatchFunc) => {
|
return async (dispatch: DispatchFunc) => {
|
||||||
const cardSetupFunction = getConfirmCardSetup(isDevMode);
|
const cardSetupFunction = getConfirmCardSetup(cwsMockMode);
|
||||||
const confirmCardSetup = cardSetupFunction(stripe.confirmCardSetup);
|
const confirmCardSetup = cardSetupFunction(stripe.confirmCardSetup);
|
||||||
|
|
||||||
const shouldConfirmCard = selfHostedNeedsConfirmation(initialProgress);
|
const shouldConfirmCard = selfHostedNeedsConfirmation(initialProgress);
|
||||||
@ -202,13 +202,13 @@ export function getTrueUpReviewStatus(): ActionFunc {
|
|||||||
export function confirmSelfHostedExpansion(
|
export function confirmSelfHostedExpansion(
|
||||||
stripe: Stripe,
|
stripe: Stripe,
|
||||||
stripeSetupIntent: StripeSetupIntent,
|
stripeSetupIntent: StripeSetupIntent,
|
||||||
isDevMode: boolean,
|
cwsMockMode: boolean,
|
||||||
billingDetails: BillingDetails,
|
billingDetails: BillingDetails,
|
||||||
initialProgress: ValueOf<typeof SelfHostedSignupProgress>,
|
initialProgress: ValueOf<typeof SelfHostedSignupProgress>,
|
||||||
expansionRequest: SelfHostedExpansionRequest,
|
expansionRequest: SelfHostedExpansionRequest,
|
||||||
): ActionFunc {
|
): ActionFunc {
|
||||||
return async (dispatch: DispatchFunc) => {
|
return async (dispatch: DispatchFunc) => {
|
||||||
const cardSetupFunction = getConfirmCardSetup(isDevMode);
|
const cardSetupFunction = getConfirmCardSetup(cwsMockMode);
|
||||||
const confirmCardSetup = cardSetupFunction(stripe.confirmCardSetup);
|
const confirmCardSetup = cardSetupFunction(stripe.confirmCardSetup);
|
||||||
|
|
||||||
const shouldConfirmCard = selfHostedNeedsConfirmation(initialProgress);
|
const shouldConfirmCard = selfHostedNeedsConfirmation(initialProgress);
|
||||||
|
@ -15,7 +15,7 @@ import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
|||||||
|
|
||||||
import {completeStripeAddPaymentMethod} from 'actions/cloud';
|
import {completeStripeAddPaymentMethod} from 'actions/cloud';
|
||||||
|
|
||||||
import {isDevModeEnabled} from 'selectors/general';
|
import {isCwsMockMode} from 'selectors/cloud';
|
||||||
|
|
||||||
import {areBillingDetailsValid, BillingDetails} from 'types/cloud/sku';
|
import {areBillingDetailsValid, BillingDetails} from 'types/cloud/sku';
|
||||||
import {GlobalState} from 'types/store';
|
import {GlobalState} from 'types/store';
|
||||||
@ -37,7 +37,7 @@ const PaymentInfoEdit: React.FC = () => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const isDevMode = useSelector(isDevModeEnabled);
|
const cwsMockMode = useSelector(isCwsMockMode);
|
||||||
const paymentInfo = useSelector((state: GlobalState) => state.entities.cloud.customer);
|
const paymentInfo = useSelector((state: GlobalState) => state.entities.cloud.customer);
|
||||||
const theme = useSelector(getTheme);
|
const theme = useSelector(getTheme);
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ const PaymentInfoEdit: React.FC = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
setIsSaving(true);
|
setIsSaving(true);
|
||||||
const setPaymentMethod = completeStripeAddPaymentMethod((await stripePromise)!, billingDetails!, isDevMode);
|
const setPaymentMethod = completeStripeAddPaymentMethod((await stripePromise)!, billingDetails!, cwsMockMode);
|
||||||
const success = await setPaymentMethod();
|
const success = await setPaymentMethod();
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
@ -22,7 +22,7 @@ function devConfirmCardSetup(confirmCardSetup: ConfirmCardSetupType): ConfirmCar
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getConfirmCardSetup = (isDevMode?: boolean) => (isDevMode ? devConfirmCardSetup : prodConfirmCardSetup);
|
export const getConfirmCardSetup = (isCwsMockMode?: boolean) => (isCwsMockMode ? devConfirmCardSetup : prodConfirmCardSetup);
|
||||||
|
|
||||||
export const STRIPE_CSS_SRC = 'https://fonts.googleapis.com/css?family=Open+Sans:400,400i,600,600i&display=swap';
|
export const STRIPE_CSS_SRC = 'https://fonts.googleapis.com/css?family=Open+Sans:400,400i,600,600i&display=swap';
|
||||||
//eslint-disable-next-line no-process-env
|
//eslint-disable-next-line no-process-env
|
||||||
|
@ -19,8 +19,7 @@ import {GlobalState} from 'types/store';
|
|||||||
import {BillingDetails} from 'types/cloud/sku';
|
import {BillingDetails} from 'types/cloud/sku';
|
||||||
|
|
||||||
import {isModalOpen} from 'selectors/views/modals';
|
import {isModalOpen} from 'selectors/views/modals';
|
||||||
import {getCloudDelinquentInvoices, isCloudDelinquencyGreaterThan90Days} from 'selectors/cloud';
|
import {getCloudDelinquentInvoices, isCloudDelinquencyGreaterThan90Days, isCwsMockMode} from 'selectors/cloud';
|
||||||
import {isDevModeEnabled} from 'selectors/general';
|
|
||||||
|
|
||||||
import {ModalIdentifiers} from 'utils/constants';
|
import {ModalIdentifiers} from 'utils/constants';
|
||||||
|
|
||||||
@ -52,7 +51,7 @@ function mapStateToProps(state: GlobalState) {
|
|||||||
show: isModalOpen(state, ModalIdentifiers.CLOUD_PURCHASE),
|
show: isModalOpen(state, ModalIdentifiers.CLOUD_PURCHASE),
|
||||||
products,
|
products,
|
||||||
yearlyProducts,
|
yearlyProducts,
|
||||||
isDevMode: isDevModeEnabled(state),
|
cwsMockMode: isCwsMockMode(state),
|
||||||
contactSupportLink,
|
contactSupportLink,
|
||||||
invoices: getCloudDelinquentInvoices(state),
|
invoices: getCloudDelinquentInvoices(state),
|
||||||
isCloudDelinquencyGreaterThan90Days: isCloudDelinquencyGreaterThan90Days(state),
|
isCloudDelinquencyGreaterThan90Days: isCloudDelinquencyGreaterThan90Days(state),
|
||||||
@ -71,7 +70,7 @@ type Actions = {
|
|||||||
closeModal: () => void;
|
closeModal: () => void;
|
||||||
openModal: <P>(modalData: ModalData<P>) => void;
|
openModal: <P>(modalData: ModalData<P>) => void;
|
||||||
getCloudProducts: () => void;
|
getCloudProducts: () => void;
|
||||||
completeStripeAddPaymentMethod: (stripe: Stripe, billingDetails: BillingDetails, isDevMode: boolean) => Promise<boolean | null>;
|
completeStripeAddPaymentMethod: (stripe: Stripe, billingDetails: BillingDetails, cwsMockMode: boolean) => Promise<boolean | null>;
|
||||||
subscribeCloudSubscription: typeof subscribeCloudSubscription;
|
subscribeCloudSubscription: typeof subscribeCloudSubscription;
|
||||||
getClientConfig: () => void;
|
getClientConfig: () => void;
|
||||||
getCloudSubscription: () => void;
|
getCloudSubscription: () => void;
|
||||||
|
@ -36,13 +36,13 @@ type Props = RouteComponentProps & {
|
|||||||
billingDetails: BillingDetails | null;
|
billingDetails: BillingDetails | null;
|
||||||
shippingAddress: Address | null;
|
shippingAddress: Address | null;
|
||||||
stripe: Promise<Stripe | null>;
|
stripe: Promise<Stripe | null>;
|
||||||
isDevMode: boolean;
|
cwsMockMode: boolean;
|
||||||
contactSupportLink: string;
|
contactSupportLink: string;
|
||||||
currentTeam: Team;
|
currentTeam: Team;
|
||||||
addPaymentMethod: (
|
addPaymentMethod: (
|
||||||
stripe: Stripe,
|
stripe: Stripe,
|
||||||
billingDetails: BillingDetails,
|
billingDetails: BillingDetails,
|
||||||
isDevMode: boolean
|
cwsMockMode: boolean
|
||||||
) => Promise<boolean | null>;
|
) => Promise<boolean | null>;
|
||||||
subscribeCloudSubscription:
|
subscribeCloudSubscription:
|
||||||
| ((productId: string, shippingAddress: Address, seats?: number, downgradeFeedback?: Feedback) => Promise<ActionResult<Subscription, ComplianceError>>)
|
| ((productId: string, shippingAddress: Address, seats?: number, downgradeFeedback?: Feedback) => Promise<ActionResult<Subscription, ComplianceError>>)
|
||||||
@ -120,10 +120,10 @@ class ProcessPaymentSetup extends React.PureComponent<Props, State> {
|
|||||||
stripe,
|
stripe,
|
||||||
addPaymentMethod,
|
addPaymentMethod,
|
||||||
billingDetails,
|
billingDetails,
|
||||||
isDevMode,
|
cwsMockMode,
|
||||||
subscribeCloudSubscription,
|
subscribeCloudSubscription,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const success = await addPaymentMethod((await stripe)!, billingDetails!, isDevMode);
|
const success = await addPaymentMethod((await stripe)!, billingDetails!, cwsMockMode);
|
||||||
|
|
||||||
if (typeof success !== 'boolean' || !success) {
|
if (typeof success !== 'boolean' || !success) {
|
||||||
trackEvent('cloud_admin', 'complete_payment_failed', {
|
trackEvent('cloud_admin', 'complete_payment_failed', {
|
||||||
|
@ -111,7 +111,7 @@ type CardProps = {
|
|||||||
type Props = {
|
type Props = {
|
||||||
customer: CloudCustomer | undefined;
|
customer: CloudCustomer | undefined;
|
||||||
show: boolean;
|
show: boolean;
|
||||||
isDevMode: boolean;
|
cwsMockMode: boolean;
|
||||||
products: Record<string, Product> | undefined;
|
products: Record<string, Product> | undefined;
|
||||||
yearlyProducts: Record<string, Product>;
|
yearlyProducts: Record<string, Product>;
|
||||||
contactSalesLink: string;
|
contactSalesLink: string;
|
||||||
@ -137,7 +137,7 @@ type Props = {
|
|||||||
completeStripeAddPaymentMethod: (
|
completeStripeAddPaymentMethod: (
|
||||||
stripe: Stripe,
|
stripe: Stripe,
|
||||||
billingDetails: BillingDetails,
|
billingDetails: BillingDetails,
|
||||||
isDevMode: boolean
|
cwsMockMode: boolean
|
||||||
) => Promise<boolean | null>;
|
) => Promise<boolean | null>;
|
||||||
subscribeCloudSubscription: (
|
subscribeCloudSubscription: (
|
||||||
productId: string,
|
productId: string,
|
||||||
@ -1006,7 +1006,7 @@ class PurchaseModal extends React.PureComponent<Props, State> {
|
|||||||
this.props.actions.
|
this.props.actions.
|
||||||
subscribeCloudSubscription
|
subscribeCloudSubscription
|
||||||
}
|
}
|
||||||
isDevMode={this.props.isDevMode}
|
cwsMockMode={this.props.cwsMockMode}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
this.props.actions.getCloudSubscription();
|
this.props.actions.getCloudSubscription();
|
||||||
this.props.actions.closeModal();
|
this.props.actions.closeModal();
|
||||||
|
@ -16,7 +16,7 @@ import {getSelfHostedSignupProgress} from 'mattermost-redux/selectors/entities/h
|
|||||||
import {DispatchFunc} from 'mattermost-redux/types/actions';
|
import {DispatchFunc} from 'mattermost-redux/types/actions';
|
||||||
import {HostedCustomerTypes} from 'mattermost-redux/action_types';
|
import {HostedCustomerTypes} from 'mattermost-redux/action_types';
|
||||||
import {Client4} from 'mattermost-redux/client';
|
import {Client4} from 'mattermost-redux/client';
|
||||||
import {isDevModeEnabled} from 'selectors/general';
|
import {isCwsMockMode} from 'selectors/cloud';
|
||||||
|
|
||||||
import {closeModal} from 'actions/views/modals';
|
import {closeModal} from 'actions/views/modals';
|
||||||
import {pageVisited} from 'actions/telemetry_actions';
|
import {pageVisited} from 'actions/telemetry_actions';
|
||||||
@ -169,7 +169,7 @@ export default function SelfHostedExpansionModal() {
|
|||||||
const theme = useSelector(getTheme);
|
const theme = useSelector(getTheme);
|
||||||
const progress = useSelector(getSelfHostedSignupProgress);
|
const progress = useSelector(getSelfHostedSignupProgress);
|
||||||
const user = useSelector(getCurrentUser);
|
const user = useSelector(getCurrentUser);
|
||||||
const isDevMode = useSelector(isDevModeEnabled);
|
const cwsMockMode = useSelector(isCwsMockMode);
|
||||||
|
|
||||||
const license = useSelector(getLicense);
|
const license = useSelector(getLicense);
|
||||||
const licensedSeats = parseInt(license.Users, 10);
|
const licensedSeats = parseInt(license.Users, 10);
|
||||||
@ -259,7 +259,7 @@ export default function SelfHostedExpansionModal() {
|
|||||||
id: signupCustomerResult.setup_intent_id,
|
id: signupCustomerResult.setup_intent_id,
|
||||||
client_secret: signupCustomerResult.setup_intent_secret,
|
client_secret: signupCustomerResult.setup_intent_secret,
|
||||||
},
|
},
|
||||||
isDevMode,
|
cwsMockMode,
|
||||||
{
|
{
|
||||||
address: formState.address,
|
address: formState.address,
|
||||||
address2: formState.address2,
|
address2: formState.address2,
|
||||||
|
@ -24,7 +24,7 @@ import {confirmSelfHostedSignup} from 'actions/hosted_customer';
|
|||||||
import {GlobalState} from 'types/store';
|
import {GlobalState} from 'types/store';
|
||||||
|
|
||||||
import {isModalOpen} from 'selectors/views/modals';
|
import {isModalOpen} from 'selectors/views/modals';
|
||||||
import {isDevModeEnabled} from 'selectors/general';
|
import {isCwsMockMode} from 'selectors/cloud';
|
||||||
|
|
||||||
import {inferNames} from 'utils/hosted_customer';
|
import {inferNames} from 'utils/hosted_customer';
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ export default function SelfHostedPurchaseModal(props: Props) {
|
|||||||
const desiredProductName = desiredProduct?.name || '';
|
const desiredProductName = desiredProduct?.name || '';
|
||||||
const desiredPlanName = getPlanNameFromProductName(desiredProductName);
|
const desiredPlanName = getPlanNameFromProductName(desiredProductName);
|
||||||
const currentUsers = analytics[StatTypes.TOTAL_USERS] as number;
|
const currentUsers = analytics[StatTypes.TOTAL_USERS] as number;
|
||||||
const isDevMode = useSelector(isDevModeEnabled);
|
const cwsMockMode = useSelector(isCwsMockMode);
|
||||||
const hasLicense = Object.keys(useSelector(getLicense) || {}).length > 0;
|
const hasLicense = Object.keys(useSelector(getLicense) || {}).length > 0;
|
||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
@ -453,7 +453,7 @@ export default function SelfHostedPurchaseModal(props: Props) {
|
|||||||
id: signupCustomerResult.setup_intent_id,
|
id: signupCustomerResult.setup_intent_id,
|
||||||
client_secret: signupCustomerResult.setup_intent_secret,
|
client_secret: signupCustomerResult.setup_intent_secret,
|
||||||
},
|
},
|
||||||
isDevMode,
|
cwsMockMode,
|
||||||
{
|
{
|
||||||
address: state.address,
|
address: state.address,
|
||||||
address2: state.address2,
|
address2: state.address2,
|
||||||
|
@ -43,3 +43,5 @@ export const isCloudDelinquencyGreaterThan90Days = createSelector(
|
|||||||
return (Math.floor((now.getTime() - delinquentDate.getTime()) / (1000 * 60 * 60 * 24)) >= 90);
|
return (Math.floor((now.getTime() - delinquentDate.getTime()) / (1000 * 60 * 60 * 24)) >= 90);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const isCwsMockMode = (state: GlobalState) => getConfig(state)?.CWSMock === 'true';
|
||||||
|
@ -30,6 +30,7 @@ export type ClientConfig = {
|
|||||||
CustomTermsOfServiceReAcceptancePeriod: string;
|
CustomTermsOfServiceReAcceptancePeriod: string;
|
||||||
CustomUrlSchemes: string;
|
CustomUrlSchemes: string;
|
||||||
CWSURL: string;
|
CWSURL: string;
|
||||||
|
CWSMock: string;
|
||||||
DataRetentionEnableFileDeletion: string;
|
DataRetentionEnableFileDeletion: string;
|
||||||
DataRetentionEnableMessageDeletion: string;
|
DataRetentionEnableMessageDeletion: string;
|
||||||
DataRetentionFileRetentionDays: string;
|
DataRetentionFileRetentionDays: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user