fix(stripe): correct redirect after success
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user