Skip to main content

Python wrapper for the Pesapal API

Project description

Pesapal Python SDK

Unofficial Python SDK for Pesapal API 3.0

Features

  • Automatic token management and refresh
  • Type-safe request models
  • Clean, intuitive API
  • Comprehensive docs
  • Good test coverage

Installation

pip install pesapal-sdk

Quickstart

from pesapal_sdk import PesapalClient
from pesapal.models import OrderRequest, BillingAddress
from decimal import Decimal

# Initialize client
client = PesapalClient(
    consumer_key="<YOUR-PESAPAL-CONSUMER-KEY>",
    consumer_secret="<YOUR-PESAPAL-CONSUMER-SECRET>",
    environment="sandbox" # or "production"
)

# Register IPN URL (one-time setup)
ipn_response = client.ipn.register("https://yoursite.com/ipn")
ipn_id = ipn_response["ipn_id"]

# Create billing address
billing = BillingAddress(
    email_address="customer@example.com",
    phone_number="0712345678",
    country_code="KE",
    first_name="Kevin",
    last_name="Kimani",
    line_1="Juja, Kenya"
)

# Submit order
order = OrderRequest(
    id="order-123",
    currency="KES",
    amount=Decimal("1000.00"),
    description="Payment for services",
    callback_url="https://yoursite.com/callback",
    notification_id=ipn_id,
    billing_address=billing
)

response = client.transactions.submit_order(order)
print(f"Redirect URL: {response['redirect_url']}")

# Check transaction status
status = client.transactions.get_status(response["order_tracking_id"])
print(f"Status: {status['payment_status_description']}"

Requirements

  • Python 3.8+
  • requests

License

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

Support

Disclaimer

This is an unofficial SDK and is not affiliated with or endorsed by Pesapal.

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

pesapal_sdk-0.1.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

pesapal_sdk-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file pesapal_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: pesapal_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for pesapal_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b63a5a2063df08e455c6aa9c940bff4fae5fc540629af5c6fcfcd48284a0fac
MD5 b2e71e59e6d1b285764b5b1ba67c5322
BLAKE2b-256 87974bd078b3566571195eaf8511716c7107fa1c7c75da685d26176afb879bd8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pesapal_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for pesapal_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d27cf8e54ac35b09a37276f614fd95ed5cb7b8ce05f395de6637b156add25ce
MD5 fbba0b8a497dcb31f79509b12b46c36d
BLAKE2b-256 f3342519ba75b628b9a8e0cc30388b1895adfb0e8b564d3c8e2c033e9625da18

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