Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

kirillzhosul/django-stripe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Stripe.

Deploy Tests
Code style: black

Test task for one of the companies. Django simple shop with Stripe. Main goal is to have endpoint /item/<item_id> that will return HTML with item information (from server database) and buy button, that will fetch another route (API) (/buy/<item_id>) that will return Stripe Session ID that is used to redirect user to payment screen (Actually, Stripe itself).

How to try project?

Project is being deployed to production by GitHub workflow (deploy action, CD). You can try project here (Click!)
Test item with id 1!

Methods.

/item/<id>: Returns HTML page with item information and button to buy selected item.
/buy/<id>: Returns Stripe Session ID (Actually, item page fetches that endpoint to redirect by own).
/admin/*: Project supports Django-Admin to work with models (Items, Discounts etc).
/: Simple index page.

How to run?

Project uses Docker, to run, simply do this in the repository root: cd src && docker-compose up. This will run Docker, Database and server with Gunicorn with Uvicorn workers!

Static files?

Currently in production, static files is being served by Ngninx (+Django collectstatic) On the development, static files is only avaliable when using django runserver

Migrations?

Run docker exec -it django-stripe-server-1 /bin/sh and then python manage.py makemigrations && python manage.py migrate this will trigger all database migrations!

How to configure?

You can modify environment variables inside /src/.server.env file that will be passed to the server with Docker. Look at the Django / App chapters. STRIPE_API_PUBLISHABLE_KEY, STRIPE_API_SECRET_KEY is Stripe keys that may be found here. URL_PREFIX is used only for under proxy urls. All other settings refers to default Django fields.

Technologies.

  • Python / Django (No DRF cause main goal is not to make API).
  • Gunicorn with Uvicorn workers (ASGI).
  • Stripe API for payments.
  • Docker / Docker-Compose
  • PostgreSQL (with PgBouncer) / Django ORM
  • GitHub Workflows (CI/CD)
  • Nginx on the server side as the proxy server.
  • Ubuntu as the server OS.

CI / CD.

  • CD: Project have deploy workflow, that will automatically deploy all changes pushed to the main branch.
  • CI: Project have tests workflow, that will run Django tests / Test Docker when you are merging branch into main branch For now there is no special tests written for this project, so tests just not so useful.

Testing.

Run docker exec -it django-stripe-server-1 /bin/sh and then python manage.py test this will trigger all tests!

References.