Payfet/Docs
PricingDashboard

Introduction

  • Getting started

Guides

  • Accept payments on your site

SDKs

  • Node.js SDK
  • Python SDK

Reference

  • API reference

For AI agents

/llms.txt

SDKs

Install and use the Payfet Python SDK for bills, airtime and transaction lookups.

View as Markdown

Python SDK

Installation

bash
pip install payfet

Quick start

python
from payfet import PayfetClient

# Initialize the client with your API key
client = PayfetClient(api_key="your_api_key_here")

# Process a bill payment
response = client.bill_payment(
    phone="08012345678",
    amount=500,
    billtype="electricity"
)

print(response)
# {
#   "status": "success",
#   "transaction_id": "txn_123456",
#   "message": "Payment successful"
# }

Read the key from the environment rather than hardcoding it, so it never reaches version control.

Common operations

python
# Top up airtime for a phone number
response = client.airtime(
    phone="08012345678",
    amount=1000,
    provider="MTN"
)

# Check status of a transaction
status = client.transaction_status(transaction_id="txn_123456")

# Retrieve your account balance
balance = client.get_balance()

Error handling

python
try:
    response = client.bill_payment(phone="08012345678", amount=500)
except PayfetAuthError as e:
    print(f"Authentication failed: {e}")
except PayfetPaymentError as e:
    print(f"Payment processing error: {e}")
except Exception as e:
    print(f"Unexpected error: {e}")

Catch PayfetAuthError separately — it means the credentials are wrong, and retrying will not help.

Taking payments from your customers

The SDK covers bills, airtime and account operations. To charge your own customers on your website, use the checkout API — see Accept payments on your site.

Need help?

Email support@payfet.org.

Building with an AI assistant? Use /llms.txt to give it every page at once.