Giter Club home page Giter Club logo

stripe_payment's Introduction

stripe_payment

Project is made with Python and Django Rest Framework

Endpoints

  • POST /api/v1/create_charge -

request data -

{
    "amount": int,
    "currency": string,
    "description": string,
    "card_number": string,
    "card_exp_month": int,
    "card_exp_year": int,
    "card_cvc": string
}

Example:
{
    "amount": 10000,
    "currency": "INR",
    "description": "First Payment",
    "card_number": "4242424242424242",
    "card_exp_month": 1,
    "card_exp_year": 2025,
    "card_cvc": "100"
}
  • POST /api/v1/capture_charge/:chargeId - Capture the created charge
  • POST /api/v1/create_refund/:chargeId - Refund created charge
  • GET /api/v1/get_charges - Get list of all charges

Dependencies

  • Django==3.2.6
  • djangorestframework==3.12.4
  • stripe==2.60

Setting Up on Local machine

Prerequisites

Python 3 is intalled on your system

Setup

  1. Open terminal in stripe_payment directory
  2. Run Following commands
# Create Virual Environment
python -m venv ./venv

# Activate Virtual Environment
./venv/Scripts/Activate

# Install Dependencies
pip install -r requirements.txt

Running the server

Once dependencies are installed run following

# Sets up migrations scripts to create/update/delete Models if any in database
python manage.py makemigrations

# Runs the migrations
python manage.py migrate

Before running the service we need to set STRIPE_API_KEY environment variable.

# Windows Powershell
$ENV:STRIPE_API_KEY = '<your stripe api key>'

# Windows CMD
set STRIPE_API_KEY=<your stripe api key>

# Linux
export STRIPE_API_KEY='<your stripe api key>'

Run the server

python manage.py runserver

Running tests

python manage.py test

Project Structure

Root:
|   - README.md
|
|---stripe_payment
    |   - manage.py
    |   - requirements.txt
    |
    |---payments (module)
    |   |   - apps.py
    |   |   - serializers.py
    |   |   - tests.py
    |   |   - urls.py
    |   |   - utils.py
    |   |   - views.py
    |   |
    |   |---services
    |       - stripe.py
    |
    |---stripe_payment (core App)
            - asgi.py
            - settings.py
            - urls.py
            - wsgi.py

Important files

  • payments/urls.py - Contains Routes to the endpoints binded with views
  • payments/serializers.py - Serializing the request
  • payments/views.py - Entry point to execute code for endpoints
  • payments/services/stripe.py

PostMan Collection

Run in Postman

stripe_payment's People

Contributors

kartiky9 avatar

Stargazers

Roman avatar

Watchers

 avatar

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.