GithubHelp home page GithubHelp logo

kirillzhosul / django-stripe Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 68 KB

Test task for one of the companies. Django simple *shop* with Stripe.

Home Page: https://kirillzhosul.florgon.space/tests/stripe/

License: MIT License

Python 79.41% Shell 5.55% Dockerfile 3.02% HTML 12.01%
django stripe api backend black cicd docker postgresql python shop

django-stripe's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.