Django client for WooHoo gift card API integration
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_woohoo-0.1.0.tar.gz.
File metadata
- Download URL: django_woohoo-0.1.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2976a76f771f695337483c80e69c33aa7ed037a779410d6ccf693f794ed1a5a
|
|
| MD5 |
4ce1315a023ed5ed447b0d08cd59ff9c
|
|
| BLAKE2b-256 |
782bfba4c75cec40c6f7a894e7fe3bf9905e23ea14eac9439d82180475b013dc
|
File details
Details for the file django_woohoo-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_woohoo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cca895fcc7193874349ebc97cc831422a379dd0bcd6a8396a069a3afb3bc89c5
|
|
| MD5 |
36f615c571edc39486225f49fea29e12
|
|
| BLAKE2b-256 |
4f37e65e9072e8283ade551343b161df7d384b695afeff198f0cfa19ef4b877a
|