fix(#622): annual access

pull/261/head
Rakov 3 years ago committed by Gitea
parent cf8515fe9e
commit 1e7ffc7366
  1. 20
      src/features/BuyMatchPopup/components/IframePayment/hooks.tsx
  2. 7
      src/requests/getPaymentUrl.tsx

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

@ -4,8 +4,13 @@ import { callApi } from 'helpers'
import type { SubscriptionResponse } from 'requests/getSubscriptions'
export enum SubscriptionAction {
CreateSubscription = 'create_subscription',
OnePayment = 'one_payment'
}
type Props = {
action: 'one_payment' | 'create_subscription',
action: SubscriptionAction,
item: SubscriptionResponse,
product_name: string,
service: string,

Loading…
Cancel
Save