feat(#2386): add brazilian payment
parent
ff2b4cd26d
commit
923a6b62e5
@ -0,0 +1,43 @@ |
||||
import { useEffect, useState } from 'react' |
||||
|
||||
import { Loader } from 'features/Loader' |
||||
|
||||
import { getBrazilPaymentUrl } from 'requests/getBrazilPaymentUrl' |
||||
import type { SubscriptionResponse } from 'requests/getSubscriptions' |
||||
|
||||
import { ScModal, LoaderWrapper } from './styled' |
||||
|
||||
type Props = { |
||||
item: SubscriptionResponse, |
||||
open: boolean, |
||||
product_name: string, |
||||
} |
||||
|
||||
export const BrazilPayment = ({ |
||||
item, |
||||
open, |
||||
product_name, |
||||
}: Props) => { |
||||
const [src, setSrc] = useState('') |
||||
|
||||
useEffect(() => { |
||||
if (open) { |
||||
(async () => { |
||||
const json: any = await getBrazilPaymentUrl({ item, product_name }) |
||||
setSrc(json[0]?.url) |
||||
})() |
||||
} |
||||
}, [item, open, product_name]) |
||||
|
||||
return ( |
||||
<ScModal isOpen={open} withCloseButton={false}> |
||||
{src && open ? ( |
||||
<iframe title='BrazilPayment' src={src} height={600} width={400} /> |
||||
) : ( |
||||
<LoaderWrapper> |
||||
<Loader color='#515151' /> |
||||
</LoaderWrapper> |
||||
)} |
||||
</ScModal> |
||||
) |
||||
} |
||||
@ -0,0 +1,38 @@ |
||||
import styled, { css } from 'styled-components/macro' |
||||
|
||||
import { isMobileDevice } from 'config/userAgent' |
||||
|
||||
import { ModalWindow } from 'features/Modal/styled' |
||||
import { Modal as BaseModal } from 'features/Modal' |
||||
|
||||
export const ScModal = styled(BaseModal)` |
||||
background-color: rgba(0, 0, 0, 0.7); |
||||
|
||||
${ModalWindow} { |
||||
padding: 0; |
||||
background-color: #333333; |
||||
border-radius: 5px; |
||||
|
||||
${isMobileDevice |
||||
? css` |
||||
width: calc(100vw - 60px); |
||||
@media screen and (orientation: landscape){ |
||||
max-width: calc(100vw - 80px); |
||||
height: calc(100vh - 60px); |
||||
overflow: auto; |
||||
} |
||||
` |
||||
: ''}; |
||||
} |
||||
` |
||||
|
||||
export const LoaderWrapper = styled.div` |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
width: 100%; |
||||
height: 100%; |
||||
display: flex; |
||||
align-items: center; |
||||
justify-content: center; |
||||
` |
||||
@ -0,0 +1,6 @@ |
||||
export const clientCountry = () => { |
||||
const country = JSON.parse( |
||||
localStorage.getItem('oidc.user:https://auth.instat.tv:ott-web') || '', |
||||
).profile.country_code |
||||
return country |
||||
} |
||||
@ -0,0 +1,21 @@ |
||||
import { API_ROOT } from 'config' |
||||
import { callApi } from 'helpers' |
||||
import type { SubscriptionResponse } from 'requests/getSubscriptions' |
||||
|
||||
type Props = { |
||||
item: SubscriptionResponse, |
||||
product_name: string, |
||||
} |
||||
|
||||
export const getBrazilPaymentUrl = async ({ item, product_name }: Props) => { |
||||
const config = { |
||||
body: { |
||||
item: { ...item, product_name }, |
||||
}, |
||||
} |
||||
|
||||
return callApi({ |
||||
config, |
||||
url: `${API_ROOT}/account/payment/pagbrasil`, |
||||
}) |
||||
} |
||||
Loading…
Reference in new issue