|
|
|
@ -6,19 +6,23 @@ import { |
|
|
|
useState, |
|
|
|
useState, |
|
|
|
} from 'react' |
|
|
|
} from 'react' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import isNumber from 'lodash/isNumber' |
|
|
|
|
|
|
|
|
|
|
|
import { PAGES, ProfileTypes } from 'config' |
|
|
|
import { PAGES, ProfileTypes } from 'config' |
|
|
|
import { ClientNames } from 'config/clients/types' |
|
|
|
import { ClientNames } from 'config/clients/types' |
|
|
|
import { payments, PaymentSystem } from 'config/payments' |
|
|
|
import { payments, PaymentSystem } from 'config/payments' |
|
|
|
|
|
|
|
|
|
|
|
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 { SubscriptionType } from 'features/BuyMatchPopup/types' |
|
|
|
|
|
|
|
|
|
|
|
import { getMatchInfo } from 'requests/getMatchInfo' |
|
|
|
import { |
|
|
|
import { SubscriptionAction, getPaymentUrl } from 'requests/getPaymentUrl' |
|
|
|
getPaymentOTTUrl, |
|
|
|
|
|
|
|
getPaymentPayUrl, |
|
|
|
|
|
|
|
getMatchInfo, |
|
|
|
|
|
|
|
SubscriptionAction, |
|
|
|
|
|
|
|
} from 'requests' |
|
|
|
|
|
|
|
|
|
|
|
import { redirectToUrl } from 'helpers' |
|
|
|
import { redirectToUrl } from 'helpers' |
|
|
|
|
|
|
|
|
|
|
|
@ -88,7 +92,7 @@ export const useIframePayment = ({ |
|
|
|
} |
|
|
|
} |
|
|
|
}, [close, error, id, matchLink, setIsOpenIframe, sportType]) |
|
|
|
}, [close, error, id, matchLink, setIsOpenIframe, sportType]) |
|
|
|
|
|
|
|
|
|
|
|
const paymentRequest = async () => { |
|
|
|
const paymentRequestOTT = async () => { |
|
|
|
let url_cancel |
|
|
|
let url_cancel |
|
|
|
let url_return |
|
|
|
let url_return |
|
|
|
let action: SubscriptionAction |
|
|
|
let action: SubscriptionAction |
|
|
|
@ -106,7 +110,7 @@ export const useIframePayment = ({ |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const payment: ResponsePaymentArray = await getPaymentUrl({ |
|
|
|
const payment: ResponsePaymentArray = await getPaymentOTTUrl({ |
|
|
|
action, |
|
|
|
action, |
|
|
|
item: originalObject, |
|
|
|
item: originalObject, |
|
|
|
product_name: `${pack} ${teams}`, |
|
|
|
product_name: `${pack} ${teams}`, |
|
|
|
@ -117,6 +121,19 @@ export const useIframePayment = ({ |
|
|
|
setSrc(payment?.url || '') |
|
|
|
setSrc(payment?.url || '') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// новое апи для оплаты, в будущем все платежки переедут на него
|
|
|
|
|
|
|
|
// делаем оплату на новой вкладке, а не через iframe
|
|
|
|
|
|
|
|
const paymentRequestPay = async () => { |
|
|
|
|
|
|
|
const payment = await getPaymentPayUrl({ |
|
|
|
|
|
|
|
item: { |
|
|
|
|
|
|
|
...originalObject, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
url_return: `${window.location.origin}${matchLink}`, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redirectToUrl(payment.url) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (paymentSystem === payments[ClientNames.Brasil]) { |
|
|
|
if (paymentSystem === payments[ClientNames.Brasil]) { |
|
|
|
// eslint-disable-next-line
|
|
|
|
// eslint-disable-next-line
|
|
|
|
window.onmessage = function (event) { |
|
|
|
window.onmessage = function (event) { |
|
|
|
@ -126,6 +143,7 @@ export const useIframePayment = ({ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// отслеживание оплаты для Paymee
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
let interval: ReturnType<typeof setInterval> |
|
|
|
let interval: ReturnType<typeof setInterval> |
|
|
|
let timeout: ReturnType<typeof setTimeout> |
|
|
|
let timeout: ReturnType<typeof setTimeout> |
|
|
|
@ -164,7 +182,14 @@ export const useIframePayment = ({ |
|
|
|
if (open) { |
|
|
|
if (open) { |
|
|
|
(async () => { |
|
|
|
(async () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
await paymentRequest() |
|
|
|
switch (paymentSystem) { |
|
|
|
|
|
|
|
case PaymentSystem.PhonePe: |
|
|
|
|
|
|
|
await paymentRequestPay() |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
await paymentRequestOTT() |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
setError('error_payment_unsuccessful') |
|
|
|
setError('error_payment_unsuccessful') |
|
|
|
} |
|
|
|
} |
|
|
|
|