From c729976cb6db3b5fdab86618bd3700d7528027f9 Mon Sep 17 00:00:00 2001 From: larryrider Date: Fri, 17 Oct 2025 11:04:08 +0200 Subject: [PATCH 1/3] feat: update stripe dependencies and remove legacy code --- package.json | 4 +- src/app/core/config/views.ts | 2 - src/app/payment/hooks/useUserPayment.test.ts | 3 + src/app/payment/services/payment.service.ts | 8 +-- .../CheckoutSession/CheckoutSessionId.tsx | 31 --------- src/app/store/index.ts | 2 - yarn.lock | 66 +++++++++++++++---- 7 files changed, 60 insertions(+), 56 deletions(-) delete mode 100644 src/app/payment/views/CheckoutSession/CheckoutSessionId.tsx diff --git a/package.json b/package.json index ca8331b4c7..1ac18f45fe 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "@reduxjs/toolkit": "^1.6.0", "@sentry/react": "^8.55.0", "@sentry/tracing": "^7.120.3", - "@stripe/react-stripe-js": "^2.7.1", - "@stripe/stripe-js": "^3.5.0", + "@stripe/react-stripe-js": "5.2.0", + "@stripe/stripe-js": "8.1.0", "@typeform/embed-react": "^1.19.0", "@types/uuid": "^8.3.4", "@vitest/browser": "^2.1.9", diff --git a/src/app/core/config/views.ts b/src/app/core/config/views.ts index 6122eb9885..20c28aa568 100644 --- a/src/app/core/config/views.ts +++ b/src/app/core/config/views.ts @@ -30,7 +30,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 { CheckoutSessionId } from 'app/payment/views/CheckoutSession/CheckoutSessionId'; import PcCloudSuccess from 'app/payment/views/CheckoutSuccessView/PcCloudSuccess'; const views: Array<{ @@ -58,7 +57,6 @@ const views: Array<{ { id: AppView.CheckoutSuccess, component: CheckoutSuccessView }, { id: AppView.PcCloudSuccess, component: PcCloudSuccess }, { id: AppView.CheckoutCancel, component: CheckoutCancelView }, - { id: AppView.CheckoutSession, component: CheckoutSessionId }, { id: AppView.Checkout, component: CheckoutViewWrapper }, { id: AppView.RecoveryLink, component: RecoveryLinkView }, { id: AppView.ShareFileToken, component: ShareFileView }, diff --git a/src/app/payment/hooks/useUserPayment.test.ts b/src/app/payment/hooks/useUserPayment.test.ts index 9e7eabcb9a..ce3f757b77 100644 --- a/src/app/payment/hooks/useUserPayment.test.ts +++ b/src/app/payment/hooks/useUserPayment.test.ts @@ -438,6 +438,7 @@ describe('Custom hook to handle payments', () => { getElement: vi.fn(), submit: vi.fn(), update: vi.fn(), + on: vi.fn(), }, selectedPlan: { price: { @@ -485,6 +486,7 @@ describe('Custom hook to handle payments', () => { getElement: vi.fn(), submit: vi.fn(), update: vi.fn(), + on: vi.fn(), }, selectedPlan: { price: { @@ -528,6 +530,7 @@ describe('Custom hook to handle payments', () => { getElement: vi.fn(), submit: vi.fn(), update: vi.fn(), + on: vi.fn(), }, selectedPlan: { price: { diff --git a/src/app/payment/services/payment.service.ts b/src/app/payment/services/payment.service.ts index 802510924d..d284d2d8c8 100644 --- a/src/app/payment/services/payment.service.ts +++ b/src/app/payment/services/payment.service.ts @@ -10,7 +10,7 @@ import { UserSubscription, UserType, } from '@internxt/sdk/dist/drive/payments/types/types'; -import { RedirectToCheckoutServerOptions, Source, Stripe, StripeError } from '@stripe/stripe-js'; +import { Source, Stripe } from '@stripe/stripe-js'; import { loadStripe } from '@stripe/stripe-js/pure'; import axios from 'axios'; import { SdkFactory } from '../../core/factory/sdk'; @@ -114,12 +114,6 @@ const paymentService = { return paymentsClient.getInvoices(payload); }, - async redirectToCheckout(options: RedirectToCheckoutServerOptions): Promise<{ error: StripeError }> { - const stripe = await this.getStripe(); - - return stripe.redirectToCheckout(options); - }, - async getUserSubscription(userType?: UserType): Promise { const paymentsClient = await SdkFactory.getNewApiInstance().createPaymentsClient(); return paymentsClient.getUserSubscription(userType); diff --git a/src/app/payment/views/CheckoutSession/CheckoutSessionId.tsx b/src/app/payment/views/CheckoutSession/CheckoutSessionId.tsx deleted file mode 100644 index b4d6dd3eac..0000000000 --- a/src/app/payment/views/CheckoutSession/CheckoutSessionId.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import errorService from 'app/core/services/error.service'; -import navigationService from 'app/core/services/navigation.service'; -import { AppView } from 'app/core/types'; -import paymentService from 'app/payment/services/payment.service'; -import { useEffect } from 'react'; -import { useParams } from 'react-router-dom'; - -export const CheckoutSessionId = () => { - const { sessionId } = useParams<{ sessionId: string }>(); - - const checkSessionId = (id: string): boolean => { - const pattern = /^cs_(test|live)_[a-zA-Z0-9]+$/; - return pattern.test(id); - }; - - useEffect(() => { - if (sessionId) { - const isValid = checkSessionId(sessionId); - - if (isValid) { - paymentService.redirectToCheckout({ sessionId }).catch((err) => { - errorService.reportError(err); - navigationService.push(AppView.CheckoutCancel); - }); - return; - } - } - }, [sessionId]); - - return <>; -}; diff --git a/src/app/store/index.ts b/src/app/store/index.ts index 128ffcfa1a..628becb4b0 100644 --- a/src/app/store/index.ts +++ b/src/app/store/index.ts @@ -2,7 +2,6 @@ import { configureStore } from '@reduxjs/toolkit'; import backupsReducer from './slices/backups'; import fileViewerReducer from './slices/fileViewer'; -import paymentReducer from './slices/payment'; import planReducer from './slices/plan'; import productsReducer from './slices/products'; import referralsReducer from './slices/referrals'; @@ -22,7 +21,6 @@ export const store = configureStore({ ui: uiReducer, plan: planReducer, products: productsReducer, - payment: paymentReducer, backups: backupsReducer, fileViewer: fileViewerReducer, taskManager: taskManagerReducer, diff --git a/yarn.lock b/yarn.lock index 8de08f9411..c7b31eea82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3068,17 +3068,17 @@ resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz#821f8442f4175d8f0467b9daf26e3a18e2d02af2" integrity sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA== -"@stripe/react-stripe-js@^2.7.1": - version "2.7.1" - resolved "https://registry.yarnpkg.com/@stripe/react-stripe-js/-/react-stripe-js-2.7.1.tgz#2be66166318fcb898c67a19e5b342364a2714d57" - integrity sha512-/i13alp27HaSBbMM6kW0jhy8KqdtOL1T/EcRjFjfhvt+CBtMEg8TD7y28W3oZG0+OBDdCyGGnXgNgrKPYQH40g== +"@stripe/react-stripe-js@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@stripe/react-stripe-js/-/react-stripe-js-5.2.0.tgz#c68a5207bc13520fb421c3f7bf386e08363072fe" + integrity sha512-m6CFXWjI5yikOcaP1L9xiabgkljdhu8vspoqF+BDD9mIjZIh1yEjeU0++oefqlXBd9U3QZj+C2ds4t3BDmICMg== dependencies: prop-types "^15.7.2" -"@stripe/stripe-js@^3.5.0": - version "3.5.0" - resolved "https://registry.yarnpkg.com/@stripe/stripe-js/-/stripe-js-3.5.0.tgz#7fff3d9d931e972c24dcc8ee25f7481a58879b2b" - integrity sha512-pKS3wZnJoL1iTyGBXAvCwduNNeghJHY6QSRSNNvpYnrrQrLZ6Owsazjyynu0e0ObRgks0i7Rv+pe2M7/MBTZpQ== +"@stripe/stripe-js@8.1.0": + version "8.1.0" + resolved "https://registry.yarnpkg.com/@stripe/stripe-js/-/stripe-js-8.1.0.tgz#d162df9f0a58b9d08c4fb7a4a670e8c90491c14e" + integrity sha512-bhhi0iSHDFRa2pPVv3WOHC6x/iGEu5AZqIiAvXsT8VOucsEre9gzgsK0jFzbzfGW2eeubF+mCdTTYwNAQCMJKg== "@svgr/babel-plugin-add-jsx-attribute@8.0.0": version "8.0.0" @@ -4877,7 +4877,7 @@ crypt@0.0.2: resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" integrity sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow== -crypto-browserify@^3.12.0, "crypto@npm:crypto-browserify": +crypto-browserify@^3.12.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== @@ -4917,6 +4917,23 @@ crypto-js@4.1.1: resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf" integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw== +"crypto@npm:crypto-browserify": + version "3.12.0" + resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" + integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== + dependencies: + browserify-cipher "^1.0.0" + browserify-sign "^4.0.0" + create-ecdh "^4.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.0" + diffie-hellman "^5.0.0" + inherits "^2.0.1" + pbkdf2 "^3.0.3" + public-encrypt "^4.0.0" + randombytes "^2.0.0" + randomfill "^1.0.3" + css-functions-list@^3.2.3: version "3.2.3" resolved "https://registry.yarnpkg.com/css-functions-list/-/css-functions-list-3.2.3.tgz#95652b0c24f0f59b291a9fc386041a19d4f40dbe" @@ -8924,7 +8941,16 @@ string-template@1.0.0: resolved "https://registry.yarnpkg.com/string-template/-/string-template-1.0.0.tgz#9e9f2233dc00f218718ec379a28a5673ecca8b96" integrity sha512-SLqR3GBUXuoPP5MmYtD7ompvXiG87QjT6lzOszyXjTM86Uu7At7vNnt2xgyTLq5o9T4IxTYFyGxcULqpsmsfdg== -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -8963,7 +8989,14 @@ stringz@2.1.0: dependencies: char-regex "^1.0.2" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -9850,7 +9883,7 @@ word-wrap@^1.2.5, word-wrap@~1.2.3: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -9868,6 +9901,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.0.1, wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" From 1521085c8f8289caea3881ee148f98d523d66d73 Mon Sep 17 00:00:00 2001 From: larryrider Date: Fri, 17 Oct 2025 13:55:59 +0200 Subject: [PATCH 2/3] feat: remove unused legacy payment slice --- src/app/store/slices/payment/index.ts | 87 --------------------------- 1 file changed, 87 deletions(-) delete mode 100644 src/app/store/slices/payment/index.ts diff --git a/src/app/store/slices/payment/index.ts b/src/app/store/slices/payment/index.ts deleted file mode 100644 index f949d616ec..0000000000 --- a/src/app/store/slices/payment/index.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'; - -import { t } from 'i18next'; -import { RootState } from '../..'; -import envService from '../../../core/services/env.service'; -import errorService from '../../../core/services/error.service'; -import notificationsService, { ToastType } from '../../../notifications/services/notifications.service'; -import paymentService, { CreatePaymentSessionPayload } from '../../../payment/services/payment.service'; -import { ProductData, ProductPriceType, StripeSessionMode } from '../../../payment/types'; - -interface PaymentState { - isBuying: boolean; - currentPriceId: string; -} - -const initialState: PaymentState = { - isBuying: false, - currentPriceId: '', -}; - -export interface CheckoutThunkPayload { - product: ProductData; -} - -export const checkoutThunk = createAsyncThunk( - 'payment/checkout', - async (payload: CheckoutThunkPayload) => { - const body: CreatePaymentSessionPayload = { - test: envService.isProduction() ? undefined : true, - // eslint-disable-next-line max-len - successUrl: - envService.getVariable('hostname') + - `/checkout/success?price_id=${payload.product.price.id}&cs_id={CHECKOUT_SESSION_ID}`, - mode: - payload.product.price.type === ProductPriceType.OneTime - ? StripeSessionMode.Payment - : StripeSessionMode.Subscription, - priceId: payload.product.price.id, - }; - body.lifetime_tier = payload.product.metadata.lifetime_tier; - - try { - const session = await paymentService.createSession(body); - - await paymentService.redirectToCheckout({ sessionId: session.id }); - } catch (err: unknown) { - const castedError = errorService.castError(err); - - notificationsService.show({ - text: t('error.redirectToStripe', { - reason: castedError.message, - }), - type: ToastType.Error, - }); - } - }, -); - -export const paymentSlice = createSlice({ - name: 'payment', - initialState, - reducers: {}, - extraReducers: (builder) => { - builder - .addCase(checkoutThunk.pending, (state, action) => { - state.isBuying = true; - state.currentPriceId = action.meta.arg.product.price.id; - }) - .addCase(checkoutThunk.fulfilled, (state) => { - state.isBuying = false; - }) - .addCase(checkoutThunk.rejected, (state) => { - state.isBuying = false; - state.currentPriceId = ''; - }); - }, -}); - -export const paymentSelectors = {}; - -export const paymentActions = paymentSlice.actions; - -export const paymentThunks = { - checkoutThunk, -}; - -export default paymentSlice.reducer; From dc32431efaf5fed09f3e08706785448640ffb441 Mon Sep 17 00:00:00 2001 From: larryrider Date: Fri, 17 Oct 2025 15:02:48 +0200 Subject: [PATCH 3/3] feat: update @iconscout/react-unicons dependency to version 2.2.5 --- package.json | 2 +- yarn.lock | 19 +++++-------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 1ac18f45fe..b71ef36dec 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "dependencies": { "@dashlane/pqc-kem-kyber512-browser": "^1.0.0", "@headlessui/react": "1.7.5", - "@iconscout/react-unicons": "^1.1.6", + "@iconscout/react-unicons": "2.2.5", "@internxt/css-config": "1.0.3", "@internxt/lib": "1.3.1", "@internxt/sdk": "=1.11.11", diff --git a/yarn.lock b/yarn.lock index c7b31eea82..ab5bf40b00 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1839,12 +1839,12 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== -"@iconscout/react-unicons@^1.1.6": - version "1.1.6" - resolved "https://registry.yarnpkg.com/@iconscout/react-unicons/-/react-unicons-1.1.6.tgz#4137afb831666f9c6d3b45a410610b9db9507f3a" - integrity sha512-BnyVvBew7Vm1lvL8+qyqjchUbkVHlDyNAlN+r5b+0P0KrkQ66BHPBuJEJ2faT89L8qRu+TohE7dHMV+bndje3Q== +"@iconscout/react-unicons@2.2.5": + version "2.2.5" + resolved "https://registry.yarnpkg.com/@iconscout/react-unicons/-/react-unicons-2.2.5.tgz#d7a27fb0e30e87d77d45ac02e4e765d85f242026" + integrity sha512-Qn1YqlQPKUjgeGvtbsOWFlnmYBJL5iYpK+B+/nsUDz0tm8BmHQeGn9MsfSBB0WVYtLWiChhz5AQHbvXKqtWDmw== dependencies: - react ">=15.0.0 <17.0.0" + prop-types "^15.8.1" "@inquirer/confirm@^5.0.0": version "5.0.2" @@ -8330,15 +8330,6 @@ react-window@^1.8.11: "@babel/runtime" "^7.0.0" memoize-one ">=3.1.1 <6" -"react@>=15.0.0 <17.0.0": - version "16.14.0" - resolved "https://registry.yarnpkg.com/react/-/react-16.14.0.tgz#94d776ddd0aaa37da3eda8fc5b6b18a4c9a3114d" - integrity sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - prop-types "^15.6.2" - react@^18.2.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"