This project demonstrates how to integrate Stripe payment processing into a React Vite application. Users can view product details and make payments using their credit cards.
- Display product details.
- Handle credit card payments with Stripe.
- Display payment status messages.
- Node.js (v14 or higher)
- Stripe account and API keys
-
Clone the repository and navigate to the backend directory:
git clone https://github.com/yourusername/react-vite-stripe.git cd react-vite-stripe/backend -
Install the required dependencies:
npm install
-
Create a
.envfile in thebackenddirectory and add your Stripe secret key:STRIPE_SECRET_KEY=your_stripe_secret_key -
Start the backend server:
npm run dev
-
Navigate to the frontend directory:
cd ../frontend -
Install the required dependencies:
npm install
-
Create a
.envfile in thefrontenddirectory and add your Stripe publishable key:VITE_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key -
Start the frontend development server:
npm run dev
- Open your browser and navigate to
http://localhost:5174/. - View the product details.
- Enter your credit card information and click "Buy Now".
- Check the payment status message to see if the payment was successful.
- Handles the creation of payment intents using Stripe's API.
- Defines an endpoint (
/create-payment-intent) to receive payment requests from the frontend.
- Displays product details.
- Integrates Stripe's
CardElementfor secure credit card input. - Handles form submission to create a payment intent and confirm the payment.
This project is licensed under the MIT License. See the LICENSE file for details.
- Stripe Documentation for comprehensive guides and examples.
- Stripe API keys
- React and Vite for providing the tools to build this application.