Skip to content

Commit

Permalink
Merge pull request #1281 from internxt/refactor/remove-old-checkout
Browse files Browse the repository at this point in the history
[_]: refactor/remove unused payment code
  • Loading branch information
masterprog-cmd authored Sep 19, 2024
2 parents 15f674e + 9ba34f0 commit 3daae9e
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 235 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const App = (props: AppProps): JSX.Element => {
to={`/?preferences=open&section=account&subsection=${params.get('tab') ?? 'account'}`}
/>
<Redirect from="/app/:section?" to={{ pathname: '/:section?', search: `${queryParameters}` }} />
{pathName !== 'checkout-plan' && pathName !== 'checkout' && isMobile && isAuthenticated ? (
{pathName !== 'checkout' && isMobile && isAuthenticated ? (
<Route path="*">
<Mobile user={props.user} />
</Route>
Expand Down
8 changes: 1 addition & 7 deletions src/app/auth/views/Auth/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ const signup = async (data, dispatch, doRegister, setLoading, appRedirect?, setE
localStorage.removeItem('email');
localStorage.removeItem('password');
setLoading(false);
appRedirect
? window.open(`${process.env.REACT_APP_HOSTNAME}`, '_parent', 'noopener')
: window.open(
`${process.env.REACT_APP_HOSTNAME}/checkout-plan?planId=plan_F7ptyrVRmyL8Gn&couponCode=g3S2TZFZ&freeTrials=30&mode=subscription`,
'_parent',
'noopener',
);
window.open(`${process.env.REACT_APP_HOSTNAME}`, '_parent', 'noopener');
} catch (err: unknown) {
setError(errorService.castError(err).message);
setLoading(false);
Expand Down
2 changes: 0 additions & 2 deletions src/app/core/config/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import ChangeEmailView from '../views/ChangeEmailView';
import NotFoundView from '../views/NotFoundView/NotFoundView';
import VerifyEmailView from '../views/VerifyEmailView';
import CheckoutViewWrapper from '../../payment/views/IntegratedCheckoutView/CheckoutViewWrapper';
import CheckoutPlanView from '../../payment/views/RedirectToCheckoutView/CheckoutPlanView';

const views: Array<{
id: string;
Expand Down Expand Up @@ -59,7 +58,6 @@ const views: Array<{
{ id: AppView.CheckoutSuccess, component: CheckoutSuccessView },
{ id: AppView.CheckoutCancel, component: CheckoutCancelView },
{ id: AppView.Checkout, component: CheckoutViewWrapper },
{ id: AppView.CheckoutPlan, component: CheckoutPlanView },
{ id: AppView.RecoveryLink, component: RecoveryLinkView },
{ id: AppView.ShareFileToken, component: ShareFileView },
{ id: AppView.ShareFileToken2, component: ShareFileView },
Expand Down
1 change: 0 additions & 1 deletion src/app/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export enum AppView {
Deactivation = 'deactivation',
CheckoutSuccess = 'checkout-success',
CheckoutCancel = 'checkout-cancel',
CheckoutPlan = 'checkout-plan',
Checkout = 'checkout',
RecoveryLink = 'recovery-link',
ShareFileToken = 'share-token',
Expand Down
24 changes: 1 addition & 23 deletions src/app/newSettings/Sections/Account/Plans/PlansSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { RootState } from '../../../../store';
import { useAppDispatch } from '../../../../store/hooks';
import { PlanState, planThunks } from '../../../../store/slices/plan';
import CancelSubscriptionModal from '../../Workspace/Billing/CancelSubscriptionModal';
import { createCheckoutSession, fetchPlanPrices, getStripe } from './api/plansApi';
import { fetchPlanPrices, getStripe } from './api/plansApi';
import ChangePlanDialog from './components/ChangePlanDialog';
import PlanCard from './components/PlanCard';
import PlanSelectionCard from './components/PlanSelectionCard';
Expand Down Expand Up @@ -200,28 +200,6 @@ const PlansSection = ({ changeSection, onClosePreferences }: PlansSectionProps)
}
};

const handleCheckoutSession = async ({
priceId,
currency,
userEmail,
mode,
}: {
userEmail: string;
priceId: string;
mode: string;
currency: string;
}) => {
try {
const response = await createCheckoutSession({ userEmail, priceId, currency, mode });
localStorage.setItem('sessionId', response.sessionId);
await paymentService.redirectToCheckout(response);
} catch (err) {
const error = errorService.castError(err);
errorService.reportError(error);
showCancelSubscriptionErrorNotification();
}
};

const onChangePlanClicked = async (priceId: string, currency: string) => {
setIsLoadingCheckout(true);
setIsUpdatingSubscription(true);
Expand Down
23 changes: 1 addition & 22 deletions src/app/newSettings/Sections/Account/Plans/api/plansApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,6 @@ const fetchPlanPrices = async (userType: UserType) => {
}
};

const createCheckoutSession = async ({
userEmail,
priceId,
mode,
currency,
}: {
userEmail: string;
priceId: string;
mode: string;
currency: string;
}) => {
return paymentService.createCheckoutSession({
price_id: priceId,
success_url: `${window.location.origin}/checkout/success`,
cancel_url: `${window.location.origin}/checkout/cancel?price_id=${priceId}`,
customer_email: userEmail,
mode: mode,
currency: currency,
});
};

const getStripe = async (stripe): Promise<Stripe> => {
if (!stripe) {
stripe = (await loadStripe(
Expand All @@ -69,4 +48,4 @@ const getStripe = async (stripe): Promise<Stripe> => {
return stripe;
};

export { createCheckoutSession, fetchPlanPrices, getStripe };
export { fetchPlanPrices, getStripe };
9 changes: 0 additions & 9 deletions src/app/payment/services/payment.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
CreateCheckoutSessionPayload,
CreatedSubscriptionData,
CustomerBillingInfo,
DisplayPrice,
Expand Down Expand Up @@ -167,14 +166,6 @@ const paymentService = {
return paymentsClient.cancelSubscription(userType);
},

async createCheckoutSession(
payload: CreateCheckoutSessionPayload & { mode?: string },
): Promise<{ sessionId: string }> {
const paymentsClient = await SdkFactory.getInstance().createPaymentsClient();

return paymentsClient.createCheckoutSession(payload);
},

async updateCustomerBillingInfo(payload: CustomerBillingInfo): Promise<void> {
const paymentsClient = await SdkFactory.getInstance().createPaymentsClient();
return paymentsClient.updateCustomerBillingInfo(payload);
Expand Down
163 changes: 0 additions & 163 deletions src/app/payment/views/RedirectToCheckoutView/CheckoutPlanView.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions src/app/routes/paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,6 @@
"exact": true,
"auth": false
},
{
"id": "checkout-plan",
"layout": "empty",
"path": "/checkout-plan/",
"exact": true,
"auth": true
},
{
"id": "recovery-link",
"layout": "empty",
Expand Down

0 comments on commit 3daae9e

Please sign in to comment.