|
|
|
@ -2,6 +2,7 @@ import { |
|
|
|
MouseEvent, |
|
|
|
MouseEvent, |
|
|
|
useCallback, |
|
|
|
useCallback, |
|
|
|
useEffect, |
|
|
|
useEffect, |
|
|
|
|
|
|
|
useMemo, |
|
|
|
useState, |
|
|
|
useState, |
|
|
|
} from 'react' |
|
|
|
} from 'react' |
|
|
|
|
|
|
|
|
|
|
|
@ -14,9 +15,10 @@ import isNumber from 'lodash/isNumber' |
|
|
|
import { useLexicsStore } from 'features/LexicsStore' |
|
|
|
import { useLexicsStore } from 'features/LexicsStore' |
|
|
|
import { useBuyMatchPopupStore } from 'features/BuyMatchPopup/store' |
|
|
|
import { useBuyMatchPopupStore } from 'features/BuyMatchPopup/store' |
|
|
|
import { getProfileUrl } from 'features/ProfileLink/helpers' |
|
|
|
import { getProfileUrl } from 'features/ProfileLink/helpers' |
|
|
|
|
|
|
|
import { SubscriptionType } from 'features/BuyMatchPopup/types' |
|
|
|
|
|
|
|
|
|
|
|
import { getMatchInfo } from 'requests/getMatchInfo' |
|
|
|
import { getMatchInfo } from 'requests/getMatchInfo' |
|
|
|
import { getPaymentUrl } from 'requests/getPaymentUrl' |
|
|
|
import { SubscriptionAction, getPaymentUrl } from 'requests/getPaymentUrl' |
|
|
|
|
|
|
|
|
|
|
|
import { redirectToUrl } from 'helpers' |
|
|
|
import { redirectToUrl } from 'helpers' |
|
|
|
|
|
|
|
|
|
|
|
@ -49,6 +51,7 @@ export const useIframePayment = ({ |
|
|
|
nameLexic, |
|
|
|
nameLexic, |
|
|
|
originalObject, |
|
|
|
originalObject, |
|
|
|
pass, |
|
|
|
pass, |
|
|
|
|
|
|
|
type, |
|
|
|
} = selectedPackage |
|
|
|
} = selectedPackage |
|
|
|
|
|
|
|
|
|
|
|
const teams = isNumber(nameLexic) ? translate(String(nameLexic)) : name |
|
|
|
const teams = isNumber(nameLexic) ? translate(String(nameLexic)) : name |
|
|
|
@ -60,6 +63,13 @@ export const useIframePayment = ({ |
|
|
|
sportType, |
|
|
|
sportType, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const defaultAction: SubscriptionAction = useMemo(() => { |
|
|
|
|
|
|
|
if (type === SubscriptionType.Month) { |
|
|
|
|
|
|
|
return SubscriptionAction.CreateSubscription |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return SubscriptionAction.OnePayment |
|
|
|
|
|
|
|
}, [type]) |
|
|
|
|
|
|
|
|
|
|
|
const closePopup = useCallback(async (e?: MouseEvent) => { |
|
|
|
const closePopup = useCallback(async (e?: MouseEvent) => { |
|
|
|
e?.stopPropagation() |
|
|
|
e?.stopPropagation() |
|
|
|
|
|
|
|
|
|
|
|
@ -81,18 +91,18 @@ export const useIframePayment = ({ |
|
|
|
const paymentRequest = async () => { |
|
|
|
const paymentRequest = async () => { |
|
|
|
let url_cancel |
|
|
|
let url_cancel |
|
|
|
let url_return |
|
|
|
let url_return |
|
|
|
let action: Parameters<typeof getPaymentUrl>[0]['action'] |
|
|
|
let action: SubscriptionAction |
|
|
|
|
|
|
|
|
|
|
|
switch (paymentSystem) { |
|
|
|
switch (paymentSystem) { |
|
|
|
case PaymentSystem.Paymee: |
|
|
|
case PaymentSystem.Paymee: |
|
|
|
url_cancel = `${window.origin}/failed-paymee` |
|
|
|
url_cancel = `${window.origin}${PAGES.failedPaymee}` |
|
|
|
url_return = null |
|
|
|
url_return = null |
|
|
|
// paymee не умеет работать с подписками
|
|
|
|
// paymee не умеет работать с подписками
|
|
|
|
action = 'one_payment' |
|
|
|
action = SubscriptionAction.OnePayment |
|
|
|
break |
|
|
|
break |
|
|
|
default: |
|
|
|
default: |
|
|
|
url_return = `${window.location.origin}${PAGES.thanksForSubscribe}` |
|
|
|
url_return = `${window.location.origin}${PAGES.thanksForSubscribe}` |
|
|
|
action = pass === 'pass_match_access' ? 'one_payment' : 'create_subscription' |
|
|
|
action = defaultAction |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|