Skip to main content

A Python wrapper for Shoket API

Project description

pyshoket

Made in Tanzania

  • A Python wrapper for Shoket API.
  • Make online payments easy with pyshoket, connecting MNO such as Tigo (Tigopesa), Halotel (Halopesa) and Airtel (Airtel money)

Installation

  • Installing pyshoket using pip
pip install pyshoket
  • OR You can also install pyshoket from github repository.
git clone https://github.com/maen08/pyshoket

Setup environment variables

To perform payments with Shoket, you need to pass PRIVATE_KEY in the request. Its already handled in this wrapper, what you need to do is to keep your Shoket key private.

  • You can receive your private key here after signup in the Shoket account.
  • In the root directory of your project, create .env file to store your key
PRIVATE_KEY=mpBsk_icAldgTTvXXXXXXXXXXXXXXXX

NB: No space between equal sign

Usage

To enable payments in your project with pyshoket, this is how you can do it.

from pyshoket import PyShoket

shoket = PyShoket()
response = shoket.make_payment(
    amount=2000,
    customer_name='Stanley Ruheza',
    customer_email='stanleyruheza@gmail.com',
    customer_number='255717610000',
    channel='Tigo'

)

print(response)

If we check the response of the above request (Successful request), it will be something like this:

# Response of successful request


{
    "Status": "success" ,
    "customer" {
        "customer_name": "376FcD3gbidW",
        "email": "stanleyruheza@gmail.com",
        "id": 64043
    },
    "data": {
        "amount": 2000,
        "channel": "Tigo",
        "currency": "TSH",
        "number_used": "255717610000",
        "status": "Success",
        "transaction_date": "2022-03-01 15:08:59.917691"
    },
    "message": "Transaction is completed",
    "reference": "adz49dS428b7kbDTdG4MN"
}

If the private key is incorrect, then you'll recieve this response:

# Unsuccessful response

{
    "detail": "Unauthorized Access",
    "message": "Errors!, Unsuccessful payment",
    "status_code": "401"
}


Contribution

Pyshoket is an open source project so feel free to contribute. You can contribute in various ways, including:

  • Fixing typos in the codes and the README document.
  • Add more features on the project
  • Resolve raised issues
  • Write use cases
  • Improve documentation

Credits

Credits to all contributors of Pyshoket. Your work is worthy.

  • maen08 - author/maintainer
  • Contributors

Give it a star

Share the project with your team, give it a star and use it.

Licence

Pyshoket is an Open Source project under MIT licence

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pyshoket-0.2.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pyshoket-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: pyshoket-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for pyshoket-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ea6d19bbc12ffe02e3d21eca50d1fabfda74c2e2e38ce53d60f3c8269895f9b2
MD5 60cd5601468c74eb5c5b204b3f65436d
BLAKE2b-256 54349b17b9f3e35f0ebb9d177327de8411cecd3b47b43e27c245969af5edc582

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page