django-stripe-marketplace
Production-grade Django app for Stripe marketplace integration with multi-tenant support, webhook handling, and comprehensive audit logging.
Features
- Multi-tenant Support: Manage multiple Stripe accounts from a single Django application
- Webhook Handling: Secure webhook processing with HMAC-SHA256 signature verification
- Subscription Management: Full subscription lifecycle management with trial support
- Payment Processing: Payment intent handling with automatic retries
- Audit Logging: Comprehensive audit trail for all Stripe operations
- Idempotency: Built-in idempotency key generation for safe API calls
- Async Processing: Celery tasks for background synchronization
- Bidirectional Sync: Keep your database in sync with Stripe
Installation
pip install django-stripe-marketplace
Add to your Django settings:
INSTALLED_APPS = [
# ...
'stripe_marketplace',
]
STRIPE_MARKETPLACE = {
'SECRET_KEY': 'sk_test_your_stripe_secret_key',
'PUBLISHABLE_KEY': 'pk_test_your_stripe_publishable_key',
'WEBHOOK_SECRET': 'whsec_your_webhook_secret',
'API_VERSION': '2024-04-10',
'CURRENCY': 'usd',
}
Run migrations:
python manage.py migrate stripe_marketplace
Quick Start
Setting Up Your Account
python manage.py setup_stripe --account-id acct_your_account_id --business-name "Your Business"
Creating a Customer
from stripe_marketplace.client import StripeClient
from stripe_marketplace.settings import settings_module
client = StripeClient(api_key=settings_module.SECRET_KEY)
customer = client.create_customer(email="customer@example.com")
Syncing Data
python manage.py sync_stripe --account-id acct_your_account_id
Handling Webhooks
Add to your URL configuration:
from django.urls import path, include
urlpatterns = [
path('stripe/', include('stripe_marketplace.urls')),
]
Configuration
Required Settings
| Setting | Description |
|---|---|
SECRET_KEY |
Stripe API secret key |
WEBHOOK_SECRET |
Stripe webhook signing secret |
Optional Settings
| Setting | Default | Description |
|---|---|---|
PUBLISHABLE_KEY |
"" |
Stripe publishable key |
API_VERSION |
"2024-04-10" |
Stripe API version |
CURRENCY |
"usd" |
Default currency |
SUBSCRIPTION_TRIAL_DAYS |
0 |
Default trial period |
ENABLE_WEBHOOK_LOGGING |
True |
Enable webhook logging |
MAX_WEBHOOK_AGE_HOURS |
24 |
Maximum webhook age |
Models
StripeAccount: Stripe account configurationStripeCustomer: Customer linked to Django userStripeProduct: Stripe productStripePlan: Subscription planStripeSubscription: SubscriptionStripeInvoice: InvoiceStripePaymentIntent: Payment intentWebhookEvent: Received webhook eventsAuditLog: Audit trail
Development
# Clone the repository
git clone https://github.com/mojnomiya/django-stripe-marketplace.git
cd django-stripe-marketplace
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
flake8 src/
black src/
isort src/
License
MIT License - see LICENSE for details.
Metadata
Release files for django-stripe-marketplace 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 | |
|---|---|---|---|
| django_stripe_marketplace-0.1.0.tar.gz | 26.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_stripe_marketplace-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.6 kB
Release files / django_stripe_marketplace-0.1.0.tar.gz
| Download URL | django_stripe_marketplace-0.1.0.tar.gz |
|---|---|
| Size | 26.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d542e6ca8aea0585e1cb03c4c5b86c0bdbbef0be463c2633ba220b3671aaa65
|
|
BLAKE2b-256 checksum How to use checksums |
d27c5d59a6019de853fa30b694657349c77477669ec7a780c2a795d3c74d832d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / django_stripe_marketplace-0.1.0-py3-none-any.whl
| Download URL | django_stripe_marketplace-0.1.0-py3-none-any.whl |
|---|---|
| Size | 24.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e18861aaeb9c016887938da02d097de97f0f071c235667c830a611561f545ea
|
|
BLAKE2b-256 checksum How to use checksums |
b1b62001923324e75cf8c1ce8880de364ddb4b521d539fa1f9da8b7c6c73a446
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|