Skip to main content

hot recharge transation using a rest library

Project description

Hot Recharge

library to do hot recharge transactions via a web service

Library installation

$ pip install -U hot-recharge

Library Usage

doing get requests

  • the example file get_tests.py show how to do basic get requests for different services
  • Check out get_tests.py
import HotRecharge
import pprint

credentials = {
    'code': '<your-code>',
    'pswd': '<your-password',
    'ref': '<agent-reference>'
}

# to use random code generated references, flag it to True
api = HotRecharge.HotRecharge(headers=credentials, use_random_ref=True)

try:
    # get wallet balance
    wallet_bal_response = api.walletBalance()

    # get end user balance
    end_user_bal_resp = api.endUserBalance(mobile_number='077xxxxxxx')

    # get data bundles
    data_bundles_resp = api.getDataBundles()

    print("Wallet Balance: ")
    pprint.pprint(wallet_bal_response)

    print("End User Balance: ")
    pprint.pprint(end_user_bal_resp)

    print("Data Bundles Balance: ")
    pprint.pprint(data_bundles_resp)

except Exception as ex:
    print(f"There was a problem: {ex}")

Recharge

Recharge data bundles

  • use bundle product code
  • an optional customer sms can be send together upon request
  • Place holders used include
%AMOUNT% 	$XXX.XX	
%COMPANYNAME%	As Defined by Customer on the website www.hot.co.zw
%ACCESSNAME%	Defined by Customer on website – Teller or Trusted User or branch name
%BUNDLE%	Name of the Data Bundle 
import HotRecharge
import sys
from pprint import pprint

credentials = {
    'code': '<your-code>',
    'pswd': '<your-password',
    'ref': '<agent-reference>'
}

# to use random code generated references, flag it to True
api = HotRecharge.HotRecharge(headers=credentials, use_random_ref=False)

try:
    # recharge data bundle with a (OPTIONAL) custom Customer SMS, max char should not exceed 135
    # uses places holders as used on hot recharge registration
    customer_sms =  " Amount of %AMOUNT% for data %BUNDLE% recharged! " \
                    " %ACCESSNAME%. The best %COMPANYNAME%!"

    # can check length first if not sure
    if len(customer_sms) > 135:
        print("Too many chars for custom customer sms.")
        sys.exit()

    # need to update reference manually, if `use_random_ref` is set to False
    api.updateReference('383yd3')

    response = api.dataBundleRecharge(product_code="<bundle-product-code>", number="077xxxxxxx", mesg=customer_sms)

    pprint(response)

except Exception as ex:
    print(f"There was a problem: {ex}")

recharge pinless

import HotRecharge
import sys

credentials = {
    'code': '<your-code>',
    'pswd': '<your-password',
    'ref': '<agent-reference>'
}

# to use random code generated references, flag it to True
api = HotRecharge.HotRecharge(headers=credentials, use_random_ref=False)

try:
    # recharge pinless with a (OPTIONAL) custom Customer SMS, max char should not exceed 135
    # uses places holders as used on hot recharge registration
    customer_sms = "Recharge of %AMOUNT% successful" \
                   "Initial balance $%INITIALBALANCE%" \
                   "Final Balance $%FINALBALANCE%" \
                   "Thank you for using %COMPANYNAME%"

    # can check length first if not sure
    if len(customer_sms) > 135:
        print("Too many chars for custom customer sms.")
        sys.exit()

    # can update reference manually, if `use_random_ref` is set to False
    api.updateReference('37ehd93')

    response = api.rechargePinless(amount=0.5, number="077xxxxxxx", mesg=customer_sms)

    print(response)

    pass

except Exception as ex:
    print(f"There was a problem: {ex}")

Project details


Release history Release notifications

This version

1.0.0

Download files

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

Files for hot-recharge, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size hot_recharge-1.0.0-py3-none-any.whl (3.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size hot-recharge-1.0.0.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page