fix(2526): fix check for payment with card without 3ds

keep-around/47eb31df4c19e533395e7a7a017207ca41855574
Andrei Dekterev 3 years ago
parent a1797acf9b
commit 47eb31df4c
  1. 7
      src/features/AddCardForm/components/Form/hooks/index.tsx
  2. 15
      src/features/BuyMatchPopup/store/hooks/index.tsx

@ -87,8 +87,9 @@ export const useFormSubmit = ({ onAddSuccess }: Props) => {
const [errorMessage, setErrorMessage] = useState('') const [errorMessage, setErrorMessage] = useState('')
const [loader, setLoader] = useState(false) const [loader, setLoader] = useState(false)
const dataHighlights = useRecoilValue(dataForPayHighlights) const dataHighlights = useRecoilValue(dataForPayHighlights)
const { const {
onConfirmationSuccessHiglights, onSuccessfulHighlights,
onUnsuccessfulSubscription, onUnsuccessfulSubscription,
} = useBuyMatchPopupStore() } = useBuyMatchPopupStore()
@ -189,7 +190,7 @@ export const useFormSubmit = ({ onAddSuccess }: Props) => {
cardId: defaultCard?.id, cardId: defaultCard?.id,
order: { ...dataHighlights?.data }, order: { ...dataHighlights?.data },
}) })
.then(() => onConfirmationSuccessHiglights, onUnsuccessfulSubscription) .then(onSuccessfulHighlights, onUnsuccessfulSubscription)
.catch(() => setErrorMessage(translate('error_payment_unsuccessful'))) .catch(() => setErrorMessage(translate('error_payment_unsuccessful')))
.finally(() => setLoader(false)) .finally(() => setLoader(false))
return return
@ -234,7 +235,7 @@ export const useFormSubmit = ({ onAddSuccess }: Props) => {
cardId: defaultCard.id, cardId: defaultCard.id,
order: { ...dataHighlights?.data }, order: { ...dataHighlights?.data },
}) })
.then(() => onConfirmationSuccessHiglights, onUnsuccessfulSubscription) .then(onSuccessfulHighlights, onUnsuccessfulSubscription)
.catch(() => setErrorMessage(translate('error_payment_unsuccessful'))) .catch(() => setErrorMessage(translate('error_payment_unsuccessful')))
} }
}) })

@ -141,14 +141,16 @@ export const useBuyMatchPopup = () => {
.then(onSuccessfulSubscription, goToError) .then(onSuccessfulSubscription, goToError)
} }
const onSuccessfulHighlights = () => {
setDataHighlights((prev) => ({
...prev,
isOpenThanksPopup: true,
}))
}
const onConfirmationSuccessHiglights = ({ id }: PaymentIntent) => { const onConfirmationSuccessHiglights = ({ id }: PaymentIntent) => {
notifySuccessfulSubscription({ paymentIntentId: id }) notifySuccessfulSubscription({ paymentIntentId: id })
.then(() => { .then(onSuccessfulHighlights)
setDataHighlights((prev) => ({
...prev,
isOpenThanksPopup: true,
}))
})
} }
const onUnsuccessfulSubscription = (data?: OnFailedPaymentActionData) => { const onUnsuccessfulSubscription = (data?: OnFailedPaymentActionData) => {
@ -213,6 +215,7 @@ export const useBuyMatchPopup = () => {
onPackageSelect, onPackageSelect,
onPeriodSelect, onPeriodSelect,
onSubscriptionSelect, onSubscriptionSelect,
onSuccessfulHighlights,
onUnsuccessfulSubscription, onUnsuccessfulSubscription,
open: openPopup, open: openPopup,
postPaymentHandler, postPaymentHandler,

Loading…
Cancel
Save