Skip to main content

A Python SDK to initiate online payment to the Dischub API

Project description

Dischub Python SDK

Overview

The Dischub Python SDK allows developers to easily integrate with the Dischub API for online payment processing. This SDK provides a simple interface for creating payments via the Dischub API.

Installation

You can install the Dischub SDK using pip:

pip install dischub

Usage

Copy and paste code below as a function called "payment" in your functions' file

from dischub import Dischub

def payment():
    data = {
        "api_key" : "your-api-key",
        "order_id" : "your-purchase-order-id-or-number",
        "sender": "your-client's-phone-number",
        "recipient": "your-dischub-business-account-email-address",
        "amount": 100,
        "currency": "USD",
        }
    payment_instance = Dischub()
    response = payment_instance.create_payment(data)
    print(response)
payment()

Success Response

If your integration is done so well, you will get the below response

{'status': 'success', 'message': 'payment initiated', 'response_code': 201}

Missing Keys Response

if you miss one or more keys in the data dictionary, you will get below response

{'status': 'error', 'message': 'missing or invalid required keys', 'response_code': 400}

Invalid Currency Response

if you upload currency type other than 'USD' and 'ZWG' on the currency key in the data dictionary, you will get below response

{'status': 'error', 'message': 'Invalid or unsupported currency', 'response_code': 400}

Authorization Response

if use invalid api_key or you Dischub business account email on the api_key or reciepient keys respectively, you will get the below response

{'status': 'error', 'message': 'authorization failed', 'response_code': 400}

Invalid Sender's Phone Number Response

If sender's phone number is invalid, you will get the below response

{'status': 'error', 'message': 'invalid sender phone number format', 'response_code': 400}

Invalid Amount Range Response

If amount is out of expected range, you will get the below response

{'status': 'error', 'message': 'amount must be greater than 0 and less than 481', 'response_code': 400}

Invalid order_id Data Type Response

If order_id not in string format, you will get the below response

{'status': 'error', 'message': 'order_id must be posted as string', 'response_code': 400}

Duplication Of order_id Response

If same order_id is repeated, you will get the below response

{'status': 'error', 'message': 'duplication of order_id detected, create a new unique order_id again', 'response_code': 400}

Invalid order_id Character Length Response

If order_id is more than 30 characters, you will get the below response

{'status': 'error', 'message': 'order_id should be 30 characters or less', 'response_code': 400}

Completing Payment

The sdk will auto redirects you to the Dischub payment page for you to complete the pending payment

Project details


Download files

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

Source Distribution

dischub-2.1.4.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dischub-2.1.4-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file dischub-2.1.4.tar.gz.

File metadata

  • Download URL: dischub-2.1.4.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dischub-2.1.4.tar.gz
Algorithm Hash digest
SHA256 55e99d82ab945fdedfa7fb6eb94b21b9af9470919c909ab13690ec504970a7f9
MD5 56d0c7845f2c0e37dc5840e770ddf2ef
BLAKE2b-256 e6b58a65734d86f1004cfef46c2fbbaa050540d7d5fa52bfbb6fadef88a28a38

See more details on using hashes here.

File details

Details for the file dischub-2.1.4-py3-none-any.whl.

File metadata

  • Download URL: dischub-2.1.4-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dischub-2.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 543b5787ac2b6429e6b778530cadcbf58349f48e011e1c81c90f44e00aa9f10b
MD5 00ea4f438ab4861a92c70ebfcedbbe65
BLAKE2b-256 99c6c4cc9aea410cb95f8cf399356176661f692395dcc01269c93de65cf8acaf

See more details on using hashes here.

Supported by

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