Flask and Stripe - Simple Open-Source eCommerce APP
Hello Coders!
This article presents an open-source codebase that provides simple eCommerce features powered by Flask and Stripe. The products are loaded from JSON
files (no database) and all related pages and cards are generated during the runtime. This codebase can be used to bootstrap fast a minimal eCommerce or simply for eLearning activities that involve Flask and Stripe. For newcomers, Flask
is a popular web framework and Stripe
is a leading payment gateway widely used in eCommerce projects.
Thanks for reading!
- 👉 Flask Stripe Sample - Source Code
- 🎁 Free Support via email (issues tracker) and Discord (1k+ community)
✨ How it works
Once the Flask source code is downloaded and compiled we need to set up the environment to bind correctly the app with the Stripe platform.
The .env.sample
should be renamed to .env
and edited to provide valid Stripe Credentials:
- Edit
STRIPE_SECRET_KEY
- provided by Stripe Platform - Edit
STRIPE_PUBLISHABLE_KEY
- provided by Stripe Platform
The app comes with product samples defined in the templates directory. During the runtime, Flask scans the directory, generates the pages, and publishes all discovered products. Let's take a look at a real sample: Air Zoom Pegasus:
JSON File - saved in the templates directory
{
"name": "Air ZOOM Pegasus",
"price": 499,
"currency": "usd",
"info": "Men's Road Running Shoes",
"short_description": "A workhorse built to help power you through every mile of the race.",
"full_description": "A workhorse built to help power you through every mile of the race, the Nike Air Zoom Pegasus 38 Ekiden continues to put a spring in your step, using the same responsive foam as its predecessor. Mesh in the upper combines the comfort and durability you want with a fit that nods back to the classic Peg."
}
Media Files: Product card and Cover Image:
The app detects all this information and builds the pages as shown in this GIF animated presentation:
To complete the payment, make sure your Stripe account runs in the TEST
mode. For a successful payment a test CC provided by Stripe can be used:
- CC Number:
4242 4242 4242 4242
- Any data for the rest of the fields
Stripe and Flask App
- Payment Confirmation page
Thanks for reading!
For more resources feel free to access:
- ✨ Free Dashboards crafted in Django, Flask, and React
- ✨ Admin Dashboards - a huge index with products
Hi can you please share your source code for flask and all the diff codes used