diff --git a/ts/features/payments/barcode/screens/PaymentsBarcodeChoiceScreen.tsx b/ts/features/payments/barcode/screens/PaymentsBarcodeChoiceScreen.tsx index 55276bd2e83..06fbd849435 100644 --- a/ts/features/payments/barcode/screens/PaymentsBarcodeChoiceScreen.tsx +++ b/ts/features/payments/barcode/screens/PaymentsBarcodeChoiceScreen.tsx @@ -31,6 +31,7 @@ import { import { useIODispatch } from "../../../../store/hooks"; import * as analytics from "../../../barcode/analytics"; import { PagoPaBarcode } from "../../../barcode/types/IOBarcode"; +import { usePagoPaPayment } from "../../checkout/hooks/usePagoPaPayment"; import { PaymentNoticeListItem } from "../components/PaymentNoticeListItem"; import { PaymentsBarcodeParamsList } from "../navigation/params"; @@ -47,6 +48,9 @@ const PaymentsBarcodeChoiceScreen = () => { const dispatch = useIODispatch(); const navigation = useNavigation>(); + const { startPaymentFlowWithRptId, isNewWalletSectionEnabled } = + usePagoPaPayment(); + useFocusEffect( React.useCallback(() => { analytics.trackBarcodeMultipleCodesScreenView(); @@ -65,15 +69,19 @@ const PaymentsBarcodeChoiceScreen = () => { : "qrcode_scan"; analytics.trackBarcodeMultipleCodesSelection(); - dispatch(paymentInitializeState()); - navigation.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: ROUTES.PAYMENT_TRANSACTION_SUMMARY, - params: { - initialAmount: barcode.amount, - rptId: barcode.rptId, - paymentStartOrigin - } - }); + if (isNewWalletSectionEnabled) { + startPaymentFlowWithRptId(barcode.rptId); + } else { + dispatch(paymentInitializeState()); + navigation.navigate(ROUTES.WALLET_NAVIGATOR, { + screen: ROUTES.PAYMENT_TRANSACTION_SUMMARY, + params: { + initialAmount: barcode.amount, + rptId: barcode.rptId, + paymentStartOrigin + } + }); + } }; const renderBarcodeItem = (barcode: PagoPaBarcode) => { diff --git a/ts/features/payments/barcode/screens/PaymentsBarcodeScanScreen.tsx b/ts/features/payments/barcode/screens/PaymentsBarcodeScanScreen.tsx index f8985902a4d..0b5d79d64da 100644 --- a/ts/features/payments/barcode/screens/PaymentsBarcodeScanScreen.tsx +++ b/ts/features/payments/barcode/screens/PaymentsBarcodeScanScreen.tsx @@ -1,3 +1,4 @@ +import { IOToast } from "@pagopa/io-app-design-system"; import { useNavigation } from "@react-navigation/native"; import * as A from "fp-ts/lib/Array"; import { pipe } from "fp-ts/lib/function"; @@ -5,7 +6,6 @@ import * as React from "react"; import ReactNativeHapticFeedback, { HapticFeedbackTypes } from "react-native-haptic-feedback"; -import { IOToast } from "@pagopa/io-app-design-system"; import { ContextualHelpPropsMarkdown } from "../../../../components/screens/BaseScreenComponent"; import I18n from "../../../../i18n"; import { mixpanelTrack } from "../../../../mixpanel"; @@ -32,6 +32,7 @@ import { IO_BARCODE_ALL_FORMATS, PagoPaBarcode } from "../../../barcode/types/IOBarcode"; +import { usePagoPaPayment } from "../../checkout/hooks/usePagoPaPayment"; import { PaymentsCheckoutRoutes } from "../../checkout/navigation/routes"; import { PaymentsBarcodeRoutes } from "../navigation/routes"; @@ -48,6 +49,9 @@ const PaymentsBarcodeScanScreen = () => { ); const isDesignSystemEnabled = useIOSelector(isDesignSystemEnabledSelector); + const { startPaymentFlowWithRptId, isNewWalletSectionEnabled } = + usePagoPaPayment(); + const barcodeFormats: Array = IO_BARCODE_ALL_FORMATS.filter( format => (format === "DATA_MATRIX" ? dataMatrixPosteEnabled : true) ); @@ -89,31 +93,34 @@ const PaymentsBarcodeScanScreen = () => { const barcode = pagoPaBarcodes[0]; if (barcode.type === "PAGOPA") { - dispatch(paymentInitializeState()); - - switch (barcode.format) { - case "QR_CODE": - navigation.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: ROUTES.PAYMENT_TRANSACTION_SUMMARY, - params: { - initialAmount: barcode.amount, - rptId: barcode.rptId, - paymentStartOrigin: "qrcode_scan" - } - }); - break; - case "DATA_MATRIX": - void mixpanelTrack("WALLET_SCAN_POSTE_DATAMATRIX_SUCCESS"); - navigation.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: ROUTES.PAYMENT_TRANSACTION_SUMMARY, - params: { - initialAmount: barcode.amount, - rptId: barcode.rptId, - paymentStartOrigin: "poste_datamatrix_scan" - } - }); - - break; + if (isNewWalletSectionEnabled) { + startPaymentFlowWithRptId(barcode.rptId); + } else { + dispatch(paymentInitializeState()); + switch (barcode.format) { + case "QR_CODE": + navigation.navigate(ROUTES.WALLET_NAVIGATOR, { + screen: ROUTES.PAYMENT_TRANSACTION_SUMMARY, + params: { + initialAmount: barcode.amount, + rptId: barcode.rptId, + paymentStartOrigin: "qrcode_scan" + } + }); + break; + case "DATA_MATRIX": + void mixpanelTrack("WALLET_SCAN_POSTE_DATAMATRIX_SUCCESS"); + navigation.navigate(ROUTES.WALLET_NAVIGATOR, { + screen: ROUTES.PAYMENT_TRANSACTION_SUMMARY, + params: { + initialAmount: barcode.amount, + rptId: barcode.rptId, + paymentStartOrigin: "poste_datamatrix_scan" + } + }); + + break; + } } } }; diff --git a/ts/features/payments/checkout/components/WalletPaymentFeedbackBanner.tsx b/ts/features/payments/checkout/components/WalletPaymentFeedbackBanner.tsx index 3bd7baf454f..f8e0f0f885e 100644 --- a/ts/features/payments/checkout/components/WalletPaymentFeedbackBanner.tsx +++ b/ts/features/payments/checkout/components/WalletPaymentFeedbackBanner.tsx @@ -17,6 +17,9 @@ const WalletPaymentFeebackBanner = () => { return openAuthenticationSession(WALLET_PAYMENT_FEEDBACK_URL, ""); }; + // This banner is temporarily disabled. Remove the next line to re-enable it + return null; + return ( <> diff --git a/ts/features/payments/checkout/hooks/usePagoPaPayment.ts b/ts/features/payments/checkout/hooks/usePagoPaPayment.ts index 0c2932dd12c..e3d474958a1 100644 --- a/ts/features/payments/checkout/hooks/usePagoPaPayment.ts +++ b/ts/features/payments/checkout/hooks/usePagoPaPayment.ts @@ -4,54 +4,66 @@ import { PaymentNoticeNumberFromString } from "@pagopa/io-pagopa-commons/lib/pagopa"; import { OrganizationFiscalCode } from "@pagopa/ts-commons/lib/strings"; -import { NavigatorScreenParams, useRoute } from "@react-navigation/native"; import { sequenceS } from "fp-ts/lib/Apply"; import * as E from "fp-ts/lib/Either"; import * as O from "fp-ts/lib/Option"; import { pipe } from "fp-ts/lib/function"; import { RptId } from "../../../../../definitions/pagopa/ecommerce/RptId"; -import { - AppParamsList, - useIONavigation -} from "../../../../navigation/params/AppParamsList"; -import { useIODispatch } from "../../../../store/hooks"; +import { useIONavigation } from "../../../../navigation/params/AppParamsList"; +import { useIODispatch, useIOSelector } from "../../../../store/hooks"; import { PaymentsCheckoutRoutes } from "../navigation/routes"; import { PaymentInitStateParams, initPaymentStateAction } from "../store/actions/orchestration"; -import { PaymentStartRoute } from "../types"; +import { isNewWalletSectionEnabledSelector } from "../../../../store/reducers/persistedPreferences"; type PagoPaPaymentParams = Omit; +const DEFAULT_PAYMENT_PARAMS: PagoPaPaymentParams = {}; + +type PaymentData = { + paymentNoticeNumber: string; + organizationFiscalCode: string; +}; + +type UsePagoPaPayment = { + startPaymentFlow: (rptId: RptId, params?: PagoPaPaymentParams) => void; + startPaymentFlowWithRptId: ( + rptId: PagoPaRptId, + params?: PagoPaPaymentParams + ) => void; + startPaymentFlowWithData: ( + data: PaymentData, + params?: PagoPaPaymentParams + ) => void; + // This is a temporary flag to tell that the new payment flow is enabled and can be used + // Will be removed once the new wallet section is released + isNewWalletSectionEnabled: boolean; +}; + /** * A hook for initiating a PagoPA payment flow. * This hook provides functions to start a payment flow using various input methods. * @returns An object containing functions to start different types of payment flows. */ -const usePagoPaPayment = () => { - const route = useRoute(); +const usePagoPaPayment = (): UsePagoPaPayment => { const dispatch = useIODispatch(); const navigation = useIONavigation(); + // Checks if the new wallet section is enabled + const isNewWalletSectionEnabled = useIOSelector( + isNewWalletSectionEnabledSelector + ); + /** * Initializes the payment state based on the provided parameters. * The initialization includes the store of the current route which allows the app to * return to it when the payment flow is finished. * @param {PagoPaPaymentParams} params - Parameters for initializing the payment state. */ - const initPaymentState = ({ startOrigin }: PagoPaPaymentParams) => { - const startRoute: PaymentStartRoute = { - routeName: route.name as keyof AppParamsList, - routeKey: - route.key as keyof NavigatorScreenParams["screen"] - }; - dispatch( - initPaymentStateAction({ - startRoute, - startOrigin - }) - ); + const initPaymentState = (params: PagoPaPaymentParams) => { + dispatch(initPaymentStateAction(params)); }; /** @@ -59,7 +71,10 @@ const usePagoPaPayment = () => { * @param {RptId} rptId - The RptId for the payment flow. * @param {PagoPaPaymentParams} params - Additional parameters for the payment flow. */ - const startPaymentFlow = (rptId: RptId, params: PagoPaPaymentParams = {}) => { + const startPaymentFlow = ( + rptId: RptId, + params: PagoPaPaymentParams = DEFAULT_PAYMENT_PARAMS + ) => { initPaymentState(params); navigation.navigate(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { screen: PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_DETAIL, @@ -76,7 +91,7 @@ const usePagoPaPayment = () => { */ const startPaymentFlowWithRptId = ( rptId: PagoPaRptId, - params: PagoPaPaymentParams = {} + params: PagoPaPaymentParams = DEFAULT_PAYMENT_PARAMS ) => { pipe( O.fromNullable(rptId), @@ -93,11 +108,8 @@ const usePagoPaPayment = () => { * @param {PagoPaPaymentParams} params - Additional parameters for the payment flow. */ const startPaymentFlowWithData = ( - data: { - paymentNoticeNumber: string; - organizationFiscalCode: string; - }, - params: PagoPaPaymentParams = {} + data: PaymentData, + params: PagoPaPaymentParams = DEFAULT_PAYMENT_PARAMS ) => { pipe( sequenceS(E.Monad)({ @@ -117,7 +129,8 @@ const usePagoPaPayment = () => { return { startPaymentFlow, startPaymentFlowWithRptId, - startPaymentFlowWithData + startPaymentFlowWithData, + isNewWalletSectionEnabled }; }; diff --git a/ts/features/payments/checkout/hooks/useWalletPaymentGoBackHandler.tsx b/ts/features/payments/checkout/hooks/useWalletPaymentGoBackHandler.tsx index c9d45a22d3e..13fc9c328de 100644 --- a/ts/features/payments/checkout/hooks/useWalletPaymentGoBackHandler.tsx +++ b/ts/features/payments/checkout/hooks/useWalletPaymentGoBackHandler.tsx @@ -30,7 +30,7 @@ const useWalletPaymentGoBackHandler = () => { const handleConfirmAbort = () => { dispatch(paymentsDeleteTransactionAction.request(transactionId)); - navigation.push(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { + navigation.replace(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { screen: PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_OUTCOME, params: { outcome: WalletPaymentOutcomeEnum.CANCELED_BY_USER diff --git a/ts/features/payments/checkout/screens/WalletPaymentConfirmScreen.tsx b/ts/features/payments/checkout/screens/WalletPaymentConfirmScreen.tsx index 3b81de67bac..6deea893463 100644 --- a/ts/features/payments/checkout/screens/WalletPaymentConfirmScreen.tsx +++ b/ts/features/payments/checkout/screens/WalletPaymentConfirmScreen.tsx @@ -59,7 +59,7 @@ const WalletPaymentConfirmScreen = () => { const handleAuthorizationOutcome = React.useCallback( (outcome: WalletPaymentOutcome) => { - navigation.navigate(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { + navigation.replace(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { screen: PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_OUTCOME, params: { outcome diff --git a/ts/features/payments/checkout/screens/WalletPaymentDetailScreen.tsx b/ts/features/payments/checkout/screens/WalletPaymentDetailScreen.tsx index 031fc9b95e3..cd6a435a15a 100644 --- a/ts/features/payments/checkout/screens/WalletPaymentDetailScreen.tsx +++ b/ts/features/payments/checkout/screens/WalletPaymentDetailScreen.tsx @@ -135,7 +135,7 @@ const WalletPaymentDetailContent = ({ const navigateToMakePaymentScreen = () => { dispatch(storeNewPaymentAttemptAction(rptId)); - navigation.push(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { + navigation.navigate(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { screen: PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_MAKE }); }; diff --git a/ts/features/payments/checkout/screens/WalletPaymentInputFiscalCodeScreen.tsx b/ts/features/payments/checkout/screens/WalletPaymentInputFiscalCodeScreen.tsx index 525261c8c37..03580b0834e 100644 --- a/ts/features/payments/checkout/screens/WalletPaymentInputFiscalCodeScreen.tsx +++ b/ts/features/payments/checkout/screens/WalletPaymentInputFiscalCodeScreen.tsx @@ -35,16 +35,15 @@ import { } from "../../../../navigation/params/AppParamsList"; import ROUTES from "../../../../navigation/routes"; import { paymentInitializeState } from "../../../../store/actions/wallet/payment"; -import { useIODispatch, useIOSelector } from "../../../../store/hooks"; +import { useIODispatch } from "../../../../store/hooks"; import themeVariables from "../../../../theme/variables"; import { emptyContextualHelp } from "../../../../utils/emptyContextualHelp"; import { decodeOrganizationFiscalCode, validateOrganizationFiscalCode } from "../../common/utils/validation"; -import { PaymentsCheckoutParamsList } from "../navigation/params"; -import { isNewWalletSectionEnabledSelector } from "../../../../store/reducers/persistedPreferences"; import { usePagoPaPayment } from "../hooks/usePagoPaPayment"; +import { PaymentsCheckoutParamsList } from "../navigation/params"; export type WalletPaymentInputFiscalCodeScreenNavigationParams = { paymentNoticeNumber: O.Option; @@ -64,11 +63,9 @@ const WalletPaymentInputFiscalCodeScreen = () => { const { params } = useRoute(); const dispatch = useIODispatch(); const navigation = useNavigation>(); - const isNewWalletSectionEnabled = useIOSelector( - isNewWalletSectionEnabledSelector - ); - const { startPaymentFlowWithRptId } = usePagoPaPayment(); + const { startPaymentFlowWithRptId, isNewWalletSectionEnabled } = + usePagoPaPayment(); const [inputState, setInputState] = React.useState({ fiscalCodeText: "", @@ -91,6 +88,10 @@ const WalletPaymentInputFiscalCodeScreen = () => { }), O.chain(flow(RptId.decode, O.fromEither)), O.map(rptId => { + // Removes the manual input screen from the stack + navigation.popToTop(); + navigation.pop(); + // Navigate to the payment details screen (payment verification) if (isNewWalletSectionEnabled) { startPaymentFlowWithRptId(rptId); } else { diff --git a/ts/features/payments/checkout/screens/WalletPaymentMakeScreen.tsx b/ts/features/payments/checkout/screens/WalletPaymentMakeScreen.tsx index accc0717bee..e3ca4ab3ee0 100644 --- a/ts/features/payments/checkout/screens/WalletPaymentMakeScreen.tsx +++ b/ts/features/payments/checkout/screens/WalletPaymentMakeScreen.tsx @@ -1,6 +1,8 @@ -import React from "react"; -import { StyleSheet, View } from "react-native"; +import { IOStyles } from "@pagopa/io-app-design-system"; +import React, { useLayoutEffect } from "react"; +import { View } from "react-native"; import PagerView from "react-native-pager-view"; +import { useIONavigation } from "../../../../navigation/params/AppParamsList"; import { useIOSelector } from "../../../../store/hooks"; import { WalletPaymentHeader } from "../components/WalletPaymentHeader"; import { selectWalletPaymentCurrentStep } from "../store/selectors"; @@ -9,6 +11,7 @@ import { WalletPaymentPickMethodScreen } from "./WalletPaymentPickMethodScreen"; import { WalletPaymentPickPspScreen } from "./WalletPaymentPickPspScreen"; const WalletPaymentMakeScreen = () => { + const navigation = useIONavigation(); const ref = React.useRef(null); const currentStep = useIOSelector(selectWalletPaymentCurrentStep); @@ -16,33 +19,31 @@ const WalletPaymentMakeScreen = () => { ref.current?.setPage(currentStep - 1); }, [ref, currentStep]); + useLayoutEffect(() => { + navigation.setOptions({ + header: () => , + headerShown: true + }); + }, [navigation, currentStep]); + return ( - <> - - - - - - - - - - - - - + + + + + + + + + + + ); }; -const styles = StyleSheet.create({ - pagerView: { - flex: 1 - } -}); - export { WalletPaymentMakeScreen }; diff --git a/ts/features/payments/checkout/screens/WalletPaymentOutcomeScreen.tsx b/ts/features/payments/checkout/screens/WalletPaymentOutcomeScreen.tsx index f52dff4bcbf..6f82e4141dc 100644 --- a/ts/features/payments/checkout/screens/WalletPaymentOutcomeScreen.tsx +++ b/ts/features/payments/checkout/screens/WalletPaymentOutcomeScreen.tsx @@ -10,6 +10,7 @@ import { import I18n from "../../../../i18n"; import { useIONavigation } from "../../../../navigation/params/AppParamsList"; import { useIOSelector } from "../../../../store/hooks"; +import { profileEmailSelector } from "../../../../store/reducers/profile"; import { formatNumberCentsToAmount } from "../../../../utils/stringBuilder"; import { useAvoidHardwareBackButton } from "../../../../utils/useAvoidHardwareBackButton"; import { WalletPaymentFeebackBanner } from "../components/WalletPaymentFeedbackBanner"; @@ -17,13 +18,13 @@ import { usePaymentFailureSupportModal } from "../hooks/usePaymentFailureSupport import { PaymentsCheckoutParamsList } from "../navigation/params"; import { walletPaymentDetailsSelector, - walletPaymentStartRouteSelector + walletPaymentOnSuccessActionSelector } from "../store/selectors"; import { WalletPaymentOutcome, WalletPaymentOutcomeEnum } from "../types/PaymentOutcomeEnum"; -import { profileEmailSelector } from "../../../../store/reducers/profile"; +import ROUTES from "../../../../navigation/routes"; type WalletPaymentOutcomeScreenNavigationParams = { outcome: WalletPaymentOutcome; @@ -42,7 +43,7 @@ const WalletPaymentOutcomeScreen = () => { const navigation = useIONavigation(); const paymentDetailsPot = useIOSelector(walletPaymentDetailsSelector); - const paymentStartRoute = useIOSelector(walletPaymentStartRouteSelector); + const onSuccessAction = useIOSelector(walletPaymentOnSuccessActionSelector); const profileEmailOption = useIOSelector(profileEmailSelector); const supportModal = usePaymentFailureSupportModal({ @@ -73,14 +74,19 @@ const WalletPaymentOutcomeScreen = () => { }; const handleClose = () => { - if (paymentStartRoute) { - // TODO: this is a workaround to solve type errors need to investigate deeply - navigation.navigate(paymentStartRoute.routeName as any, { - screen: paymentStartRoute.routeKey + if ( + onSuccessAction === "showHome" || + onSuccessAction === "showTransaction" + ) { + // Currently we do support only navigation to the wallet + // TODO navigate to the transaction details if payment outcome is success + navigation.popToTop(); + navigation.navigate(ROUTES.MAIN, { + screen: ROUTES.PAYMENTS_HOME }); return; } - navigation.popToTop(); + navigation.pop(); }; diff --git a/ts/features/payments/checkout/screens/WalletPaymentPickMethodScreen.tsx b/ts/features/payments/checkout/screens/WalletPaymentPickMethodScreen.tsx index cbdf4b3fb5e..2bc9183b7b7 100644 --- a/ts/features/payments/checkout/screens/WalletPaymentPickMethodScreen.tsx +++ b/ts/features/payments/checkout/screens/WalletPaymentPickMethodScreen.tsx @@ -169,7 +169,7 @@ const WalletPaymentPickMethodScreen = () => { React.useEffect(() => { if (isError) { - navigation.navigate(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { + navigation.replace(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { screen: PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_OUTCOME, params: { outcome: WalletPaymentOutcomeEnum.GENERIC_ERROR diff --git a/ts/features/payments/checkout/screens/WalletPaymentPickPspScreen.tsx b/ts/features/payments/checkout/screens/WalletPaymentPickPspScreen.tsx index 994c2ab22e4..7d643d5e237 100644 --- a/ts/features/payments/checkout/screens/WalletPaymentPickPspScreen.tsx +++ b/ts/features/payments/checkout/screens/WalletPaymentPickPspScreen.tsx @@ -56,7 +56,7 @@ const WalletPaymentPickPspScreen = () => { React.useEffect(() => { if (isError) { - navigation.navigate(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { + navigation.replace(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { screen: PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_OUTCOME, params: { outcome: WalletPaymentOutcomeEnum.GENERIC_ERROR diff --git a/ts/features/payments/checkout/store/actions/orchestration.ts b/ts/features/payments/checkout/store/actions/orchestration.ts index 2873a27305c..339b0d7d890 100644 --- a/ts/features/payments/checkout/store/actions/orchestration.ts +++ b/ts/features/payments/checkout/store/actions/orchestration.ts @@ -1,20 +1,17 @@ import { ActionType, createStandardAction } from "typesafe-actions"; import { Bundle } from "../../../../../../definitions/pagopa/ecommerce/Bundle"; import { WalletInfo } from "../../../../../../definitions/pagopa/ecommerce/WalletInfo"; -import { - PaymentStartOrigin, - PaymentStartRoute, - WalletPaymentStepEnum -} from "../../types"; +import { PaymentStartOrigin, WalletPaymentStepEnum } from "../../types"; export const walletPaymentSetCurrentStep = createStandardAction( "WALLET_PAYMENT_SET_CURRENT_STEP" )(); +export type OnPaymentSuccessAction = "showHome" | "showTransaction"; + export type PaymentInitStateParams = { startOrigin?: PaymentStartOrigin; - startRoute?: PaymentStartRoute; - showTransaction?: boolean; + onSuccess?: OnPaymentSuccessAction; }; /** diff --git a/ts/features/payments/checkout/store/reducers/index.ts b/ts/features/payments/checkout/store/reducers/index.ts index 65db870055d..60e14dcb2ee 100644 --- a/ts/features/payments/checkout/store/reducers/index.ts +++ b/ts/features/payments/checkout/store/reducers/index.ts @@ -7,31 +7,32 @@ import { PaymentMethodsResponse } from "../../../../../../definitions/pagopa/eco import { PaymentRequestsGetResponse } from "../../../../../../definitions/pagopa/ecommerce/PaymentRequestsGetResponse"; import { RptId } from "../../../../../../definitions/pagopa/ecommerce/RptId"; import { TransactionInfo } from "../../../../../../definitions/pagopa/ecommerce/TransactionInfo"; +import { WalletInfo } from "../../../../../../definitions/pagopa/ecommerce/WalletInfo"; +import { Wallets } from "../../../../../../definitions/pagopa/ecommerce/Wallets"; import { Action } from "../../../../../store/actions/types"; import { NetworkError } from "../../../../../utils/errors"; -import { PaymentStartRoute, WalletPaymentStepEnum } from "../../types"; +import { WalletPaymentStepEnum } from "../../types"; +import { WalletPaymentFailure } from "../../types/WalletPaymentFailure"; import { - paymentsStartPaymentAuthorizationAction, paymentsCalculatePaymentFeesAction, paymentsCreateTransactionAction, paymentsDeleteTransactionAction, - paymentsGetPaymentMethodsAction, + paymentsGetNewSessionTokenAction, paymentsGetPaymentDetailsAction, + paymentsGetPaymentMethodsAction, paymentsGetPaymentTransactionInfoAction, paymentsGetPaymentUserMethodsAction, - paymentsGetNewSessionTokenAction, - paymentsResetPaymentPspList + paymentsResetPaymentPspList, + paymentsStartPaymentAuthorizationAction } from "../actions/networking"; import { + OnPaymentSuccessAction, initPaymentStateAction, + resetPaymentPspAction, selectPaymentMethodAction, selectPaymentPspAction, - resetPaymentPspAction, walletPaymentSetCurrentStep } from "../actions/orchestration"; -import { WalletPaymentFailure } from "../../types/WalletPaymentFailure"; -import { Wallets } from "../../../../../../definitions/pagopa/ecommerce/Wallets"; -import { WalletInfo } from "../../../../../../definitions/pagopa/ecommerce/WalletInfo"; export const WALLET_PAYMENT_STEP_MAX = 4; @@ -50,8 +51,7 @@ export type PaymentsCheckoutState = { chosenPsp: O.Option; transaction: pot.Pot; authorizationUrl: pot.Pot; - startRoute?: PaymentStartRoute; - showTransaction?: boolean; + onSuccess?: OnPaymentSuccessAction; }; const INITIAL_STATE: PaymentsCheckoutState = { @@ -76,8 +76,7 @@ const reducer = ( case getType(initPaymentStateAction): return { ...INITIAL_STATE, - startRoute: action.payload.startRoute, - showTransaction: action.payload.showTransaction + onSuccess: action.payload.onSuccess }; case getType(walletPaymentSetCurrentStep): diff --git a/ts/features/payments/checkout/store/selectors/index.ts b/ts/features/payments/checkout/store/selectors/index.ts index 640a295994c..a99e423d871 100644 --- a/ts/features/payments/checkout/store/selectors/index.ts +++ b/ts/features/payments/checkout/store/selectors/index.ts @@ -72,5 +72,5 @@ export const walletPaymentTransactionSelector = (state: GlobalState) => export const walletPaymentAuthorizationUrlSelector = (state: GlobalState) => selectPaymentsCheckoutState(state).authorizationUrl; -export const walletPaymentStartRouteSelector = (state: GlobalState) => - selectPaymentsCheckoutState(state).startRoute; +export const walletPaymentOnSuccessActionSelector = (state: GlobalState) => + selectPaymentsCheckoutState(state).onSuccess; diff --git a/ts/features/payments/checkout/types/index.ts b/ts/features/payments/checkout/types/index.ts index 23e29991e70..0e9d6fb26fa 100644 --- a/ts/features/payments/checkout/types/index.ts +++ b/ts/features/payments/checkout/types/index.ts @@ -1,6 +1,3 @@ -import { NavigatorScreenParams } from "@react-navigation/native"; -import { AppParamsList } from "../../../../navigation/params/AppParamsList"; - export type WalletPaymentPspSortType = "default" | "name" | "amount"; export type PaymentStartOrigin = @@ -10,11 +7,6 @@ export type PaymentStartOrigin = | "manual_insertion" | "donation"; -export type PaymentStartRoute = { - routeName: keyof AppParamsList; - routeKey: NavigatorScreenParams["screen"]; -}; - export enum WalletPaymentStepEnum { NONE = 0, PICK_PAYMENT_METHOD = 1, diff --git a/ts/features/payments/home/screens/PaymentsHomeScreen.tsx b/ts/features/payments/home/screens/PaymentsHomeScreen.tsx index e6d0357d8ee..738994d3324 100644 --- a/ts/features/payments/home/screens/PaymentsHomeScreen.tsx +++ b/ts/features/payments/home/screens/PaymentsHomeScreen.tsx @@ -2,7 +2,7 @@ import { GradientScrollView, VSpacer } from "@pagopa/io-app-design-system"; import * as React from "react"; import I18n from "../../../../i18n"; import { useIONavigation } from "../../../../navigation/params/AppParamsList"; -import { PaymentsCheckoutRoutes } from "../../checkout/navigation/routes"; +import { PaymentsBarcodeRoutes } from "../../barcode/navigation/routes"; import { PaymentsHomeTransactionList } from "../components/PaymentsHomeTransactionList"; import { PaymentsHomeUserMethodsList } from "../components/PaymentsHomeUserMethodsList"; @@ -10,8 +10,8 @@ export const PaymentsHomeScreen = () => { const navigation = useIONavigation(); const handleOnPayNoticedPress = () => { - navigation.navigate(PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_NAVIGATOR, { - screen: PaymentsCheckoutRoutes.PAYMENT_CHECKOUT_INPUT_NOTICE_NUMBER + navigation.navigate(PaymentsBarcodeRoutes.PAYMENT_BARCODE_NAVIGATOR, { + screen: PaymentsBarcodeRoutes.PAYMENT_BARCODE_SCAN }); };