Remove carte bancaire payment method
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import {useState} from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import Tabs from '@mui/material/Tabs'
|
||||
import Tab from '@mui/material/Tab'
|
||||
@@ -6,16 +5,9 @@ import Box from '@mui/material/Box'
|
||||
import Button from '@mui/material/Button'
|
||||
|
||||
import {Paypal, Liberapay} from '@icons-pack/react-simple-icons'
|
||||
import {Elements} from '@stripe/react-stripe-js'
|
||||
import {loadStripe} from '@stripe/stripe-js'
|
||||
|
||||
import {Grid} from '@mui/material'
|
||||
import {appearance} from '../../lib/utils/stripe-style'
|
||||
import Grid from '@mui/material/Unstable_Grid2'
|
||||
|
||||
import CheckoutForm from './checkout-form'
|
||||
import StripeDialog from './stripe-dialog'
|
||||
|
||||
const STRIPE_PUBLIC_KEY = process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY
|
||||
const PAYPAL_ID = process.env.NEXT_PUBLIC_PAYPAL_DONATE_ID
|
||||
const LIBERAPAY_DONATE = process.env.NEXT_PUBLIC_LIBERAPAY_DONATE
|
||||
|
||||
@@ -52,48 +44,27 @@ function a11yProps(index) {
|
||||
}
|
||||
}
|
||||
|
||||
export default function PaymentMethod({isLoading, paymentMethod, setPaymentMethod, selectedMontant, setSelectedMontant, validMontant, setValidMontant, paymentIntent, setClientSecret, setPaymentIntent, setIsLoading, setClientEmail, clientEmail, error, setError, clientSecret}) {
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
const options = {
|
||||
clientSecret,
|
||||
appearance,
|
||||
}
|
||||
|
||||
export default function PaymentMethod({paymentMethod, setPaymentMethod}) {
|
||||
const handleChange = (event, newValue) => {
|
||||
setPaymentMethod(newValue)
|
||||
}
|
||||
|
||||
const handleClickOpen = () => {
|
||||
setOpen(true)
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
if (selectedMontant) {
|
||||
setSelectedMontant(null)
|
||||
setValidMontant(null)
|
||||
}
|
||||
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<Box sx={{width: '100%'}}>
|
||||
<Box sx={{borderBottom: 1, borderColor: 'divider'}}>
|
||||
<Tabs scrollButtons allowScrollButtonsMobile value={paymentMethod} aria-label='basic tabs example' variant='fullWidth' onChange={handleChange}>
|
||||
<Tab wrapped label='Liberapay / PayPal' {...a11yProps(0)} />
|
||||
<Tab wrapped label='Adhésion' {...a11yProps(1)} />
|
||||
<Tab wrapped label='Carte bancaire' {...a11yProps(2)} />
|
||||
</Tabs>
|
||||
</Box>
|
||||
<TabPanel value={paymentMethod} index={0}>
|
||||
<Grid container rowSpacing={1}>
|
||||
<Grid item md={6} xs={12}>
|
||||
<Grid md={6} xs={12}>
|
||||
<Button variant='outlined' size='large' endIcon={<Liberapay />} onClick={() => window.open(`https://liberapay.com/${LIBERAPAY_DONATE}/donate`, '_blank')}>
|
||||
Faire un don via Liberapay
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid item md={6} xs={12}>
|
||||
<Grid md={6} xs={12}>
|
||||
<Button variant='outlined' size='large' endIcon={<Paypal />} onClick={() => window.open(`https://www.paypal.com/donate/?hosted_button_id=${PAYPAL_ID}`, '_blank')}>
|
||||
Faire un don via PayPal
|
||||
</Button>
|
||||
@@ -105,67 +76,11 @@ export default function PaymentMethod({isLoading, paymentMethod, setPaymentMetho
|
||||
Cliquez ici pour adhérer à l’association OKi
|
||||
</Button>
|
||||
</TabPanel>
|
||||
<TabPanel value={paymentMethod} index={2}>
|
||||
<Button size='large' variant='outlined' onClick={handleClickOpen}>
|
||||
Faire un don par carte bancaire
|
||||
</Button>
|
||||
<StripeDialog
|
||||
open={open}
|
||||
handleClose={handleClose}
|
||||
selectedMontant={selectedMontant}
|
||||
setSelectedMontant={setSelectedMontant}
|
||||
validMontant={validMontant}
|
||||
setValidMontant={setValidMontant}
|
||||
paymentIntent={paymentIntent}
|
||||
setClientSecret={setClientSecret}
|
||||
setPaymentIntent={setPaymentIntent}
|
||||
setIsLoading={setIsLoading}
|
||||
setClientEmail={setClientEmail}
|
||||
clientEmail={clientEmail}
|
||||
error={error}
|
||||
setError={setError}
|
||||
isLoading={isLoading}
|
||||
>
|
||||
{clientSecret && validMontant && paymentMethod === 2 && (
|
||||
<Elements options={options} stripe={loadStripe(STRIPE_PUBLIC_KEY)}>
|
||||
<CheckoutForm
|
||||
validMontant={validMontant}
|
||||
setError={setError}
|
||||
isLoading={isLoading}
|
||||
setIsLoading={setIsLoading}
|
||||
/>
|
||||
</Elements>
|
||||
)}
|
||||
</StripeDialog>
|
||||
</TabPanel>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
PaymentMethod.defaultProps = {
|
||||
selectedMontant: null,
|
||||
validMontant: null,
|
||||
paymentIntent: null,
|
||||
clientEmail: null,
|
||||
error: null,
|
||||
clientSecret: null
|
||||
}
|
||||
|
||||
PaymentMethod.propTypes = {
|
||||
isLoading: PropTypes.bool.isRequired,
|
||||
paymentMethod: PropTypes.number.isRequired,
|
||||
setPaymentMethod: PropTypes.func.isRequired,
|
||||
selectedMontant: PropTypes.string,
|
||||
setSelectedMontant: PropTypes.func.isRequired,
|
||||
validMontant: PropTypes.string,
|
||||
setValidMontant: PropTypes.func.isRequired,
|
||||
paymentIntent: PropTypes.string,
|
||||
setClientSecret: PropTypes.func.isRequired,
|
||||
setPaymentIntent: PropTypes.func.isRequired,
|
||||
setIsLoading: PropTypes.func.isRequired,
|
||||
setClientEmail: PropTypes.func.isRequired,
|
||||
clientEmail: PropTypes.string,
|
||||
error: PropTypes.string,
|
||||
setError: PropTypes.func.isRequired,
|
||||
clientSecret: PropTypes.string
|
||||
setPaymentMethod: PropTypes.func.isRequired
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user