This project demonstrates how to integrate Cashfree Payments' payment gateway into a Django e-commerce application. It is intended for educational purposes and is not recommended for production use.
- Landing Page: Lists products fetched from the Fake Store API.
- Cart Page: Allows users to add, update, and remove products from the cart.
- Payment Integration: Uses Cashfree Payments' payment gateway to process orders.
- Order Success Page: Displays order details and redirects to the landing page after a successful payment.
- Python 3.9+
- Django 4.2.13
- Cashfree Python SDK
-
Clone the repository:
git clone https://github.com/withshubh/fakeazon.git cd fakeazon -
Create and activate a virtual environment:
python -m venv myenv source myenv/bin/activate # On Windows, use `myenv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set up the Django project:
python manage.py migrate python manage.py runserver
-
Access the application:
Open your web browser and go to
http://localhost:8000.
- shop/views.py: Contains the views for the landing page, cart page, order creation, and order success page.
- shop/templates/shop: Contains the HTML templates for the landing page, cart page, and order success page.
- shop/static/css/styles.css: Contains the CSS styles for the application.
In shop/views.py, configure the Cashfree SDK with your Client ID and Secret key:
from cashfree_pg.api_client import Cashfree
Cashfree.XClientId = 'YOUR_CLIENT_ID'
Cashfree.XClientSecret = 'YOUR_CLIENT_SECRET'
Cashfree.XEnvironment = Cashfree.SANDBOX # Use `Cashfree.PRODUCTION` for productionThe order creation process is handled in the create_order view. This view calculates the total amount from the cart, creates an order using the Cashfree SDK, and returns the payment session ID.
The payment session ID is used to open the Cashfree checkout page. This is done in the cart_page.html template using the Cashfree JavaScript SDK.
Contributions are welcome! Please read the CONTRIBUTING.md file for details on how to get started.
This project is licensed under the MIT License. See the LICENSE file for details.

