Remove carte bancaire payment method

This commit is contained in:
2023-07-22 13:50:24 +04:00
parent 7226c62bef
commit 7d1b6be5d4
2 changed files with 6 additions and 91 deletions
+5 -90
View File
@@ -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 à lassociation 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
}
+1 -1
View File
@@ -21,7 +21,7 @@ export default function Presantasyon() {
<strong>Toute contribution, aussi modeste soit-elle, nous permet daugmenter nos capacités</strong>.
</Typography>
<Typography paragraph variant='subtitle1' component='div'>
Concernant les dons, ils peuvent s&apos;effectuer via <Link underline='hover' href='https://liberapay.com/OKi/donate' target='_blank' rel='noreferrer'><strong>Liberapay</strong></Link>, <Link underline='hover' href='https://www.paypal.com/donate/?hosted_button_id=5Q3KPR79CAZVW' target='_blank' rel='noreferrer'><strong>PayPal</strong></Link> ou directement sur notre site par carte bancaire. Pour ce dernier, nous utilisons <Link underline='hover' href='https://stripe.com/fr/about' target='_blank' rel='noreferrer'><strong>Stripe</strong></Link> (une plateforme de paiement 100% sécurisée).
Concernant les dons, ils peuvent s&apos;effectuer via <Link underline='hover' href='https://liberapay.com/OKi/donate' target='_blank' rel='noreferrer'><strong>Liberapay</strong></Link>, <Link underline='hover' href='https://www.paypal.com/donate/?hosted_button_id=5Q3KPR79CAZVW' target='_blank' rel='noreferrer'><strong>PayPal</strong></Link>.
</Typography>
<Typography paragraph variant='subtitle1' component='div'>
Vous pouvez adhérer à notre association en vous rendant sur <Link underline='hover' href='https://asso.oki.re/public/members/new.php' target='_blank' rel='noreferrer'><strong>asso.oki.re</strong></Link>.