Skip to main content

Chapa CLI

Chapa CLI is a command-line tool that helps you integrate, manage, and interact with Chapa's payment API directly from your terminal. This tool provides various commands to handle transactions, retrieve bank details, and more, making it easier to work with Chapa's API without the need for manual API calls.

Chapa CLI in Action

Chapa CLI in Action

Features

  • Initialize Transactions: Create new transactions directly from the CLI.
  • Verify Transactions: Check the status of a transaction.
  • Get Banks: Retrieve a list of supported banks.
  • Get Transaction Events: Fetch and display events related to a specific transaction.
  • Webhook Management: Listen to and test webhooks, including signature verification using HMAC SHA256.

Installation

You don't need this source code unless you want to modify the package. If you just want to use the package, just run:

pip install --upgrade chapa-cli

Install from source with:

Prerequisites

  • Python 3.7 or later (PyPy supported)
  • pip (Python package installer)

Steps

  1. Clone the Repository:

    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  # On Windows use: chapa-env\Scripts\activate
    
  3. Install the CLI:

    pip install -e .
    

Usage

Login

Before using most commands, you need to log in by providing your Chapa API token.

chapa login

You will be prompted to enter your Chapa secret token. This token is securely stored and used for authenticating API requests.

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 to a Webhook

chapa webhook listen /pay/chapa-webhook

Ping a Webhook

chapa webhook ping http://localhost:5000/pay/chapa-webhook

Verify a Webhook URL

You can verify your webhook URL using Chapa's standard webhook protocol, which includes checking the URL's reachability, support for the POST method, SSL certificate validity, and validating the webhook signature with a provided secret key.

chapa webhook verifywebhook https://webhook.site/your-webhook-url --usekey your_secret_key
  • URL: The webhook URL you want to verify.
  • --usekey: (Optional) Your secret key used to sign the request and validate the response. This is crucial for ensuring the integrity and authenticity of webhook requests.

Configuration

Storing the Token

Your Chapa secret token is stored in a configuration file located at ~/.chapa-cli_config.json. This file is created when you log in using the chapa login command.

Environment Variables

If needed, you can also set environment variables for the CLI:

  • CHAPA_API_TOKEN: Set this to your Chapa API token if you want to bypass the login prompt.

Development

Running Tests

To run tests, you can use pytest or any other testing framework of your choice:

pytest

Contributing

Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.

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

License

This project is licensed under the MIT License. Check the LICENSE file for details.

Release files for chapa-cli 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chapa-cli 0.0.4
File Size Uploaded
chapa_cli-0.0.4.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chapa-cli 0.0.4
File Interpreter ABI Platform
chapa_cli-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 23.5 kB

Release files / chapa_cli-0.0.4.tar.gz

Download URL chapa_cli-0.0.4.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2eb91ed7a70fe470bf4cfff53718a2c84c57960253a73933eae27c179e203660
BLAKE2b-256 checksum
How to use checksums
ba7f60d596a1120d311c1914028a44343fe9af744993bcba44c5ffc69401633e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / chapa_cli-0.0.4-py3-none-any.whl

Download URL chapa_cli-0.0.4-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97e9d85aa230bb65cb317a8c1d29feff5130939c7806300888e8d7eb4e920749
BLAKE2b-256 checksum
How to use checksums
e892d3b901ef820f67de4155cd07ed4e2db7a409127a4deed90e7038af091b43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page