Metadata-Version: 2.4
Name: pesapal_sdk
Version: 0.1.5
Summary: Python wrapper for the Pesapal API
Author-email: Kevin Kimani <kimanikevin254@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/kimanikevin254/pesapal-python-sdk
Project-URL: Repository, https://github.com/kimanikevin254/pesapal-python-sdk
Project-URL: Issues, https://github.com/kimanikevin254/pesapal-python-sdk/issues
Keywords: pesapal,sdk,payments
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: requests>=2.28.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: pytest-mock>=3.10; extra == "dev"
Dynamic: license-file

# Pesapal Python SDK

Unofficial Python SDK for [Pesapal API 3.0](https://developer.pesapal.com/how-to-integrate/e-commerce/api-30-json/api-reference)

## Features

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

## Installation

```
pip install pesapal-sdk
```

## Quickstart

```python
from pesapal_sdk import PesapalClient
from pesapal_sdk.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",
    line1="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](./LICENSE.md) file for details.

## Support

-   Documentation: [Pesapal API Docs](https://developer.pesapal.com/how-to-integrate/e-commerce/api-30-json/api-reference)
-   Issues: [GitHub Issues](https://github.com/kimanikevin254/pesapal-python-sdk/issues)

## Disclaimer

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