diff --git a/.env example b/.env example new file mode 100644 index 0000000..ed98d4b --- /dev/null +++ b/.env example @@ -0,0 +1,4 @@ +//used for frontend + +REACT_APP_STRIPE_PUBLISHABLE_KEY= stripe publishable key +REACT_APP_BACKEND_URL= backend local host url diff --git a/server/.env example b/server/.env example new file mode 100644 index 0000000..12cf395 --- /dev/null +++ b/server/.env example @@ -0,0 +1,3 @@ +//used by server.js for backend + +STRIPE_SECRET_KEY= stripe secret key \ No newline at end of file diff --git a/src/Pages/pay/pay.jsx b/src/Pages/pay/pay.jsx index 7fd3f7d..723398c 100644 --- a/src/Pages/pay/pay.jsx +++ b/src/Pages/pay/pay.jsx @@ -5,8 +5,11 @@ import axios from 'axios'; import CheckoutForm from './CheckoutForm'; import './pay.scss'; + // Initialize Stripe with your publishable key -const stripePromise = loadStripe("pk_test_51OZeOJSHKQ5UtevikLLJG3vvyhNe2XwePgVfDVvW1aalKTW1yhPJyiEg50tZJ9xldsoauRrhEfAjpdzritmEGAQ100wKhUGSSq"); +const stripePromise = loadStripe(process.env.REACT_APP_STRIPE_PUBLISHABLE_KEY); +// or use this statement, paste publisable key here +// const stripePromise = loadStripe("paste key here"); const Pay = () => { const [clientSecret, setClientSecret] = useState(""); @@ -15,7 +18,9 @@ const Pay = () => { useEffect(() => { const makeRequest = async () => { try { - const backendUrl = 'http://localhost:8801'; + const backendUrl = process.env.REACT_APP_BACKEND_URL; + //or use this statement, paste backend url + // const backendUrl = 'paste backend url'; const response = await axios.post(`${backendUrl}/create-payment-intent`, { amount }); setClientSecret(response.data.clientSecret); } catch (err) {