Django WooHoo
Django WooHoo is a Django-compatible client library to securely integrate with the WooHoo API for initiating Amazon (and Flipkart-ready) coupon-based payouts. This library handles token management, signature generation, transaction processing, and audit logging.
✨ Features
- 🔐 Secure handling of WooHoo authorization and bearer tokens
- 🔁 Automatic token caching with auto-refresh after expiry (6 days)
- 📦 Supports Amazon coupon disbursement via API
- 🧾 Logs every API request and response for traceability
- 🧱 Designed to integrate seamlessly with Django user models
📦 Installation
pip install django-woohoo # (when published to PyPI)
Or use it locally:
pip install -e /path/to/django_woohoo
⚙️ Setup
- Add to
INSTALLED_APPS:
# settings.py
INSTALLED_APPS = [
...
"django_woohoo",
]
- Set environment variables in your
.envor system environment:
WOOHOO_BASE_URL="https://your-woohoo-api-endpoint.com"
WOOHOO_CLIENT_ID="your-client-id"
WOOHOO_CLIENT_SECRET="your-client-secret"
WOOHOO_USERNAME="your-username"
WOOHOO_PASSWORD="your-password"
- Apply migrations:
python manage.py makemigrations django_woohoo
python manage.py migrate
🧩 Usage
Step 1: Prepare the input data
from django_woohoo.dataclasses import (
PaymentBeneficiaryDetails,
PaymentInitiateTransactionDataClass
)
beneficiary = PaymentBeneficiaryDetails(
beneficiary_name="John Doe",
beneficiary_email="john@example.com",
beneficiary_phone="9999999999"
)
transaction_data = PaymentInitiateTransactionDataClass(
transfer_amount=500,
beneficiary_details=beneficiary
)
Step 2: Use the AmazonCouponClient to process payment
from django_woohoo.client import AmazonCouponClient
# `user` should be a Django user instance
client = AmazonCouponClient(user=user)
status, response = client.process_amount(
data=transaction_data,
sku_code="AMZ-500" # example SKU from WooHoo
)
print(status) # 200 on success
print(response) # Response JSON from WooHoo
🧠 Internals
Models
- PlatformToken: Caches WooHoo authorization and bearer tokens per platform
- PlatformPaymentRequestLog: Logs every request/response made to WooHoo with user context
Helpers
- WoohooSignatureGeneratorHelper: Generates HMAC SHA512-compliant request signatures
- get_env_variable: Robust environment variable loader with
.envsupport
🧪 Admin Usage (Optional)
You may optionally register PlatformToken and PlatformPaymentRequestLog in the Django admin to monitor token and request data.
✅ TODO
- Add Flipkart coupon support
- Admin dashboards for logs
- Retry support for failed requests
- Custom exceptions and error classes
📝 License
MIT License
🤝 Contributing
Feel free to fork, enhance, or raise issues. Pull requests welcome!
📬 Contact
For integration help or issues, open an issue or contact the maintainer.
Metadata
Release files for django-woohoo 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_woohoo-0.1.0.tar.gz | 12.4 kB | Without provenance | Details for django_woohoo-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_woohoo-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for django_woohoo-0.1.0-py3-none-any.whl |
Total release size: 25.7 kB
Release files / django_woohoo-0.1.0.tar.gz
| Download URL | django_woohoo-0.1.0.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2976a76f771f695337483c80e69c33aa7ed037a779410d6ccf693f794ed1a5a
|
|
BLAKE2b-256 checksum How to use checksums |
782bfba4c75cec40c6f7a894e7fe3bf9905e23ea14eac9439d82180475b013dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / django_woohoo-0.1.0-py3-none-any.whl
| Download URL | django_woohoo-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cca895fcc7193874349ebc97cc831422a379dd0bcd6a8396a069a3afb3bc89c5
|
|
BLAKE2b-256 checksum How to use checksums |
4f37e65e9072e8283ade551343b161df7d384b695afeff198f0cfa19ef4b877a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for django-woohoo 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.