ChapaChapa Docs

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-cli

Install from source:

Prerequisites: Python 3.7+ (PyPy supported), pip

  1. Clone and enter the repo:
    git clone https://github.com/chapa-Et/chapa-cli.git
    cd chapa-cli
  2. Create and activate a virtual environment:
    python -m venv chapa-env
    source chapa-env/bin/activate  # Windows: chapa-env\Scripts\activate
  3. Install the CLI:
    pip install -e .

Usage

Login

chapa login

Enter 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/callback

Verify a Transaction

chapa transaction verify --reference REF123

Get Supported Banks

chapa transaction banks

Get Transaction Events

chapa transaction events AP9ARo9XvMO5

Webhook 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.json after chapa login.
  • Environment variable: CHAPA_API_TOKEN to bypass login prompt.

Development

Run tests:

pytest

Contributing

  1. Fork the repo
  2. Create a branch: git checkout -b feature/your-feature-name
  3. Commit: git commit -am 'Add some feature'
  4. Push: git push origin feature/your-feature-name
  5. Open a pull request

License

MIT License. See LICENSE in the repo.

On this page