A robust and scalable backend API for E-commerce platforms built with Django and Django REST Framework (DRF). This project includes essential e-commerce features like cart management, product reviews, wishlists, and seamless payment integration with Stripe.
- ✅ Product Management: Product List & Detail views (Slug-based).
- ✅ Categories: Categorized browsing with List & Detail views.
- ✅ Shopping Cart: Full cart functionality (Add / Update / Delete items).
- ✅ Reviews: Users can Add, Update, and Delete product reviews.
- ✅ Wishlist: Toggle mechanism to Add/Remove items.
- ✅ Search: Advanced search by Name, Description, or Category.
- ✅ Payments: Secure Stripe Checkout Integration.
- ✅ Automation: Stripe Webhook for automatic Order creation and Cart cleanup.
- ✅ API Ready: Fully RESTful API architecture suitable for React, Vue, Next.js, or Mobile Apps.
- Backend: Python 3.10+, Django, Django REST Framework
- Database: SQLite (Dev) / PostgreSQL (Recommended for Prod)
- Authentication: Django Custom User (Email-based)
- Payment Gateway: Stripe
- Security: CSRF exemption for Webhooks, Stripe Signature Verification.
CoreApiProject/
│
├── app/
│ ├── views.py
│ ├── models.py
│ ├── serializers.py
│ ├── urls.py
│
├── CoreApiProject/
│ ├── settings.py
│ ├── urls.py
│
├── manage.py
├── .gitignore
└── README.md
Clone Repo:
git clone https://github.com/daCircuitSage/DRF-Ecommerce-API.gitFor windows:
python -m venv env
env\Scripts\activateFor linux/mac:
python3 -m venv env
source env/bin/activateOpen settings.py (or create a .env file) and add your Stripe keys:
STRIPE_SECRET_KEY = "sk_test_************"
WEBHOOK_SECRET = "whsec_************"python manage.py makemigrations
python manage.py migratepython manage.py createsuperuserpython manage.py runserver
#The API will be available at http://127.0.0.1:8000/ GET /api/product_list/ GET /api/product/<slug>/ GET /api/category_list/ GET /api/category/<slug>/| Parameter | Type | Description |
|---|---|---|
slug |
string |
Required slug of item to fetch |
POST /api/add_to_cart/| Key | Value | Description |
|---|---|---|
cart_code |
string |
Required cart code of the cart |
product_id |
string |
Required product id of the product |
PUT /api/update_cartitem/| Key | Value | Description |
|---|---|---|
cartitem_id |
string |
Required cartitem id of the cartitem |
quantity |
string |
Required quantity to update |
DELETE /api/delete_cartitem/<id>/ POST /api/add_review/| Key | Value | Description |
|---|---|---|
product_id |
string |
Required id of the product |
rating |
string |
Required add rating 1,2,3,4 or 5 |
review_text |
string |
Required review_text as review |
email |
string |
Required email to identity user |
PUT /api/update_review/<id>/ DELETE /api/delete_review/<id>/ POST /api/add_to_wishlist/| Key | Value | Description |
|---|---|---|
email |
string |
Required email to indentify the user |
product_id |
string |
Required product id of the product |
GET /api/product_search?search=phone| Search Works on | ||
|---|---|---|
product name |
||
product description |
||
category name |
POST /api/create_checkout_session/| Key | Value | Description |
|---|---|---|
cart_code |
string |
Required code of the cart |
email |
string |
Required email to identify the user |
-
User adds products to cart
-
Checkout session created
-
User completes payment via Stripe
-
Stripe webhook triggered
-
Order & OrderItems created automatically
-
Cart deleted
POST /api/webhook/| Handled Events | ||
|---|---|---|
checkout.session.completed |
||
checkout.session.async_payment_succeeded |
Order automatically created after successful payment
OrderItems generated from CartItems
Stripe Checkout ID stored for tracking
Payment status marked as Paid
Stripe Webhook Signature Verification enabled
CSRF disabled only for Stripe webhook
Sensitive keys should be stored as Environment Variables in production