Skip to content

Two way syncing application between local system's customer list and Stripe's customer list which is an external service.

Notifications You must be signed in to change notification settings

atharvabhide/Stripe-Sync

Repository files navigation

Stripe-Sync

Demo Video:

demo.video.mp4

System environment:

  1. Windows 11
  2. Anaconda Python 3.10.9 / Python 3.10.9 virtual environment (Link)
  3. Docker Desktop (Link)
  4. MySQL 8.0 (Link)
  5. ngrok (Link)

Installation steps:

  1. Clone the repository:

    git clone https://github.com/atharvabhide/Stripe-Sync.git
    cd Stripe-Sync
  2. Create a Python environment

    conda create --name <ENV_NAME> python=3.10.9
    conda activate <ENV_NAME>
    
    OR
    
    virtualenv <ENV_NAME> -p python3.10.9
    <ENV_NAME>\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
  4. Create a developer account on Stripe and copy the Secret key: https://dashboard.stripe.com/developers

  5. Create the MySQL DB:

    mysql -u <DB_USERNAME> -p
    create database <DB_NAME>
  6. Create an env file in the backend folder (.env):

    DB_USERNAME = <YOUR_DB_USERNAME>
    DB_PASSWORD = <YOUR_DB_PASSWORD>
    DB_NAME = <YOUR_DB_NAME>
    STRIPE_API_KEY = <YOUR_STRIPE_API_PRIVATE_KEY>
  7. Create and start Docker containers for Kafka and Zookeeper:

    docker-compose -f backend\kafka\docker_compose.yml up -d
  8. Expose port 8000 using ngrok:

    ngrok http 8000
  9. Add the ngrok exposed url (add /stripe-webhook to the url) in the Web Hooks section of the Stripe Developer account: https://dashboard.stripe.com/test/webhooks with the following events:

    • customer.created
    • customer.updated
    • customer.deleted
  10. Run the main FastAPI local server (in a separate terminal):

    python backend\main.py
  11. Run the stripe webhook FastAPI local server (in a separate terminal):

    python backend\kafka\api.py
  12. Run the main Kafka consumer/worker (in a separate terminal):

    python backend\kafka\consumer.py
  13. Run the stripe webhook Kafka consumer/worker (in a separate terminal):

    python backend\kafka\stripe_consumer.py
  14. Outward Sync:

    • Open localhost:8080/docs to access the FastAPI documentation.
    • Perform CRUD operations by using the APIs.
    • The changes get reflected in the Customer list of the developer account on Stripe.
  15. Inward Sync:

    • Open Customer list of the developer account on Stripe.
    • Perform CRUD operations through the Stripe interface.
    • The changes get reflected on the local system and can be observed on localhost:8080/docs through the read APIs.
  16. To use the Streamlit dashboard for the outward sync (in a separate terminal):

    streamlit run frontend\app.py

About

Two way syncing application between local system's customer list and Stripe's customer list which is an external service.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages