CLI
Chapa CLI helps you integrate, manage, and interact with Chapa's API directly from your terminal.
Chapa CLI is a command-line tool for working with Chapa's payment API without manual HTTP calls.
Features
- Initialize transactions
- Verify transactions
- Get supported banks
- Fetch transaction events
- Manage webhooks (listen, ping, verify)
Installation
If you only need the CLI, install from PyPI:
pip install --upgrade chapa-cliInstall from source:
Prerequisites: Python 3.7+ (PyPy supported), pip
- Clone and enter the repo:
git clone https://github.com/chapa-Et/chapa-cli.git cd chapa-cli - Create and activate a virtual environment:
python -m venv chapa-env source chapa-env/bin/activate # Windows: chapa-env\Scripts\activate - Install the CLI:
pip install -e .
Usage
Login
chapa loginEnter your Chapa secret token when prompted. Stored at ~/.chapa-cli_config.json.
Initialize a Transaction
chapa transaction initialize --amount 100 --phone 0911112233 --tx_ref REF123 --callback_url https://souq.com/callbackVerify a Transaction
chapa transaction verify --reference REF123Get Supported Banks
chapa transaction banksGet Transaction Events
chapa transaction events AP9ARo9XvMO5Webhook Management
- Listen:
chapa webhook listen /pay/chapa-webhook - Ping:
chapa webhook ping http://localhost:5000/pay/chapa-webhook - Verify:
chapa webhook verifywebhook https://webhook.site/De7bbf58-3c3e-4247-8ac1-4b00a4d38519 -usekey 342jfsdXXXXXXXXX
Configuration
- Token stored at
~/.chapa-cli_config.jsonafterchapa login. - Environment variable:
CHAPA_API_TOKENto bypass login prompt.
Development
Run tests:
pytestContributing
- Fork the repo
- Create a branch:
git checkout -b feature/your-feature-name - Commit:
git commit -am 'Add some feature' - Push:
git push origin feature/your-feature-name - Open a pull request
License
MIT License. See LICENSE in the repo.