Skip to main content

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

  1. Add to INSTALLED_APPS:
# settings.py
INSTALLED_APPS = [
    ...
    "django_woohoo",
]
  1. Set environment variables in your .env or 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"
  1. 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 .env support

🧪 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_woohoo-0.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

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

django_woohoo-0.1.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

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

Hashes for django_woohoo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b2976a76f771f695337483c80e69c33aa7ed037a779410d6ccf693f794ed1a5a
MD5 4ce1315a023ed5ed447b0d08cd59ff9c
BLAKE2b-256 782bfba4c75cec40c6f7a894e7fe3bf9905e23ea14eac9439d82180475b013dc

See more details on using hashes here.

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

Hashes for django_woohoo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cca895fcc7193874349ebc97cc831422a379dd0bcd6a8396a069a3afb3bc89c5
MD5 36f615c571edc39486225f49fea29e12
BLAKE2b-256 4f37e65e9072e8283ade551343b161df7d384b695afeff198f0cfa19ef4b877a

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