From f4cff698cfb80f9ad2da7ecb626f84277f97eb7c Mon Sep 17 00:00:00 2001 From: Kalista Payne Date: Thu, 3 Oct 2024 17:58:59 -0500 Subject: [PATCH] fix(stripe): correct redirect after success --- website/client/src/mixins/payments.js | 10 ++-------- website/client/src/router/handleRedirect.js | 18 ++++++++---------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/website/client/src/mixins/payments.js b/website/client/src/mixins/payments.js index 78555a8a35..47763dccaf 100644 --- a/website/client/src/mixins/payments.js +++ b/website/client/src/mixins/payments.js @@ -8,7 +8,6 @@ import notificationsMixin from '@/mixins/notifications'; import { CONSTANTS, setLocalSetting } from '@/libs/userlocalManager'; import * as Analytics from '@/libs/analytics'; -const BASE_URL = process.env.BASE_URL; const STRIPE_PUB_KEY = process.env.STRIPE_PUB_KEY; let stripeInstance = null; @@ -192,13 +191,9 @@ export default { setLocalSetting(CONSTANTS.savedAppStateValues.SAVED_APP_STATE, JSON.stringify(appState)); try { - const checkoutOptions = { + const checkoutSessionResult = await stripeInstance.redirectToCheckout({ sessionId: response.data.data.sessionId, - }; - if (paymentType === 'subscription') { - checkoutOptions.successUrl = `${BASE_URL}/user/settings/subscription`; - } - const checkoutSessionResult = await stripeInstance.redirectToCheckout(checkoutOptions); + }); if (checkoutSessionResult.error) { console.error(checkoutSessionResult.error); // eslint-disable-line alert(`Error while redirecting to Stripe: ${checkoutSessionResult.error.message}`); @@ -247,7 +242,6 @@ export default { try { const checkoutSessionResult = await stripeInstance.redirectToCheckout({ sessionId: response.data.data.sessionId, - successUrl: `${BASE_URL}/user/settings/subscription`, }); if (checkoutSessionResult.error) { console.error(checkoutSessionResult.error); // eslint-disable-line diff --git a/website/client/src/router/handleRedirect.js b/website/client/src/router/handleRedirect.js index 66b99b75ef..2fb2c08425 100644 --- a/website/client/src/router/handleRedirect.js +++ b/website/client/src/router/handleRedirect.js @@ -22,17 +22,15 @@ export default function handleRedirect (to, from, next) { newAppState.paymentCompleted = true; setLocalSetting(CONSTANTS.savedAppStateValues.SAVED_APP_STATE, JSON.stringify(newAppState)); - if (newAppState.isStripeEdit) { - if (newAppState.paymentType === 'subscription') { - return next({ name: 'subscription' }); - } + if (newAppState.isStripeEdit && newAppState.paymentType === 'groupPlan') { + return next({ + name: 'groupPlanBilling', + params: { groupId: newAppState.groupId }, + }); + } - if (newAppState.paymentType === 'groupPlan') { - return next({ - name: 'groupPlanBilling', - params: { groupId: newAppState.groupId }, - }); - } + if (newAppState.paymentType === 'subscription') { + return next({ name: 'subscription' }); } const newGroup = newAppState.group;