This is a Laravel-based ecommerce application where users can view products, add them to the cart, and proceed to checkout using the Stripe payment gateway.
- View all products
- Add products to cart
- View cart
- Checkout and pay with Stripe
- Success and cancellation pages for payment
- PHP 8.2 or higher
- Composer
- Node.js & npm
- Laravel 11.x
- Clone the repository:
git clone https://github.com/phi-rakib/laravel-ecommerce-stripe.git cd laravel-ecommerce-stripe
- Install dependencies:
composer install npm install
- Copy the .env file:
cp .env.example .env
- Set up your environment variables in the .env file:
APP_NAME=Laravel APP_ENV=local APP_KEY=base64:randomkeyhere APP_DEBUG=true APP_URL=http://localhost DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_database DB_USERNAME=your_username DB_PASSWORD=your_password STRIPE_KEY=your_stripe_key STRIPE_SECRET=your_stripe_secret
- Run migrations and seed the database:
php artisan migrate php artisan db:seed
- Serve the application:
php artisan serve
- Access the application in your web browser:
http://localhost:8000
- View Products: Navigate to the home page to view all products.
- Add to Cart: Click on the "Add to Cart" button on a product to add it to your cart.
- View Cart: Go to the cart page to view all the items in your cart.
- Checkout: Click the "Checkout" button on the cart page to proceed to the Stripe payment gateway.
- Payment Success: After a successful payment, you will be redirected to the success page.
- Payment Cancelled: If the payment is cancelled, you will be redirected to the cancellation page.
- app/Http/Controllers: Contains the controllers for handling requests.
- app/Models: Contains the Eloquent models.
- database/migrations: Contains the database migration files.
- database/seeders: Contains the database seeder files.
- resources/views: Contains the Blade templates for the views.
- routes/web.php: Contains the web routes.
- ProductController:
- index(): Displays all products.
- show($id): Displays a single product.
- CartController:
- index(): Displays the cart.
- add(Request $request): Adds a product to the cart.
- PaymentController:
- checkout(): Displays the checkout page.
- createCheckoutSession(Request $request): Creates a Stripe Checkout session.
- success(): Handles successful payment.
- cancel(): Handles cancelled payment.
Contributions are welcome! Please submit a pull request or create an issue for any improvements or bug fixes.
This project is licensed under the MIT License.