diff --git a/src/features/AddCardForm/components/Form/hooks/index.tsx b/src/features/AddCardForm/components/Form/hooks/index.tsx index ae6c9d8a..3efb83c3 100644 --- a/src/features/AddCardForm/components/Form/hooks/index.tsx +++ b/src/features/AddCardForm/components/Form/hooks/index.tsx @@ -87,8 +87,9 @@ export const useFormSubmit = ({ onAddSuccess }: Props) => { const [errorMessage, setErrorMessage] = useState('') const [loader, setLoader] = useState(false) const dataHighlights = useRecoilValue(dataForPayHighlights) + const { - onConfirmationSuccessHiglights, + onSuccessfulHighlights, onUnsuccessfulSubscription, } = useBuyMatchPopupStore() @@ -189,7 +190,7 @@ export const useFormSubmit = ({ onAddSuccess }: Props) => { cardId: defaultCard?.id, order: { ...dataHighlights?.data }, }) - .then(() => onConfirmationSuccessHiglights, onUnsuccessfulSubscription) + .then(onSuccessfulHighlights, onUnsuccessfulSubscription) .catch(() => setErrorMessage(translate('error_payment_unsuccessful'))) .finally(() => setLoader(false)) return @@ -234,7 +235,7 @@ export const useFormSubmit = ({ onAddSuccess }: Props) => { cardId: defaultCard.id, order: { ...dataHighlights?.data }, }) - .then(() => onConfirmationSuccessHiglights, onUnsuccessfulSubscription) + .then(onSuccessfulHighlights, onUnsuccessfulSubscription) .catch(() => setErrorMessage(translate('error_payment_unsuccessful'))) } }) diff --git a/src/features/BuyMatchPopup/store/hooks/index.tsx b/src/features/BuyMatchPopup/store/hooks/index.tsx index 2188c3cc..4dc583c6 100644 --- a/src/features/BuyMatchPopup/store/hooks/index.tsx +++ b/src/features/BuyMatchPopup/store/hooks/index.tsx @@ -141,14 +141,16 @@ export const useBuyMatchPopup = () => { .then(onSuccessfulSubscription, goToError) } + const onSuccessfulHighlights = () => { + setDataHighlights((prev) => ({ + ...prev, + isOpenThanksPopup: true, + })) + } + const onConfirmationSuccessHiglights = ({ id }: PaymentIntent) => { notifySuccessfulSubscription({ paymentIntentId: id }) - .then(() => { - setDataHighlights((prev) => ({ - ...prev, - isOpenThanksPopup: true, - })) - }) + .then(onSuccessfulHighlights) } const onUnsuccessfulSubscription = (data?: OnFailedPaymentActionData) => { @@ -213,6 +215,7 @@ export const useBuyMatchPopup = () => { onPackageSelect, onPeriodSelect, onSubscriptionSelect, + onSuccessfulHighlights, onUnsuccessfulSubscription, open: openPopup, postPaymentHandler,