Skip to main content

VTPass Python SDK to interact with various services provided by VTPass. The SDK allows you to perform operations such as checking wallet balance, purchasing airtime, and subscribing to data services.

Project description

VTPass Python SDK

This repository provides the VTPass Python SDK to interact with various services provided by VTPass. The SDK allows you to perform operations such as checking wallet balance, purchasing airtime, and subscribing to data services.

Prerequisites

  • Python 3.7 or higher
  • vtpass package
  • python-dotenv package
  • VTPass API Key
  • VTPass Public Key
  • VTPass Secret Key

Installation

First, clone the repository and navigate to the project directory:

git clone https://github.com/yourusername/vtpass-pythonsdk.git
cd vtpass-pythonsdk

Then, install the required packages or skipp if you have already installed the vtpass-python-sdk package:

pip install -r requirements.txt

Environment Variables

Create a .env file in the root of your project directory and add the following environment variables:

API_KEY=your_api_key
PUBLIC_KEY=your_public_key
SECRET_KEY=your_secret_key
TIMEZONE=Africa/Lagos
JSON_RESPONSE=False # Set to True to return JSON response which is useful 
Sandbox_URL=https://sandbox.vtpass.com/api
Live_URL=https://live.vtpass.com/api

Usage

Import Required Modules

from vtpass import vtPass
from airtime import vtpass_airtime
from dotenv import load_dotenv
import os
from airtime.schema import AirtimeSchema
from data_subscription.schema import DataSubscriptionSchema, VerifySmileEmailSchema
from data_subscription import vtpass_data_subscription
from vtpass.schema import (
    ServiceIdentifierSchema,
    ServiceIdVariationSchema,
    ProductOptionSchema,
    ServiceIdSchema,
)

# Load environment variables from .env file
load_dotenv()

sandbox_url = os.getenv('Sandbox_URL')
live_url = os.getenv('Live_URL')

Get Wallet Balance

# Get wallet balance
balance = vtPass.get_credit_wallet_balance(sandbox_url)
print(balance)

Get Available Service Categories

# Get available service categories
service_categories = vtPass.get_available_service_categories(sandbox_url)
try:
    # If JSON response is False
    for category in service_categories:
        print(f"Identifier: {category.get('identifier')}, Name: {category.get('name')}")
except Exception:
    # If JSON response is True
    print(service_categories)

Get Available Service Details

# Get available service details
identifier = ServiceIdentifierSchema(identifier="insurance")
service_details = vtPass.get_service_identify_details(sandbox_url, identifier)
try:
    # If JSON response is False
    for detail in service_details:
        print(f"Service Id: {detail.get('serviceID')}, Name: {detail.get('name')}")
except Exception:
    # If JSON response is True
    print(service_details)

Get Service Variation Details

# Get service variation details
service_id = ServiceIdVariationSchema(service_id="airtel-data")
service_variation_details = vtPass.get_service_variation_details(sandbox_url, service_id)
print(service_variation_details)

Get Product Options

# Get product options
product_option_schema = ProductOptionSchema(
    service_id="ui-insure",
    name="Third Party Motor Insurance - Universal Insurance"
)
service_product_options = vtPass.get_product_options(sandbox_url, product_option_schema)
print(service_product_options)

Generate Request ID

# Generate request ID
request_id = vtPass.generate_request_id()
print(request_id)

Purchase Airtime

# Purchase airtime
airtime_schema = AirtimeSchema(
    service_id="etisalat",
    phone_number="08011111111",
    amount=2000,
    request_id=request_id
)
purchase_airtime = vtpass_airtime.purchase_airtime(sandbox_url, airtime_schema=airtime_schema)
print(purchase_airtime)

Get Service Variation Code

# Get service variation code
service_id = ServiceIdSchema(service_id="spectranet")
service_variation_code = vtPass.get_service_variation_codes(sandbox_url, service_id)
print(service_variation_code)

Verify Smile Email Address

# Verify Smile email address
verify_smile_schema = VerifySmileEmailSchema(
    billers_code="tester@sandbox.com",
    service_id="smile-direct"
)
vtpass_smile_email_verify = vtpass_data_subscription.verify_smile_email(sandbox_url, verify_smile_schema)
print(vtpass_smile_email_verify)

Buy Data Subscription

# Buy data subscription
data_sub_schema = DataSubscriptionSchema(
    service_id="spectranet",
    variation_code="vt-5000",
    request_id=request_id,
    phone="08011111111",
    billers_code="1212121212",
)
data_subscription = vtpass_data_subscription.purchase_data_susbscription(sandbox_url, data_sub_schema)
print(data_subscription)

License

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

Contributing

Please feel free to submit issues, fork the repository and send pull requests!


This README provides a comprehensive guide on how to use the VTPass Python SDK with detailed examples. You can also check the official documentation for more information.

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

vtpass-python-sdk-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

vtpass_python_sdk-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file vtpass-python-sdk-0.1.0.tar.gz.

File metadata

  • Download URL: vtpass-python-sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for vtpass-python-sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 24f3756e51d0668d35de7e74ef4a4c6b8acd574b8df3580477004bb403e4d84d
MD5 f9acea5944fee2a335eba9edcd218320
BLAKE2b-256 45530fa3482cb42a245c13b53b05f204cf5614f3befcf7eb02a0316113bdea05

See more details on using hashes here.

File details

Details for the file vtpass_python_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vtpass_python_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26be0081aeda17c707007c5bdb8650e24d2154f2df1d4fc2c1775a710936cc54
MD5 deeed93018e0f1a7683ccedadec95b40
BLAKE2b-256 e4f793e8217b30939fb21f2b9cfefa2c02a1ecc5bb623244ad6ffe3d6330b15f

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