Metadata-Version: 2.4
Name: wagtail-subscriptions
Version: 0.1.1
Summary: A comprehensive subscription management system for Wagtail CMS
Home-page: https://github.com/wagtail-subscriptions/wagtail-subscriptions
Author: Wagtail Subscriptions Team
Author-email: Wagtail Subscriptions Team <contact@wagtail-subscriptions.org>
License: MIT License
        
        Copyright (c) 2024 Wagtail Subscriptions
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/wagtail-subscriptions/wagtail-subscriptions
Project-URL: Documentation, https://wagtail-subscriptions.readthedocs.io/en/latest/
Project-URL: Repository, https://github.com/wagtail-subscriptions/wagtail-subscriptions
Project-URL: Bug Tracker, https://github.com/wagtail-subscriptions/wagtail-subscriptions/issues
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 4.1
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Wagtail
Classifier: Framework :: Wagtail :: 4
Classifier: Framework :: Wagtail :: 5
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
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: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django<5.0,>=3.2
Requires-Dist: wagtail<6.0,>=4.0
Requires-Dist: python-dateutil>=2.8.0
Requires-Dist: stripe>=5.0.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-django>=4.0; extra == "dev"
Requires-Dist: coverage>=6.0; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Requires-Dist: flake8>=4.0; extra == "dev"
Requires-Dist: pylint>=2.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: bandit>=1.7; extra == "dev"
Requires-Dist: stripe>=5.0; extra == "dev"
Requires-Dist: paypalrestsdk>=1.13; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# Wagtail Subscriptions

[![PyPI version](https://badge.fury.io/py/wagtail-subscriptions.svg)](https://badge.fury.io/py/wagtail-subscriptions)
[![Documentation Status](https://readthedocs.org/projects/wagtail-subscriptions/badge/?version=latest)](https://wagtail-subscriptions.readthedocs.io/en/latest/?badge=latest)
[![Python Version](https://img.shields.io/pypi/pyversions/wagtail-subscriptions.svg)](https://pypi.org/project/wagtail-subscriptions/)
[![Django Version](https://img.shields.io/badge/django-3.2%20%7C%204.2-blue.svg)](https://www.djangoproject.com/)
[![Wagtail Version](https://img.shields.io/badge/wagtail-4.0%20%7C%205.0-teal.svg)](https://wagtail.org/)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)

A comprehensive subscription management system for Wagtail CMS that provides everything you need to build a SaaS application with subscription billing.

📚 **[Read the full documentation](https://wagtail-subscriptions.readthedocs.io/en/latest/)**

## Features

🚀 **Complete Subscription Management**
- Multiple subscription plans with flexible billing periods
- Feature-based access control
- Trial periods and plan upgrades
- Customer portal and billing management
- **Multi-tenant support** (auto-detects django-tenant-schemas)

💳 **Payment Integration**
- Stripe integration (built-in)
- Paddle support
- PayPal integration
- Extensible payment processor architecture

🎛️ **Admin Dashboard**
- Beautiful Wagtail-integrated admin interface
- Plan and feature management
- Customer overview and analytics
- Payment processor configuration
- **Tenant-aware permissions** (works in both single/multi-tenant modes)

🎨 **Frontend Components**
- Responsive pricing tables
- Modern UI with Tailwind CSS
- Customizable templates
- Template tags for easy integration

## Quick Start

### Installation

```bash
pip install wagtail-subscriptions
```

### Settings

Add to your `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
    # ... your apps
    'wagtail_subscriptions',
]
```

Configure payment processors:

```python
WAGTAIL_SUBSCRIPTIONS = {
    'PAYMENT_PROCESSORS': {
        'stripe': {
            'public_key': 'pk_test_...',
            'secret_key': 'sk_test_...',
            'webhook_secret': 'whsec_...',
        }
    }
}
```

### URLs

```python
from django.urls import path, include

urlpatterns = [
    # ... your URLs
    path('subscriptions/', include('wagtail_subscriptions.urls')),
]
```

### Migrate

```bash
python manage.py migrate
python manage.py setup_subscription_permissions
```

## Usage

### Create Subscription Plans

1. Go to Wagtail Admin → Subscriptions → Plans
2. Create your subscription plans with pricing
3. Add modules and features
4. Associate features with plans

### Display Pricing

Use the built-in template tag:

```django
{% load subscription_tags %}
{% price_table %}
```

### Protect Views

```python
from wagtail_subscriptions.permissions.decorators import subscription_required, feature_required

@subscription_required
def my_view(request):
    return render(request, 'my_template.html')

@feature_required('advanced_analytics')
def analytics_view(request):
    return render(request, 'analytics.html')
```

### Check Permissions in Templates

```django
{% load subscription_tags %}

<!-- Works in both single-tenant and multi-tenant modes -->
{% if request|has_feature:'api_access' %}
    <a href="/api/">API Documentation</a>
{% endif %}

<!-- Get subscription info -->
{% subscription_info as sub_info %}
<p>Current Plan: {{ sub_info.plan }}</p>
<p>Subscriber: {{ sub_info.name }} ({{ sub_info.type }})</p>
```

## Documentation

### Models

- **SubscriptionPlan**: Define pricing and billing periods
- **Module**: Organize features into logical groups
- **Feature**: Individual features with quota support
- **PlanFeature**: Associate features with plans
- **Subscription**: User subscriptions and billing
- **Customer**: Extended customer information

### Payment Processors

#### Stripe Setup

1. Create Stripe account
2. Get API keys from dashboard
3. Add webhook endpoint: `/subscriptions/webhooks/stripe/`
4. Configure in Django settings

#### Paddle Setup

1. Create Paddle account
2. Get Vendor ID and Auth Code
3. Configure webhook URL
4. Add to Django settings

### Template Tags

```django
{% load subscription_tags %}

<!-- Basic pricing table -->
{% price_table %}

<!-- Custom options -->
{% price_table show_trial=False highlight_plan="pro" %}

<!-- Check feature access -->
{% if subscription|has_feature:"advanced_reports" %}
    <!-- Feature content -->
{% endif %}
```

### Management Commands

```bash
# Set up permissions
python manage.py setup_subscription_permissions

# Create sample data
python manage.py create_sample_plans

# Sync tenant plans (for multi-tenant setups)
python manage.py sync_tenant_plans
```

## API Reference

### Subscription Model Methods

```python
subscription = request.user.subscriptions.first()

# Check feature access
subscription.has_feature_access('feature_slug')

# Get feature quota
subscription.get_feature_quota('feature_slug')

# Check if active
subscription.is_active

# Check if in trial
subscription.is_trial
```

### Permission Mixins

```python
from wagtail_subscriptions.permissions.mixins import (
    SubscriptionRequiredMixin, 
    FeatureRequiredMixin
)

# Works automatically in both single-tenant and multi-tenant modes
class MyView(FeatureRequiredMixin, TemplateView):
    required_feature = 'advanced_analytics'
    template_name = 'my_template.html'
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request

## License

MIT License - see LICENSE file for details.

## Support

- **Documentation**: https://wagtail-subscriptions.readthedocs.io/en/latest/
- **Issues**: https://github.com/yourusername/wagtail-subscriptions/issues
- **Discussions**: https://github.com/yourusername/wagtail-subscriptions/discussions
- **PyPI**: https://pypi.org/project/wagtail-subscriptions/
