diff --git a/components/soutyen/checkout-form.js b/components/soutyen/checkout-form.js
deleted file mode 100644
index 6dcf336..0000000
--- a/components/soutyen/checkout-form.js
+++ /dev/null
@@ -1,83 +0,0 @@
-import {useState, useEffect} from 'react'
-import PropTypes from 'prop-types'
-import {
- PaymentElement,
- useStripe,
- useElements
-} from '@stripe/react-stripe-js'
-import {Button, Container, LinearProgress, Paper} from '@mui/material'
-
-const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3001'
-
-export default function CheckoutForm({validMontant, setError, isLoading, setIsLoading}) {
- const stripe = useStripe()
- const elements = useElements()
- const [isPaymentLoading, setIsPaymentLoading] = useState(false)
- const [prices, setPrices] = useState([])
-
- const handleSubmit = async event => {
- event.preventDefault()
-
- if (!stripe || !elements) {
- return
- }
-
- setIsPaymentLoading(true)
-
- const {error} = await stripe.confirmPayment({
- elements,
- confirmParams: {
- return_url: `${SITE_URL}/soutyen`
- },
- })
-
- if (error.type === 'card_error' || error.type === 'validation_error') {
- setError(error.message)
- } else {
- setError('Une erreur s’est produite.')
- }
-
- setIsPaymentLoading(false)
- }
-
- const handleReady = () => {
- setIsLoading(false)
- }
-
- useEffect(() => {
- const fetchPrices = async () => {
- try {
- const response = await fetch(`${SITE_URL}/stripe/dons-list`)
- const pricesList = await response.json()
- setPrices(pricesList)
- } catch (error) {
- console.error('error', error)
- }
- }
-
- fetchPrices()
- }, [prices])
-
- return (
-
-
-
- {!isLoading && (
-
- )}
- {isPaymentLoading && (
-
- )}
-
-
- )
-}
-
-CheckoutForm.propTypes = {
- validMontant: PropTypes.string.isRequired,
- setError: PropTypes.func.isRequired,
- isLoading: PropTypes.bool.isRequired,
- setIsLoading: PropTypes.func.isRequired
-}
diff --git a/components/soutyen/don.js b/components/soutyen/don.js
deleted file mode 100644
index d1ff499..0000000
--- a/components/soutyen/don.js
+++ /dev/null
@@ -1,108 +0,0 @@
-import PropTypes from 'prop-types'
-import {Container, Stack, Typography} from '@mui/material'
-import axios from 'axios'
-import Button from '@mui/material/Button'
-import Box from '@mui/material/Box'
-import {Paypal} from '@icons-pack/react-simple-icons'
-
-import {validateEmail} from '../../lib/utils/emails'
-
-import Montant from './montant'
-import Email from './email'
-
-const PAYPAL_ID = process.env.NEXT_PUBLIC_PAYPAL_DONATE_ID
-
-export default function Don({isPaypal, selectedMontant, setSelectedMontant, validMontant, setValidMontant, prices, paymentIntent, setClientSecret, setPaymentIntent, setIsLoading, setClientEmail, clientEmail, error, setError}) {
- const cancelPayment = async () => {
- setClientEmail('')
- setIsLoading(false)
- setClientSecret(null)
-
- try {
- await axios.post('/stripe/cancel-payment', {
- paymentIntent
- })
- setPaymentIntent(null)
- } catch (error_) {
- console.log(error_.message)
- }
- }
-
- const handleCancel = async () => {
- setValidMontant(null)
- setSelectedMontant(null)
- await cancelPayment()
- }
-
- const handleClick = () => {
- if (!clientEmail) {
- setError('Adresse e-mail obligatoire.')
- return
- }
-
- if (!validateEmail(clientEmail)) {
- setError('Adresse e-mail invalide.')
- return
- }
-
- setIsLoading(true)
- setValidMontant(selectedMontant)
- }
-
- return (
-
-
- {isPaypal ? (
- <>
- PayPal
- } onClick={() => window.open(`https://www.paypal.com/donate/?hosted_button_id=${PAYPAL_ID}`, '_blank')}>Don via PayPal
- >
- ) : (
- <>
- Carte bancaire
-
-
-
-
- {validMontant && (
-
- )}
-
- >
- )}
-
-
- )
-}
-
-Don.propTypes = {
- isPaypal: PropTypes.bool.isRequired,
- selectedMontant: PropTypes.string,
- setSelectedMontant: PropTypes.func.isRequired,
- validMontant: PropTypes.string,
- setValidMontant: PropTypes.func.isRequired,
- prices: PropTypes.array.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
-}
diff --git a/components/soutyen/email.js b/components/soutyen/email.js
deleted file mode 100644
index 5e9a778..0000000
--- a/components/soutyen/email.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import PropTypes from 'prop-types'
-import Box from '@mui/material/Box'
-import TextField from '@mui/material/TextField'
-
-export default function Email({validMontant, error, clientEmail, setClientEmail}) {
- return (
-
- setClientEmail(event.target.value)}
- />
-
- )
-}
-
-Email.propTypes = {
- validMontant: PropTypes.string,
- error: PropTypes.string,
- clientEmail: PropTypes.string,
- setClientEmail: PropTypes.func.isRequired
-}
diff --git a/components/soutyen/montant.js b/components/soutyen/montant.js
deleted file mode 100644
index b1c389c..0000000
--- a/components/soutyen/montant.js
+++ /dev/null
@@ -1,61 +0,0 @@
-import {useState, useEffect} from 'react'
-import PropTypes from 'prop-types'
-import ToggleButton from '@mui/material/ToggleButton'
-import ToggleButtonGroup from '@mui/material/ToggleButtonGroup'
-import Typography from '@mui/material/Typography'
-import {Box} from '@mui/material'
-import CircularProgress from '@mui/material/CircularProgress'
-
-const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3001'
-
-export default function Montant({selectedMontant, setSelectedMontant, validMontant}) {
- const [prices, setPrices] = useState(null)
- const handleChange = (event, newMontant) => {
- setSelectedMontant(newMontant)
- }
-
- useEffect(() => {
- const fetchPrices = async () => {
- try {
- const response = await fetch(`${SITE_URL}/stripe/dons-list`)
- const pricesList = await response.json()
- setPrices(pricesList)
- } catch (error) {
- console.error('error', error)
- }
- }
-
- fetchPrices()
- }, [prices])
-
- return (
-
-
- Choisir un montant *
-
-
- {!prices && (
-
- )}
-
- {prices && prices.map(r => (
- {r.unit_amount / 100} €
- ))}
-
-
-
- )
-}
-
-Montant.propTypes = {
- selectedMontant: PropTypes.string,
- setSelectedMontant: PropTypes.func.isRequired,
- validMontant: PropTypes.string
-}
diff --git a/components/soutyen/stripe-dialog.js b/components/soutyen/stripe-dialog.js
deleted file mode 100644
index 9f5ba86..0000000
--- a/components/soutyen/stripe-dialog.js
+++ /dev/null
@@ -1,83 +0,0 @@
-import Dialog from '@mui/material/Dialog'
-import PropTypes from 'prop-types'
-import DialogTitle from '@mui/material/DialogTitle'
-import DialogContent from '@mui/material/DialogContent'
-import useMediaQuery from '@mui/material/useMediaQuery'
-import {useTheme} from '@mui/material/styles'
-
-import StripePayment from './stripe-payment'
-
-export default function StripeDialog({
- open,
- handleClose,
- selectedMontant,
- setSelectedMontant,
- validMontant,
- setValidMontant,
- paymentIntent,
- setClientSecret,
- setPaymentIntent,
- setIsLoading,
- setClientEmail,
- clientEmail,
- error,
- setError,
- isLoading,
- children
-}) {
- const theme = useTheme()
- const fullScreen = useMediaQuery(theme.breakpoints.down('md'))
-
- return (
-
-
-
- )
-}
-
-StripeDialog.propTypes = {
- open: PropTypes.bool.isRequired,
- handleClose: PropTypes.func.isRequired,
- isLoading: PropTypes.bool.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,
- children: PropTypes.node
-}
diff --git a/components/soutyen/stripe-payment.js b/components/soutyen/stripe-payment.js
deleted file mode 100644
index b164ee9..0000000
--- a/components/soutyen/stripe-payment.js
+++ /dev/null
@@ -1,109 +0,0 @@
-import PropTypes from 'prop-types'
-import axios from 'axios'
-import Box from '@mui/material/Box'
-import Container from '@mui/material/Container'
-import Typography from '@mui/material/Typography'
-import Stack from '@mui/material/Stack'
-import Button from '@mui/material/Button'
-import LinearProgress from '@mui/material/LinearProgress'
-
-import {validateEmail} from '../../lib/utils/emails'
-
-import Email from './email'
-import Montant from './montant'
-
-export default function StripePayment({isLoading, selectedMontant, setSelectedMontant, validMontant, setValidMontant, paymentIntent, setClientSecret, setPaymentIntent, setIsLoading, setClientEmail, clientEmail, error, setError, handleClose}) {
- const cancelPayment = async () => {
- setClientEmail('')
- setIsLoading(false)
- setClientSecret(null)
-
- try {
- await axios.post('/stripe/cancel-payment', {
- paymentIntent
- })
- setPaymentIntent(null)
- } catch (error_) {
- console.log(error_.message)
- }
- }
-
- const handleCancel = async () => {
- if (validMontant) {
- setValidMontant(null)
- setSelectedMontant(null)
- await cancelPayment()
- handleClose()
- } else {
- handleClose()
- }
- }
-
- const handleClick = () => {
- if (!clientEmail) {
- setError('Adresse e-mail obligatoire.')
- return
- }
-
- if (!validateEmail(clientEmail)) {
- setError('Adresse e-mail invalide.')
- return
- }
-
- setIsLoading(true)
- setValidMontant(selectedMontant)
- }
-
- return (
-
-
- <>
-
-
- * Obligatoire
-
-
-
-
-
- >
- {isLoading && (
-
-
-
- )}
-
-
- )
-}
-
-StripePayment.propTypes = {
- isLoading: PropTypes.bool.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,
- handleClose: PropTypes.func.isRequired
-}
diff --git a/package.json b/package.json
index 9e99d69..4e702cb 100644
--- a/package.json
+++ b/package.json
@@ -19,8 +19,6 @@
"@mui/lab": "^5.0.0-alpha.89",
"@mui/material": "^5.14.1",
"@mui/styles": "^5.8.7",
- "@stripe/react-stripe-js": "^1.7.0",
- "@stripe/stripe-js": "^1.22.0",
"@svgr/webpack": "^6.5.0",
"axios": "^0.21.0",
"compression": "^1.7.4",
@@ -39,8 +37,7 @@
"react-dom": "^18.2.0",
"react-swipeable-views": "^0.13.9",
"react-virtuoso": "^4.4.0",
- "sharp": "^0.29.3",
- "stripe": "^8.202.0"
+ "sharp": "^0.29.3"
},
"devDependencies": {
"eslint": "^8.7.0",
diff --git a/yarn.lock b/yarn.lock
index fb27c92..960611a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2679,18 +2679,6 @@
estree-walker "^1.0.1"
picomatch "^2.2.2"
-"@stripe/react-stripe-js@^1.7.0":
- version "1.7.0"
- resolved "https://registry.yarnpkg.com/@stripe/react-stripe-js/-/react-stripe-js-1.7.0.tgz#83c993a09a903703205d556617f9729784a896c3"
- integrity sha512-L20v8Jq0TDZFL2+y+uXD751t6q9SalSFkSYZpmZ2VWrGZGK7HAGfRQ804dzYSSr5fGenW6iz6y7U0YKfC/TK3g==
- dependencies:
- prop-types "^15.7.2"
-
-"@stripe/stripe-js@^1.22.0":
- version "1.22.0"
- resolved "https://registry.yarnpkg.com/@stripe/stripe-js/-/stripe-js-1.22.0.tgz#9d3d2f0a1ce81f185ec477fd7cc67544b2b2a00c"
- integrity sha512-fm8TR8r4LwbXgBIYdPmeMjJJkxxFC66tvoliNnmXOpUgZSgQKoNPW3ON0ZphZIiif1oqWNhAaSrr7tOvGu+AFg==
-
"@surma/rollup-plugin-off-main-thread@^2.2.3":
version "2.2.3"
resolved "https://registry.yarnpkg.com/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz#ee34985952ca21558ab0d952f00298ad2190c053"
@@ -2870,11 +2858,6 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.10.tgz#5958a82e41863cfc71f2307b3748e3491ba03785"
integrity sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ==
-"@types/node@>=8.1.0":
- version "17.0.17"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.17.tgz#a8ddf6e0c2341718d74ee3dc413a13a042c45a0c"
- integrity sha512-e8PUNQy1HgJGV3iU/Bp2+D/DXh3PYeyli8LgIwsQcs1Ar1LoaWHSIT6Rw+H2rNJmiq6SNWiDytfx8+gYj7wDHw==
-
"@types/normalize-package-data@^2.4.0":
version "2.4.1"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
@@ -6643,13 +6626,6 @@ qs@6.7.0:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
-qs@^6.6.0:
- version "6.10.3"
- resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.3.tgz#d6cde1b2ffca87b5aa57889816c5f81535e22e8e"
- integrity sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==
- dependencies:
- side-channel "^1.0.4"
-
queue-microtask@^1.2.2:
version "1.2.3"
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
@@ -7517,14 +7493,6 @@ strip-json-comments@~2.0.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=
-stripe@^8.202.0:
- version "8.202.0"
- resolved "https://registry.yarnpkg.com/stripe/-/stripe-8.202.0.tgz#884760713a690983d5a3128ea3cbeb677ee2645f"
- integrity sha512-3YGHVnUatEn/At5+aRy+REdB2IyVa96/zls2xvQrKFTgaJzRu1MsJcK0GKg0p2B0y0VqlZo9gmdDEqphSHHvtA==
- dependencies:
- "@types/node" ">=8.1.0"
- qs "^6.6.0"
-
styled-jsx@5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-5.1.1.tgz#839a1c3aaacc4e735fed0781b8619ea5d0009d1f"