Code Monkey home page Code Monkey logo

chapa-python's Introduction

Chapa

Linter Version Build License

Unofficial Python SDK for Chapa API.

Instructions

This is a Python SDK for Chapa API. It is not official and is not supported by Chapa. It is provided as-is. Anyone can contribute to this project.

Installation

pip install chapa

Usage

from chapa import Chapa

data = {
    'email': '[email protected]',
    'amount': 1000,
    'first_name': 'Abebe',
    'last_name': 'Bikila',
    'tx_ref': '<your-unique-transaction-id>',
    # optional
    'callback_url': 'https://www.your-site.com/callback',
    'customization': {
        'title': '<Your-Company>',
        'description': 'Payment for your services',
    }
}

chapa = Chapa('<your_api_key>')
response = chapa.initialize(**data)
print(response['data']['checkout_url'])

# Another Implementation
chapa = Chapa('<your_api_key>', response_format='obj')
response = chapa.initialize(**data)
# notice how the response is an object
print(response.data.checkout_url)


# How to verify a transaction
response = chapa.verify('<your-unique-transaction-id>')

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. After that free to contribute to this project. Please read the CONTRIBUTING.md file for more information.

Please make sure to update tests as appropriate.

API Reference

Create new Transaction

Base endpoint https://api.chapa.co/v1

  POST /transaction/initialize
Parameter Type Description
key string Required. This will be your public key from Chapa. When on test mode use the test key, and when on live mode use the live key.
email string Required. A customer’s email. address
amount integer Required. The amount you will be charging your customer.
first_name string Required. Your API key
last_name string Required. A customer’s last name.
tx_ref string Required. A unique reference given to each transaction.
currency string Required. The currency in which all the charges are made. Currency allowed is ETB.
callback_url string The URL to redirect the customer to after payment is done.
customization[title] string The customizations field (optional) allows you to customize the look and feel of the payment modal. You can set a logo, the store name to be displayed (title), and a description for the payment.
HEADER Key Value
Authorization Bearer <YOUR-API-KEY>

Verify Transaction

  GET /transaction/verify/${tx_ref}
Parameter Type Description
tx_ref string Required. A unique reference given to each transaction

FAQ

No Available Questions!

Run Locally

Clone the project

git clone https://github.com/chapimenge3/chapa.git

Go to the project directory

   cd chapa

Install dependencies

pip install -r requirements.txt

License

MIT

Author

Temkin Mengistu

portfolio linkedin twitter

chapa-python's People

Contributors

chapimenge3 avatar isrugeek avatar adilmohak avatar bacode-x avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.