DEV Community

Cover image for Free Django eCommerce - Use Products from Stripe
Sm0ke
Sm0ke

Posted on • Originally published at blog.appseed.us

Free Django eCommerce - Use Products from Stripe

Hello coders!

This article presents an open-source Django & Stripe Mini eCommerce starter that builds product pages using the information saved in Stripe Dashboard. Once the Stripe Secrets are provided in the .env file, the superusers are able to pull the products from Stripe and edit the information via a simple UI. The sources, released under the MIT License, can be used in commercial projects and eLearning activities. Thanks for reading!


✨ How it works

The sources come with a default product, saved in the local filesystem. If the user initiates the purchase, the application warns that the Stripe Secrets are not provided and the flow cannot continue. The steps, as explained in the video, are the following:

πŸ‘‰ Step #1 - Clone the source code from the public repository

$ git clone https://github.com/app-generator/sample-django-stripe.git
$ cd sample-django-stripe
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Step #2 - Follow up the usual set up for a Django Project

$ python -m venv env
$ source env/bin/activate
$ pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Step #3 - Migrate the database & Create a Superuser

$ python manage.py migrate          # migrate DB
$ python manage.py createsuperuser  # create the app King
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Step #4 - Create .env file in the root of the project

DEBUG=True
SECRET_KEY=WhateEver_KEY

STRIPE_SECRET_KEY=<FROM_STRIPE>       # <-- MANDATORY
STRIPE_PUBLISHABLE_KEY=<FROM_STRIPE>  # <-- MANDATORY

# Server Address (used by Stripe callback)
# Should be the URL used to start the APP
DOMAIN_URL=http://localhost:8000/
Enter fullscreen mode Exit fullscreen mode

The most important settings are the Stripe Secrets that will authorize the payment flow using Stripe as the payment provider. The values can be found on your Stripe Dashboard and the newcomers should use the "TEST" mode during the tests.

Once the env file is edited and saved, we can safely start the project and import the data from Stripe using a simple UI.


πŸ‘‰ Stripe Dashboard - With Three products defined

Django eCommerce - Stripe Dashboard (free product)


Before import, the app warns the users to authenticate and add more products using a superuser account.

Django & Stripe - Missing Products Warning.


In the page, reserved for superusers, if the configuration is correct, the information from Stripe becomes available and editable.

Django eCommerce - Information pulled from Stripe.


For each product, all product fields are editable using a minimal UI: price, name, description, and IMAGES. A live payment flow should look like this:

Django & Stripe eCommerce - Payment Flow


The sample used in the video demonstration can be found on GitHub with all the products already downloaded from Stripe:

GitHub logo app-generator / django-mini-ecomm

Django Mini eCommerce - Products DW from Stripe

Django & Stripe Mini eCommerce

Open-source mini eCommerce project that loads the products from JSON files saved in the templates directory (no database required) and uses a decent UI for page styling - Powered by Django.

Roadmap & Features



















































Status Item info
βœ… Django For backend logic
βœ… Stripe Payment processor
βœ… Soft UI Design (Free Version) by Creative-Tim
βœ… JSON
Products definition - see sample
βœ… Automatic Products Discovery Source DIR: templates\products
βœ… Dw Products from Stripe On going development via Python Stripe Library
❌ Docker -
❌ CI/CD Render Deployment Platform


django-stripe-mini-ecommerce.mp4

✨ Quick Start

πŸ‘‰ Step 1 - Download the code from the GH repository (using GIT)

$ git clone https://github.com/app-generator/django-mini-ecomm.git
$ cd django-mini-ecomm
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Step 2 - Create .env using provided env.sample

Add .env file…


Thanks for reading! For more tools and support feel free to access:

Top comments (6)

Collapse
 
crearesite profile image
WebsiteMarket

Simple tool. A SQLite persistence might be a nice evolution.

Collapse
 
sm0ke profile image
Sm0ke

Noted. Ty!
πŸš€πŸš€

Collapse
 
uithemes profile image
ui-themes

The UI looks really nice.
Thanks for coding this.

Collapse
 
sm0ke profile image
Sm0ke

πŸš€πŸš€

Collapse
 
austinjhunt profile image
Austin Hunt

Neato! Just added a Stripe integration to my Django project sketchyactivity.com this year for handling non-cash commissions, I'm going to take a look at this! Thanks for building & documenting!

Collapse
 
sm0ke profile image
Sm0ke

πŸš€πŸš€