A simple wrapper (API) that sits between MPESA and BtoBet, allowing 3rd party clients to seamlessly process payments (B2B, B2C and C2B).
TODO:
- B2B flow
- B2C flow
- C2B (partially, the Broker has been implemented)
- Unit Tests
- CI/CD (Github Actions or/and GitLab CI)
Prerequisite:
- git
- Python 3.12 or later.
- Poetry
- Docker
Without Docker:
git clone git@github.com:clovisphere/mpesa-btobet-client.git
cd mpesa-btobet-client
poetry install
export PYTHONDONTWRITEBYTECODE=1 # you don't have to do this:-)
export DATABASE_URL=sqlite:///./demo.db
If you are using the zed code editor, please add the below to ./pyproject.toml:
[tool.pyright]
venvPath = "" # absolute path to your `virtualenvs` folder
venv = "" # venv name
Setup the database (fresh start, with no revision):
alembic current # check db state
alembic revision --autogenerate -m "init" # initialize database
alembic upgrade head # apply migration(s)
Use the below if revision(s) exist in versions:
alembic current # check db state
alembic upgrade head # apply migration(s)
To learn more about alembic here.
$ sqlite3 demo.db # access sqlite console from your terminal
sqlite> .headers ON
sqlite> .mode columns
sqlite> .tables # show all tables
sqlite> .schema deposit # equivalent to MySQL's `DESC deposit;`
sqlite> pragma table_info(deposit); # same as ☝🏽
sqlite> select * from deposit; # view (all) table data
sqlite> .exit # exit the sqlite3 console
We will use a Makefile to start the app 🤗
make local-dev
With Docker:
make build-start-container-dev
Test it out:
with httpie:
http :8088/health
you'd get:
{
"status": "healthy 😊"
}
To bring down the containers and volumes down once done:
make stop-container
You can read and learn about Makefiles here.
make build-start-container-prod DATABASE_URL=url_to_your_prod_db
Clovis Mugaruka
Copyright ©️ 2023, Clovis Mugaruka.
Released under the MIT License.