The objective of this repo is to simulate a product that has a simple customer catalog (think of it as a simple customer table) and to build a two-way integration with a customer catalog in an external service - Stripe in this case. The two-way sync is real-time so that a customer added/edited on one system propagates to the other system within a few seconds.
First, to clone this repository to your local machine run the following command in your git Bash
https://github.com/sukhmani1303/two-way-integration.git
make sure you clone it into an appropriate folder :)
Then, setup a virtual environment using the following command
virtualenv venv
use the following command to install the requirements
pip install -r requirements.txt
First, install Docker in your machine & execute the following steps
- open any terminal and cd into the "docker-kafka" folder
- run the following command in the terminal
docker compose -f docker-compose.yml up -d
- Open Docker & start the "docker-kafka" container to enable kafka
- Download Ngrok file from here
- Run the following command after running main.py module to get public url for Webhook
ngrok http 8080
- Save the url & endpoint "<public_url>/inward_sync/update" as endpoint url for stripe webhook which listens to customer.updated
- Login into Stripe
- Get all the API keys & store them as json in "Keys.json" file
{
"STRIPE_SECRET_KEY" : "<your key>",
"STRIPE_PUBLISHABLE_KEY" : "<your key>",
"WEBHOOK_SECRET" : "<your key>"
}
- Download & install PostgreSQL
- Insert Data which you entered in stripe's customer catalog
- Change the "SQLALCHEMY_DATABASE_URL" inside the database.py module to connect to your local DB
- Start the "docker-kafka" container in Docker Desktop
- Activate the virtual environment
- Run the "k_consumer.py" module in a separate terminal
- Run "main.py" module
- Use Ngrok to get a public url & update stripe's Webhook endpoint
- Run app.py by writing the following command in terminal
streamlit run app.py
using the streamlit's interface one can
- update the records & trigger outward sync
- view all the record by applying inward sync changes