wagtail-subscriptions 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wagtail_subscriptions-0.1.0/LICENSE +21 -0
- wagtail_subscriptions-0.1.0/MANIFEST.in +8 -0
- wagtail_subscriptions-0.1.0/PKG-INFO +316 -0
- wagtail_subscriptions-0.1.0/README.md +239 -0
- wagtail_subscriptions-0.1.0/pyproject.toml +129 -0
- wagtail_subscriptions-0.1.0/requirements.txt +4 -0
- wagtail_subscriptions-0.1.0/setup.cfg +4 -0
- wagtail_subscriptions-0.1.0/setup.py +59 -0
- wagtail_subscriptions-0.1.0/tests/test_subscription_lifecycle.py +188 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/__init__.py +8 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/admin/__init__.py +1 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/admin/features.py +40 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/admin/subscription.py +39 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/admin.py +104 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/analytics.py +81 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/apps.py +12 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/context_processors.py +10 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/forms.py +76 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/management/__init__.py +1 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/management/commands/__init__.py +1 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/management/commands/check_expired_subscriptions.py +41 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/management/commands/create_sample_plans.py +247 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/management/commands/setup_subscription_permissions.py +73 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/management/commands/subscription_maintenance.py +95 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/management/commands/sync_subscription_plans.py +43 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/management/commands/sync_tenant_plans.py +102 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/migrations/0001_initial.py +347 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/migrations/0002_invoice_payment_paymentmethod_subscriptiongroup_and_more.py +476 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/migrations/__init__.py +1 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/models/__init__.py +22 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/models/audit.py +94 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/models/core.py +167 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/models/features.py +188 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/models/payments.py +175 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/models/permissions.py +39 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/payments/__init__.py +12 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/payments/base.py +120 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/payments/paddle.py +210 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/payments/paypal.py +169 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/payments/stripe.py +155 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/permissions/__init__.py +0 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/permissions/decorators.py +50 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/permissions/middleware.py +21 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/permissions/mixins.py +56 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/permissions/tenant_manager.py +82 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/services/__init__.py +1 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/services/invoice_service.py +90 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/services/notification_service.py +132 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/settings.py +28 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/signals.py +26 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/admin/analytics.html +85 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/admin/customers.html +151 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/admin/dashboard.html +399 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/admin/features.html +103 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/admin/plan_features.html +190 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/admin/plans.html +72 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/admin/settings.html +337 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/api/subscription_detail.html +20 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/base.html +54 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/components/price_table.html +86 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/components/pricing_cards.html +328 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/pricing/pricing_page.html +116 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/subscription/cancel.html +17 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/subscription/portal.html +178 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/subscription/subscribe.html +114 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/subscription/success.html +101 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/subscription/upgrade.html +26 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templates/wagtail_subscriptions/tags/subscription_status.html +19 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templatetags/__init__.py +1 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/templatetags/subscription_tags.py +65 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/urls.py +73 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/urls_admin.py +21 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/utils.py +103 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/views/__init__.py +10 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/views/admin.py +276 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/views/analytics.py +26 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/views/api.py +75 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/views/plan_features.py +69 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/views/plan_management.py +203 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/views/pricing.py +19 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/views/subscription.py +153 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/views/webhooks.py +234 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions/wagtail_hooks.py +65 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions.egg-info/PKG-INFO +316 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions.egg-info/SOURCES.txt +87 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions.egg-info/dependency_links.txt +1 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions.egg-info/not-zip-safe +1 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions.egg-info/requires.txt +17 -0
- wagtail_subscriptions-0.1.0/wagtail_subscriptions.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Wagtail Subscriptions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include requirements.txt
|
|
4
|
+
recursive-include wagtail_subscriptions/templates *
|
|
5
|
+
recursive-include wagtail_subscriptions/static *
|
|
6
|
+
recursive-include wagtail_subscriptions/migrations *
|
|
7
|
+
recursive-exclude * __pycache__
|
|
8
|
+
recursive-exclude * *.py[co]
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wagtail-subscriptions
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A comprehensive subscription management system for Wagtail CMS
|
|
5
|
+
Home-page: https://github.com/wagtail-subscriptions/wagtail-subscriptions
|
|
6
|
+
Author: Wagtail Subscriptions Team
|
|
7
|
+
Author-email: Wagtail Subscriptions Team <contact@wagtail-subscriptions.org>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2024 Wagtail Subscriptions
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
Project-URL: Homepage, https://github.com/wagtail-subscriptions/wagtail-subscriptions
|
|
30
|
+
Project-URL: Documentation, https://wagtail-subscriptions.readthedocs.io/
|
|
31
|
+
Project-URL: Repository, https://github.com/wagtail-subscriptions/wagtail-subscriptions
|
|
32
|
+
Project-URL: Bug Tracker, https://github.com/wagtail-subscriptions/wagtail-subscriptions/issues
|
|
33
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
34
|
+
Classifier: Environment :: Web Environment
|
|
35
|
+
Classifier: Framework :: Django
|
|
36
|
+
Classifier: Framework :: Django :: 3.2
|
|
37
|
+
Classifier: Framework :: Django :: 4.0
|
|
38
|
+
Classifier: Framework :: Django :: 4.1
|
|
39
|
+
Classifier: Framework :: Django :: 4.2
|
|
40
|
+
Classifier: Framework :: Wagtail
|
|
41
|
+
Classifier: Framework :: Wagtail :: 4
|
|
42
|
+
Classifier: Framework :: Wagtail :: 5
|
|
43
|
+
Classifier: Intended Audience :: Developers
|
|
44
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
45
|
+
Classifier: Operating System :: OS Independent
|
|
46
|
+
Classifier: Programming Language :: Python
|
|
47
|
+
Classifier: Programming Language :: Python :: 3
|
|
48
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
49
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
50
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
51
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
52
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
53
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
54
|
+
Requires-Python: >=3.8
|
|
55
|
+
Description-Content-Type: text/markdown
|
|
56
|
+
License-File: LICENSE
|
|
57
|
+
Requires-Dist: Django<5.0,>=3.2
|
|
58
|
+
Requires-Dist: wagtail<6.0,>=4.0
|
|
59
|
+
Requires-Dist: python-dateutil>=2.8.0
|
|
60
|
+
Requires-Dist: stripe>=5.0.0
|
|
61
|
+
Provides-Extra: dev
|
|
62
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
63
|
+
Requires-Dist: pytest-django>=4.0; extra == "dev"
|
|
64
|
+
Requires-Dist: coverage>=6.0; extra == "dev"
|
|
65
|
+
Requires-Dist: black>=22.0; extra == "dev"
|
|
66
|
+
Requires-Dist: isort>=5.0; extra == "dev"
|
|
67
|
+
Requires-Dist: flake8>=4.0; extra == "dev"
|
|
68
|
+
Requires-Dist: pylint>=2.0; extra == "dev"
|
|
69
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
70
|
+
Requires-Dist: bandit>=1.7; extra == "dev"
|
|
71
|
+
Requires-Dist: stripe>=5.0; extra == "dev"
|
|
72
|
+
Requires-Dist: paypalrestsdk>=1.13; extra == "dev"
|
|
73
|
+
Dynamic: author
|
|
74
|
+
Dynamic: home-page
|
|
75
|
+
Dynamic: license-file
|
|
76
|
+
Dynamic: requires-python
|
|
77
|
+
|
|
78
|
+
# Wagtail Subscriptions
|
|
79
|
+
|
|
80
|
+
A comprehensive subscription management system for Wagtail CMS that provides everything you need to build a SaaS application with subscription billing.
|
|
81
|
+
|
|
82
|
+
## Features
|
|
83
|
+
|
|
84
|
+
🚀 **Complete Subscription Management**
|
|
85
|
+
- Multiple subscription plans with flexible billing periods
|
|
86
|
+
- Feature-based access control
|
|
87
|
+
- Trial periods and plan upgrades
|
|
88
|
+
- Customer portal and billing management
|
|
89
|
+
- **Multi-tenant support** (auto-detects django-tenant-schemas)
|
|
90
|
+
|
|
91
|
+
💳 **Payment Integration**
|
|
92
|
+
- Stripe integration (built-in)
|
|
93
|
+
- Paddle support
|
|
94
|
+
- PayPal integration
|
|
95
|
+
- Extensible payment processor architecture
|
|
96
|
+
|
|
97
|
+
🎛️ **Admin Dashboard**
|
|
98
|
+
- Beautiful Wagtail-integrated admin interface
|
|
99
|
+
- Plan and feature management
|
|
100
|
+
- Customer overview and analytics
|
|
101
|
+
- Payment processor configuration
|
|
102
|
+
- **Tenant-aware permissions** (works in both single/multi-tenant modes)
|
|
103
|
+
|
|
104
|
+
🎨 **Frontend Components**
|
|
105
|
+
- Responsive pricing tables
|
|
106
|
+
- Modern UI with Tailwind CSS
|
|
107
|
+
- Customizable templates
|
|
108
|
+
- Template tags for easy integration
|
|
109
|
+
|
|
110
|
+
## Quick Start
|
|
111
|
+
|
|
112
|
+
### Installation
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
pip install wagtail-subscriptions
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Settings
|
|
119
|
+
|
|
120
|
+
Add to your `INSTALLED_APPS`:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
INSTALLED_APPS = [
|
|
124
|
+
# ... your apps
|
|
125
|
+
'wagtail_subscriptions',
|
|
126
|
+
]
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Configure payment processors:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
WAGTAIL_SUBSCRIPTIONS = {
|
|
133
|
+
'PAYMENT_PROCESSORS': {
|
|
134
|
+
'stripe': {
|
|
135
|
+
'public_key': 'pk_test_...',
|
|
136
|
+
'secret_key': 'sk_test_...',
|
|
137
|
+
'webhook_secret': 'whsec_...',
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### URLs
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from django.urls import path, include
|
|
147
|
+
|
|
148
|
+
urlpatterns = [
|
|
149
|
+
# ... your URLs
|
|
150
|
+
path('subscriptions/', include('wagtail_subscriptions.urls')),
|
|
151
|
+
]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Migrate
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
python manage.py migrate
|
|
158
|
+
python manage.py setup_subscription_permissions
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Usage
|
|
162
|
+
|
|
163
|
+
### Create Subscription Plans
|
|
164
|
+
|
|
165
|
+
1. Go to Wagtail Admin → Subscriptions → Plans
|
|
166
|
+
2. Create your subscription plans with pricing
|
|
167
|
+
3. Add modules and features
|
|
168
|
+
4. Associate features with plans
|
|
169
|
+
|
|
170
|
+
### Display Pricing
|
|
171
|
+
|
|
172
|
+
Use the built-in template tag:
|
|
173
|
+
|
|
174
|
+
```django
|
|
175
|
+
{% load subscription_tags %}
|
|
176
|
+
{% price_table %}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Protect Views
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from wagtail_subscriptions.permissions.decorators import subscription_required, feature_required
|
|
183
|
+
|
|
184
|
+
@subscription_required
|
|
185
|
+
def my_view(request):
|
|
186
|
+
return render(request, 'my_template.html')
|
|
187
|
+
|
|
188
|
+
@feature_required('advanced_analytics')
|
|
189
|
+
def analytics_view(request):
|
|
190
|
+
return render(request, 'analytics.html')
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Check Permissions in Templates
|
|
194
|
+
|
|
195
|
+
```django
|
|
196
|
+
{% load subscription_tags %}
|
|
197
|
+
|
|
198
|
+
<!-- Works in both single-tenant and multi-tenant modes -->
|
|
199
|
+
{% if request|has_feature:'api_access' %}
|
|
200
|
+
<a href="/api/">API Documentation</a>
|
|
201
|
+
{% endif %}
|
|
202
|
+
|
|
203
|
+
<!-- Get subscription info -->
|
|
204
|
+
{% subscription_info as sub_info %}
|
|
205
|
+
<p>Current Plan: {{ sub_info.plan }}</p>
|
|
206
|
+
<p>Subscriber: {{ sub_info.name }} ({{ sub_info.type }})</p>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Documentation
|
|
210
|
+
|
|
211
|
+
### Models
|
|
212
|
+
|
|
213
|
+
- **SubscriptionPlan**: Define pricing and billing periods
|
|
214
|
+
- **Module**: Organize features into logical groups
|
|
215
|
+
- **Feature**: Individual features with quota support
|
|
216
|
+
- **PlanFeature**: Associate features with plans
|
|
217
|
+
- **Subscription**: User subscriptions and billing
|
|
218
|
+
- **Customer**: Extended customer information
|
|
219
|
+
|
|
220
|
+
### Payment Processors
|
|
221
|
+
|
|
222
|
+
#### Stripe Setup
|
|
223
|
+
|
|
224
|
+
1. Create Stripe account
|
|
225
|
+
2. Get API keys from dashboard
|
|
226
|
+
3. Add webhook endpoint: `/subscriptions/webhooks/stripe/`
|
|
227
|
+
4. Configure in Django settings
|
|
228
|
+
|
|
229
|
+
#### Paddle Setup
|
|
230
|
+
|
|
231
|
+
1. Create Paddle account
|
|
232
|
+
2. Get Vendor ID and Auth Code
|
|
233
|
+
3. Configure webhook URL
|
|
234
|
+
4. Add to Django settings
|
|
235
|
+
|
|
236
|
+
### Template Tags
|
|
237
|
+
|
|
238
|
+
```django
|
|
239
|
+
{% load subscription_tags %}
|
|
240
|
+
|
|
241
|
+
<!-- Basic pricing table -->
|
|
242
|
+
{% price_table %}
|
|
243
|
+
|
|
244
|
+
<!-- Custom options -->
|
|
245
|
+
{% price_table show_trial=False highlight_plan="pro" %}
|
|
246
|
+
|
|
247
|
+
<!-- Check feature access -->
|
|
248
|
+
{% if subscription|has_feature:"advanced_reports" %}
|
|
249
|
+
<!-- Feature content -->
|
|
250
|
+
{% endif %}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Management Commands
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# Set up permissions
|
|
257
|
+
python manage.py setup_subscription_permissions
|
|
258
|
+
|
|
259
|
+
# Create sample data
|
|
260
|
+
python manage.py create_sample_plans
|
|
261
|
+
|
|
262
|
+
# Sync tenant plans (for multi-tenant setups)
|
|
263
|
+
python manage.py sync_tenant_plans
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## API Reference
|
|
267
|
+
|
|
268
|
+
### Subscription Model Methods
|
|
269
|
+
|
|
270
|
+
```python
|
|
271
|
+
subscription = request.user.subscriptions.first()
|
|
272
|
+
|
|
273
|
+
# Check feature access
|
|
274
|
+
subscription.has_feature_access('feature_slug')
|
|
275
|
+
|
|
276
|
+
# Get feature quota
|
|
277
|
+
subscription.get_feature_quota('feature_slug')
|
|
278
|
+
|
|
279
|
+
# Check if active
|
|
280
|
+
subscription.is_active
|
|
281
|
+
|
|
282
|
+
# Check if in trial
|
|
283
|
+
subscription.is_trial
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Permission Mixins
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
from wagtail_subscriptions.permissions.mixins import (
|
|
290
|
+
SubscriptionRequiredMixin,
|
|
291
|
+
FeatureRequiredMixin
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
# Works automatically in both single-tenant and multi-tenant modes
|
|
295
|
+
class MyView(FeatureRequiredMixin, TemplateView):
|
|
296
|
+
required_feature = 'advanced_analytics'
|
|
297
|
+
template_name = 'my_template.html'
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## Contributing
|
|
301
|
+
|
|
302
|
+
1. Fork the repository
|
|
303
|
+
2. Create a feature branch
|
|
304
|
+
3. Make your changes
|
|
305
|
+
4. Add tests
|
|
306
|
+
5. Submit a pull request
|
|
307
|
+
|
|
308
|
+
## License
|
|
309
|
+
|
|
310
|
+
MIT License - see LICENSE file for details.
|
|
311
|
+
|
|
312
|
+
## Support
|
|
313
|
+
|
|
314
|
+
- Documentation: https://wagtail-subscriptions.readthedocs.io/
|
|
315
|
+
- Issues: https://github.com/yourusername/wagtail-subscriptions/issues
|
|
316
|
+
- Discussions: https://github.com/yourusername/wagtail-subscriptions/discussions
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Wagtail Subscriptions
|
|
2
|
+
|
|
3
|
+
A comprehensive subscription management system for Wagtail CMS that provides everything you need to build a SaaS application with subscription billing.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
🚀 **Complete Subscription Management**
|
|
8
|
+
- Multiple subscription plans with flexible billing periods
|
|
9
|
+
- Feature-based access control
|
|
10
|
+
- Trial periods and plan upgrades
|
|
11
|
+
- Customer portal and billing management
|
|
12
|
+
- **Multi-tenant support** (auto-detects django-tenant-schemas)
|
|
13
|
+
|
|
14
|
+
💳 **Payment Integration**
|
|
15
|
+
- Stripe integration (built-in)
|
|
16
|
+
- Paddle support
|
|
17
|
+
- PayPal integration
|
|
18
|
+
- Extensible payment processor architecture
|
|
19
|
+
|
|
20
|
+
🎛️ **Admin Dashboard**
|
|
21
|
+
- Beautiful Wagtail-integrated admin interface
|
|
22
|
+
- Plan and feature management
|
|
23
|
+
- Customer overview and analytics
|
|
24
|
+
- Payment processor configuration
|
|
25
|
+
- **Tenant-aware permissions** (works in both single/multi-tenant modes)
|
|
26
|
+
|
|
27
|
+
🎨 **Frontend Components**
|
|
28
|
+
- Responsive pricing tables
|
|
29
|
+
- Modern UI with Tailwind CSS
|
|
30
|
+
- Customizable templates
|
|
31
|
+
- Template tags for easy integration
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
### Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install wagtail-subscriptions
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Settings
|
|
42
|
+
|
|
43
|
+
Add to your `INSTALLED_APPS`:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
INSTALLED_APPS = [
|
|
47
|
+
# ... your apps
|
|
48
|
+
'wagtail_subscriptions',
|
|
49
|
+
]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Configure payment processors:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
WAGTAIL_SUBSCRIPTIONS = {
|
|
56
|
+
'PAYMENT_PROCESSORS': {
|
|
57
|
+
'stripe': {
|
|
58
|
+
'public_key': 'pk_test_...',
|
|
59
|
+
'secret_key': 'sk_test_...',
|
|
60
|
+
'webhook_secret': 'whsec_...',
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### URLs
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from django.urls import path, include
|
|
70
|
+
|
|
71
|
+
urlpatterns = [
|
|
72
|
+
# ... your URLs
|
|
73
|
+
path('subscriptions/', include('wagtail_subscriptions.urls')),
|
|
74
|
+
]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Migrate
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python manage.py migrate
|
|
81
|
+
python manage.py setup_subscription_permissions
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
### Create Subscription Plans
|
|
87
|
+
|
|
88
|
+
1. Go to Wagtail Admin → Subscriptions → Plans
|
|
89
|
+
2. Create your subscription plans with pricing
|
|
90
|
+
3. Add modules and features
|
|
91
|
+
4. Associate features with plans
|
|
92
|
+
|
|
93
|
+
### Display Pricing
|
|
94
|
+
|
|
95
|
+
Use the built-in template tag:
|
|
96
|
+
|
|
97
|
+
```django
|
|
98
|
+
{% load subscription_tags %}
|
|
99
|
+
{% price_table %}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Protect Views
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from wagtail_subscriptions.permissions.decorators import subscription_required, feature_required
|
|
106
|
+
|
|
107
|
+
@subscription_required
|
|
108
|
+
def my_view(request):
|
|
109
|
+
return render(request, 'my_template.html')
|
|
110
|
+
|
|
111
|
+
@feature_required('advanced_analytics')
|
|
112
|
+
def analytics_view(request):
|
|
113
|
+
return render(request, 'analytics.html')
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Check Permissions in Templates
|
|
117
|
+
|
|
118
|
+
```django
|
|
119
|
+
{% load subscription_tags %}
|
|
120
|
+
|
|
121
|
+
<!-- Works in both single-tenant and multi-tenant modes -->
|
|
122
|
+
{% if request|has_feature:'api_access' %}
|
|
123
|
+
<a href="/api/">API Documentation</a>
|
|
124
|
+
{% endif %}
|
|
125
|
+
|
|
126
|
+
<!-- Get subscription info -->
|
|
127
|
+
{% subscription_info as sub_info %}
|
|
128
|
+
<p>Current Plan: {{ sub_info.plan }}</p>
|
|
129
|
+
<p>Subscriber: {{ sub_info.name }} ({{ sub_info.type }})</p>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Documentation
|
|
133
|
+
|
|
134
|
+
### Models
|
|
135
|
+
|
|
136
|
+
- **SubscriptionPlan**: Define pricing and billing periods
|
|
137
|
+
- **Module**: Organize features into logical groups
|
|
138
|
+
- **Feature**: Individual features with quota support
|
|
139
|
+
- **PlanFeature**: Associate features with plans
|
|
140
|
+
- **Subscription**: User subscriptions and billing
|
|
141
|
+
- **Customer**: Extended customer information
|
|
142
|
+
|
|
143
|
+
### Payment Processors
|
|
144
|
+
|
|
145
|
+
#### Stripe Setup
|
|
146
|
+
|
|
147
|
+
1. Create Stripe account
|
|
148
|
+
2. Get API keys from dashboard
|
|
149
|
+
3. Add webhook endpoint: `/subscriptions/webhooks/stripe/`
|
|
150
|
+
4. Configure in Django settings
|
|
151
|
+
|
|
152
|
+
#### Paddle Setup
|
|
153
|
+
|
|
154
|
+
1. Create Paddle account
|
|
155
|
+
2. Get Vendor ID and Auth Code
|
|
156
|
+
3. Configure webhook URL
|
|
157
|
+
4. Add to Django settings
|
|
158
|
+
|
|
159
|
+
### Template Tags
|
|
160
|
+
|
|
161
|
+
```django
|
|
162
|
+
{% load subscription_tags %}
|
|
163
|
+
|
|
164
|
+
<!-- Basic pricing table -->
|
|
165
|
+
{% price_table %}
|
|
166
|
+
|
|
167
|
+
<!-- Custom options -->
|
|
168
|
+
{% price_table show_trial=False highlight_plan="pro" %}
|
|
169
|
+
|
|
170
|
+
<!-- Check feature access -->
|
|
171
|
+
{% if subscription|has_feature:"advanced_reports" %}
|
|
172
|
+
<!-- Feature content -->
|
|
173
|
+
{% endif %}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Management Commands
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Set up permissions
|
|
180
|
+
python manage.py setup_subscription_permissions
|
|
181
|
+
|
|
182
|
+
# Create sample data
|
|
183
|
+
python manage.py create_sample_plans
|
|
184
|
+
|
|
185
|
+
# Sync tenant plans (for multi-tenant setups)
|
|
186
|
+
python manage.py sync_tenant_plans
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## API Reference
|
|
190
|
+
|
|
191
|
+
### Subscription Model Methods
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
subscription = request.user.subscriptions.first()
|
|
195
|
+
|
|
196
|
+
# Check feature access
|
|
197
|
+
subscription.has_feature_access('feature_slug')
|
|
198
|
+
|
|
199
|
+
# Get feature quota
|
|
200
|
+
subscription.get_feature_quota('feature_slug')
|
|
201
|
+
|
|
202
|
+
# Check if active
|
|
203
|
+
subscription.is_active
|
|
204
|
+
|
|
205
|
+
# Check if in trial
|
|
206
|
+
subscription.is_trial
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Permission Mixins
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
from wagtail_subscriptions.permissions.mixins import (
|
|
213
|
+
SubscriptionRequiredMixin,
|
|
214
|
+
FeatureRequiredMixin
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
# Works automatically in both single-tenant and multi-tenant modes
|
|
218
|
+
class MyView(FeatureRequiredMixin, TemplateView):
|
|
219
|
+
required_feature = 'advanced_analytics'
|
|
220
|
+
template_name = 'my_template.html'
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Contributing
|
|
224
|
+
|
|
225
|
+
1. Fork the repository
|
|
226
|
+
2. Create a feature branch
|
|
227
|
+
3. Make your changes
|
|
228
|
+
4. Add tests
|
|
229
|
+
5. Submit a pull request
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT License - see LICENSE file for details.
|
|
234
|
+
|
|
235
|
+
## Support
|
|
236
|
+
|
|
237
|
+
- Documentation: https://wagtail-subscriptions.readthedocs.io/
|
|
238
|
+
- Issues: https://github.com/yourusername/wagtail-subscriptions/issues
|
|
239
|
+
- Discussions: https://github.com/yourusername/wagtail-subscriptions/discussions
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=45", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "wagtail-subscriptions"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A comprehensive subscription management system for Wagtail CMS"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {file = "LICENSE"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Wagtail Subscriptions Team", email = "contact@wagtail-subscriptions.org"}
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Environment :: Web Environment",
|
|
17
|
+
"Framework :: Django",
|
|
18
|
+
"Framework :: Django :: 3.2",
|
|
19
|
+
"Framework :: Django :: 4.0",
|
|
20
|
+
"Framework :: Django :: 4.1",
|
|
21
|
+
"Framework :: Django :: 4.2",
|
|
22
|
+
"Framework :: Wagtail",
|
|
23
|
+
"Framework :: Wagtail :: 4",
|
|
24
|
+
"Framework :: Wagtail :: 5",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"License :: OSI Approved :: MIT License",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Programming Language :: Python",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3.8",
|
|
31
|
+
"Programming Language :: Python :: 3.9",
|
|
32
|
+
"Programming Language :: Python :: 3.10",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
35
|
+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
|
|
36
|
+
]
|
|
37
|
+
requires-python = ">=3.8"
|
|
38
|
+
dependencies = [
|
|
39
|
+
"Django>=3.2,<5.0",
|
|
40
|
+
"wagtail>=4.0,<6.0",
|
|
41
|
+
"python-dateutil>=2.8.0",
|
|
42
|
+
"stripe>=5.0.0",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.optional-dependencies]
|
|
46
|
+
dev = [
|
|
47
|
+
"pytest>=6.0",
|
|
48
|
+
"pytest-django>=4.0",
|
|
49
|
+
"coverage>=6.0",
|
|
50
|
+
"black>=22.0",
|
|
51
|
+
"isort>=5.0",
|
|
52
|
+
"flake8>=4.0",
|
|
53
|
+
"pylint>=2.0",
|
|
54
|
+
"mypy>=1.0",
|
|
55
|
+
"bandit>=1.7",
|
|
56
|
+
"stripe>=5.0",
|
|
57
|
+
"paypalrestsdk>=1.13",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[project.urls]
|
|
61
|
+
Homepage = "https://github.com/wagtail-subscriptions/wagtail-subscriptions"
|
|
62
|
+
Documentation = "https://wagtail-subscriptions.readthedocs.io/"
|
|
63
|
+
Repository = "https://github.com/wagtail-subscriptions/wagtail-subscriptions"
|
|
64
|
+
"Bug Tracker" = "https://github.com/wagtail-subscriptions/wagtail-subscriptions/issues"
|
|
65
|
+
|
|
66
|
+
[tool.setuptools.packages.find]
|
|
67
|
+
include = ["wagtail_subscriptions*"]
|
|
68
|
+
|
|
69
|
+
[tool.setuptools.package-data]
|
|
70
|
+
wagtail_subscriptions = [
|
|
71
|
+
"templates/**/*",
|
|
72
|
+
"static/**/*",
|
|
73
|
+
"migrations/**/*",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[tool.black]
|
|
77
|
+
line-length = 100
|
|
78
|
+
target-version = ['py38', 'py39', 'py310', 'py311']
|
|
79
|
+
include = '\.pyi?$'
|
|
80
|
+
extend-exclude = '''
|
|
81
|
+
/(
|
|
82
|
+
# directories
|
|
83
|
+
\.eggs
|
|
84
|
+
| \.git
|
|
85
|
+
| \.hg
|
|
86
|
+
| \.mypy_cache
|
|
87
|
+
| \.tox
|
|
88
|
+
| \.venv
|
|
89
|
+
| build
|
|
90
|
+
| dist
|
|
91
|
+
| migrations
|
|
92
|
+
)/
|
|
93
|
+
'''
|
|
94
|
+
|
|
95
|
+
[tool.isort]
|
|
96
|
+
profile = "black"
|
|
97
|
+
line_length = 100
|
|
98
|
+
multi_line_output = 3
|
|
99
|
+
include_trailing_comma = true
|
|
100
|
+
force_grid_wrap = 0
|
|
101
|
+
use_parentheses = true
|
|
102
|
+
ensure_newline_before_comments = true
|
|
103
|
+
skip_glob = ["*/migrations/*", "*/venv/*", "*/.venv/*"]
|
|
104
|
+
|
|
105
|
+
[tool.pylint.messages_control]
|
|
106
|
+
disable = [
|
|
107
|
+
"C0111", # missing-docstring
|
|
108
|
+
"C0103", # invalid-name
|
|
109
|
+
"R0903", # too-few-public-methods
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
[tool.pylint.format]
|
|
113
|
+
max-line-length = 100
|
|
114
|
+
|
|
115
|
+
[tool.mypy]
|
|
116
|
+
python_version = "3.8"
|
|
117
|
+
warn_return_any = true
|
|
118
|
+
warn_unused_configs = true
|
|
119
|
+
ignore_missing_imports = true
|
|
120
|
+
exclude = ["migrations/", "venv/", ".venv/"]
|
|
121
|
+
|
|
122
|
+
[tool.pytest.ini_options]
|
|
123
|
+
pythonpath = "."
|
|
124
|
+
testpaths = ["tests"]
|
|
125
|
+
DJANGO_SETTINGS_MODULE = "test_settings"
|
|
126
|
+
python_files = ["test_*.py", "*_test.py"]
|
|
127
|
+
python_classes = ["Test*"]
|
|
128
|
+
python_functions = ["test_*"]
|
|
129
|
+
addopts = "-v --tb=short --strict-markers"
|